smart-home-engine 1.8.1 → 1.9.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,230 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jsonMode-CXWNuhmR.js","assets/monaco-langs-BW2J83t5.js","assets/monaco-langs-DyX1CsEw.css","assets/tsMode-DK6XHYAS.js"])))=>i.map(i=>d[i]);
2
- var zA=Object.defineProperty;var lL=o=>{throw TypeError(o)};var VA=(o,e,t)=>e in o?zA(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var yn=(o,e,t)=>VA(o,typeof e!="symbol"?e+"":e,t),yw=(o,e,t)=>e.has(o)||lL("Cannot "+t);var be=(o,e,t)=>(yw(o,e,"read from private field"),t?t.call(o):e.get(o)),gn=(o,e,t)=>e.has(o)?lL("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(o):e.set(o,t),pn=(o,e,t,i)=>(yw(o,e,"write to private field"),i?i.call(o,t):e.set(o,t),t),zn=(o,e,t)=>(yw(o,e,"access private method"),t);import{_ as AD,m as OD,l as ui,A as yo,C as Ae,I as Un,D as o_,a as as,g as FD,M as Gt,b as ji,E as ca,c as B,r as Tn,d as Nr,e as C,f as jA,h as Wn,R as _n,S as Fi,i as to,j as Ar,k as Sn,n as nn,o as xe,p as lt,K as us,q as oi,s as Dt,t as Ss,u as Z,v as dn,O as Ha,w as _s,P as gi,x as ww,y as r_,z as HD,B as pl,F as da,G as wS,H as Ws,U as Pn,J as uf,L as pi,N as wl,Q as $A,T as go,V as SS,W as UA,X as WD,$ as si,Y as xn,Z as wn,a0 as Zn,a1 as Zi,a2 as Go,a3 as dp,a4 as Lt,a5 as Dm,a6 as qA,a7 as GA,a8 as ws,a9 as KA,aa as ua,ab as wo,ac as bi,ad as BD,ae as jn,af as ZA,ag as YA,ah as mo,ai as zf,aj as hs,ak as my,al as co,am as Bc,an as Zx,ao as vy,ap as Os,aq as hf,ar as Fs,as as by,at as yy,au as XA,av as a_,aw as Vf,ax as Ml,ay as QA,az as jf,aA as JA,aB as Yx,aC as e2,aD as t2,aE as cL,aF as rs,aG as _l,aH as uo,aI as Qi,aJ as dl,aK as i2,aL as Va,aM as $o,aN as Es,aO as ha,aP as Xx,aQ as Cs,aR as is,aS as tv,aT as Xi,aU as zD,aV as n2,aW as Qx,aX as wy,aY as Jx,aZ as e0,a_ as bd,a$ as s2,b0 as t0,b1 as o2,b2 as i0,b3 as Rl,b4 as Nl,b5 as ff,b6 as up,b7 as Mo,b8 as l_,b9 as iv,ba as Sw,bb as Nn,bc as n0,bd as c_,be as Sy,bf as r2,bg as VD,bh as hp,bi as gf,bj as fp,bk as d_,bl as Cy,bm as Cn,bn as zc,bo as u_,bp as a2,bq as l2,br as s0,bs as c2,bt as nv,bu as ur,bv as o0,bw as pf,bx as Al,by as $f,bz as cn,bA as _f,bB as jD,bC as h_,bD as d2,bE as yd,bF as ei,bG as dL,bH as Tm,bI as $D,bJ as Hr,bK as oa,bL as On,bM as mf,bN as Er,bO as vf,bP as Kn,bQ as gp,bR as Fu,bS as CS,bT as UD,bU as qD,bV as GD,bW as r0,bX as Lo,bY as En,bZ as f_,b_ as KD,b$ as ml,c0 as xy,c1 as u2,c2 as Ch,c3 as uL,c4 as g_,c5 as ZD,c6 as xh,c7 as h2,c8 as wr,c9 as ky,ca as f2,cb as So,cc as fa,cd as p_,ce as pp,cf as YD,cg as ar,ch as __,ci as Ly,cj as g2,ck as p2,cl as _2,cm as Uf,cn as ja,co as Ds,cp as m2,cq as a0,cr as v2,cs as b2,ct as hL,cu as y2,cv as m_,cw as Sl,cx as xS,cy as mu,cz as Cl,cA as w2,cB as Wa,cC as Dr,cD as Bo,cE as fL,cF as no,cG as v_,cH as Pc,cI as $a,cJ as S2,cK as ga,cL as _p,cM as Iy,cN as XD,cO as C2,cP as x2,cQ as l0,cR as k2,cS as mp,cT as L2,cU as sc,cV as vp,cW as gL,cX as I2,cY as E2,cZ as Ga,c_ as D2,c$ as c0,d0 as QD,d1 as JD,d2 as eT,d3 as tT,d4 as T2,d5 as P2,d6 as iT,d7 as nT,d8 as M2,d9 as d0,da as R2,db as N2,dc as Qn,dd as A2,de as u0,df as O2,dg as kh,dh as pL,di as F2,dj as H2,dk as W2,dl as B2,dm as z2,dn as V2,dp as bf,dq as Ey,dr as kS,ds as j2,dt as $2,du as _L,dv as LS,dw as U2,dx as mL,dy as Cw,dz as q2,dA as sT,dB as G2,dC as oT,dD as IS,dE as K2,dF as Z2,dG as Y2,dH as rT,dI as aT,dJ as X2,dK as sv,dL as lT,dM as Dy,dN as Q2,dO as J2,dP as Mc,dQ as h0,dR as eO,dS as vL,dT as bL,dU as tO,dV as Lh,dW as cT,dX as iO,dY as nO,dZ as sO,d_ as oO,d$ as dT,e0 as uT,e1 as hT,e2 as fT,e3 as rO,e4 as Ba,e5 as yL,e6 as aO,e7 as b_,e8 as lO,e9 as xg,ea as gT,eb as wL,ec as bp,ed as pT,ee as ov,ef as cO,eg as _T,eh as dO,ei as mT,ej as uO,ek as hO,el as vT,em as bT,en as xl,eo as Ty,ep as fO,eq as yT,er as Uo,es as wd,et as wT,eu as gO,ev as pO,ew as ST,ex as CT,ey as _O,ez as xT,eA as kT,eB as yp,eC as mO,eD as vO,eE as bO,eF as yO,eG as fg,eH as SL,eI as wO,eJ as SO,eK as CO,eL as rv,eM as Ks,eN as xO,eO as ES,eP as Hu,eQ as kO,eR as cl,eS as LO,eT as IO,eU as LT,eV as EO,eW as Vg,eX as DO,eY as TO,eZ as PO,e_ as MO,e$ as CL,f0 as xL,f1 as kL,f2 as Wu,f3 as f0,f4 as IT,f5 as DS,f6 as Pm,f7 as ET,f8 as av,f9 as RO,fa as NO,fb as AO,fc as OO,fd as g0,fe as DT,ff as FO,fg as lv,fh as TT,fi as PT,fj as HO,fk as WO,fl as BO,fm as zO,fn as VO,fo as jO,fp as $O,fq as UO,fr as MT,fs as qO,ft as cv,fu as RT,fv as GO,fw as NT,fx as KO,fy as AT,fz as OT,fA as ZO,fB as LL,fC as FT,fD as IL,fE as YO,fF as xw,fG as EL,fH as XO,fI as QO,fJ as JO,fK as Pa,fL as Rc,fM as eF,fN as DL,fO as Mm,fP as tF,fQ as ul,fR as Py,fS as TS,fT as iF,fU as HT,fV as WT,fW as so,fX as TL,fY as Y_,fZ as p0,f_ as nF,f$ as sF,g0 as oF,g1 as rF,g2 as aF,g3 as lF,g4 as cF,g5 as dF,g6 as PL,g7 as uF,g8 as hF,g9 as fF,ga as yf,gb as jg,gc as BT,gd as gF,ge as _0,gf as Rm,gg as X_,gh as kw,gi as pF,gj as _F,gk as zT,gl as mF,gm as m0,gn as vF,go as bF,gp as VT,gq as My,gr as yF,gs as dv,gt as v0,gu as b0,gv as y0,gw as jT,gx as $T,gy as UT,gz as qT,gA as GT,gB as KT,gC as ZT,gD as ML,gE as YT,gF as eh,gG as wF,gH as SF,gI as CF,gJ as xF,gK as XT,gL as kF,gM as LF,gN as RL,gO as PS,gP as uc,gQ as IF,gR as EF,gS as DF,gT as TF,gU as PF,gV as MF,gW as NL,gX as w0,gY as MS,gZ as RF,g_ as RS,g$ as NF,h0 as AF,h1 as OF,h2 as FF,h3 as S0,h4 as QT,h5 as AL,h6 as OL,h7 as HF,h8 as WF,h9 as BF,ha as FL,hb as Lw,hc as zF,hd as VF,he as jF,hf as Iw,hg as JT,hh as eP,hi as tP,hj as iP,hk as kl,hl as nP,hm as C0,hn as HL,ho as $F,hp as sP,hq as UF,hr as qF,hs as Ry,ht as Ny,hu as Bu,hv as Ay,hw as y_,hx as GF,hy as Oy,hz as KF,hA as ZF,hB as YF,hC as oP,hD as gg,hE as XF,hF as QF,hG as JF,hH as e3,hI as w_,hJ as t3,hK as rP,hL as aP,hM as lP,hN as NS,hO as i3,hP as n3,hQ as s3,hR as o3,hS as r3,hT as AS,hU as a3,hV as l3,hW as c3,hX as d3,hY as u3,hZ as h3,h_ as f3,h$ as g3,i0 as cP,i1 as p3,i2 as _3,i3 as m3,i4 as WL,i5 as v3,i6 as b3,i7 as od,i8 as mr,i9 as y3,ia as w3}from"./monaco-langs-BW2J83t5.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const s of n)if(s.type==="childList")for(const r of s.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function t(n){const s={};return n.integrity&&(s.integrity=n.integrity),n.referrerPolicy&&(s.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?s.credentials="include":n.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(n){if(n.ep)return;n.ep=!0;const s=t(n);fetch(n.href,s)}})();const dP=!1;var x0=Array.isArray,S3=Array.prototype.indexOf,uv=Array.prototype.includes,Fy=Array.from,C3=Object.defineProperty,zh=Object.getOwnPropertyDescriptor,x3=Object.getOwnPropertyDescriptors,k3=Object.prototype,L3=Array.prototype,uP=Object.getPrototypeOf,BL=Object.isExtensible;const Hy=()=>{};function I3(o){for(var e=0;e<o.length;e++)o[e]()}function hP(){var o,e,t=new Promise((i,n)=>{o=i,e=n});return{promise:t,resolve:o,reject:e}}function E3(o,e,t=!1){return o===void 0?t?e():e:o}function zL(o,e){if(Array.isArray(o))return o;if(!(Symbol.iterator in o))return Array.from(o);const t=[];for(const i of o)if(t.push(i),t.length===e)break;return t}const ao=2,wf=4,Wy=8,fP=1<<24,ra=16,la=32,Nc=64,OS=128,Mr=512,Zs=1024,Js=2048,Ua=4096,Eo=8192,Rr=16384,qf=32768,FS=1<<25,Sf=65536,hv=1<<17,D3=1<<18,Gf=1<<19,T3=1<<20,Aa=1<<25,vu=65536,fv=1<<21,Vh=1<<22,hc=1<<23,Sd=Symbol("$state"),P3=Symbol("legacy props"),M3=Symbol(""),Nm=Symbol("attributes"),HS=Symbol("class"),WS=Symbol("style"),kg=Symbol("text"),Am=Symbol("form reset"),By=new class extends Error{constructor(){super(...arguments);yn(this,"name","StaleReactionError");yn(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var MD;const R3=!!((MD=globalThis.document)!=null&&MD.contentType)&&globalThis.document.contentType.includes("xml");function gP(o){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function N3(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function A3(o,e,t){throw new Error("https://svelte.dev/e/each_key_duplicate")}function O3(o){throw new Error("https://svelte.dev/e/effect_in_teardown")}function F3(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function H3(o){throw new Error("https://svelte.dev/e/effect_orphan")}function W3(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function B3(o){throw new Error("https://svelte.dev/e/props_invalid_value")}function z3(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function V3(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function j3(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function $3(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const U3=1,q3=2,pP=4,G3=8,K3=16,Z3=1,Y3=4,X3=8,Q3=16,J3=1,eH=2,Gs=Symbol("uninitialized"),_P="http://www.w3.org/1999/xhtml",tH="http://www.w3.org/2000/svg",iH="http://www.w3.org/1998/Math/MathML";function nH(){console.warn("https://svelte.dev/e/derived_inert")}function sH(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function oH(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function mP(o){return o===this.v}function rH(o,e){return o!=o?e==e:o!==e||o!==null&&typeof o=="object"||typeof o=="function"}function vP(o){return!rH(o,this.v)}let aH=!1,ro=null;function Cf(o){ro=o}function Ts(o,e=!1,t){ro={p:ro,i:!1,c:null,e:null,s:o,x:null,r:Dn,l:null}}function Ps(o){var e=ro,t=e.e;if(t!==null){e.e=null;for(var i of t)BP(i)}return o!==void 0&&(e.x=o),e.i=!0,ro=e.p,o??{}}function bP(){return!0}let dd=[];function yP(){var o=dd;dd=[],I3(o)}function fc(o){if(dd.length===0&&!Ug){var e=dd;queueMicrotask(()=>{e===dd&&yP()})}dd.push(o)}function lH(){for(;dd.length>0;)yP()}function wP(o){var e=Dn;if(e===null)return In.f|=hc,o;if((e.f&qf)===0&&(e.f&wf)===0)throw o;oc(o,e)}function oc(o,e){for(;e!==null;){if((e.f&OS)!==0){if((e.f&qf)===0)throw o;try{e.b.error(o);return}catch(t){o=t}}e=e.parent}throw o}const cH=-7169;function Ls(o,e){o.f=o.f&cH|e}function k0(o){(o.f&Mr)!==0||o.deps===null?Ls(o,Zs):Ls(o,Ua)}function SP(o){if(o!==null)for(const e of o)(e.f&ao)===0||(e.f&vu)===0||(e.f^=vu,SP(e.deps))}function CP(o,e,t){(o.f&Js)!==0?e.add(o):(o.f&Ua)!==0&&t.add(o),SP(o.deps),Ls(o,Zs)}let Q_=!1;function dH(o){var e=Q_;try{return Q_=!1,[o(),Q_]}finally{Q_=e}}let Ew=null,th=null,Yi=null,$g=null,io=null,BS=null,Ug=!1,Dw=!1,Ih=null,Om=null;var VL=0;let uH=1;var qh,tc,gd,Gh,Kh,Zh,ol,Yh,Fo,Jp,rl,Yr,Ia,Xh,pd,Jn,zS,Lg,VS,xP,kP,mh,hH,Ig;const xb=class xb{constructor(){gn(this,Jn);yn(this,"id",uH++);gn(this,qh,!1);yn(this,"linked",!0);gn(this,tc,null);gn(this,gd,null);yn(this,"async_deriveds",new Map);yn(this,"current",new Map);yn(this,"previous",new Map);gn(this,Gh,new Set);gn(this,Kh,new Set);gn(this,Zh,0);gn(this,ol,new Map);gn(this,Yh,null);gn(this,Fo,[]);gn(this,Jp,[]);gn(this,rl,new Set);gn(this,Yr,new Set);gn(this,Ia,new Map);gn(this,Xh,new Set);yn(this,"is_fork",!1);gn(this,pd,!1);th===null?Ew=th=this:(pn(th,gd,this),pn(this,tc,th)),th=this}skip_effect(e){be(this,Ia).has(e)||be(this,Ia).set(e,{d:[],m:[]}),be(this,Xh).delete(e)}unskip_effect(e,t=i=>this.schedule(i)){var i=be(this,Ia).get(e);if(i){be(this,Ia).delete(e);for(var n of i.d)Ls(n,Js),t(n);for(n of i.m)Ls(n,Ua),t(n)}be(this,Xh).add(e)}capture(e,t,i=!1){e.v!==Gs&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&hc)===0&&(this.current.set(e,[t,i]),io==null||io.set(e,t)),this.is_fork||(e.v=t)}activate(){Yi=this}deactivate(){Yi=null,io=null}flush(){try{Dw=!0,Yi=this,zn(this,Jn,Lg).call(this)}finally{VL=0,BS=null,Ih=null,Om=null,Dw=!1,Yi=null,io=null,Cd.clear()}}discard(){var e;for(const t of be(this,Kh))t(this);be(this,Kh).clear(),zn(this,Jn,Ig).call(this),(e=be(this,Yh))==null||e.resolve()}register_created_effect(e){be(this,Jp).push(e)}increment(e,t){if(pn(this,Zh,be(this,Zh)+1),e){let i=be(this,ol).get(t)??0;be(this,ol).set(t,i+1)}}decrement(e,t){if(pn(this,Zh,be(this,Zh)-1),e){let i=be(this,ol).get(t)??0;i===1?be(this,ol).delete(t):be(this,ol).set(t,i-1)}be(this,pd)||(pn(this,pd,!0),fc(()=>{pn(this,pd,!1),this.linked&&this.flush()}))}transfer_effects(e,t){for(const i of e)be(this,rl).add(i);for(const i of t)be(this,Yr).add(i);e.clear(),t.clear()}oncommit(e){be(this,Gh).add(e)}ondiscard(e){be(this,Kh).add(e)}settled(){return(be(this,Yh)??pn(this,Yh,hP())).promise}static ensure(){if(Yi===null){const e=Yi=new xb;!Dw&&!Ug&&fc(()=>{be(e,qh)||e.flush()})}return Yi}apply(){{io=null;return}}schedule(e){var n;if(BS=e,(n=e.b)!=null&&n.is_pending&&(e.f&(wf|Wy|fP))!==0&&(e.f&qf)===0){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var i=t.f;if(Ih!==null&&t===Dn&&(In===null||(In.f&ao)===0))return;if((i&(Nc|la))!==0){if((i&Zs)===0)return;t.f^=Zs}}be(this,Fo).push(t)}};qh=new WeakMap,tc=new WeakMap,gd=new WeakMap,Gh=new WeakMap,Kh=new WeakMap,Zh=new WeakMap,ol=new WeakMap,Yh=new WeakMap,Fo=new WeakMap,Jp=new WeakMap,rl=new WeakMap,Yr=new WeakMap,Ia=new WeakMap,Xh=new WeakMap,pd=new WeakMap,Jn=new WeakSet,zS=function(){if(this.is_fork)return!0;for(const i of be(this,ol).keys()){for(var e=i,t=!1;e.parent!==null;){if(be(this,Ia).has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1},Lg=function(){var d,u,f,g;pn(this,qh,!0),VL++>1e3&&(zn(this,Jn,Ig).call(this),gH());for(const p of be(this,rl))be(this,Yr).delete(p),Ls(p,Js),this.schedule(p);for(const p of be(this,Yr))Ls(p,Ua),this.schedule(p);const e=be(this,Fo);pn(this,Fo,[]),this.apply();var t=Ih=[],i=[],n=Om=[];for(const p of e)try{zn(this,Jn,VS).call(this,p,t,i)}catch(w){throw EP(p),zn(this,Jn,zS).call(this)||this.discard(),w}if(Yi=null,n.length>0){var s=xb.ensure();for(const p of n)s.schedule(p)}if(Ih=null,Om=null,zn(this,Jn,zS).call(this)){zn(this,Jn,mh).call(this,i),zn(this,Jn,mh).call(this,t);for(const[p,w]of be(this,Ia))IP(p,w);n.length>0&&zn(d=Yi,Jn,Lg).call(d);return}const r=zn(this,Jn,xP).call(this);if(r){zn(this,Jn,mh).call(this,i),zn(this,Jn,mh).call(this,t),zn(u=r,Jn,kP).call(u,this);return}be(this,rl).clear(),be(this,Yr).clear();for(const p of be(this,Gh))p(this);be(this,Gh).clear(),$g=this,jL(i),jL(t),$g=null,(f=be(this,Yh))==null||f.resolve();var a=Yi;if(be(this,Zh)===0&&(be(this,Fo).length===0||a!==null)&&zn(this,Jn,Ig).call(this),be(this,Fo).length>0)if(a!==null){const p=a;be(p,Fo).push(...be(this,Fo).filter(w=>!be(p,Fo).includes(w)))}else a=this;a!==null&&zn(g=a,Jn,Lg).call(g)},VS=function(e,t,i){e.f^=Zs;for(var n=e.first;n!==null;){var s=n.f,r=(s&(la|Nc))!==0,a=r&&(s&Zs)!==0,d=a||(s&Eo)!==0||be(this,Ia).has(n);if(!d&&n.fn!==null){r?n.f^=Zs:(s&wf)!==0?t.push(n):C_(n)&&((s&ra)!==0&&be(this,Yr).add(n),kf(n));var u=n.first;if(u!==null){n=u;continue}}for(;n!==null;){var f=n.next;if(f!==null){n=f;break}n=n.parent}}},xP=function(){for(var e=be(this,tc);e!==null;){if(!e.is_fork){for(const[t,[,i]]of this.current)if(e.current.has(t)&&!i)return e}e=be(e,tc)}return null},kP=function(e){var i;for(const[n,s]of e.current)!this.previous.has(n)&&e.previous.has(n)&&this.previous.set(n,e.previous.get(n)),this.current.set(n,s);for(const[n,s]of e.async_deriveds){const r=this.async_deriveds.get(n);r&&s.promise.then(r.resolve).catch(r.reject)}this.transfer_effects(be(e,rl),be(e,Yr));const t=n=>{var s=n.reactions;if(s!==null)for(const d of s){var r=d.f;if((r&ao)!==0)t(d);else{var a=d;r&(Vh|ra)&&!this.async_deriveds.has(a)&&(be(this,Yr).delete(a),Ls(a,Js),this.schedule(a))}}};for(const n of this.current.keys())t(n);this.oncommit(()=>e.discard()),zn(i=e,Jn,Ig).call(i),Yi=this,zn(this,Jn,Lg).call(this)},mh=function(e){for(var t=0;t<e.length;t+=1)CP(e[t],be(this,rl),be(this,Yr))},hH=function(){var f;for(let g=Ew;g!==null;g=be(g,gd)){var e=g.id<this.id,t=[];for(const[p,[w,y]]of this.current){if(g.current.has(p)){var i=g.current.get(p)[0];if(e&&w!==i)g.current.set(p,[w,y]);else continue}t.push(p)}if(e)for(const[p,w]of this.async_deriveds){const y=g.async_deriveds.get(p);y&&w.promise.then(y.resolve).catch(y.reject)}if(be(g,qh)){var n=[...g.current.keys()].filter(p=>!g.current.get(p)[1]&&!this.current.has(p));if(n.length===0)e&&g.discard();else if(t.length>0){if(e)for(const p of be(this,Xh))g.unskip_effect(p,w=>{var y;(w.f&(ra|Vh))!==0?g.schedule(w):zn(y=g,Jn,mh).call(y,[w])});g.activate();var s=new Set,r=new Map;for(var a of t)LP(a,n,s,r);r=new Map;var d=[...g.current].filter(([p,w])=>{const y=this.current.get(p);return y?y[0]!==w[0]||y[1]!==w[1]:!0}).map(([p])=>p);if(d.length>0)for(const p of be(this,Jp))(p.f&(Rr|Eo|hv))===0&&L0(p,d,r)&&((p.f&(Vh|ra))!==0?(Ls(p,Js),g.schedule(p)):be(g,rl).add(p));if(be(g,Fo).length>0&&!be(g,pd)){g.apply();for(var u of be(g,Fo))zn(f=g,Jn,VS).call(f,u,[],[]);pn(g,Fo,[])}g.deactivate()}}}},Ig=function(){if(this.linked){var e=be(this,tc),t=be(this,gd);e===null?Ew=t:pn(e,gd,t),t===null?th=e:pn(t,tc,e),this.linked=!1}};let bu=xb;function fH(o){var e=Ug;Ug=!0;try{for(var t;;){if(lH(),Yi===null)return t;Yi.flush()}}finally{Ug=e}}function gH(){try{W3()}catch(o){oc(o,BS)}}let Gr=null;function jL(o){var e=o.length;if(e!==0){for(var t=0;t<e;){var i=o[t++];if((i.f&(Rr|Eo))===0&&C_(i)&&(Gr=new Set,kf(i),i.deps===null&&i.first===null&&i.nodes===null&&i.teardown===null&&i.ac===null&&jP(i),(Gr==null?void 0:Gr.size)>0)){Cd.clear();for(const n of Gr){if((n.f&(Rr|Eo))!==0)continue;const s=[n];let r=n.parent;for(;r!==null;)Gr.has(r)&&(Gr.delete(r),s.push(r)),r=r.parent;for(let a=s.length-1;a>=0;a--){const d=s[a];(d.f&(Rr|Eo))===0&&kf(d)}}Gr.clear()}}Gr=null}}function LP(o,e,t,i){if(!t.has(o)&&(t.add(o),o.reactions!==null))for(const n of o.reactions){const s=n.f;(s&ao)!==0?LP(n,e,t,i):(s&(Vh|ra))!==0&&(s&Js)===0&&L0(n,e,i)&&(Ls(n,Js),I0(n))}}function L0(o,e,t){const i=t.get(o);if(i!==void 0)return i;if(o.deps!==null)for(const n of o.deps){if(uv.call(e,n))return!0;if((n.f&ao)!==0&&L0(n,e,t))return t.set(n,!0),!0}return t.set(o,!1),!1}function I0(o){Yi.schedule(o)}function IP(o,e){if(!((o.f&la)!==0&&(o.f&Zs)!==0)){(o.f&Js)!==0?e.d.push(o):(o.f&Ua)!==0&&e.m.push(o),Ls(o,Zs);for(var t=o.first;t!==null;)IP(t,e),t=t.next}}function EP(o){Ls(o,Zs);for(var e=o.first;e!==null;)EP(e),e=e.next}function pH(o){let e=0,t=yu(0),i;return()=>{P0()&&(c(t),Vy(()=>(e===0&&(i=Fl(()=>o(()=>qg(t)))),e+=1,()=>{fc(()=>{e-=1,e===0&&(i==null||i(),i=void 0,qg(t))})})))}}var _H=Sf|Gf;function mH(o,e,t,i){new vH(o,e,t,i)}var Cr,Kx,xr,_d,Ho,kr,xo,nr,al,md,ic,Qh,e_,t_,ll,kb,Is,bH,yH,wH,jS,Fm,Hm,$S,US;class vH{constructor(e,t,i,n){gn(this,Is);yn(this,"parent");yn(this,"is_pending",!1);yn(this,"transform_error");gn(this,Cr);gn(this,Kx,null);gn(this,xr);gn(this,_d);gn(this,Ho);gn(this,kr,null);gn(this,xo,null);gn(this,nr,null);gn(this,al,null);gn(this,md,0);gn(this,ic,0);gn(this,Qh,!1);gn(this,e_,new Set);gn(this,t_,new Set);gn(this,ll,null);gn(this,kb,pH(()=>(pn(this,ll,yu(be(this,md))),()=>{pn(this,ll,null)})));var s;pn(this,Cr,e),pn(this,xr,t),pn(this,_d,r=>{var a=Dn;a.b=this,a.f|=OS,i(r)}),this.parent=Dn.b,this.transform_error=n??((s=this.parent)==null?void 0:s.transform_error)??(r=>r),pn(this,Ho,N0(()=>{zn(this,Is,jS).call(this)},_H))}defer_effect(e){CP(e,be(this,e_),be(this,t_))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!be(this,xr).pending}update_pending_count(e,t){zn(this,Is,$S).call(this,e,t),pn(this,md,be(this,md)+e),!(!be(this,ll)||be(this,Qh))&&(pn(this,Qh,!0),fc(()=>{pn(this,Qh,!1),be(this,ll)&&xf(be(this,ll),be(this,md))}))}get_effect_pending(){return be(this,kb).call(this),c(be(this,ll))}error(e){if(!be(this,xr).onerror&&!be(this,xr).failed)throw e;Yi!=null&&Yi.is_fork?(be(this,kr)&&Yi.skip_effect(be(this,kr)),be(this,xo)&&Yi.skip_effect(be(this,xo)),be(this,nr)&&Yi.skip_effect(be(this,nr)),Yi.oncommit(()=>{zn(this,Is,US).call(this,e)})):zn(this,Is,US).call(this,e)}}Cr=new WeakMap,Kx=new WeakMap,xr=new WeakMap,_d=new WeakMap,Ho=new WeakMap,kr=new WeakMap,xo=new WeakMap,nr=new WeakMap,al=new WeakMap,md=new WeakMap,ic=new WeakMap,Qh=new WeakMap,e_=new WeakMap,t_=new WeakMap,ll=new WeakMap,kb=new WeakMap,Is=new WeakSet,bH=function(){try{pn(this,kr,Lr(()=>be(this,_d).call(this,be(this,Cr))))}catch(e){this.error(e)}},yH=function(e){const t=be(this,xr).failed;t&&pn(this,nr,Lr(()=>{t(be(this,Cr),()=>e,()=>()=>{})}))},wH=function(){const e=be(this,xr).pending;e&&(this.is_pending=!0,pn(this,xo,Lr(()=>e(be(this,Cr)))),fc(()=>{var t=pn(this,al,document.createDocumentFragment()),i=vl();t.append(i),pn(this,kr,zn(this,Is,Hm).call(this,()=>Lr(()=>be(this,_d).call(this,i)))),be(this,ic)===0&&(be(this,Cr).before(t),pn(this,al,null),kd(be(this,xo),()=>{pn(this,xo,null)}),zn(this,Is,Fm).call(this,Yi))}))},jS=function(){try{if(this.is_pending=this.has_pending_snippet(),pn(this,ic,0),pn(this,md,0),pn(this,kr,Lr(()=>{be(this,_d).call(this,be(this,Cr))})),be(this,ic)>0){var e=pn(this,al,document.createDocumentFragment());O0(be(this,kr),e);const t=be(this,xr).pending;pn(this,xo,Lr(()=>t(be(this,Cr))))}else zn(this,Is,Fm).call(this,Yi)}catch(t){this.error(t)}},Fm=function(e){this.is_pending=!1,e.transfer_effects(be(this,e_),be(this,t_))},Hm=function(e){var t=Dn,i=In,n=ro;qa(be(this,Ho)),Or(be(this,Ho)),Cf(be(this,Ho).ctx);try{return bu.ensure(),e()}catch(s){return wP(s),null}finally{qa(t),Or(i),Cf(n)}},$S=function(e,t){var i;if(!this.has_pending_snippet()){this.parent&&zn(i=this.parent,Is,$S).call(i,e,t);return}pn(this,ic,be(this,ic)+e),be(this,ic)===0&&(zn(this,Is,Fm).call(this,t),be(this,xo)&&kd(be(this,xo),()=>{pn(this,xo,null)}),be(this,al)&&(be(this,Cr).before(be(this,al)),pn(this,al,null)))},US=function(e){be(this,kr)&&(qo(be(this,kr)),pn(this,kr,null)),be(this,xo)&&(qo(be(this,xo)),pn(this,xo,null)),be(this,nr)&&(qo(be(this,nr)),pn(this,nr,null));var t=be(this,xr).onerror;let i=be(this,xr).failed;var n=!1,s=!1;const r=()=>{if(n){oH();return}n=!0,s&&$3(),be(this,nr)!==null&&kd(be(this,nr),()=>{pn(this,nr,null)}),zn(this,Is,Hm).call(this,()=>{zn(this,Is,jS).call(this)})},a=d=>{try{s=!0,t==null||t(d,r),s=!1}catch(u){oc(u,be(this,Ho)&&be(this,Ho).parent)}i&&pn(this,nr,zn(this,Is,Hm).call(this,()=>{try{return Lr(()=>{var u=Dn;u.b=this,u.f|=OS,i(be(this,Cr),()=>d,()=>r)})}catch(u){return oc(u,be(this,Ho).parent),null}}))};fc(()=>{var d;try{d=this.transform_error(e)}catch(u){oc(u,be(this,Ho)&&be(this,Ho).parent);return}d!==null&&typeof d=="object"&&typeof d.then=="function"?d.then(a,u=>oc(u,be(this,Ho)&&be(this,Ho).parent)):a(d)})};function SH(o,e,t,i){const n=wp;var s=o.filter(p=>!p.settled);if(t.length===0&&s.length===0){i(e.map(n));return}var r=Dn,a=CH(),d=s.length===1?s[0].promise:s.length>1?Promise.all(s.map(p=>p.promise)):null;function u(p){if((r.f&Rr)===0){a();try{i(p)}catch(w){oc(w,r)}gv()}}var f=DP();if(t.length===0){d.then(()=>u(e.map(n))).finally(f);return}function g(){Promise.all(t.map(p=>xH(p))).then(p=>u([...e.map(n),...p])).catch(p=>oc(p,r)).finally(f)}d?d.then(()=>{a(),g(),gv()}):g()}function CH(){var o=Dn,e=In,t=ro,i=Yi;return function(s=!0){qa(o),Or(e),Cf(t),s&&(o.f&Rr)===0&&(i==null||i.activate(),i==null||i.apply())}}function gv(o=!0){qa(null),Or(null),Cf(null),o&&(Yi==null||Yi.deactivate())}function DP(){var o=Dn,e=o.b,t=Yi,i=!!(e!=null&&e.is_rendered());return e==null||e.update_pending_count(1,t),t.increment(i,o),()=>{e==null||e.update_pending_count(-1,t),t.decrement(i,o)}}function wp(o){var e=ao|Js;return Dn!==null&&(Dn.f|=Gf),{ctx:ro,deps:null,effects:null,equals:mP,f:e,fn:o,reactions:null,rv:0,v:Gs,wv:0,parent:Dn,ac:null}}const J_=Symbol("obsolete");function xH(o,e,t){let i=Dn;i===null&&N3();var n=void 0,s=yu(Gs),r=!In,a=new Set;return OH(()=>{var w,y;var d=Dn,u=hP();n=u.promise;try{Promise.resolve(o()).then(u.resolve,x=>{x!==By&&u.reject(x)}).finally(gv)}catch(x){u.reject(x),gv()}var f=Yi;if(r){if((d.f&qf)!==0)var g=DP();if((w=i.b)!=null&&w.is_rendered())(y=f.async_deriveds.get(d))==null||y.reject(J_);else for(const x of a.values())x.reject(J_);a.add(u),f.async_deriveds.set(d,u)}const p=(x,k=void 0)=>{g==null||g(),a.delete(u),k!==J_&&(f.activate(),k?(s.f|=hc,xf(s,k)):((s.f&hc)!==0&&(s.f^=hc),xf(s,x)),f.deactivate())};u.promise.then(p,x=>p(null,x||"unknown"))}),M0(()=>{for(const d of a)d.reject(J_)}),new Promise(d=>{function u(f){function g(){f===n?d(s):u(n)}f.then(g,g)}u(n)})}function Ct(o){const e=wp(o);return qP(e),e}function E0(o){const e=wp(o);return e.equals=vP,e}function kH(o){var e=o.effects;if(e!==null){o.effects=null;for(var t=0;t<e.length;t+=1)qo(e[t])}}function D0(o){var e,t=Dn,i=o.parent;if(!Ll&&i!==null&&o.v!==Gs&&(i.f&(Rr|Eo))!==0)return nH(),o.v;qa(i);try{o.f&=~vu,kH(o),e=YP(o)}finally{qa(t)}return e}function TP(o){var e=D0(o);if(!o.equals(e)&&(o.wv=KP(),(!(Yi!=null&&Yi.is_fork)||o.deps===null)&&(Yi!==null?(Yi.capture(o,e,!0),$g==null||$g.capture(o,e,!0)):o.v=e,o.deps===null))){Ls(o,Zs);return}Ll||(io!==null?(P0()||Yi!=null&&Yi.is_fork)&&io.set(o,e):k0(o))}function LH(o){var e,t;if(o.effects!==null)for(const i of o.effects)(i.teardown||i.ac)&&((e=i.teardown)==null||e.call(i),(t=i.ac)==null||t.abort(By),i.fn!==null&&(i.teardown=Hy),i.ac=null,Sp(i,0),A0(i))}function PP(o){if(o.effects!==null)for(const e of o.effects)e.teardown&&e.fn!==null&&kf(e)}let pv=new Set;const Cd=new Map;let MP=!1;function yu(o,e){var t={f:0,v:o,reactions:null,equals:mP,rv:0,wv:0};return t}function P(o,e){const t=yu(o);return qP(t),t}function IH(o,e=!1,t=!0){const i=yu(o);return e||(i.equals=vP),i}function v(o,e,t=!1){In!==null&&(!aa||(In.f&hv)!==0)&&bP()&&(In.f&(ao|ra|Vh|hv))!==0&&(za===null||!za.has(o))&&j3();let i=t?yi(e):e;return xf(o,i,Om)}function xf(o,e,t=null){if(!o.equals(e)){Cd.set(o,Ll?e:o.v);var i=bu.ensure();if(i.capture(o,e),(o.f&ao)!==0){const n=o;(o.f&Js)!==0&&D0(n),io===null&&k0(n)}o.wv=KP(),RP(o,Js,t),Dn!==null&&(Dn.f&Zs)!==0&&(Dn.f&(la|Nc))===0&&(Sr===null?HH([o]):Sr.push(o)),!i.is_fork&&pv.size>0&&!MP&&EH()}return e}function EH(){MP=!1;for(const o of pv){(o.f&Zs)!==0&&Ls(o,Ua);let e;try{e=C_(o)}catch{e=!0}e&&kf(o)}pv.clear()}function $L(o,e=1){var t=c(o),i=e===1?t++:t--;return v(o,t),i}function qg(o){v(o,o.v+1)}function RP(o,e,t){var i=o.reactions;if(i!==null)for(var n=i.length,s=0;s<n;s++){var r=i[s],a=r.f,d=(a&Js)===0;if(d&&Ls(r,e),(a&hv)!==0)pv.add(r);else if((a&ao)!==0){var u=r;io==null||io.delete(u),(a&vu)===0&&(a&Mr&&(Dn===null||(Dn.f&fv)===0)&&(r.f|=vu),RP(u,Ua,t))}else if(d){var f=r;(a&ra)!==0&&Gr!==null&&Gr.add(f),t!==null?t.push(f):I0(f)}}}function yi(o){if(typeof o!="object"||o===null||Sd in o)return o;const e=uP(o);if(e!==k3&&e!==L3)return o;var t=new Map,i=x0(o),n=P(0),s=Ld,r=a=>{if(Ld===s)return a();var d=In,u=Ld;Or(null),KL(s);var f=a();return Or(d),KL(u),f};return i&&t.set("length",P(o.length)),new Proxy(o,{defineProperty(a,d,u){(!("value"in u)||u.configurable===!1||u.enumerable===!1||u.writable===!1)&&z3();var f=t.get(d);return f===void 0?r(()=>{var g=P(u.value);return t.set(d,g),g}):v(f,u.value,!0),!0},deleteProperty(a,d){var u=t.get(d);if(u===void 0){if(d in a){const f=r(()=>P(Gs));t.set(d,f),qg(n)}}else v(u,Gs),qg(n);return!0},get(a,d,u){var w;if(d===Sd)return o;var f=t.get(d),g=d in a;if(f===void 0&&(!g||(w=zh(a,d))!=null&&w.writable)&&(f=r(()=>{var y=yi(g?a[d]:Gs),x=P(y);return x}),t.set(d,f)),f!==void 0){var p=c(f);return p===Gs?void 0:p}return Reflect.get(a,d,u)},getOwnPropertyDescriptor(a,d){var u=Reflect.getOwnPropertyDescriptor(a,d);if(u&&"value"in u){var f=t.get(d);f&&(u.value=c(f))}else if(u===void 0){var g=t.get(d),p=g==null?void 0:g.v;if(g!==void 0&&p!==Gs)return{enumerable:!0,configurable:!0,value:p,writable:!0}}return u},has(a,d){var p;if(d===Sd)return!0;var u=t.get(d),f=u!==void 0&&u.v!==Gs||Reflect.has(a,d);if(u!==void 0||Dn!==null&&(!f||(p=zh(a,d))!=null&&p.writable)){u===void 0&&(u=r(()=>{var w=f?yi(a[d]):Gs,y=P(w);return y}),t.set(d,u));var g=c(u);if(g===Gs)return!1}return f},set(a,d,u,f){var F;var g=t.get(d),p=d in a;if(i&&d==="length")for(var w=u;w<g.v;w+=1){var y=t.get(w+"");y!==void 0?v(y,Gs):w in a&&(y=r(()=>P(Gs)),t.set(w+"",y))}if(g===void 0)(!p||(F=zh(a,d))!=null&&F.writable)&&(g=r(()=>P(void 0)),v(g,yi(u)),t.set(d,g));else{p=g.v!==Gs;var x=r(()=>yi(u));v(g,x)}var k=Reflect.getOwnPropertyDescriptor(a,d);if(k!=null&&k.set&&k.set.call(f,u),!p){if(i&&typeof d=="string"){var D=t.get("length"),M=Number(d);Number.isInteger(M)&&M>=D.v&&v(D,M+1)}qg(n)}return!0},ownKeys(a){c(n);var d=Reflect.ownKeys(a).filter(g=>{var p=t.get(g);return p===void 0||p.v!==Gs});for(var[u,f]of t)f.v!==Gs&&!(u in a)&&d.push(u);return d},setPrototypeOf(){V3()}})}function UL(o){try{if(o!==null&&typeof o=="object"&&Sd in o)return o[Sd]}catch{}return o}function DH(o,e){return Object.is(UL(o),UL(e))}var xd,NP,AP,OP,FP;function TH(){if(xd===void 0){xd=window,NP=document,AP=/Firefox/.test(navigator.userAgent);var o=Element.prototype,e=Node.prototype,t=Text.prototype;OP=zh(e,"firstChild").get,FP=zh(e,"nextSibling").get,BL(o)&&(o[HS]=void 0,o[Nm]=null,o[WS]=void 0,o.__e=void 0),BL(t)&&(t[kg]=void 0)}}function vl(o=""){return document.createTextNode(o)}function Oa(o){return OP.call(o)}function S_(o){return FP.call(o)}function b(o,e){return Oa(o)}function xt(o,e=!1){{var t=Oa(o);return t instanceof Comment&&t.data===""?S_(t):t}}function m(o,e=1,t=!1){let i=o;for(;e--;)i=S_(i);return i}function PH(o){o.textContent=""}function HP(){return!1}function WP(o,e,t){return e==null||e===_P?t?document.createElement(o,{is:t}):document.createElement(o):t?document.createElementNS(e,o,{is:t}):document.createElementNS(e,o)}let qL=!1;function MH(){qL||(qL=!0,document.addEventListener("reset",o=>{Promise.resolve().then(()=>{var e;if(!o.defaultPrevented)for(const t of o.target.elements)(e=t[Am])==null||e.call(t)})},{capture:!0}))}function zy(o){var e=In,t=Dn;Or(null),qa(null);try{return o()}finally{Or(e),qa(t)}}function T0(o,e,t,i=t){o.addEventListener(e,()=>zy(t));const n=o[Am];n?o[Am]=()=>{n(),i(!0)}:o[Am]=()=>i(!0),MH()}function RH(o){Dn===null&&(In===null&&H3(),F3()),Ll&&O3()}function NH(o,e){var t=e.last;t===null?e.last=e.first=o:(t.next=o,o.prev=t,e.last=o)}function Ol(o,e){var t=Dn;t!==null&&(t.f&Eo)!==0&&(o|=Eo);var i={ctx:ro,deps:null,nodes:null,f:o|Js|Mr,first:null,fn:e,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};Yi==null||Yi.register_created_effect(i);var n=i;if((o&wf)!==0)Ih!==null?Ih.push(i):bu.ensure().schedule(i);else if(e!==null){try{kf(i)}catch(r){throw qo(i),r}n.deps===null&&n.teardown===null&&n.nodes===null&&n.first===n.last&&(n.f&Gf)===0&&(n=n.first,(o&ra)!==0&&(o&Sf)!==0&&n!==null&&(n.f|=Sf))}if(n!==null&&(n.parent=t,t!==null&&NH(n,t),In!==null&&(In.f&ao)!==0&&(o&Nc)===0)){var s=In;(s.effects??(s.effects=[])).push(n)}return i}function P0(){return In!==null&&!aa}function M0(o){const e=Ol(Wy,null);return Ls(e,Zs),e.teardown=o,e}function Vn(o){RH();var e=Dn.f,t=!In&&(e&la)!==0&&ro!==null&&!ro.i;if(t){var i=ro;(i.e??(i.e=[])).push(o)}else return BP(o)}function BP(o){return Ol(wf|T3,o)}function AH(o){bu.ensure();const e=Ol(Nc|Gf,o);return(t={})=>new Promise(i=>{t.outro?kd(e,()=>{qo(e),i(void 0)}):(qo(e),i(void 0))})}function R0(o){return Ol(wf,o)}function OH(o){return Ol(Vh|Gf,o)}function Vy(o,e=0){return Ol(Wy|e,o)}function H(o,e=[],t=[],i=[]){SH(i,e,t,n=>{Ol(Wy,()=>o(...n.map(c)))})}function N0(o,e=0){var t=Ol(ra|e,o);return t}function Lr(o){return Ol(la|Gf,o)}function zP(o){var e=o.teardown;if(e!==null){const t=Ll,i=In;GL(!0),Or(null);try{e.call(null)}finally{GL(t),Or(i)}}}function A0(o,e=!1){var t=o.first;for(o.first=o.last=null;t!==null;){const n=t.ac;n!==null&&zy(()=>{n.abort(By)});var i=t.next;(t.f&Nc)!==0?t.parent=null:qo(t,e),t=i}}function FH(o){for(var e=o.first;e!==null;){var t=e.next;(e.f&la)===0&&qo(e),e=t}}function qo(o,e=!0){var t=!1;(e||(o.f&D3)!==0)&&o.nodes!==null&&o.nodes.end!==null&&(VP(o.nodes.start,o.nodes.end),t=!0),Ls(o,FS),A0(o,e&&!t),Sp(o,0);var i=o.nodes&&o.nodes.t;if(i!==null)for(const s of i)s.stop();zP(o),o.f^=FS,o.f|=Rr;var n=o.parent;n!==null&&n.first!==null&&jP(o),o.next=o.prev=o.teardown=o.ctx=o.deps=o.fn=o.nodes=o.ac=o.b=null}function VP(o,e){for(;o!==null;){var t=o===e?null:S_(o);o.remove(),o=t}}function jP(o){var e=o.parent,t=o.prev,i=o.next;t!==null&&(t.next=i),i!==null&&(i.prev=t),e!==null&&(e.first===o&&(e.first=i),e.last===o&&(e.last=t))}function kd(o,e,t=!0){var i=[];$P(o,i,!0);var n=()=>{t&&qo(o),e&&e()},s=i.length;if(s>0){var r=()=>--s||n();for(var a of i)a.out(r)}else n()}function $P(o,e,t){if((o.f&Eo)===0){o.f^=Eo;var i=o.nodes&&o.nodes.t;if(i!==null)for(const a of i)(a.is_global||t)&&e.push(a);for(var n=o.first;n!==null;){var s=n.next;if((n.f&Nc)===0){var r=(n.f&Sf)!==0||(n.f&la)!==0&&(o.f&ra)!==0;$P(n,e,r?t:!1)}n=s}}}function _v(o){UP(o,!0)}function UP(o,e){if((o.f&Eo)!==0){o.f^=Eo,(o.f&Zs)===0&&(Ls(o,Js),bu.ensure().schedule(o));for(var t=o.first;t!==null;){var i=t.next,n=(t.f&Sf)!==0||(t.f&la)!==0;UP(t,n?e:!1),t=i}var s=o.nodes&&o.nodes.t;if(s!==null)for(const r of s)(r.is_global||e)&&r.in()}}function O0(o,e){if(o.nodes)for(var t=o.nodes.start,i=o.nodes.end;t!==null;){var n=t===i?null:S_(t);e.append(t),t=n}}let Wm=!1,Ll=!1;function GL(o){Ll=o}let In=null,aa=!1;function Or(o){In=o}let Dn=null;function qa(o){Dn=o}let za=null;function qP(o){In!==null&&(za??(za=new Set)).add(o)}let Wo=null,tr=0,Sr=null;function HH(o){Sr=o}let GP=1,ud=0,Ld=ud;function KL(o){Ld=o}function KP(){return++GP}function C_(o){var e=o.f;if((e&Js)!==0)return!0;if(e&ao&&(o.f&=~vu),(e&Ua)!==0){for(var t=o.deps,i=t.length,n=0;n<i;n++){var s=t[n];if(C_(s)&&TP(s),s.wv>o.wv)return!0}(e&Mr)!==0&&io===null&&Ls(o,Zs)}return!1}function ZP(o,e,t=!0){var i=o.reactions;if(i!==null&&!(za!==null&&za.has(o)))for(var n=0;n<i.length;n++){var s=i[n];(s.f&ao)!==0?ZP(s,e,!1):e===s&&(t?Ls(s,Js):(s.f&Zs)!==0&&Ls(s,Ua),I0(s))}}function YP(o){var x;var e=Wo,t=tr,i=Sr,n=In,s=za,r=ro,a=aa,d=Ld,u=o.f;Wo=null,tr=0,Sr=null,In=(u&(la|Nc))===0?o:null,za=null,Cf(o.ctx),aa=!1,Ld=++ud,o.ac!==null&&(zy(()=>{o.ac.abort(By)}),o.ac=null);try{o.f|=fv;var f=o.fn,g=f();o.f|=qf;var p=o.deps,w=Yi==null?void 0:Yi.is_fork;if(Wo!==null){var y;if(w||Sp(o,tr),p!==null&&tr>0)for(p.length=tr+Wo.length,y=0;y<Wo.length;y++)p[tr+y]=Wo[y];else o.deps=p=Wo;if(P0()&&(o.f&Mr)!==0)for(y=tr;y<p.length;y++)((x=p[y]).reactions??(x.reactions=[])).push(o)}else!w&&p!==null&&tr<p.length&&(Sp(o,tr),p.length=tr);if(bP()&&Sr!==null&&!aa&&p!==null&&(o.f&(ao|Ua|Js))===0)for(y=0;y<Sr.length;y++)ZP(Sr[y],o);if(n!==null&&n!==o){if(ud++,n.deps!==null)for(let k=0;k<t;k+=1)n.deps[k].rv=ud;if(e!==null)for(const k of e)k.rv=ud;Sr!==null&&(i===null?i=Sr:i.push(...Sr))}return(o.f&hc)!==0&&(o.f^=hc),g}catch(k){return wP(k)}finally{o.f^=fv,Wo=e,tr=t,Sr=i,In=n,za=s,Cf(r),aa=a,Ld=d}}function WH(o,e){let t=e.reactions;if(t!==null){var i=S3.call(t,o);if(i!==-1){var n=t.length-1;n===0?t=e.reactions=null:(t[i]=t[n],t.pop())}}if(t===null&&(e.f&ao)!==0&&(Wo===null||!uv.call(Wo,e))){var s=e;(s.f&Mr)!==0&&(s.f^=Mr,s.f&=~vu),s.v!==Gs&&k0(s),LH(s),Sp(s,0)}}function Sp(o,e){var t=o.deps;if(t!==null)for(var i=e;i<t.length;i++)WH(o,t[i])}function kf(o){var e=o.f;if((e&Rr)===0){Ls(o,Zs);var t=Dn,i=Wm;Dn=o,Wm=!0;try{(e&(ra|fP))!==0?FH(o):A0(o),zP(o);var n=YP(o);o.teardown=typeof n=="function"?n:null,o.wv=GP;var s;dP&&aH&&(o.f&Js)!==0&&o.deps}finally{Wm=i,Dn=t}}}async function Gg(){await Promise.resolve(),fH()}function c(o){var e=o.f,t=(e&ao)!==0;if(In!==null&&!aa){var i=Dn!==null&&(Dn.f&Rr)!==0;if(!i&&(za===null||!za.has(o))){var n=In.deps;if((In.f&fv)!==0)o.rv<ud&&(o.rv=ud,Wo===null&&n!==null&&n[tr]===o?tr++:Wo===null?Wo=[o]:Wo.push(o));else{In.deps??(In.deps=[]),uv.call(In.deps,o)||In.deps.push(o);var s=o.reactions;s===null?o.reactions=[In]:uv.call(s,In)||s.push(In)}}}if(Ll&&Cd.has(o))return Cd.get(o);if(t){var r=o;if(Ll){var a=r.v;return((r.f&Zs)===0&&r.reactions!==null||QP(r))&&(a=D0(r)),Cd.set(r,a),a}var d=(r.f&Mr)===0&&!aa&&In!==null&&(Wm||(In.f&Mr)!==0),u=(r.f&qf)===0;C_(r)&&(d&&(r.f|=Mr),TP(r)),d&&!u&&(PP(r),XP(r))}if(io!=null&&io.has(o))return io.get(o);if((o.f&hc)!==0)throw o.v;return o.v}function XP(o){if(o.f|=Mr,o.deps!==null)for(const e of o.deps)(e.reactions??(e.reactions=[])).push(o),(e.f&ao)!==0&&(e.f&Mr)===0&&(PP(e),XP(e))}function QP(o){if(o.v===Gs)return!0;if(o.deps===null)return!1;for(const e of o.deps)if(Cd.has(e)||(e.f&ao)!==0&&QP(e))return!0;return!1}function Fl(o){var e=aa;try{return aa=!0,o()}finally{aa=e}}const BH=["touchstart","touchmove"];function zH(o){return BH.includes(o)}const hd=Symbol("events"),JP=new Set,qS=new Set;function VH(o,e,t,i={}){function n(s){if(i.capture||GS.call(e,s),!s.cancelBubble)return zy(()=>t==null?void 0:t.call(this,s))}return o.startsWith("pointer")||o.startsWith("touch")||o==="wheel"?fc(()=>{e.addEventListener(o,n,i)}):e.addEventListener(o,n,i),n}function ds(o,e,t,i,n){var s={capture:i,passive:n},r=VH(o,e,t,s);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&M0(()=>{e.removeEventListener(o,r,s)})}function z(o,e,t){(e[hd]??(e[hd]={}))[o]=t}function zs(o){for(var e=0;e<o.length;e++)JP.add(o[e]);for(var t of qS)t(o)}let ZL=null;function GS(o){var x,k;var e=this,t=e.ownerDocument,i=o.type,n=((x=o.composedPath)==null?void 0:x.call(o))||[],s=n[0]||o.target;ZL=o;var r=0,a=ZL===o&&o[hd];if(a){var d=n.indexOf(a);if(d!==-1&&(e===document||e===window)){o[hd]=e;return}var u=n.indexOf(e);if(u===-1)return;d<=u&&(r=d)}if(s=n[r]||o.target,s!==e){C3(o,"currentTarget",{configurable:!0,get(){return s||t}});var f=In,g=Dn;Or(null),qa(null);try{for(var p,w=[];s!==null&&s!==e;){try{var y=(k=s[hd])==null?void 0:k[i];y!=null&&(!s.disabled||o.target===s)&&y.call(s,o)}catch(D){p?w.push(D):p=D}if(o.cancelBubble)break;r++,s=r<n.length?n[r]:null}if(p){for(let D of w)queueMicrotask(()=>{throw D});throw p}}finally{o[hd]=e,delete o.currentTarget,Or(f),qa(g)}}}var RD;const Tw=((RD=globalThis==null?void 0:globalThis.window)==null?void 0:RD.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:o=>o});function jH(o){return(Tw==null?void 0:Tw.createHTML(o))??o}function eM(o){var e=WP("template");return e.innerHTML=jH(o.replaceAll("<!>","<!---->")),e.content}function wu(o,e){var t=Dn;t.nodes===null&&(t.nodes={start:o,end:e,a:null,t:null})}function T(o,e){var t=(e&J3)!==0,i=(e&eH)!==0,n,s=!o.startsWith("<!>");return()=>{n===void 0&&(n=eM(s?o:"<!>"+o),t||(n=Oa(n)));var r=i||AP?document.importNode(n,!0):n.cloneNode(!0);if(t){var a=Oa(r),d=r.lastChild;wu(a,d)}else wu(r,r);return r}}function $H(o,e,t="svg"){var i=!o.startsWith("<!>"),n=`<${t}>${i?o:"<!>"+o}</${t}>`,s;return()=>{if(!s){var r=eM(n),a=Oa(r);s=Oa(a)}var d=s.cloneNode(!0);return wu(d,d),d}}function tM(o,e){return $H(o,e,"svg")}function po(o=""){{var e=vl(o+"");return wu(e,e),e}}function As(){var o=document.createDocumentFragment(),e=document.createComment(""),t=vl();return o.append(e,t),wu(e,t),o}function I(o,e){o!==null&&o.before(e)}function N(o,e){var t=e==null?"":typeof e=="object"?`${e}`:e;t!==(o[kg]??(o[kg]=o.nodeValue))&&(o[kg]=t,o.nodeValue=`${t}`)}function UH(o,e){return qH(o,e)}const em=new Map;function qH(o,{target:e,anchor:t,props:i={},events:n,context:s,intro:r=!0,transformError:a}){TH();var d=void 0,u=AH(()=>{var f=t??e.appendChild(vl());mH(f,{pending:()=>{}},w=>{Ts({});var y=ro;s&&(y.c=s),n&&(i.$$events=n),d=o(w,i)||{},Ps()},a);var g=new Set,p=w=>{for(var y=0;y<w.length;y++){var x=w[y];if(!g.has(x)){g.add(x);var k=zH(x);for(const F of[e,document]){var D=em.get(F);D===void 0&&(D=new Map,em.set(F,D));var M=D.get(x);M===void 0?(F.addEventListener(x,GS,{passive:k}),D.set(x,1)):D.set(x,M+1)}}}};return p(Fy(JP)),qS.add(p),()=>{var k;for(var w of g)for(const D of[e,document]){var y=em.get(D),x=y.get(w);--x==0?(D.removeEventListener(w,GS),y.delete(w),y.size===0&&em.delete(D)):y.set(w,x)}qS.delete(p),f!==t&&((k=f.parentNode)==null||k.removeChild(f))}});return GH.set(d,u),d}let GH=new WeakMap;var Xr,Ea,sr,vd,i_,n_,Lb;class KH{constructor(e,t=!0){yn(this,"anchor");gn(this,Xr,new Map);gn(this,Ea,new Map);gn(this,sr,new Map);gn(this,vd,new Set);gn(this,i_,!0);gn(this,n_,e=>{if(be(this,Xr).has(e)){var t=be(this,Xr).get(e),i=be(this,Ea).get(t);if(i)_v(i),be(this,vd).delete(t);else{var n=be(this,sr).get(t);n&&(_v(n.effect),be(this,Ea).set(t,n.effect),be(this,sr).delete(t),n.fragment.lastChild.remove(),this.anchor.before(n.fragment),i=n.effect)}for(const[s,r]of be(this,Xr)){if(be(this,Xr).delete(s),s===e)break;const a=be(this,sr).get(r);a&&(qo(a.effect),be(this,sr).delete(r))}for(const[s,r]of be(this,Ea)){if(s===t||be(this,vd).has(s))continue;const a=()=>{if(Array.from(be(this,Xr).values()).includes(s)){var u=document.createDocumentFragment();O0(r,u),u.append(vl()),be(this,sr).set(s,{effect:r,fragment:u})}else qo(r);be(this,vd).delete(s),be(this,Ea).delete(s)};be(this,i_)||!i?(be(this,vd).add(s),kd(r,a,!1)):a()}}});gn(this,Lb,e=>{be(this,Xr).delete(e);const t=Array.from(be(this,Xr).values());for(const[i,n]of be(this,sr))t.includes(i)||(qo(n.effect),be(this,sr).delete(i))});this.anchor=e,pn(this,i_,t)}ensure(e,t){var i=Yi,n=HP();if(t&&!be(this,Ea).has(e)&&!be(this,sr).has(e))if(n){var s=document.createDocumentFragment(),r=vl();s.append(r),be(this,sr).set(e,{effect:Lr(()=>t(r)),fragment:s})}else be(this,Ea).set(e,Lr(()=>t(this.anchor)));if(be(this,Xr).set(i,e),n){for(const[a,d]of be(this,Ea))a===e?i.unskip_effect(d):i.skip_effect(d);for(const[a,d]of be(this,sr))a===e?i.unskip_effect(d.effect):i.skip_effect(d.effect);i.oncommit(be(this,n_)),i.ondiscard(be(this,Lb))}else be(this,n_).call(this,i)}}Xr=new WeakMap,Ea=new WeakMap,sr=new WeakMap,vd=new WeakMap,i_=new WeakMap,n_=new WeakMap,Lb=new WeakMap;function O(o,e,t=!1){var i=new KH(o),n=t?Sf:0;function s(r,a){i.ensure(r,a)}N0(()=>{var r=!1;e((a,d=0)=>{r=!0,s(d,a)}),r||s(-1,null)},n)}function Vi(o,e){return e}function ZH(o,e,t){for(var i=[],n=e.length,s,r=e.length,a=0;a<n;a++){let g=e[a];kd(g,()=>{if(s){if(s.pending.delete(g),s.done.add(g),s.pending.size===0){var p=o.outrogroups;KS(o,Fy(s.done)),p.delete(s),p.size===0&&(o.outrogroups=null)}}else r-=1},!1)}if(r===0){var d=i.length===0&&t!==null;if(d){var u=t,f=u.parentNode;PH(f),f.append(u),o.items.clear()}KS(o,e,!d)}else s={pending:new Set(e),done:new Set},(o.outrogroups??(o.outrogroups=new Set)).add(s)}function KS(o,e,t=!0){var i;if(o.pending.size>0){i=new Set;for(const r of o.pending.values())for(const a of r)i.add(o.items.get(a).e)}for(var n=0;n<e.length;n++){var s=e[n];if(i!=null&&i.has(s)){s.f|=Aa;const r=document.createDocumentFragment();O0(s,r)}else qo(e[n],t)}}var YL;function ni(o,e,t,i,n,s=null){var r=o,a=new Map,d=(e&pP)!==0;if(d){var u=o;r=u.appendChild(vl())}var f=null,g=E0(()=>{var F=t();return x0(F)?F:F==null?[]:Fy(F)}),p,w=new Map,y=!0;function x(F){(M.effect.f&Rr)===0&&(M.pending.delete(F),M.fallback=f,YH(M,p,r,e,i),f!==null&&(p.length===0?(f.f&Aa)===0?_v(f):(f.f^=Aa,Eg(f,null,r)):kd(f,()=>{f=null})))}function k(F){M.pending.delete(F)}var D=N0(()=>{p=c(g);for(var F=p.length,K=new Set,V=Yi,se=HP(),te=0;te<F;te+=1){var pe=p[te],je=i(pe,te),Ke=y?null:a.get(je);Ke?(Ke.v&&xf(Ke.v,pe),Ke.i&&xf(Ke.i,te),se&&V.unskip_effect(Ke.e)):(Ke=XH(a,y?r:YL??(YL=vl()),pe,je,te,n,e,t),y||(Ke.e.f|=Aa),a.set(je,Ke)),K.add(je)}if(F===0&&s&&!f&&(y?f=Lr(()=>s(r)):(f=Lr(()=>s(YL??(YL=vl()))),f.f|=Aa)),F>K.size&&A3(),!y)if(w.set(V,K),se){for(const[ue,He]of a)K.has(ue)||V.skip_effect(He.e);V.oncommit(x),V.ondiscard(k)}else x(V);c(g)}),M={effect:D,items:a,pending:w,outrogroups:null,fallback:f};y=!1}function pg(o){for(;o!==null&&(o.f&la)===0;)o=o.next;return o}function YH(o,e,t,i,n){var Ke,ue,He,dt,we,gt,ot,Pt,Oe;var s=(i&G3)!==0,r=e.length,a=o.items,d=pg(o.effect.first),u,f=null,g,p=[],w=[],y,x,k,D;if(s)for(D=0;D<r;D+=1)y=e[D],x=n(y,D),k=a.get(x).e,(k.f&Aa)===0&&((ue=(Ke=k.nodes)==null?void 0:Ke.a)==null||ue.measure(),(g??(g=new Set)).add(k));for(D=0;D<r;D+=1){if(y=e[D],x=n(y,D),k=a.get(x).e,o.outrogroups!==null)for(const Mt of o.outrogroups)Mt.pending.delete(k),Mt.done.delete(k);if((k.f&Eo)!==0&&(_v(k),s&&((dt=(He=k.nodes)==null?void 0:He.a)==null||dt.unfix(),(g??(g=new Set)).delete(k))),(k.f&Aa)!==0)if(k.f^=Aa,k===d)Eg(k,null,t);else{var M=f?f.next:d;k===o.effect.last&&(o.effect.last=k.prev),k.prev&&(k.prev.next=k.next),k.next&&(k.next.prev=k.prev),jl(o,f,k),jl(o,k,M),Eg(k,M,t),f=k,p=[],w=[],d=pg(f.next);continue}if(k!==d){if(u!==void 0&&u.has(k)){if(p.length<w.length){var F=w[0],K;f=F.prev;var V=p[0],se=p[p.length-1];for(K=0;K<p.length;K+=1)Eg(p[K],F,t);for(K=0;K<w.length;K+=1)u.delete(w[K]);jl(o,V.prev,se.next),jl(o,f,V),jl(o,se,F),d=F,f=se,D-=1,p=[],w=[]}else u.delete(k),Eg(k,d,t),jl(o,k.prev,k.next),jl(o,k,f===null?o.effect.first:f.next),jl(o,f,k),f=k;continue}for(p=[],w=[];d!==null&&d!==k;)(u??(u=new Set)).add(d),w.push(d),d=pg(d.next);if(d===null)continue}(k.f&Aa)===0&&p.push(k),f=k,d=pg(k.next)}if(o.outrogroups!==null){for(const Mt of o.outrogroups)Mt.pending.size===0&&(KS(o,Fy(Mt.done)),(we=o.outrogroups)==null||we.delete(Mt));o.outrogroups.size===0&&(o.outrogroups=null)}if(d!==null||u!==void 0){var te=[];if(u!==void 0)for(k of u)(k.f&Eo)===0&&te.push(k);for(;d!==null;)(d.f&Eo)===0&&d!==o.fallback&&te.push(d),d=pg(d.next);var pe=te.length;if(pe>0){var je=(i&pP)!==0&&r===0?t:null;if(s){for(D=0;D<pe;D+=1)(ot=(gt=te[D].nodes)==null?void 0:gt.a)==null||ot.measure();for(D=0;D<pe;D+=1)(Oe=(Pt=te[D].nodes)==null?void 0:Pt.a)==null||Oe.fix()}ZH(o,te,je)}}s&&fc(()=>{var Mt,et;if(g!==void 0)for(k of g)(et=(Mt=k.nodes)==null?void 0:Mt.a)==null||et.apply()})}function XH(o,e,t,i,n,s,r,a){var d=(r&U3)!==0?(r&K3)===0?IH(t,!1,!1):yu(t):null,u=(r&q3)!==0?yu(n):null;return{v:d,i:u,e:Lr(()=>(s(e,d??t,u??n,a),()=>{o.delete(i)}))}}function Eg(o,e,t){if(o.nodes)for(var i=o.nodes.start,n=o.nodes.end,s=e&&(e.f&Aa)===0?e.nodes.start:t;i!==null;){var r=S_(i);if(s.before(i),i===n)return;i=r}}function jl(o,e,t){e===null?o.effect.first=t:e.next=t,t===null?o.effect.last=e:t.prev=e}function rc(o,e,t=!1,i=!1,n=!1,s=!1){var r=o,a="";if(t)var d=o;H(()=>{var u=Dn;if(a!==(a=e()??"")){if(t){u.nodes=null,d.innerHTML=a,a!==""&&wu(Oa(d),d.lastChild);return}if(u.nodes!==null&&(VP(u.nodes.start,u.nodes.end),u.nodes=null),a!==""){var f=i?tH:n?iH:void 0,g=WP(i?"svg":n?"math":"template",f);g.innerHTML=a;var p=i||n?g:g.content;if(wu(Oa(p),p.lastChild),i||n)for(;Oa(p);)r.before(Oa(p));else r.before(p)}}})}function iM(o){var e,t,i="";if(typeof o=="string"||typeof o=="number")i+=o;else if(typeof o=="object")if(Array.isArray(o)){var n=o.length;for(e=0;e<n;e++)o[e]&&(t=iM(o[e]))&&(i&&(i+=" "),i+=t)}else for(t in o)o[t]&&(i&&(i+=" "),i+=t);return i}function QH(){for(var o,e,t=0,i="",n=arguments.length;t<n;t++)(o=arguments[t])&&(e=iM(o))&&(i&&(i+=" "),i+=e);return i}function Kg(o){return typeof o=="object"?QH(o):o??""}const XL=[...`
3
- \r\f \v\uFEFF`];function JH(o,e,t){var i=o==null?"":""+o;if(e&&(i=i?i+" "+e:e),t){for(var n of Object.keys(t))if(t[n])i=i?i+" "+n:n;else if(i.length)for(var s=n.length,r=0;(r=i.indexOf(n,r))>=0;){var a=r+s;(r===0||XL.includes(i[r-1]))&&(a===i.length||XL.includes(i[a]))?i=(r===0?"":i.substring(0,r))+i.substring(a+1):r=a}}return i===""?null:i}function QL(o,e=!1){var t=e?" !important;":";",i="";for(var n of Object.keys(o)){var s=o[n];s!=null&&s!==""&&(i+=" "+n+": "+s+t)}return i}function Pw(o){return o[0]!=="-"||o[1]!=="-"?o.toLowerCase():o}function eW(o,e){if(e){var t="",i,n;if(Array.isArray(e)?(i=e[0],n=e[1]):i=e,o){o=String(o).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var s=!1,r=0,a=!1,d=[];i&&d.push(...Object.keys(i).map(Pw)),n&&d.push(...Object.keys(n).map(Pw));var u=0,f=-1;const x=o.length;for(var g=0;g<x;g++){var p=o[g];if(a?p==="/"&&o[g-1]==="*"&&(a=!1):s?s===p&&(s=!1):p==="/"&&o[g+1]==="*"?a=!0:p==='"'||p==="'"?s=p:p==="("?r++:p===")"&&r--,!a&&s===!1&&r===0){if(p===":"&&f===-1)f=g;else if(p===";"||g===x-1){if(f!==-1){var w=Pw(o.substring(u,f).trim());if(!d.includes(w)){p!==";"&&g++;var y=o.substring(u,g).trim();t+=" "+y+";"}}u=g+1,f=-1}}}}return i&&(t+=QL(i)),n&&(t+=QL(n,!0)),t=t.trim(),t===""?null:t}return o==null?null:String(o)}function kt(o,e,t,i,n,s){var r=o[HS];if(r!==t||r===void 0){var a=JH(t,i,s);a==null?o.removeAttribute("class"):e?o.className=a:o.setAttribute("class",a),o[HS]=t}else if(s&&n!==s)for(var d in s){var u=!!s[d];(n==null||u!==!!n[d])&&o.classList.toggle(d,u)}return s}function Mw(o,e={},t,i){for(var n in t){var s=t[n];e[n]!==s&&(t[n]==null?o.style.removeProperty(n):o.style.setProperty(n,s,i))}}function zo(o,e,t,i){var n=o[WS];if(n!==e){var s=eW(e,i);s==null?o.removeAttribute("style"):o.style.cssText=s,o[WS]=e}else i&&(Array.isArray(i)?(Mw(o,t==null?void 0:t[0],i[0]),Mw(o,t==null?void 0:t[1],i[1],"important")):Mw(o,t,i));return i}function mv(o,e,t=!1){if(o.multiple){if(e==null)return;if(!x0(e))return sH();for(var i of o.options)i.selected=e.includes(Zg(i));return}for(i of o.options){var n=Zg(i);if(DH(n,e)){i.selected=!0;return}}(!t||e!==void 0)&&(o.selectedIndex=-1)}function ZS(o){var e=new MutationObserver(()=>{mv(o,o.__value)});e.observe(o,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),M0(()=>{e.disconnect()})}function ys(o,e,t=e){var i=new WeakSet,n=!0;T0(o,"change",s=>{var r=s?"[selected]":":checked",a;if(o.multiple)a=[].map.call(o.querySelectorAll(r),Zg);else{var d=o.querySelector(r)??o.querySelector("option:not([disabled])");a=d&&Zg(d)}t(a),o.__value=a,Yi!==null&&i.add(Yi)}),R0(()=>{var s=e();if(o===document.activeElement){var r=Yi;if(i.has(r))return}if(mv(o,s,n),n&&s===void 0){var a=o.querySelector(":checked");a!==null&&(s=Zg(a),t(s))}o.__value=s,n=!1}),ZS(o)}function Zg(o){return"__value"in o?o.__value:o.value}const tW=Symbol("is custom element"),iW=Symbol("is html"),nW=R3?"progress":"PROGRESS";function YS(o,e){var t=F0(o);t.value===(t.value=e??void 0)||o.value===e&&(e!==0||o.nodeName!==nW)||(o.value=e??"")}function hl(o,e){var t=F0(o);t.checked!==(t.checked=e??void 0)&&(o.checked=e)}function ln(o,e,t,i){var n=F0(o);n[e]!==(n[e]=t)&&(e==="loading"&&(o[M3]=t),t==null?o.removeAttribute(e):typeof t!="string"&&sW(o).includes(e)?o[e]=t:o.setAttribute(e,t))}function F0(o){return o[Nm]??(o[Nm]={[tW]:o.nodeName.includes("-"),[iW]:o.namespaceURI===_P})}var JL=new Map;function sW(o){var e=o.getAttribute("is")||o.nodeName,t=JL.get(e);if(t)return t;JL.set(e,t=[]);for(var i,n=o,s=Element.prototype;s!==n;){i=x3(n);for(var r in i)i[r].set&&r!=="innerHTML"&&r!=="textContent"&&r!=="innerText"&&t.push(r);n=uP(n)}return t}function Ht(o,e,t=e){var i=new WeakSet;T0(o,"input",async n=>{var s=n?o.defaultValue:o.value;if(s=Rw(o)?Nw(s):s,t(s),Yi!==null&&i.add(Yi),await Gg(),s!==(s=e())){var r=o.selectionStart,a=o.selectionEnd,d=o.value.length;if(o.value=s??"",a!==null){var u=o.value.length;r===a&&a===d&&u>d?(o.selectionStart=u,o.selectionEnd=u):(o.selectionStart=r,o.selectionEnd=Math.min(a,u))}}}),Fl(e)==null&&o.value&&(t(Rw(o)?Nw(o.value):o.value),Yi!==null&&i.add(Yi)),Vy(()=>{var n=e();if(o===document.activeElement){var s=Yi;if(i.has(s))return}Rw(o)&&n===Nw(o.value)||o.type==="date"&&!n&&!o.value||n!==o.value&&(o.value=n??"")})}function ms(o,e,t=e){T0(o,"change",i=>{var n=i?o.defaultChecked:o.checked;t(n)}),Fl(e)==null&&t(o.checked),Vy(()=>{var i=e();o.checked=!!i})}function Rw(o){var e=o.type;return e==="number"||e==="range"}function Nw(o){return o===""?null:+o}var nc,Jh,s_,Ib,nM;const Eb=class Eb{constructor(e){gn(this,Ib);gn(this,nc,new WeakMap);gn(this,Jh);gn(this,s_);pn(this,s_,e)}observe(e,t){var i=be(this,nc).get(e)||new Set;return i.add(t),be(this,nc).set(e,i),zn(this,Ib,nM).call(this).observe(e,be(this,s_)),()=>{var n=be(this,nc).get(e);n.delete(t),n.size===0&&(be(this,nc).delete(e),be(this,Jh).unobserve(e))}}};nc=new WeakMap,Jh=new WeakMap,s_=new WeakMap,Ib=new WeakSet,nM=function(){return be(this,Jh)??pn(this,Jh,new ResizeObserver(e=>{for(var t of e){Eb.entries.set(t.target,t);for(var i of be(this,nc).get(t.target)||[])i(t)}}))},yn(Eb,"entries",new WeakMap);let XS=Eb;var oW=new XS({box:"border-box"});function rW(o,e,t){var i=oW.observe(o,()=>t(o[e]));R0(()=>(Fl(()=>t(o[e])),i))}function Aw(o,e){return o===e||(o==null?void 0:o[Sd])===e}function vs(o={},e,t,i){var n=ro.r,s=Dn;return R0(()=>{var r,a;return Vy(()=>{r=a,a=[],Fl(()=>{Aw(t(...a),o)||(e(o,...a),r&&Aw(t(...r),o)&&e(null,...r))})}),()=>{let d=s;for(;d!==n&&d.parent!==null&&d.parent.f&FS;)d=d.parent;const u=()=>{a&&Aw(t(...a),o)&&e(null,...a)},f=d.teardown;d.teardown=()=>{u(),f==null||f()}}}),o}function Su(o,e,t,i){var K;var n=!0,s=(t&X3)!==0,r=(t&Q3)!==0,a=i,d=!0,u=void 0,f=()=>r&&n?(u??(u=wp(i)),c(u)):(d&&(d=!1,a=r?Fl(i):i),a);let g;if(s){var p=Sd in o||P3 in o;g=((K=zh(o,e))==null?void 0:K.set)??(p&&e in o?V=>o[e]=V:void 0)}var w,y=!1;s?[w,y]=dH(()=>o[e]):w=o[e],w===void 0&&i!==void 0&&(w=f(),g&&(B3(),g(w)));var x;if(x=()=>{var V=o[e];return V===void 0?f():(d=!0,V)},(t&Y3)===0)return x;if(g){var k=o.$$legacy;return(function(V,se){return arguments.length>0?((!se||k||y)&&g(se?x():V),V):x()})}var D=!1,M=((t&Z3)!==0?wp:E0)(()=>(D=!1,x()));s&&c(M);var F=Dn;return(function(V,se){if(arguments.length>0){const te=se?c(M):s?yi(V):V;return v(M,te),D=!0,a!==void 0&&(a=te),V}return Ll&&D||(F.f&Rr)!==0?M.v:c(M)})}function Bs(o){ro===null&&gP(),Vn(()=>{const e=Fl(o);if(typeof e=="function")return e})}function x_(o){ro===null&&gP(),Bs(()=>()=>Fl(o))}const aW="5";var ND;typeof window<"u"&&((ND=window.__svelte??(window.__svelte={})).v??(ND.v=new Set)).add(aW);/*!-----------------------------------------------------------------------------
4
- * Copyright (c) Microsoft Corporation. All rights reserved.
5
- * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
6
- * Released under the MIT license
7
- * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
8
- *-----------------------------------------------------------------------------*/var lW=Object.defineProperty,cW=Object.getOwnPropertyDescriptor,dW=Object.getOwnPropertyNames,uW=Object.prototype.hasOwnProperty,hW=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of dW(e))!uW.call(o,n)&&n!==t&&lW(o,n,{get:()=>e[n],enumerable:!(i=cW(e,n))||i.enumerable});return o},fW=(o,e,t)=>(hW(o,e,"default"),t),k_={};fW(k_,OD);var gW=class{constructor(e,t,i){this._onDidChange=new k_.Emitter,this._languageId=e,this.setDiagnosticsOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}},pW={validate:!0,allowComments:!0,schemas:[],enableSchemaRequest:!1,schemaRequest:"warning",schemaValidation:"warning",comments:"error",trailingCommas:"error"},_W={documentFormattingEdits:!0,documentRangeFormattingEdits:!0,completionItems:!0,hovers:!0,documentSymbols:!0,tokens:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0},sM=new gW("json",pW,_W),mW=()=>oM().then(o=>o.getWorker());k_.languages.json={jsonDefaults:sM,getWorker:mW};function oM(){return AD(()=>import("./jsonMode-CXWNuhmR.js"),__vite__mapDeps([0,1,2]))}k_.languages.register({id:"json",extensions:[".json",".bowerrc",".jshintrc",".jscsrc",".eslintrc",".babelrc",".har"],aliases:["JSON","json"],mimetypes:["application/json"]});k_.languages.onLanguage("json",()=>{oM().then(o=>o.setupMode(sM))});/*!-----------------------------------------------------------------------------
9
- * Copyright (c) Microsoft Corporation. All rights reserved.
10
- * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
11
- * Released under the MIT license
12
- * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
13
- *-----------------------------------------------------------------------------*/var vW=Object.defineProperty,bW=Object.getOwnPropertyDescriptor,yW=Object.getOwnPropertyNames,wW=Object.prototype.hasOwnProperty,SW=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of yW(e))!wW.call(o,n)&&n!==t&&vW(o,n,{get:()=>e[n],enumerable:!(i=bW(e,n))||i.enumerable});return o},CW=(o,e,t)=>(SW(o,e,"default"),t),xW="5.4.5",Lf={};CW(Lf,OD);var rM=(o=>(o[o.None=0]="None",o[o.CommonJS=1]="CommonJS",o[o.AMD=2]="AMD",o[o.UMD=3]="UMD",o[o.System=4]="System",o[o.ES2015=5]="ES2015",o[o.ESNext=99]="ESNext",o))(rM||{}),aM=(o=>(o[o.None=0]="None",o[o.Preserve=1]="Preserve",o[o.React=2]="React",o[o.ReactNative=3]="ReactNative",o[o.ReactJSX=4]="ReactJSX",o[o.ReactJSXDev=5]="ReactJSXDev",o))(aM||{}),lM=(o=>(o[o.CarriageReturnLineFeed=0]="CarriageReturnLineFeed",o[o.LineFeed=1]="LineFeed",o))(lM||{}),cM=(o=>(o[o.ES3=0]="ES3",o[o.ES5=1]="ES5",o[o.ES2015=2]="ES2015",o[o.ES2016=3]="ES2016",o[o.ES2017=4]="ES2017",o[o.ES2018=5]="ES2018",o[o.ES2019=6]="ES2019",o[o.ES2020=7]="ES2020",o[o.ESNext=99]="ESNext",o[o.JSON=100]="JSON",o[o.Latest=99]="Latest",o))(cM||{}),dM=(o=>(o[o.Classic=1]="Classic",o[o.NodeJs=2]="NodeJs",o))(dM||{}),uM=class{constructor(o,e,t,i,n){this._onDidChange=new Lf.Emitter,this._onDidExtraLibsChange=new Lf.Emitter,this._extraLibs=Object.create(null),this._removedExtraLibs=Object.create(null),this._eagerModelSync=!1,this.setCompilerOptions(o),this.setDiagnosticsOptions(e),this.setWorkerOptions(t),this.setInlayHintsOptions(i),this.setModeConfiguration(n),this._onDidExtraLibsChangeTimeout=-1}get onDidChange(){return this._onDidChange.event}get onDidExtraLibsChange(){return this._onDidExtraLibsChange.event}get modeConfiguration(){return this._modeConfiguration}get workerOptions(){return this._workerOptions}get inlayHintsOptions(){return this._inlayHintsOptions}getExtraLibs(){return this._extraLibs}addExtraLib(o,e){let t;if(typeof e>"u"?t=`ts:extralib-${Math.random().toString(36).substring(2,15)}`:t=e,this._extraLibs[t]&&this._extraLibs[t].content===o)return{dispose:()=>{}};let i=1;return this._removedExtraLibs[t]&&(i=this._removedExtraLibs[t]+1),this._extraLibs[t]&&(i=this._extraLibs[t].version+1),this._extraLibs[t]={content:o,version:i},this._fireOnDidExtraLibsChangeSoon(),{dispose:()=>{let n=this._extraLibs[t];n&&n.version===i&&(delete this._extraLibs[t],this._removedExtraLibs[t]=i,this._fireOnDidExtraLibsChangeSoon())}}}setExtraLibs(o){for(const e in this._extraLibs)this._removedExtraLibs[e]=this._extraLibs[e].version;if(this._extraLibs=Object.create(null),o&&o.length>0)for(const e of o){const t=e.filePath||`ts:extralib-${Math.random().toString(36).substring(2,15)}`,i=e.content;let n=1;this._removedExtraLibs[t]&&(n=this._removedExtraLibs[t]+1),this._extraLibs[t]={content:i,version:n}}this._fireOnDidExtraLibsChangeSoon()}_fireOnDidExtraLibsChangeSoon(){this._onDidExtraLibsChangeTimeout===-1&&(this._onDidExtraLibsChangeTimeout=window.setTimeout(()=>{this._onDidExtraLibsChangeTimeout=-1,this._onDidExtraLibsChange.fire(void 0)},0))}getCompilerOptions(){return this._compilerOptions}setCompilerOptions(o){this._compilerOptions=o||Object.create(null),this._onDidChange.fire(void 0)}getDiagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(o){this._diagnosticsOptions=o||Object.create(null),this._onDidChange.fire(void 0)}setWorkerOptions(o){this._workerOptions=o||Object.create(null),this._onDidChange.fire(void 0)}setInlayHintsOptions(o){this._inlayHintsOptions=o||Object.create(null),this._onDidChange.fire(void 0)}setMaximumWorkerIdleTime(o){}setEagerModelSync(o){this._eagerModelSync=o}getEagerModelSync(){return this._eagerModelSync}setModeConfiguration(o){this._modeConfiguration=o||Object.create(null),this._onDidChange.fire(void 0)}},kW=xW,hM={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,diagnostics:!0,documentRangeFormattingEdits:!0,signatureHelp:!0,onTypeFormattingEdits:!0,codeActions:!0,inlayHints:!0},fM=new uM({allowNonTsExtensions:!0,target:99},{noSemanticValidation:!1,noSyntaxValidation:!1,onlyVisible:!1},{},{},hM),gM=new uM({allowNonTsExtensions:!0,allowJs:!0,target:99},{noSemanticValidation:!0,noSyntaxValidation:!1,onlyVisible:!1},{},{},hM),LW=()=>jy().then(o=>o.getTypeScriptWorker()),IW=()=>jy().then(o=>o.getJavaScriptWorker());Lf.languages.typescript={ModuleKind:rM,JsxEmit:aM,NewLineKind:lM,ScriptTarget:cM,ModuleResolutionKind:dM,typescriptVersion:kW,typescriptDefaults:fM,javascriptDefaults:gM,getTypeScriptWorker:LW,getJavaScriptWorker:IW};function jy(){return AD(()=>import("./tsMode-DK6XHYAS.js"),__vite__mapDeps([3,1,2]))}Lf.languages.onLanguage("typescript",()=>jy().then(o=>o.setupTypeScript(fM)));Lf.languages.onLanguage("javascript",()=>jy().then(o=>o.setupJavaScript(gM)));class EW extends yo{constructor(){super({id:"diffEditor.toggleCollapseUnchangedRegions",title:ui("toggleCollapseUnchangedRegions","Toggle Collapse Unchanged Regions"),icon:ji.map,toggled:Ae.has("config.diffEditor.hideUnchangedRegions.enabled"),precondition:Ae.has("isInDiffEditor"),menu:{when:Ae.has("isInDiffEditor"),id:Gt.EditorTitle,order:22,group:"navigation"}})}run(e,...t){const i=e.get(Un),n=!i.getValue("diffEditor.hideUnchangedRegions.enabled");i.updateValue("diffEditor.hideUnchangedRegions.enabled",n)}}class pM extends yo{constructor(){super({id:"diffEditor.toggleShowMovedCodeBlocks",title:ui("toggleShowMovedCodeBlocks","Toggle Show Moved Code Blocks"),precondition:Ae.has("isInDiffEditor")})}run(e,...t){const i=e.get(Un),n=!i.getValue("diffEditor.experimental.showMoves");i.updateValue("diffEditor.experimental.showMoves",n)}}class _M extends yo{constructor(){super({id:"diffEditor.toggleUseInlineViewWhenSpaceIsLimited",title:ui("toggleUseInlineViewWhenSpaceIsLimited","Toggle Use Inline View When Space Is Limited"),precondition:Ae.has("isInDiffEditor")})}run(e,...t){const i=e.get(Un),n=!i.getValue("diffEditor.useInlineViewWhenSpaceIsLimited");i.updateValue("diffEditor.useInlineViewWhenSpaceIsLimited",n)}}const L_=ui("diffEditor","Diff Editor");class DW extends ca{constructor(){super({id:"diffEditor.switchSide",title:ui("switchSide","Switch Side"),icon:ji.arrowSwap,precondition:Ae.has("isInDiffEditor"),f1:!0,category:L_})}runEditorCommand(e,t,i){const n=Kf(e);if(n instanceof o_){if(i&&i.dryRun)return{destinationSelection:n.mapToOtherSide().destinationSelection};n.switchSide()}}}class TW extends ca{constructor(){super({id:"diffEditor.exitCompareMove",title:ui("exitCompareMove","Exit Compare Move"),icon:ji.close,precondition:B.comparingMovedCode,f1:!1,category:L_,keybinding:{weight:1e4,primary:9}})}runEditorCommand(e,t,...i){const n=Kf(e);n instanceof o_&&n.exitCompareMove()}}class PW extends ca{constructor(){super({id:"diffEditor.collapseAllUnchangedRegions",title:ui("collapseAllUnchangedRegions","Collapse All Unchanged Regions"),icon:ji.fold,precondition:Ae.has("isInDiffEditor"),f1:!0,category:L_})}runEditorCommand(e,t,...i){const n=Kf(e);n instanceof o_&&n.collapseAllUnchangedRegions()}}class MW extends ca{constructor(){super({id:"diffEditor.showAllUnchangedRegions",title:ui("showAllUnchangedRegions","Show All Unchanged Regions"),icon:ji.unfold,precondition:Ae.has("isInDiffEditor"),f1:!0,category:L_})}runEditorCommand(e,t,...i){const n=Kf(e);n instanceof o_&&n.showAllUnchangedRegions()}}class QS extends yo{constructor(){super({id:"diffEditor.revert",title:ui("revert","Revert"),f1:!1,category:L_})}run(e,t){const i=RW(e,t.originalUri,t.modifiedUri);i instanceof o_&&i.revertRangeMappings(t.mapping.innerChanges??[])}}const mM=ui("accessibleDiffViewer","Accessible Diff Viewer"),Db=class Db extends yo{constructor(){super({id:Db.id,title:ui("editor.action.accessibleDiffViewer.next","Go to Next Difference"),category:mM,precondition:Ae.has("isInDiffEditor"),keybinding:{primary:65,weight:100},f1:!0})}run(e){const t=Kf(e);t==null||t.accessibleDiffViewerNext()}};Db.id="editor.action.accessibleDiffViewer.next";let Cp=Db;const Tb=class Tb extends yo{constructor(){super({id:Tb.id,title:ui("editor.action.accessibleDiffViewer.prev","Go to Previous Difference"),category:mM,precondition:Ae.has("isInDiffEditor"),keybinding:{primary:1089,weight:100},f1:!0})}run(e){const t=Kf(e);t==null||t.accessibleDiffViewerPrev()}};Tb.id="editor.action.accessibleDiffViewer.prev";let vv=Tb;function RW(o,e,t){return o.get(as).listDiffEditors().find(s=>{var d,u;const r=s.getModifiedEditor(),a=s.getOriginalEditor();return r&&((d=r.getModel())==null?void 0:d.uri.toString())===t.toString()&&a&&((u=a.getModel())==null?void 0:u.uri.toString())===e.toString()})||null}function Kf(o){const t=o.get(as).listDiffEditors(),i=FD();if(i)for(const n of t){const s=n.getContainerDomNode();if(NW(s,i))return n}return null}function NW(o,e){let t=e;for(;t;){if(t===o)return!0;t=t.parentElement}return!1}Tn(EW);Tn(pM);Tn(_M);Nr.appendMenuItem(Gt.EditorTitle,{command:{id:new _M().desc.id,title:C("useInlineViewWhenSpaceIsLimited","Use Inline View When Space Is Limited"),toggled:Ae.has("config.diffEditor.useInlineViewWhenSpaceIsLimited"),precondition:Ae.has("isInDiffEditor")},order:11,group:"1_diff",when:Ae.and(B.diffEditorRenderSideBySideInlineBreakpointReached,Ae.has("isInDiffEditor"))});Nr.appendMenuItem(Gt.EditorTitle,{command:{id:new pM().desc.id,title:C("showMoves","Show Moved Code Blocks"),icon:ji.move,toggled:jA.create("config.diffEditor.experimental.showMoves",!0),precondition:Ae.has("isInDiffEditor")},order:10,group:"1_diff",when:Ae.has("isInDiffEditor")});Tn(QS);for(const o of[{icon:ji.arrowRight,key:B.diffEditorInlineMode.toNegated()},{icon:ji.discard,key:B.diffEditorInlineMode}])Nr.appendMenuItem(Gt.DiffEditorHunkToolbar,{command:{id:new QS().desc.id,title:C("revertHunk","Revert Block"),icon:o.icon},when:Ae.and(B.diffEditorModifiedWritable,o.key),order:5,group:"primary"}),Nr.appendMenuItem(Gt.DiffEditorSelectionToolbar,{command:{id:new QS().desc.id,title:C("revertSelection","Revert Selection"),icon:o.icon},when:Ae.and(B.diffEditorModifiedWritable,o.key),order:5,group:"primary"});Tn(DW);Tn(TW);Tn(PW);Tn(MW);Nr.appendMenuItem(Gt.EditorTitle,{command:{id:Cp.id,title:C("Open Accessible Diff Viewer","Open Accessible Diff Viewer"),precondition:Ae.has("isInDiffEditor")},order:10,group:"2_diff",when:Ae.and(B.accessibleDiffViewerVisible.negate(),Ae.has("isInDiffEditor"))});Wn.registerCommandAlias("editor.action.diffReview.next",Cp.id);Tn(Cp);Wn.registerCommandAlias("editor.action.diffReview.prev",vv.id);Tn(vv);var AW=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},OW=function(o,e){return function(t,i){e(t,i,o)}},JS;const $y=new _n("selectionAnchorSet",!1);var Td;let Ac=(Td=class{static get(e){return e.getContribution(JS.ID)}constructor(e,t){this.editor=e,this.selectionAnchorSetContextKey=$y.bindTo(t),this.modelChangeListener=e.onDidChangeModel(()=>this.selectionAnchorSetContextKey.reset())}setSelectionAnchor(){if(this.editor.hasModel()){const e=this.editor.getPosition();this.editor.changeDecorations(t=>{this.decorationId&&t.removeDecoration(this.decorationId),this.decorationId=t.addDecoration(Fi.fromPositions(e,e),{description:"selection-anchor",stickiness:1,hoverMessage:new to().appendText(C("selectionAnchor","Selection Anchor")),className:"selection-anchor"})}),this.selectionAnchorSetContextKey.set(!!this.decorationId),Ar(C("anchorSet","Anchor set at {0}:{1}",e.lineNumber,e.column))}}goToSelectionAnchor(){if(this.editor.hasModel()&&this.decorationId){const e=this.editor.getModel().getDecorationRange(this.decorationId);e&&this.editor.setPosition(e.getStartPosition())}}selectFromAnchorToCursor(){if(this.editor.hasModel()&&this.decorationId){const e=this.editor.getModel().getDecorationRange(this.decorationId);if(e){const t=this.editor.getPosition();this.editor.setSelection(Fi.fromPositions(e.getStartPosition(),t)),this.cancelSelectionAnchor()}}}cancelSelectionAnchor(){if(this.decorationId){const e=this.decorationId;this.editor.changeDecorations(t=>{t.removeDecoration(e),this.decorationId=void 0}),this.selectionAnchorSetContextKey.set(!1)}}dispose(){this.cancelSelectionAnchor(),this.modelChangeListener.dispose()}},JS=Td,Td.ID="editor.contrib.selectionAnchorController",Td);Ac=JS=AW([OW(1,Sn)],Ac);class FW extends lt{constructor(){super({id:"editor.action.setSelectionAnchor",label:C("setSelectionAnchor","Set Selection Anchor"),alias:"Set Selection Anchor",precondition:void 0,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2080),weight:100}})}async run(e,t){var i;(i=Ac.get(t))==null||i.setSelectionAnchor()}}class HW extends lt{constructor(){super({id:"editor.action.goToSelectionAnchor",label:C("goToSelectionAnchor","Go to Selection Anchor"),alias:"Go to Selection Anchor",precondition:$y})}async run(e,t){var i;(i=Ac.get(t))==null||i.goToSelectionAnchor()}}class WW extends lt{constructor(){super({id:"editor.action.selectFromAnchorToCursor",label:C("selectFromAnchorToCursor","Select from Anchor to Cursor"),alias:"Select from Anchor to Cursor",precondition:$y,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2089),weight:100}})}async run(e,t){var i;(i=Ac.get(t))==null||i.selectFromAnchorToCursor()}}class BW extends lt{constructor(){super({id:"editor.action.cancelSelectionAnchor",label:C("cancelSelectionAnchor","Cancel Selection Anchor"),alias:"Cancel Selection Anchor",precondition:$y,kbOpts:{kbExpr:B.editorTextFocus,primary:9,weight:100}})}async run(e,t){var i;(i=Ac.get(t))==null||i.cancelSelectionAnchor()}}nn(Ac.ID,Ac,4);xe(FW);xe(HW);xe(WW);xe(BW);const zW=oi("editorOverviewRuler.bracketMatchForeground","#A0A0A0",C("overviewRulerBracketMatchForeground","Overview ruler marker color for matching brackets."));class VW extends lt{constructor(){super({id:"editor.action.jumpToBracket",label:C("smartSelect.jumpBracket","Go to Bracket"),alias:"Go to Bracket",precondition:void 0,kbOpts:{kbExpr:B.editorTextFocus,primary:3165,weight:100}})}run(e,t){var i;(i=Cu.get(t))==null||i.jumpToBracket()}}class jW extends lt{constructor(){super({id:"editor.action.selectToBracket",label:C("smartSelect.selectToBracket","Select to Bracket"),alias:"Select to Bracket",precondition:void 0,metadata:{description:ui("smartSelect.selectToBracketDescription","Select the text inside and including the brackets or curly braces"),args:[{name:"args",schema:{type:"object",properties:{selectBrackets:{type:"boolean",default:!0}}}}]}})}run(e,t,i){var s;let n=!0;i&&i.selectBrackets===!1&&(n=!1),(s=Cu.get(t))==null||s.selectToBracket(n)}}class $W extends lt{constructor(){super({id:"editor.action.removeBrackets",label:C("smartSelect.removeBrackets","Remove Brackets"),alias:"Remove Brackets",precondition:void 0,kbOpts:{kbExpr:B.editorTextFocus,primary:2561,weight:100}})}run(e,t){var i;(i=Cu.get(t))==null||i.removeBrackets(this.id)}}class UW{constructor(e,t,i){this.position=e,this.brackets=t,this.options=i}}const Yl=class Yl extends Dt{static get(e){return e.getContribution(Yl.ID)}constructor(e){super(),this._editor=e,this._lastBracketsData=[],this._lastVersionId=0,this._decorations=this._editor.createDecorationsCollection(),this._updateBracketsSoon=this._register(new Ss(()=>this._updateBrackets(),50)),this._matchBrackets=this._editor.getOption(72),this._updateBracketsSoon.schedule(),this._register(e.onDidChangeCursorPosition(t=>{this._matchBrackets!=="never"&&this._updateBracketsSoon.schedule()})),this._register(e.onDidChangeModelContent(t=>{this._updateBracketsSoon.schedule()})),this._register(e.onDidChangeModel(t=>{this._lastBracketsData=[],this._updateBracketsSoon.schedule()})),this._register(e.onDidChangeModelLanguageConfiguration(t=>{this._lastBracketsData=[],this._updateBracketsSoon.schedule()})),this._register(e.onDidChangeConfiguration(t=>{t.hasChanged(72)&&(this._matchBrackets=this._editor.getOption(72),this._decorations.clear(),this._lastBracketsData=[],this._lastVersionId=0,this._updateBracketsSoon.schedule())})),this._register(e.onDidBlurEditorWidget(()=>{this._updateBracketsSoon.schedule()})),this._register(e.onDidFocusEditorWidget(()=>{this._updateBracketsSoon.schedule()}))}jumpToBracket(){if(!this._editor.hasModel())return;const e=this._editor.getModel(),t=this._editor.getSelections().map(i=>{const n=i.getStartPosition(),s=e.bracketPairs.matchBracket(n);let r=null;if(s)s[0].containsPosition(n)&&!s[1].containsPosition(n)?r=s[1].getStartPosition():s[1].containsPosition(n)&&(r=s[0].getStartPosition());else{const a=e.bracketPairs.findEnclosingBrackets(n);if(a)r=a[1].getStartPosition();else{const d=e.bracketPairs.findNextBracket(n);d&&d.range&&(r=d.range.getStartPosition())}}return r?new Fi(r.lineNumber,r.column,r.lineNumber,r.column):new Fi(n.lineNumber,n.column,n.lineNumber,n.column)});this._editor.setSelections(t),this._editor.revealRange(t[0])}selectToBracket(e){if(!this._editor.hasModel())return;const t=this._editor.getModel(),i=[];this._editor.getSelections().forEach(n=>{const s=n.getStartPosition();let r=t.bracketPairs.matchBracket(s);if(!r&&(r=t.bracketPairs.findEnclosingBrackets(s),!r)){const u=t.bracketPairs.findNextBracket(s);u&&u.range&&(r=t.bracketPairs.matchBracket(u.range.getStartPosition()))}let a=null,d=null;if(r){r.sort(Z.compareRangesUsingStarts);const[u,f]=r;if(a=e?u.getStartPosition():u.getEndPosition(),d=e?f.getEndPosition():f.getStartPosition(),f.containsPosition(s)){const g=a;a=d,d=g}}a&&d&&i.push(new Fi(a.lineNumber,a.column,d.lineNumber,d.column))}),i.length>0&&(this._editor.setSelections(i),this._editor.revealRange(i[0]))}removeBrackets(e){if(!this._editor.hasModel())return;const t=this._editor.getModel();this._editor.getSelections().forEach(i=>{const n=i.getPosition();let s=t.bracketPairs.matchBracket(n);s||(s=t.bracketPairs.findEnclosingBrackets(n)),s&&(this._editor.pushUndoStop(),this._editor.executeEdits(e,[{range:s[0],text:""},{range:s[1],text:""}]),this._editor.pushUndoStop())})}_updateBrackets(){if(this._matchBrackets==="never")return;this._recomputeBrackets();const e=[];let t=0;for(const i of this._lastBracketsData){const n=i.brackets;n&&(e[t++]={range:n[0],options:i.options},e[t++]={range:n[1],options:i.options})}this._decorations.set(e)}_recomputeBrackets(){if(!this._editor.hasModel()||!this._editor.hasWidgetFocus()){this._lastBracketsData=[],this._lastVersionId=0;return}const e=this._editor.getSelections();if(e.length>100){this._lastBracketsData=[],this._lastVersionId=0;return}const t=this._editor.getModel(),i=t.getVersionId();let n=[];this._lastVersionId===i&&(n=this._lastBracketsData);const s=[];let r=0;for(let g=0,p=e.length;g<p;g++){const w=e[g];w.isEmpty()&&(s[r++]=w.getStartPosition())}s.length>1&&s.sort(gi.compare);const a=[];let d=0,u=0;const f=n.length;for(let g=0,p=s.length;g<p;g++){const w=s[g];for(;u<f&&n[u].position.isBefore(w);)u++;if(u<f&&n[u].position.equals(w))a[d++]=n[u];else{let y=t.bracketPairs.matchBracket(w,20),x=Yl._DECORATION_OPTIONS_WITH_OVERVIEW_RULER;!y&&this._matchBrackets==="always"&&(y=t.bracketPairs.findEnclosingBrackets(w,20),x=Yl._DECORATION_OPTIONS_WITHOUT_OVERVIEW_RULER),a[d++]=new UW(w,y,x)}}this._lastBracketsData=a,this._lastVersionId=i}};Yl.ID="editor.contrib.bracketMatchingController",Yl._DECORATION_OPTIONS_WITH_OVERVIEW_RULER=dn.register({description:"bracket-match-overview",stickiness:1,className:"bracket-match",overviewRuler:{color:_s(zW),position:Ha.Center}}),Yl._DECORATION_OPTIONS_WITHOUT_OVERVIEW_RULER=dn.register({description:"bracket-match-no-overview",stickiness:1,className:"bracket-match"});let Cu=Yl;nn(Cu.ID,Cu,1);xe(jW);xe(VW);xe($W);Nr.appendMenuItem(Gt.MenubarGoMenu,{group:"5_infile_nav",command:{id:"editor.action.jumpToBracket",title:C({key:"miGoToBracket",comment:["&& denotes a mnemonic"]},"Go to &&Bracket")},order:2});class qW{constructor(e,t){this._selection=e,this._isMovingLeft=t}getEditOperations(e,t){if(this._selection.startLineNumber!==this._selection.endLineNumber||this._selection.isEmpty())return;const i=this._selection.startLineNumber,n=this._selection.startColumn,s=this._selection.endColumn;if(!(this._isMovingLeft&&n===1)&&!(!this._isMovingLeft&&s===e.getLineMaxColumn(i)))if(this._isMovingLeft){const r=new Z(i,n-1,i,n),a=e.getValueInRange(r);t.addEditOperation(r,null),t.addEditOperation(new Z(i,s,i,s),a)}else{const r=new Z(i,s,i,s+1),a=e.getValueInRange(r);t.addEditOperation(r,null),t.addEditOperation(new Z(i,n,i,n),a)}}computeCursorState(e,t){return this._isMovingLeft?new Fi(this._selection.startLineNumber,this._selection.startColumn-1,this._selection.endLineNumber,this._selection.endColumn-1):new Fi(this._selection.startLineNumber,this._selection.startColumn+1,this._selection.endLineNumber,this._selection.endColumn+1)}}class vM extends lt{constructor(e,t){super(t),this.left=e}run(e,t){if(!t.hasModel())return;const i=[],n=t.getSelections();for(const s of n)i.push(new qW(s,this.left));t.pushUndoStop(),t.executeCommands(this.id,i),t.pushUndoStop()}}class GW extends vM{constructor(){super(!0,{id:"editor.action.moveCarretLeftAction",label:C("caret.moveLeft","Move Selected Text Left"),alias:"Move Selected Text Left",precondition:B.writable})}}class KW extends vM{constructor(){super(!1,{id:"editor.action.moveCarretRightAction",label:C("caret.moveRight","Move Selected Text Right"),alias:"Move Selected Text Right",precondition:B.writable})}}xe(GW);xe(KW);class ZW extends lt{constructor(){super({id:"editor.action.transposeLetters",label:C("transposeLetters.label","Transpose Letters"),alias:"Transpose Letters",precondition:B.writable,kbOpts:{kbExpr:B.textInputFocus,primary:0,mac:{primary:306},weight:100}})}run(e,t){if(!t.hasModel())return;const i=t.getModel(),n=[],s=t.getSelections();for(const r of s){if(!r.isEmpty())continue;const a=r.startLineNumber,d=r.startColumn,u=i.getLineMaxColumn(a);if(a===1&&(d===1||d===2&&u===2))continue;const f=d===u?r.getPosition():ww.rightPosition(i,r.getPosition().lineNumber,r.getPosition().column),g=ww.leftPosition(i,f),p=ww.leftPosition(i,g),w=i.getValueInRange(Z.fromPositions(p,g)),y=i.getValueInRange(Z.fromPositions(g,f)),x=Z.fromPositions(p,f);n.push(new r_(x,y+w))}n.length>0&&(t.pushUndoStop(),t.executeCommands(this.id,n),t.pushUndoStop())}}xe(ZW);const Uy=(function(){if(typeof crypto=="object"&&typeof crypto.randomUUID=="function")return crypto.randomUUID.bind(crypto);let o;typeof crypto=="object"&&typeof crypto.getRandomValues=="function"?o=crypto.getRandomValues.bind(crypto):o=function(i){for(let n=0;n<i.length;n++)i[n]=Math.floor(Math.random()*256);return i};const e=new Uint8Array(16),t=[];for(let i=0;i<256;i++)t.push(i.toString(16).padStart(2,"0"));return function(){o(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let n=0,s="";return s+=t[e[n++]],s+=t[e[n++]],s+=t[e[n++]],s+=t[e[n++]],s+="-",s+=t[e[n++]],s+=t[e[n++]],s+="-",s+=t[e[n++]],s+=t[e[n++]],s+="-",s+=t[e[n++]],s+=t[e[n++]],s+="-",s+=t[e[n++]],s+=t[e[n++]],s+=t[e[n++]],s+=t[e[n++]],s+=t[e[n++]],s+=t[e[n++]],s}})();function H0(o){return{asString:async()=>o,asFile:()=>{},value:typeof o=="string"?o:void 0}}function YW(o,e,t){const i={id:Uy(),name:o,uri:e,data:t};return{asString:async()=>"",asFile:()=>i,value:void 0}}class bM{constructor(){this._entries=new Map}get size(){let e=0;for(const t of this._entries)e++;return e}has(e){return this._entries.has(this.toKey(e))}matches(e){const t=[...this._entries.keys()];return pl.some(this,([i,n])=>n.asFile())&&t.push("files"),wM(bv(e),t)}get(e){var t;return(t=this._entries.get(this.toKey(e)))==null?void 0:t[0]}append(e,t){const i=this._entries.get(e);i?i.push(t):this._entries.set(this.toKey(e),[t])}replace(e,t){this._entries.set(this.toKey(e),[t])}delete(e){this._entries.delete(this.toKey(e))}*[Symbol.iterator](){for(const[e,t]of this._entries)for(const i of t)yield[e,i]}toKey(e){return bv(e)}}function bv(o){return o.toLowerCase()}function yM(o,e){return wM(bv(o),e.map(bv))}function wM(o,e){if(o==="*/*")return e.length>0;if(e.includes(o))return!0;const t=o.match(/^([a-z]+)\/([a-z]+|\*)$/i);if(!t)return!1;const[i,n,s]=t;return s==="*"?e.some(r=>r.startsWith(n+"/")):!1}const qy=Object.freeze({create:o=>HD(o.map(e=>e.toString())).join(`\r
14
- `),split:o=>o.split(`\r
15
- `),parse:o=>qy.split(o).filter(e=>!e.startsWith("#"))}),Ca=class Ca{constructor(e){this.value=e}equals(e){return this.value===e.value}contains(e){return this.equals(e)||this.value===""||e.value.startsWith(this.value+Ca.sep)}intersects(e){return this.contains(e)||e.contains(this)}append(...e){return new Ca((this.value?[this.value,...e]:e).join(Ca.sep))}};Ca.sep=".",Ca.None=new Ca("@@none@@"),Ca.Empty=new Ca("");let $n=Ca;const eI={EDITORS:"CodeEditors",FILES:"CodeFiles"};class XW{}const QW={DragAndDropContribution:"workbench.contributions.dragAndDrop"};da.add(QW.DragAndDropContribution,new XW);const rp=class rp{constructor(){}static getInstance(){return rp.INSTANCE}hasData(e){return e&&e===this.proto}getData(e){if(this.hasData(e))return this.data}};rp.INSTANCE=new rp;let eC=rp;function SM(o){const e=new bM;for(const t of o.items){const i=t.type;if(t.kind==="string"){const n=new Promise(s=>t.getAsString(s));e.append(i,H0(n))}else if(t.kind==="file"){const n=t.getAsFile();n&&e.append(i,JW(n))}}return e}function JW(o){const e=o.path?Pn.parse(o.path):void 0;return YW(o.name,e,async()=>new Uint8Array(await o.arrayBuffer()))}const e4=Object.freeze([eI.EDITORS,eI.FILES,wS.RESOURCES,wS.INTERNAL_URI_LIST]);function CM(o,e=!1){const t=SM(o),i=t.get(wS.INTERNAL_URI_LIST);if(i)t.replace(Ws.uriList,i);else if(e||!t.has(Ws.uriList)){const n=[];for(const s of o.items){const r=s.getAsFile();if(r){const a=r.path;try{a?n.push(Pn.file(a).toString()):n.push(Pn.parse(r.name,!0).toString())}catch{}}}n.length&&t.replace(Ws.uriList,H0(qy.create(n)))}for(const n of e4)t.delete(n);return t}var W0=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},xp=function(o,e){return function(t,i){e(t,i,o)}};class B0{async provideDocumentPasteEdits(e,t,i,n,s){const r=await this.getEdit(i,s);if(r)return{edits:[{insertText:r.insertText,title:r.title,kind:r.kind,handledMimeType:r.handledMimeType,yieldTo:r.yieldTo}],dispose(){}}}async provideDocumentDropEdits(e,t,i,n){const s=await this.getEdit(i,n);if(s)return{edits:[{insertText:s.insertText,title:s.title,kind:s.kind,handledMimeType:s.handledMimeType,yieldTo:s.yieldTo}],dispose(){}}}}const ap=class ap extends B0{constructor(){super(...arguments),this.kind=ap.kind,this.dropMimeTypes=[Ws.text],this.pasteMimeTypes=[Ws.text]}async getEdit(e,t){const i=e.get(Ws.text);if(!i||e.has(Ws.uriList))return;const n=await i.asString();return{handledMimeType:Ws.text,title:C("text.label","Insert Plain Text"),insertText:n,kind:this.kind}}};ap.id="text",ap.kind=new $n("text.plain");let xu=ap;class xM extends B0{constructor(){super(...arguments),this.kind=new $n("uri.absolute"),this.dropMimeTypes=[Ws.uriList],this.pasteMimeTypes=[Ws.uriList]}async getEdit(e,t){const i=await kM(e);if(!i.length||t.isCancellationRequested)return;let n=0;const s=i.map(({uri:a,originalText:d})=>a.scheme===go.file?a.fsPath:(n++,d)).join(" ");let r;return n>0?r=i.length>1?C("defaultDropProvider.uriList.uris","Insert Uris"):C("defaultDropProvider.uriList.uri","Insert Uri"):r=i.length>1?C("defaultDropProvider.uriList.paths","Insert Paths"):C("defaultDropProvider.uriList.path","Insert Path"),{handledMimeType:Ws.uriList,insertText:s,title:r,kind:this.kind}}}let yv=class extends B0{constructor(e){super(),this._workspaceContextService=e,this.kind=new $n("uri.relative"),this.dropMimeTypes=[Ws.uriList],this.pasteMimeTypes=[Ws.uriList]}async getEdit(e,t){const i=await kM(e);if(!i.length||t.isCancellationRequested)return;const n=wl(i.map(({uri:s})=>{const r=this._workspaceContextService.getWorkspaceFolder(s);return r?$A(r.uri,s):void 0}));if(n.length)return{handledMimeType:Ws.uriList,insertText:n.join(" "),title:i.length>1?C("defaultDropProvider.uriList.relativePaths","Insert Relative Paths"):C("defaultDropProvider.uriList.relativePath","Insert Relative Path"),kind:this.kind}}};yv=W0([xp(0,uf)],yv);class t4{constructor(){this.kind=new $n("html"),this.pasteMimeTypes=["text/html"],this._yieldTo=[{mimeType:Ws.text}]}async provideDocumentPasteEdits(e,t,i,n,s){var d;if(n.triggerKind!==SS.PasteAs&&!((d=n.only)!=null&&d.contains(this.kind)))return;const r=i.get("text/html"),a=await(r==null?void 0:r.asString());if(!(!a||s.isCancellationRequested))return{dispose(){},edits:[{insertText:a,yieldTo:this._yieldTo,title:C("pasteHtmlLabel","Insert HTML"),kind:this.kind}]}}}async function kM(o){const e=o.get(Ws.uriList);if(!e)return[];const t=await e.asString(),i=[];for(const n of qy.parse(t))try{i.push({uri:Pn.parse(n),originalText:n})}catch{}return i}let tC=class extends Dt{constructor(e,t){super(),this._register(e.documentDropEditProvider.register("*",new xu)),this._register(e.documentDropEditProvider.register("*",new xM)),this._register(e.documentDropEditProvider.register("*",new yv(t)))}};tC=W0([xp(0,pi),xp(1,uf)],tC);let iC=class extends Dt{constructor(e,t){super(),this._register(e.documentPasteEditProvider.register("*",new xu)),this._register(e.documentPasteEditProvider.register("*",new xM)),this._register(e.documentPasteEditProvider.register("*",new yv(t))),this._register(e.documentPasteEditProvider.register("*",new t4))}};iC=W0([xp(0,pi),xp(1,uf)],iC);const vr=class vr{constructor(){this.value="",this.pos=0}static isDigitCharacter(e){return e>=48&&e<=57}static isVariableCharacter(e){return e===95||e>=97&&e<=122||e>=65&&e<=90}text(e){this.value=e,this.pos=0}tokenText(e){return this.value.substr(e.pos,e.len)}next(){if(this.pos>=this.value.length)return{type:14,pos:this.pos,len:0};const e=this.pos;let t=0,i=this.value.charCodeAt(e),n;if(n=vr._table[i],typeof n=="number")return this.pos+=1,{type:n,pos:e,len:1};if(vr.isDigitCharacter(i)){n=8;do t+=1,i=this.value.charCodeAt(e+t);while(vr.isDigitCharacter(i));return this.pos+=t,{type:n,pos:e,len:t}}if(vr.isVariableCharacter(i)){n=9;do i=this.value.charCodeAt(e+ ++t);while(vr.isVariableCharacter(i)||vr.isDigitCharacter(i));return this.pos+=t,{type:n,pos:e,len:t}}n=10;do t+=1,i=this.value.charCodeAt(e+t);while(!isNaN(i)&&typeof vr._table[i]>"u"&&!vr.isDigitCharacter(i)&&!vr.isVariableCharacter(i));return this.pos+=t,{type:n,pos:e,len:t}}};vr._table={36:0,58:1,44:2,123:3,125:4,92:5,47:6,124:7,43:11,45:12,63:13};let nC=vr;class Zf{constructor(){this._children=[]}appendChild(e){return e instanceof Io&&this._children[this._children.length-1]instanceof Io?this._children[this._children.length-1].value+=e.value:(e.parent=this,this._children.push(e)),this}replace(e,t){const{parent:i}=e,n=i.children.indexOf(e),s=i.children.slice(0);s.splice(n,1,...t),i._children=s,(function r(a,d){for(const u of a)u.parent=d,r(u.children,u)})(t,i)}get children(){return this._children}get rightMostDescendant(){return this._children.length>0?this._children[this._children.length-1].rightMostDescendant:this}get snippet(){let e=this;for(;;){if(!e)return;if(e instanceof I_)return e;e=e.parent}}toString(){return this.children.reduce((e,t)=>e+t.toString(),"")}len(){return 0}}let Io=class LM extends Zf{constructor(e){super(),this.value=e}toString(){return this.value}len(){return this.value.length}clone(){return new LM(this.value)}};class IM extends Zf{}class lr extends IM{static compareByIndex(e,t){return e.index===t.index?0:e.isFinalTabstop?1:t.isFinalTabstop||e.index<t.index?-1:e.index>t.index?1:0}constructor(e){super(),this.index=e}get isFinalTabstop(){return this.index===0}get choice(){return this._children.length===1&&this._children[0]instanceof Yf?this._children[0]:void 0}clone(){const e=new lr(this.index);return this.transform&&(e.transform=this.transform.clone()),e._children=this.children.map(t=>t.clone()),e}}class Yf extends Zf{constructor(){super(...arguments),this.options=[]}appendChild(e){return e instanceof Io&&(e.parent=this,this.options.push(e)),this}toString(){return this.options[0].value}len(){return this.options[0].len()}clone(){const e=new Yf;return this.options.forEach(e.appendChild,e),e}}class z0 extends Zf{constructor(){super(...arguments),this.regexp=new RegExp("")}resolve(e){const t=this;let i=!1,n=e.replace(this.regexp,function(){return i=!0,t._replace(Array.prototype.slice.call(arguments,0,-2))});return!i&&this._children.some(s=>s instanceof Qr&&!!s.elseValue)&&(n=this._replace([])),n}_replace(e){let t="";for(const i of this._children)if(i instanceof Qr){let n=e[i.index]||"";n=i.resolve(n),t+=n}else t+=i.toString();return t}toString(){return""}clone(){const e=new z0;return e.regexp=new RegExp(this.regexp.source,(this.regexp.ignoreCase?"i":"")+(this.regexp.global?"g":"")),e._children=this.children.map(t=>t.clone()),e}}class Qr extends Zf{constructor(e,t,i,n){super(),this.index=e,this.shorthandName=t,this.ifValue=i,this.elseValue=n}resolve(e){return this.shorthandName==="upcase"?e?e.toLocaleUpperCase():"":this.shorthandName==="downcase"?e?e.toLocaleLowerCase():"":this.shorthandName==="capitalize"?e?e[0].toLocaleUpperCase()+e.substr(1):"":this.shorthandName==="pascalcase"?e?this._toPascalCase(e):"":this.shorthandName==="camelcase"?e?this._toCamelCase(e):"":e&&typeof this.ifValue=="string"?this.ifValue:!e&&typeof this.elseValue=="string"?this.elseValue:e||""}_toPascalCase(e){const t=e.match(/[a-z0-9]+/gi);return t?t.map(i=>i.charAt(0).toUpperCase()+i.substr(1)).join(""):e}_toCamelCase(e){const t=e.match(/[a-z0-9]+/gi);return t?t.map((i,n)=>n===0?i.charAt(0).toLowerCase()+i.substr(1):i.charAt(0).toUpperCase()+i.substr(1)).join(""):e}clone(){return new Qr(this.index,this.shorthandName,this.ifValue,this.elseValue)}}class kp extends IM{constructor(e){super(),this.name=e}resolve(e){let t=e.resolve(this);return this.transform&&(t=this.transform.resolve(t||"")),t!==void 0?(this._children=[new Io(t)],!0):!1}clone(){const e=new kp(this.name);return this.transform&&(e.transform=this.transform.clone()),e._children=this.children.map(t=>t.clone()),e}}function tI(o,e){const t=[...o];for(;t.length>0;){const i=t.shift();if(!e(i))break;t.unshift(...i.children)}}class I_ extends Zf{get placeholderInfo(){if(!this._placeholders){const e=[];let t;this.walk(function(i){return i instanceof lr&&(e.push(i),t=!t||t.index<i.index?i:t),!0}),this._placeholders={all:e,last:t}}return this._placeholders}get placeholders(){const{all:e}=this.placeholderInfo;return e}offset(e){let t=0,i=!1;return this.walk(n=>n===e?(i=!0,!1):(t+=n.len(),!0)),i?t:-1}fullLen(e){let t=0;return tI([e],i=>(t+=i.len(),!0)),t}enclosingPlaceholders(e){const t=[];let{parent:i}=e;for(;i;)i instanceof lr&&t.push(i),i=i.parent;return t}resolveVariables(e){return this.walk(t=>(t instanceof kp&&t.resolve(e)&&(this._placeholders=void 0),!0)),this}appendChild(e){return this._placeholders=void 0,super.appendChild(e)}replace(e,t){return this._placeholders=void 0,super.replace(e,t)}clone(){const e=new I_;return this._children=this.children.map(t=>t.clone()),e}walk(e){tI(this.children,e)}}class ku{constructor(){this._scanner=new nC,this._token={type:14,pos:0,len:0}}static escape(e){return e.replace(/\$|}|\\/g,"\\$&")}static guessNeedsClipboard(e){return/\${?CLIPBOARD/.test(e)}parse(e,t,i){const n=new I_;return this.parseFragment(e,n),this.ensureFinalTabstop(n,i??!1,t??!1),n}parseFragment(e,t){const i=t.children.length;for(this._scanner.text(e),this._token=this._scanner.next();this._parse(t););const n=new Map,s=[];t.walk(d=>(d instanceof lr&&(d.isFinalTabstop?n.set(0,void 0):!n.has(d.index)&&d.children.length>0?n.set(d.index,d.children):s.push(d)),!0));const r=(d,u)=>{const f=n.get(d.index);if(!f)return;const g=new lr(d.index);g.transform=d.transform;for(const p of f){const w=p.clone();g.appendChild(w),w instanceof lr&&n.has(w.index)&&!u.has(w.index)&&(u.add(w.index),r(w,u),u.delete(w.index))}t.replace(d,[g])},a=new Set;for(const d of s)r(d,a);return t.children.slice(i)}ensureFinalTabstop(e,t,i){(t||i&&e.placeholders.length>0)&&(e.placeholders.find(s=>s.index===0)||e.appendChild(new lr(0)))}_accept(e,t){if(e===void 0||this._token.type===e){const i=t?this._scanner.tokenText(this._token):!0;return this._token=this._scanner.next(),i}return!1}_backTo(e){return this._scanner.pos=e.pos+e.len,this._token=e,!1}_until(e){const t=this._token;for(;this._token.type!==e;){if(this._token.type===14)return!1;if(this._token.type===5){const n=this._scanner.next();if(n.type!==0&&n.type!==4&&n.type!==5)return!1}this._token=this._scanner.next()}const i=this._scanner.value.substring(t.pos,this._token.pos).replace(/\\(\$|}|\\)/g,"$1");return this._token=this._scanner.next(),i}_parse(e){return this._parseEscaped(e)||this._parseTabstopOrVariableName(e)||this._parseComplexPlaceholder(e)||this._parseComplexVariable(e)||this._parseAnything(e)}_parseEscaped(e){let t;return(t=this._accept(5,!0))?(t=this._accept(0,!0)||this._accept(4,!0)||this._accept(5,!0)||t,e.appendChild(new Io(t)),!0):!1}_parseTabstopOrVariableName(e){let t;const i=this._token;return this._accept(0)&&(t=this._accept(9,!0)||this._accept(8,!0))?(e.appendChild(/^\d+$/.test(t)?new lr(Number(t)):new kp(t)),!0):this._backTo(i)}_parseComplexPlaceholder(e){let t;const i=this._token;if(!(this._accept(0)&&this._accept(3)&&(t=this._accept(8,!0))))return this._backTo(i);const s=new lr(Number(t));if(this._accept(1))for(;;){if(this._accept(4))return e.appendChild(s),!0;if(!this._parse(s))return e.appendChild(new Io("${"+t+":")),s.children.forEach(e.appendChild,e),!0}else if(s.index>0&&this._accept(7)){const r=new Yf;for(;;){if(this._parseChoiceElement(r)){if(this._accept(2))continue;if(this._accept(7)&&(s.appendChild(r),this._accept(4)))return e.appendChild(s),!0}return this._backTo(i),!1}}else return this._accept(6)?this._parseTransform(s)?(e.appendChild(s),!0):(this._backTo(i),!1):this._accept(4)?(e.appendChild(s),!0):this._backTo(i)}_parseChoiceElement(e){const t=this._token,i=[];for(;!(this._token.type===2||this._token.type===7);){let n;if((n=this._accept(5,!0))?n=this._accept(2,!0)||this._accept(7,!0)||this._accept(5,!0)||n:n=this._accept(void 0,!0),!n)return this._backTo(t),!1;i.push(n)}return i.length===0?(this._backTo(t),!1):(e.appendChild(new Io(i.join(""))),!0)}_parseComplexVariable(e){let t;const i=this._token;if(!(this._accept(0)&&this._accept(3)&&(t=this._accept(9,!0))))return this._backTo(i);const s=new kp(t);if(this._accept(1))for(;;){if(this._accept(4))return e.appendChild(s),!0;if(!this._parse(s))return e.appendChild(new Io("${"+t+":")),s.children.forEach(e.appendChild,e),!0}else return this._accept(6)?this._parseTransform(s)?(e.appendChild(s),!0):(this._backTo(i),!1):this._accept(4)?(e.appendChild(s),!0):this._backTo(i)}_parseTransform(e){const t=new z0;let i="",n="";for(;!this._accept(6);){let s;if(s=this._accept(5,!0)){s=this._accept(6,!0)||s,i+=s;continue}if(this._token.type!==14){i+=this._accept(void 0,!0);continue}return!1}for(;!this._accept(6);){let s;if(s=this._accept(5,!0)){s=this._accept(5,!0)||this._accept(6,!0)||s,t.appendChild(new Io(s));continue}if(!(this._parseFormatString(t)||this._parseAnything(t)))return!1}for(;!this._accept(4);){if(this._token.type!==14){n+=this._accept(void 0,!0);continue}return!1}try{t.regexp=new RegExp(i,n)}catch{return!1}return e.transform=t,!0}_parseFormatString(e){const t=this._token;if(!this._accept(0))return!1;let i=!1;this._accept(3)&&(i=!0);const n=this._accept(8,!0);if(n)if(i){if(this._accept(4))return e.appendChild(new Qr(Number(n))),!0;if(!this._accept(1))return this._backTo(t),!1}else return e.appendChild(new Qr(Number(n))),!0;else return this._backTo(t),!1;if(this._accept(6)){const s=this._accept(9,!0);return!s||!this._accept(4)?(this._backTo(t),!1):(e.appendChild(new Qr(Number(n),s)),!0)}else if(this._accept(11)){const s=this._until(4);if(s)return e.appendChild(new Qr(Number(n),void 0,s,void 0)),!0}else if(this._accept(12)){const s=this._until(4);if(s)return e.appendChild(new Qr(Number(n),void 0,void 0,s)),!0}else if(this._accept(13)){const s=this._until(1);if(s){const r=this._until(4);if(r)return e.appendChild(new Qr(Number(n),void 0,s,r)),!0}}else{const s=this._until(4);if(s)return e.appendChild(new Qr(Number(n),void 0,void 0,s)),!0}return this._backTo(t),!1}_parseAnything(e){return this._token.type!==14?(e.appendChild(new Io(this._scanner.tokenText(this._token))),this._accept(void 0),!0):!1}}function EM(o,e,t){var i,n;return(typeof t.insertText=="string"?t.insertText==="":t.insertText.snippet==="")?{edits:((i=t.additionalEdit)==null?void 0:i.edits)??[]}:{edits:[...e.map(s=>new UA(o,{range:s,text:typeof t.insertText=="string"?ku.escape(t.insertText)+"$0":t.insertText.snippet,insertAsSnippet:!0})),...((n=t.additionalEdit)==null?void 0:n.edits)??[]]}}function DM(o){function e(r,a){return"mimeType"in r?r.mimeType===a.handledMimeType:!!a.kind&&r.kind.contains(a.kind)}const t=new Map;for(const r of o)for(const a of r.yieldTo??[])for(const d of o)if(d!==r&&e(a,d)){let u=t.get(r);u||(u=[],t.set(r,u)),u.push(d)}if(!t.size)return Array.from(o);const i=new Set,n=[];function s(r){if(!r.length)return[];const a=r[0];if(n.includes(a))return console.warn("Yield to cycle detected",a),r;if(i.has(a))return s(r.slice(1));let d=[];const u=t.get(a);return u&&(n.push(a),d=s(u),n.pop()),i.add(a),[...d,a,...s(r.slice(1))]}return s(Array.from(o))}var i4=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},n4=function(o,e){return function(t,i){e(t,i,o)}};const s4=dn.register({description:"inline-progress-widget",stickiness:1,showIfCollapsed:!0,after:{content:WD,inlineClassName:"inline-editor-progress-decoration",inlineClassNameAffectsLetterSpacing:!0}}),Pb=class Pb extends Dt{constructor(e,t,i,n,s){super(),this.typeId=e,this.editor=t,this.range=i,this.delegate=s,this.allowEditorOverflow=!1,this.suppressMouseDown=!0,this.create(n),this.editor.addContentWidget(this),this.editor.layoutContentWidget(this)}create(e){this.domNode=si(".inline-progress-widget"),this.domNode.role="button",this.domNode.title=e;const t=si("span.icon");this.domNode.append(t),t.classList.add(...xn.asClassNameArray(ji.loading),"codicon-modifier-spin");const i=()=>{const n=this.editor.getOption(67);this.domNode.style.height=`${n}px`,this.domNode.style.width=`${Math.ceil(.8*n)}px`};i(),this._register(this.editor.onDidChangeConfiguration(n=>{(n.hasChanged(52)||n.hasChanged(67))&&i()})),this._register(wn(this.domNode,Zn.CLICK,n=>{this.delegate.cancel()}))}getId(){return Pb.baseId+"."+this.typeId}getDomNode(){return this.domNode}getPosition(){return{position:{lineNumber:this.range.startLineNumber,column:this.range.startColumn},preference:[0]}}dispose(){super.dispose(),this.editor.removeContentWidget(this)}};Pb.baseId="editor.widget.inlineProgressWidget";let sC=Pb,wv=class extends Dt{constructor(e,t,i){super(),this.id=e,this._editor=t,this._instantiationService=i,this._showDelay=500,this._showPromise=this._register(new Go),this._currentWidget=this._register(new Go),this._operationIdPool=0,this._currentDecorations=t.createDecorationsCollection()}dispose(){super.dispose(),this._currentDecorations.clear()}async showWhile(e,t,i,n,s){const r=this._operationIdPool++;this._currentOperation=r,this.clear(),this._showPromise.value=dp(()=>{const a=Z.fromPositions(e);this._currentDecorations.set([{range:a,options:s4}]).length>0&&(this._currentWidget.value=this._instantiationService.createInstance(sC,this.id,this._editor,a,t,n))},s??this._showDelay);try{return await i}finally{this._currentOperation===r&&(this.clear(),this._currentOperation=void 0)}}clear(){this._showPromise.clear(),this._currentDecorations.clear(),this._currentWidget.clear()}};wv=i4([n4(2,Zi)],wv);var o4=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},iI=function(o,e){return function(t,i){e(t,i,o)}},Bm,pc;let Do=(pc=class{static get(e){return e.getContribution(Bm.ID)}constructor(e,t,i){this._openerService=i,this._messageWidget=new Go,this._messageListeners=new Lt,this._mouseOverMessage=!1,this._editor=e,this._visible=Bm.MESSAGE_VISIBLE.bindTo(t)}dispose(){var e;(e=this._message)==null||e.dispose(),this._messageListeners.dispose(),this._messageWidget.dispose(),this._visible.reset()}showMessage(e,t){Ar(Dm(e)?e.value:e),this._visible.set(!0),this._messageWidget.clear(),this._messageListeners.clear(),this._message=Dm(e)?qA(e,{actionHandler:{callback:n=>{this.closeMessage(),GA(this._openerService,n,Dm(e)?e.isTrusted:void 0)},disposables:this._messageListeners}}):void 0,this._messageWidget.value=new nI(this._editor,t,typeof e=="string"?e:this._message.element),this._messageListeners.add(ws.debounce(this._editor.onDidBlurEditorText,(n,s)=>s,0)(()=>{this._mouseOverMessage||this._messageWidget.value&&KA(FD(),this._messageWidget.value.getDomNode())||this.closeMessage()})),this._messageListeners.add(this._editor.onDidChangeCursorPosition(()=>this.closeMessage())),this._messageListeners.add(this._editor.onDidDispose(()=>this.closeMessage())),this._messageListeners.add(this._editor.onDidChangeModel(()=>this.closeMessage())),this._messageListeners.add(wn(this._messageWidget.value.getDomNode(),Zn.MOUSE_ENTER,()=>this._mouseOverMessage=!0,!0)),this._messageListeners.add(wn(this._messageWidget.value.getDomNode(),Zn.MOUSE_LEAVE,()=>this._mouseOverMessage=!1,!0));let i;this._messageListeners.add(this._editor.onMouseMove(n=>{n.target.position&&(i?i.containsPosition(n.target.position)||this.closeMessage():i=new Z(t.lineNumber-3,1,n.target.position.lineNumber+3,1))}))}closeMessage(){this._visible.reset(),this._messageListeners.clear(),this._messageWidget.value&&this._messageListeners.add(nI.fadeOut(this._messageWidget.value))}},Bm=pc,pc.ID="editor.contrib.messageController",pc.MESSAGE_VISIBLE=new _n("messageVisible",!1,C("messageVisible","Whether the editor is currently showing an inline message")),pc);Do=Bm=o4([iI(1,Sn),iI(2,ua)],Do);const r4=wo.bindToContribution(Do.get);bi(new r4({id:"leaveEditorMessage",precondition:Do.MESSAGE_VISIBLE,handler:o=>o.closeMessage(),kbOpts:{weight:130,primary:9}}));let nI=class{static fadeOut(e){const t=()=>{e.dispose(),clearTimeout(i),e.getDomNode().removeEventListener("animationend",t)},i=setTimeout(t,110);return e.getDomNode().addEventListener("animationend",t),e.getDomNode().classList.add("fadeOut"),{dispose:t}}constructor(e,{lineNumber:t,column:i},n){this.allowEditorOverflow=!0,this.suppressMouseDown=!1,this._editor=e,this._editor.revealLinesInCenterIfOutsideViewport(t,t,0),this._position={lineNumber:t,column:i},this._domNode=document.createElement("div"),this._domNode.classList.add("monaco-editor-overlaymessage"),this._domNode.style.marginLeft="-6px";const s=document.createElement("div");s.classList.add("anchor","top"),this._domNode.appendChild(s);const r=document.createElement("div");typeof n=="string"?(r.classList.add("message"),r.textContent=n):(n.classList.add("message"),r.appendChild(n)),this._domNode.appendChild(r);const a=document.createElement("div");a.classList.add("anchor","below"),this._domNode.appendChild(a),this._editor.addContentWidget(this),this._domNode.classList.add("fadeIn")}dispose(){this._editor.removeContentWidget(this)}getId(){return"messageoverlay"}getDomNode(){return this._domNode}getPosition(){return{position:this._position,preference:[1,2],positionAffinity:1}}afterRender(e){this._domNode.classList.toggle("below",e===2)}};nn(Do.ID,Do,4);function Ow(o,e){return e&&(o.stack||o.stacktrace)?C("stackTrace.format","{0}: {1}",oI(o),sI(o.stack)||sI(o.stacktrace)):oI(o)}function sI(o){return Array.isArray(o)?o.join(`
16
- `):o}function oI(o){return o.code==="ERR_UNC_HOST_NOT_ALLOWED"?`${o.message}. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.`:typeof o.code=="string"&&typeof o.errno=="number"&&typeof o.syscall=="string"?C("nodeExceptionMessage","A system error occurred ({0})",o.message):o.message||C("error.defaultMessage","An unknown error occurred. Please consult the log for more details.")}function Sv(o=null,e=!1){if(!o)return C("error.defaultMessage","An unknown error occurred. Please consult the log for more details.");if(Array.isArray(o)){const t=wl(o),i=Sv(t[0],e);return t.length>1?C("error.moreErrors","{0} ({1} errors in total)",i,t.length):i}if(BD(o))return o;if(o.detail){const t=o.detail;if(t.error)return Ow(t.error,e);if(t.exception)return Ow(t.exception,e)}return o.stack?Ow(o,e):o.message?o.message:C("error.defaultMessage","An unknown error occurred. Please consult the log for more details.")}var TM=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},jh=function(o,e){return function(t,i){e(t,i,o)}},oC,Pd;let rC=(Pd=class extends Dt{constructor(e,t,i,n,s,r,a,d,u,f){super(),this.typeId=e,this.editor=t,this.showCommand=n,this.range=s,this.edits=r,this.onSelectNewEdit=a,this._contextMenuService=d,this._keybindingService=f,this.allowEditorOverflow=!0,this.suppressMouseDown=!0,this.create(),this.visibleContext=i.bindTo(u),this.visibleContext.set(!0),this._register(jn(()=>this.visibleContext.reset())),this.editor.addContentWidget(this),this.editor.layoutContentWidget(this),this._register(jn((()=>this.editor.removeContentWidget(this)))),this._register(this.editor.onDidChangeCursorPosition(g=>{s.containsPosition(g.position)||this.dispose()})),this._register(ws.runAndSubscribe(f.onDidUpdateKeybindings,()=>{this._updateButtonTitle()}))}_updateButtonTitle(){var t;const e=(t=this._keybindingService.lookupKeybinding(this.showCommand.id))==null?void 0:t.getLabel();this.button.element.title=this.showCommand.label+(e?` (${e})`:"")}create(){this.domNode=si(".post-edit-widget"),this.button=this._register(new ZA(this.domNode,{supportIcons:!0})),this.button.label="$(insert)",this._register(wn(this.domNode,Zn.CLICK,()=>this.showSelector()))}getId(){return oC.baseId+"."+this.typeId}getDomNode(){return this.domNode}getPosition(){return{position:this.range.getEndPosition(),preference:[2]}}showSelector(){this._contextMenuService.showContextMenu({getAnchor:()=>{const e=mo(this.button.element);return{x:e.left+e.width,y:e.top+e.height}},getActions:()=>this.edits.allEdits.map((e,t)=>YA({id:"",label:e.title,checked:t===this.edits.activeEditIndex,run:()=>{if(t!==this.edits.activeEditIndex)return this.onSelectNewEdit(t)}}))})}},oC=Pd,Pd.baseId="editor.widget.postEditWidget",Pd);rC=oC=TM([jh(7,zf),jh(8,Sn),jh(9,hs)],rC);let Cv=class extends Dt{constructor(e,t,i,n,s,r,a){super(),this._id=e,this._editor=t,this._visibleContext=i,this._showCommand=n,this._instantiationService=s,this._bulkEditService=r,this._notificationService=a,this._currentWidget=this._register(new Go),this._register(ws.any(t.onDidChangeModel,t.onDidChangeModelContent)(()=>this.clear()))}async applyEditAndShowIfNeeded(e,t,i,n,s){const r=this._editor.getModel();if(!r||!e.length)return;const a=t.allEdits.at(t.activeEditIndex);if(!a)return;const d=async k=>{const D=this._editor.getModel();D&&(await D.undo(),this.applyEditAndShowIfNeeded(e,{activeEditIndex:k,allEdits:t.allEdits},i,n,s))},u=(k,D)=>{Bc(k)||(this._notificationService.error(D),i&&this.show(e[0],t,d))};let f;try{f=await n(a,s)}catch(k){return u(k,C("resolveError",`Error resolving edit '{0}':
17
- {1}`,a.title,Sv(k)))}if(s.isCancellationRequested)return;const g=EM(r.uri,e,f),p=e[0],w=r.deltaDecorations([],[{range:p,options:{description:"paste-line-suffix",stickiness:0}}]);this._editor.focus();let y,x;try{y=await this._bulkEditService.apply(g,{editor:this._editor,token:s}),x=r.getDecorationRange(w[0])}catch(k){return u(k,C("applyError",`Error applying edit '{0}':
18
- {1}`,a.title,Sv(k)))}finally{r.deltaDecorations(w,[])}s.isCancellationRequested||i&&y.isApplied&&t.allEdits.length>1&&this.show(x??p,t,d)}show(e,t,i){this.clear(),this._editor.hasModel()&&(this._currentWidget.value=this._instantiationService.createInstance(rC,this._id,this._editor,this._visibleContext,this._showCommand,e,t,i))}clear(){this._currentWidget.clear()}tryShowSelector(){var e;(e=this._currentWidget.value)==null||e.showSelector()}};Cv=TM([jh(4,Zi),jh(5,my),jh(6,co)],Cv);var a4=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ih=function(o,e){return function(t,i){e(t,i,o)}},id;const PM="editor.changePasteType",V0=new _n("pasteWidgetVisible",!1,C("pasteWidgetVisible","Whether the paste widget is showing")),Fw="application/vnd.code.copyMetadata";var Md;let Il=(Md=class extends Dt{static get(e){return e.getContribution(id.ID)}constructor(e,t,i,n,s,r,a){super(),this._bulkEditService=i,this._clipboardService=n,this._languageFeaturesService=s,this._quickInputService=r,this._progressService=a,this._editor=e;const d=e.getContainerDomNode();this._register(wn(d,"copy",u=>this.handleCopy(u))),this._register(wn(d,"cut",u=>this.handleCopy(u))),this._register(wn(d,"paste",u=>this.handlePaste(u),!0)),this._pasteProgressManager=this._register(new wv("pasteIntoEditor",e,t)),this._postPasteWidgetManager=this._register(t.createInstance(Cv,"pasteIntoEditor",e,V0,{id:PM,label:C("postPasteWidgetTitle","Show paste options...")}))}changePasteType(){this._postPasteWidgetManager.tryShowSelector()}pasteAs(e){this._editor.focus();try{this._pasteAsActionContext={preferred:e},Zx().execCommand("paste")}finally{this._pasteAsActionContext=void 0}}clearWidgets(){this._postPasteWidgetManager.clear()}isPasteAsEnabled(){return this._editor.getOption(85).enabled}async finishedPaste(){await this._currentPasteOperation}handleCopy(e){var x,k,D,M;if(!this._editor.hasTextFocus()||((k=(x=this._clipboardService).clearInternalState)==null||k.call(x),!e.clipboardData||!this.isPasteAsEnabled()))return;const t=this._editor.getModel(),i=this._editor.getSelections();if(!t||!(i!=null&&i.length))return;const n=this._editor.getOption(37);let s=i;const r=i.length===1&&i[0].isEmpty();if(r){if(!n)return;s=[new Z(s[0].startLineNumber,1,s[0].startLineNumber,1+t.getLineLength(s[0].startLineNumber))]}const a=(D=this._editor._getViewModel())==null?void 0:D.getPlainTextToCopy(i,n,vy),u={multicursorText:Array.isArray(a)?a:null,pasteOnNewLine:r,mode:null},f=this._languageFeaturesService.documentPasteEditProvider.ordered(t).filter(F=>!!F.prepareDocumentPaste);if(!f.length){this.setCopyMetadata(e.clipboardData,{defaultPastePayload:u});return}const g=SM(e.clipboardData),p=f.flatMap(F=>F.copyMimeTypes??[]),w=Uy();this.setCopyMetadata(e.clipboardData,{id:w,providerCopyMimeTypes:p,defaultPastePayload:u});const y=Os(async F=>{const K=wl(await Promise.all(f.map(async V=>{try{return await V.prepareDocumentPaste(t,s,g,F)}catch(se){console.error(se);return}})));K.reverse();for(const V of K)for(const[se,te]of V)g.replace(se,te);return g});(M=id._currentCopyOperation)==null||M.dataTransferPromise.cancel(),id._currentCopyOperation={handle:w,dataTransferPromise:y}}async handlePaste(e){var d,u,f;if(!e.clipboardData||!this._editor.hasTextFocus())return;(d=Do.get(this._editor))==null||d.closeMessage(),(u=this._currentPasteOperation)==null||u.cancel(),this._currentPasteOperation=void 0;const t=this._editor.getModel(),i=this._editor.getSelections();if(!(i!=null&&i.length)||!t||this._editor.getOption(92)||!this.isPasteAsEnabled()&&!this._pasteAsActionContext)return;const n=this.fetchCopyMetadata(e),s=CM(e.clipboardData);s.delete(Fw);const r=[...e.clipboardData.types,...(n==null?void 0:n.providerCopyMimeTypes)??[],Ws.uriList],a=this._languageFeaturesService.documentPasteEditProvider.ordered(t).filter(g=>{var w,y;const p=(w=this._pasteAsActionContext)==null?void 0:w.preferred;return p&&g.providedPasteEditKinds&&!this.providerMatchesPreference(g,p)?!1:(y=g.pasteMimeTypes)==null?void 0:y.some(x=>yM(x,r))});if(!a.length){(f=this._pasteAsActionContext)!=null&&f.preferred&&this.showPasteAsNoEditMessage(i,this._pasteAsActionContext.preferred);return}e.preventDefault(),e.stopImmediatePropagation(),this._pasteAsActionContext?this.showPasteAsPick(this._pasteAsActionContext.preferred,a,i,s,n):this.doPasteInline(a,i,s,n,e)}showPasteAsNoEditMessage(e,t){var i;(i=Do.get(this._editor))==null||i.showMessage(C("pasteAsError","No paste edits for '{0}' found",t instanceof $n?t.value:t.providerId),e[0].getStartPosition())}doPasteInline(e,t,i,n,s){const r=this._editor;if(!r.hasModel())return;const a=new hf(r,3,void 0),d=Os(async u=>{const f=this._editor;if(!f.hasModel())return;const g=f.getModel(),p=new Lt,w=p.add(new Fs(u));p.add(a.token.onCancellationRequested(()=>w.cancel()));const y=w.token;try{if(await this.mergeInDataFromCopy(i,n,y),y.isCancellationRequested)return;const x=e.filter(M=>this.isSupportedPasteProvider(M,i));if(!x.length||x.length===1&&x[0]instanceof xu)return this.applyDefaultPasteHandler(i,n,y,s);const k={triggerKind:SS.Automatic},D=await this.getPasteEdits(x,i,g,t,k,y);if(p.add(D),y.isCancellationRequested)return;if(D.edits.length===1&&D.edits[0].provider instanceof xu)return this.applyDefaultPasteHandler(i,n,y,s);if(D.edits.length){const M=f.getOption(85).showPasteSelector==="afterPaste";return this._postPasteWidgetManager.applyEditAndShowIfNeeded(t,{activeEditIndex:0,allEdits:D.edits},M,(F,K)=>new Promise((V,se)=>{(async()=>{var te,pe;try{const je=(pe=(te=F.provider).resolveDocumentPasteEdit)==null?void 0:pe.call(te,F,K),Ke=new by,ue=je&&await this._pasteProgressManager.showWhile(t[0].getEndPosition(),C("resolveProcess","Resolving paste edit. Click to cancel"),Promise.race([Ke.p,je]),{cancel:()=>(Ke.cancel(),se(new yy))},0);return ue&&(F.additionalEdit=ue.additionalEdit),V(F)}catch(je){return se(je)}})()}),y)}await this.applyDefaultPasteHandler(i,n,y,s)}finally{p.dispose(),this._currentPasteOperation===d&&(this._currentPasteOperation=void 0)}});this._pasteProgressManager.showWhile(t[0].getEndPosition(),C("pasteIntoEditorProgress","Running paste handlers. Click to cancel and do basic paste"),d,{cancel:async()=>{try{if(d.cancel(),a.token.isCancellationRequested)return;await this.applyDefaultPasteHandler(i,n,a.token,s)}finally{a.dispose()}}}).then(()=>{a.dispose()}),this._currentPasteOperation=d}showPasteAsPick(e,t,i,n,s){const r=Os(async a=>{const d=this._editor;if(!d.hasModel())return;const u=d.getModel(),f=new Lt,g=f.add(new hf(d,3,void 0,a));try{if(await this.mergeInDataFromCopy(n,s,g.token),g.token.isCancellationRequested)return;let p=t.filter(D=>this.isSupportedPasteProvider(D,n,e));e&&(p=p.filter(D=>this.providerMatchesPreference(D,e)));const w={triggerKind:SS.PasteAs,only:e&&e instanceof $n?e:void 0};let y=f.add(await this.getPasteEdits(p,n,u,i,w,g.token));if(g.token.isCancellationRequested)return;if(e&&(y={edits:y.edits.filter(D=>e instanceof $n?e.contains(D.kind):e.providerId===D.provider.id),dispose:y.dispose}),!y.edits.length){w.only&&this.showPasteAsNoEditMessage(i,w.only);return}let x;if(e)x=y.edits.at(0);else{const D=await this._quickInputService.pick(y.edits.map(M=>{var F;return{label:M.title,description:(F=M.kind)==null?void 0:F.value,edit:M}}),{placeHolder:C("pasteAsPickerPlaceholder","Select Paste Action")});x=D==null?void 0:D.edit}if(!x)return;const k=EM(u.uri,i,x);await this._bulkEditService.apply(k,{editor:this._editor})}finally{f.dispose(),this._currentPasteOperation===r&&(this._currentPasteOperation=void 0)}});this._progressService.withProgress({location:10,title:C("pasteAsProgress","Running paste handlers")},()=>r)}setCopyMetadata(e,t){e.setData(Fw,JSON.stringify(t))}fetchCopyMetadata(e){if(!e.clipboardData)return;const t=e.clipboardData.getData(Fw);if(t)try{return JSON.parse(t)}catch{return}const[i,n]=XA.getTextData(e.clipboardData);if(n)return{defaultPastePayload:{mode:n.mode,multicursorText:n.multicursorText??null,pasteOnNewLine:!!n.isFromEmptySelection}}}async mergeInDataFromCopy(e,t,i){var n;if(t!=null&&t.id&&((n=id._currentCopyOperation)==null?void 0:n.handle)===t.id){const s=await id._currentCopyOperation.dataTransferPromise;if(i.isCancellationRequested)return;for(const[r,a]of s)e.replace(r,a)}if(!e.has(Ws.uriList)){const s=await this._clipboardService.readResources();if(i.isCancellationRequested)return;s.length&&e.append(Ws.uriList,H0(qy.create(s)))}}async getPasteEdits(e,t,i,n,s,r){const a=new Lt,d=await a_(Promise.all(e.map(async f=>{var g,p;try{const w=await((g=f.provideDocumentPasteEdits)==null?void 0:g.call(f,i,n,t,s,r));return w&&a.add(w),(p=w==null?void 0:w.edits)==null?void 0:p.map(y=>({...y,provider:f}))}catch(w){Bc(w)||console.error(w);return}})),r),u=wl(d??[]).flat().filter(f=>!s.only||s.only.contains(f.kind));return{edits:DM(u),dispose:()=>a.dispose()}}async applyDefaultPasteHandler(e,t,i,n){const s=e.get(Ws.text)??e.get("text"),r=await(s==null?void 0:s.asString())??"";if(i.isCancellationRequested)return;const a={clipboardEvent:n,text:r,pasteOnNewLine:(t==null?void 0:t.defaultPastePayload.pasteOnNewLine)??!1,multicursorText:(t==null?void 0:t.defaultPastePayload.multicursorText)??null,mode:null};this._editor.trigger("keyboard","paste",a)}isSupportedPasteProvider(e,t,i){var n;return(n=e.pasteMimeTypes)!=null&&n.some(s=>t.matches(s))?!i||this.providerMatchesPreference(e,i):!1}providerMatchesPreference(e,t){return t instanceof $n?e.providedPasteEditKinds?e.providedPasteEditKinds.some(i=>t.contains(i)):!0:e.id===t.providerId}},id=Md,Md.ID="editor.contrib.copyPasteActionController",Md);Il=id=a4([ih(1,Zi),ih(2,my),ih(3,Vf),ih(4,pi),ih(5,Ml),ih(6,QA)],Il);const Lu="9_cutcopypaste",l4=jf||document.queryCommandSupported("cut"),MM=jf||document.queryCommandSupported("copy"),c4=typeof navigator.clipboard>"u"||JA?document.queryCommandSupported("paste"):!0;function j0(o){return o.register(),o}const d4=l4?j0(new Yx({id:"editor.action.clipboardCutAction",precondition:void 0,kbOpts:jf?{primary:2102,win:{primary:2102,secondary:[1044]},weight:100}:void 0,menuOpts:[{menuId:Gt.MenubarEditMenu,group:"2_ccp",title:C({key:"miCut",comment:["&& denotes a mnemonic"]},"Cu&&t"),order:1},{menuId:Gt.EditorContext,group:Lu,title:C("actions.clipboard.cutLabel","Cut"),when:B.writable,order:1},{menuId:Gt.CommandPalette,group:"",title:C("actions.clipboard.cutLabel","Cut"),order:1},{menuId:Gt.SimpleEditorContext,group:Lu,title:C("actions.clipboard.cutLabel","Cut"),when:B.writable,order:1}]})):void 0,u4=MM?j0(new Yx({id:"editor.action.clipboardCopyAction",precondition:void 0,kbOpts:jf?{primary:2081,win:{primary:2081,secondary:[2067]},weight:100}:void 0,menuOpts:[{menuId:Gt.MenubarEditMenu,group:"2_ccp",title:C({key:"miCopy",comment:["&& denotes a mnemonic"]},"&&Copy"),order:2},{menuId:Gt.EditorContext,group:Lu,title:C("actions.clipboard.copyLabel","Copy"),order:2},{menuId:Gt.CommandPalette,group:"",title:C("actions.clipboard.copyLabel","Copy"),order:1},{menuId:Gt.SimpleEditorContext,group:Lu,title:C("actions.clipboard.copyLabel","Copy"),order:2}]})):void 0;Nr.appendMenuItem(Gt.MenubarEditMenu,{submenu:Gt.MenubarCopy,title:ui("copy as","Copy As"),group:"2_ccp",order:3});Nr.appendMenuItem(Gt.EditorContext,{submenu:Gt.EditorContextCopy,title:ui("copy as","Copy As"),group:Lu,order:3});Nr.appendMenuItem(Gt.EditorContext,{submenu:Gt.EditorContextShare,title:ui("share","Share"),group:"11_share",order:-1,when:Ae.and(Ae.notEquals("resourceScheme","output"),B.editorTextFocus)});Nr.appendMenuItem(Gt.ExplorerContext,{submenu:Gt.ExplorerContextShare,title:ui("share","Share"),group:"11_share",order:-1});const Hw=c4?j0(new Yx({id:"editor.action.clipboardPasteAction",precondition:void 0,kbOpts:jf?{primary:2100,win:{primary:2100,secondary:[1043]},linux:{primary:2100,secondary:[1043]},weight:100}:void 0,menuOpts:[{menuId:Gt.MenubarEditMenu,group:"2_ccp",title:C({key:"miPaste",comment:["&& denotes a mnemonic"]},"&&Paste"),order:4},{menuId:Gt.EditorContext,group:Lu,title:C("actions.clipboard.pasteLabel","Paste"),when:B.writable,order:4},{menuId:Gt.CommandPalette,group:"",title:C("actions.clipboard.pasteLabel","Paste"),order:1},{menuId:Gt.SimpleEditorContext,group:Lu,title:C("actions.clipboard.pasteLabel","Paste"),when:B.writable,order:4}]})):void 0;class h4 extends lt{constructor(){super({id:"editor.action.clipboardCopyWithSyntaxHighlightingAction",label:C("actions.clipboard.copyWithSyntaxHighlightingLabel","Copy With Syntax Highlighting"),alias:"Copy With Syntax Highlighting",precondition:void 0,kbOpts:{kbExpr:B.textInputFocus,primary:0,weight:100}})}run(e,t){!t.hasModel()||!t.getOption(37)&&t.getSelection().isEmpty()||(cL.forceCopyWithSyntaxHighlighting=!0,t.focus(),t.getContainerDomNode().ownerDocument.execCommand("copy"),cL.forceCopyWithSyntaxHighlighting=!1)}}function RM(o,e){o&&(o.addImplementation(1e4,"code-editor",(t,i)=>{const n=t.get(as).getFocusedCodeEditor();if(n&&n.hasTextFocus()){const s=n.getOption(37),r=n.getSelection();return r&&r.isEmpty()&&!s||n.getContainerDomNode().ownerDocument.execCommand(e),!0}return!1}),o.addImplementation(0,"generic-dom",(t,i)=>(Zx().execCommand(e),!0)))}RM(d4,"cut");RM(u4,"copy");Hw&&(Hw.addImplementation(1e4,"code-editor",(o,e)=>{var s;const t=o.get(as),i=o.get(Vf),n=t.getFocusedCodeEditor();return n&&n.hasTextFocus()?n.getContainerDomNode().ownerDocument.execCommand("paste")?((s=Il.get(n))==null?void 0:s.finishedPaste())??Promise.resolve():e2?(async()=>{const a=await i.readText();if(a!==""){const d=t2.INSTANCE.get(a);let u=!1,f=null,g=null;d&&(u=n.getOption(37)&&!!d.isFromEmptySelection,f=typeof d.multicursorText<"u"?d.multicursorText:null,g=d.mode),n.trigger("keyboard","paste",{text:a,pasteOnNewLine:u,multicursorText:f,mode:g})}})():!0:!1}),Hw.addImplementation(0,"generic-dom",(o,e)=>(Zx().execCommand("paste"),!0)));MM&&xe(h4);const Fn=new class{constructor(){this.QuickFix=new $n("quickfix"),this.Refactor=new $n("refactor"),this.RefactorExtract=this.Refactor.append("extract"),this.RefactorInline=this.Refactor.append("inline"),this.RefactorMove=this.Refactor.append("move"),this.RefactorRewrite=this.Refactor.append("rewrite"),this.Notebook=new $n("notebook"),this.Source=new $n("source"),this.SourceOrganizeImports=this.Source.append("organizeImports"),this.SourceFixAll=this.Source.append("fixAll"),this.SurroundWith=this.Refactor.append("surround")}};var Ro;(function(o){o.Refactor="refactor",o.RefactorPreview="refactor preview",o.Lightbulb="lightbulb",o.Default="other (default)",o.SourceAction="source action",o.QuickFix="quick fix action",o.FixAll="fix all",o.OrganizeImports="organize imports",o.AutoFix="auto fix",o.QuickFixHover="quick fix hover window",o.OnSave="save participants",o.ProblemsView="problems view"})(Ro||(Ro={}));function f4(o,e){return!(o.include&&!o.include.intersects(e)||o.excludes&&o.excludes.some(t=>NM(e,t,o.include))||!o.includeSourceActions&&Fn.Source.contains(e))}function g4(o,e){const t=e.kind?new $n(e.kind):void 0;return!(o.include&&(!t||!o.include.contains(t))||o.excludes&&t&&o.excludes.some(i=>NM(t,i,o.include))||!o.includeSourceActions&&t&&Fn.Source.contains(t)||o.onlyIncludePreferredActions&&!e.isPreferred)}function NM(o,e,t){return!(!e.contains(o)||t&&e.contains(t))}class Ma{static fromUser(e,t){return!e||typeof e!="object"?new Ma(t.kind,t.apply,!1):new Ma(Ma.getKindFromUser(e,t.kind),Ma.getApplyFromUser(e,t.apply),Ma.getPreferredUser(e))}static getApplyFromUser(e,t){switch(typeof e.apply=="string"?e.apply.toLowerCase():""){case"first":return"first";case"never":return"never";case"ifsingle":return"ifSingle";default:return t}}static getKindFromUser(e,t){return typeof e.kind=="string"?new $n(e.kind):t}static getPreferredUser(e){return typeof e.preferred=="boolean"?e.preferred:!1}constructor(e,t,i){this.kind=e,this.apply=t,this.preferred=i}}class p4{constructor(e,t,i){this.action=e,this.provider=t,this.highlightRange=i}async resolve(e){var t;if((t=this.provider)!=null&&t.resolveCodeAction&&!this.action.edit){let i;try{i=await this.provider.resolveCodeAction(this.action,e)}catch(n){rs(n)}i&&(this.action.edit=i.edit)}return this}}const AM="editor.action.codeAction",$0="editor.action.quickFix",OM="editor.action.autoFix",FM="editor.action.refactor",HM="editor.action.sourceAction",aC="editor.action.organizeImports",lC="editor.action.fixAll";class Yg extends Dt{static codeActionsPreferredComparator(e,t){return e.isPreferred&&!t.isPreferred?-1:!e.isPreferred&&t.isPreferred?1:0}static codeActionsComparator({action:e},{action:t}){return e.isAI&&!t.isAI?1:!e.isAI&&t.isAI?-1:$o(e.diagnostics)?$o(t.diagnostics)?Yg.codeActionsPreferredComparator(e,t):-1:$o(t.diagnostics)?1:Yg.codeActionsPreferredComparator(e,t)}constructor(e,t,i){super(),this.documentation=t,this._register(i),this.allActions=[...e].sort(Yg.codeActionsComparator),this.validActions=this.allActions.filter(({action:n})=>!n.disabled)}get hasAutoFix(){return this.validActions.some(({action:e})=>!!e.kind&&Fn.QuickFix.contains(new $n(e.kind))&&!!e.isPreferred)}get hasAIFix(){return this.validActions.some(({action:e})=>!!e.isAI)}get allAIFixes(){return this.validActions.every(({action:e})=>!!e.isAI)}}const rI={actions:[],documentation:void 0};async function Eh(o,e,t,i,n,s){var x;const r=i.filter||{},a={...r,excludes:[...r.excludes||[],Fn.Notebook]},d={only:(x=r.include)==null?void 0:x.value,trigger:i.type},u=new i2(e,s),f=i.type===2,g=_4(o,e,f?a:r),p=new Lt,w=g.map(async k=>{try{n.report(k);const D=await k.provideCodeActions(e,t,d,u.token);if(D&&p.add(D),u.token.isCancellationRequested)return rI;const M=((D==null?void 0:D.actions)||[]).filter(K=>K&&g4(r,K)),F=v4(k,M,r.include);return{actions:M.map(K=>new p4(K,k)),documentation:F}}catch(D){if(Bc(D))throw D;return rs(D),rI}}),y=o.onDidChange(()=>{const k=o.all(e);Va(k,g)||u.cancel()});try{const k=await Promise.all(w),D=k.map(F=>F.actions).flat(),M=[...wl(k.map(F=>F.documentation)),...m4(o,e,i,D)];return new Yg(D,M,p)}finally{y.dispose(),u.dispose()}}function _4(o,e,t){return o.all(e).filter(i=>i.providedCodeActionKinds?i.providedCodeActionKinds.some(n=>f4(t,new $n(n))):!0)}function*m4(o,e,t,i){var n,s,r;if(e&&i.length)for(const a of o.all(e))a._getAdditionalMenuItems&&(yield*(r=a._getAdditionalMenuItems)==null?void 0:r.call(a,{trigger:t.type,only:(s=(n=t.filter)==null?void 0:n.include)==null?void 0:s.value},i.map(d=>d.action)))}function v4(o,e,t){if(!o.documentation)return;const i=o.documentation.map(n=>({kind:new $n(n.kind),command:n.command}));if(t){let n;for(const s of i)s.kind.contains(t)&&(n?n.kind.contains(s.kind)&&(n=s):n=s);if(n)return n==null?void 0:n.command}for(const n of e)if(n.kind){for(const s of i)if(s.kind.contains(new $n(n.kind)))return s.command}}var fd;(function(o){o.OnSave="onSave",o.FromProblemsView="fromProblemsView",o.FromCodeActions="fromCodeActions",o.FromAILightbulb="fromAILightbulb"})(fd||(fd={}));async function b4(o,e,t,i,n=Qi.None){var u;const s=o.get(my),r=o.get(Es),a=o.get(ha),d=o.get(co);if(a.publicLog2("codeAction.applyCodeAction",{codeActionTitle:e.action.title,codeActionKind:e.action.kind,codeActionIsPreferred:!!e.action.isPreferred,reason:t}),await e.resolve(n),!n.isCancellationRequested&&!((u=e.action.edit)!=null&&u.edits.length&&!(await s.apply(e.action.edit,{editor:i==null?void 0:i.editor,label:e.action.title,quotableLabel:e.action.title,code:"undoredo.codeAction",respectAutoSaveConfig:t!==fd.OnSave,showPreview:i==null?void 0:i.preview})).isApplied)&&e.action.command)try{await r.executeCommand(e.action.command.id,...e.action.command.arguments||[])}catch(f){const g=y4(f);d.error(typeof g=="string"?g:C("applyCodeActionFailed","An unknown error occurred while applying the code action"))}}function y4(o){return typeof o=="string"?o:o instanceof Error&&typeof o.message=="string"?o.message:void 0}Wn.registerCommand("_executeCodeActionProvider",async function(o,e,t,i,n){if(!(e instanceof Pn))throw _l();const{codeActionProvider:s}=o.get(pi),r=o.get(uo).getModel(e);if(!r)throw _l();const a=Fi.isISelection(t)?Fi.liftSelection(t):Z.isIRange(t)?r.validateRange(t):void 0;if(!a)throw _l();const d=typeof i=="string"?new $n(i):void 0,u=await Eh(s,r,a,{type:1,triggerAction:Ro.Default,filter:{includeSourceActions:!0,include:d}},dl.None,Qi.None),f=[],g=Math.min(u.validActions.length,typeof n=="number"?n:0);for(let p=0;p<g;p++)f.push(u.validActions[p].resolve(Qi.None));try{return await Promise.all(f),u.validActions.map(p=>p.action)}finally{setTimeout(()=>u.dispose(),100)}});var w4=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},S4=function(o,e){return function(t,i){e(t,i,o)}},cC,Rd;let dC=(Rd=class{constructor(e){this.keybindingService=e}getResolver(){const e=new Xx(()=>this.keybindingService.getKeybindings().filter(t=>cC.codeActionCommands.indexOf(t.command)>=0).filter(t=>t.resolvedKeybinding).map(t=>{let i=t.commandArgs;return t.command===aC?i={kind:Fn.SourceOrganizeImports.value}:t.command===lC&&(i={kind:Fn.SourceFixAll.value}),{resolvedKeybinding:t.resolvedKeybinding,...Ma.fromUser(i,{kind:$n.None,apply:"never"})}}));return t=>{if(t.kind){const i=this.bestKeybindingForCodeAction(t,e.value);return i==null?void 0:i.resolvedKeybinding}}}bestKeybindingForCodeAction(e,t){if(!e.kind)return;const i=new $n(e.kind);return t.filter(n=>n.kind.contains(i)).filter(n=>n.preferred?e.isPreferred:!0).reduceRight((n,s)=>n?n.kind.contains(s.kind)?s:n:s,void 0)}},cC=Rd,Rd.codeActionCommands=[FM,AM,HM,aC,lC],Rd);dC=cC=w4([S4(0,hs)],dC);oi("symbolIcon.arrayForeground",Cs,C("symbolIcon.arrayForeground","The foreground color for array symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.booleanForeground",Cs,C("symbolIcon.booleanForeground","The foreground color for boolean symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.classForeground",{dark:"#EE9D28",light:"#D67E00",hcDark:"#EE9D28",hcLight:"#D67E00"},C("symbolIcon.classForeground","The foreground color for class symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.colorForeground",Cs,C("symbolIcon.colorForeground","The foreground color for color symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.constantForeground",Cs,C("symbolIcon.constantForeground","The foreground color for constant symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.constructorForeground",{dark:"#B180D7",light:"#652D90",hcDark:"#B180D7",hcLight:"#652D90"},C("symbolIcon.constructorForeground","The foreground color for constructor symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.enumeratorForeground",{dark:"#EE9D28",light:"#D67E00",hcDark:"#EE9D28",hcLight:"#D67E00"},C("symbolIcon.enumeratorForeground","The foreground color for enumerator symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.enumeratorMemberForeground",{dark:"#75BEFF",light:"#007ACC",hcDark:"#75BEFF",hcLight:"#007ACC"},C("symbolIcon.enumeratorMemberForeground","The foreground color for enumerator member symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.eventForeground",{dark:"#EE9D28",light:"#D67E00",hcDark:"#EE9D28",hcLight:"#D67E00"},C("symbolIcon.eventForeground","The foreground color for event symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.fieldForeground",{dark:"#75BEFF",light:"#007ACC",hcDark:"#75BEFF",hcLight:"#007ACC"},C("symbolIcon.fieldForeground","The foreground color for field symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.fileForeground",Cs,C("symbolIcon.fileForeground","The foreground color for file symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.folderForeground",Cs,C("symbolIcon.folderForeground","The foreground color for folder symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.functionForeground",{dark:"#B180D7",light:"#652D90",hcDark:"#B180D7",hcLight:"#652D90"},C("symbolIcon.functionForeground","The foreground color for function symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.interfaceForeground",{dark:"#75BEFF",light:"#007ACC",hcDark:"#75BEFF",hcLight:"#007ACC"},C("symbolIcon.interfaceForeground","The foreground color for interface symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.keyForeground",Cs,C("symbolIcon.keyForeground","The foreground color for key symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.keywordForeground",Cs,C("symbolIcon.keywordForeground","The foreground color for keyword symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.methodForeground",{dark:"#B180D7",light:"#652D90",hcDark:"#B180D7",hcLight:"#652D90"},C("symbolIcon.methodForeground","The foreground color for method symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.moduleForeground",Cs,C("symbolIcon.moduleForeground","The foreground color for module symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.namespaceForeground",Cs,C("symbolIcon.namespaceForeground","The foreground color for namespace symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.nullForeground",Cs,C("symbolIcon.nullForeground","The foreground color for null symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.numberForeground",Cs,C("symbolIcon.numberForeground","The foreground color for number symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.objectForeground",Cs,C("symbolIcon.objectForeground","The foreground color for object symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.operatorForeground",Cs,C("symbolIcon.operatorForeground","The foreground color for operator symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.packageForeground",Cs,C("symbolIcon.packageForeground","The foreground color for package symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.propertyForeground",Cs,C("symbolIcon.propertyForeground","The foreground color for property symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.referenceForeground",Cs,C("symbolIcon.referenceForeground","The foreground color for reference symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.snippetForeground",Cs,C("symbolIcon.snippetForeground","The foreground color for snippet symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.stringForeground",Cs,C("symbolIcon.stringForeground","The foreground color for string symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.structForeground",Cs,C("symbolIcon.structForeground","The foreground color for struct symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.textForeground",Cs,C("symbolIcon.textForeground","The foreground color for text symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.typeParameterForeground",Cs,C("symbolIcon.typeParameterForeground","The foreground color for type parameter symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.unitForeground",Cs,C("symbolIcon.unitForeground","The foreground color for unit symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));oi("symbolIcon.variableForeground",{dark:"#75BEFF",light:"#007ACC",hcDark:"#75BEFF",hcLight:"#007ACC"},C("symbolIcon.variableForeground","The foreground color for variable symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));const WM=Object.freeze({kind:$n.Empty,title:C("codeAction.widget.id.more","More Actions...")}),C4=Object.freeze([{kind:Fn.QuickFix,title:C("codeAction.widget.id.quickfix","Quick Fix")},{kind:Fn.RefactorExtract,title:C("codeAction.widget.id.extract","Extract"),icon:ji.wrench},{kind:Fn.RefactorInline,title:C("codeAction.widget.id.inline","Inline"),icon:ji.wrench},{kind:Fn.RefactorRewrite,title:C("codeAction.widget.id.convert","Rewrite"),icon:ji.wrench},{kind:Fn.RefactorMove,title:C("codeAction.widget.id.move","Move"),icon:ji.wrench},{kind:Fn.SurroundWith,title:C("codeAction.widget.id.surround","Surround With"),icon:ji.surroundWith},{kind:Fn.Source,title:C("codeAction.widget.id.source","Source Action"),icon:ji.symbolFile},WM]);function x4(o,e,t){if(!e)return o.map(s=>{var r;return{kind:"action",item:s,group:WM,disabled:!!s.action.disabled,label:s.action.disabled||s.action.title,canPreview:!!((r=s.action.edit)!=null&&r.edits.length)}});const i=C4.map(s=>({group:s,actions:[]}));for(const s of o){const r=s.action.kind?new $n(s.action.kind):$n.None;for(const a of i)if(a.group.kind.contains(r)){a.actions.push(s);break}}const n=[];for(const s of i)if(s.actions.length){n.push({kind:"header",group:s.group});for(const r of s.actions){const a=s.group;n.push({kind:"action",item:r,group:r.action.isAI?{title:a.title,kind:a.kind,icon:ji.sparkle}:a,label:r.action.title,disabled:!!r.action.disabled,keybinding:t(r.action)})}}return n}var k4=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},L4=function(o,e){return function(t,i){e(t,i,o)}},vh;const aI=is("gutter-lightbulb",ji.lightBulb,C("gutterLightbulbWidget","Icon which spawns code actions menu from the gutter when there is no space in the editor.")),lI=is("gutter-lightbulb-auto-fix",ji.lightbulbAutofix,C("gutterLightbulbAutoFixWidget","Icon which spawns code actions menu from the gutter when there is no space in the editor and a quick fix is available.")),cI=is("gutter-lightbulb-sparkle",ji.lightbulbSparkle,C("gutterLightbulbAIFixWidget","Icon which spawns code actions menu from the gutter when there is no space in the editor and an AI fix is available.")),dI=is("gutter-lightbulb-aifix-auto-fix",ji.lightbulbSparkleAutofix,C("gutterLightbulbAIFixAutoFixWidget","Icon which spawns code actions menu from the gutter when there is no space in the editor and an AI fix and a quick fix is available.")),uI=is("gutter-lightbulb-sparkle-filled",ji.sparkleFilled,C("gutterLightbulbSparkleFilledWidget","Icon which spawns code actions menu from the gutter when there is no space in the editor and an AI fix and a quick fix is available."));var Kr;(function(o){o.Hidden={type:0};class e{constructor(i,n,s,r){this.actions=i,this.trigger=n,this.editorPosition=s,this.widgetPosition=r,this.type=1}}o.Showing=e})(Kr||(Kr={}));var fl;let Lp=(fl=class extends Dt{constructor(e,t){super(),this._editor=e,this._keybindingService=t,this._onClick=this._register(new Xi),this.onClick=this._onClick.event,this._state=Kr.Hidden,this._gutterState=Kr.Hidden,this._iconClasses=[],this.lightbulbClasses=["codicon-"+aI.id,"codicon-"+dI.id,"codicon-"+lI.id,"codicon-"+cI.id,"codicon-"+uI.id],this.gutterDecoration=vh.GUTTER_DECORATION,this._domNode=si("div.lightBulbWidget"),this._domNode.role="listbox",this._register(zD.ignoreTarget(this._domNode)),this._editor.addContentWidget(this),this._register(this._editor.onDidChangeModelContent(i=>{const n=this._editor.getModel();(this.state.type!==1||!n||this.state.editorPosition.lineNumber>=n.getLineCount())&&this.hide(),(this.gutterState.type!==1||!n||this.gutterState.editorPosition.lineNumber>=n.getLineCount())&&this.gutterHide()})),this._register(n2(this._domNode,i=>{if(this.state.type!==1)return;this._editor.focus(),i.preventDefault();const{top:n,height:s}=mo(this._domNode),r=this._editor.getOption(67);let a=Math.floor(r/3);this.state.widgetPosition.position!==null&&this.state.widgetPosition.position.lineNumber<this.state.editorPosition.lineNumber&&(a+=r),this._onClick.fire({x:i.posx,y:n+s+a,actions:this.state.actions,trigger:this.state.trigger})})),this._register(wn(this._domNode,"mouseenter",i=>{(i.buttons&1)===1&&this.hide()})),this._register(ws.runAndSubscribe(this._keybindingService.onDidUpdateKeybindings,()=>{var i,n;this._preferredKbLabel=((i=this._keybindingService.lookupKeybinding(OM))==null?void 0:i.getLabel())??void 0,this._quickFixKbLabel=((n=this._keybindingService.lookupKeybinding($0))==null?void 0:n.getLabel())??void 0,this._updateLightBulbTitleAndIcon()})),this._register(this._editor.onMouseDown(async i=>{if(!i.target.element||!this.lightbulbClasses.some(d=>i.target.element&&i.target.element.classList.contains(d))||this.gutterState.type!==1)return;this._editor.focus();const{top:n,height:s}=mo(i.target.element),r=this._editor.getOption(67);let a=Math.floor(r/3);this.gutterState.widgetPosition.position!==null&&this.gutterState.widgetPosition.position.lineNumber<this.gutterState.editorPosition.lineNumber&&(a+=r),this._onClick.fire({x:i.event.posx,y:n+s+a,actions:this.gutterState.actions,trigger:this.gutterState.trigger})}))}dispose(){super.dispose(),this._editor.removeContentWidget(this),this._gutterDecorationID&&this._removeGutterDecoration(this._gutterDecorationID)}getId(){return"LightBulbWidget"}getDomNode(){return this._domNode}getPosition(){return this._state.type===1?this._state.widgetPosition:null}update(e,t,i){if(e.validActions.length<=0)return this.gutterHide(),this.hide();if(!this._editor.hasTextFocus())return this.gutterHide(),this.hide();if(!this._editor.getOptions().get(65).enabled)return this.gutterHide(),this.hide();const r=this._editor.getModel();if(!r)return this.gutterHide(),this.hide();const{lineNumber:a,column:d}=r.validatePosition(i),u=r.getOptions().tabSize,f=this._editor.getOptions().get(50),g=r.getLineContent(a),p=Qx(g,u),w=f.spaceWidth*p>22,y=V=>V>2&&this._editor.getTopForLineNumber(V)===this._editor.getTopForLineNumber(V-1),x=this._editor.getLineDecorations(a);let k=!1;if(x)for(const V of x){const se=V.options.glyphMarginClassName;if(se&&!this.lightbulbClasses.some(te=>se.includes(te))){k=!0;break}}let D=a,M=1;if(!w){const V=se=>{const te=r.getLineContent(se);return/^\s*$|^\s+/.test(te)||te.length<=M};if(a>1&&!y(a-1)){const se=r.getLineCount(),te=a===se,pe=a>1&&V(a-1),je=!te&&V(a+1),Ke=V(a),ue=!je&&!pe;if(!je&&!pe&&!k)return this.gutterState=new Kr.Showing(e,t,i,{position:{lineNumber:D,column:M},preference:vh._posPref}),this.renderGutterLightbub(),this.hide();pe||te||pe&&!Ke?D-=1:(je||ue&&Ke)&&(D+=1)}else if(a===1&&(a===r.getLineCount()||!V(a+1)&&!V(a)))if(this.gutterState=new Kr.Showing(e,t,i,{position:{lineNumber:D,column:M},preference:vh._posPref}),k)this.gutterHide();else return this.renderGutterLightbub(),this.hide();else if(a<r.getLineCount()&&!y(a+1))D+=1;else if(d*f.spaceWidth<22)return this.hide();M=/^\S\s*$/.test(r.getLineContent(D))?2:1}this.state=new Kr.Showing(e,t,i,{position:{lineNumber:D,column:M},preference:vh._posPref}),this._gutterDecorationID&&(this._removeGutterDecoration(this._gutterDecorationID),this.gutterHide());const F=e.validActions,K=e.validActions[0].action.kind;if(F.length!==1||!K){this._editor.layoutContentWidget(this);return}this._editor.layoutContentWidget(this)}hide(){this.state!==Kr.Hidden&&(this.state=Kr.Hidden,this._editor.layoutContentWidget(this))}gutterHide(){this.gutterState!==Kr.Hidden&&(this._gutterDecorationID&&this._removeGutterDecoration(this._gutterDecorationID),this.gutterState=Kr.Hidden)}get state(){return this._state}set state(e){this._state=e,this._updateLightBulbTitleAndIcon()}get gutterState(){return this._gutterState}set gutterState(e){this._gutterState=e,this._updateGutterLightBulbTitleAndIcon()}_updateLightBulbTitleAndIcon(){if(this._domNode.classList.remove(...this._iconClasses),this._iconClasses=[],this.state.type!==1)return;let e,t=!1;this.state.actions.allAIFixes?(e=ji.sparkleFilled,this.state.actions.validActions.length===1&&(t=!0)):this.state.actions.hasAutoFix?this.state.actions.hasAIFix?e=ji.lightbulbSparkleAutofix:e=ji.lightbulbAutofix:this.state.actions.hasAIFix?e=ji.lightbulbSparkle:e=ji.lightBulb,this._updateLightbulbTitle(this.state.actions.hasAutoFix,t),this._iconClasses=xn.asClassNameArray(e),this._domNode.classList.add(...this._iconClasses)}_updateGutterLightBulbTitleAndIcon(){if(this.gutterState.type!==1)return;let e,t=!1;this.gutterState.actions.allAIFixes?(e=uI,this.gutterState.actions.validActions.length===1&&(t=!0)):this.gutterState.actions.hasAutoFix?this.gutterState.actions.hasAIFix?e=dI:e=lI:this.gutterState.actions.hasAIFix?e=cI:e=aI,this._updateLightbulbTitle(this.gutterState.actions.hasAutoFix,t);const i=dn.register({description:"codicon-gutter-lightbulb-decoration",glyphMarginClassName:xn.asClassName(e),glyphMargin:{position:tv.Left},stickiness:1});this.gutterDecoration=i}renderGutterLightbub(){const e=this._editor.getSelection();e&&(this._gutterDecorationID===void 0?this._addGutterDecoration(e.startLineNumber):this._updateGutterDecoration(this._gutterDecorationID,e.startLineNumber))}_addGutterDecoration(e){this._editor.changeDecorations(t=>{this._gutterDecorationID=t.addDecoration(new Z(e,0,e,0),this.gutterDecoration)})}_removeGutterDecoration(e){this._editor.changeDecorations(t=>{t.removeDecoration(e),this._gutterDecorationID=void 0})}_updateGutterDecoration(e,t){this._editor.changeDecorations(i=>{i.changeDecoration(e,new Z(t,0,t,0)),i.changeDecorationOptions(e,this.gutterDecoration)})}_updateLightbulbTitle(e,t){this.state.type===1&&(t?this.title=C("codeActionAutoRun","Run: {0}",this.state.actions.validActions[0].action.title):e&&this._preferredKbLabel?this.title=C("preferredcodeActionWithKb","Show Code Actions. Preferred Quick Fix Available ({0})",this._preferredKbLabel):!e&&this._quickFixKbLabel?this.title=C("codeActionWithKb","Show Code Actions ({0})",this._quickFixKbLabel):e||(this.title=C("codeAction","Show Code Actions")))}set title(e){this._domNode.title=e}},vh=fl,fl.GUTTER_DECORATION=dn.register({description:"codicon-gutter-lightbulb-decoration",glyphMarginClassName:xn.asClassName(ji.lightBulb),glyphMargin:{position:tv.Left},stickiness:1}),fl.ID="editor.contrib.lightbulbWidget",fl._posPref=[0],fl);Lp=vh=k4([L4(1,hs)],Lp);var BM=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},uC=function(o,e){return function(t,i){e(t,i,o)}};const zM="acceptSelectedCodeAction",VM="previewSelectedCodeAction";class I4{get templateId(){return"header"}renderTemplate(e){e.classList.add("group-header");const t=document.createElement("span");return e.append(t),{container:e,text:t}}renderElement(e,t,i){var n;i.text.textContent=((n=e.group)==null?void 0:n.title)??""}disposeTemplate(e){}}let hC=class{get templateId(){return"action"}constructor(e,t){this._supportsPreview=e,this._keybindingService=t}renderTemplate(e){e.classList.add(this.templateId);const t=document.createElement("div");t.className="icon",e.append(t);const i=document.createElement("span");i.className="title",e.append(i);const n=new Jx(e,e0);return{container:e,icon:t,text:i,keybinding:n}}renderElement(e,t,i){var r,a,d;if((r=e.group)!=null&&r.icon?(i.icon.className=xn.asClassName(e.group.icon),e.group.icon.color&&(i.icon.style.color=bd(e.group.icon.color.id))):(i.icon.className=xn.asClassName(ji.lightBulb),i.icon.style.color="var(--vscode-editorLightBulb-foreground)"),!e.item||!e.label)return;i.text.textContent=jM(e.label),i.keybinding.set(e.keybinding),s2(!!e.keybinding,i.keybinding.element);const n=(a=this._keybindingService.lookupKeybinding(zM))==null?void 0:a.getLabel(),s=(d=this._keybindingService.lookupKeybinding(VM))==null?void 0:d.getLabel();i.container.classList.toggle("option-disabled",e.disabled),e.disabled?i.container.title=e.label:n&&s?this._supportsPreview&&e.canPreview?i.container.title=C({key:"label-preview",comment:['placeholders are keybindings, e.g "F2 to Apply, Shift+F2 to Preview"']},"{0} to Apply, {1} to Preview",n,s):i.container.title=C({key:"label",comment:['placeholder is a keybinding, e.g "F2 to Apply"']},"{0} to Apply",n):i.container.title=""}disposeTemplate(e){e.keybinding.dispose()}};hC=BM([uC(1,hs)],hC);class E4 extends UIEvent{constructor(){super("acceptSelectedAction")}}class hI extends UIEvent{constructor(){super("previewSelectedAction")}}function D4(o){if(o.kind==="action")return o.label}let fC=class extends Dt{constructor(e,t,i,n,s,r){super(),this._delegate=n,this._contextViewService=s,this._keybindingService=r,this._actionLineHeight=24,this._headerLineHeight=26,this.cts=this._register(new Fs),this.domNode=document.createElement("div"),this.domNode.classList.add("actionList");const a={getHeight:d=>d.kind==="header"?this._headerLineHeight:this._actionLineHeight,getTemplateId:d=>d.kind};this._list=this._register(new t0(e,this.domNode,a,[new hC(t,this._keybindingService),new I4],{keyboardSupport:!1,typeNavigationEnabled:!0,keyboardNavigationLabelProvider:{getKeyboardNavigationLabel:D4},accessibilityProvider:{getAriaLabel:d=>{if(d.kind==="action"){let u=d.label?jM(d==null?void 0:d.label):"";return d.disabled&&(u=C({key:"customQuickFixWidget.labels",comment:["Action widget labels for accessibility."]},"{0}, Disabled Reason: {1}",u,d.disabled)),u}return null},getWidgetAriaLabel:()=>C({key:"customQuickFixWidget",comment:["An action widget option"]},"Action Widget"),getRole:d=>d.kind==="action"?"option":"separator",getWidgetRole:()=>"listbox"}})),this._list.style(o2),this._register(this._list.onMouseClick(d=>this.onListClick(d))),this._register(this._list.onMouseOver(d=>this.onListHover(d))),this._register(this._list.onDidChangeFocus(()=>this.onFocus())),this._register(this._list.onDidChangeSelection(d=>this.onListSelection(d))),this._allMenuItems=i,this._list.splice(0,this._list.length,this._allMenuItems),this._list.length&&this.focusNext()}focusCondition(e){return!e.disabled&&e.kind==="action"}hide(e){this._delegate.onHide(e),this.cts.cancel(),this._contextViewService.hideContextView()}layout(e){const t=this._allMenuItems.filter(d=>d.kind==="header").length,n=this._allMenuItems.length*this._actionLineHeight+t*this._headerLineHeight-t*this._actionLineHeight;this._list.layout(n);let s=e;if(this._allMenuItems.length>=50)s=380;else{const d=this._allMenuItems.map((u,f)=>{const g=this.domNode.ownerDocument.getElementById(this._list.getElementID(f));if(g){g.style.width="auto";const p=g.getBoundingClientRect().width;return g.style.width="",p}return 0});s=Math.max(...d,e)}const a=Math.min(n,this.domNode.ownerDocument.body.clientHeight*.7);return this._list.layout(a,s),this.domNode.style.height=`${a}px`,this._list.domFocus(),s}focusPrevious(){this._list.focusPrevious(1,!0,void 0,this.focusCondition)}focusNext(){this._list.focusNext(1,!0,void 0,this.focusCondition)}acceptSelected(e){const t=this._list.getFocus();if(t.length===0)return;const i=t[0],n=this._list.element(i);if(!this.focusCondition(n))return;const s=e?new hI:new E4;this._list.setSelection([i],s)}onListSelection(e){if(!e.elements.length)return;const t=e.elements[0];t.item&&this.focusCondition(t)?this._delegate.onSelect(t.item,e.browserEvent instanceof hI):this._list.setSelection([])}onFocus(){var n,s;const e=this._list.getFocus();if(e.length===0)return;const t=e[0],i=this._list.element(t);(s=(n=this._delegate).onFocus)==null||s.call(n,i.item)}async onListHover(e){const t=e.element;if(t&&t.item&&this.focusCondition(t)){if(this._delegate.onHover&&!t.disabled&&t.kind==="action"){const i=await this._delegate.onHover(t.item,this.cts.token);t.canPreview=i?i.canPreview:void 0}e.index&&this._list.splice(e.index,1,[t])}this._list.setFocus(typeof e.index=="number"?[e.index]:[])}onListClick(e){e.element&&this.focusCondition(e.element)&&this._list.setFocus([])}};fC=BM([uC(4,wy),uC(5,hs)],fC);function jM(o){return o.replace(/\r\n|\r|\n/g," ")}var T4=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ww=function(o,e){return function(t,i){e(t,i,o)}};oi("actionBar.toggledBackground",i0,C("actionBar.toggledBackground","Background color for toggled action items in action bar."));const Iu={Visible:new _n("codeActionMenuVisible",!1,C("codeActionMenuVisible","Whether the action widget list is visible"))},zu=Rl("actionWidgetService");let Eu=class extends Dt{get isVisible(){return Iu.Visible.getValue(this._contextKeyService)||!1}constructor(e,t,i){super(),this._contextViewService=e,this._contextKeyService=t,this._instantiationService=i,this._list=this._register(new Go)}show(e,t,i,n,s,r,a){const d=Iu.Visible.bindTo(this._contextKeyService),u=this._instantiationService.createInstance(fC,e,t,i,n);this._contextViewService.showContextView({getAnchor:()=>s,render:f=>(d.set(!0),this._renderWidget(f,u,a??[])),onHide:f=>{d.reset(),this._onWidgetClosed(f)}},r,!1)}acceptSelected(e){var t;(t=this._list.value)==null||t.acceptSelected(e)}focusPrevious(){var e,t;(t=(e=this._list)==null?void 0:e.value)==null||t.focusPrevious()}focusNext(){var e,t;(t=(e=this._list)==null?void 0:e.value)==null||t.focusNext()}hide(e){var t;(t=this._list.value)==null||t.hide(e),this._list.clear()}_renderWidget(e,t,i){var w;const n=document.createElement("div");if(n.classList.add("action-widget"),e.appendChild(n),this._list.value=t,this._list.value)n.appendChild(this._list.value.domNode);else throw new Error("List has no value");const s=new Lt,r=document.createElement("div"),a=e.appendChild(r);a.classList.add("context-view-block"),s.add(wn(a,Zn.MOUSE_DOWN,y=>y.stopPropagation()));const d=document.createElement("div"),u=e.appendChild(d);u.classList.add("context-view-pointerBlock"),s.add(wn(u,Zn.POINTER_MOVE,()=>u.remove())),s.add(wn(u,Zn.MOUSE_DOWN,()=>u.remove()));let f=0;if(i.length){const y=this._createActionBar(".action-widget-action-bar",i);y&&(n.appendChild(y.getContainer().parentElement),s.add(y),f=y.getContainer().offsetWidth)}const g=(w=this._list.value)==null?void 0:w.layout(f);n.style.width=`${g}px`;const p=s.add(ff(e));return s.add(p.onDidBlur(()=>this.hide(!0))),s}_createActionBar(e,t){if(!t.length)return;const i=si(e),n=new up(i);return n.push(t,{icon:!1,label:!0}),n}_onWidgetClosed(e){var t;(t=this._list.value)==null||t.hide(e)}};Eu=T4([Ww(0,wy),Ww(1,Sn),Ww(2,Zi)],Eu);Nl(zu,Eu,1);const E_=1100;Tn(class extends yo{constructor(){super({id:"hideCodeActionWidget",title:ui("hideCodeActionWidget.title","Hide action widget"),precondition:Iu.Visible,keybinding:{weight:E_,primary:9,secondary:[1033]}})}run(o){o.get(zu).hide(!0)}});Tn(class extends yo{constructor(){super({id:"selectPrevCodeAction",title:ui("selectPrevCodeAction.title","Select previous action"),precondition:Iu.Visible,keybinding:{weight:E_,primary:16,secondary:[2064],mac:{primary:16,secondary:[2064,302]}}})}run(o){const e=o.get(zu);e instanceof Eu&&e.focusPrevious()}});Tn(class extends yo{constructor(){super({id:"selectNextCodeAction",title:ui("selectNextCodeAction.title","Select next action"),precondition:Iu.Visible,keybinding:{weight:E_,primary:18,secondary:[2066],mac:{primary:18,secondary:[2066,300]}}})}run(o){const e=o.get(zu);e instanceof Eu&&e.focusNext()}});Tn(class extends yo{constructor(){super({id:zM,title:ui("acceptSelected.title","Accept selected action"),precondition:Iu.Visible,keybinding:{weight:E_,primary:3,secondary:[2137]}})}run(o){const e=o.get(zu);e instanceof Eu&&e.acceptSelected()}});Tn(class extends yo{constructor(){super({id:VM,title:ui("previewSelected.title","Preview selected action"),precondition:Iu.Visible,keybinding:{weight:E_,primary:2051}})}run(o){const e=o.get(zu);e instanceof Eu&&e.acceptSelected(!0)}});const $M=new _n("supportedCodeAction",""),fI="_typescript.applyFixAllCodeAction";class P4 extends Dt{constructor(e,t,i,n=250){super(),this._editor=e,this._markerService=t,this._signalChange=i,this._delay=n,this._autoTriggerTimer=this._register(new l_),this._register(this._markerService.onMarkerChanged(s=>this._onMarkerChanges(s))),this._register(this._editor.onDidChangeCursorPosition(()=>this._tryAutoTrigger()))}trigger(e){const t=this._getRangeOfSelectionUnlessWhitespaceEnclosed(e);this._signalChange(t?{trigger:e,selection:t}:void 0)}_onMarkerChanges(e){const t=this._editor.getModel();t&&e.some(i=>iv(i,t.uri))&&this._tryAutoTrigger()}_tryAutoTrigger(){this._autoTriggerTimer.cancelAndSet(()=>{this.trigger({type:2,triggerAction:Ro.Default})},this._delay)}_getRangeOfSelectionUnlessWhitespaceEnclosed(e){if(!this._editor.hasModel())return;const t=this._editor.getSelection();if(e.type===1)return t;const i=this._editor.getOption(65).enabled;if(i!==Sw.Off){{if(i===Sw.On)return t;if(i===Sw.OnCode){if(!t.isEmpty())return t;const s=this._editor.getModel(),{lineNumber:r,column:a}=t.getPosition(),d=s.getLineContent(r);if(d.length===0)return;if(a===1){if(/\s/.test(d[0]))return}else if(a===s.getLineMaxColumn(r)){if(/\s/.test(d[d.length-1]))return}else if(/\s/.test(d[a-2])&&/\s/.test(d[a-1]))return}}return t}}}var rd;(function(o){o.Empty={type:0};class e{constructor(i,n,s){this.trigger=i,this.position=n,this._cancellablePromise=s,this.type=1,this.actions=s.catch(r=>{if(Bc(r))return UM;throw r})}cancel(){this._cancellablePromise.cancel()}}o.Triggered=e})(rd||(rd={}));const UM=Object.freeze({allActions:[],validActions:[],dispose:()=>{},documentation:[],hasAutoFix:!1,hasAIFix:!1,allAIFixes:!1});class M4 extends Dt{constructor(e,t,i,n,s,r,a){super(),this._editor=e,this._registry=t,this._markerService=i,this._progressService=s,this._configurationService=r,this._telemetryService=a,this._codeActionOracle=this._register(new Go),this._state=rd.Empty,this._onDidChangeState=this._register(new Xi),this.onDidChangeState=this._onDidChangeState.event,this._disposed=!1,this._supportedCodeActions=$M.bindTo(n),this._register(this._editor.onDidChangeModel(()=>this._update())),this._register(this._editor.onDidChangeModelLanguage(()=>this._update())),this._register(this._registry.onDidChange(()=>this._update())),this._register(this._editor.onDidChangeConfiguration(d=>{d.hasChanged(65)&&this._update()})),this._update()}dispose(){this._disposed||(this._disposed=!0,super.dispose(),this.setState(rd.Empty,!0))}_settingEnabledNearbyQuickfixes(){var t;const e=(t=this._editor)==null?void 0:t.getModel();return this._configurationService?this._configurationService.getValue("editor.codeActionWidget.includeNearbyQuickFixes",{resource:e==null?void 0:e.uri}):!1}_update(){if(this._disposed)return;this._codeActionOracle.value=void 0,this.setState(rd.Empty);const e=this._editor.getModel();if(e&&this._registry.has(e)&&!this._editor.getOption(92)){const t=this._registry.all(e).flatMap(i=>i.providedCodeActionKinds??[]);this._supportedCodeActions.set(t.join(" ")),this._codeActionOracle.value=new P4(this._editor,this._markerService,i=>{var d;if(!i){this.setState(rd.Empty);return}const n=i.selection.getStartPosition(),s=Os(async u=>{var f,g,p,w,y,x,k,D,M,F;if(this._settingEnabledNearbyQuickfixes()&&i.trigger.type===1&&(i.trigger.triggerAction===Ro.QuickFix||(g=(f=i.trigger.filter)==null?void 0:f.include)!=null&&g.contains(Fn.QuickFix))){const K=await Eh(this._registry,e,i.selection,i.trigger,dl.None,u),V=[...K.allActions];if(u.isCancellationRequested)return UM;const se=(p=K.validActions)==null?void 0:p.some(pe=>pe.action.kind?Fn.QuickFix.contains(new $n(pe.action.kind)):!1),te=this._markerService.read({resource:e.uri});if(se){for(const pe of K.validActions)(y=(w=pe.action.command)==null?void 0:w.arguments)!=null&&y.some(je=>typeof je=="string"&&je.includes(fI))&&(pe.action.diagnostics=[...te.filter(je=>je.relatedInformation)]);return{validActions:K.validActions,allActions:V,documentation:K.documentation,hasAutoFix:K.hasAutoFix,hasAIFix:K.hasAIFix,allAIFixes:K.allAIFixes,dispose:()=>{K.dispose()}}}else if(!se&&te.length>0){const pe=i.selection.getPosition();let je=pe,Ke=Number.MAX_VALUE;const ue=[...K.validActions];for(const dt of te){const we=dt.endColumn,gt=dt.endLineNumber,ot=dt.startLineNumber;if(gt===pe.lineNumber||ot===pe.lineNumber){je=new gi(gt,we);const Pt={type:i.trigger.type,triggerAction:i.trigger.triggerAction,filter:{include:(x=i.trigger.filter)!=null&&x.include?(k=i.trigger.filter)==null?void 0:k.include:Fn.QuickFix},autoApply:i.trigger.autoApply,context:{notAvailableMessage:((D=i.trigger.context)==null?void 0:D.notAvailableMessage)||"",position:je}},Oe=new Fi(je.lineNumber,je.column,je.lineNumber,je.column),Mt=await Eh(this._registry,e,Oe,Pt,dl.None,u);if(Mt.validActions.length!==0){for(const et of Mt.validActions)(F=(M=et.action.command)==null?void 0:M.arguments)!=null&&F.some(ct=>typeof ct=="string"&&ct.includes(fI))&&(et.action.diagnostics=[...te.filter(ct=>ct.relatedInformation)]);K.allActions.length===0&&V.push(...Mt.allActions),Math.abs(pe.column-we)<Ke?ue.unshift(...Mt.validActions):ue.push(...Mt.validActions)}Ke=Math.abs(pe.column-we)}}const He=ue.filter((dt,we,gt)=>gt.findIndex(ot=>ot.action.title===dt.action.title)===we);return He.sort((dt,we)=>dt.action.isPreferred&&!we.action.isPreferred?-1:!dt.action.isPreferred&&we.action.isPreferred||dt.action.isAI&&!we.action.isAI?1:!dt.action.isAI&&we.action.isAI?-1:0),{validActions:He,allActions:V,documentation:K.documentation,hasAutoFix:K.hasAutoFix,hasAIFix:K.hasAIFix,allAIFixes:K.allAIFixes,dispose:()=>{K.dispose()}}}}if(i.trigger.type===1){const K=new Mo,V=await Eh(this._registry,e,i.selection,i.trigger,dl.None,u);return this._telemetryService&&this._telemetryService.publicLog2("codeAction.invokedDurations",{codeActions:V.validActions.length,duration:K.elapsed()}),V}return Eh(this._registry,e,i.selection,i.trigger,dl.None,u)});i.trigger.type===1&&((d=this._progressService)==null||d.showWhile(s,250));const r=new rd.Triggered(i.trigger,n,s);let a=!1;this._state.type===1&&(a=this._state.trigger.type===1&&r.type===1&&r.trigger.type===2&&this._state.position!==r.position),a?setTimeout(()=>{this.setState(r)},500):this.setState(r)},void 0),this._codeActionOracle.value.trigger({type:2,triggerAction:Ro.Default})}else this._supportedCodeActions.reset()}trigger(e){var t;(t=this._codeActionOracle.value)==null||t.trigger(e)}setState(e,t){e!==this._state&&(this._state.type===1&&this._state.cancel(),this._state=e,!t&&!this._disposed&&this._onDidChangeState.fire(e))}}var R4=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ma=function(o,e){return function(t,i){e(t,i,o)}},bh;const N4="quickfix-edit-highlight";var _c;let If=(_c=class extends Dt{static get(e){return e.getContribution(bh.ID)}constructor(e,t,i,n,s,r,a,d,u,f,g){super(),this._commandService=a,this._configurationService=d,this._actionWidgetService=u,this._instantiationService=f,this._telemetryService=g,this._activeCodeActions=this._register(new Go),this._showDisabled=!1,this._disposed=!1,this._editor=e,this._model=this._register(new M4(this._editor,s.codeActionProvider,t,i,r,d,this._telemetryService)),this._register(this._model.onDidChangeState(p=>this.update(p))),this._lightBulbWidget=new Xx(()=>{const p=this._editor.getContribution(Lp.ID);return p&&this._register(p.onClick(w=>this.showCodeActionsFromLightbulb(w.actions,w))),p}),this._resolver=n.createInstance(dC),this._register(this._editor.onDidLayoutChange(()=>this._actionWidgetService.hide()))}dispose(){this._disposed=!0,super.dispose()}async showCodeActionsFromLightbulb(e,t){if(e.allAIFixes&&e.validActions.length===1){const i=e.validActions[0],n=i.action.command;n&&n.id==="inlineChat.start"&&n.arguments&&n.arguments.length>=1&&(n.arguments[0]={...n.arguments[0],autoSend:!1}),await this._applyCodeAction(i,!1,!1,fd.FromAILightbulb);return}await this.showCodeActionList(e,t,{includeDisabledActions:!1,fromLightbulb:!0})}showCodeActions(e,t,i){return this.showCodeActionList(t,i,{includeDisabledActions:!1,fromLightbulb:!1})}manualTriggerAtCurrentPosition(e,t,i,n){var r;if(!this._editor.hasModel())return;(r=Do.get(this._editor))==null||r.closeMessage();const s=this._editor.getPosition();this._trigger({type:1,triggerAction:t,filter:i,autoApply:n,context:{notAvailableMessage:e,position:s}})}_trigger(e){return this._model.trigger(e)}async _applyCodeAction(e,t,i,n){try{await this._instantiationService.invokeFunction(b4,e,n,{preview:i,editor:this._editor})}finally{t&&this._trigger({type:2,triggerAction:Ro.QuickFix,filter:{}})}}hideLightBulbWidget(){var e,t;(e=this._lightBulbWidget.rawValue)==null||e.hide(),(t=this._lightBulbWidget.rawValue)==null||t.gutterHide()}async update(e){var n,s,r,a,d;if(e.type!==1){this.hideLightBulbWidget();return}let t;try{t=await e.actions}catch(u){Nn(u);return}if(this._disposed)return;const i=this._editor.getSelection();if((i==null?void 0:i.startLineNumber)===e.position.lineNumber)if((n=this._lightBulbWidget.value)==null||n.update(t,e.trigger,e.position),e.trigger.type===1){if((s=e.trigger.filter)!=null&&s.include){const f=this.tryGetValidActionToApply(e.trigger,t);if(f){try{this.hideLightBulbWidget(),await this._applyCodeAction(f,!1,!1,fd.FromCodeActions)}finally{t.dispose()}return}if(e.trigger.context){const g=this.getInvalidActionThatWouldHaveBeenApplied(e.trigger,t);if(g&&g.action.disabled){(r=Do.get(this._editor))==null||r.showMessage(g.action.disabled,e.trigger.context.position),t.dispose();return}}}const u=!!((a=e.trigger.filter)!=null&&a.include);if(e.trigger.context&&(!t.allActions.length||!u&&!t.validActions.length)){(d=Do.get(this._editor))==null||d.showMessage(e.trigger.context.notAvailableMessage,e.trigger.context.position),this._activeCodeActions.value=t,t.dispose();return}this._activeCodeActions.value=t,this.showCodeActionList(t,this.toCoords(e.position),{includeDisabledActions:u,fromLightbulb:!1})}else this._actionWidgetService.isVisible?t.dispose():this._activeCodeActions.value=t}getInvalidActionThatWouldHaveBeenApplied(e,t){if(t.allActions.length&&(e.autoApply==="first"&&t.validActions.length===0||e.autoApply==="ifSingle"&&t.allActions.length===1))return t.allActions.find(({action:i})=>i.disabled)}tryGetValidActionToApply(e,t){if(t.validActions.length&&(e.autoApply==="first"&&t.validActions.length>0||e.autoApply==="ifSingle"&&t.validActions.length===1))return t.validActions[0]}async showCodeActionList(e,t,i){const n=this._editor.createDecorationsCollection(),s=this._editor.getDomNode();if(!s)return;const r=i.includeDisabledActions&&(this._showDisabled||e.validActions.length===0)?e.allActions:e.validActions;if(!r.length)return;const a=gi.isIPosition(t)?this.toCoords(t):t,d={onSelect:async(u,f)=>{this._applyCodeAction(u,!0,!!f,i.fromLightbulb?fd.FromAILightbulb:fd.FromCodeActions),this._actionWidgetService.hide(!1),n.clear()},onHide:u=>{var f;(f=this._editor)==null||f.focus(),n.clear()},onHover:async(u,f)=>{var w;if(f.isCancellationRequested)return;let g=!1;const p=u.action.kind;if(p){const y=new $n(p);g=[Fn.RefactorExtract,Fn.RefactorInline,Fn.RefactorRewrite,Fn.RefactorMove,Fn.Source].some(k=>k.contains(y))}return{canPreview:g||!!((w=u.action.edit)!=null&&w.edits.length)}},onFocus:u=>{var f,g;if(u&&u.action){const p=u.action.ranges,w=u.action.diagnostics;if(n.clear(),p&&p.length>0){const y=w&&(w==null?void 0:w.length)>1?w.map(x=>({range:x,options:bh.DECORATION})):p.map(x=>({range:x,options:bh.DECORATION}));n.set(y)}else if(w&&w.length>0){const y=w.map(k=>({range:k,options:bh.DECORATION}));n.set(y);const x=w[0];if(x.startLineNumber&&x.startColumn){const k=(g=(f=this._editor.getModel())==null?void 0:f.getWordAtPosition({lineNumber:x.startLineNumber,column:x.startColumn}))==null?void 0:g.word;gf(C("editingNewSelection","Context: {0} at line {1} and column {2}.",k,x.startLineNumber,x.startColumn))}}}else n.clear()}};this._actionWidgetService.show("codeActionWidget",!0,x4(r,this._shouldShowHeaders(),this._resolver.getResolver()),d,a,s,this._getActionBarActions(e,t,i))}toCoords(e){if(!this._editor.hasModel())return{x:0,y:0};this._editor.revealPosition(e,1),this._editor.render();const t=this._editor.getScrolledVisiblePosition(e),i=mo(this._editor.getDomNode()),n=i.left+t.left,s=i.top+t.top+t.height;return{x:n,y:s}}_shouldShowHeaders(){var t;const e=(t=this._editor)==null?void 0:t.getModel();return this._configurationService.getValue("editor.codeActionWidget.showHeaders",{resource:e==null?void 0:e.uri})}_getActionBarActions(e,t,i){if(i.fromLightbulb)return[];const n=e.documentation.map(s=>({id:s.id,label:s.title,tooltip:s.tooltip??"",class:void 0,enabled:!0,run:()=>this._commandService.executeCommand(s.id,...s.arguments??[])}));return i.includeDisabledActions&&e.validActions.length>0&&e.allActions.length!==e.validActions.length&&n.push(this._showDisabled?{id:"hideMoreActions",label:C("hideMoreActions","Hide Disabled"),enabled:!0,tooltip:"",class:void 0,run:()=>(this._showDisabled=!1,this.showCodeActionList(e,t,i))}:{id:"showMoreActions",label:C("showMoreActions","Show Disabled"),enabled:!0,tooltip:"",class:void 0,run:()=>(this._showDisabled=!0,this.showCodeActionList(e,t,i))}),n}},bh=_c,_c.ID="editor.contrib.codeActionController",_c.DECORATION=dn.register({description:"quickfix-highlight",className:N4}),_c);If=bh=R4([ma(1,n0),ma(2,Sn),ma(3,Zi),ma(4,pi),ma(5,c_),ma(6,Es),ma(7,Un),ma(8,zu),ma(9,Zi),ma(10,ha)],If);Sy((o,e)=>{((n,s)=>{s&&e.addRule(`.monaco-editor ${n} { background-color: ${s}; }`)})(".quickfix-edit-highlight",o.getColor(r2));const i=o.getColor(VD);i&&e.addRule(`.monaco-editor .quickfix-edit-highlight { border: 1px ${hp(o.type)?"dotted":"solid"} ${i}; box-sizing: border-box; }`)});function D_(o){return Ae.regex($M.keys()[0],new RegExp("(\\s|^)"+fp(o.value)+"\\b"))}const U0={type:"object",defaultSnippets:[{body:{kind:""}}],properties:{kind:{type:"string",description:C("args.schema.kind","Kind of the code action to run.")},apply:{type:"string",description:C("args.schema.apply","Controls when the returned actions are applied."),default:"ifSingle",enum:["first","ifSingle","never"],enumDescriptions:[C("args.schema.apply.first","Always apply the first returned code action."),C("args.schema.apply.ifSingle","Apply the first returned code action if it is the only one."),C("args.schema.apply.never","Do not apply the returned code actions.")]},preferred:{type:"boolean",default:!1,description:C("args.schema.preferred","Controls if only preferred code actions should be returned.")}}};function Vu(o,e,t,i,n=Ro.Default){if(o.hasModel()){const s=If.get(o);s==null||s.manualTriggerAtCurrentPosition(e,n,t,i)}}class A4 extends lt{constructor(){super({id:$0,label:C("quickfix.trigger.label","Quick Fix..."),alias:"Quick Fix...",precondition:Ae.and(B.writable,B.hasCodeActionsProvider),kbOpts:{kbExpr:B.textInputFocus,primary:2137,weight:100}})}run(e,t){return Vu(t,C("editor.action.quickFix.noneMessage","No code actions available"),void 0,void 0,Ro.QuickFix)}}class O4 extends wo{constructor(){super({id:AM,precondition:Ae.and(B.writable,B.hasCodeActionsProvider),metadata:{description:"Trigger a code action",args:[{name:"args",schema:U0}]}})}runEditorCommand(e,t,i){const n=Ma.fromUser(i,{kind:$n.Empty,apply:"ifSingle"});return Vu(t,typeof(i==null?void 0:i.kind)=="string"?n.preferred?C("editor.action.codeAction.noneMessage.preferred.kind","No preferred code actions for '{0}' available",i.kind):C("editor.action.codeAction.noneMessage.kind","No code actions for '{0}' available",i.kind):n.preferred?C("editor.action.codeAction.noneMessage.preferred","No preferred code actions available"):C("editor.action.codeAction.noneMessage","No code actions available"),{include:n.kind,includeSourceActions:!0,onlyIncludePreferredActions:n.preferred},n.apply)}}class F4 extends lt{constructor(){super({id:FM,label:C("refactor.label","Refactor..."),alias:"Refactor...",precondition:Ae.and(B.writable,B.hasCodeActionsProvider),kbOpts:{kbExpr:B.textInputFocus,primary:3120,mac:{primary:1328},weight:100},contextMenuOpts:{group:"1_modification",order:2,when:Ae.and(B.writable,D_(Fn.Refactor))},metadata:{description:"Refactor...",args:[{name:"args",schema:U0}]}})}run(e,t,i){const n=Ma.fromUser(i,{kind:Fn.Refactor,apply:"never"});return Vu(t,typeof(i==null?void 0:i.kind)=="string"?n.preferred?C("editor.action.refactor.noneMessage.preferred.kind","No preferred refactorings for '{0}' available",i.kind):C("editor.action.refactor.noneMessage.kind","No refactorings for '{0}' available",i.kind):n.preferred?C("editor.action.refactor.noneMessage.preferred","No preferred refactorings available"):C("editor.action.refactor.noneMessage","No refactorings available"),{include:Fn.Refactor.contains(n.kind)?n.kind:$n.None,onlyIncludePreferredActions:n.preferred},n.apply,Ro.Refactor)}}class H4 extends lt{constructor(){super({id:HM,label:C("source.label","Source Action..."),alias:"Source Action...",precondition:Ae.and(B.writable,B.hasCodeActionsProvider),contextMenuOpts:{group:"1_modification",order:2.1,when:Ae.and(B.writable,D_(Fn.Source))},metadata:{description:"Source Action...",args:[{name:"args",schema:U0}]}})}run(e,t,i){const n=Ma.fromUser(i,{kind:Fn.Source,apply:"never"});return Vu(t,typeof(i==null?void 0:i.kind)=="string"?n.preferred?C("editor.action.source.noneMessage.preferred.kind","No preferred source actions for '{0}' available",i.kind):C("editor.action.source.noneMessage.kind","No source actions for '{0}' available",i.kind):n.preferred?C("editor.action.source.noneMessage.preferred","No preferred source actions available"):C("editor.action.source.noneMessage","No source actions available"),{include:Fn.Source.contains(n.kind)?n.kind:$n.None,includeSourceActions:!0,onlyIncludePreferredActions:n.preferred},n.apply,Ro.SourceAction)}}class W4 extends lt{constructor(){super({id:aC,label:C("organizeImports.label","Organize Imports"),alias:"Organize Imports",precondition:Ae.and(B.writable,D_(Fn.SourceOrganizeImports)),kbOpts:{kbExpr:B.textInputFocus,primary:1581,weight:100}})}run(e,t){return Vu(t,C("editor.action.organize.noneMessage","No organize imports action available"),{include:Fn.SourceOrganizeImports,includeSourceActions:!0},"ifSingle",Ro.OrganizeImports)}}class B4 extends lt{constructor(){super({id:lC,label:C("fixAll.label","Fix All"),alias:"Fix All",precondition:Ae.and(B.writable,D_(Fn.SourceFixAll))})}run(e,t){return Vu(t,C("fixAll.noneMessage","No fix all action available"),{include:Fn.SourceFixAll,includeSourceActions:!0},"ifSingle",Ro.FixAll)}}class z4 extends lt{constructor(){super({id:OM,label:C("autoFix.label","Auto Fix..."),alias:"Auto Fix...",precondition:Ae.and(B.writable,D_(Fn.QuickFix)),kbOpts:{kbExpr:B.textInputFocus,primary:1625,mac:{primary:2649},weight:100}})}run(e,t){return Vu(t,C("editor.action.autoFix.noneMessage","No auto fixes available"),{include:Fn.QuickFix,onlyIncludePreferredActions:!0},"ifSingle",Ro.AutoFix)}}nn(If.ID,If,3);nn(Lp.ID,Lp,4);xe(A4);xe(F4);xe(H4);xe(W4);xe(z4);xe(B4);bi(new O4);da.as(d_.Configuration).registerConfiguration({...Cy,properties:{"editor.codeActionWidget.showHeaders":{type:"boolean",scope:5,description:C("showCodeActionHeaders","Enable/disable showing group headers in the Code Action menu."),default:!0}}});da.as(d_.Configuration).registerConfiguration({...Cy,properties:{"editor.codeActionWidget.includeNearbyQuickFixes":{type:"boolean",scope:5,description:C("includeNearbyQuickFixes","Enable/disable showing nearest Quick Fix within a line when not currently on a diagnostic."),default:!0}}});da.as(d_.Configuration).registerConfiguration({...Cy,properties:{"editor.codeActions.triggerOnFocusChange":{type:"boolean",scope:5,markdownDescription:C("triggerOnFocusChange","Enable triggering {0} when {1} is set to {2}. Code Actions must be set to {3} to be triggered for window and focus changes.","`#editor.codeActionsOnSave#`","`#files.autoSave#`","`afterDelay`","`always`"),default:!1}}});class gC{constructor(){this.lenses=[],this._disposables=new Lt}dispose(){this._disposables.dispose()}get isDisposed(){return this._disposables.isDisposed}add(e,t){this._disposables.add(e);for(const i of e.lenses)this.lenses.push({symbol:i,provider:t})}}async function qM(o,e,t){const i=o.ordered(e),n=new Map,s=new gC,r=i.map(async(a,d)=>{n.set(a,d);try{const u=await Promise.resolve(a.provideCodeLenses(e,t));u&&s.add(u,a)}catch(u){rs(u)}});return await Promise.all(r),s.lenses=s.lenses.sort((a,d)=>a.symbol.range.startLineNumber<d.symbol.range.startLineNumber?-1:a.symbol.range.startLineNumber>d.symbol.range.startLineNumber?1:n.get(a.provider)<n.get(d.provider)?-1:n.get(a.provider)>n.get(d.provider)?1:a.symbol.range.startColumn<d.symbol.range.startColumn?-1:a.symbol.range.startColumn>d.symbol.range.startColumn?1:0),s}Wn.registerCommand("_executeCodeLensProvider",function(o,...e){let[t,i]=e;Cn(Pn.isUri(t)),Cn(typeof i=="number"||!i);const{codeLensProvider:n}=o.get(pi),s=o.get(uo).getModel(t);if(!s)throw _l();const r=[],a=new Lt;return qM(n,s,Qi.None).then(d=>{a.add(d);const u=[];for(const f of d.lenses)i==null||f.symbol.command?r.push(f.symbol):i-- >0&&f.provider.resolveCodeLens&&u.push(Promise.resolve(f.provider.resolveCodeLens(s,f.symbol,Qi.None)).then(g=>r.push(g||f.symbol)));return Promise.all(u)}).then(()=>r).finally(()=>{setTimeout(()=>a.dispose(),100)})});var V4=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},j4=function(o,e){return function(t,i){e(t,i,o)}};const GM=Rl("ICodeLensCache");class gI{constructor(e,t){this.lineCount=e,this.data=t}}let pC=class{constructor(e){this._fakeProvider=new class{provideCodeLenses(){throw new Error("not supported")}},this._cache=new u_(20,.75);const t="codelens/cache";a2(l2,()=>e.remove(t,1));const i="codelens/cache2",n=e.get(i,1,"{}");this._deserialize(n);const s=ws.filter(e.onWillSaveState,r=>r.reason===s0.SHUTDOWN);ws.once(s)(r=>{e.store(i,this._serialize(),1,1)})}put(e,t){const i=t.lenses.map(r=>{var a;return{range:r.symbol.range,command:r.symbol.command&&{id:"",title:(a=r.symbol.command)==null?void 0:a.title}}}),n=new gC;n.add({lenses:i,dispose:()=>{}},this._fakeProvider);const s=new gI(e.getLineCount(),n);this._cache.set(e.uri.toString(),s)}get(e){const t=this._cache.get(e.uri.toString());return t&&t.lineCount===e.getLineCount()?t.data:void 0}delete(e){this._cache.delete(e.uri.toString())}_serialize(){const e=Object.create(null);for(const[t,i]of this._cache){const n=new Set;for(const s of i.data.lenses)n.add(s.symbol.range.startLineNumber);e[t]={lineCount:i.lineCount,lines:[...n.values()]}}return JSON.stringify(e)}_deserialize(e){try{const t=JSON.parse(e);for(const i in t){const n=t[i],s=[];for(const a of n.lines)s.push({range:new Z(a,1,a,11)});const r=new gC;r.add({lenses:s,dispose(){}},this._fakeProvider),this._cache.set(i,new gI(n.lineCount,r))}}catch{}}};pC=V4([j4(0,zc)],pC);Nl(GM,pC,1);class $4{constructor(e,t,i){this.afterColumn=1073741824,this.afterLineNumber=e,this.heightInPx=t,this._onHeight=i,this.suppressMouseDown=!0,this.domNode=document.createElement("div")}onComputedHeight(e){this._lastHeight===void 0?this._lastHeight=e:this._lastHeight!==e&&(this._lastHeight=e,this._onHeight())}isVisible(){return this._lastHeight!==0&&this.domNode.hasAttribute("monaco-visible-view-zone")}}const lp=class lp{constructor(e,t){this.allowEditorOverflow=!1,this.suppressMouseDown=!0,this._commands=new Map,this._isEmpty=!0,this._editor=e,this._id=`codelens.widget-${lp._idPool++}`,this.updatePosition(t),this._domNode=document.createElement("span"),this._domNode.className="codelens-decoration"}withCommands(e,t){this._commands.clear();const i=[];let n=!1;for(let s=0;s<e.length;s++){const r=e[s];if(r&&(n=!0,r.command)){const a=c2(r.command.title.trim());if(r.command.id){const d=`c${lp._idPool++}`;i.push(si("a",{id:d,title:r.command.tooltip,role:"button"},...a)),this._commands.set(d,r.command)}else i.push(si("span",{title:r.command.tooltip},...a));s+1<e.length&&i.push(si("span",void 0," | "))}}n?(nv(this._domNode,...i),this._isEmpty&&t&&this._domNode.classList.add("fadein"),this._isEmpty=!1):nv(this._domNode,si("span",void 0,"no commands"))}getCommand(e){return e.parentElement===this._domNode?this._commands.get(e.id):void 0}getId(){return this._id}getDomNode(){return this._domNode}updatePosition(e){const t=this._editor.getModel().getLineFirstNonWhitespaceColumn(e);this._widgetPosition={position:{lineNumber:e,column:t},preference:[1]}}getPosition(){return this._widgetPosition||null}};lp._idPool=0;let _C=lp;class Bw{constructor(){this._removeDecorations=[],this._addDecorations=[],this._addDecorationsCallbacks=[]}addDecoration(e,t){this._addDecorations.push(e),this._addDecorationsCallbacks.push(t)}removeDecoration(e){this._removeDecorations.push(e)}commit(e){const t=e.deltaDecorations(this._removeDecorations,this._addDecorations);for(let i=0,n=t.length;i<n;i++)this._addDecorationsCallbacks[i](t[i])}}const pI=dn.register({collapseOnReplaceEdit:!0,description:"codelens"});class _I{constructor(e,t,i,n,s,r){this._isDisposed=!1,this._editor=t,this._data=e,this._decorationIds=[];let a;const d=[];this._data.forEach((u,f)=>{u.symbol.command&&d.push(u.symbol),i.addDecoration({range:u.symbol.range,options:pI},g=>this._decorationIds[f]=g),a?a=Z.plusRange(a,u.symbol.range):a=Z.lift(u.symbol.range)}),this._viewZone=new $4(a.startLineNumber-1,s,r),this._viewZoneId=n.addZone(this._viewZone),d.length>0&&(this._createContentWidgetIfNecessary(),this._contentWidget.withCommands(d,!1))}_createContentWidgetIfNecessary(){this._contentWidget?this._editor.layoutContentWidget(this._contentWidget):(this._contentWidget=new _C(this._editor,this._viewZone.afterLineNumber+1),this._editor.addContentWidget(this._contentWidget))}dispose(e,t){this._decorationIds.forEach(e.removeDecoration,e),this._decorationIds=[],t==null||t.removeZone(this._viewZoneId),this._contentWidget&&(this._editor.removeContentWidget(this._contentWidget),this._contentWidget=void 0),this._isDisposed=!0}isDisposed(){return this._isDisposed}isValid(){return this._decorationIds.some((e,t)=>{const i=this._editor.getModel().getDecorationRange(e),n=this._data[t].symbol;return!!(i&&Z.isEmpty(n.range)===i.isEmpty())})}updateCodeLensSymbols(e,t){this._decorationIds.forEach(t.removeDecoration,t),this._decorationIds=[],this._data=e,this._data.forEach((i,n)=>{t.addDecoration({range:i.symbol.range,options:pI},s=>this._decorationIds[n]=s)})}updateHeight(e,t){this._viewZone.heightInPx=e,t.layoutZone(this._viewZoneId),this._contentWidget&&this._editor.layoutContentWidget(this._contentWidget)}computeIfNecessary(e){if(!this._viewZone.isVisible())return null;for(let t=0;t<this._decorationIds.length;t++){const i=e.getDecorationRange(this._decorationIds[t]);i&&(this._data[t].symbol.range=i)}return this._data}updateCommands(e){this._createContentWidgetIfNecessary(),this._contentWidget.withCommands(e,!0);for(let t=0;t<this._data.length;t++){const i=e[t];if(i){const{symbol:n}=this._data[t];n.command=i.command||n.command}}}getCommand(e){var t;return(t=this._contentWidget)==null?void 0:t.getCommand(e)}getLineNumber(){const e=this._editor.getModel().getDecorationRange(this._decorationIds[0]);return e?e.startLineNumber:-1}update(e){if(this.isValid()){const t=this._editor.getModel().getDecorationRange(this._decorationIds[0]);t&&(this._viewZone.afterLineNumber=t.startLineNumber-1,e.layoutZone(this._viewZoneId),this._contentWidget&&(this._contentWidget.updatePosition(t.startLineNumber),this._editor.layoutContentWidget(this._contentWidget)))}}}var U4=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},_g=function(o,e){return function(t,i){e(t,i,o)}},ef;let Ip=(ef=class{constructor(e,t,i,n,s,r){this._editor=e,this._languageFeaturesService=t,this._commandService=n,this._notificationService=s,this._codeLensCache=r,this._disposables=new Lt,this._localToDispose=new Lt,this._lenses=[],this._oldCodeLensModels=new Lt,this._provideCodeLensDebounce=i.for(t.codeLensProvider,"CodeLensProvide",{min:250}),this._resolveCodeLensesDebounce=i.for(t.codeLensProvider,"CodeLensResolve",{min:250,salt:"resolve"}),this._resolveCodeLensesScheduler=new Ss(()=>this._resolveCodeLensesInViewport(),this._resolveCodeLensesDebounce.default()),this._disposables.add(this._editor.onDidChangeModel(()=>this._onModelChange())),this._disposables.add(this._editor.onDidChangeModelLanguage(()=>this._onModelChange())),this._disposables.add(this._editor.onDidChangeConfiguration(a=>{(a.hasChanged(50)||a.hasChanged(19)||a.hasChanged(18))&&this._updateLensStyle(),a.hasChanged(17)&&this._onModelChange()})),this._disposables.add(t.codeLensProvider.onDidChange(this._onModelChange,this)),this._onModelChange(),this._updateLensStyle()}dispose(){var e;this._localDispose(),this._disposables.dispose(),this._oldCodeLensModels.dispose(),(e=this._currentCodeLensModel)==null||e.dispose()}_getLayoutInfo(){const e=Math.max(1.3,this._editor.getOption(67)/this._editor.getOption(52));let t=this._editor.getOption(19);return(!t||t<5)&&(t=this._editor.getOption(52)*.9|0),{fontSize:t,codeLensHeight:t*e|0}}_updateLensStyle(){const{codeLensHeight:e,fontSize:t}=this._getLayoutInfo(),i=this._editor.getOption(18),n=this._editor.getOption(50),{style:s}=this._editor.getContainerDomNode();s.setProperty("--vscode-editorCodeLens-lineHeight",`${e}px`),s.setProperty("--vscode-editorCodeLens-fontSize",`${t}px`),s.setProperty("--vscode-editorCodeLens-fontFeatureSettings",n.fontFeatureSettings),i&&(s.setProperty("--vscode-editorCodeLens-fontFamily",i),s.setProperty("--vscode-editorCodeLens-fontFamilyDefault",o0.fontFamily)),this._editor.changeViewZones(r=>{for(const a of this._lenses)a.updateHeight(e,r)})}_localDispose(){var e,t,i;(e=this._getCodeLensModelPromise)==null||e.cancel(),this._getCodeLensModelPromise=void 0,(t=this._resolveCodeLensesPromise)==null||t.cancel(),this._resolveCodeLensesPromise=void 0,this._localToDispose.clear(),this._oldCodeLensModels.clear(),(i=this._currentCodeLensModel)==null||i.dispose()}_onModelChange(){this._localDispose();const e=this._editor.getModel();if(!e||!this._editor.getOption(17)||e.isTooLargeForTokenization())return;const t=this._codeLensCache.get(e);if(t&&this._renderCodeLensSymbols(t),!this._languageFeaturesService.codeLensProvider.has(e)){t&&dp(()=>{const n=this._codeLensCache.get(e);t===n&&(this._codeLensCache.delete(e),this._onModelChange())},30*1e3,this._localToDispose);return}for(const n of this._languageFeaturesService.codeLensProvider.all(e))if(typeof n.onDidChange=="function"){const s=n.onDidChange(()=>i.schedule());this._localToDispose.add(s)}const i=new Ss(()=>{var s;const n=Date.now();(s=this._getCodeLensModelPromise)==null||s.cancel(),this._getCodeLensModelPromise=Os(r=>qM(this._languageFeaturesService.codeLensProvider,e,r)),this._getCodeLensModelPromise.then(r=>{this._currentCodeLensModel&&this._oldCodeLensModels.add(this._currentCodeLensModel),this._currentCodeLensModel=r,this._codeLensCache.put(e,r);const a=this._provideCodeLensDebounce.update(e,Date.now()-n);i.delay=a,this._renderCodeLensSymbols(r),this._resolveCodeLensesInViewportSoon()},Nn)},this._provideCodeLensDebounce.get(e));this._localToDispose.add(i),this._localToDispose.add(jn(()=>this._resolveCodeLensesScheduler.cancel())),this._localToDispose.add(this._editor.onDidChangeModelContent(()=>{var n;this._editor.changeDecorations(s=>{this._editor.changeViewZones(r=>{const a=[];let d=-1;this._lenses.forEach(f=>{!f.isValid()||d===f.getLineNumber()?a.push(f):(f.update(r),d=f.getLineNumber())});const u=new Bw;a.forEach(f=>{f.dispose(u,r),this._lenses.splice(this._lenses.indexOf(f),1)}),u.commit(s)})}),i.schedule(),this._resolveCodeLensesScheduler.cancel(),(n=this._resolveCodeLensesPromise)==null||n.cancel(),this._resolveCodeLensesPromise=void 0})),this._localToDispose.add(this._editor.onDidFocusEditorText(()=>{i.schedule()})),this._localToDispose.add(this._editor.onDidBlurEditorText(()=>{i.cancel()})),this._localToDispose.add(this._editor.onDidScrollChange(n=>{n.scrollTopChanged&&this._lenses.length>0&&this._resolveCodeLensesInViewportSoon()})),this._localToDispose.add(this._editor.onDidLayoutChange(()=>{this._resolveCodeLensesInViewportSoon()})),this._localToDispose.add(jn(()=>{if(this._editor.getModel()){const n=pf.capture(this._editor);this._editor.changeDecorations(s=>{this._editor.changeViewZones(r=>{this._disposeAllLenses(s,r)})}),n.restore(this._editor)}else this._disposeAllLenses(void 0,void 0)})),this._localToDispose.add(this._editor.onMouseDown(n=>{if(n.target.type!==9)return;let s=n.target.element;if((s==null?void 0:s.tagName)==="SPAN"&&(s=s.parentElement),(s==null?void 0:s.tagName)==="A")for(const r of this._lenses){const a=r.getCommand(s);if(a){this._commandService.executeCommand(a.id,...a.arguments||[]).catch(d=>this._notificationService.error(d));break}}})),i.schedule()}_disposeAllLenses(e,t){const i=new Bw;for(const n of this._lenses)n.dispose(i,t);e&&i.commit(e),this._lenses.length=0}_renderCodeLensSymbols(e){if(!this._editor.hasModel())return;const t=this._editor.getModel().getLineCount(),i=[];let n;for(const a of e.lenses){const d=a.symbol.range.startLineNumber;d<1||d>t||(n&&n[n.length-1].symbol.range.startLineNumber===d?n.push(a):(n=[a],i.push(n)))}if(!i.length&&!this._lenses.length)return;const s=pf.capture(this._editor),r=this._getLayoutInfo();this._editor.changeDecorations(a=>{this._editor.changeViewZones(d=>{const u=new Bw;let f=0,g=0;for(;g<i.length&&f<this._lenses.length;){const p=i[g][0].symbol.range.startLineNumber,w=this._lenses[f].getLineNumber();w<p?(this._lenses[f].dispose(u,d),this._lenses.splice(f,1)):w===p?(this._lenses[f].updateCodeLensSymbols(i[g],u),g++,f++):(this._lenses.splice(f,0,new _I(i[g],this._editor,u,d,r.codeLensHeight,()=>this._resolveCodeLensesInViewportSoon())),f++,g++)}for(;f<this._lenses.length;)this._lenses[f].dispose(u,d),this._lenses.splice(f,1);for(;g<i.length;)this._lenses.push(new _I(i[g],this._editor,u,d,r.codeLensHeight,()=>this._resolveCodeLensesInViewportSoon())),g++;u.commit(a)})}),s.restore(this._editor)}_resolveCodeLensesInViewportSoon(){this._editor.getModel()&&this._resolveCodeLensesScheduler.schedule()}_resolveCodeLensesInViewport(){var r;(r=this._resolveCodeLensesPromise)==null||r.cancel(),this._resolveCodeLensesPromise=void 0;const e=this._editor.getModel();if(!e)return;const t=[],i=[];if(this._lenses.forEach(a=>{const d=a.computeIfNecessary(e);d&&(t.push(d),i.push(a))}),t.length===0)return;const n=Date.now(),s=Os(a=>{const d=t.map((u,f)=>{const g=new Array(u.length),p=u.map((w,y)=>!w.symbol.command&&typeof w.provider.resolveCodeLens=="function"?Promise.resolve(w.provider.resolveCodeLens(e,w.symbol,a)).then(x=>{g[y]=x},rs):(g[y]=w.symbol,Promise.resolve(void 0)));return Promise.all(p).then(()=>{!a.isCancellationRequested&&!i[f].isDisposed()&&i[f].updateCommands(g)})});return Promise.all(d)});this._resolveCodeLensesPromise=s,this._resolveCodeLensesPromise.then(()=>{const a=this._resolveCodeLensesDebounce.update(e,Date.now()-n);this._resolveCodeLensesScheduler.delay=a,this._currentCodeLensModel&&this._codeLensCache.put(e,this._currentCodeLensModel),this._oldCodeLensModels.clear(),s===this._resolveCodeLensesPromise&&(this._resolveCodeLensesPromise=void 0)},a=>{Nn(a),s===this._resolveCodeLensesPromise&&(this._resolveCodeLensesPromise=void 0)})}async getModel(){var e;return await this._getCodeLensModelPromise,await this._resolveCodeLensesPromise,(e=this._currentCodeLensModel)!=null&&e.isDisposed?void 0:this._currentCodeLensModel}},ef.ID="css.editor.codeLens",ef);Ip=U4([_g(1,pi),_g(2,ur),_g(3,Es),_g(4,co),_g(5,GM)],Ip);nn(Ip.ID,Ip,1);xe(class extends lt{constructor(){super({id:"codelens.showLensesInCurrentLine",precondition:B.hasCodeLensProvider,label:C("showLensOnLine","Show CodeLens Commands For Current Line"),alias:"Show CodeLens Commands For Current Line"})}async run(e,t){if(!t.hasModel())return;const i=e.get(Ml),n=e.get(Es),s=e.get(co),r=t.getSelection().positionLineNumber,a=t.getContribution(Ip.ID);if(!a)return;const d=await a.getModel();if(!d)return;const u=[];for(const p of d.lenses)p.symbol.command&&p.symbol.range.startLineNumber===r&&u.push({label:p.symbol.command.title,command:p.symbol.command});if(u.length===0)return;const f=await i.pick(u,{canPickMany:!1,placeHolder:C("placeHolder","Select a command")});if(!f)return;let g=f.command;if(d.isDisposed){const p=await a.getModel(),w=p==null?void 0:p.lenses.find(y=>{var x;return y.symbol.range.startLineNumber===r&&((x=y.symbol.command)==null?void 0:x.title)===g.title});if(!w||!w.symbol.command)return;g=w.symbol.command}try{await n.executeCommand(g.id,...g.arguments||[])}catch(p){s.error(p)}}});var KM=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},mC=function(o,e){return function(t,i){e(t,i,o)}};let Ep=class{constructor(e){this._editorWorkerService=e}async provideDocumentColors(e,t){return this._editorWorkerService.computeDefaultDocumentColors(e.uri)}provideColorPresentations(e,t,i){const n=t.range,s=t.color,r=s.alpha,a=new cn(new _f(Math.round(255*s.red),Math.round(255*s.green),Math.round(255*s.blue),r)),d=r?cn.Format.CSS.formatRGB(a):cn.Format.CSS.formatRGBA(a),u=r?cn.Format.CSS.formatHSL(a):cn.Format.CSS.formatHSLA(a),f=r?cn.Format.CSS.formatHex(a):cn.Format.CSS.formatHexA(a),g=[];return g.push({label:d,textEdit:{range:n,text:d}}),g.push({label:u,textEdit:{range:n,text:u}}),g.push({label:f,textEdit:{range:n,text:f}}),g}};Ep=KM([mC(0,Al)],Ep);let vC=class extends Dt{constructor(e,t){super(),this._register(e.colorProvider.register("*",new Ep(t)))}};vC=KM([mC(0,pi),mC(1,Al)],vC);$f(vC);async function ZM(o,e,t,i=!0){return q0(new q4,o,e,t,i)}function YM(o,e,t,i){return Promise.resolve(t.provideColorPresentations(o,e,i))}class q4{constructor(){}async compute(e,t,i,n){const s=await e.provideDocumentColors(t,i);if(Array.isArray(s))for(const r of s)n.push({colorInfo:r,provider:e});return Array.isArray(s)}}class G4{constructor(){}async compute(e,t,i,n){const s=await e.provideDocumentColors(t,i);if(Array.isArray(s))for(const r of s)n.push({range:r.range,color:[r.color.red,r.color.green,r.color.blue,r.color.alpha]});return Array.isArray(s)}}class K4{constructor(e){this.colorInfo=e}async compute(e,t,i,n){const s=await e.provideColorPresentations(t,this.colorInfo,Qi.None);return Array.isArray(s)&&n.push(...s),Array.isArray(s)}}async function q0(o,e,t,i,n){let s=!1,r;const a=[],d=e.ordered(t);for(let u=d.length-1;u>=0;u--){const f=d[u];if(f instanceof Ep)r=f;else try{await o.compute(f,t,i,a)&&(s=!0)}catch(g){rs(g)}}return s?a:r&&n?(await o.compute(r,t,i,a),a):[]}function XM(o,e){const{colorProvider:t}=o.get(pi),i=o.get(uo).getModel(e);if(!i)throw _l();const n=o.get(Un).getValue("editor.defaultColorDecorators",{resource:e});return{model:i,colorProviderRegistry:t,isDefaultColorDecoratorsEnabled:n}}Wn.registerCommand("_executeDocumentColorProvider",function(o,...e){const[t]=e;if(!(t instanceof Pn))throw _l();const{model:i,colorProviderRegistry:n,isDefaultColorDecoratorsEnabled:s}=XM(o,t);return q0(new G4,n,i,Qi.None,s)});Wn.registerCommand("_executeColorPresentationProvider",function(o,...e){const[t,i]=e,{uri:n,range:s}=i;if(!(n instanceof Pn)||!Array.isArray(t)||t.length!==4||!Z.isIRange(s))throw _l();const{model:r,colorProviderRegistry:a,isDefaultColorDecoratorsEnabled:d}=XM(o,n),[u,f,g,p]=t;return q0(new K4({range:s,color:{red:u,green:f,blue:g,alpha:p}}),a,r,Qi.None,d)});var Z4=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},zw=function(o,e){return function(t,i){e(t,i,o)}},bC;const QM=Object.create({});var mc;let Ef=(mc=class extends Dt{constructor(e,t,i,n){super(),this._editor=e,this._configurationService=t,this._languageFeaturesService=i,this._localToDispose=this._register(new Lt),this._decorationsIds=[],this._colorDatas=new Map,this._colorDecoratorIds=this._editor.createDecorationsCollection(),this._ruleFactory=new jD(this._editor),this._decoratorLimitReporter=new Y4,this._colorDecorationClassRefs=this._register(new Lt),this._debounceInformation=n.for(i.colorProvider,"Document Colors",{min:bC.RECOMPUTE_TIME}),this._register(e.onDidChangeModel(()=>{this._isColorDecoratorsEnabled=this.isEnabled(),this.updateColors()})),this._register(e.onDidChangeModelLanguage(()=>this.updateColors())),this._register(i.colorProvider.onDidChange(()=>this.updateColors())),this._register(e.onDidChangeConfiguration(s=>{const r=this._isColorDecoratorsEnabled;this._isColorDecoratorsEnabled=this.isEnabled(),this._isDefaultColorDecoratorsEnabled=this._editor.getOption(148);const a=r!==this._isColorDecoratorsEnabled||s.hasChanged(21),d=s.hasChanged(148);(a||d)&&(this._isColorDecoratorsEnabled?this.updateColors():this.removeAllDecorations())})),this._timeoutTimer=null,this._computePromise=null,this._isColorDecoratorsEnabled=this.isEnabled(),this._isDefaultColorDecoratorsEnabled=this._editor.getOption(148),this.updateColors()}isEnabled(){const e=this._editor.getModel();if(!e)return!1;const t=e.getLanguageId(),i=this._configurationService.getValue(t);if(i&&typeof i=="object"){const n=i.colorDecorators;if(n&&n.enable!==void 0&&!n.enable)return n.enable}return this._editor.getOption(20)}static get(e){return e.getContribution(this.ID)}dispose(){this.stop(),this.removeAllDecorations(),super.dispose()}updateColors(){if(this.stop(),!this._isColorDecoratorsEnabled)return;const e=this._editor.getModel();!e||!this._languageFeaturesService.colorProvider.has(e)||(this._localToDispose.add(this._editor.onDidChangeModelContent(()=>{this._timeoutTimer||(this._timeoutTimer=new l_,this._timeoutTimer.cancelAndSet(()=>{this._timeoutTimer=null,this.beginCompute()},this._debounceInformation.get(e)))})),this.beginCompute())}async beginCompute(){this._computePromise=Os(async e=>{const t=this._editor.getModel();if(!t)return[];const i=new Mo(!1),n=await ZM(this._languageFeaturesService.colorProvider,t,e,this._isDefaultColorDecoratorsEnabled);return this._debounceInformation.update(t,i.elapsed()),n});try{const e=await this._computePromise;this.updateDecorations(e),this.updateColorDecorators(e),this._computePromise=null}catch(e){Nn(e)}}stop(){this._timeoutTimer&&(this._timeoutTimer.cancel(),this._timeoutTimer=null),this._computePromise&&(this._computePromise.cancel(),this._computePromise=null),this._localToDispose.clear()}updateDecorations(e){const t=e.map(i=>({range:{startLineNumber:i.colorInfo.range.startLineNumber,startColumn:i.colorInfo.range.startColumn,endLineNumber:i.colorInfo.range.endLineNumber,endColumn:i.colorInfo.range.endColumn},options:dn.EMPTY}));this._editor.changeDecorations(i=>{this._decorationsIds=i.deltaDecorations(this._decorationsIds,t),this._colorDatas=new Map,this._decorationsIds.forEach((n,s)=>this._colorDatas.set(n,e[s]))})}updateColorDecorators(e){this._colorDecorationClassRefs.clear();const t=[],i=this._editor.getOption(21);for(let s=0;s<e.length&&t.length<i;s++){const{red:r,green:a,blue:d,alpha:u}=e[s].colorInfo.color,f=new _f(Math.round(r*255),Math.round(a*255),Math.round(d*255),u),g=`rgba(${f.r}, ${f.g}, ${f.b}, ${f.a})`,p=this._colorDecorationClassRefs.add(this._ruleFactory.createClassNameRef({backgroundColor:g}));t.push({range:{startLineNumber:e[s].colorInfo.range.startLineNumber,startColumn:e[s].colorInfo.range.startColumn,endLineNumber:e[s].colorInfo.range.endLineNumber,endColumn:e[s].colorInfo.range.endColumn},options:{description:"colorDetector",before:{content:WD,inlineClassName:`${p.className} colorpicker-color-decoration`,inlineClassNameAffectsLetterSpacing:!0,attachedData:QM}}})}const n=i<e.length?i:!1;this._decoratorLimitReporter.update(e.length,n),this._colorDecoratorIds.set(t)}removeAllDecorations(){this._editor.removeDecorations(this._decorationsIds),this._decorationsIds=[],this._colorDecoratorIds.clear(),this._colorDecorationClassRefs.clear()}getColorData(e){const t=this._editor.getModel();if(!t)return null;const i=t.getDecorationsInRange(Z.fromPositions(e,e)).filter(n=>this._colorDatas.has(n.id));return i.length===0?null:this._colorDatas.get(i[0].id)}isColorDecoration(e){return this._colorDecoratorIds.has(e)}},bC=mc,mc.ID="editor.contrib.colorDetector",mc.RECOMPUTE_TIME=1e3,mc);Ef=bC=Z4([zw(1,Un),zw(2,pi),zw(3,ur)],Ef);class Y4{constructor(){this._onDidChange=new Xi,this._computed=0,this._limited=!1}update(e,t){(e!==this._computed||t!==this._limited)&&(this._computed=e,this._limited=t,this._onDidChange.fire())}}nn(Ef.ID,Ef,1);class X4{get color(){return this._color}set color(e){this._color.equals(e)||(this._color=e,this._onDidChangeColor.fire(e))}get presentation(){return this.colorPresentations[this.presentationIndex]}get colorPresentations(){return this._colorPresentations}set colorPresentations(e){this._colorPresentations=e,this.presentationIndex>e.length-1&&(this.presentationIndex=0),this._onDidChangePresentation.fire(this.presentation)}constructor(e,t,i){this.presentationIndex=i,this._onColorFlushed=new Xi,this.onColorFlushed=this._onColorFlushed.event,this._onDidChangeColor=new Xi,this.onDidChangeColor=this._onDidChangeColor.event,this._onDidChangePresentation=new Xi,this.onDidChangePresentation=this._onDidChangePresentation.event,this.originalColor=e,this._color=e,this._colorPresentations=t}selectNextColorPresentation(){this.presentationIndex=(this.presentationIndex+1)%this.colorPresentations.length,this.flushColor(),this._onDidChangePresentation.fire(this.presentation)}guessColorPresentation(e,t){let i=-1;for(let n=0;n<this.colorPresentations.length;n++)if(t.toLowerCase()===this.colorPresentations[n].label){i=n;break}if(i===-1){const n=t.split("(")[0].toLowerCase();for(let s=0;s<this.colorPresentations.length;s++)if(this.colorPresentations[s].label.toLowerCase().startsWith(n)){i=s;break}}i!==-1&&i!==this.presentationIndex&&(this.presentationIndex=i,this._onDidChangePresentation.fire(this.presentation))}flushColor(){this._onColorFlushed.fire(this._color)}}const jo=si;class Q4 extends Dt{constructor(e,t,i,n=!1){super(),this.model=t,this.showingStandaloneColorPicker=n,this._closeButton=null,this._domNode=jo(".colorpicker-header"),ei(e,this._domNode),this._pickedColorNode=ei(this._domNode,jo(".picked-color")),ei(this._pickedColorNode,jo("span.codicon.codicon-color-mode")),this._pickedColorPresentation=ei(this._pickedColorNode,document.createElement("span")),this._pickedColorPresentation.classList.add("picked-color-presentation");const s=C("clickToToggleColorOptions","Click to toggle color options (rgb/hsl/hex)");this._pickedColorNode.setAttribute("title",s),this._originalColorNode=ei(this._domNode,jo(".original-color")),this._originalColorNode.style.backgroundColor=cn.Format.CSS.format(this.model.originalColor)||"",this.backgroundColor=i.getColorTheme().getColor(dL)||cn.white,this._register(i.onDidColorThemeChange(r=>{this.backgroundColor=r.getColor(dL)||cn.white})),this._register(wn(this._pickedColorNode,Zn.CLICK,()=>this.model.selectNextColorPresentation())),this._register(wn(this._originalColorNode,Zn.CLICK,()=>{this.model.color=this.model.originalColor,this.model.flushColor()})),this._register(t.onDidChangeColor(this.onDidChangeColor,this)),this._register(t.onDidChangePresentation(this.onDidChangePresentation,this)),this._pickedColorNode.style.backgroundColor=cn.Format.CSS.format(t.color)||"",this._pickedColorNode.classList.toggle("light",t.color.rgba.a<.5?this.backgroundColor.isLighter():t.color.isLighter()),this.onDidChangeColor(this.model.color),this.showingStandaloneColorPicker&&(this._domNode.classList.add("standalone-colorpicker"),this._closeButton=this._register(new J4(this._domNode)))}get closeButton(){return this._closeButton}get pickedColorNode(){return this._pickedColorNode}get originalColorNode(){return this._originalColorNode}onDidChangeColor(e){this._pickedColorNode.style.backgroundColor=cn.Format.CSS.format(e)||"",this._pickedColorNode.classList.toggle("light",e.rgba.a<.5?this.backgroundColor.isLighter():e.isLighter()),this.onDidChangePresentation()}onDidChangePresentation(){this._pickedColorPresentation.textContent=this.model.presentation?this.model.presentation.label:""}}class J4 extends Dt{constructor(e){super(),this._onClicked=this._register(new Xi),this.onClicked=this._onClicked.event,this._button=document.createElement("div"),this._button.classList.add("close-button"),ei(e,this._button);const t=document.createElement("div");t.classList.add("close-button-inner-div"),ei(this._button,t),ei(t,jo(".button"+xn.asCSSSelector(is("color-picker-close",ji.close,C("closeIcon","Icon to close the color picker"))))).classList.add("close-icon"),this._register(wn(this._button,Zn.CLICK,()=>{this._onClicked.fire()}))}}class eB extends Dt{constructor(e,t,i,n=!1){super(),this.model=t,this.pixelRatio=i,this._insertButton=null,this._domNode=jo(".colorpicker-body"),ei(e,this._domNode),this._saturationBox=new tB(this._domNode,this.model,this.pixelRatio),this._register(this._saturationBox),this._register(this._saturationBox.onDidChange(this.onDidSaturationValueChange,this)),this._register(this._saturationBox.onColorFlushed(this.flushColor,this)),this._opacityStrip=new iB(this._domNode,this.model,n),this._register(this._opacityStrip),this._register(this._opacityStrip.onDidChange(this.onDidOpacityChange,this)),this._register(this._opacityStrip.onColorFlushed(this.flushColor,this)),this._hueStrip=new nB(this._domNode,this.model,n),this._register(this._hueStrip),this._register(this._hueStrip.onDidChange(this.onDidHueChange,this)),this._register(this._hueStrip.onColorFlushed(this.flushColor,this)),n&&(this._insertButton=this._register(new sB(this._domNode)),this._domNode.classList.add("standalone-colorpicker"))}flushColor(){this.model.flushColor()}onDidSaturationValueChange({s:e,v:t}){const i=this.model.color.hsva;this.model.color=new cn(new Tm(i.h,e,t,i.a))}onDidOpacityChange(e){const t=this.model.color.hsva;this.model.color=new cn(new Tm(t.h,t.s,t.v,e))}onDidHueChange(e){const t=this.model.color.hsva,i=(1-e)*360;this.model.color=new cn(new Tm(i===360?0:i,t.s,t.v,t.a))}get domNode(){return this._domNode}get saturationBox(){return this._saturationBox}get enterButton(){return this._insertButton}layout(){this._saturationBox.layout(),this._opacityStrip.layout(),this._hueStrip.layout()}}class tB extends Dt{constructor(e,t,i){super(),this.model=t,this.pixelRatio=i,this._onDidChange=new Xi,this.onDidChange=this._onDidChange.event,this._onColorFlushed=new Xi,this.onColorFlushed=this._onColorFlushed.event,this._domNode=jo(".saturation-wrap"),ei(e,this._domNode),this._canvas=document.createElement("canvas"),this._canvas.className="saturation-box",ei(this._domNode,this._canvas),this.selection=jo(".saturation-selection"),ei(this._domNode,this.selection),this.layout(),this._register(wn(this._domNode,Zn.POINTER_DOWN,n=>this.onPointerDown(n))),this._register(this.model.onDidChangeColor(this.onDidChangeColor,this)),this.monitor=null}get domNode(){return this._domNode}onPointerDown(e){if(!e.target||!(e.target instanceof Element))return;this.monitor=this._register(new $D);const t=mo(this._domNode);e.target!==this.selection&&this.onDidChangePosition(e.offsetX,e.offsetY),this.monitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>this.onDidChangePosition(n.pageX-t.left,n.pageY-t.top),()=>null);const i=wn(e.target.ownerDocument,Zn.POINTER_UP,()=>{this._onColorFlushed.fire(),i.dispose(),this.monitor&&(this.monitor.stopMonitoring(!0),this.monitor=null)},!0)}onDidChangePosition(e,t){const i=Math.max(0,Math.min(1,e/this.width)),n=Math.max(0,Math.min(1,1-t/this.height));this.paintSelection(i,n),this._onDidChange.fire({s:i,v:n})}layout(){this.width=this._domNode.offsetWidth,this.height=this._domNode.offsetHeight,this._canvas.width=this.width*this.pixelRatio,this._canvas.height=this.height*this.pixelRatio,this.paint();const e=this.model.color.hsva;this.paintSelection(e.s,e.v)}paint(){const e=this.model.color.hsva,t=new cn(new Tm(e.h,1,1,1)),i=this._canvas.getContext("2d"),n=i.createLinearGradient(0,0,this._canvas.width,0);n.addColorStop(0,"rgba(255, 255, 255, 1)"),n.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),n.addColorStop(1,"rgba(255, 255, 255, 0)");const s=i.createLinearGradient(0,0,0,this._canvas.height);s.addColorStop(0,"rgba(0, 0, 0, 0)"),s.addColorStop(1,"rgba(0, 0, 0, 1)"),i.rect(0,0,this._canvas.width,this._canvas.height),i.fillStyle=cn.Format.CSS.format(t),i.fill(),i.fillStyle=n,i.fill(),i.fillStyle=s,i.fill()}paintSelection(e,t){this.selection.style.left=`${e*this.width}px`,this.selection.style.top=`${this.height-t*this.height}px`}onDidChangeColor(e){if(this.monitor&&this.monitor.isMonitoring())return;this.paint();const t=e.hsva;this.paintSelection(t.s,t.v)}}class JM extends Dt{constructor(e,t,i=!1){super(),this.model=t,this._onDidChange=new Xi,this.onDidChange=this._onDidChange.event,this._onColorFlushed=new Xi,this.onColorFlushed=this._onColorFlushed.event,i?(this.domNode=ei(e,jo(".standalone-strip")),this.overlay=ei(this.domNode,jo(".standalone-overlay"))):(this.domNode=ei(e,jo(".strip")),this.overlay=ei(this.domNode,jo(".overlay"))),this.slider=ei(this.domNode,jo(".slider")),this.slider.style.top="0px",this._register(wn(this.domNode,Zn.POINTER_DOWN,n=>this.onPointerDown(n))),this._register(t.onDidChangeColor(this.onDidChangeColor,this)),this.layout()}layout(){this.height=this.domNode.offsetHeight-this.slider.offsetHeight;const e=this.getValue(this.model.color);this.updateSliderPosition(e)}onDidChangeColor(e){const t=this.getValue(e);this.updateSliderPosition(t)}onPointerDown(e){if(!e.target||!(e.target instanceof Element))return;const t=this._register(new $D),i=mo(this.domNode);this.domNode.classList.add("grabbing"),e.target!==this.slider&&this.onDidChangeTop(e.offsetY),t.startMonitoring(e.target,e.pointerId,e.buttons,s=>this.onDidChangeTop(s.pageY-i.top),()=>null);const n=wn(e.target.ownerDocument,Zn.POINTER_UP,()=>{this._onColorFlushed.fire(),n.dispose(),t.stopMonitoring(!0),this.domNode.classList.remove("grabbing")},!0)}onDidChangeTop(e){const t=Math.max(0,Math.min(1,1-e/this.height));this.updateSliderPosition(t),this._onDidChange.fire(t)}updateSliderPosition(e){this.slider.style.top=`${(1-e)*this.height}px`}}class iB extends JM{constructor(e,t,i=!1){super(e,t,i),this.domNode.classList.add("opacity-strip"),this.onDidChangeColor(this.model.color)}onDidChangeColor(e){super.onDidChangeColor(e);const{r:t,g:i,b:n}=e.rgba,s=new cn(new _f(t,i,n,1)),r=new cn(new _f(t,i,n,0));this.overlay.style.background=`linear-gradient(to bottom, ${s} 0%, ${r} 100%)`}getValue(e){return e.hsva.a}}class nB extends JM{constructor(e,t,i=!1){super(e,t,i),this.domNode.classList.add("hue-strip")}getValue(e){return 1-e.hsva.h/360}}class sB extends Dt{constructor(e){super(),this._onClicked=this._register(new Xi),this.onClicked=this._onClicked.event,this._button=ei(e,document.createElement("button")),this._button.classList.add("insert-button"),this._button.textContent="Insert",this._register(wn(this._button,Zn.CLICK,()=>{this._onClicked.fire()}))}get button(){return this._button}}class oB extends h_{constructor(e,t,i,n,s=!1){super(),this.model=t,this.pixelRatio=i,this._register(d2.getInstance(yd(e)).onDidChange(()=>this.layout())),this._domNode=jo(".colorpicker-widget"),e.appendChild(this._domNode),this.header=this._register(new Q4(this._domNode,this.model,n,s)),this.body=this._register(new eB(this._domNode,this.model,this.pixelRatio,s))}layout(){this.body.layout()}get domNode(){return this._domNode}}class Vw{constructor(e,t,i,n){this.priority=e,this.range=t,this.initialMousePosX=i,this.initialMousePosY=n,this.type=1}equals(e){return e.type===1&&this.range.equalsRange(e.range)}canAdoptVisibleHover(e,t){return e.type===1&&t.lineNumber===this.range.startLineNumber}}class zm{constructor(e,t,i,n,s,r){this.priority=e,this.owner=t,this.range=i,this.initialMousePosX=n,this.initialMousePosY=s,this.supportsMarkerHover=r,this.type=2}equals(e){return e.type===2&&this.owner===e.owner}canAdoptVisibleHover(e,t){return e.type===2&&this.owner===e.owner}}class Du{constructor(e){this.renderedHoverParts=e}dispose(){for(const e of this.renderedHoverParts)e.dispose()}}const ju=new class{constructor(){this._participants=[]}register(e){this._participants.push(e)}getAll(){return this._participants}};var eR=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},tR=function(o,e){return function(t,i){e(t,i,o)}};class rB{constructor(e,t,i,n){this.owner=e,this.range=t,this.model=i,this.provider=n,this.forceShowAtRange=!0}isValidForHoverAnchor(e){return e.type===1&&this.range.startColumn<=e.range.startColumn&&this.range.endColumn>=e.range.endColumn}}let Dp=class{constructor(e,t){this._editor=e,this._themeService=t,this.hoverOrdinal=2}computeSync(e,t){return[]}computeAsync(e,t,i){return oa.fromPromise(this._computeAsync(e,t,i))}async _computeAsync(e,t,i){if(!this._editor.hasModel())return[];const n=Ef.get(this._editor);if(!n)return[];for(const s of t){if(!n.isColorDecoration(s))continue;const r=n.getColorData(s.range.getStartPosition());if(r)return[await iR(this,this._editor.getModel(),r.colorInfo,r.provider)]}return[]}renderHoverParts(e,t){const i=nR(this,this._editor,this._themeService,t,e);if(!i)return new Du([]);this._colorPicker=i.colorPicker;const n={hoverPart:i.hoverPart,hoverElement:this._colorPicker.domNode,dispose(){i.disposables.dispose()}};return new Du([n])}handleResize(){var e;(e=this._colorPicker)==null||e.layout()}isColorPickerVisible(){return!!this._colorPicker}};Dp=eR([tR(1,Hr)],Dp);class aB{constructor(e,t,i,n){this.owner=e,this.range=t,this.model=i,this.provider=n}}let Tp=class{constructor(e,t){this._editor=e,this._themeService=t,this._color=null}async createColorHover(e,t,i){if(!this._editor.hasModel()||!Ef.get(this._editor))return null;const s=await ZM(i,this._editor.getModel(),Qi.None);let r=null,a=null;for(const g of s){const p=g.colorInfo;Z.containsRange(p.range,e.range)&&(r=p,a=g.provider)}const d=r??e,u=a??t,f=!!r;return{colorHover:await iR(this,this._editor.getModel(),d,u),foundInEditor:f}}async updateEditorModel(e){if(!this._editor.hasModel())return;const t=e.model;let i=new Z(e.range.startLineNumber,e.range.startColumn,e.range.endLineNumber,e.range.endColumn);this._color&&(await Vm(this._editor.getModel(),t,this._color,i,e),i=sR(this._editor,i,t))}renderHoverParts(e,t){return nR(this,this._editor,this._themeService,t,e)}set color(e){this._color=e}get color(){return this._color}};Tp=eR([tR(1,Hr)],Tp);async function iR(o,e,t,i){const n=e.getValueInRange(t.range),{red:s,green:r,blue:a,alpha:d}=t.color,u=new _f(Math.round(s*255),Math.round(r*255),Math.round(a*255),d),f=new cn(u),g=await YM(e,t,i,Qi.None),p=new X4(f,[],0);return p.colorPresentations=g||[],p.guessColorPresentation(f,n),o instanceof Dp?new rB(o,Z.lift(t.range),p,i):new aB(o,Z.lift(t.range),p,i)}function nR(o,e,t,i,n){if(i.length===0||!e.hasModel())return;if(n.setMinimumDimensions){const p=e.getOption(67)+8;n.setMinimumDimensions(new On(302,p))}const s=new Lt,r=i[0],a=e.getModel(),d=r.model,u=s.add(new oB(n.fragment,d,e.getOption(144),t,o instanceof Tp));let f=!1,g=new Z(r.range.startLineNumber,r.range.startColumn,r.range.endLineNumber,r.range.endColumn);if(o instanceof Tp){const p=r.model.color;o.color=p,Vm(a,d,p,g,r),s.add(d.onColorFlushed(w=>{o.color=w}))}else s.add(d.onColorFlushed(async p=>{await Vm(a,d,p,g,r),f=!0,g=sR(e,g,d)}));return s.add(d.onDidChangeColor(p=>{Vm(a,d,p,g,r)})),s.add(e.onDidChangeModelContent(p=>{f?f=!1:(n.hide(),e.focus())})),{hoverPart:r,colorPicker:u,disposables:s}}function sR(o,e,t){const i=[],n=t.presentation.textEdit??{range:e,text:t.presentation.label,forceMoveMarkers:!1};i.push(n),t.presentation.additionalTextEdits&&i.push(...t.presentation.additionalTextEdits);const s=Z.lift(n.range),r=o.getModel()._setTrackedRange(null,s,3);return o.executeEdits("colorpicker",i),o.pushUndoStop(),o.getModel()._getTrackedRange(r)??s}async function Vm(o,e,t,i,n){const s=await YM(o,{range:i,color:{red:t.rgba.r/255,green:t.rgba.g/255,blue:t.rgba.b/255,alpha:t.rgba.a}},n.provider,Qi.None);e.colorPresentations=s||[]}const oR="editor.action.showHover",lB="editor.action.showDefinitionPreviewHover",cB="editor.action.scrollUpHover",dB="editor.action.scrollDownHover",uB="editor.action.scrollLeftHover",hB="editor.action.scrollRightHover",fB="editor.action.pageUpHover",gB="editor.action.pageDownHover",pB="editor.action.goToTopHover",_B="editor.action.goToBottomHover",Gy="editor.action.increaseHoverVerbosityLevel",mB=C({key:"increaseHoverVerbosityLevel",comment:["Label for action that will increase the hover verbosity level."]},"Increase Hover Verbosity Level"),Ky="editor.action.decreaseHoverVerbosityLevel",vB=C({key:"decreaseHoverVerbosityLevel",comment:["Label for action that will decrease the hover verbosity level."]},"Decrease Hover Verbosity Level"),rR="editor.action.inlineSuggest.commit",aR="editor.action.inlineSuggest.showPrevious",lR="editor.action.inlineSuggest.showNext";var G0=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ir=function(o,e){return function(t,i){e(t,i,o)}},jm;let yC=class extends Dt{constructor(e,t,i){super(),this.editor=e,this.model=t,this.instantiationService=i,this.alwaysShowToolbar=Lo(this,this.editor.onDidChangeConfiguration,()=>this.editor.getOption(62).showToolbar==="always"),this.sessionPosition=void 0,this.position=En(this,n=>{var d,u;const s=(d=this.model.read(n))==null?void 0:d.primaryGhostText.read(n);if(!this.alwaysShowToolbar.read(n)||!s||s.parts.length===0)return this.sessionPosition=void 0,null;const r=s.parts[0].column;this.sessionPosition&&this.sessionPosition.lineNumber!==s.lineNumber&&(this.sessionPosition=void 0);const a=new gi(s.lineNumber,Math.min(r,((u=this.sessionPosition)==null?void 0:u.column)??Number.MAX_SAFE_INTEGER));return this.sessionPosition=a,a}),this._register(f_((n,s)=>{const r=this.model.read(n);if(!r||!this.alwaysShowToolbar.read(n))return;const a=KD((u,f)=>{const g=f.add(this.instantiationService.createInstance(Df,this.editor,!0,this.position,r.selectedInlineCompletionIndex,r.inlineCompletionsCount,r.activeCommands));return e.addContentWidget(g),f.add(jn(()=>e.removeContentWidget(g))),f.add(Kn(p=>{this.position.read(p)&&r.lastTriggerKind.read(p)!==ml.Explicit&&r.triggerExplicitly()})),g}),d=xy(this,(u,f)=>!!this.position.read(u)||!!f);s.add(Kn(u=>{d.read(u)&&a.read(u)}))}))}};yC=G0([Ir(2,Zi)],yC);const bB=is("inline-suggestion-hints-next",ji.chevronRight,C("parameterHintsNextIcon","Icon for show next parameter hint.")),yB=is("inline-suggestion-hints-previous",ji.chevronLeft,C("parameterHintsPreviousIcon","Icon for show previous parameter hint."));var vc;let Df=(vc=class extends Dt{static get dropDownVisible(){return this._dropDownVisible}createCommandAction(e,t,i){const n=new mf(e,t,i,!0,()=>this._commandService.executeCommand(e)),s=this.keybindingService.lookupKeybinding(e,this._contextKeyService);let r=t;return s&&(r=C({key:"content",comment:["A label","A keybinding"]},"{0} ({1})",t,s.getLabel())),n.tooltip=r,n}constructor(e,t,i,n,s,r,a,d,u,f,g){super(),this.editor=e,this.withBorder=t,this._position=i,this._currentSuggestionIdx=n,this._suggestionCount=s,this._extraCommands=r,this._commandService=a,this.keybindingService=u,this._contextKeyService=f,this._menuService=g,this.id=`InlineSuggestionHintsContentWidget${jm.id++}`,this.allowEditorOverflow=!0,this.suppressMouseDown=!1,this.nodes=Er("div.inlineSuggestionsHints",{className:this.withBorder?".withBorder":""},[Er("div@toolBar")]),this.previousAction=this.createCommandAction(aR,C("previous","Previous"),xn.asClassName(yB)),this.availableSuggestionCountAction=new mf("inlineSuggestionHints.availableSuggestionCount","",void 0,!1),this.nextAction=this.createCommandAction(lR,C("next","Next"),xn.asClassName(bB)),this.inlineCompletionsActionsMenus=this._register(this._menuService.createMenu(Gt.InlineCompletionsActions,this._contextKeyService)),this.clearAvailableSuggestionCountLabelDebounced=this._register(new Ss(()=>{this.availableSuggestionCountAction.label=""},100)),this.disableButtonsDebounced=this._register(new Ss(()=>{this.previousAction.enabled=this.nextAction.enabled=!1},100)),this.toolBar=this._register(d.createInstance(wC,this.nodes.toolBar,Gt.InlineSuggestionToolbar,{menuOptions:{renderShortTitle:!0},toolbarOptions:{primaryGroup:p=>p.startsWith("primary")},actionViewItemProvider:(p,w)=>{if(p instanceof vf)return d.createInstance(SB,p,void 0);if(p===this.availableSuggestionCountAction){const y=new wB(void 0,p,{label:!0,icon:!1});return y.setClass("availableSuggestionCount"),y}},telemetrySource:"InlineSuggestionToolbar"})),this.toolBar.setPrependedPrimaryActions([this.previousAction,this.availableSuggestionCountAction,this.nextAction]),this._register(this.toolBar.onDidChangeDropdownVisibility(p=>{jm._dropDownVisible=p})),this._register(Kn(p=>{this._position.read(p),this.editor.layoutContentWidget(this)})),this._register(Kn(p=>{const w=this._suggestionCount.read(p),y=this._currentSuggestionIdx.read(p);w!==void 0?(this.clearAvailableSuggestionCountLabelDebounced.cancel(),this.availableSuggestionCountAction.label=`${y+1}/${w}`):this.clearAvailableSuggestionCountLabelDebounced.schedule(),w!==void 0&&w>1?(this.disableButtonsDebounced.cancel(),this.previousAction.enabled=this.nextAction.enabled=!0):this.disableButtonsDebounced.schedule()})),this._register(Kn(p=>{const y=this._extraCommands.read(p).map(x=>({class:void 0,id:x.id,enabled:!0,tooltip:x.tooltip||"",label:x.title,run:k=>this._commandService.executeCommand(x.id)}));for(const[x,k]of this.inlineCompletionsActionsMenus.getActions())for(const D of k)D instanceof vf&&y.push(D);y.length>0&&y.unshift(new gp),this.toolBar.setAdditionalSecondaryActions(y)}))}getId(){return this.id}getDomNode(){return this.nodes.root}getPosition(){return{position:this._position.get(),preference:[1,2],positionAffinity:3}}},jm=vc,vc._dropDownVisible=!1,vc.id=0,vc);Df=jm=G0([Ir(6,Es),Ir(7,Zi),Ir(8,hs),Ir(9,Sn),Ir(10,Fu)],Df);class wB extends CS{constructor(){super(...arguments),this._className=void 0}setClass(e){this._className=e}render(e){super.render(e),this._className&&e.classList.add(this._className)}updateTooltip(){}}let SB=class extends UD{updateLabel(){const e=this._keybindingService.lookupKeybinding(this._action.id,this._contextKeyService);if(!e)return super.updateLabel();if(this.label){const t=Er("div.keybinding").root;this._register(new Jx(t,e0,{disableTitle:!0,...qD})).set(e),this.label.textContent=this._action.label,this.label.appendChild(t),this.label.classList.add("inlineSuggestionStatusBarItemLabel")}}updateTooltip(){}},wC=class extends GD{constructor(e,t,i,n,s,r,a,d,u){super(e,{resetMenu:t,...i},n,s,r,a,d,u),this.menuId=t,this.options2=i,this.menuService=n,this.contextKeyService=s,this.menu=this._store.add(this.menuService.createMenu(this.menuId,this.contextKeyService,{emitEventsForSubmenuChanges:!0})),this.additionalActions=[],this.prependedPrimaryActions=[],this._store.add(this.menu.onDidChange(()=>this.updateToolbar())),this.updateToolbar()}updateToolbar(){var i,n,s,r,a,d,u;const e=[],t=[];r0(this.menu,(i=this.options2)==null?void 0:i.menuOptions,{primary:e,secondary:t},(s=(n=this.options2)==null?void 0:n.toolbarOptions)==null?void 0:s.primaryGroup,(a=(r=this.options2)==null?void 0:r.toolbarOptions)==null?void 0:a.shouldInlineSubmenu,(u=(d=this.options2)==null?void 0:d.toolbarOptions)==null?void 0:u.useSeparatorsInPrimaryActions),t.push(...this.additionalActions),e.unshift(...this.prependedPrimaryActions),this.setActions(e,t)}setPrependedPrimaryActions(e){Va(this.prependedPrimaryActions,e,(t,i)=>t===i)||(this.prependedPrimaryActions=e,this.updateToolbar())}setAdditionalSecondaryActions(e){Va(this.additionalActions,e,(t,i)=>t===i)||(this.additionalActions=e,this.updateToolbar())}};wC=G0([Ir(3,Fu),Ir(4,Sn),Ir(5,zf),Ir(6,hs),Ir(7,Es),Ir(8,ha)],wC);function Zy(o,e,t){const i=mo(o);return!(e<i.left||e>i.left+i.width||t<i.top||t>i.top+i.height)}let CB=class{constructor(e,t,i){this.value=e,this.isComplete=t,this.hasLoadingMessage=i}};class cR extends Dt{constructor(e,t){super(),this._editor=e,this._computer=t,this._onResult=this._register(new Xi),this.onResult=this._onResult.event,this._firstWaitScheduler=this._register(new Ss(()=>this._triggerAsyncComputation(),0)),this._secondWaitScheduler=this._register(new Ss(()=>this._triggerSyncComputation(),0)),this._loadingMessageScheduler=this._register(new Ss(()=>this._triggerLoadingMessage(),0)),this._state=0,this._asyncIterable=null,this._asyncIterableDone=!1,this._result=[]}dispose(){this._asyncIterable&&(this._asyncIterable.cancel(),this._asyncIterable=null),super.dispose()}get _hoverTime(){return this._editor.getOption(60).delay}get _firstWaitTime(){return this._hoverTime/2}get _secondWaitTime(){return this._hoverTime-this._firstWaitTime}get _loadingMessageTime(){return 3*this._hoverTime}_setState(e,t=!0){this._state=e,t&&this._fireResult()}_triggerAsyncComputation(){this._setState(2),this._secondWaitScheduler.schedule(this._secondWaitTime),this._computer.computeAsync?(this._asyncIterableDone=!1,this._asyncIterable=u2(e=>this._computer.computeAsync(e)),(async()=>{try{for await(const e of this._asyncIterable)e&&(this._result.push(e),this._fireResult());this._asyncIterableDone=!0,(this._state===3||this._state===4)&&this._setState(0)}catch(e){Nn(e)}})()):this._asyncIterableDone=!0}_triggerSyncComputation(){this._computer.computeSync&&(this._result=this._result.concat(this._computer.computeSync())),this._setState(this._asyncIterableDone?0:3)}_triggerLoadingMessage(){this._state===3&&this._setState(4)}_fireResult(){if(this._state===1||this._state===2)return;const e=this._state===0,t=this._state===4;this._onResult.fire(new CB(this._result.slice(0),e,t))}start(e){if(e===0)this._state===0&&(this._setState(1),this._firstWaitScheduler.schedule(this._firstWaitTime),this._loadingMessageScheduler.schedule(this._loadingMessageTime));else switch(this._state){case 0:this._triggerAsyncComputation(),this._secondWaitScheduler.cancel(),this._triggerSyncComputation();break;case 2:this._secondWaitScheduler.cancel(),this._triggerSyncComputation();break}}cancel(){this._firstWaitScheduler.cancel(),this._secondWaitScheduler.cancel(),this._loadingMessageScheduler.cancel(),this._asyncIterable&&(this._asyncIterable.cancel(),this._asyncIterable=null),this._result=[],this._setState(0,!1)}}class K0{constructor(){this._onDidWillResize=new Xi,this.onDidWillResize=this._onDidWillResize.event,this._onDidResize=new Xi,this.onDidResize=this._onDidResize.event,this._sashListener=new Lt,this._size=new On(0,0),this._minSize=new On(0,0),this._maxSize=new On(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),this.domNode=document.createElement("div"),this._eastSash=new Ch(this.domNode,{getVerticalSashLeft:()=>this._size.width},{orientation:0}),this._westSash=new Ch(this.domNode,{getVerticalSashLeft:()=>0},{orientation:0}),this._northSash=new Ch(this.domNode,{getHorizontalSashTop:()=>0},{orientation:1,orthogonalEdge:uL.North}),this._southSash=new Ch(this.domNode,{getHorizontalSashTop:()=>this._size.height},{orientation:1,orthogonalEdge:uL.South}),this._northSash.orthogonalStartSash=this._westSash,this._northSash.orthogonalEndSash=this._eastSash,this._southSash.orthogonalStartSash=this._westSash,this._southSash.orthogonalEndSash=this._eastSash;let e,t=0,i=0;this._sashListener.add(ws.any(this._northSash.onDidStart,this._eastSash.onDidStart,this._southSash.onDidStart,this._westSash.onDidStart)(()=>{e===void 0&&(this._onDidWillResize.fire(),e=this._size,t=0,i=0)})),this._sashListener.add(ws.any(this._northSash.onDidEnd,this._eastSash.onDidEnd,this._southSash.onDidEnd,this._westSash.onDidEnd)(()=>{e!==void 0&&(e=void 0,t=0,i=0,this._onDidResize.fire({dimension:this._size,done:!0}))})),this._sashListener.add(this._eastSash.onDidChange(n=>{e&&(i=n.currentX-n.startX,this.layout(e.height+t,e.width+i),this._onDidResize.fire({dimension:this._size,done:!1,east:!0}))})),this._sashListener.add(this._westSash.onDidChange(n=>{e&&(i=-(n.currentX-n.startX),this.layout(e.height+t,e.width+i),this._onDidResize.fire({dimension:this._size,done:!1,west:!0}))})),this._sashListener.add(this._northSash.onDidChange(n=>{e&&(t=-(n.currentY-n.startY),this.layout(e.height+t,e.width+i),this._onDidResize.fire({dimension:this._size,done:!1,north:!0}))})),this._sashListener.add(this._southSash.onDidChange(n=>{e&&(t=n.currentY-n.startY,this.layout(e.height+t,e.width+i),this._onDidResize.fire({dimension:this._size,done:!1,south:!0}))})),this._sashListener.add(ws.any(this._eastSash.onDidReset,this._westSash.onDidReset)(n=>{this._preferredSize&&(this.layout(this._size.height,this._preferredSize.width),this._onDidResize.fire({dimension:this._size,done:!0}))})),this._sashListener.add(ws.any(this._northSash.onDidReset,this._southSash.onDidReset)(n=>{this._preferredSize&&(this.layout(this._preferredSize.height,this._size.width),this._onDidResize.fire({dimension:this._size,done:!0}))}))}dispose(){this._northSash.dispose(),this._southSash.dispose(),this._eastSash.dispose(),this._westSash.dispose(),this._sashListener.dispose(),this._onDidResize.dispose(),this._onDidWillResize.dispose(),this.domNode.remove()}enableSashes(e,t,i,n){this._northSash.state=e?3:0,this._eastSash.state=t?3:0,this._southSash.state=i?3:0,this._westSash.state=n?3:0}layout(e=this.size.height,t=this.size.width){const{height:i,width:n}=this._minSize,{height:s,width:r}=this._maxSize;e=Math.max(i,Math.min(s,e)),t=Math.max(n,Math.min(r,t));const a=new On(t,e);On.equals(a,this._size)||(this.domNode.style.height=e+"px",this.domNode.style.width=t+"px",this._size=a,this._northSash.layout(),this._eastSash.layout(),this._southSash.layout(),this._westSash.layout())}clearSashHoverState(){this._eastSash.clearSashHoverState(),this._westSash.clearSashHoverState(),this._northSash.clearSashHoverState(),this._southSash.clearSashHoverState()}get size(){return this._size}set maxSize(e){this._maxSize=e}get maxSize(){return this._maxSize}set minSize(e){this._minSize=e}get minSize(){return this._minSize}set preferredSize(e){this._preferredSize=e}get preferredSize(){return this._preferredSize}}const xB=30,kB=24;class LB extends Dt{constructor(e,t=new On(10,10)){super(),this._editor=e,this.allowEditorOverflow=!0,this.suppressMouseDown=!1,this._resizableNode=this._register(new K0),this._contentPosition=null,this._isResizing=!1,this._resizableNode.domNode.style.position="absolute",this._resizableNode.minSize=On.lift(t),this._resizableNode.layout(t.height,t.width),this._resizableNode.enableSashes(!0,!0,!0,!0),this._register(this._resizableNode.onDidResize(i=>{this._resize(new On(i.dimension.width,i.dimension.height)),i.done&&(this._isResizing=!1)})),this._register(this._resizableNode.onDidWillResize(()=>{this._isResizing=!0}))}get isResizing(){return this._isResizing}getDomNode(){return this._resizableNode.domNode}getPosition(){return this._contentPosition}get position(){var e;return(e=this._contentPosition)!=null&&e.position?gi.lift(this._contentPosition.position):void 0}_availableVerticalSpaceAbove(e){const t=this._editor.getDomNode(),i=this._editor.getScrolledVisiblePosition(e);return!t||!i?void 0:mo(t).top+i.top-xB}_availableVerticalSpaceBelow(e){const t=this._editor.getDomNode(),i=this._editor.getScrolledVisiblePosition(e);if(!t||!i)return;const n=mo(t),s=g_(t.ownerDocument.body),r=n.top+i.top+i.height;return s.height-r-kB}_findPositionPreference(e,t){const i=Math.min(this._availableVerticalSpaceBelow(t)??1/0,e),n=Math.min(this._availableVerticalSpaceAbove(t)??1/0,e),s=Math.min(Math.max(n,i),e),r=Math.min(e,s);let a;return this._editor.getOption(60).above?a=r<=n?1:2:a=r<=i?2:1,a===1?this._resizableNode.enableSashes(!0,!0,!1,!1):this._resizableNode.enableSashes(!1,!0,!0,!1),a}_resize(e){this._resizableNode.layout(e.height,e.width)}}var IB=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},tm=function(o,e){return function(t,i){e(t,i,o)}},wa;const mI=30,EB=6;var bc;let SC=(bc=class extends LB{get isVisibleFromKeyboard(){var e;return((e=this._renderedHover)==null?void 0:e.source)===1}get isVisible(){return this._hoverVisibleKey.get()??!1}get isFocused(){return this._hoverFocusedKey.get()??!1}constructor(e,t,i,n,s){const r=e.getOption(67)+8,a=150,d=new On(a,r);super(e,d),this._configurationService=i,this._accessibilityService=n,this._keybindingService=s,this._hover=this._register(new ZD),this._onDidResize=this._register(new Xi),this.onDidResize=this._onDidResize.event,this._minimumSize=d,this._hoverVisibleKey=B.hoverVisible.bindTo(t),this._hoverFocusedKey=B.hoverFocused.bindTo(t),ei(this._resizableNode.domNode,this._hover.containerDomNode),this._resizableNode.domNode.style.zIndex="50",this._register(this._editor.onDidLayoutChange(()=>{this.isVisible&&this._updateMaxDimensions()})),this._register(this._editor.onDidChangeConfiguration(f=>{f.hasChanged(50)&&this._updateFont()}));const u=this._register(ff(this._resizableNode.domNode));this._register(u.onDidFocus(()=>{this._hoverFocusedKey.set(!0)})),this._register(u.onDidBlur(()=>{this._hoverFocusedKey.set(!1)})),this._setRenderedHover(void 0),this._editor.addContentWidget(this)}dispose(){var e;super.dispose(),(e=this._renderedHover)==null||e.dispose(),this._editor.removeContentWidget(this)}getId(){return wa.ID}static _applyDimensions(e,t,i){const n=typeof t=="number"?`${t}px`:t,s=typeof i=="number"?`${i}px`:i;e.style.width=n,e.style.height=s}_setContentsDomNodeDimensions(e,t){const i=this._hover.contentsDomNode;return wa._applyDimensions(i,e,t)}_setContainerDomNodeDimensions(e,t){const i=this._hover.containerDomNode;return wa._applyDimensions(i,e,t)}_setHoverWidgetDimensions(e,t){this._setContentsDomNodeDimensions(e,t),this._setContainerDomNodeDimensions(e,t),this._layoutContentWidget()}static _applyMaxDimensions(e,t,i){const n=typeof t=="number"?`${t}px`:t,s=typeof i=="number"?`${i}px`:i;e.style.maxWidth=n,e.style.maxHeight=s}_setHoverWidgetMaxDimensions(e,t){wa._applyMaxDimensions(this._hover.contentsDomNode,e,t),wa._applyMaxDimensions(this._hover.containerDomNode,e,t),this._hover.containerDomNode.style.setProperty("--vscode-hover-maxWidth",typeof e=="number"?`${e}px`:e),this._layoutContentWidget()}_setAdjustedHoverWidgetDimensions(e){this._setHoverWidgetMaxDimensions("none","none");const t=e.width,i=e.height;this._setHoverWidgetDimensions(t,i)}_updateResizableNodeMaxDimensions(){const e=this._findMaximumRenderingWidth()??1/0,t=this._findMaximumRenderingHeight()??1/0;this._resizableNode.maxSize=new On(e,t),this._setHoverWidgetMaxDimensions(e,t)}_resize(e){wa._lastDimensions=new On(e.width,e.height),this._setAdjustedHoverWidgetDimensions(e),this._resizableNode.layout(e.height,e.width),this._updateResizableNodeMaxDimensions(),this._hover.scrollbar.scanDomNode(),this._editor.layoutContentWidget(this),this._onDidResize.fire()}_findAvailableSpaceVertically(){var t;const e=(t=this._renderedHover)==null?void 0:t.showAtPosition;if(e)return this._positionPreference===1?this._availableVerticalSpaceAbove(e):this._availableVerticalSpaceBelow(e)}_findMaximumRenderingHeight(){const e=this._findAvailableSpaceVertically();if(!e)return;let t=EB;return Array.from(this._hover.contentsDomNode.children).forEach(i=>{t+=i.clientHeight}),Math.min(e,t)}_isHoverTextOverflowing(){this._hover.containerDomNode.style.setProperty("--vscode-hover-whiteSpace","nowrap"),this._hover.containerDomNode.style.setProperty("--vscode-hover-sourceWhiteSpace","nowrap");const e=Array.from(this._hover.contentsDomNode.children).some(t=>t.scrollWidth>t.clientWidth);return this._hover.containerDomNode.style.removeProperty("--vscode-hover-whiteSpace"),this._hover.containerDomNode.style.removeProperty("--vscode-hover-sourceWhiteSpace"),e}_findMaximumRenderingWidth(){if(!this._editor||!this._editor.hasModel())return;const e=this._isHoverTextOverflowing(),t=typeof this._contentWidth>"u"?0:this._contentWidth-2;return e||this._hover.containerDomNode.clientWidth<t?g_(this._hover.containerDomNode.ownerDocument.body).width-14:this._hover.containerDomNode.clientWidth+2}isMouseGettingCloser(e,t){if(!this._renderedHover)return!1;if(this._renderedHover.initialMousePosX===void 0||this._renderedHover.initialMousePosY===void 0)return this._renderedHover.initialMousePosX=e,this._renderedHover.initialMousePosY=t,!1;const i=mo(this.getDomNode());this._renderedHover.closestMouseDistance===void 0&&(this._renderedHover.closestMouseDistance=vI(this._renderedHover.initialMousePosX,this._renderedHover.initialMousePosY,i.left,i.top,i.width,i.height));const n=vI(e,t,i.left,i.top,i.width,i.height);return n>this._renderedHover.closestMouseDistance+4?!1:(this._renderedHover.closestMouseDistance=Math.min(this._renderedHover.closestMouseDistance,n),!0)}_setRenderedHover(e){var t;(t=this._renderedHover)==null||t.dispose(),this._renderedHover=e,this._hoverVisibleKey.set(!!e),this._hover.containerDomNode.classList.toggle("hidden",!e)}_updateFont(){const{fontSize:e,lineHeight:t}=this._editor.getOption(50),i=this._hover.contentsDomNode;i.style.fontSize=`${e}px`,i.style.lineHeight=`${t/e}`,Array.prototype.slice.call(this._hover.contentsDomNode.getElementsByClassName("code")).forEach(s=>this._editor.applyFontInfo(s))}_updateContent(e){const t=this._hover.contentsDomNode;t.style.paddingBottom="",t.textContent="",t.appendChild(e)}_layoutContentWidget(){this._editor.layoutContentWidget(this),this._hover.onContentsChanged()}_updateMaxDimensions(){const e=Math.max(this._editor.getLayoutInfo().height/4,250,wa._lastDimensions.height),t=Math.max(this._editor.getLayoutInfo().width*.66,500,wa._lastDimensions.width);this._setHoverWidgetMaxDimensions(t,e)}_render(e){this._setRenderedHover(e),this._updateFont(),this._updateContent(e.domNode),this._updateMaxDimensions(),this.onContentsChanged(),this._editor.render()}getPosition(){return this._renderedHover?{position:this._renderedHover.showAtPosition,secondaryPosition:this._renderedHover.showAtSecondaryPosition,positionAffinity:this._renderedHover.shouldAppearBeforeContent?3:void 0,preference:[this._positionPreference??1]}:null}show(e){var r;if(!this._editor||!this._editor.hasModel())return;this._render(e);const t=xh(this._hover.containerDomNode),i=e.showAtPosition;this._positionPreference=this._findPositionPreference(t,i)??1,this.onContentsChanged(),e.shouldFocus&&this._hover.containerDomNode.focus(),this._onDidResize.fire();const s=this._hover.containerDomNode.ownerDocument.activeElement===this._hover.containerDomNode&&h2(this._configurationService.getValue("accessibility.verbosity.hover")===!0&&this._accessibilityService.isScreenReaderOptimized(),((r=this._keybindingService.lookupKeybinding("editor.action.accessibleView"))==null?void 0:r.getAriaLabel())??"");s&&(this._hover.contentsDomNode.ariaLabel=this._hover.contentsDomNode.textContent+", "+s)}hide(){if(!this._renderedHover)return;const e=this._renderedHover.shouldFocus||this._hoverFocusedKey.get();this._setRenderedHover(void 0),this._resizableNode.maxSize=new On(1/0,1/0),this._resizableNode.clearSashHoverState(),this._hoverFocusedKey.set(!1),this._editor.layoutContentWidget(this),e&&this._editor.focus()}_removeConstraintsRenderNormally(){const e=this._editor.getLayoutInfo();this._resizableNode.layout(e.height,e.width),this._setHoverWidgetDimensions("auto","auto")}setMinimumDimensions(e){this._minimumSize=new On(Math.max(this._minimumSize.width,e.width),Math.max(this._minimumSize.height,e.height)),this._updateMinimumWidth()}_updateMinimumWidth(){const e=typeof this._contentWidth>"u"?this._minimumSize.width:Math.min(this._contentWidth,this._minimumSize.width);this._resizableNode.minSize=new On(e,this._minimumSize.height)}onContentsChanged(){var n;this._removeConstraintsRenderNormally();const e=this._hover.containerDomNode;let t=xh(e),i=wr(e);if(this._resizableNode.layout(t,i),this._setHoverWidgetDimensions(i,t),t=xh(e),i=wr(e),this._contentWidth=i,this._updateMinimumWidth(),this._resizableNode.layout(t,i),(n=this._renderedHover)!=null&&n.showAtPosition){const s=xh(this._hover.containerDomNode);this._positionPreference=this._findPositionPreference(s,this._renderedHover.showAtPosition)}this._layoutContentWidget()}focus(){this._hover.containerDomNode.focus()}scrollUp(){const e=this._hover.scrollbar.getScrollPosition().scrollTop,t=this._editor.getOption(50);this._hover.scrollbar.setScrollPosition({scrollTop:e-t.lineHeight})}scrollDown(){const e=this._hover.scrollbar.getScrollPosition().scrollTop,t=this._editor.getOption(50);this._hover.scrollbar.setScrollPosition({scrollTop:e+t.lineHeight})}scrollLeft(){const e=this._hover.scrollbar.getScrollPosition().scrollLeft;this._hover.scrollbar.setScrollPosition({scrollLeft:e-mI})}scrollRight(){const e=this._hover.scrollbar.getScrollPosition().scrollLeft;this._hover.scrollbar.setScrollPosition({scrollLeft:e+mI})}pageUp(){const e=this._hover.scrollbar.getScrollPosition().scrollTop,t=this._hover.scrollbar.getScrollDimensions().height;this._hover.scrollbar.setScrollPosition({scrollTop:e-t})}pageDown(){const e=this._hover.scrollbar.getScrollPosition().scrollTop,t=this._hover.scrollbar.getScrollDimensions().height;this._hover.scrollbar.setScrollPosition({scrollTop:e+t})}goToTop(){this._hover.scrollbar.setScrollPosition({scrollTop:0})}goToBottom(){this._hover.scrollbar.setScrollPosition({scrollTop:this._hover.scrollbar.getScrollDimensions().scrollHeight})}},wa=bc,bc.ID="editor.contrib.resizableContentHoverWidget",bc._lastDimensions=new On(0,0),bc);SC=wa=IB([tm(1,Sn),tm(2,Un),tm(3,ky),tm(4,hs)],SC);function vI(o,e,t,i,n,s){const r=t+n/2,a=i+s/2,d=Math.max(Math.abs(o-r)-n/2,0),u=Math.max(Math.abs(e-a)-s/2,0);return Math.sqrt(d*d+u*u)}class xv{get anchor(){return this._anchor}set anchor(e){this._anchor=e}get shouldFocus(){return this._shouldFocus}set shouldFocus(e){this._shouldFocus=e}get source(){return this._source}set source(e){this._source=e}get insistOnKeepingHoverVisible(){return this._insistOnKeepingHoverVisible}set insistOnKeepingHoverVisible(e){this._insistOnKeepingHoverVisible=e}constructor(e,t){this._editor=e,this._participants=t,this._anchor=null,this._shouldFocus=!1,this._source=0,this._insistOnKeepingHoverVisible=!1}static _getLineDecorations(e,t){if(t.type!==1&&!t.supportsMarkerHover)return[];const i=e.getModel(),n=t.range.startLineNumber;if(n>i.getLineCount())return[];const s=i.getLineMaxColumn(n);return e.getLineDecorations(n).filter(r=>{if(r.options.isWholeLine)return!0;const a=r.range.startLineNumber===n?r.range.startColumn:1,d=r.range.endLineNumber===n?r.range.endColumn:s;if(r.options.showIfCollapsed){if(a>t.range.startColumn+1||t.range.endColumn-1>d)return!1}else if(a>t.range.startColumn||t.range.endColumn>d)return!1;return!0})}computeAsync(e){const t=this._anchor;if(!this._editor.hasModel()||!t)return oa.EMPTY;const i=xv._getLineDecorations(this._editor,t);return oa.merge(this._participants.map(n=>n.computeAsync?n.computeAsync(t,i,e):oa.EMPTY))}computeSync(){if(!this._editor.hasModel()||!this._anchor)return[];const e=xv._getLineDecorations(this._editor,this._anchor);let t=[];for(const i of this._participants)t=t.concat(i.computeSync(this._anchor,e));return wl(t)}}class dR{constructor(e,t,i){this.anchor=e,this.hoverParts=t,this.isComplete=i}filter(e){const t=this.hoverParts.filter(i=>i.isValidForHoverAnchor(e));return t.length===this.hoverParts.length?this:new DB(this,this.anchor,t,this.isComplete)}}class DB extends dR{constructor(e,t,i,n){super(t,i,n),this.original=e}filter(e){return this.original.filter(e)}}var TB=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},PB=function(o,e){return function(t,i){e(t,i,o)}};const bI=si;let kv=class extends Dt{get hasContent(){return this._hasContent}constructor(e){super(),this._keybindingService=e,this.actions=[],this._hasContent=!1,this.hoverElement=bI("div.hover-row.status-bar"),this.hoverElement.tabIndex=0,this.actionsElement=ei(this.hoverElement,bI("div.actions"))}addAction(e){const t=this._keybindingService.lookupKeybinding(e.commandId),i=t?t.getLabel():null;this._hasContent=!0;const n=this._register(f2.render(this.actionsElement,e,i));return this.actions.push(n),n}append(e){const t=ei(this.actionsElement,e);return this._hasContent=!0,t}};kv=TB([PB(0,hs)],kv);class MB{constructor(e,t,i){this.provider=e,this.hover=t,this.ordinal=i}}async function RB(o,e,t,i,n){const s=await Promise.resolve(o.provideHover(t,i,n)).catch(rs);if(!(!s||!NB(s)))return new MB(o,s,e)}function Z0(o,e,t,i,n=!1){const r=o.ordered(e,n).map((a,d)=>RB(a,d,e,t,i));return oa.fromPromises(r).coalesce()}function uR(o,e,t,i,n=!1){return Z0(o,e,t,i,n).map(s=>s.hover).toPromise()}So("_executeHoverProvider",(o,e,t)=>{const i=o.get(pi);return uR(i.hoverProvider,e,t,Qi.None)});So("_executeHoverProvider_recursive",(o,e,t)=>{const i=o.get(pi);return uR(i.hoverProvider,e,t,Qi.None,!0)});function NB(o){const e=typeof o.range<"u",t=typeof o.contents<"u"&&o.contents&&o.contents.length>0;return e&&t}var AB=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Xc=function(o,e){return function(t,i){e(t,i,o)}};const Dh=si,OB=is("hover-increase-verbosity",ji.add,C("increaseHoverVerbosity","Icon for increaseing hover verbosity.")),FB=is("hover-decrease-verbosity",ji.remove,C("decreaseHoverVerbosity","Icon for decreasing hover verbosity."));class Tr{constructor(e,t,i,n,s,r=void 0){this.owner=e,this.range=t,this.contents=i,this.isBeforeContent=n,this.ordinal=s,this.source=r}isValidForHoverAnchor(e){return e.type===1&&this.range.startColumn<=e.range.startColumn&&this.range.endColumn>=e.range.endColumn}}class hR{constructor(e,t,i){this.hover=e,this.hoverProvider=t,this.hoverPosition=i}supportsVerbosityAction(e){switch(e){case ar.Increase:return this.hover.canIncreaseVerbosity??!1;case ar.Decrease:return this.hover.canDecreaseVerbosity??!1}}}let Pp=class{constructor(e,t,i,n,s,r,a,d){this._editor=e,this._languageService=t,this._openerService=i,this._configurationService=n,this._languageFeaturesService=s,this._keybindingService=r,this._hoverService=a,this._commandService=d,this.hoverOrdinal=3}createLoadingMessage(e){return new Tr(this,e.range,[new to().appendText(C("modesContentHover.loading","Loading..."))],!1,2e3)}computeSync(e,t){if(!this._editor.hasModel()||e.type!==1)return[];const i=this._editor.getModel(),n=e.range.startLineNumber,s=i.getLineMaxColumn(n),r=[];let a=1e3;const d=i.getLineLength(n),u=i.getLanguageIdAtPosition(e.range.startLineNumber,e.range.startColumn),f=this._editor.getOption(118),g=this._configurationService.getValue("editor.maxTokenizationLineLength",{overrideIdentifier:u});let p=!1;f>=0&&d>f&&e.range.startColumn>=f&&(p=!0,r.push(new Tr(this,e.range,[{value:C("stopped rendering","Rendering paused for long line for performance reasons. This can be configured via `editor.stopRenderingLineAfter`.")}],!1,a++))),!p&&typeof g=="number"&&d>=g&&r.push(new Tr(this,e.range,[{value:C("too many characters","Tokenization is skipped for long lines for performance reasons. This can be configured via `editor.maxTokenizationLineLength`.")}],!1,a++));let w=!1;for(const y of t){const x=y.range.startLineNumber===n?y.range.startColumn:1,k=y.range.endLineNumber===n?y.range.endColumn:s,D=y.options.hoverMessage;if(!D||pp(D))continue;y.options.beforeContentClassName&&(w=!0);const M=new Z(e.range.startLineNumber,x,e.range.startLineNumber,k);r.push(new Tr(this,M,YD(D),w,a++))}return r}computeAsync(e,t,i){if(!this._editor.hasModel()||e.type!==1)return oa.EMPTY;const n=this._editor.getModel(),s=this._languageFeaturesService.hoverProvider;return s.has(n)?this._getMarkdownHovers(s,n,e,i):oa.EMPTY}_getMarkdownHovers(e,t,i,n){const s=i.range.getStartPosition();return Z0(e,t,s,n).filter(d=>!pp(d.hover.contents)).map(d=>{const u=d.hover.range?Z.lift(d.hover.range):i.range,f=new hR(d.hover,d.provider,s);return new Tr(this,u,d.hover.contents,!1,d.ordinal,f)})}renderHoverParts(e,t){return this._renderedHoverParts=new HB(t,e.fragment,this,this._editor,this._languageService,this._openerService,this._commandService,this._keybindingService,this._hoverService,this._configurationService,e.onContentsChanged),this._renderedHoverParts}updateMarkdownHoverVerbosityLevel(e,t,i){var n;return Promise.resolve((n=this._renderedHoverParts)==null?void 0:n.updateMarkdownHoverPartVerbosityLevel(e,t,i))}};Pp=AB([Xc(1,fa),Xc(2,ua),Xc(3,Un),Xc(4,pi),Xc(5,hs),Xc(6,p_),Xc(7,Es)],Pp);class im{constructor(e,t,i){this.hoverPart=e,this.hoverElement=t,this.disposables=i}dispose(){this.disposables.dispose()}}class HB{constructor(e,t,i,n,s,r,a,d,u,f,g){this._hoverParticipant=i,this._editor=n,this._languageService=s,this._openerService=r,this._commandService=a,this._keybindingService=d,this._hoverService=u,this._configurationService=f,this._onFinishedRendering=g,this._ongoingHoverOperations=new Map,this._disposables=new Lt,this.renderedHoverParts=this._renderHoverParts(e,t,this._onFinishedRendering),this._disposables.add(jn(()=>{this.renderedHoverParts.forEach(p=>{p.dispose()}),this._ongoingHoverOperations.forEach(p=>{p.tokenSource.dispose(!0)})}))}_renderHoverParts(e,t,i){return e.sort(__(n=>n.ordinal,Ly)),e.map(n=>{const s=this._renderHoverPart(n,i);return t.appendChild(s.hoverElement),s})}_renderHoverPart(e,t){const i=this._renderMarkdownHover(e,t),n=i.hoverElement,s=e.source,r=new Lt;if(r.add(i),!s)return new im(e,n,r);const a=s.supportsVerbosityAction(ar.Increase),d=s.supportsVerbosityAction(ar.Decrease);if(!a&&!d)return new im(e,n,r);const u=Dh("div.verbosity-actions");return n.prepend(u),r.add(this._renderHoverExpansionAction(u,ar.Increase,a)),r.add(this._renderHoverExpansionAction(u,ar.Decrease,d)),new im(e,n,r)}_renderMarkdownHover(e,t){return fR(this._editor,e,this._languageService,this._openerService,t)}_renderHoverExpansionAction(e,t,i){const n=new Lt,s=t===ar.Increase,r=ei(e,Dh(xn.asCSSSelector(s?OB:FB)));r.tabIndex=0;const a=new g2("mouse",!1,{target:e,position:{hoverPosition:0}},this._configurationService,this._hoverService);if(n.add(this._hoverService.setupManagedHover(a,r,BB(this._keybindingService,t))),!i)return r.classList.add("disabled"),n;r.classList.add("enabled");const d=()=>this._commandService.executeCommand(t===ar.Increase?Gy:Ky);return n.add(new p2(r,d)),n.add(new _2(r,d,[3,10])),n}async updateMarkdownHoverPartVerbosityLevel(e,t,i=!0){const n=this._editor.getModel();if(!n)return;const s=this._getRenderedHoverPartAtIndex(t),r=s==null?void 0:s.hoverPart.source;if(!s||!(r!=null&&r.supportsVerbosityAction(e)))return;const a=await this._fetchHover(r,n,e);if(!a)return;const d=new hR(a,r.hoverProvider,r.hoverPosition),u=s.hoverPart,f=new Tr(this._hoverParticipant,u.range,a.contents,u.isBeforeContent,u.ordinal,d),g=this._renderHoverPart(f,this._onFinishedRendering);return this._replaceRenderedHoverPartAtIndex(t,g,f),i&&this._focusOnHoverPartWithIndex(t),{hoverPart:f,hoverElement:g.hoverElement}}async _fetchHover(e,t,i){let n=i===ar.Increase?1:-1;const s=e.hoverProvider,r=this._ongoingHoverOperations.get(s);r&&(r.tokenSource.cancel(),n+=r.verbosityDelta);const a=new Fs;this._ongoingHoverOperations.set(s,{verbosityDelta:n,tokenSource:a});const d={verbosityRequest:{verbosityDelta:n,previousHover:e.hover}};let u;try{u=await Promise.resolve(s.provideHover(t,e.hoverPosition,a.token,d))}catch(f){rs(f)}return a.dispose(),this._ongoingHoverOperations.delete(s),u}_replaceRenderedHoverPartAtIndex(e,t,i){if(e>=this.renderedHoverParts.length||e<0)return;const n=this.renderedHoverParts[e],s=n.hoverElement,r=t.hoverElement,a=Array.from(r.children);s.replaceChildren(...a);const d=new im(i,s,t.disposables);s.focus(),n.dispose(),this.renderedHoverParts[e]=d}_focusOnHoverPartWithIndex(e){this.renderedHoverParts[e].hoverElement.focus()}_getRenderedHoverPartAtIndex(e){return this.renderedHoverParts[e]}dispose(){this._disposables.dispose()}}function WB(o,e,t,i,n){e.sort(__(r=>r.ordinal,Ly));const s=[];for(const r of e)s.push(fR(t,r,i,n,o.onContentsChanged));return new Du(s)}function fR(o,e,t,i,n){const s=new Lt,r=Dh("div.hover-row"),a=Dh("div.hover-row-contents");r.appendChild(a);const d=e.contents;for(const f of d){if(pp(f))continue;const g=Dh("div.markdown-hover"),p=ei(g,Dh("div.hover-contents")),w=s.add(new Uf({editor:o},t,i));s.add(w.onDidRenderAsync(()=>{p.className="hover-contents code-hover-contents",n()}));const y=s.add(w.render(f));p.appendChild(y.element),a.appendChild(g)}return{hoverPart:e,hoverElement:r,dispose(){s.dispose()}}}function BB(o,e){switch(e){case ar.Increase:{const t=o.lookupKeybinding(Gy);return t?C("increaseVerbosityWithKb","Increase Hover Verbosity ({0})",t.getLabel()):C("increaseVerbosity","Increase Hover Verbosity")}case ar.Decrease:{const t=o.lookupKeybinding(Ky);return t?C("decreaseVerbosityWithKb","Decrease Hover Verbosity ({0})",t.getLabel()):C("decreaseVerbosity","Decrease Hover Verbosity")}}}function CC(o,e){return!!o[e]}class jw{constructor(e,t){this.target=e.target,this.isLeftClick=e.event.leftButton,this.isMiddleClick=e.event.middleButton,this.isRightClick=e.event.rightButton,this.hasTriggerModifier=CC(e.event,t.triggerModifier),this.hasSideBySideModifier=CC(e.event,t.triggerSideBySideModifier),this.isNoneOrSingleMouseDown=e.event.detail<=1}}class yI{constructor(e,t){this.keyCodeIsTriggerKey=e.keyCode===t.triggerKey,this.keyCodeIsSideBySideKey=e.keyCode===t.triggerSideBySideKey,this.hasTriggerModifier=CC(e,t.triggerModifier)}}class nm{constructor(e,t,i,n){this.triggerKey=e,this.triggerModifier=t,this.triggerSideBySideKey=i,this.triggerSideBySideModifier=n}equals(e){return this.triggerKey===e.triggerKey&&this.triggerModifier===e.triggerModifier&&this.triggerSideBySideKey===e.triggerSideBySideKey&&this.triggerSideBySideModifier===e.triggerSideBySideModifier}}function wI(o){return o==="altKey"?ja?new nm(57,"metaKey",6,"altKey"):new nm(5,"ctrlKey",6,"altKey"):ja?new nm(6,"altKey",57,"metaKey"):new nm(6,"altKey",5,"ctrlKey")}class Yy extends Dt{constructor(e,t){super(),this._onMouseMoveOrRelevantKeyDown=this._register(new Xi),this.onMouseMoveOrRelevantKeyDown=this._onMouseMoveOrRelevantKeyDown.event,this._onExecute=this._register(new Xi),this.onExecute=this._onExecute.event,this._onCancel=this._register(new Xi),this.onCancel=this._onCancel.event,this._editor=e,this._extractLineNumberFromMouseEvent=(t==null?void 0:t.extractLineNumberFromMouseEvent)??(i=>i.target.position?i.target.position.lineNumber:0),this._opts=wI(this._editor.getOption(78)),this._lastMouseMoveEvent=null,this._hasTriggerKeyOnMouseDown=!1,this._lineNumberOnMouseDown=0,this._register(this._editor.onDidChangeConfiguration(i=>{if(i.hasChanged(78)){const n=wI(this._editor.getOption(78));if(this._opts.equals(n))return;this._opts=n,this._lastMouseMoveEvent=null,this._hasTriggerKeyOnMouseDown=!1,this._lineNumberOnMouseDown=0,this._onCancel.fire()}})),this._register(this._editor.onMouseMove(i=>this._onEditorMouseMove(new jw(i,this._opts)))),this._register(this._editor.onMouseDown(i=>this._onEditorMouseDown(new jw(i,this._opts)))),this._register(this._editor.onMouseUp(i=>this._onEditorMouseUp(new jw(i,this._opts)))),this._register(this._editor.onKeyDown(i=>this._onEditorKeyDown(new yI(i,this._opts)))),this._register(this._editor.onKeyUp(i=>this._onEditorKeyUp(new yI(i,this._opts)))),this._register(this._editor.onMouseDrag(()=>this._resetHandler())),this._register(this._editor.onDidChangeCursorSelection(i=>this._onDidChangeCursorSelection(i))),this._register(this._editor.onDidChangeModel(i=>this._resetHandler())),this._register(this._editor.onDidChangeModelContent(()=>this._resetHandler())),this._register(this._editor.onDidScrollChange(i=>{(i.scrollTopChanged||i.scrollLeftChanged)&&this._resetHandler()}))}_onDidChangeCursorSelection(e){e.selection&&e.selection.startColumn!==e.selection.endColumn&&this._resetHandler()}_onEditorMouseMove(e){this._lastMouseMoveEvent=e,this._onMouseMoveOrRelevantKeyDown.fire([e,null])}_onEditorMouseDown(e){this._hasTriggerKeyOnMouseDown=e.hasTriggerModifier,this._lineNumberOnMouseDown=this._extractLineNumberFromMouseEvent(e)}_onEditorMouseUp(e){const t=this._extractLineNumberFromMouseEvent(e);this._hasTriggerKeyOnMouseDown&&this._lineNumberOnMouseDown&&this._lineNumberOnMouseDown===t&&this._onExecute.fire(e)}_onEditorKeyDown(e){this._lastMouseMoveEvent&&(e.keyCodeIsTriggerKey||e.keyCodeIsSideBySideKey&&e.hasTriggerModifier)?this._onMouseMoveOrRelevantKeyDown.fire([this._lastMouseMoveEvent,e]):e.hasTriggerModifier&&this._onCancel.fire()}_onEditorKeyUp(e){e.keyCodeIsTriggerKey&&this._onCancel.fire()}_resetHandler(){this._lastMouseMoveEvent=null,this._hasTriggerKeyOnMouseDown=!1,this._onCancel.fire()}}class gR{constructor(e,t){this.range=e,this.direction=t}}class Y0{constructor(e,t,i){this.hint=e,this.anchor=t,this.provider=i,this._isResolved=!1}with(e){const t=new Y0(this.hint,e.anchor,this.provider);return t._isResolved=this._isResolved,t._currentResolve=this._currentResolve,t}async resolve(e){if(typeof this.provider.resolveInlayHint=="function"){if(this._currentResolve)return await this._currentResolve,e.isCancellationRequested?void 0:this.resolve(e);this._isResolved||(this._currentResolve=this._doResolve(e).finally(()=>this._currentResolve=void 0)),await this._currentResolve}}async _doResolve(e){try{const t=await Promise.resolve(this.provider.resolveInlayHint(this.hint,e));this.hint.tooltip=(t==null?void 0:t.tooltip)??this.hint.tooltip,this.hint.label=(t==null?void 0:t.label)??this.hint.label,this.hint.textEdits=(t==null?void 0:t.textEdits)??this.hint.textEdits,this._isResolved=!0}catch(t){rs(t),this._isResolved=!1}}}const Oh=class Oh{static async create(e,t,i,n){const s=[],r=e.ordered(t).reverse().map(a=>i.map(async d=>{try{const u=await a.provideInlayHints(t,d,n);(u!=null&&u.hints.length||a.onDidChangeInlayHints)&&s.push([u??Oh._emptyInlayHintList,a])}catch(u){rs(u)}}));if(await Promise.all(r.flat()),n.isCancellationRequested||t.isDisposed())throw new yy;return new Oh(i,s,t)}constructor(e,t,i){this._disposables=new Lt,this.ranges=e,this.provider=new Set;const n=[];for(const[s,r]of t){this._disposables.add(s),this.provider.add(r);for(const a of s.hints){const d=i.validatePosition(a.position);let u="before";const f=Oh._getRangeAtPosition(i,d);let g;f.getStartPosition().isBefore(d)?(g=Z.fromPositions(f.getStartPosition(),d),u="after"):(g=Z.fromPositions(d,f.getEndPosition()),u="before"),n.push(new Y0(a,new gR(g,u),r))}}this.items=n.sort((s,r)=>gi.compare(s.hint.position,r.hint.position))}dispose(){this._disposables.dispose()}static _getRangeAtPosition(e,t){const i=t.lineNumber,n=e.getWordAtPosition(t);if(n)return new Z(i,n.startColumn,i,n.endColumn);e.tokenization.tokenizeIfCheap(i);const s=e.tokenization.getLineTokens(i),r=t.column-1,a=s.findTokenIndexAtOffset(r);let d=s.getStartOffset(a),u=s.getEndOffset(a);return u-d===1&&(d===r&&a>1?(d=s.getStartOffset(a-1),u=s.getEndOffset(a-1)):u===r&&a<s.getCount()-1&&(d=s.getStartOffset(a+1),u=s.getEndOffset(a+1))),new Z(i,d+1,i,u+1)}};Oh._emptyInlayHintList=Object.freeze({dispose(){},hints:[]});let Lv=Oh;function zB(o){return Pn.from({scheme:go.command,path:o.id,query:o.arguments&&encodeURIComponent(JSON.stringify(o.arguments))}).toString()}var VB=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ja=function(o,e){return function(t,i){e(t,i,o)}};let Fr=class extends m2{constructor(e,t,i,n,s,r,a,d,u,f,g,p,w){super(e,{...n.getRawOptions(),overflowWidgetsDomNode:n.getOverflowWidgetsDomNode()},i,s,r,a,d,u,f,g,p,w),this._parentEditor=n,this._overwriteOptions=t,super.updateOptions(this._overwriteOptions),this._register(n.onDidChangeConfiguration(y=>this._onParentConfigurationChanged(y)))}getParentEditor(){return this._parentEditor}_onParentConfigurationChanged(e){super.updateOptions(this._parentEditor.getRawOptions()),super.updateOptions(this._overwriteOptions)}updateOptions(e){a0(this._overwriteOptions,e,!0),super.updateOptions(this._overwriteOptions)}};Fr=VB([Ja(4,Zi),Ja(5,as),Ja(6,Es),Ja(7,Sn),Ja(8,Hr),Ja(9,co),Ja(10,ky),Ja(11,Ds),Ja(12,pi)],Fr);const SI=new cn(new _f(0,122,204)),jB={showArrow:!0,showFrame:!0,className:"",frameColor:SI,arrowColor:SI,keepEditorSelection:!1},$B="vs.editor.contrib.zoneWidget";class UB{constructor(e,t,i,n,s,r,a,d){this.id="",this.domNode=e,this.afterLineNumber=t,this.afterColumn=i,this.heightInLines=n,this.showInHiddenAreas=a,this.ordinal=d,this._onDomNodeTop=s,this._onComputedHeight=r}onDomNodeTop(e){this._onDomNodeTop(e)}onComputedHeight(e){this._onComputedHeight(e)}}class qB{constructor(e,t){this._id=e,this._domNode=t}getId(){return this._id}getDomNode(){return this._domNode}getPosition(){return null}}const Mb=class Mb{constructor(e){this._editor=e,this._ruleName=Mb._IdGenerator.nextId(),this._decorations=this._editor.createDecorationsCollection(),this._color=null,this._height=-1}dispose(){this.hide(),hL(this._ruleName)}set color(e){this._color!==e&&(this._color=e,this._updateStyle())}set height(e){this._height!==e&&(this._height=e,this._updateStyle())}_updateStyle(){hL(this._ruleName),y2(`.monaco-editor ${this._ruleName}`,`border-style: solid; border-color: transparent; border-bottom-color: ${this._color}; border-width: ${this._height}px; bottom: -${this._height}px !important; margin-left: -${this._height}px; `)}show(e){e.column===1&&(e={lineNumber:e.lineNumber,column:2}),this._decorations.set([{range:Z.fromPositions(e),options:{description:"zone-widget-arrow",className:this._ruleName,stickiness:1}}])}hide(){this._decorations.clear()}};Mb._IdGenerator=new b2(".arrow-decoration-");let xC=Mb;class GB{constructor(e,t={}){this._arrow=null,this._overlayWidget=null,this._resizeSash=null,this._viewZone=null,this._disposables=new Lt,this.container=null,this._isShowing=!1,this.editor=e,this._positionMarkerId=this.editor.createDecorationsCollection(),this.options=v2(t),a0(this.options,jB,!1),this.domNode=document.createElement("div"),this.options.isAccessible||(this.domNode.setAttribute("aria-hidden","true"),this.domNode.setAttribute("role","presentation")),this._disposables.add(this.editor.onDidLayoutChange(i=>{const n=this._getWidth(i);this.domNode.style.width=n+"px",this.domNode.style.left=this._getLeft(i)+"px",this._onWidth(n)}))}dispose(){this._overlayWidget&&(this.editor.removeOverlayWidget(this._overlayWidget),this._overlayWidget=null),this._viewZone&&this.editor.changeViewZones(e=>{this._viewZone&&e.removeZone(this._viewZone.id),this._viewZone=null}),this._positionMarkerId.clear(),this._disposables.dispose()}create(){this.domNode.classList.add("zone-widget"),this.options.className&&this.domNode.classList.add(this.options.className),this.container=document.createElement("div"),this.container.classList.add("zone-widget-container"),this.domNode.appendChild(this.container),this.options.showArrow&&(this._arrow=new xC(this.editor),this._disposables.add(this._arrow)),this._fillContainer(this.container),this._initSash(),this._applyStyles()}style(e){e.frameColor&&(this.options.frameColor=e.frameColor),e.arrowColor&&(this.options.arrowColor=e.arrowColor),this._applyStyles()}_applyStyles(){if(this.container&&this.options.frameColor){const e=this.options.frameColor.toString();this.container.style.borderTopColor=e,this.container.style.borderBottomColor=e}if(this._arrow&&this.options.arrowColor){const e=this.options.arrowColor.toString();this._arrow.color=e}}_getWidth(e){return e.width-e.minimap.minimapWidth-e.verticalScrollbarWidth}_getLeft(e){return e.minimap.minimapWidth>0&&e.minimap.minimapLeft===0?e.minimap.minimapWidth:0}_onViewZoneTop(e){this.domNode.style.top=e+"px"}_onViewZoneHeight(e){var t;if(this.domNode.style.height=`${e}px`,this.container){const i=e-this._decoratingElementsHeight();this.container.style.height=`${i}px`;const n=this.editor.getLayoutInfo();this._doLayout(i,this._getWidth(n))}(t=this._resizeSash)==null||t.layout()}get position(){const e=this._positionMarkerId.getRange(0);if(e)return e.getStartPosition()}show(e,t){const i=Z.isIRange(e)?Z.lift(e):Z.fromPositions(e);this._isShowing=!0,this._showImpl(i,t),this._isShowing=!1,this._positionMarkerId.set([{range:i,options:dn.EMPTY}])}hide(){var e;this._viewZone&&(this.editor.changeViewZones(t=>{this._viewZone&&t.removeZone(this._viewZone.id)}),this._viewZone=null),this._overlayWidget&&(this.editor.removeOverlayWidget(this._overlayWidget),this._overlayWidget=null),(e=this._arrow)==null||e.hide(),this._positionMarkerId.clear()}_decoratingElementsHeight(){const e=this.editor.getOption(67);let t=0;if(this.options.showArrow){const i=Math.round(e/3);t+=2*i}if(this.options.showFrame){const i=Math.round(e/9);t+=2*i}return t}_showImpl(e,t){const i=e.getStartPosition(),n=this.editor.getLayoutInfo(),s=this._getWidth(n);this.domNode.style.width=`${s}px`,this.domNode.style.left=this._getLeft(n)+"px";const r=document.createElement("div");r.style.overflow="hidden";const a=this.editor.getOption(67);if(!this.options.allowUnlimitedHeight){const p=Math.max(12,this.editor.getLayoutInfo().height/a*.8);t=Math.min(t,p)}let d=0,u=0;if(this._arrow&&this.options.showArrow&&(d=Math.round(a/3),this._arrow.height=d,this._arrow.show(i)),this.options.showFrame&&(u=Math.round(a/9)),this.editor.changeViewZones(p=>{this._viewZone&&p.removeZone(this._viewZone.id),this._overlayWidget&&(this.editor.removeOverlayWidget(this._overlayWidget),this._overlayWidget=null),this.domNode.style.top="-1000px",this._viewZone=new UB(r,i.lineNumber,i.column,t,w=>this._onViewZoneTop(w),w=>this._onViewZoneHeight(w),this.options.showInHiddenAreas,this.options.ordinal),this._viewZone.id=p.addZone(this._viewZone),this._overlayWidget=new qB($B+this._viewZone.id,this.domNode),this.editor.addOverlayWidget(this._overlayWidget)}),this.container&&this.options.showFrame){const p=this.options.frameWidth?this.options.frameWidth:u;this.container.style.borderTopWidth=p+"px",this.container.style.borderBottomWidth=p+"px"}const f=t*a-this._decoratingElementsHeight();this.container&&(this.container.style.top=d+"px",this.container.style.height=f+"px",this.container.style.overflow="hidden"),this._doLayout(f,s),this.options.keepEditorSelection||this.editor.setSelection(e);const g=this.editor.getModel();if(g){const p=g.validateRange(new Z(e.startLineNumber,1,e.endLineNumber+1,1));this.revealRange(p,p.startLineNumber===g.getLineCount())}}revealRange(e,t){t?this.editor.revealLineNearTop(e.endLineNumber,0):this.editor.revealRange(e,0)}setCssClass(e,t){this.container&&(t&&this.container.classList.remove(t),this.container.classList.add(e))}_onWidth(e){}_doLayout(e,t){}_relayout(e){this._viewZone&&this._viewZone.heightInLines!==e&&this.editor.changeViewZones(t=>{this._viewZone&&(this._viewZone.heightInLines=e,t.layoutZone(this._viewZone.id))})}_initSash(){if(this._resizeSash)return;this._resizeSash=this._disposables.add(new Ch(this.domNode,this,{orientation:1})),this.options.isResizeable||(this._resizeSash.state=0);let e;this._disposables.add(this._resizeSash.onDidStart(t=>{this._viewZone&&(e={startY:t.startY,heightInLines:this._viewZone.heightInLines})})),this._disposables.add(this._resizeSash.onDidEnd(()=>{e=void 0})),this._disposables.add(this._resizeSash.onDidChange(t=>{if(e){const i=(t.currentY-e.startY)/this.editor.getOption(67),n=i<0?Math.ceil(i):Math.floor(i),s=e.heightInLines+n;s>5&&s<35&&this._relayout(s)}}))}getHorizontalSashLeft(){return 0}getHorizontalSashTop(){return(this.domNode.style.height===null?0:parseInt(this.domNode.style.height))-this._decoratingElementsHeight()/2}getHorizontalSashWidth(){const e=this.editor.getLayoutInfo();return e.width-e.minimap.minimapWidth}}var pR=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},_R=function(o,e){return function(t,i){e(t,i,o)}};const mR=Rl("IPeekViewService");Nl(mR,class{constructor(){this._widgets=new Map}addExclusiveWidget(o,e){const t=this._widgets.get(o);t&&(t.listener.dispose(),t.widget.dispose());const i=()=>{const n=this._widgets.get(o);n&&n.widget===e&&(n.listener.dispose(),this._widgets.delete(o))};this._widgets.set(o,{widget:e,listener:e.onDidClose(i)})}},1);var vo;(function(o){o.inPeekEditor=new _n("inReferenceSearchEditor",!0,C("inReferenceSearchEditor","Whether the current code editor is embedded inside peek")),o.notInPeekEditor=o.inPeekEditor.toNegated()})(vo||(vo={}));var tf;let Iv=(tf=class{constructor(e,t){e instanceof Fr&&vo.inPeekEditor.bindTo(t)}dispose(){}},tf.ID="editor.contrib.referenceController",tf);Iv=pR([_R(1,Sn)],Iv);nn(Iv.ID,Iv,0);function KB(o){const e=o.get(as).getFocusedCodeEditor();return e instanceof Fr?e.getParentEditor():e}const ZB={headerBackgroundColor:cn.white,primaryHeadingColor:cn.fromHex("#333333"),secondaryHeadingColor:cn.fromHex("#6c6c6cb3")};let Ev=class extends GB{constructor(e,t,i){super(e,t),this.instantiationService=i,this._onDidClose=new Xi,this.onDidClose=this._onDidClose.event,a0(this.options,ZB,!1)}dispose(){this.disposed||(this.disposed=!0,super.dispose(),this._onDidClose.fire(this))}style(e){const t=this.options;e.headerBackgroundColor&&(t.headerBackgroundColor=e.headerBackgroundColor),e.primaryHeadingColor&&(t.primaryHeadingColor=e.primaryHeadingColor),e.secondaryHeadingColor&&(t.secondaryHeadingColor=e.secondaryHeadingColor),super.style(e)}_applyStyles(){super._applyStyles();const e=this.options;this._headElement&&e.headerBackgroundColor&&(this._headElement.style.backgroundColor=e.headerBackgroundColor.toString()),this._primaryHeading&&e.primaryHeadingColor&&(this._primaryHeading.style.color=e.primaryHeadingColor.toString()),this._secondaryHeading&&e.secondaryHeadingColor&&(this._secondaryHeading.style.color=e.secondaryHeadingColor.toString()),this._bodyElement&&e.frameColor&&(this._bodyElement.style.borderColor=e.frameColor.toString())}_fillContainer(e){this.setCssClass("peekview-widget"),this._headElement=si(".head"),this._bodyElement=si(".body"),this._fillHead(this._headElement),this._fillBody(this._bodyElement),e.appendChild(this._headElement),e.appendChild(this._bodyElement)}_fillHead(e,t){this._titleElement=si(".peekview-title"),this.options.supportOnTitleClick&&(this._titleElement.classList.add("clickable"),Cl(this._titleElement,"click",s=>this._onTitleClick(s))),ei(this._headElement,this._titleElement),this._fillTitleIcon(this._titleElement),this._primaryHeading=si("span.filename"),this._secondaryHeading=si("span.dirname"),this._metaHeading=si("span.meta"),ei(this._titleElement,this._primaryHeading,this._secondaryHeading,this._metaHeading);const i=si(".peekview-actions");ei(this._headElement,i);const n=this._getActionBarOptions();this._actionbarWidget=new up(i,n),this._disposables.add(this._actionbarWidget),t||this._actionbarWidget.push(new mf("peekview.close",C("label.close","Close"),xn.asClassName(ji.close),!0,()=>(this.dispose(),Promise.resolve())),{label:!1,icon:!0})}_fillTitleIcon(e){}_getActionBarOptions(){return{actionViewItemProvider:w2.bind(void 0,this.instantiationService),orientation:0}}_onTitleClick(e){}setTitle(e,t){this._primaryHeading&&this._secondaryHeading&&(this._primaryHeading.innerText=e,this._primaryHeading.setAttribute("title",e),t?this._secondaryHeading.innerText=t:Wa(this._secondaryHeading))}setMetaTitle(e){this._metaHeading&&(e?(this._metaHeading.innerText=e,Dr(this._metaHeading)):Bo(this._metaHeading))}_doLayout(e,t){if(!this._isShowing&&e<0){this.dispose();return}const i=Math.ceil(this.editor.getOption(67)*1.2),n=Math.round(e-(i+2));this._doLayoutHead(i,t),this._doLayoutBody(n,t)}_doLayoutHead(e,t){this._headElement&&(this._headElement.style.height=`${e}px`,this._headElement.style.lineHeight=this._headElement.style.height)}_doLayoutBody(e,t){this._bodyElement&&(this._bodyElement.style.height=`${e}px`)}};Ev=pR([_R(2,Zi)],Ev);const YB=oi("peekViewTitle.background",{dark:"#252526",light:"#F3F3F3",hcDark:cn.black,hcLight:cn.white},C("peekViewTitleBackground","Background color of the peek view title area.")),vR=oi("peekViewTitleLabel.foreground",{dark:cn.white,light:cn.black,hcDark:cn.white,hcLight:m_},C("peekViewTitleForeground","Color of the peek view title.")),bR=oi("peekViewTitleDescription.foreground",{dark:"#ccccccb3",light:"#616161",hcDark:"#FFFFFF99",hcLight:"#292929"},C("peekViewTitleInfoForeground","Color of the peek view title info.")),XB=oi("peekView.border",{dark:xS,light:xS,hcDark:Sl,hcLight:Sl},C("peekViewBorder","Color of the peek view borders and arrow.")),QB=oi("peekViewResult.background",{dark:"#252526",light:"#F3F3F3",hcDark:cn.black,hcLight:cn.white},C("peekViewResultsBackground","Background color of the peek view result list."));oi("peekViewResult.lineForeground",{dark:"#bbbbbb",light:"#646465",hcDark:cn.white,hcLight:m_},C("peekViewResultsMatchForeground","Foreground color for line nodes in the peek view result list."));oi("peekViewResult.fileForeground",{dark:cn.white,light:"#1E1E1E",hcDark:cn.white,hcLight:m_},C("peekViewResultsFileForeground","Foreground color for file nodes in the peek view result list."));oi("peekViewResult.selectionBackground",{dark:"#3399ff33",light:"#3399ff33",hcDark:null,hcLight:null},C("peekViewResultsSelectionBackground","Background color of the selected entry in the peek view result list."));oi("peekViewResult.selectionForeground",{dark:cn.white,light:"#6C6C6C",hcDark:cn.white,hcLight:m_},C("peekViewResultsSelectionForeground","Foreground color of the selected entry in the peek view result list."));const yR=oi("peekViewEditor.background",{dark:"#001F33",light:"#F2F8FC",hcDark:cn.black,hcLight:cn.white},C("peekViewEditorBackground","Background color of the peek view editor."));oi("peekViewEditorGutter.background",yR,C("peekViewEditorGutterBackground","Background color of the gutter in the peek view editor."));oi("peekViewEditorStickyScroll.background",yR,C("peekViewEditorStickScrollBackground","Background color of sticky scroll in the peek view editor."));oi("peekViewResult.matchHighlightBackground",{dark:"#ea5c004d",light:"#ea5c004d",hcDark:null,hcLight:null},C("peekViewResultsMatchHighlight","Match highlight color in the peek view result list."));oi("peekViewEditor.matchHighlightBackground",{dark:"#ff8f0099",light:"#f5d802de",hcDark:null,hcLight:null},C("peekViewEditorMatchHighlight","Match highlight color in the peek view editor."));oi("peekViewEditor.matchHighlightBorder",{dark:null,light:null,hcDark:mu,hcLight:mu},C("peekViewEditorMatchHighlightBorder","Match highlight border in the peek view editor."));class Oc{constructor(e,t,i,n){this.isProviderFirst=e,this.parent=t,this.link=i,this._rangeCallback=n,this.id=S2.nextId()}get uri(){return this.link.uri}get range(){return this._range??this.link.targetSelectionRange??this.link.range}set range(e){this._range=e,this._rangeCallback(this)}get ariaMessage(){var t;const e=(t=this.parent.getPreview(this))==null?void 0:t.preview(this.range);return e?C({key:"aria.oneReference.preview",comment:["Placeholders are: 0: filename, 1:line number, 2: column number, 3: preview snippet of source code"]},"{0} in {1} on line {2} at column {3}",e.value,$a(this.uri),this.range.startLineNumber,this.range.startColumn):C("aria.oneReference","in {0} on line {1} at column {2}",$a(this.uri),this.range.startLineNumber,this.range.startColumn)}}class JB{constructor(e){this._modelReference=e}dispose(){this._modelReference.dispose()}preview(e,t=8){const i=this._modelReference.object.textEditorModel;if(!i)return;const{startLineNumber:n,startColumn:s,endLineNumber:r,endColumn:a}=e,d=i.getWordUntilPosition({lineNumber:n,column:s-t}),u=new Z(n,d.startColumn,n,s),f=new Z(r,a,r,1073741824),g=i.getValueInRange(u).replace(/^\s+/,""),p=i.getValueInRange(e),w=i.getValueInRange(f).replace(/\s+$/,"");return{value:g+p+w,highlight:{start:g.length,end:g.length+p.length}}}}class Mp{constructor(e,t){this.parent=e,this.uri=t,this.children=[],this._previews=new Pc}dispose(){no(this._previews.values()),this._previews.clear()}getPreview(e){return this._previews.get(e.uri)}get ariaMessage(){const e=this.children.length;return e===1?C("aria.fileReferences.1","1 symbol in {0}, full path {1}",$a(this.uri),this.uri.fsPath):C("aria.fileReferences.N","{0} symbols in {1}, full path {2}",e,$a(this.uri),this.uri.fsPath)}async resolve(e){if(this._previews.size!==0)return this;for(const t of this.children)if(!this._previews.has(t.uri))try{const i=await e.createModelReference(t.uri);this._previews.set(t.uri,new JB(i))}catch(i){Nn(i)}return this}}class To{constructor(e,t){this.groups=[],this.references=[],this._onDidChangeReferenceRange=new Xi,this.onDidChangeReferenceRange=this._onDidChangeReferenceRange.event,this._links=e,this._title=t;const[i]=e;e.sort(To._compareReferences);let n;for(const s of e)if((!n||!fL.isEqual(n.uri,s.uri,!0))&&(n=new Mp(this,s.uri),this.groups.push(n)),n.children.length===0||To._compareReferences(s,n.children[n.children.length-1])!==0){const r=new Oc(i===s,n,s,a=>this._onDidChangeReferenceRange.fire(a));this.references.push(r),n.children.push(r)}}dispose(){no(this.groups),this._onDidChangeReferenceRange.dispose(),this.groups.length=0}clone(){return new To(this._links,this._title)}get title(){return this._title}get isEmpty(){return this.groups.length===0}get ariaMessage(){return this.isEmpty?C("aria.result.0","No results found"):this.references.length===1?C("aria.result.1","Found 1 symbol in {0}",this.references[0].uri.fsPath):this.groups.length===1?C("aria.result.n1","Found {0} symbols in {1}",this.references.length,this.groups[0].uri.fsPath):C("aria.result.nm","Found {0} symbols in {1} files",this.references.length,this.groups.length)}nextOrPreviousReference(e,t){const{parent:i}=e;let n=i.children.indexOf(e);const s=i.children.length,r=i.parent.groups.length;return r===1||t&&n+1<s||!t&&n>0?(t?n=(n+1)%s:n=(n+s-1)%s,i.children[n]):(n=i.parent.groups.indexOf(i),t?(n=(n+1)%r,i.parent.groups[n].children[0]):(n=(n+r-1)%r,i.parent.groups[n].children[i.parent.groups[n].children.length-1]))}nearestReference(e,t){const i=this.references.map((n,s)=>({idx:s,prefixLen:v_(n.uri.toString(),e.toString()),offsetDist:Math.abs(n.range.startLineNumber-t.lineNumber)*100+Math.abs(n.range.startColumn-t.column)})).sort((n,s)=>n.prefixLen>s.prefixLen?-1:n.prefixLen<s.prefixLen?1:n.offsetDist<s.offsetDist?-1:n.offsetDist>s.offsetDist?1:0)[0];if(i)return this.references[i.idx]}referenceAt(e,t){for(const i of this.references)if(i.uri.toString()===e.toString()&&Z.containsPosition(i.range,t))return i}firstReference(){for(const e of this.references)if(e.isProviderFirst)return e;return this.references[0]}static _compareReferences(e,t){return fL.compare(e.uri,t.uri)||Z.compareRangesUsingStarts(e.range,t.range)}}var Xy=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Qy=function(o,e){return function(t,i){e(t,i,o)}},kC;let LC=class{constructor(e){this._resolverService=e}hasChildren(e){return e instanceof To||e instanceof Mp}getChildren(e){if(e instanceof To)return e.groups;if(e instanceof Mp)return e.resolve(this._resolverService).then(t=>t.children);throw new Error("bad tree")}};LC=Xy([Qy(0,ga)],LC);class ez{getHeight(){return 23}getTemplateId(e){return e instanceof Mp?Dv.id:Tv.id}}let IC=class{constructor(e){this._keybindingService=e}getKeyboardNavigationLabel(e){var t;if(e instanceof Oc){const i=(t=e.parent.getPreview(e))==null?void 0:t.preview(e.range);if(i)return i.value}return $a(e.uri)}};IC=Xy([Qy(0,hs)],IC);class tz{getId(e){return e instanceof Oc?e.id:e.uri}}let EC=class extends Dt{constructor(e,t){super(),this._labelService=t;const i=document.createElement("div");i.classList.add("reference-file"),this.file=this._register(new XD(i,{supportHighlights:!0})),this.badge=new C2(ei(i,si(".count")),{},x2),e.appendChild(i)}set(e,t){const i=l0(e.uri);this.file.setLabel(this._labelService.getUriBasenameLabel(e.uri),this._labelService.getUriLabel(i,{relative:!0}),{title:this._labelService.getUriLabel(e.uri),matches:t});const n=e.children.length;this.badge.setCount(n),n>1?this.badge.setTitleFormat(C("referencesCount","{0} references",n)):this.badge.setTitleFormat(C("referenceCount","{0} reference",n))}};EC=Xy([Qy(1,_p)],EC);var Nd;let Dv=(Nd=class{constructor(e){this._instantiationService=e,this.templateId=kC.id}renderTemplate(e){return this._instantiationService.createInstance(EC,e)}renderElement(e,t,i){i.set(e.element,Iy(e.filterData))}disposeTemplate(e){e.dispose()}},kC=Nd,Nd.id="FileReferencesRenderer",Nd);Dv=kC=Xy([Qy(0,Zi)],Dv);class iz extends Dt{constructor(e){super(),this.label=this._register(new k2(e))}set(e,t){var n;const i=(n=e.parent.getPreview(e))==null?void 0:n.preview(e.range);if(!i||!i.value)this.label.set(`${$a(e.uri)}:${e.range.startLineNumber+1}:${e.range.startColumn+1}`);else{const{value:s,highlight:r}=i;t&&!mp.isDefault(t)?(this.label.element.classList.toggle("referenceMatch",!1),this.label.set(s,Iy(t))):(this.label.element.classList.toggle("referenceMatch",!0),this.label.set(s,[r]))}}}const Rb=class Rb{constructor(){this.templateId=Rb.id}renderTemplate(e){return new iz(e)}renderElement(e,t,i){i.set(e.element,e.filterData)}disposeTemplate(e){e.dispose()}};Rb.id="OneReferenceRenderer";let Tv=Rb;class nz{getWidgetAriaLabel(){return C("treeAriaLabel","References")}getAriaLabel(e){return e.ariaMessage}}var sz=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},nh=function(o,e){return function(t,i){e(t,i,o)}};const Nb=class Nb{constructor(e,t){this._editor=e,this._model=t,this._decorations=new Map,this._decorationIgnoreSet=new Set,this._callOnDispose=new Lt,this._callOnModelChange=new Lt,this._callOnDispose.add(this._editor.onDidChangeModel(()=>this._onModelChanged())),this._onModelChanged()}dispose(){this._callOnModelChange.dispose(),this._callOnDispose.dispose(),this.removeDecorations()}_onModelChanged(){this._callOnModelChange.clear();const e=this._editor.getModel();if(e){for(const t of this._model.references)if(t.uri.toString()===e.uri.toString()){this._addDecorations(t.parent);return}}}_addDecorations(e){if(!this._editor.hasModel())return;this._callOnModelChange.add(this._editor.getModel().onDidChangeDecorations(()=>this._onDecorationChanged()));const t=[],i=[];for(let n=0,s=e.children.length;n<s;n++){const r=e.children[n];this._decorationIgnoreSet.has(r.id)||r.uri.toString()===this._editor.getModel().uri.toString()&&(t.push({range:r.range,options:Nb.DecorationOptions}),i.push(n))}this._editor.changeDecorations(n=>{const s=n.deltaDecorations([],t);for(let r=0;r<s.length;r++)this._decorations.set(s[r],e.children[i[r]])})}_onDecorationChanged(){const e=[],t=this._editor.getModel();if(t){for(const[i,n]of this._decorations){const s=t.getDecorationRange(i);if(!s)continue;let r=!1;if(!Z.equalsRange(s,n.range)){if(Z.spansMultipleLines(s))r=!0;else{const a=n.range.endColumn-n.range.startColumn,d=s.endColumn-s.startColumn;a!==d&&(r=!0)}r?(this._decorationIgnoreSet.add(n.id),e.push(i)):n.range=s}}for(let i=0,n=e.length;i<n;i++)this._decorations.delete(e[i]);this._editor.removeDecorations(e)}}removeDecorations(){this._editor.removeDecorations([...this._decorations.keys()]),this._decorations.clear()}};Nb.DecorationOptions=dn.register({description:"reference-decoration",stickiness:1,className:"reference-decoration"});let DC=Nb;class oz{constructor(){this.ratio=.7,this.heightInLines=18}static fromJSON(e){let t,i;try{const n=JSON.parse(e);t=n.ratio,i=n.heightInLines}catch{}return{ratio:t||.7,heightInLines:i||18}}}class rz extends E2{}let TC=class extends Ev{constructor(e,t,i,n,s,r,a,d,u){super(e,{showFrame:!1,showArrow:!0,isResizeable:!0,isAccessible:!0,supportOnTitleClick:!0},r),this._defaultTreeKeyboardSupport=t,this.layoutData=i,this._textModelResolverService=s,this._instantiationService=r,this._peekViewService=a,this._uriLabel=d,this._keybindingService=u,this._disposeOnNewModel=new Lt,this._callOnDispose=new Lt,this._onDidSelectReference=new Xi,this.onDidSelectReference=this._onDidSelectReference.event,this._dim=new On(0,0),this._isClosing=!1,this._applyTheme(n.getColorTheme()),this._callOnDispose.add(n.onDidColorThemeChange(this._applyTheme.bind(this))),this._peekViewService.addExclusiveWidget(e,this),this.create()}get isClosing(){return this._isClosing}dispose(){this._isClosing=!0,this.setModel(void 0),this._callOnDispose.dispose(),this._disposeOnNewModel.dispose(),no(this._preview),no(this._previewNotAvailableMessage),no(this._tree),no(this._previewModelReference),this._splitView.dispose(),super.dispose()}_applyTheme(e){const t=e.getColor(XB)||cn.transparent;this.style({arrowColor:t,frameColor:t,headerBackgroundColor:e.getColor(YB)||cn.transparent,primaryHeadingColor:e.getColor(vR),secondaryHeadingColor:e.getColor(bR)})}show(e){super.show(e,this.layoutData.heightInLines||18)}focusOnReferenceTree(){this._tree.domFocus()}focusOnPreviewEditor(){this._preview.focus()}isPreviewEditorFocused(){return this._preview.hasTextFocus()}_onTitleClick(e){this._preview&&this._preview.getModel()&&this._onDidSelectReference.fire({element:this._getFocusedReference(),kind:e.ctrlKey||e.metaKey||e.altKey?"side":"open",source:"title"})}_fillBody(e){this.setCssClass("reference-zone-widget"),this._messageContainer=ei(e,si("div.messages")),Bo(this._messageContainer),this._splitView=new L2(e,{orientation:1}),this._previewContainer=ei(e,si("div.preview.inline"));const t={scrollBeyondLastLine:!1,scrollbar:{verticalScrollbarSize:14,horizontal:"auto",useShadows:!0,verticalHasArrows:!1,horizontalHasArrows:!1,alwaysConsumeMouseWheel:!0},overviewRulerLanes:2,fixedOverflowWidgets:!0,minimap:{enabled:!1}};this._preview=this._instantiationService.createInstance(Fr,this._previewContainer,t,{},this.editor),Bo(this._previewContainer),this._previewNotAvailableMessage=this._instantiationService.createInstance(sc,C("missingPreviewMessage","no preview available"),vp,sc.DEFAULT_CREATION_OPTIONS,null),this._treeContainer=ei(e,si("div.ref-tree.inline"));const i={keyboardSupport:this._defaultTreeKeyboardSupport,accessibilityProvider:new nz,keyboardNavigationLabelProvider:this._instantiationService.createInstance(IC),identityProvider:new tz,openOnSingleClick:!0,selectionNavigation:!0,overrideStyles:{listBackground:QB}};this._defaultTreeKeyboardSupport&&this._callOnDispose.add(Cl(this._treeContainer,"keydown",s=>{s.equals(9)&&(this._keybindingService.dispatchEvent(s,s.target),s.stopPropagation())},!0)),this._tree=this._instantiationService.createInstance(rz,"ReferencesWidget",this._treeContainer,new ez,[this._instantiationService.createInstance(Dv),this._instantiationService.createInstance(Tv)],this._instantiationService.createInstance(LC),i),this._splitView.addView({onDidChange:ws.None,element:this._previewContainer,minimumSize:200,maximumSize:Number.MAX_VALUE,layout:s=>{this._preview.layout({height:this._dim.height,width:s})}},gL.Distribute),this._splitView.addView({onDidChange:ws.None,element:this._treeContainer,minimumSize:100,maximumSize:Number.MAX_VALUE,layout:s=>{this._treeContainer.style.height=`${this._dim.height}px`,this._treeContainer.style.width=`${s}px`,this._tree.layout(this._dim.height,s)}},gL.Distribute),this._disposables.add(this._splitView.onDidSashChange(()=>{this._dim.width&&(this.layoutData.ratio=this._splitView.getViewSize(0)/this._dim.width)},void 0));const n=(s,r)=>{s instanceof Oc&&(r==="show"&&this._revealReference(s,!1),this._onDidSelectReference.fire({element:s,kind:r,source:"tree"}))};this._disposables.add(this._tree.onDidOpen(s=>{s.sideBySide?n(s.element,"side"):s.editorOptions.pinned?n(s.element,"goto"):n(s.element,"show")})),Bo(this._treeContainer)}_onWidth(e){this._dim&&this._doLayoutBody(this._dim.height,e)}_doLayoutBody(e,t){super._doLayoutBody(e,t),this._dim=new On(t,e),this.layoutData.heightInLines=this._viewZone?this._viewZone.heightInLines:this.layoutData.heightInLines,this._splitView.layout(t),this._splitView.resizeView(0,t*this.layoutData.ratio)}setSelection(e){return this._revealReference(e,!0).then(()=>{this._model&&(this._tree.setSelection([e]),this._tree.setFocus([e]))})}setModel(e){return this._disposeOnNewModel.clear(),this._model=e,this._model?this._onNewModel():Promise.resolve()}_onNewModel(){return this._model?this._model.isEmpty?(this.setTitle(""),this._messageContainer.innerText=C("noResults","No results"),Dr(this._messageContainer),Promise.resolve(void 0)):(Bo(this._messageContainer),this._decorationsManager=new DC(this._preview,this._model),this._disposeOnNewModel.add(this._decorationsManager),this._disposeOnNewModel.add(this._model.onDidChangeReferenceRange(e=>this._tree.rerender(e))),this._disposeOnNewModel.add(this._preview.onMouseDown(e=>{const{event:t,target:i}=e;if(t.detail!==2)return;const n=this._getFocusedReference();n&&this._onDidSelectReference.fire({element:{uri:n.uri,range:i.range},kind:t.ctrlKey||t.metaKey||t.altKey?"side":"open",source:"editor"})})),this.container.classList.add("results-loaded"),Dr(this._treeContainer),Dr(this._previewContainer),this._splitView.layout(this._dim.width),this.focusOnReferenceTree(),this._tree.setInput(this._model.groups.length===1?this._model.groups[0]:this._model)):Promise.resolve(void 0)}_getFocusedReference(){const[e]=this._tree.getFocus();if(e instanceof Oc)return e;if(e instanceof Mp&&e.children.length>0)return e.children[0]}async revealReference(e){await this._revealReference(e,!1),this._onDidSelectReference.fire({element:e,kind:"goto",source:"tree"})}async _revealReference(e,t){if(this._revealedReference===e)return;this._revealedReference=e,e.uri.scheme!==go.inMemory?this.setTitle(I2(e.uri),this._uriLabel.getUriLabel(l0(e.uri))):this.setTitle(C("peekView.alternateTitle","References"));const i=this._textModelResolverService.createModelReference(e.uri);this._tree.getInput()===e.parent?this._tree.reveal(e):(t&&this._tree.reveal(e.parent),await this._tree.expand(e.parent),this._tree.reveal(e));const n=await i;if(!this._model){n.dispose();return}no(this._previewModelReference);const s=n.object;if(s){const r=this._preview.getModel()===s.textEditorModel?0:1,a=Z.lift(e.range).collapseToStart();this._previewModelReference=n,this._preview.setModel(s.textEditorModel),this._preview.setSelection(a),this._preview.revealRangeInCenter(a,r)}else this._preview.setModel(this._previewNotAvailableMessage),n.dispose()}};TC=sz([nh(3,Hr),nh(4,ga),nh(5,Zi),nh(6,mR),nh(7,_p),nh(8,hs)],TC);var az=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},sh=function(o,e){return function(t,i){e(t,i,o)}},$m;const $u=new _n("referenceSearchVisible",!1,C("referenceSearchVisible","Whether reference peek is visible, like 'Peek References' or 'Peek Definition'"));var Ad;let Tu=(Ad=class{static get(e){return e.getContribution($m.ID)}constructor(e,t,i,n,s,r,a,d){this._defaultTreeKeyboardSupport=e,this._editor=t,this._editorService=n,this._notificationService=s,this._instantiationService=r,this._storageService=a,this._configurationService=d,this._disposables=new Lt,this._requestIdPool=0,this._ignoreModelChangeEvent=!1,this._referenceSearchVisible=$u.bindTo(i)}dispose(){var e,t;this._referenceSearchVisible.reset(),this._disposables.dispose(),(e=this._widget)==null||e.dispose(),(t=this._model)==null||t.dispose(),this._widget=void 0,this._model=void 0}toggleWidget(e,t,i){let n;if(this._widget&&(n=this._widget.position),this.closeWidget(),n&&e.containsPosition(n))return;this._peekMode=i,this._referenceSearchVisible.set(!0),this._disposables.add(this._editor.onDidChangeModelLanguage(()=>{this.closeWidget()})),this._disposables.add(this._editor.onDidChangeModel(()=>{this._ignoreModelChangeEvent||this.closeWidget()}));const s="peekViewLayout",r=oz.fromJSON(this._storageService.get(s,0,"{}"));this._widget=this._instantiationService.createInstance(TC,this._editor,this._defaultTreeKeyboardSupport,r),this._widget.setTitle(C("labelLoading","Loading...")),this._widget.show(e),this._disposables.add(this._widget.onDidClose(()=>{t.cancel(),this._widget?(this._storageService.store(s,JSON.stringify(this._widget.layoutData),0,1),this._widget.isClosing||this.closeWidget(),this._widget=void 0):this.closeWidget()})),this._disposables.add(this._widget.onDidSelectReference(d=>{const{element:u,kind:f}=d;if(u)switch(f){case"open":(d.source!=="editor"||!this._configurationService.getValue("editor.stablePeek"))&&this.openReference(u,!1,!1);break;case"side":this.openReference(u,!0,!1);break;case"goto":i?this._gotoReference(u,!0):this.openReference(u,!1,!0);break}}));const a=++this._requestIdPool;t.then(d=>{var u;if(a!==this._requestIdPool||!this._widget){d.dispose();return}return(u=this._model)==null||u.dispose(),this._model=d,this._widget.setModel(this._model).then(()=>{if(this._widget&&this._model&&this._editor.hasModel()){this._model.isEmpty?this._widget.setMetaTitle(""):this._widget.setMetaTitle(C("metaTitle.N","{0} ({1})",this._model.title,this._model.references.length));const f=this._editor.getModel().uri,g=new gi(e.startLineNumber,e.startColumn),p=this._model.nearestReference(f,g);if(p)return this._widget.setSelection(p).then(()=>{this._widget&&this._editor.getOption(87)==="editor"&&this._widget.focusOnPreviewEditor()})}})},d=>{this._notificationService.error(d)})}changeFocusBetweenPreviewAndReferences(){this._widget&&(this._widget.isPreviewEditorFocused()?this._widget.focusOnReferenceTree():this._widget.focusOnPreviewEditor())}async goToNextOrPreviousReference(e){if(!this._editor.hasModel()||!this._model||!this._widget)return;const t=this._widget.position;if(!t)return;const i=this._model.nearestReference(this._editor.getModel().uri,t);if(!i)return;const n=this._model.nextOrPreviousReference(i,e),s=this._editor.hasTextFocus(),r=this._widget.isPreviewEditorFocused();await this._widget.setSelection(n),await this._gotoReference(n,!1),s?this._editor.focus():this._widget&&r&&this._widget.focusOnPreviewEditor()}async revealReference(e){!this._editor.hasModel()||!this._model||!this._widget||await this._widget.revealReference(e)}closeWidget(e=!0){var t,i;(t=this._widget)==null||t.dispose(),(i=this._model)==null||i.dispose(),this._referenceSearchVisible.reset(),this._disposables.clear(),this._widget=void 0,this._model=void 0,e&&this._editor.focus(),this._requestIdPool+=1}_gotoReference(e,t){var n;(n=this._widget)==null||n.hide(),this._ignoreModelChangeEvent=!0;const i=Z.lift(e.range).collapseToStart();return this._editorService.openCodeEditor({resource:e.uri,options:{selection:i,selectionSource:"code.jump",pinned:t}},this._editor).then(s=>{if(this._ignoreModelChangeEvent=!1,!s||!this._widget){this.closeWidget();return}if(this._editor===s)this._widget.show(i),this._widget.focusOnReferenceTree();else{const r=$m.get(s),a=this._model.clone();this.closeWidget(),s.focus(),r==null||r.toggleWidget(i,Os(d=>Promise.resolve(a)),this._peekMode??!1)}},s=>{this._ignoreModelChangeEvent=!1,Nn(s)})}openReference(e,t,i){t||this.closeWidget();const{uri:n,range:s}=e;this._editorService.openCodeEditor({resource:n,options:{selection:s,selectionSource:"code.jump",pinned:i}},this._editor,t)}},$m=Ad,Ad.ID="editor.contrib.referencesController",Ad);Tu=$m=az([sh(2,Sn),sh(3,as),sh(4,co),sh(5,Zi),sh(6,zc),sh(7,Un)],Tu);function Uu(o,e){const t=KB(o);if(!t)return;const i=Tu.get(t);i&&e(i)}Ga.registerCommandAndKeybindingRule({id:"togglePeekWidgetFocus",weight:100,primary:us(2089,60),when:Ae.or($u,vo.inPeekEditor),handler(o){Uu(o,e=>{e.changeFocusBetweenPreviewAndReferences()})}});Ga.registerCommandAndKeybindingRule({id:"goToNextReference",weight:90,primary:62,secondary:[70],when:Ae.or($u,vo.inPeekEditor),handler(o){Uu(o,e=>{e.goToNextOrPreviousReference(!0)})}});Ga.registerCommandAndKeybindingRule({id:"goToPreviousReference",weight:90,primary:1086,secondary:[1094],when:Ae.or($u,vo.inPeekEditor),handler(o){Uu(o,e=>{e.goToNextOrPreviousReference(!1)})}});Wn.registerCommandAlias("goToNextReferenceFromEmbeddedEditor","goToNextReference");Wn.registerCommandAlias("goToPreviousReferenceFromEmbeddedEditor","goToPreviousReference");Wn.registerCommandAlias("closeReferenceSearchEditor","closeReferenceSearch");Wn.registerCommand("closeReferenceSearch",o=>Uu(o,e=>e.closeWidget()));Ga.registerKeybindingRule({id:"closeReferenceSearch",weight:-1,primary:9,secondary:[1033],when:Ae.and(vo.inPeekEditor,Ae.not("config.editor.stablePeek"))});Ga.registerKeybindingRule({id:"closeReferenceSearch",weight:250,primary:9,secondary:[1033],when:Ae.and($u,Ae.not("config.editor.stablePeek"),Ae.or(B.editorTextFocus,D2.negate()))});Ga.registerCommandAndKeybindingRule({id:"revealReference",weight:200,primary:3,mac:{primary:3,secondary:[2066]},when:Ae.and($u,QD,JD.negate(),eT.negate()),handler(o){var i;const t=(i=o.get(c0).lastFocusedList)==null?void 0:i.getFocus();Array.isArray(t)&&t[0]instanceof Oc&&Uu(o,n=>n.revealReference(t[0]))}});Ga.registerCommandAndKeybindingRule({id:"openReferenceToSide",weight:100,primary:2051,mac:{primary:259},when:Ae.and($u,QD,JD.negate(),eT.negate()),handler(o){var i;const t=(i=o.get(c0).lastFocusedList)==null?void 0:i.getFocus();Array.isArray(t)&&t[0]instanceof Oc&&Uu(o,n=>n.openReference(t[0],!0,!0))}});Wn.registerCommand("openReference",o=>{var i;const t=(i=o.get(c0).lastFocusedList)==null?void 0:i.getFocus();Array.isArray(t)&&t[0]instanceof Oc&&Uu(o,n=>n.openReference(t[0],!1,!0))});var wR=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Dg=function(o,e){return function(t,i){e(t,i,o)}};const X0=new _n("hasSymbols",!1,C("hasSymbols","Whether there are symbol locations that can be navigated via keyboard-only.")),Jy=Rl("ISymbolNavigationService");let PC=class{constructor(e,t,i,n){this._editorService=t,this._notificationService=i,this._keybindingService=n,this._currentModel=void 0,this._currentIdx=-1,this._ignoreEditorChange=!1,this._ctxHasSymbols=X0.bindTo(e)}reset(){var e,t;this._ctxHasSymbols.reset(),(e=this._currentState)==null||e.dispose(),(t=this._currentMessage)==null||t.dispose(),this._currentModel=void 0,this._currentIdx=-1}put(e){const t=e.parent.parent;if(t.references.length<=1){this.reset();return}this._currentModel=t,this._currentIdx=t.references.indexOf(e),this._ctxHasSymbols.set(!0),this._showMessage();const i=new MC(this._editorService),n=i.onDidChange(s=>{if(this._ignoreEditorChange)return;const r=this._editorService.getActiveCodeEditor();if(!r)return;const a=r.getModel(),d=r.getPosition();if(!a||!d)return;let u=!1,f=!1;for(const g of t.references)if(iv(g.uri,a.uri))u=!0,f=f||Z.containsPosition(g.range,d);else if(u)break;(!u||!f)&&this.reset()});this._currentState=tT(i,n)}revealNext(e){if(!this._currentModel)return Promise.resolve();this._currentIdx+=1,this._currentIdx%=this._currentModel.references.length;const t=this._currentModel.references[this._currentIdx];return this._showMessage(),this._ignoreEditorChange=!0,this._editorService.openCodeEditor({resource:t.uri,options:{selection:Z.collapseToStart(t.range),selectionRevealType:3}},e).finally(()=>{this._ignoreEditorChange=!1})}_showMessage(){var i;(i=this._currentMessage)==null||i.dispose();const e=this._keybindingService.lookupKeybinding("editor.gotoNextSymbolFromResult"),t=e?C("location.kb","Symbol {0} of {1}, {2} for next",this._currentIdx+1,this._currentModel.references.length,e.getLabel()):C("location","Symbol {0} of {1}",this._currentIdx+1,this._currentModel.references.length);this._currentMessage=this._notificationService.status(t)}};PC=wR([Dg(0,Sn),Dg(1,as),Dg(2,co),Dg(3,hs)],PC);Nl(Jy,PC,1);bi(new class extends wo{constructor(){super({id:"editor.gotoNextSymbolFromResult",precondition:X0,kbOpts:{weight:100,primary:70}})}runEditorCommand(o,e){return o.get(Jy).revealNext(e)}});Ga.registerCommandAndKeybindingRule({id:"editor.gotoNextSymbolFromResult.cancel",weight:100,when:X0,primary:9,handler(o){o.get(Jy).reset()}});let MC=class{constructor(e){this._listener=new Map,this._disposables=new Lt,this._onDidChange=new Xi,this.onDidChange=this._onDidChange.event,this._disposables.add(e.onCodeEditorRemove(this._onDidRemoveEditor,this)),this._disposables.add(e.onCodeEditorAdd(this._onDidAddEditor,this)),e.listCodeEditors().forEach(this._onDidAddEditor,this)}dispose(){this._disposables.dispose(),this._onDidChange.dispose(),no(this._listener.values())}_onDidAddEditor(e){this._listener.set(e,tT(e.onDidChangeCursorPosition(t=>this._onDidChange.fire({editor:e})),e.onDidChangeModelContent(t=>this._onDidChange.fire({editor:e}))))}_onDidRemoveEditor(e){var t;(t=this._listener.get(e))==null||t.dispose(),this._listener.delete(e)}};MC=wR([Dg(0,as)],MC);function RC(o,e){return e.uri.scheme===o.uri.scheme?!0:!T2(e.uri,go.walkThroughSnippet,go.vscodeChatCodeBlock,go.vscodeChatCodeCompareBlock)}async function T_(o,e,t,i,n){const r=t.ordered(o,i).map(d=>Promise.resolve(n(d,o,e)).then(void 0,u=>{rs(u)})),a=await Promise.all(r);return wl(a.flat()).filter(d=>RC(o,d))}function P_(o,e,t,i,n){return T_(e,t,o,i,(s,r,a)=>s.provideDefinition(r,a,n))}function Q0(o,e,t,i,n){return T_(e,t,o,i,(s,r,a)=>s.provideDeclaration(r,a,n))}function J0(o,e,t,i,n){return T_(e,t,o,i,(s,r,a)=>s.provideImplementation(r,a,n))}function ek(o,e,t,i,n){return T_(e,t,o,i,(s,r,a)=>s.provideTypeDefinition(r,a,n))}function M_(o,e,t,i,n,s){return T_(e,t,o,n,async(r,a,d)=>{var g,p;const u=(g=await r.provideReferences(a,d,{includeDeclaration:!0},s))==null?void 0:g.filter(w=>RC(a,w));if(!i||!u||u.length!==2)return u;const f=(p=await r.provideReferences(a,d,{includeDeclaration:!1},s))==null?void 0:p.filter(w=>RC(a,w));return f&&f.length===1?f:u})}async function Ka(o){const e=await o(),t=new To(e,""),i=t.references.map(n=>n.link);return t.dispose(),i}So("_executeDefinitionProvider",(o,e,t)=>{const i=o.get(pi),n=P_(i.definitionProvider,e,t,!1,Qi.None);return Ka(()=>n)});So("_executeDefinitionProvider_recursive",(o,e,t)=>{const i=o.get(pi),n=P_(i.definitionProvider,e,t,!0,Qi.None);return Ka(()=>n)});So("_executeTypeDefinitionProvider",(o,e,t)=>{const i=o.get(pi),n=ek(i.typeDefinitionProvider,e,t,!1,Qi.None);return Ka(()=>n)});So("_executeTypeDefinitionProvider_recursive",(o,e,t)=>{const i=o.get(pi),n=ek(i.typeDefinitionProvider,e,t,!0,Qi.None);return Ka(()=>n)});So("_executeDeclarationProvider",(o,e,t)=>{const i=o.get(pi),n=Q0(i.declarationProvider,e,t,!1,Qi.None);return Ka(()=>n)});So("_executeDeclarationProvider_recursive",(o,e,t)=>{const i=o.get(pi),n=Q0(i.declarationProvider,e,t,!0,Qi.None);return Ka(()=>n)});So("_executeReferenceProvider",(o,e,t)=>{const i=o.get(pi),n=M_(i.referenceProvider,e,t,!1,!1,Qi.None);return Ka(()=>n)});So("_executeReferenceProvider_recursive",(o,e,t)=>{const i=o.get(pi),n=M_(i.referenceProvider,e,t,!1,!0,Qi.None);return Ka(()=>n)});So("_executeImplementationProvider",(o,e,t)=>{const i=o.get(pi),n=J0(i.implementationProvider,e,t,!1,Qi.None);return Ka(()=>n)});So("_executeImplementationProvider_recursive",(o,e,t)=>{const i=o.get(pi),n=J0(i.implementationProvider,e,t,!0,Qi.None);return Ka(()=>n)});Nr.appendMenuItem(Gt.EditorContext,{submenu:Gt.EditorContextPeek,title:C("peek.submenu","Peek"),group:"navigation",order:100});class Tf{static is(e){return!e||typeof e!="object"?!1:!!(e instanceof Tf||gi.isIPosition(e.position)&&e.model)}constructor(e,t){this.model=e,this.position=t}}const br=class br extends ca{static all(){return br._allSymbolNavigationCommands.values()}static _patchConfig(e){const t={...e,f1:!0};if(t.menu)for(const i of pl.wrap(t.menu))(i.id===Gt.EditorContext||i.id===Gt.EditorContextPeek)&&(i.when=Ae.and(e.precondition,i.when));return t}constructor(e,t){super(br._patchConfig(t)),this.configuration=e,br._allSymbolNavigationCommands.set(t.id,this)}runEditorCommand(e,t,i,n){if(!t.hasModel())return Promise.resolve(void 0);const s=e.get(co),r=e.get(as),a=e.get(c_),d=e.get(Jy),u=e.get(pi),f=e.get(Zi),g=t.getModel(),p=t.getPosition(),w=Tf.is(i)?i:new Tf(g,p),y=new hf(t,5),x=a_(this._getLocationModel(u,w.model,w.position,y.token),y.token).then(async k=>{var F;if(!k||y.token.isCancellationRequested)return;Ar(k.ariaMessage);let D;if(k.referenceAt(g.uri,p)){const K=this._getAlternativeCommand(t);!br._activeAlternativeCommands.has(K)&&br._allSymbolNavigationCommands.has(K)&&(D=br._allSymbolNavigationCommands.get(K))}const M=k.references.length;if(M===0){if(!this.configuration.muteMessage){const K=g.getWordAtPosition(p);(F=Do.get(t))==null||F.showMessage(this._getNoResultFoundMessage(K),p)}}else if(M===1&&D)br._activeAlternativeCommands.add(this.desc.id),f.invokeFunction(K=>D.runEditorCommand(K,t,i,n).finally(()=>{br._activeAlternativeCommands.delete(this.desc.id)}));else return this._onResult(r,d,t,k,n)},k=>{s.error(k)}).finally(()=>{y.dispose()});return a.showWhile(x,250),x}async _onResult(e,t,i,n,s){const r=this._getGoToPreference(i);if(!(i instanceof Fr)&&(this.configuration.openInPeek||r==="peek"&&n.references.length>1))this._openInPeek(i,n,s);else{const a=n.firstReference(),d=n.references.length>1&&r==="gotoAndPeek",u=await this._openReference(i,e,a,this.configuration.openToSide,!d);d&&u?this._openInPeek(u,n,s):n.dispose(),r==="goto"&&t.put(a)}}async _openReference(e,t,i,n,s){let r;if(P2(i)&&(r=i.targetSelectionRange),r||(r=i.range),!r)return;const a=await t.openCodeEditor({resource:i.uri,options:{selection:Z.collapseToStart(r),selectionRevealType:3,selectionSource:"code.jump"}},e,n);if(a){if(s){const d=a.getModel(),u=a.createDecorationsCollection([{range:r,options:{description:"symbol-navigate-action-highlight",className:"symbolHighlight"}}]);setTimeout(()=>{a.getModel()===d&&u.clear()},350)}return a}}_openInPeek(e,t,i){const n=Tu.get(e);n&&e.hasModel()?n.toggleWidget(i??e.getSelection(),Os(s=>Promise.resolve(t)),this.configuration.openInPeek):t.dispose()}};br._allSymbolNavigationCommands=new Map,br._activeAlternativeCommands=new Set;let El=br;class R_ extends El{async _getLocationModel(e,t,i,n){return new To(await P_(e.definitionProvider,t,i,!1,n),C("def.title","Definitions"))}_getNoResultFoundMessage(e){return e&&e.word?C("noResultWord","No definition found for '{0}'",e.word):C("generic.noResults","No definition found")}_getAlternativeCommand(e){return e.getOption(58).alternativeDefinitionCommand}_getGoToPreference(e){return e.getOption(58).multipleDefinitions}}var yc;Tn((yc=class extends R_{constructor(){super({openToSide:!1,openInPeek:!1,muteMessage:!1},{id:yc.id,title:{...ui("actions.goToDecl.label","Go to Definition"),mnemonicTitle:C({key:"miGotoDefinition",comment:["&& denotes a mnemonic"]},"Go to &&Definition")},precondition:B.hasDefinitionProvider,keybinding:[{when:B.editorTextFocus,primary:70,weight:100},{when:Ae.and(B.editorTextFocus,iT),primary:2118,weight:100}],menu:[{id:Gt.EditorContext,group:"navigation",order:1.1},{id:Gt.MenubarGoMenu,precondition:null,group:"4_symbol_nav",order:2}]}),Wn.registerCommandAlias("editor.action.goToDeclaration",yc.id)}},yc.id="editor.action.revealDefinition",yc));var wc;Tn((wc=class extends R_{constructor(){super({openToSide:!0,openInPeek:!1,muteMessage:!1},{id:wc.id,title:ui("actions.goToDeclToSide.label","Open Definition to the Side"),precondition:Ae.and(B.hasDefinitionProvider,B.isInEmbeddedEditor.toNegated()),keybinding:[{when:B.editorTextFocus,primary:us(2089,70),weight:100},{when:Ae.and(B.editorTextFocus,iT),primary:us(2089,2118),weight:100}]}),Wn.registerCommandAlias("editor.action.openDeclarationToTheSide",wc.id)}},wc.id="editor.action.revealDefinitionAside",wc));var Sc;Tn((Sc=class extends R_{constructor(){super({openToSide:!1,openInPeek:!0,muteMessage:!1},{id:Sc.id,title:ui("actions.previewDecl.label","Peek Definition"),precondition:Ae.and(B.hasDefinitionProvider,vo.notInPeekEditor,B.isInEmbeddedEditor.toNegated()),keybinding:{when:B.editorTextFocus,primary:582,linux:{primary:3140},weight:100},menu:{id:Gt.EditorContextPeek,group:"peek",order:2}}),Wn.registerCommandAlias("editor.action.previewDeclaration",Sc.id)}},Sc.id="editor.action.peekDefinition",Sc));class SR extends El{async _getLocationModel(e,t,i,n){return new To(await Q0(e.declarationProvider,t,i,!1,n),C("decl.title","Declarations"))}_getNoResultFoundMessage(e){return e&&e.word?C("decl.noResultWord","No declaration found for '{0}'",e.word):C("decl.generic.noResults","No declaration found")}_getAlternativeCommand(e){return e.getOption(58).alternativeDeclarationCommand}_getGoToPreference(e){return e.getOption(58).multipleDeclarations}}var Od;Tn((Od=class extends SR{constructor(){super({openToSide:!1,openInPeek:!1,muteMessage:!1},{id:Od.id,title:{...ui("actions.goToDeclaration.label","Go to Declaration"),mnemonicTitle:C({key:"miGotoDeclaration",comment:["&& denotes a mnemonic"]},"Go to &&Declaration")},precondition:Ae.and(B.hasDeclarationProvider,B.isInEmbeddedEditor.toNegated()),menu:[{id:Gt.EditorContext,group:"navigation",order:1.3},{id:Gt.MenubarGoMenu,precondition:null,group:"4_symbol_nav",order:3}]})}_getNoResultFoundMessage(e){return e&&e.word?C("decl.noResultWord","No declaration found for '{0}'",e.word):C("decl.generic.noResults","No declaration found")}},Od.id="editor.action.revealDeclaration",Od));Tn(class extends SR{constructor(){super({openToSide:!1,openInPeek:!0,muteMessage:!1},{id:"editor.action.peekDeclaration",title:ui("actions.peekDecl.label","Peek Declaration"),precondition:Ae.and(B.hasDeclarationProvider,vo.notInPeekEditor,B.isInEmbeddedEditor.toNegated()),menu:{id:Gt.EditorContextPeek,group:"peek",order:3}})}});class CR extends El{async _getLocationModel(e,t,i,n){return new To(await ek(e.typeDefinitionProvider,t,i,!1,n),C("typedef.title","Type Definitions"))}_getNoResultFoundMessage(e){return e&&e.word?C("goToTypeDefinition.noResultWord","No type definition found for '{0}'",e.word):C("goToTypeDefinition.generic.noResults","No type definition found")}_getAlternativeCommand(e){return e.getOption(58).alternativeTypeDefinitionCommand}_getGoToPreference(e){return e.getOption(58).multipleTypeDefinitions}}var Fd;Tn((Fd=class extends CR{constructor(){super({openToSide:!1,openInPeek:!1,muteMessage:!1},{id:Fd.ID,title:{...ui("actions.goToTypeDefinition.label","Go to Type Definition"),mnemonicTitle:C({key:"miGotoTypeDefinition",comment:["&& denotes a mnemonic"]},"Go to &&Type Definition")},precondition:B.hasTypeDefinitionProvider,keybinding:{when:B.editorTextFocus,primary:0,weight:100},menu:[{id:Gt.EditorContext,group:"navigation",order:1.4},{id:Gt.MenubarGoMenu,precondition:null,group:"4_symbol_nav",order:3}]})}},Fd.ID="editor.action.goToTypeDefinition",Fd));var Hd;Tn((Hd=class extends CR{constructor(){super({openToSide:!1,openInPeek:!0,muteMessage:!1},{id:Hd.ID,title:ui("actions.peekTypeDefinition.label","Peek Type Definition"),precondition:Ae.and(B.hasTypeDefinitionProvider,vo.notInPeekEditor,B.isInEmbeddedEditor.toNegated()),menu:{id:Gt.EditorContextPeek,group:"peek",order:4}})}},Hd.ID="editor.action.peekTypeDefinition",Hd));class xR extends El{async _getLocationModel(e,t,i,n){return new To(await J0(e.implementationProvider,t,i,!1,n),C("impl.title","Implementations"))}_getNoResultFoundMessage(e){return e&&e.word?C("goToImplementation.noResultWord","No implementation found for '{0}'",e.word):C("goToImplementation.generic.noResults","No implementation found")}_getAlternativeCommand(e){return e.getOption(58).alternativeImplementationCommand}_getGoToPreference(e){return e.getOption(58).multipleImplementations}}var Wd;Tn((Wd=class extends xR{constructor(){super({openToSide:!1,openInPeek:!1,muteMessage:!1},{id:Wd.ID,title:{...ui("actions.goToImplementation.label","Go to Implementations"),mnemonicTitle:C({key:"miGotoImplementation",comment:["&& denotes a mnemonic"]},"Go to &&Implementations")},precondition:B.hasImplementationProvider,keybinding:{when:B.editorTextFocus,primary:2118,weight:100},menu:[{id:Gt.EditorContext,group:"navigation",order:1.45},{id:Gt.MenubarGoMenu,precondition:null,group:"4_symbol_nav",order:4}]})}},Wd.ID="editor.action.goToImplementation",Wd));var Bd;Tn((Bd=class extends xR{constructor(){super({openToSide:!1,openInPeek:!0,muteMessage:!1},{id:Bd.ID,title:ui("actions.peekImplementation.label","Peek Implementations"),precondition:Ae.and(B.hasImplementationProvider,vo.notInPeekEditor,B.isInEmbeddedEditor.toNegated()),keybinding:{when:B.editorTextFocus,primary:3142,weight:100},menu:{id:Gt.EditorContextPeek,group:"peek",order:5}})}},Bd.ID="editor.action.peekImplementation",Bd));class kR extends El{_getNoResultFoundMessage(e){return e?C("references.no","No references found for '{0}'",e.word):C("references.noGeneric","No references found")}_getAlternativeCommand(e){return e.getOption(58).alternativeReferenceCommand}_getGoToPreference(e){return e.getOption(58).multipleReferences}}Tn(class extends kR{constructor(){super({openToSide:!1,openInPeek:!1,muteMessage:!1},{id:"editor.action.goToReferences",title:{...ui("goToReferences.label","Go to References"),mnemonicTitle:C({key:"miGotoReference",comment:["&& denotes a mnemonic"]},"Go to &&References")},precondition:Ae.and(B.hasReferenceProvider,vo.notInPeekEditor,B.isInEmbeddedEditor.toNegated()),keybinding:{when:B.editorTextFocus,primary:1094,weight:100},menu:[{id:Gt.EditorContext,group:"navigation",order:1.45},{id:Gt.MenubarGoMenu,precondition:null,group:"4_symbol_nav",order:5}]})}async _getLocationModel(e,t,i,n){return new To(await M_(e.referenceProvider,t,i,!0,!1,n),C("ref.title","References"))}});Tn(class extends kR{constructor(){super({openToSide:!1,openInPeek:!0,muteMessage:!1},{id:"editor.action.referenceSearch.trigger",title:ui("references.action.label","Peek References"),precondition:Ae.and(B.hasReferenceProvider,vo.notInPeekEditor,B.isInEmbeddedEditor.toNegated()),menu:{id:Gt.EditorContextPeek,group:"peek",order:6}})}async _getLocationModel(e,t,i,n){return new To(await M_(e.referenceProvider,t,i,!1,!1,n),C("ref.title","References"))}});class lz extends El{constructor(e,t,i){super(e,{id:"editor.action.goToLocation",title:ui("label.generic","Go to Any Symbol"),precondition:Ae.and(vo.notInPeekEditor,B.isInEmbeddedEditor.toNegated())}),this._references=t,this._gotoMultipleBehaviour=i}async _getLocationModel(e,t,i,n){return new To(this._references,C("generic.title","Locations"))}_getNoResultFoundMessage(e){return e&&C("generic.noResult","No results for '{0}'",e.word)||""}_getGoToPreference(e){return this._gotoMultipleBehaviour??e.getOption(58).multipleReferences}_getAlternativeCommand(){return""}}Wn.registerCommand({id:"editor.action.goToLocations",metadata:{description:"Go to locations from a position in a file",args:[{name:"uri",description:"The text document in which to start",constraint:Pn},{name:"position",description:"The position at which to start",constraint:gi.isIPosition},{name:"locations",description:"An array of locations.",constraint:Array},{name:"multiple",description:"Define what to do when having multiple results, either `peek`, `gotoAndPeek`, or `goto`"},{name:"noResultsMessage",description:"Human readable message that shows when locations is empty."}]},handler:async(o,e,t,i,n,s,r)=>{Cn(Pn.isUri(e)),Cn(gi.isIPosition(t)),Cn(Array.isArray(i)),Cn(typeof n>"u"||typeof n=="string"),Cn(typeof r>"u"||typeof r=="boolean");const a=o.get(as),d=await a.openCodeEditor({resource:e},a.getFocusedCodeEditor());if(nT(d))return d.setPosition(t),d.revealPositionInCenterIfOutsideViewport(t,0),d.invokeWithinContext(u=>{const f=new class extends lz{_getNoResultFoundMessage(g){return s||super._getNoResultFoundMessage(g)}}({muteMessage:!s,openInPeek:!!r,openToSide:!1},i,n);u.get(Zi).invokeFunction(f.run.bind(f),d)})}});Wn.registerCommand({id:"editor.action.peekLocations",metadata:{description:"Peek locations from a position in a file",args:[{name:"uri",description:"The text document in which to start",constraint:Pn},{name:"position",description:"The position at which to start",constraint:gi.isIPosition},{name:"locations",description:"An array of locations.",constraint:Array},{name:"multiple",description:"Define what to do when having multiple results, either `peek`, `gotoAndPeek`, or `goto`"}]},handler:async(o,e,t,i,n)=>{o.get(Es).executeCommand("editor.action.goToLocations",e,t,i,n,void 0,!0)}});Wn.registerCommand({id:"editor.action.findReferences",handler:(o,e,t)=>{Cn(Pn.isUri(e)),Cn(gi.isIPosition(t));const i=o.get(pi),n=o.get(as);return n.openCodeEditor({resource:e},n.getFocusedCodeEditor()).then(s=>{if(!nT(s)||!s.hasModel())return;const r=Tu.get(s);if(!r)return;const a=Os(u=>M_(i.referenceProvider,s.getModel(),gi.lift(t),!1,!1,u).then(f=>new To(f,C("ref.title","References")))),d=new Z(t.lineNumber,t.column,t.lineNumber,t.column);return Promise.resolve(r.toggleWidget(d,a,!1))})}});Wn.registerCommandAlias("editor.action.showReferences","editor.action.peekLocations");async function cz(o,e,t,i){const n=o.get(ga),s=o.get(zf),r=o.get(Es),a=o.get(Zi),d=o.get(co);if(await i.item.resolve(Qi.None),!i.part.location)return;const u=i.part.location,f=[],g=new Set(Nr.getMenuItems(Gt.EditorContext).map(w=>M2(w)?w.command.id:Uy()));for(const w of El.all())g.has(w.desc.id)&&f.push(new mf(w.desc.id,vf.label(w.desc,{renderShortTitle:!0}),void 0,!0,async()=>{const y=await n.createModelReference(u.uri);try{const x=new Tf(y.object.textEditorModel,Z.getStartPosition(u.range)),k=i.item.anchor.range;await a.invokeFunction(w.runEditorCommand.bind(w),e,x,k)}finally{y.dispose()}}));if(i.part.command){const{command:w}=i.part;f.push(new gp),f.push(new mf(w.id,w.title,void 0,!0,async()=>{try{await r.executeCommand(w.id,...w.arguments??[])}catch(y){d.notify({severity:d0.Error,source:i.item.provider.displayName,message:y})}}))}const p=e.getOption(128);s.showContextMenu({domForShadowRoot:p?e.getDomNode()??void 0:void 0,getAnchor:()=>{const w=mo(t);return{x:w.left,y:w.top+w.height+8}},getActions:()=>f,onHide:()=>{e.focus()},autoSelectFirstItem:!0})}async function LR(o,e,t,i){const s=await o.get(ga).createModelReference(i.uri);await t.invokeWithinContext(async r=>{const a=e.hasSideBySideModifier,d=r.get(Sn),u=vo.inPeekEditor.getValue(d),f=!a&&t.getOption(89)&&!u;return new R_({openToSide:a,openInPeek:f,muteMessage:!0},{title:{value:"",original:""},id:"",precondition:void 0}).run(r,new Tf(s.object.textEditorModel,Z.getStartPosition(i.range)),Z.lift(i.range))}),s.dispose()}var dz=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},oh=function(o,e){return function(t,i){e(t,i,o)}},yh;class Pv{constructor(){this._entries=new u_(50)}get(e){const t=Pv._key(e);return this._entries.get(t)}set(e,t){const i=Pv._key(e);this._entries.set(i,t)}static _key(e){return`${e.uri.toString()}/${e.getVersionId()}`}}const IR=Rl("IInlayHintsCache");Nl(IR,Pv,1);class NC{constructor(e,t){this.item=e,this.index=t}get part(){const e=this.item.hint.label;return typeof e=="string"?{label:e}:e[this.index]}}class uz{constructor(e,t){this.part=e,this.hasTriggerModifier=t}}var gl;let Rp=(gl=class{static get(e){return e.getContribution(yh.ID)??void 0}constructor(e,t,i,n,s,r,a){this._editor=e,this._languageFeaturesService=t,this._inlayHintsCache=n,this._commandService=s,this._notificationService=r,this._instaService=a,this._disposables=new Lt,this._sessionDisposables=new Lt,this._decorationsMetadata=new Map,this._ruleFactory=new jD(this._editor),this._activeRenderMode=0,this._debounceInfo=i.for(t.inlayHintsProvider,"InlayHint",{min:25}),this._disposables.add(t.inlayHintsProvider.onDidChange(()=>this._update())),this._disposables.add(e.onDidChangeModel(()=>this._update())),this._disposables.add(e.onDidChangeModelLanguage(()=>this._update())),this._disposables.add(e.onDidChangeConfiguration(d=>{d.hasChanged(142)&&this._update()})),this._update()}dispose(){this._sessionDisposables.dispose(),this._removeAllDecorations(),this._disposables.dispose()}_update(){this._sessionDisposables.clear(),this._removeAllDecorations();const e=this._editor.getOption(142);if(e.enabled==="off")return;const t=this._editor.getModel();if(!t||!this._languageFeaturesService.inlayHintsProvider.has(t))return;if(e.enabled==="on")this._activeRenderMode=0;else{let a,d;e.enabled==="onUnlessPressed"?(a=0,d=1):(a=1,d=0),this._activeRenderMode=a,this._sessionDisposables.add(R2.getInstance().event(u=>{if(!this._editor.hasModel())return;const f=u.altKey&&u.ctrlKey&&!(u.shiftKey||u.metaKey)?d:a;if(f!==this._activeRenderMode){this._activeRenderMode=f;const g=this._editor.getModel(),p=this._copyInlayHintsWithCurrentAnchor(g);this._updateHintsDecorators([g.getFullModelRange()],p),r.schedule(0)}}))}const i=this._inlayHintsCache.get(t);i&&this._updateHintsDecorators([t.getFullModelRange()],i),this._sessionDisposables.add(jn(()=>{t.isDisposed()||this._cacheHintsForFastRestore(t)}));let n;const s=new Set,r=new Ss(async()=>{const a=Date.now();n==null||n.dispose(!0),n=new Fs;const d=t.onWillDispose(()=>n==null?void 0:n.cancel());try{const u=n.token,f=await Lv.create(this._languageFeaturesService.inlayHintsProvider,t,this._getHintsRanges(),u);if(r.delay=this._debounceInfo.update(t,Date.now()-a),u.isCancellationRequested){f.dispose();return}for(const g of f.provider)typeof g.onDidChangeInlayHints=="function"&&!s.has(g)&&(s.add(g),this._sessionDisposables.add(g.onDidChangeInlayHints(()=>{r.isScheduled()||r.schedule()})));this._sessionDisposables.add(f),this._updateHintsDecorators(f.ranges,f.items),this._cacheHintsForFastRestore(t)}catch(u){Nn(u)}finally{n.dispose(),d.dispose()}},this._debounceInfo.get(t));this._sessionDisposables.add(r),this._sessionDisposables.add(jn(()=>n==null?void 0:n.dispose(!0))),r.schedule(0),this._sessionDisposables.add(this._editor.onDidScrollChange(a=>{(a.scrollTopChanged||!r.isScheduled())&&r.schedule()})),this._sessionDisposables.add(this._editor.onDidChangeModelContent(a=>{n==null||n.cancel();const d=Math.max(r.delay,1250);r.schedule(d)})),this._sessionDisposables.add(this._installDblClickGesture(()=>r.schedule(0))),this._sessionDisposables.add(this._installLinkGesture()),this._sessionDisposables.add(this._installContextMenu())}_installLinkGesture(){const e=new Lt,t=e.add(new Yy(this._editor)),i=new Lt;return e.add(i),e.add(t.onMouseMoveOrRelevantKeyDown(n=>{const[s]=n,r=this._getInlayHintLabelPart(s),a=this._editor.getModel();if(!r||!a){i.clear();return}const d=new Fs;i.add(jn(()=>d.dispose(!0))),r.item.resolve(d.token),this._activeInlayHintPart=r.part.command||r.part.location?new uz(r,s.hasTriggerModifier):void 0;const u=a.validatePosition(r.item.hint.position).lineNumber,f=new Z(u,1,u,a.getLineMaxColumn(u)),g=this._getInlineHintsForRange(f);this._updateHintsDecorators([f],g),i.add(jn(()=>{this._activeInlayHintPart=void 0,this._updateHintsDecorators([f],g)}))})),e.add(t.onCancel(()=>i.clear())),e.add(t.onExecute(async n=>{const s=this._getInlayHintLabelPart(n);if(s){const r=s.part;r.location?this._instaService.invokeFunction(LR,n,this._editor,r.location):N2.is(r.command)&&await this._invokeCommand(r.command,s.item)}})),e}_getInlineHintsForRange(e){const t=new Set;for(const i of this._decorationsMetadata.values())e.containsRange(i.item.anchor.range)&&t.add(i.item);return Array.from(t)}_installDblClickGesture(e){return this._editor.onMouseUp(async t=>{if(t.event.detail!==2)return;const i=this._getInlayHintLabelPart(t);if(i&&(t.event.preventDefault(),await i.item.resolve(Qi.None),$o(i.item.hint.textEdits))){const n=i.item.hint.textEdits.map(s=>Qn.replace(Z.lift(s.range),s.text));this._editor.executeEdits("inlayHint.default",n),e()}})}_installContextMenu(){return this._editor.onContextMenu(async e=>{if(!A2(e.event.target))return;const t=this._getInlayHintLabelPart(e);t&&await this._instaService.invokeFunction(cz,this._editor,e.event.target,t)})}_getInlayHintLabelPart(e){var i;if(e.target.type!==6)return;const t=(i=e.target.detail.injectedText)==null?void 0:i.options;if(t instanceof u0&&(t==null?void 0:t.attachedData)instanceof NC)return t.attachedData}async _invokeCommand(e,t){try{await this._commandService.executeCommand(e.id,...e.arguments??[])}catch(i){this._notificationService.notify({severity:d0.Error,source:t.provider.displayName,message:i})}}_cacheHintsForFastRestore(e){const t=this._copyInlayHintsWithCurrentAnchor(e);this._inlayHintsCache.set(e,t)}_copyInlayHintsWithCurrentAnchor(e){const t=new Map;for(const[i,n]of this._decorationsMetadata){if(t.has(n.item))continue;const s=e.getDecorationRange(i);if(s){const r=new gR(s,n.item.anchor.direction),a=n.item.with({anchor:r});t.set(n.item,a)}}return Array.from(t.values())}_getHintsRanges(){const t=this._editor.getModel(),i=this._editor.getVisibleRangesPlusViewportAboveBelow(),n=[];for(const s of i.sort(Z.compareRangesUsingStarts)){const r=t.validateRange(new Z(s.startLineNumber-30,s.startColumn,s.endLineNumber+30,s.endColumn));n.length===0||!Z.areIntersectingOrTouching(n[n.length-1],r)?n.push(r):n[n.length-1]=Z.plusRange(n[n.length-1],r)}return n}_updateHintsDecorators(e,t){var y,x;const i=[],n=(k,D,M,F,K)=>{const V={content:M,inlineClassNameAffectsLetterSpacing:!0,inlineClassName:D.className,cursorStops:F,attachedData:K};i.push({item:k,classNameRef:D,decoration:{range:k.anchor.range,options:{description:"InlayHint",showIfCollapsed:k.anchor.range.isEmpty(),collapseOnReplaceEdit:!k.anchor.range.isEmpty(),stickiness:0,[k.anchor.direction]:this._activeRenderMode===0?V:void 0}}})},s=(k,D)=>{const M=this._ruleFactory.createClassNameRef({width:`${r/3|0}px`,display:"inline-block"});n(k,M," ",D?kh.Right:kh.None)},{fontSize:r,fontFamily:a,padding:d,isUniform:u}=this._getLayoutInfo(),f="--code-editorInlayHintsFontFamily";this._editor.getContainerDomNode().style.setProperty(f,a);let g={line:0,totalLen:0};for(const k of t){if(g.line!==k.anchor.range.startLineNumber&&(g={line:k.anchor.range.startLineNumber,totalLen:0}),g.totalLen>yh._MAX_LABEL_LEN)continue;k.hint.paddingLeft&&s(k,!1);const D=typeof k.hint.label=="string"?[{label:k.hint.label}]:k.hint.label;for(let M=0;M<D.length;M++){const F=D[M],K=M===0,V=M===D.length-1,se={fontSize:`${r}px`,fontFamily:`var(${f}), ${o0.fontFamily}`,verticalAlign:u?"baseline":"middle",unicodeBidi:"isolate"};$o(k.hint.textEdits)&&(se.cursor="default"),this._fillInColors(se,k.hint),(F.command||F.location)&&((y=this._activeInlayHintPart)==null?void 0:y.part.item)===k&&this._activeInlayHintPart.part.index===M&&(se.textDecoration="underline",this._activeInlayHintPart.hasTriggerModifier&&(se.color=_s(O2),se.cursor="pointer")),d&&(K&&V?(se.padding=`1px ${Math.max(1,r/4)|0}px`,se.borderRadius=`${r/4|0}px`):K?(se.padding=`1px 0 1px ${Math.max(1,r/4)|0}px`,se.borderRadius=`${r/4|0}px 0 0 ${r/4|0}px`):V?(se.padding=`1px ${Math.max(1,r/4)|0}px 1px 0`,se.borderRadius=`0 ${r/4|0}px ${r/4|0}px 0`):se.padding="1px 0 1px 0");let te=F.label;g.totalLen+=te.length;let pe=!1;const je=g.totalLen-yh._MAX_LABEL_LEN;if(je>0&&(te=te.slice(0,-je)+"…",pe=!0),n(k,this._ruleFactory.createClassNameRef(se),hz(te),V&&!k.hint.paddingRight?kh.Right:kh.None,new NC(k,M)),pe)break}if(k.hint.paddingRight&&s(k,!0),i.length>yh._MAX_DECORATORS)break}const p=[];for(const[k,D]of this._decorationsMetadata){const M=(x=this._editor.getModel())==null?void 0:x.getDecorationRange(k);M&&e.some(F=>F.containsRange(M))&&(p.push(k),D.classNameRef.dispose(),this._decorationsMetadata.delete(k))}const w=pf.capture(this._editor);this._editor.changeDecorations(k=>{const D=k.deltaDecorations(p,i.map(M=>M.decoration));for(let M=0;M<D.length;M++){const F=i[M];this._decorationsMetadata.set(D[M],F)}}),w.restore(this._editor)}_fillInColors(e,t){t.kind===pL.Parameter?(e.backgroundColor=_s(F2),e.color=_s(H2)):t.kind===pL.Type?(e.backgroundColor=_s(W2),e.color=_s(B2)):(e.backgroundColor=_s(z2),e.color=_s(V2))}_getLayoutInfo(){const e=this._editor.getOption(142),t=e.padding,i=this._editor.getOption(52),n=this._editor.getOption(49);let s=e.fontSize;(!s||s<5||s>i)&&(s=i);const r=e.fontFamily||n;return{fontSize:s,fontFamily:r,padding:t,isUniform:!t&&r===n&&s===i}}_removeAllDecorations(){this._editor.removeDecorations(Array.from(this._decorationsMetadata.keys()));for(const e of this._decorationsMetadata.values())e.classNameRef.dispose();this._decorationsMetadata.clear()}},yh=gl,gl.ID="editor.contrib.InlayHints",gl._MAX_DECORATORS=1500,gl._MAX_LABEL_LEN=43,gl);Rp=yh=dz([oh(1,pi),oh(2,ur),oh(3,IR),oh(4,Es),oh(5,co),oh(6,Zi)],Rp);function hz(o){return o.replace(/[ \t]/g," ")}Wn.registerCommand("_executeInlayHintProvider",async(o,...e)=>{const[t,i]=e;Cn(Pn.isUri(t)),Cn(Z.isIRange(i));const{inlayHintsProvider:n}=o.get(pi),s=await o.get(ga).createModelReference(t);try{const r=await Lv.create(n,s.object.textEditorModel,[Z.lift(i)],Qi.None),a=r.items.map(d=>d.hint);return setTimeout(()=>r.dispose(),0),a}finally{s.dispose()}});var fz=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},$l=function(o,e){return function(t,i){e(t,i,o)}};class CI extends zm{constructor(e,t,i,n){super(10,t,e.item.anchor.range,i,n,!0),this.part=e}}let Mv=class extends Pp{constructor(e,t,i,n,s,r,a,d,u){super(e,t,i,r,d,n,s,u),this._resolverService=a,this.hoverOrdinal=6}suggestHoverAnchor(e){var n;if(!Rp.get(this._editor)||e.target.type!==6)return null;const i=(n=e.target.detail.injectedText)==null?void 0:n.options;return i instanceof u0&&i.attachedData instanceof NC?new CI(i.attachedData,this,e.event.posx,e.event.posy):null}computeSync(){return[]}computeAsync(e,t,i){return e instanceof CI?new oa(async n=>{const{part:s}=e;if(await s.item.resolve(i),i.isCancellationRequested)return;let r;typeof s.item.hint.tooltip=="string"?r=new to().appendText(s.item.hint.tooltip):s.item.hint.tooltip&&(r=s.item.hint.tooltip),r&&n.emitOne(new Tr(this,e.range,[r],!1,0)),$o(s.item.hint.textEdits)&&n.emitOne(new Tr(this,e.range,[new to().appendText(C("hint.dbl","Double-click to insert"))],!1,10001));let a;if(typeof s.part.tooltip=="string"?a=new to().appendText(s.part.tooltip):s.part.tooltip&&(a=s.part.tooltip),a&&n.emitOne(new Tr(this,e.range,[a],!1,1)),s.part.location||s.part.command){let u;const g=this._editor.getOption(78)==="altKey"?ja?C("links.navigate.kb.meta.mac","cmd + click"):C("links.navigate.kb.meta","ctrl + click"):ja?C("links.navigate.kb.alt.mac","option + click"):C("links.navigate.kb.alt","alt + click");s.part.location&&s.part.command?u=new to().appendText(C("hint.defAndCommand","Go to Definition ({0}), right click for more",g)):s.part.location?u=new to().appendText(C("hint.def","Go to Definition ({0})",g)):s.part.command&&(u=new to(`[${C("hint.cmd","Execute Command")}](${zB(s.part.command)} "${s.part.command.title}") (${g})`,{isTrusted:!0})),u&&n.emitOne(new Tr(this,e.range,[u],!1,1e4))}const d=await this._resolveInlayHintLabelPartHover(s,i);for await(const u of d)n.emitOne(u)}):oa.EMPTY}async _resolveInlayHintLabelPartHover(e,t){if(!e.part.location)return oa.EMPTY;const{uri:i,range:n}=e.part.location,s=await this._resolverService.createModelReference(i);try{const r=s.object.textEditorModel;return this._languageFeaturesService.hoverProvider.has(r)?Z0(this._languageFeaturesService.hoverProvider,r,new gi(n.startLineNumber,n.startColumn),t).filter(a=>!pp(a.hover.contents)).map(a=>new Tr(this,e.item.anchor.range,a.hover.contents,!1,2+a.ordinal)):oa.EMPTY}finally{s.dispose()}}};Mv=fz([$l(1,fa),$l(2,ua),$l(3,hs),$l(4,p_),$l(5,Un),$l(6,ga),$l(7,pi),$l(8,Es)],Mv);class tk extends Dt{constructor(e,t,i,n,s,r){super();const a=t.anchor,d=t.hoverParts;this._renderedHoverParts=this._register(new AC(e,i,d,r,s));const{showAtPosition:u,showAtSecondaryPosition:f}=tk.computeHoverPositions(e,a.range,d);this.shouldAppearBeforeContent=d.some(g=>g.isBeforeContent),this.showAtPosition=u,this.showAtSecondaryPosition=f,this.initialMousePosX=a.initialMousePosX,this.initialMousePosY=a.initialMousePosY,this.shouldFocus=n.shouldFocus,this.source=n.source}get domNode(){return this._renderedHoverParts.domNode}get domNodeHasChildren(){return this._renderedHoverParts.domNodeHasChildren}get focusedHoverPartIndex(){return this._renderedHoverParts.focusedHoverPartIndex}async updateHoverVerbosityLevel(e,t,i){this._renderedHoverParts.updateHoverVerbosityLevel(e,t,i)}isColorPickerVisible(){return this._renderedHoverParts.isColorPickerVisible()}static computeHoverPositions(e,t,i){let n=1;if(e.hasModel()){const f=e._getViewModel(),g=f.coordinatesConverter,p=g.convertModelRangeToViewRange(t),w=f.getLineMinColumn(p.startLineNumber),y=new gi(p.startLineNumber,w);n=g.convertViewPositionToModelPosition(y).column}const s=t.startLineNumber;let r=t.startColumn,a;for(const f of i){const g=f.range,p=g.startLineNumber===s,w=g.endLineNumber===s;if(p&&w){const x=g.startColumn,k=Math.min(r,x);r=Math.max(k,n)}f.forceShowAtRange&&(a=g)}let d,u;if(a){const f=a.getStartPosition();d=f,u=f}else d=t.getStartPosition(),u=new gi(s,r);return{showAtPosition:d,showAtSecondaryPosition:u}}}class gz{constructor(e,t){this._statusBar=t,e.appendChild(this._statusBar.hoverElement)}get hoverElement(){return this._statusBar.hoverElement}get actions(){return this._statusBar.actions}dispose(){this._statusBar.dispose()}}const Ab=class Ab extends Dt{constructor(e,t,i,n,s){super(),this._renderedParts=[],this._focusedHoverPartIndex=-1,this._context=s,this._fragment=document.createDocumentFragment(),this._register(this._renderParts(t,i,s,n)),this._register(this._registerListenersOnRenderedParts()),this._register(this._createEditorDecorations(e,i)),this._updateMarkdownAndColorParticipantInfo(t)}_createEditorDecorations(e,t){if(t.length===0)return Dt.None;let i=t[0].range;for(const s of t){const r=s.range;i=Z.plusRange(i,r)}const n=e.createDecorationsCollection();return n.set([{range:i,options:Ab._DECORATION_OPTIONS}]),jn(()=>{n.clear()})}_renderParts(e,t,i,n){const s=new kv(n),r={fragment:this._fragment,statusBar:s,...i},a=new Lt;for(const u of e){const f=this._renderHoverPartsForParticipant(t,u,r);a.add(f);for(const g of f.renderedHoverParts)this._renderedParts.push({type:"hoverPart",participant:u,hoverPart:g.hoverPart,hoverElement:g.hoverElement})}const d=this._renderStatusBar(this._fragment,s);return d&&(a.add(d),this._renderedParts.push({type:"statusBar",hoverElement:d.hoverElement,actions:d.actions})),jn(()=>{a.dispose()})}_renderHoverPartsForParticipant(e,t,i){const n=e.filter(r=>r.owner===t);return n.length>0?t.renderHoverParts(i,n):new Du([])}_renderStatusBar(e,t){if(t.hasContent)return new gz(e,t)}_registerListenersOnRenderedParts(){const e=new Lt;return this._renderedParts.forEach((t,i)=>{const n=t.hoverElement;n.tabIndex=0,e.add(wn(n,Zn.FOCUS_IN,s=>{s.stopPropagation(),this._focusedHoverPartIndex=i})),e.add(wn(n,Zn.FOCUS_OUT,s=>{s.stopPropagation(),this._focusedHoverPartIndex=-1}))}),e}_updateMarkdownAndColorParticipantInfo(e){const t=e.find(i=>i instanceof Pp&&!(i instanceof Mv));t&&(this._markdownHoverParticipant=t),this._colorHoverParticipant=e.find(i=>i instanceof Dp)}async updateHoverVerbosityLevel(e,t,i){if(!this._markdownHoverParticipant)return;const n=this._normalizedIndexToMarkdownHoverIndexRange(this._markdownHoverParticipant,t);if(n===void 0)return;const s=await this._markdownHoverParticipant.updateMarkdownHoverVerbosityLevel(e,n,i);s&&(this._renderedParts[t]={type:"hoverPart",participant:this._markdownHoverParticipant,hoverPart:s.hoverPart,hoverElement:s.hoverElement},this._context.onContentsChanged())}isColorPickerVisible(){var e;return((e=this._colorHoverParticipant)==null?void 0:e.isColorPickerVisible())??!1}_normalizedIndexToMarkdownHoverIndexRange(e,t){const i=this._renderedParts[t];if(!i||i.type!=="hoverPart"||!(i.participant===e))return;const s=this._renderedParts.findIndex(r=>r.type==="hoverPart"&&r.participant===e);if(s===-1)throw new bf;return t-s}get domNode(){return this._fragment}get domNodeHasChildren(){return this._fragment.hasChildNodes()}get focusedHoverPartIndex(){return this._focusedHoverPartIndex}};Ab._DECORATION_OPTIONS=dn.register({description:"content-hover-highlight",className:"hoverHighlight"});let AC=Ab;var pz=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},xI=function(o,e){return function(t,i){e(t,i,o)}};let OC=class extends Dt{constructor(e,t,i){super(),this._editor=e,this._instantiationService=t,this._keybindingService=i,this._currentResult=null,this._onContentsChanged=this._register(new Xi),this.onContentsChanged=this._onContentsChanged.event,this._contentHoverWidget=this._register(this._instantiationService.createInstance(SC,this._editor)),this._participants=this._initializeHoverParticipants(),this._computer=new xv(this._editor,this._participants),this._hoverOperation=this._register(new cR(this._editor,this._computer)),this._registerListeners()}_initializeHoverParticipants(){const e=[];for(const t of ju.getAll()){const i=this._instantiationService.createInstance(t,this._editor);e.push(i)}return e.sort((t,i)=>t.hoverOrdinal-i.hoverOrdinal),this._register(this._contentHoverWidget.onDidResize(()=>{this._participants.forEach(t=>{var i;return(i=t.handleResize)==null?void 0:i.call(t)})})),e}_registerListeners(){this._register(this._hoverOperation.onResult(t=>{if(!this._computer.anchor)return;const i=t.hasLoadingMessage?this._addLoadingMessage(t.value):t.value;this._withResult(new dR(this._computer.anchor,i,t.isComplete))}));const e=this._contentHoverWidget.getDomNode();this._register(Cl(e,"keydown",t=>{t.equals(9)&&this.hide()})),this._register(Cl(e,"mouseleave",t=>{this._onMouseLeave(t)})),this._register(Ey.onDidChange(()=>{this._contentHoverWidget.position&&this._currentResult&&this._setCurrentResult(this._currentResult)}))}_startShowingOrUpdateHover(e,t,i,n,s){if(!(this._contentHoverWidget.position&&this._currentResult))return e?(this._startHoverOperationIfNecessary(e,t,i,n,!1),!0):!1;const a=this._editor.getOption(60).sticky,d=s&&this._contentHoverWidget.isMouseGettingCloser(s.event.posx,s.event.posy);return a&&d?(e&&this._startHoverOperationIfNecessary(e,t,i,n,!0),!0):e?this._currentResult.anchor.equals(e)?!0:e.canAdoptVisibleHover(this._currentResult.anchor,this._contentHoverWidget.position)?(this._setCurrentResult(this._currentResult.filter(e)),this._startHoverOperationIfNecessary(e,t,i,n,!1),!0):(this._setCurrentResult(null),this._startHoverOperationIfNecessary(e,t,i,n,!1),!0):(this._setCurrentResult(null),!1)}_startHoverOperationIfNecessary(e,t,i,n,s){this._computer.anchor&&this._computer.anchor.equals(e)||(this._hoverOperation.cancel(),this._computer.anchor=e,this._computer.shouldFocus=n,this._computer.source=i,this._computer.insistOnKeepingHoverVisible=s,this._hoverOperation.start(t))}_setCurrentResult(e){let t=e;if(this._currentResult===t)return;t&&t.hoverParts.length===0&&(t=null),this._currentResult=t,this._currentResult?this._showHover(this._currentResult):this._hideHover()}_addLoadingMessage(e){if(!this._computer.anchor)return e;for(const t of this._participants){if(!t.createLoadingMessage)continue;const i=t.createLoadingMessage(this._computer.anchor);if(i)return e.slice(0).concat([i])}return e}_withResult(e){if(this._contentHoverWidget.position&&this._currentResult&&this._currentResult.isComplete||this._setCurrentResult(e),!e.isComplete)return;const n=e.hoverParts.length===0,s=this._computer.insistOnKeepingHoverVisible;n&&s||this._setCurrentResult(e)}_showHover(e){const t=this._getHoverContext();this._renderedContentHover=new tk(this._editor,e,this._participants,this._computer,t,this._keybindingService),this._renderedContentHover.domNodeHasChildren?this._contentHoverWidget.show(this._renderedContentHover):this._renderedContentHover.dispose()}_hideHover(){this._contentHoverWidget.hide()}_getHoverContext(){return{hide:()=>{this.hide()},onContentsChanged:()=>{this._onContentsChanged.fire(),this._contentHoverWidget.onContentsChanged()},setMinimumDimensions:n=>{this._contentHoverWidget.setMinimumDimensions(n)}}}showsOrWillShow(e){if(this._contentHoverWidget.isResizing)return!0;const i=this._findHoverAnchorCandidates(e);if(!(i.length>0))return this._startShowingOrUpdateHover(null,0,0,!1,e);const s=i[0];return this._startShowingOrUpdateHover(s,0,0,!1,e)}_findHoverAnchorCandidates(e){const t=[];for(const n of this._participants){if(!n.suggestHoverAnchor)continue;const s=n.suggestHoverAnchor(e);s&&t.push(s)}const i=e.target;switch(i.type){case 6:{t.push(new Vw(0,i.range,e.event.posx,e.event.posy));break}case 7:{const n=this._editor.getOption(50).typicalHalfwidthCharacterWidth/2;if(!(!i.detail.isAfterLines&&typeof i.detail.horizontalDistanceToText=="number"&&i.detail.horizontalDistanceToText<n))break;t.push(new Vw(0,i.range,e.event.posx,e.event.posy));break}}return t.sort((n,s)=>s.priority-n.priority),t}_onMouseLeave(e){const t=this._editor.getDomNode();(!t||!Zy(t,e.x,e.y))&&this.hide()}startShowingAtRange(e,t,i,n){this._startShowingOrUpdateHover(new Vw(0,e,void 0,void 0),t,i,n,null)}async updateHoverVerbosityLevel(e,t,i){var n;(n=this._renderedContentHover)==null||n.updateHoverVerbosityLevel(e,t,i)}focusedHoverPartIndex(){var e;return((e=this._renderedContentHover)==null?void 0:e.focusedHoverPartIndex)??-1}containsNode(e){return e?this._contentHoverWidget.getDomNode().contains(e):!1}focus(){this._contentHoverWidget.focus()}scrollUp(){this._contentHoverWidget.scrollUp()}scrollDown(){this._contentHoverWidget.scrollDown()}scrollLeft(){this._contentHoverWidget.scrollLeft()}scrollRight(){this._contentHoverWidget.scrollRight()}pageUp(){this._contentHoverWidget.pageUp()}pageDown(){this._contentHoverWidget.pageDown()}goToTop(){this._contentHoverWidget.goToTop()}goToBottom(){this._contentHoverWidget.goToBottom()}hide(){this._computer.anchor=null,this._hoverOperation.cancel(),this._setCurrentResult(null)}getDomNode(){return this._contentHoverWidget.getDomNode()}get isColorPickerVisible(){var e;return((e=this._renderedContentHover)==null?void 0:e.isColorPickerVisible())??!1}get isVisibleFromKeyboard(){return this._contentHoverWidget.isVisibleFromKeyboard}get isVisible(){return this._contentHoverWidget.isVisible}get isFocused(){return this._contentHoverWidget.isFocused}get isResizing(){return this._contentHoverWidget.isResizing}get widget(){return this._contentHoverWidget}};OC=pz([xI(1,Zi),xI(2,hs)],OC);var _z=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},kI=function(o,e){return function(t,i){e(t,i,o)}},FC,zd;let eo=(zd=class extends Dt{constructor(e,t,i){super(),this._editor=e,this._instantiationService=t,this._keybindingService=i,this._onHoverContentsChanged=this._register(new Xi),this.shouldKeepOpenOnEditorMouseMoveOrLeave=!1,this._listenersStore=new Lt,this._hoverState={mouseDown:!1,activatedByDecoratorClick:!1},this._reactToEditorMouseMoveRunner=this._register(new Ss(()=>this._reactToEditorMouseMove(this._mouseMoveEvent),0)),this._hookListeners(),this._register(this._editor.onDidChangeConfiguration(n=>{n.hasChanged(60)&&(this._unhookListeners(),this._hookListeners())}))}static get(e){return e.getContribution(FC.ID)}_hookListeners(){const e=this._editor.getOption(60);this._hoverSettings={enabled:e.enabled,sticky:e.sticky,hidingDelay:e.hidingDelay},e.enabled?(this._listenersStore.add(this._editor.onMouseDown(t=>this._onEditorMouseDown(t))),this._listenersStore.add(this._editor.onMouseUp(()=>this._onEditorMouseUp())),this._listenersStore.add(this._editor.onMouseMove(t=>this._onEditorMouseMove(t))),this._listenersStore.add(this._editor.onKeyDown(t=>this._onKeyDown(t)))):(this._listenersStore.add(this._editor.onMouseMove(t=>this._onEditorMouseMove(t))),this._listenersStore.add(this._editor.onKeyDown(t=>this._onKeyDown(t)))),this._listenersStore.add(this._editor.onMouseLeave(t=>this._onEditorMouseLeave(t))),this._listenersStore.add(this._editor.onDidChangeModel(()=>{this._cancelScheduler(),this._hideWidgets()})),this._listenersStore.add(this._editor.onDidChangeModelContent(()=>this._cancelScheduler())),this._listenersStore.add(this._editor.onDidScrollChange(t=>this._onEditorScrollChanged(t)))}_unhookListeners(){this._listenersStore.clear()}_cancelScheduler(){this._mouseMoveEvent=void 0,this._reactToEditorMouseMoveRunner.cancel()}_onEditorScrollChanged(e){(e.scrollTopChanged||e.scrollLeftChanged)&&this._hideWidgets()}_onEditorMouseDown(e){this._hoverState.mouseDown=!0,!this._shouldNotHideCurrentHoverWidget(e)&&this._hideWidgets()}_shouldNotHideCurrentHoverWidget(e){return this._isMouseOnContentHoverWidget(e)||this._isContentWidgetResizing()}_isMouseOnContentHoverWidget(e){var i;const t=(i=this._contentWidget)==null?void 0:i.getDomNode();return t?Zy(t,e.event.posx,e.event.posy):!1}_onEditorMouseUp(){this._hoverState.mouseDown=!1}_onEditorMouseLeave(e){this.shouldKeepOpenOnEditorMouseMoveOrLeave||(this._cancelScheduler(),this._shouldNotHideCurrentHoverWidget(e))||this._hideWidgets()}_shouldNotRecomputeCurrentHoverWidget(e){const t=this._hoverSettings.sticky,i=(r,a)=>{const d=this._isMouseOnContentHoverWidget(r);return a&&d},n=r=>{var u;const a=this._isMouseOnContentHoverWidget(r),d=((u=this._contentWidget)==null?void 0:u.isColorPickerVisible)??!1;return a&&d},s=(r,a)=>{var d,u,f,g;return(a&&((u=this._contentWidget)==null?void 0:u.containsNode((d=r.event.browserEvent.view)==null?void 0:d.document.activeElement))&&!((g=(f=r.event.browserEvent.view)==null?void 0:f.getSelection())!=null&&g.isCollapsed))??!1};return i(e,t)||n(e)||s(e,t)}_onEditorMouseMove(e){var a,d,u,f;if(this.shouldKeepOpenOnEditorMouseMoveOrLeave||(this._mouseMoveEvent=e,(a=this._contentWidget)!=null&&a.isFocused||(d=this._contentWidget)!=null&&d.isResizing))return;const t=this._hoverSettings.sticky;if(t&&((u=this._contentWidget)!=null&&u.isVisibleFromKeyboard))return;if(this._shouldNotRecomputeCurrentHoverWidget(e)){this._reactToEditorMouseMoveRunner.cancel();return}const n=this._hoverSettings.hidingDelay;if(((f=this._contentWidget)==null?void 0:f.isVisible)&&t&&n>0){this._reactToEditorMouseMoveRunner.isScheduled()||this._reactToEditorMouseMoveRunner.schedule(n);return}this._reactToEditorMouseMove(e)}_reactToEditorMouseMove(e){var d;if(!e)return;const i=(d=e.target.element)==null?void 0:d.classList.contains("colorpicker-color-decoration"),n=this._editor.getOption(149),s=this._hoverSettings.enabled,r=this._hoverState.activatedByDecoratorClick;if(i&&(n==="click"&&!r||n==="hover"&&!s||n==="clickAndHover"&&!s&&!r)||!i&&!s&&!r){this._hideWidgets();return}this._tryShowHoverWidget(e)||this._hideWidgets()}_tryShowHoverWidget(e){return this._getOrCreateContentWidget().showsOrWillShow(e)}_onKeyDown(e){var n;if(!this._editor.hasModel())return;const t=this._keybindingService.softDispatch(e,this._editor.getDomNode()),i=t.kind===1||t.kind===2&&(t.commandId===oR||t.commandId===Gy||t.commandId===Ky)&&((n=this._contentWidget)==null?void 0:n.isVisible);e.keyCode===5||e.keyCode===6||e.keyCode===57||e.keyCode===4||i||this._hideWidgets()}_hideWidgets(){var e,t;this._hoverState.mouseDown&&((e=this._contentWidget)!=null&&e.isColorPickerVisible)||Df.dropDownVisible||(this._hoverState.activatedByDecoratorClick=!1,(t=this._contentWidget)==null||t.hide())}_getOrCreateContentWidget(){return this._contentWidget||(this._contentWidget=this._instantiationService.createInstance(OC,this._editor),this._listenersStore.add(this._contentWidget.onContentsChanged(()=>this._onHoverContentsChanged.fire()))),this._contentWidget}showContentHover(e,t,i,n,s=!1){this._hoverState.activatedByDecoratorClick=s,this._getOrCreateContentWidget().startShowingAtRange(e,t,i,n)}_isContentWidgetResizing(){var e;return((e=this._contentWidget)==null?void 0:e.widget.isResizing)||!1}focusedHoverPartIndex(){return this._getOrCreateContentWidget().focusedHoverPartIndex()}updateHoverVerbosityLevel(e,t,i){this._getOrCreateContentWidget().updateHoverVerbosityLevel(e,t,i)}focus(){var e;(e=this._contentWidget)==null||e.focus()}scrollUp(){var e;(e=this._contentWidget)==null||e.scrollUp()}scrollDown(){var e;(e=this._contentWidget)==null||e.scrollDown()}scrollLeft(){var e;(e=this._contentWidget)==null||e.scrollLeft()}scrollRight(){var e;(e=this._contentWidget)==null||e.scrollRight()}pageUp(){var e;(e=this._contentWidget)==null||e.pageUp()}pageDown(){var e;(e=this._contentWidget)==null||e.pageDown()}goToTop(){var e;(e=this._contentWidget)==null||e.goToTop()}goToBottom(){var e;(e=this._contentWidget)==null||e.goToBottom()}get isColorPickerVisible(){var e;return(e=this._contentWidget)==null?void 0:e.isColorPickerVisible}get isHoverVisible(){var e;return(e=this._contentWidget)==null?void 0:e.isVisible}dispose(){var e;super.dispose(),this._unhookListeners(),this._listenersStore.dispose(),(e=this._contentWidget)==null||e.dispose()}},FC=zd,zd.ID="editor.contrib.contentHover",zd);eo=FC=_z([kI(1,Zi),kI(2,hs)],eo);const jk=class jk extends Dt{constructor(e){super(),this._editor=e,this._register(e.onMouseDown(t=>this.onMouseDown(t)))}dispose(){super.dispose()}onMouseDown(e){const t=this._editor.getOption(149);if(t!=="click"&&t!=="clickAndHover")return;const i=e.target;if(i.type!==6||!i.detail.injectedText||i.detail.injectedText.options.attachedData!==QM||!i.range)return;const n=this._editor.getContribution(eo.ID);if(n&&!n.isColorPickerVisible){const s=new Z(i.range.startLineNumber,i.range.startColumn+1,i.range.endLineNumber,i.range.endColumn+1);n.showContentHover(s,1,0,!1,!0)}}};jk.ID="editor.contrib.colorContribution";let Rv=jk;nn(Rv.ID,Rv,2);ju.register(Dp);var ER=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Th=function(o,e){return function(t,i){e(t,i,o)}},HC,WC,Vd;let Pu=(Vd=class extends Dt{constructor(e,t,i){super(),this._editor=e,this._instantiationService=i,this._standaloneColorPickerWidget=null,this._standaloneColorPickerVisible=B.standaloneColorPickerVisible.bindTo(t),this._standaloneColorPickerFocused=B.standaloneColorPickerFocused.bindTo(t)}showOrFocus(){var e;this._editor.hasModel()&&(this._standaloneColorPickerVisible.get()?this._standaloneColorPickerFocused.get()||(e=this._standaloneColorPickerWidget)==null||e.focus():this._standaloneColorPickerWidget=this._instantiationService.createInstance(BC,this._editor,this._standaloneColorPickerVisible,this._standaloneColorPickerFocused))}hide(){var e;this._standaloneColorPickerFocused.set(!1),this._standaloneColorPickerVisible.set(!1),(e=this._standaloneColorPickerWidget)==null||e.hide(),this._editor.focus()}insertColor(){var e;(e=this._standaloneColorPickerWidget)==null||e.updateEditor(),this.hide()}static get(e){return e.getContribution(HC.ID)}},HC=Vd,Vd.ID="editor.contrib.standaloneColorPickerController",Vd);Pu=HC=ER([Th(1,Sn),Th(2,Zi)],Pu);nn(Pu.ID,Pu,1);const LI=8,mz=22;var jd;let BC=(jd=class extends Dt{constructor(e,t,i,n,s,r,a){var g;super(),this._editor=e,this._standaloneColorPickerVisible=t,this._standaloneColorPickerFocused=i,this._keybindingService=s,this._languageFeaturesService=r,this._editorWorkerService=a,this.allowEditorOverflow=!0,this._position=void 0,this._body=document.createElement("div"),this._colorHover=null,this._selectionSetInEditor=!1,this._onResult=this._register(new Xi),this.onResult=this._onResult.event,this._standaloneColorPickerVisible.set(!0),this._standaloneColorPickerParticipant=n.createInstance(Tp,this._editor),this._position=(g=this._editor._getViewModel())==null?void 0:g.getPrimaryCursorState().modelState.position;const d=this._editor.getSelection(),u=d?{startLineNumber:d.startLineNumber,startColumn:d.startColumn,endLineNumber:d.endLineNumber,endColumn:d.endColumn}:{startLineNumber:0,endLineNumber:0,endColumn:0,startColumn:0},f=this._register(ff(this._body));this._register(f.onDidBlur(p=>{this.hide()})),this._register(f.onDidFocus(p=>{this.focus()})),this._register(this._editor.onDidChangeCursorPosition(()=>{this._selectionSetInEditor?this._selectionSetInEditor=!1:this.hide()})),this._register(this._editor.onMouseMove(p=>{var y;const w=(y=p.target.element)==null?void 0:y.classList;w&&w.contains("colorpicker-color-decoration")&&this.hide()})),this._register(this.onResult(p=>{this._render(p.value,p.foundInEditor)})),this._start(u),this._body.style.zIndex="50",this._editor.addContentWidget(this)}updateEditor(){this._colorHover&&this._standaloneColorPickerParticipant.updateEditorModel(this._colorHover)}getId(){return WC.ID}getDomNode(){return this._body}getPosition(){if(!this._position)return null;const e=this._editor.getOption(60).above;return{position:this._position,secondaryPosition:this._position,preference:e?[1,2]:[2,1],positionAffinity:2}}hide(){this.dispose(),this._standaloneColorPickerVisible.set(!1),this._standaloneColorPickerFocused.set(!1),this._editor.removeContentWidget(this),this._editor.focus()}focus(){this._standaloneColorPickerFocused.set(!0),this._body.focus()}async _start(e){const t=await this._computeAsync(e);t&&this._onResult.fire(new vz(t.result,t.foundInEditor))}async _computeAsync(e){if(!this._editor.hasModel())return null;const t={range:e,color:{red:0,green:0,blue:0,alpha:1}},i=await this._standaloneColorPickerParticipant.createColorHover(t,new Ep(this._editorWorkerService),this._languageFeaturesService.colorProvider);return i?{result:i.colorHover,foundInEditor:i.foundInEditor}:null}_render(e,t){const i=document.createDocumentFragment(),n=this._register(new kv(this._keybindingService)),s={fragment:i,statusBar:n,onContentsChanged:()=>{},hide:()=>this.hide()};this._colorHover=e;const r=this._standaloneColorPickerParticipant.renderHoverParts(s,[e]);if(!r)return;this._register(r.disposables);const a=r.colorPicker;this._body.classList.add("standalone-colorpicker-body"),this._body.style.maxHeight=Math.max(this._editor.getLayoutInfo().height/4,250)+"px",this._body.style.maxWidth=Math.max(this._editor.getLayoutInfo().width*.66,500)+"px",this._body.tabIndex=0,this._body.appendChild(i),a.layout();const d=a.body,u=d.saturationBox.domNode.clientWidth,f=d.domNode.clientWidth-u-mz-LI,g=a.body.enterButton;g==null||g.onClicked(()=>{this.updateEditor(),this.hide()});const p=a.header,w=p.pickedColorNode;w.style.width=u+LI+"px";const y=p.originalColorNode;y.style.width=f+"px";const x=a.header.closeButton;x==null||x.onClicked(()=>{this.hide()}),t&&(g&&(g.button.textContent="Replace"),this._selectionSetInEditor=!0,this._editor.setSelection(e.range)),this._editor.layoutContentWidget(this)}},WC=jd,jd.ID="editor.contrib.standaloneColorPickerWidget",jd);BC=WC=ER([Th(3,Zi),Th(4,hs),Th(5,pi),Th(6,Al)],BC);class vz{constructor(e,t){this.value=e,this.foundInEditor=t}}class bz extends ca{constructor(){super({id:"editor.action.showOrFocusStandaloneColorPicker",title:{...ui("showOrFocusStandaloneColorPicker","Show or Focus Standalone Color Picker"),mnemonicTitle:C({key:"mishowOrFocusStandaloneColorPicker",comment:["&& denotes a mnemonic"]},"&&Show or Focus Standalone Color Picker")},precondition:void 0,menu:[{id:Gt.CommandPalette}],metadata:{description:ui("showOrFocusStandaloneColorPickerDescription","Show or focus a standalone color picker which uses the default color provider. It displays hex/rgb/hsl colors.")}})}runEditorCommand(e,t){var i;(i=Pu.get(t))==null||i.showOrFocus()}}class yz extends lt{constructor(){super({id:"editor.action.hideColorPicker",label:C({key:"hideColorPicker",comment:["Action that hides the color picker"]},"Hide the Color Picker"),alias:"Hide the Color Picker",precondition:B.standaloneColorPickerVisible.isEqualTo(!0),kbOpts:{primary:9,weight:100},metadata:{description:ui("hideColorPickerDescription","Hide the standalone color picker.")}})}run(e,t){var i;(i=Pu.get(t))==null||i.hide()}}class wz extends lt{constructor(){super({id:"editor.action.insertColorWithStandaloneColorPicker",label:C({key:"insertColorWithStandaloneColorPicker",comment:["Action that inserts color with standalone color picker"]},"Insert Color with Standalone Color Picker"),alias:"Insert Color with Standalone Color Picker",precondition:B.standaloneColorPickerFocused.isEqualTo(!0),kbOpts:{primary:3,weight:100},metadata:{description:ui("insertColorWithStandaloneColorPickerDescription","Insert hex/rgb/hsl colors with the focused standalone color picker.")}})}run(e,t){var i;(i=Pu.get(t))==null||i.insertColor()}}xe(yz);xe(wz);Tn(bz);class ac{constructor(e,t,i){this.languageConfigurationService=i,this._selection=e,this._insertSpace=t,this._usedEndToken=null}static _haystackHasNeedleAtOffset(e,t,i){if(i<0)return!1;const n=t.length,s=e.length;if(i+n>s)return!1;for(let r=0;r<n;r++){const a=e.charCodeAt(i+r),d=t.charCodeAt(r);if(a!==d&&!(a>=65&&a<=90&&a+32===d)&&!(d>=65&&d<=90&&d+32===a))return!1}return!0}_createOperationsForBlockComment(e,t,i,n,s,r){const a=e.startLineNumber,d=e.startColumn,u=e.endLineNumber,f=e.endColumn,g=s.getLineContent(a),p=s.getLineContent(u);let w=g.lastIndexOf(t,d-1+t.length),y=p.indexOf(i,f-1-i.length);if(w!==-1&&y!==-1)if(a===u)g.substring(w+t.length,y).indexOf(i)>=0&&(w=-1,y=-1);else{const k=g.substring(w+t.length),D=p.substring(0,y);(k.indexOf(i)>=0||D.indexOf(i)>=0)&&(w=-1,y=-1)}let x;w!==-1&&y!==-1?(n&&w+t.length<g.length&&g.charCodeAt(w+t.length)===32&&(t=t+" "),n&&y>0&&p.charCodeAt(y-1)===32&&(i=" "+i,y-=1),x=ac._createRemoveBlockCommentOperations(new Z(a,w+t.length+1,u,y+1),t,i)):(x=ac._createAddBlockCommentOperations(e,t,i,this._insertSpace),this._usedEndToken=x.length===1?i:null);for(const k of x)r.addTrackedEditOperation(k.range,k.text)}static _createRemoveBlockCommentOperations(e,t,i){const n=[];return Z.isEmpty(e)?n.push(Qn.delete(new Z(e.startLineNumber,e.startColumn-t.length,e.endLineNumber,e.endColumn+i.length))):(n.push(Qn.delete(new Z(e.startLineNumber,e.startColumn-t.length,e.startLineNumber,e.startColumn))),n.push(Qn.delete(new Z(e.endLineNumber,e.endColumn,e.endLineNumber,e.endColumn+i.length)))),n}static _createAddBlockCommentOperations(e,t,i,n){const s=[];return Z.isEmpty(e)?s.push(Qn.replace(new Z(e.startLineNumber,e.startColumn,e.endLineNumber,e.endColumn),t+" "+i)):(s.push(Qn.insert(new gi(e.startLineNumber,e.startColumn),t+(n?" ":""))),s.push(Qn.insert(new gi(e.endLineNumber,e.endColumn),(n?" ":"")+i))),s}getEditOperations(e,t){const i=this._selection.startLineNumber,n=this._selection.startColumn;e.tokenization.tokenizeIfCheap(i);const s=e.getLanguageIdAtPosition(i,n),r=this.languageConfigurationService.getLanguageConfiguration(s).comments;!r||!r.blockCommentStartToken||!r.blockCommentEndToken||this._createOperationsForBlockComment(this._selection,r.blockCommentStartToken,r.blockCommentEndToken,this._insertSpace,e,t)}computeCursorState(e,t){const i=t.getInverseEditOperations();if(i.length===2){const n=i[0],s=i[1];return new Fi(n.range.endLineNumber,n.range.endColumn,s.range.startLineNumber,s.range.startColumn)}else{const n=i[0].range,s=this._usedEndToken?-this._usedEndToken.length-1:0;return new Fi(n.endLineNumber,n.endColumn+s,n.endLineNumber,n.endColumn+s)}}}class il{constructor(e,t,i,n,s,r,a){this.languageConfigurationService=e,this._selection=t,this._indentSize=i,this._type=n,this._insertSpace=s,this._selectionId=null,this._deltaColumn=0,this._moveEndPositionDown=!1,this._ignoreEmptyLines=r,this._ignoreFirstLine=a||!1}static _gatherPreflightCommentStrings(e,t,i,n){e.tokenization.tokenizeIfCheap(t);const s=e.getLanguageIdAtPosition(t,1),r=n.getLanguageConfiguration(s).comments,a=r?r.lineCommentToken:null;if(!a)return null;const d=[];for(let u=0,f=i-t+1;u<f;u++)d[u]={ignore:!1,commentStr:a,commentStrOffset:0,commentStrLength:a.length};return d}static _analyzeLines(e,t,i,n,s,r,a,d){let u=!0,f;e===0?f=!0:e===1?f=!1:f=!0;for(let g=0,p=n.length;g<p;g++){const w=n[g],y=s+g;if(y===s&&a){w.ignore=!0;continue}const x=i.getLineContent(y),k=kS(x);if(k===-1){w.ignore=r,w.commentStrOffset=x.length;continue}if(u=!1,w.ignore=!1,w.commentStrOffset=k,f&&!ac._haystackHasNeedleAtOffset(x,w.commentStr,k)&&(e===0?f=!1:e===1||(w.ignore=!0)),f&&t){const D=k+w.commentStrLength;D<x.length&&x.charCodeAt(D)===32&&(w.commentStrLength+=1)}}if(e===0&&u){f=!1;for(let g=0,p=n.length;g<p;g++)n[g].ignore=!1}return{supported:!0,shouldRemoveComments:f,lines:n}}static _gatherPreflightData(e,t,i,n,s,r,a,d){const u=il._gatherPreflightCommentStrings(i,n,s,d);return u===null?{supported:!1}:il._analyzeLines(e,t,i,u,n,r,a,d)}_executeLineComments(e,t,i,n){let s;i.shouldRemoveComments?s=il._createRemoveLineCommentsOperations(i.lines,n.startLineNumber):(il._normalizeInsertionPoint(e,i.lines,n.startLineNumber,this._indentSize),s=this._createAddLineCommentsOperations(i.lines,n.startLineNumber));const r=new gi(n.positionLineNumber,n.positionColumn);for(let a=0,d=s.length;a<d;a++)t.addEditOperation(s[a].range,s[a].text),Z.isEmpty(s[a].range)&&Z.getStartPosition(s[a].range).equals(r)&&e.getLineContent(r.lineNumber).length+1===r.column&&(this._deltaColumn=(s[a].text||"").length);this._selectionId=t.trackSelection(n)}_attemptRemoveBlockComment(e,t,i,n){let s=t.startLineNumber,r=t.endLineNumber;const a=n.length+Math.max(e.getLineFirstNonWhitespaceColumn(t.startLineNumber),t.startColumn);let d=e.getLineContent(s).lastIndexOf(i,a-1),u=e.getLineContent(r).indexOf(n,t.endColumn-1-i.length);return d!==-1&&u===-1&&(u=e.getLineContent(s).indexOf(n,d+i.length),r=s),d===-1&&u!==-1&&(d=e.getLineContent(r).lastIndexOf(i,u),s=r),t.isEmpty()&&(d===-1||u===-1)&&(d=e.getLineContent(s).indexOf(i),d!==-1&&(u=e.getLineContent(s).indexOf(n,d+i.length))),d!==-1&&e.getLineContent(s).charCodeAt(d+i.length)===32&&(i+=" "),u!==-1&&e.getLineContent(r).charCodeAt(u-1)===32&&(n=" "+n,u-=1),d!==-1&&u!==-1?ac._createRemoveBlockCommentOperations(new Z(s,d+i.length+1,r,u+1),i,n):null}_executeBlockComment(e,t,i){e.tokenization.tokenizeIfCheap(i.startLineNumber);const n=e.getLanguageIdAtPosition(i.startLineNumber,1),s=this.languageConfigurationService.getLanguageConfiguration(n).comments;if(!s||!s.blockCommentStartToken||!s.blockCommentEndToken)return;const r=s.blockCommentStartToken,a=s.blockCommentEndToken;let d=this._attemptRemoveBlockComment(e,i,r,a);if(!d){if(i.isEmpty()){const u=e.getLineContent(i.startLineNumber);let f=kS(u);f===-1&&(f=u.length),d=ac._createAddBlockCommentOperations(new Z(i.startLineNumber,f+1,i.startLineNumber,u.length+1),r,a,this._insertSpace)}else d=ac._createAddBlockCommentOperations(new Z(i.startLineNumber,e.getLineFirstNonWhitespaceColumn(i.startLineNumber),i.endLineNumber,e.getLineMaxColumn(i.endLineNumber)),r,a,this._insertSpace);d.length===1&&(this._deltaColumn=r.length+1)}this._selectionId=t.trackSelection(i);for(const u of d)t.addEditOperation(u.range,u.text)}getEditOperations(e,t){let i=this._selection;if(this._moveEndPositionDown=!1,i.startLineNumber===i.endLineNumber&&this._ignoreFirstLine){t.addEditOperation(new Z(i.startLineNumber,e.getLineMaxColumn(i.startLineNumber),i.startLineNumber+1,1),i.startLineNumber===e.getLineCount()?"":`
19
- `),this._selectionId=t.trackSelection(i);return}i.startLineNumber<i.endLineNumber&&i.endColumn===1&&(this._moveEndPositionDown=!0,i=i.setEndPosition(i.endLineNumber-1,e.getLineMaxColumn(i.endLineNumber-1)));const n=il._gatherPreflightData(this._type,this._insertSpace,e,i.startLineNumber,i.endLineNumber,this._ignoreEmptyLines,this._ignoreFirstLine,this.languageConfigurationService);return n.supported?this._executeLineComments(e,t,n,i):this._executeBlockComment(e,t,i)}computeCursorState(e,t){let i=t.getTrackedSelection(this._selectionId);return this._moveEndPositionDown&&(i=i.setEndPosition(i.endLineNumber+1,1)),new Fi(i.selectionStartLineNumber,i.selectionStartColumn+this._deltaColumn,i.positionLineNumber,i.positionColumn+this._deltaColumn)}static _createRemoveLineCommentsOperations(e,t){const i=[];for(let n=0,s=e.length;n<s;n++){const r=e[n];r.ignore||i.push(Qn.delete(new Z(t+n,r.commentStrOffset+1,t+n,r.commentStrOffset+r.commentStrLength+1)))}return i}_createAddLineCommentsOperations(e,t){const i=[],n=this._insertSpace?" ":"";for(let s=0,r=e.length;s<r;s++){const a=e[s];a.ignore||i.push(Qn.insert(new gi(t+s,a.commentStrOffset+1),a.commentStr+n))}return i}static nextVisibleColumn(e,t,i,n){return i?e+(t-e%t):e+n}static _normalizeInsertionPoint(e,t,i,n){let s=1073741824,r,a;for(let d=0,u=t.length;d<u;d++){if(t[d].ignore)continue;const f=e.getLineContent(i+d);let g=0;for(let p=0,w=t[d].commentStrOffset;g<s&&p<w;p++)g=il.nextVisibleColumn(g,n,f.charCodeAt(p)===9,1);g<s&&(s=g)}s=Math.floor(s/n)*n;for(let d=0,u=t.length;d<u;d++){if(t[d].ignore)continue;const f=e.getLineContent(i+d);let g=0;for(r=0,a=t[d].commentStrOffset;g<s&&r<a;r++)g=il.nextVisibleColumn(g,n,f.charCodeAt(r)===9,1);g>s?t[d].commentStrOffset=r-1:t[d].commentStrOffset=r}}}class ik extends lt{constructor(e,t){super(t),this._type=e}run(e,t){const i=e.get(Ds);if(!t.hasModel())return;const n=t.getModel(),s=[],r=n.getOptions(),a=t.getOption(23),d=t.getSelections().map((f,g)=>({selection:f,index:g,ignoreFirstLine:!1}));d.sort((f,g)=>Z.compareRangesUsingStarts(f.selection,g.selection));let u=d[0];for(let f=1;f<d.length;f++){const g=d[f];u.selection.endLineNumber===g.selection.startLineNumber&&(u.index<g.index?g.ignoreFirstLine=!0:(u.ignoreFirstLine=!0,u=g))}for(const f of d)s.push(new il(i,f.selection,r.indentSize,this._type,a.insertSpace,a.ignoreEmptyLines,f.ignoreFirstLine));t.pushUndoStop(),t.executeCommands(this.id,s),t.pushUndoStop()}}class Sz extends ik{constructor(){super(0,{id:"editor.action.commentLine",label:C("comment.line","Toggle Line Comment"),alias:"Toggle Line Comment",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:2138,weight:100},menuOpts:{menuId:Gt.MenubarEditMenu,group:"5_insert",title:C({key:"miToggleLineComment",comment:["&& denotes a mnemonic"]},"&&Toggle Line Comment"),order:1}})}}class Cz extends ik{constructor(){super(1,{id:"editor.action.addCommentLine",label:C("comment.line.add","Add Line Comment"),alias:"Add Line Comment",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2081),weight:100}})}}class xz extends ik{constructor(){super(2,{id:"editor.action.removeCommentLine",label:C("comment.line.remove","Remove Line Comment"),alias:"Remove Line Comment",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2099),weight:100}})}}class kz extends lt{constructor(){super({id:"editor.action.blockComment",label:C("comment.block","Toggle Block Comment"),alias:"Toggle Block Comment",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:1567,linux:{primary:3103},weight:100},menuOpts:{menuId:Gt.MenubarEditMenu,group:"5_insert",title:C({key:"miToggleBlockComment",comment:["&& denotes a mnemonic"]},"Toggle &&Block Comment"),order:2}})}run(e,t){const i=e.get(Ds);if(!t.hasModel())return;const n=t.getOption(23),s=[],r=t.getSelections();for(const a of r)s.push(new ac(a,n.insertSpace,i));t.pushUndoStop(),t.executeCommands(this.id,s),t.pushUndoStop()}}xe(Sz);xe(Cz);xe(xz);xe(kz);var Lz=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Qc=function(o,e){return function(t,i){e(t,i,o)}},zC,$d;let Pf=($d=class{static get(e){return e.getContribution(zC.ID)}constructor(e,t,i,n,s,r,a,d){this._contextMenuService=t,this._contextViewService=i,this._contextKeyService=n,this._keybindingService=s,this._menuService=r,this._configurationService=a,this._workspaceContextService=d,this._toDispose=new Lt,this._contextMenuIsBeingShownCount=0,this._editor=e,this._toDispose.add(this._editor.onContextMenu(u=>this._onContextMenu(u))),this._toDispose.add(this._editor.onMouseWheel(u=>{if(this._contextMenuIsBeingShownCount>0){const f=this._contextViewService.getContextViewElement(),g=u.srcElement;g.shadowRoot&&j2(f)===g.shadowRoot||this._contextViewService.hideContextView()}})),this._toDispose.add(this._editor.onKeyDown(u=>{this._editor.getOption(24)&&u.keyCode===58&&(u.preventDefault(),u.stopPropagation(),this.showContextMenu())}))}_onContextMenu(e){if(!this._editor.hasModel())return;if(!this._editor.getOption(24)){this._editor.focus(),e.target.position&&!this._editor.getSelection().containsPosition(e.target.position)&&this._editor.setPosition(e.target.position);return}if(e.target.type===12||e.target.type===6&&e.target.detail.injectedText)return;if(e.event.preventDefault(),e.event.stopPropagation(),e.target.type===11)return this._showScrollbarContextMenu(e.event);if(e.target.type!==6&&e.target.type!==7&&e.target.type!==1)return;if(this._editor.focus(),e.target.position){let i=!1;for(const n of this._editor.getSelections())if(n.containsPosition(e.target.position)){i=!0;break}i||this._editor.setPosition(e.target.position)}let t=null;e.target.type!==1&&(t=e.event),this.showContextMenu(t)}showContextMenu(e){if(!this._editor.getOption(24)||!this._editor.hasModel())return;const t=this._getMenuActions(this._editor.getModel(),this._editor.contextMenuId);t.length>0&&this._doShowContextMenu(t,e)}_getMenuActions(e,t){const i=[],n=this._menuService.getMenuActions(t,this._contextKeyService,{arg:e.uri});for(const s of n){const[,r]=s;let a=0;for(const d of r)if(d instanceof $2){const u=this._getMenuActions(e,d.item.submenu);u.length>0&&(i.push(new _L(d.id,d.label,u)),a++)}else i.push(d),a++;a&&i.push(new gp)}return i.length&&i.pop(),i}_doShowContextMenu(e,t=null){if(!this._editor.hasModel())return;const i=this._editor.getOption(60);this._editor.updateOptions({hover:{enabled:!1}});let n=t;if(!n){this._editor.revealPosition(this._editor.getPosition(),1),this._editor.render();const r=this._editor.getScrolledVisiblePosition(this._editor.getPosition()),a=mo(this._editor.getDomNode()),d=a.left+r.left,u=a.top+r.top+r.height;n={x:d,y:u}}const s=this._editor.getOption(128)&&!LS;this._contextMenuIsBeingShownCount++,this._contextMenuService.showContextMenu({domForShadowRoot:s?this._editor.getOverflowWidgetsDomNode()??this._editor.getDomNode():void 0,getAnchor:()=>n,getActions:()=>e,getActionViewItem:r=>{const a=this._keybindingFor(r);if(a)return new CS(r,r,{label:!0,keybinding:a.getLabel(),isMenu:!0});const d=r;return typeof d.getActionViewItem=="function"?d.getActionViewItem():new CS(r,r,{icon:!0,label:!0,isMenu:!0})},getKeyBinding:r=>this._keybindingFor(r),onHide:r=>{this._contextMenuIsBeingShownCount--,this._editor.updateOptions({hover:i})}})}_showScrollbarContextMenu(e){if(!this._editor.hasModel()||U2(this._workspaceContextService.getWorkspace()))return;const t=this._editor.getOption(73);let i=0;const n=u=>({id:`menu-action-${++i}`,label:u.label,tooltip:"",class:void 0,enabled:typeof u.enabled>"u"?!0:u.enabled,checked:u.checked,run:u.run}),s=(u,f)=>new _L(`menu-action-${++i}`,u,f,void 0),r=(u,f,g,p,w)=>{if(!f)return n({label:u,enabled:f,run:()=>{}});const y=k=>()=>{this._configurationService.updateValue(g,k)},x=[];for(const k of w)x.push(n({label:k.label,checked:p===k.value,run:y(k.value)}));return s(u,x)},a=[];a.push(n({label:C("context.minimap.minimap","Minimap"),checked:t.enabled,run:()=>{this._configurationService.updateValue("editor.minimap.enabled",!t.enabled)}})),a.push(new gp),a.push(n({label:C("context.minimap.renderCharacters","Render Characters"),enabled:t.enabled,checked:t.renderCharacters,run:()=>{this._configurationService.updateValue("editor.minimap.renderCharacters",!t.renderCharacters)}})),a.push(r(C("context.minimap.size","Vertical size"),t.enabled,"editor.minimap.size",t.size,[{label:C("context.minimap.size.proportional","Proportional"),value:"proportional"},{label:C("context.minimap.size.fill","Fill"),value:"fill"},{label:C("context.minimap.size.fit","Fit"),value:"fit"}])),a.push(r(C("context.minimap.slider","Slider"),t.enabled,"editor.minimap.showSlider",t.showSlider,[{label:C("context.minimap.slider.mouseover","Mouse Over"),value:"mouseover"},{label:C("context.minimap.slider.always","Always"),value:"always"}]));const d=this._editor.getOption(128)&&!LS;this._contextMenuIsBeingShownCount++,this._contextMenuService.showContextMenu({domForShadowRoot:d?this._editor.getDomNode():void 0,getAnchor:()=>e,getActions:()=>a,onHide:u=>{this._contextMenuIsBeingShownCount--,this._editor.focus()}})}_keybindingFor(e){return this._keybindingService.lookupKeybinding(e.id)}dispose(){this._contextMenuIsBeingShownCount>0&&this._contextViewService.hideContextView(),this._toDispose.dispose()}},zC=$d,$d.ID="editor.contrib.contextmenu",$d);Pf=zC=Lz([Qc(1,zf),Qc(2,wy),Qc(3,Sn),Qc(4,hs),Qc(5,Fu),Qc(6,Un),Qc(7,uf)],Pf);class Iz extends lt{constructor(){super({id:"editor.action.showContextMenu",label:C("action.showContextMenu.label","Show Editor Context Menu"),alias:"Show Editor Context Menu",precondition:void 0,kbOpts:{kbExpr:B.textInputFocus,primary:1092,weight:100}})}run(e,t){var i;(i=Pf.get(t))==null||i.showContextMenu()}}nn(Pf.ID,Pf,2);xe(Iz);class $w{constructor(e){this.selections=e}equals(e){const t=this.selections.length,i=e.selections.length;if(t!==i)return!1;for(let n=0;n<t;n++)if(!this.selections[n].equalsSelection(e.selections[n]))return!1;return!0}}class Uw{constructor(e,t,i){this.cursorState=e,this.scrollTop=t,this.scrollLeft=i}}const Ob=class Ob extends Dt{static get(e){return e.getContribution(Ob.ID)}constructor(e){super(),this._editor=e,this._isCursorUndoRedo=!1,this._undoStack=[],this._redoStack=[],this._register(e.onDidChangeModel(t=>{this._undoStack=[],this._redoStack=[]})),this._register(e.onDidChangeModelContent(t=>{this._undoStack=[],this._redoStack=[]})),this._register(e.onDidChangeCursorSelection(t=>{if(this._isCursorUndoRedo||!t.oldSelections||t.oldModelVersionId!==t.modelVersionId)return;const i=new $w(t.oldSelections);this._undoStack.length>0&&this._undoStack[this._undoStack.length-1].cursorState.equals(i)||(this._undoStack.push(new Uw(i,e.getScrollTop(),e.getScrollLeft())),this._redoStack=[],this._undoStack.length>50&&this._undoStack.shift())}))}cursorUndo(){!this._editor.hasModel()||this._undoStack.length===0||(this._redoStack.push(new Uw(new $w(this._editor.getSelections()),this._editor.getScrollTop(),this._editor.getScrollLeft())),this._applyState(this._undoStack.pop()))}cursorRedo(){!this._editor.hasModel()||this._redoStack.length===0||(this._undoStack.push(new Uw(new $w(this._editor.getSelections()),this._editor.getScrollTop(),this._editor.getScrollLeft())),this._applyState(this._redoStack.pop()))}_applyState(e){this._isCursorUndoRedo=!0,this._editor.setSelections(e.cursorState.selections),this._editor.setScrollPosition({scrollTop:e.scrollTop,scrollLeft:e.scrollLeft}),this._isCursorUndoRedo=!1}};Ob.ID="editor.contrib.cursorUndoRedoController";let Mf=Ob;class Ez extends lt{constructor(){super({id:"cursorUndo",label:C("cursor.undo","Cursor Undo"),alias:"Cursor Undo",precondition:void 0,kbOpts:{kbExpr:B.textInputFocus,primary:2099,weight:100}})}run(e,t,i){var n;(n=Mf.get(t))==null||n.cursorUndo()}}class Dz extends lt{constructor(){super({id:"cursorRedo",label:C("cursor.redo","Cursor Redo"),alias:"Cursor Redo",precondition:void 0})}run(e,t,i){var n;(n=Mf.get(t))==null||n.cursorRedo()}}nn(Mf.ID,Mf,0);xe(Ez);xe(Dz);class Tz{constructor(e,t,i){this.selection=e,this.targetPosition=t,this.copy=i,this.targetSelection=null}getEditOperations(e,t){const i=e.getValueInRange(this.selection);if(this.copy||t.addEditOperation(this.selection,null),t.addEditOperation(new Z(this.targetPosition.lineNumber,this.targetPosition.column,this.targetPosition.lineNumber,this.targetPosition.column),i),this.selection.containsPosition(this.targetPosition)&&!(this.copy&&(this.selection.getEndPosition().equals(this.targetPosition)||this.selection.getStartPosition().equals(this.targetPosition)))){this.targetSelection=this.selection;return}if(this.copy){this.targetSelection=new Fi(this.targetPosition.lineNumber,this.targetPosition.column,this.selection.endLineNumber-this.selection.startLineNumber+this.targetPosition.lineNumber,this.selection.startLineNumber===this.selection.endLineNumber?this.targetPosition.column+this.selection.endColumn-this.selection.startColumn:this.selection.endColumn);return}if(this.targetPosition.lineNumber>this.selection.endLineNumber){this.targetSelection=new Fi(this.targetPosition.lineNumber-this.selection.endLineNumber+this.selection.startLineNumber,this.targetPosition.column,this.targetPosition.lineNumber,this.selection.startLineNumber===this.selection.endLineNumber?this.targetPosition.column+this.selection.endColumn-this.selection.startColumn:this.selection.endColumn);return}if(this.targetPosition.lineNumber<this.selection.endLineNumber){this.targetSelection=new Fi(this.targetPosition.lineNumber,this.targetPosition.column,this.targetPosition.lineNumber+this.selection.endLineNumber-this.selection.startLineNumber,this.selection.startLineNumber===this.selection.endLineNumber?this.targetPosition.column+this.selection.endColumn-this.selection.startColumn:this.selection.endColumn);return}this.selection.endColumn<=this.targetPosition.column?this.targetSelection=new Fi(this.targetPosition.lineNumber-this.selection.endLineNumber+this.selection.startLineNumber,this.selection.startLineNumber===this.selection.endLineNumber?this.targetPosition.column-this.selection.endColumn+this.selection.startColumn:this.targetPosition.column-this.selection.endColumn+this.selection.startColumn,this.targetPosition.lineNumber,this.selection.startLineNumber===this.selection.endLineNumber?this.targetPosition.column:this.selection.endColumn):this.targetSelection=new Fi(this.targetPosition.lineNumber-this.selection.endLineNumber+this.selection.startLineNumber,this.targetPosition.column,this.targetPosition.lineNumber,this.targetPosition.column+this.selection.endColumn-this.selection.startColumn)}computeCursorState(e,t){return this.targetSelection}}function rh(o){return ja?o.altKey:o.ctrlKey}const Xl=class Xl extends Dt{constructor(e){super(),this._editor=e,this._dndDecorationIds=this._editor.createDecorationsCollection(),this._register(this._editor.onMouseDown(t=>this._onEditorMouseDown(t))),this._register(this._editor.onMouseUp(t=>this._onEditorMouseUp(t))),this._register(this._editor.onMouseDrag(t=>this._onEditorMouseDrag(t))),this._register(this._editor.onMouseDrop(t=>this._onEditorMouseDrop(t))),this._register(this._editor.onMouseDropCanceled(()=>this._onEditorMouseDropCanceled())),this._register(this._editor.onKeyDown(t=>this.onEditorKeyDown(t))),this._register(this._editor.onKeyUp(t=>this.onEditorKeyUp(t))),this._register(this._editor.onDidBlurEditorWidget(()=>this.onEditorBlur())),this._register(this._editor.onDidBlurEditorText(()=>this.onEditorBlur())),this._mouseDown=!1,this._modifierPressed=!1,this._dragSelection=null}onEditorBlur(){this._removeDecoration(),this._dragSelection=null,this._mouseDown=!1,this._modifierPressed=!1}onEditorKeyDown(e){!this._editor.getOption(35)||this._editor.getOption(22)||(rh(e)&&(this._modifierPressed=!0),this._mouseDown&&rh(e)&&this._editor.updateOptions({mouseStyle:"copy"}))}onEditorKeyUp(e){!this._editor.getOption(35)||this._editor.getOption(22)||(rh(e)&&(this._modifierPressed=!1),this._mouseDown&&e.keyCode===Xl.TRIGGER_KEY_VALUE&&this._editor.updateOptions({mouseStyle:"default"}))}_onEditorMouseDown(e){this._mouseDown=!0}_onEditorMouseUp(e){this._mouseDown=!1,this._editor.updateOptions({mouseStyle:"text"})}_onEditorMouseDrag(e){const t=e.target;if(this._dragSelection===null){const n=(this._editor.getSelections()||[]).filter(s=>t.position&&s.containsPosition(t.position));if(n.length===1)this._dragSelection=n[0];else return}rh(e.event)?this._editor.updateOptions({mouseStyle:"copy"}):this._editor.updateOptions({mouseStyle:"default"}),t.position&&(this._dragSelection.containsPosition(t.position)?this._removeDecoration():this.showAt(t.position))}_onEditorMouseDropCanceled(){this._editor.updateOptions({mouseStyle:"text"}),this._removeDecoration(),this._dragSelection=null,this._mouseDown=!1}_onEditorMouseDrop(e){if(e.target&&(this._hitContent(e.target)||this._hitMargin(e.target))&&e.target.position){const t=new gi(e.target.position.lineNumber,e.target.position.column);if(this._dragSelection===null){let i=null;if(e.event.shiftKey){const n=this._editor.getSelection();if(n){const{selectionStartLineNumber:s,selectionStartColumn:r}=n;i=[new Fi(s,r,t.lineNumber,t.column)]}}else i=(this._editor.getSelections()||[]).map(n=>n.containsPosition(t)?new Fi(t.lineNumber,t.column,t.lineNumber,t.column):n);this._editor.setSelections(i||[],"mouse",3)}else(!this._dragSelection.containsPosition(t)||(rh(e.event)||this._modifierPressed)&&(this._dragSelection.getEndPosition().equals(t)||this._dragSelection.getStartPosition().equals(t)))&&(this._editor.pushUndoStop(),this._editor.executeCommand(Xl.ID,new Tz(this._dragSelection,t,rh(e.event)||this._modifierPressed)),this._editor.pushUndoStop())}this._editor.updateOptions({mouseStyle:"text"}),this._removeDecoration(),this._dragSelection=null,this._mouseDown=!1}showAt(e){this._dndDecorationIds.set([{range:new Z(e.lineNumber,e.column,e.lineNumber,e.column),options:Xl._DECORATION_OPTIONS}]),this._editor.revealPosition(e,1)}_removeDecoration(){this._dndDecorationIds.clear()}_hitContent(e){return e.type===6||e.type===7}_hitMargin(e){return e.type===2||e.type===3||e.type===4}dispose(){this._removeDecoration(),this._dragSelection=null,this._mouseDown=!1,this._modifierPressed=!1,super.dispose()}};Xl.ID="editor.contrib.dragAndDrop",Xl.TRIGGER_KEY_VALUE=ja?6:5,Xl._DECORATION_OPTIONS=dn.register({description:"dnd-target",className:"dnd-target"});let Nv=Xl;nn(Nv.ID,Nv,2);nn(Il.ID,Il,0);$f(iC);bi(new class extends wo{constructor(){super({id:PM,precondition:V0,kbOpts:{weight:100,primary:2137}})}runEditorCommand(o,e){var t;return(t=Il.get(e))==null?void 0:t.changePasteType()}});bi(new class extends wo{constructor(){super({id:"editor.hidePasteWidget",precondition:V0,kbOpts:{weight:100,primary:9}})}runEditorCommand(o,e){var t;(t=Il.get(e))==null||t.clearWidgets()}});var Ud;xe((Ud=class extends lt{constructor(){super({id:"editor.action.pasteAs",label:C("pasteAs","Paste As..."),alias:"Paste As...",precondition:B.writable,metadata:{description:"Paste as",args:[{name:"args",schema:Ud.argsSchema}]}})}run(e,t,i){var s;let n=typeof(i==null?void 0:i.kind)=="string"?i.kind:void 0;return!n&&i&&(n=typeof i.id=="string"?i.id:void 0),(s=Il.get(t))==null?void 0:s.pasteAs(n?new $n(n):void 0)}},Ud.argsSchema={type:"object",properties:{kind:{type:"string",description:C("pasteAs.kind","The kind of the paste edit to try applying. If not provided or there are multiple edits for this kind, the editor will show a picker.")}}},Ud));xe(class extends lt{constructor(){super({id:"editor.action.pasteAsText",label:C("pasteAsText","Paste as Text"),alias:"Paste as Text",precondition:B.writable})}run(o,e){var t;return(t=Il.get(e))==null?void 0:t.pasteAs({providerId:xu.id})}});class Pz{constructor(){this._dragOperations=new Map}removeDragOperationTransfer(e){if(e&&this._dragOperations.has(e)){const t=this._dragOperations.get(e);return this._dragOperations.delete(e),t}}}class II{constructor(e){this.identifier=e}}const DR=Rl("treeViewsDndService");Nl(DR,Pz,1);var Mz=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},sm=function(o,e){return function(t,i){e(t,i,o)}},VC;const TR="editor.experimental.dropIntoEditor.defaultProvider",PR="editor.changeDropType",nk=new _n("dropWidgetVisible",!1,C("dropWidgetVisible","Whether the drop widget is showing"));var qd;let Rf=(qd=class extends Dt{static get(e){return e.getContribution(VC.ID)}constructor(e,t,i,n,s){super(),this._configService=i,this._languageFeaturesService=n,this._treeViewsDragAndDropService=s,this.treeItemsTransfer=eC.getInstance(),this._dropProgressManager=this._register(t.createInstance(wv,"dropIntoEditor",e)),this._postDropWidgetManager=this._register(t.createInstance(Cv,"dropIntoEditor",e,nk,{id:PR,label:C("postDropWidgetTitle","Show drop options...")})),this._register(e.onDropIntoEditor(r=>this.onDropIntoEditor(e,r.position,r.event)))}clearWidgets(){this._postDropWidgetManager.clear()}changeDropType(){this._postDropWidgetManager.tryShowSelector()}async onDropIntoEditor(e,t,i){var s;if(!i.dataTransfer||!e.hasModel())return;(s=this._currentOperation)==null||s.cancel(),e.focus(),e.setPosition(t);const n=Os(async r=>{const a=new Lt,d=a.add(new hf(e,1,void 0,r));try{const u=await this.extractDataTransferData(i);if(u.size===0||d.token.isCancellationRequested)return;const f=e.getModel();if(!f)return;const g=this._languageFeaturesService.documentDropEditProvider.ordered(f).filter(w=>w.dropMimeTypes?w.dropMimeTypes.some(y=>u.matches(y)):!0),p=a.add(await this.getDropEdits(g,f,t,u,d));if(d.token.isCancellationRequested)return;if(p.edits.length){const w=this.getInitialActiveEditIndex(f,p.edits),y=e.getOption(36).showDropSelector==="afterDrop";await this._postDropWidgetManager.applyEditAndShowIfNeeded([Z.fromPositions(t)],{activeEditIndex:w,allEdits:p.edits},y,async x=>x,r)}}finally{a.dispose(),this._currentOperation===n&&(this._currentOperation=void 0)}});this._dropProgressManager.showWhile(t,C("dropIntoEditorProgress","Running drop handlers. Click to cancel"),n,{cancel:()=>n.cancel()}),this._currentOperation=n}async getDropEdits(e,t,i,n,s){const r=new Lt,a=await a_(Promise.all(e.map(async u=>{try{const f=await u.provideDocumentDropEdits(t,i,n,s.token);return f&&r.add(f),f==null?void 0:f.edits.map(g=>({...g,providerId:u.id}))}catch(f){console.error(f)}})),s.token),d=wl(a??[]).flat();return{edits:DM(d),dispose:()=>r.dispose()}}getInitialActiveEditIndex(e,t){const i=this._configService.getValue(TR,{resource:e.uri});for(const[n,s]of Object.entries(i)){const r=new $n(s),a=t.findIndex(d=>r.value===d.providerId&&d.handledMimeType&&yM(n,[d.handledMimeType]));if(a>=0)return a}return 0}async extractDataTransferData(e){if(!e.dataTransfer)return new bM;const t=CM(e.dataTransfer);if(this.treeItemsTransfer.hasData(II.prototype)){const i=this.treeItemsTransfer.getData(II.prototype);if(Array.isArray(i))for(const n of i){const s=await this._treeViewsDragAndDropService.removeDragOperationTransfer(n.identifier);if(s)for(const[r,a]of s)t.replace(r,a)}}return t}},VC=qd,qd.ID="editor.contrib.dropIntoEditorController",qd);Rf=VC=Mz([sm(1,Zi),sm(2,Un),sm(3,pi),sm(4,DR)],Rf);nn(Rf.ID,Rf,2);$f(tC);bi(new class extends wo{constructor(){super({id:PR,precondition:nk,kbOpts:{weight:100,primary:2137}})}runEditorCommand(o,e,t){var i;(i=Rf.get(e))==null||i.changeDropType()}});bi(new class extends wo{constructor(){super({id:"editor.hideDropWidget",precondition:nk,kbOpts:{weight:100,primary:9}})}runEditorCommand(o,e,t){var i;(i=Rf.get(e))==null||i.clearWidgets()}});da.as(d_.Configuration).registerConfiguration({...Cy,properties:{[TR]:{type:"object",scope:5,description:C("defaultProviderDescription","Configures the default drop provider to use for content of a given mime type."),default:{},additionalProperties:{type:"string"}}}});const Qs=class Qs{constructor(e){this._editor=e,this._decorations=[],this._overviewRulerApproximateDecorations=[],this._findScopeDecorationIds=[],this._rangeHighlightDecorationId=null,this._highlightedDecorationId=null,this._startPosition=this._editor.getPosition()}dispose(){this._editor.removeDecorations(this._allDecorations()),this._decorations=[],this._overviewRulerApproximateDecorations=[],this._findScopeDecorationIds=[],this._rangeHighlightDecorationId=null,this._highlightedDecorationId=null}reset(){this._decorations=[],this._overviewRulerApproximateDecorations=[],this._findScopeDecorationIds=[],this._rangeHighlightDecorationId=null,this._highlightedDecorationId=null}getCount(){return this._decorations.length}getFindScope(){return this._findScopeDecorationIds[0]?this._editor.getModel().getDecorationRange(this._findScopeDecorationIds[0]):null}getFindScopes(){if(this._findScopeDecorationIds.length){const e=this._findScopeDecorationIds.map(t=>this._editor.getModel().getDecorationRange(t)).filter(t=>!!t);if(e.length)return e}return null}getStartPosition(){return this._startPosition}setStartPosition(e){this._startPosition=e,this.setCurrentFindMatch(null)}_getDecorationIndex(e){const t=this._decorations.indexOf(e);return t>=0?t+1:1}getDecorationRangeAt(e){const t=e<this._decorations.length?this._decorations[e]:null;return t?this._editor.getModel().getDecorationRange(t):null}getCurrentMatchesPosition(e){const t=this._editor.getModel().getDecorationsInRange(e);for(const i of t){const n=i.options;if(n===Qs._FIND_MATCH_DECORATION||n===Qs._CURRENT_FIND_MATCH_DECORATION)return this._getDecorationIndex(i.id)}return 0}setCurrentFindMatch(e){let t=null,i=0;if(e)for(let n=0,s=this._decorations.length;n<s;n++){const r=this._editor.getModel().getDecorationRange(this._decorations[n]);if(e.equalsRange(r)){t=this._decorations[n],i=n+1;break}}return(this._highlightedDecorationId!==null||t!==null)&&this._editor.changeDecorations(n=>{if(this._highlightedDecorationId!==null&&(n.changeDecorationOptions(this._highlightedDecorationId,Qs._FIND_MATCH_DECORATION),this._highlightedDecorationId=null),t!==null&&(this._highlightedDecorationId=t,n.changeDecorationOptions(this._highlightedDecorationId,Qs._CURRENT_FIND_MATCH_DECORATION)),this._rangeHighlightDecorationId!==null&&(n.removeDecoration(this._rangeHighlightDecorationId),this._rangeHighlightDecorationId=null),t!==null){let s=this._editor.getModel().getDecorationRange(t);if(s.startLineNumber!==s.endLineNumber&&s.endColumn===1){const r=s.endLineNumber-1,a=this._editor.getModel().getLineMaxColumn(r);s=new Z(s.startLineNumber,s.startColumn,r,a)}this._rangeHighlightDecorationId=n.addDecoration(s,Qs._RANGE_HIGHLIGHT_DECORATION)}}),i}set(e,t){this._editor.changeDecorations(i=>{let n=Qs._FIND_MATCH_DECORATION;const s=[];if(e.length>1e3){n=Qs._FIND_MATCH_NO_OVERVIEW_DECORATION;const a=this._editor.getModel().getLineCount(),u=this._editor.getLayoutInfo().height/a,f=Math.max(2,Math.ceil(3/u));let g=e[0].range.startLineNumber,p=e[0].range.endLineNumber;for(let w=1,y=e.length;w<y;w++){const x=e[w].range;p+f>=x.startLineNumber?x.endLineNumber>p&&(p=x.endLineNumber):(s.push({range:new Z(g,1,p,1),options:Qs._FIND_MATCH_ONLY_OVERVIEW_DECORATION}),g=x.startLineNumber,p=x.endLineNumber)}s.push({range:new Z(g,1,p,1),options:Qs._FIND_MATCH_ONLY_OVERVIEW_DECORATION})}const r=new Array(e.length);for(let a=0,d=e.length;a<d;a++)r[a]={range:e[a].range,options:n};this._decorations=i.deltaDecorations(this._decorations,r),this._overviewRulerApproximateDecorations=i.deltaDecorations(this._overviewRulerApproximateDecorations,s),this._rangeHighlightDecorationId&&(i.removeDecoration(this._rangeHighlightDecorationId),this._rangeHighlightDecorationId=null),this._findScopeDecorationIds.length&&(this._findScopeDecorationIds.forEach(a=>i.removeDecoration(a)),this._findScopeDecorationIds=[]),t!=null&&t.length&&(this._findScopeDecorationIds=t.map(a=>i.addDecoration(a,Qs._FIND_SCOPE_DECORATION)))})}matchBeforePosition(e){if(this._decorations.length===0)return null;for(let t=this._decorations.length-1;t>=0;t--){const i=this._decorations[t],n=this._editor.getModel().getDecorationRange(i);if(!(!n||n.endLineNumber>e.lineNumber)){if(n.endLineNumber<e.lineNumber)return n;if(!(n.endColumn>e.column))return n}}return this._editor.getModel().getDecorationRange(this._decorations[this._decorations.length-1])}matchAfterPosition(e){if(this._decorations.length===0)return null;for(let t=0,i=this._decorations.length;t<i;t++){const n=this._decorations[t],s=this._editor.getModel().getDecorationRange(n);if(!(!s||s.startLineNumber<e.lineNumber)){if(s.startLineNumber>e.lineNumber)return s;if(!(s.startColumn<e.column))return s}}return this._editor.getModel().getDecorationRange(this._decorations[0])}_allDecorations(){let e=[];return e=e.concat(this._decorations),e=e.concat(this._overviewRulerApproximateDecorations),this._findScopeDecorationIds.length&&e.push(...this._findScopeDecorationIds),this._rangeHighlightDecorationId&&e.push(this._rangeHighlightDecorationId),e}};Qs._CURRENT_FIND_MATCH_DECORATION=dn.register({description:"current-find-match",stickiness:1,zIndex:13,className:"currentFindMatch",inlineClassName:"currentFindMatchInline",showIfCollapsed:!0,overviewRuler:{color:_s(Cw),position:Ha.Center},minimap:{color:_s(mL),position:1}}),Qs._FIND_MATCH_DECORATION=dn.register({description:"find-match",stickiness:1,zIndex:10,className:"findMatch",inlineClassName:"findMatchInline",showIfCollapsed:!0,overviewRuler:{color:_s(Cw),position:Ha.Center},minimap:{color:_s(mL),position:1}}),Qs._FIND_MATCH_NO_OVERVIEW_DECORATION=dn.register({description:"find-match-no-overview",stickiness:1,className:"findMatch",showIfCollapsed:!0}),Qs._FIND_MATCH_ONLY_OVERVIEW_DECORATION=dn.register({description:"find-match-only-overview",stickiness:1,overviewRuler:{color:_s(Cw),position:Ha.Center}}),Qs._RANGE_HIGHLIGHT_DECORATION=dn.register({description:"find-range-highlight",stickiness:1,className:"rangeHighlight",isWholeLine:!0}),Qs._FIND_SCOPE_DECORATION=dn.register({description:"find-scope",className:"findScope",isWholeLine:!0});let jC=Qs;class Rz{constructor(e,t,i){this._editorSelection=e,this._ranges=t,this._replaceStrings=i,this._trackedEditorSelectionId=null}getEditOperations(e,t){if(this._ranges.length>0){const i=[];for(let r=0;r<this._ranges.length;r++)i.push({range:this._ranges[r],text:this._replaceStrings[r]});i.sort((r,a)=>Z.compareRangesUsingStarts(r.range,a.range));const n=[];let s=i[0];for(let r=1;r<i.length;r++)s.range.endLineNumber===i[r].range.startLineNumber&&s.range.endColumn===i[r].range.startColumn?(s.range=s.range.plusRange(i[r].range),s.text=s.text+i[r].text):(n.push(s),s=i[r]);n.push(s);for(const r of n)t.addEditOperation(r.range,r.text)}this._trackedEditorSelectionId=t.trackSelection(this._editorSelection)}computeCursorState(e,t){return t.getTrackedSelection(this._trackedEditorSelectionId)}}function MR(o,e){if(o&&o[0]!==""){const t=EI(o,e,"-"),i=EI(o,e,"_");return t&&!i?DI(o,e,"-"):!t&&i?DI(o,e,"_"):o[0].toUpperCase()===o[0]?e.toUpperCase():o[0].toLowerCase()===o[0]?e.toLowerCase():q2(o[0][0])&&e.length>0?e[0].toUpperCase()+e.substr(1):o[0][0].toUpperCase()!==o[0][0]&&e.length>0?e[0].toLowerCase()+e.substr(1):e}else return e}function EI(o,e,t){return o[0].indexOf(t)!==-1&&e.indexOf(t)!==-1&&o[0].split(t).length===e.split(t).length}function DI(o,e,t){const i=e.split(t),n=o[0].split(t);let s="";return i.forEach((r,a)=>{s+=MR([n[a]],r)+t}),s.slice(0,-1)}class TI{constructor(e){this.staticValue=e,this.kind=0}}class Nz{constructor(e){this.pieces=e,this.kind=1}}class Nf{static fromStaticValue(e){return new Nf([Id.staticValue(e)])}get hasReplacementPatterns(){return this._state.kind===1}constructor(e){!e||e.length===0?this._state=new TI(""):e.length===1&&e[0].staticValue!==null?this._state=new TI(e[0].staticValue):this._state=new Nz(e)}buildReplaceString(e,t){if(this._state.kind===0)return t?MR(e,this._state.staticValue):this._state.staticValue;let i="";for(let n=0,s=this._state.pieces.length;n<s;n++){const r=this._state.pieces[n];if(r.staticValue!==null){i+=r.staticValue;continue}let a=Nf._substitute(r.matchIndex,e);if(r.caseOps!==null&&r.caseOps.length>0){const d=[],u=r.caseOps.length;let f=0;for(let g=0,p=a.length;g<p;g++){if(f>=u){d.push(a.slice(g));break}switch(r.caseOps[f]){case"U":d.push(a[g].toUpperCase());break;case"u":d.push(a[g].toUpperCase()),f++;break;case"L":d.push(a[g].toLowerCase());break;case"l":d.push(a[g].toLowerCase()),f++;break;default:d.push(a[g])}}a=d.join("")}i+=a}return i}static _substitute(e,t){if(t===null)return"";if(e===0)return t[0];let i="";for(;e>0;){if(e<t.length)return(t[e]||"")+i;i=String(e%10)+i,e=Math.floor(e/10)}return"$"+i}}class Id{static staticValue(e){return new Id(e,-1,null)}static caseOps(e,t){return new Id(null,e,t)}constructor(e,t,i){this.staticValue=e,this.matchIndex=t,!i||i.length===0?this.caseOps=null:this.caseOps=i.slice(0)}}class Az{constructor(e){this._source=e,this._lastCharIndex=0,this._result=[],this._resultLen=0,this._currentStaticPiece=""}emitUnchanged(e){this._emitStatic(this._source.substring(this._lastCharIndex,e)),this._lastCharIndex=e}emitStatic(e,t){this._emitStatic(e),this._lastCharIndex=t}_emitStatic(e){e.length!==0&&(this._currentStaticPiece+=e)}emitMatchIndex(e,t,i){this._currentStaticPiece.length!==0&&(this._result[this._resultLen++]=Id.staticValue(this._currentStaticPiece),this._currentStaticPiece=""),this._result[this._resultLen++]=Id.caseOps(e,i),this._lastCharIndex=t}finalize(){return this.emitUnchanged(this._source.length),this._currentStaticPiece.length!==0&&(this._result[this._resultLen++]=Id.staticValue(this._currentStaticPiece),this._currentStaticPiece=""),new Nf(this._result)}}function Oz(o){if(!o||o.length===0)return new Nf(null);const e=[],t=new Az(o);for(let i=0,n=o.length;i<n;i++){const s=o.charCodeAt(i);if(s===92){if(i++,i>=n)break;const r=o.charCodeAt(i);switch(r){case 92:t.emitUnchanged(i-1),t.emitStatic("\\",i+1);break;case 110:t.emitUnchanged(i-1),t.emitStatic(`
20
- `,i+1);break;case 116:t.emitUnchanged(i-1),t.emitStatic(" ",i+1);break;case 117:case 85:case 108:case 76:t.emitUnchanged(i-1),t.emitStatic("",i+1),e.push(String.fromCharCode(r));break}continue}if(s===36){if(i++,i>=n)break;const r=o.charCodeAt(i);if(r===36){t.emitUnchanged(i-1),t.emitStatic("$",i+1);continue}if(r===48||r===38){t.emitUnchanged(i-1),t.emitMatchIndex(0,i+1,e),e.length=0;continue}if(49<=r&&r<=57){let a=r-48;if(i+1<n){const d=o.charCodeAt(i+1);if(48<=d&&d<=57){i++,a=a*10+(d-48),t.emitUnchanged(i-2),t.emitMatchIndex(a,i+1,e),e.length=0;continue}}t.emitUnchanged(i-1),t.emitMatchIndex(a,i+1,e),e.length=0;continue}}}return t.finalize()}const Hl=new _n("findWidgetVisible",!1);Hl.toNegated();const ew=new _n("findInputFocussed",!1),sk=new _n("replaceInputFocussed",!1),om={primary:545,mac:{primary:2593}},rm={primary:565,mac:{primary:2613}},am={primary:560,mac:{primary:2608}},lm={primary:554,mac:{primary:2602}},cm={primary:558,mac:{primary:2606}},Rn={StartFindAction:"actions.find",StartFindWithSelection:"actions.findWithSelection",StartFindWithArgs:"editor.actions.findWithArgs",NextMatchFindAction:"editor.action.nextMatchFindAction",PreviousMatchFindAction:"editor.action.previousMatchFindAction",GoToMatchFindAction:"editor.action.goToMatchFindAction",NextSelectionMatchFindAction:"editor.action.nextSelectionMatchFindAction",PreviousSelectionMatchFindAction:"editor.action.previousSelectionMatchFindAction",StartFindReplaceAction:"editor.action.startFindReplaceAction",CloseFindWidgetCommand:"closeFindWidget",ToggleCaseSensitiveCommand:"toggleFindCaseSensitive",ToggleWholeWordCommand:"toggleFindWholeWord",ToggleRegexCommand:"toggleFindRegex",ToggleSearchScopeCommand:"toggleFindInSelection",TogglePreserveCaseCommand:"togglePreserveCase",ReplaceOneAction:"editor.action.replaceOne",ReplaceAllAction:"editor.action.replaceAll",SelectAllMatchesAction:"editor.action.selectAllMatches"},lc=19999,Fz=240;class Xg{constructor(e,t){this._toDispose=new Lt,this._editor=e,this._state=t,this._isDisposed=!1,this._startSearchingTimer=new l_,this._decorations=new jC(e),this._toDispose.add(this._decorations),this._updateDecorationsScheduler=new Ss(()=>{if(this._editor.hasModel())return this.research(!1)},100),this._toDispose.add(this._updateDecorationsScheduler),this._toDispose.add(this._editor.onDidChangeCursorPosition(i=>{(i.reason===3||i.reason===5||i.reason===6)&&this._decorations.setStartPosition(this._editor.getPosition())})),this._ignoreModelContentChanged=!1,this._toDispose.add(this._editor.onDidChangeModelContent(i=>{this._ignoreModelContentChanged||(i.isFlush&&this._decorations.reset(),this._decorations.setStartPosition(this._editor.getPosition()),this._updateDecorationsScheduler.schedule())})),this._toDispose.add(this._state.onFindReplaceStateChange(i=>this._onStateChanged(i))),this.research(!1,this._state.searchScope)}dispose(){this._isDisposed=!0,no(this._startSearchingTimer),this._toDispose.dispose()}_onStateChanged(e){this._isDisposed||this._editor.hasModel()&&(e.searchString||e.isReplaceRevealed||e.isRegex||e.wholeWord||e.matchCase||e.searchScope)&&(this._editor.getModel().isTooLargeForSyncing()?(this._startSearchingTimer.cancel(),this._startSearchingTimer.setIfNotSet(()=>{e.searchScope?this.research(e.moveCursor,this._state.searchScope):this.research(e.moveCursor)},Fz)):e.searchScope?this.research(e.moveCursor,this._state.searchScope):this.research(e.moveCursor))}static _getSearchRange(e,t){return t||e.getFullModelRange()}research(e,t){let i=null;typeof t<"u"?t!==null&&(Array.isArray(t)?i=t:i=[t]):i=this._decorations.getFindScopes(),i!==null&&(i=i.map(a=>{if(a.startLineNumber!==a.endLineNumber){let d=a.endLineNumber;return a.endColumn===1&&(d=d-1),new Z(a.startLineNumber,1,d,this._editor.getModel().getLineMaxColumn(d))}return a}));const n=this._findMatches(i,!1,lc);this._decorations.set(n,i);const s=this._editor.getSelection();let r=this._decorations.getCurrentMatchesPosition(s);if(r===0&&n.length>0){const a=sT(n.map(d=>d.range),d=>Z.compareRangesUsingStarts(d,s)>=0);r=a>0?a-1+1:r}this._state.changeMatchInfo(r,this._decorations.getCount(),void 0),e&&this._editor.getOption(41).cursorMoveOnType&&this._moveToNextMatch(this._decorations.getStartPosition())}_hasMatches(){return this._state.matchesCount>0}_cannotFind(){if(!this._hasMatches()){const e=this._decorations.getFindScope();return e&&this._editor.revealRangeInCenterIfOutsideViewport(e,0),!0}return!1}_setCurrentFindMatch(e){const t=this._decorations.setCurrentFindMatch(e);this._state.changeMatchInfo(t,this._decorations.getCount(),e),this._editor.setSelection(e),this._editor.revealRangeInCenterIfOutsideViewport(e,0)}_prevSearchPosition(e){const t=this._state.isRegex&&(this._state.searchString.indexOf("^")>=0||this._state.searchString.indexOf("$")>=0);let{lineNumber:i,column:n}=e;const s=this._editor.getModel();return t||n===1?(i===1?i=s.getLineCount():i--,n=s.getLineMaxColumn(i)):n--,new gi(i,n)}_moveToPrevMatch(e,t=!1){if(!this._state.canNavigateBack()){const f=this._decorations.matchAfterPosition(e);f&&this._setCurrentFindMatch(f);return}if(this._decorations.getCount()<lc){let f=this._decorations.matchBeforePosition(e);f&&f.isEmpty()&&f.getStartPosition().equals(e)&&(e=this._prevSearchPosition(e),f=this._decorations.matchBeforePosition(e)),f&&this._setCurrentFindMatch(f);return}if(this._cannotFind())return;const i=this._decorations.getFindScope(),n=Xg._getSearchRange(this._editor.getModel(),i);n.getEndPosition().isBefore(e)&&(e=n.getEndPosition()),e.isBefore(n.getStartPosition())&&(e=n.getEndPosition());const{lineNumber:s,column:r}=e,a=this._editor.getModel();let d=new gi(s,r),u=a.findPreviousMatch(this._state.searchString,d,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(132):null,!1);if(u&&u.range.isEmpty()&&u.range.getStartPosition().equals(d)&&(d=this._prevSearchPosition(d),u=a.findPreviousMatch(this._state.searchString,d,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(132):null,!1)),!!u){if(!t&&!n.containsRange(u.range))return this._moveToPrevMatch(u.range.getStartPosition(),!0);this._setCurrentFindMatch(u.range)}}moveToPrevMatch(){this._moveToPrevMatch(this._editor.getSelection().getStartPosition())}_nextSearchPosition(e){const t=this._state.isRegex&&(this._state.searchString.indexOf("^")>=0||this._state.searchString.indexOf("$")>=0);let{lineNumber:i,column:n}=e;const s=this._editor.getModel();return t||n===s.getLineMaxColumn(i)?(i===s.getLineCount()?i=1:i++,n=1):n++,new gi(i,n)}_moveToNextMatch(e){if(!this._state.canNavigateForward()){const i=this._decorations.matchBeforePosition(e);i&&this._setCurrentFindMatch(i);return}if(this._decorations.getCount()<lc){let i=this._decorations.matchAfterPosition(e);i&&i.isEmpty()&&i.getStartPosition().equals(e)&&(e=this._nextSearchPosition(e),i=this._decorations.matchAfterPosition(e)),i&&this._setCurrentFindMatch(i);return}const t=this._getNextMatch(e,!1,!0);t&&this._setCurrentFindMatch(t.range)}_getNextMatch(e,t,i,n=!1){if(this._cannotFind())return null;const s=this._decorations.getFindScope(),r=Xg._getSearchRange(this._editor.getModel(),s);r.getEndPosition().isBefore(e)&&(e=r.getStartPosition()),e.isBefore(r.getStartPosition())&&(e=r.getStartPosition());const{lineNumber:a,column:d}=e,u=this._editor.getModel();let f=new gi(a,d),g=u.findNextMatch(this._state.searchString,f,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(132):null,t);return i&&g&&g.range.isEmpty()&&g.range.getStartPosition().equals(f)&&(f=this._nextSearchPosition(f),g=u.findNextMatch(this._state.searchString,f,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(132):null,t)),g?!n&&!r.containsRange(g.range)?this._getNextMatch(g.range.getEndPosition(),t,i,!0):g:null}moveToNextMatch(){this._moveToNextMatch(this._editor.getSelection().getEndPosition())}_moveToMatch(e){const t=this._decorations.getDecorationRangeAt(e);t&&this._setCurrentFindMatch(t)}moveToMatch(e){this._moveToMatch(e)}_getReplacePattern(){return this._state.isRegex?Oz(this._state.replaceString):Nf.fromStaticValue(this._state.replaceString)}replace(){if(!this._hasMatches())return;const e=this._getReplacePattern(),t=this._editor.getSelection(),i=this._getNextMatch(t.getStartPosition(),!0,!1);if(i)if(t.equalsRange(i.range)){const n=e.buildReplaceString(i.matches,this._state.preserveCase),s=new r_(t,n);this._executeEditorCommand("replace",s),this._decorations.setStartPosition(new gi(t.startLineNumber,t.startColumn+n.length)),this.research(!0)}else this._decorations.setStartPosition(this._editor.getPosition()),this._setCurrentFindMatch(i.range)}_findMatches(e,t,i){const n=(e||[null]).map(s=>Xg._getSearchRange(this._editor.getModel(),s));return this._editor.getModel().findMatches(this._state.searchString,n,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(132):null,t,i)}replaceAll(){if(!this._hasMatches())return;const e=this._decorations.getFindScopes();e===null&&this._state.matchesCount>=lc?this._largeReplaceAll():this._regularReplaceAll(e),this.research(!1)}_largeReplaceAll(){const t=new G2(this._state.searchString,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(132):null).parseSearchRequest();if(!t)return;let i=t.regex;if(!i.multiline){let g="mu";i.ignoreCase&&(g+="i"),i.global&&(g+="g"),i=new RegExp(i.source,g)}const n=this._editor.getModel(),s=n.getValue(1),r=n.getFullModelRange(),a=this._getReplacePattern();let d;const u=this._state.preserveCase;a.hasReplacementPatterns||u?d=s.replace(i,function(){return a.buildReplaceString(arguments,u)}):d=s.replace(i,a.buildReplaceString(null,u));const f=new oT(r,d,this._editor.getSelection());this._executeEditorCommand("replaceAll",f)}_regularReplaceAll(e){const t=this._getReplacePattern(),i=this._findMatches(e,t.hasReplacementPatterns||this._state.preserveCase,1073741824),n=[];for(let r=0,a=i.length;r<a;r++)n[r]=t.buildReplaceString(i[r].matches,this._state.preserveCase);const s=new Rz(this._editor.getSelection(),i.map(r=>r.range),n);this._executeEditorCommand("replaceAll",s)}selectAllMatches(){if(!this._hasMatches())return;const e=this._decorations.getFindScopes();let i=this._findMatches(e,!1,1073741824).map(s=>new Fi(s.range.startLineNumber,s.range.startColumn,s.range.endLineNumber,s.range.endColumn));const n=this._editor.getSelection();for(let s=0,r=i.length;s<r;s++)if(i[s].equalsRange(n)){i=[n].concat(i.slice(0,s)).concat(i.slice(s+1));break}this._editor.setSelections(i)}_executeEditorCommand(e,t){try{this._ignoreModelContentChanged=!0,this._editor.pushUndoStop(),this._editor.executeCommand(e,t),this._editor.pushUndoStop()}finally{this._ignoreModelContentChanged=!1}}}const Fb=class Fb extends h_{constructor(e,t,i){super(),this._hideSoon=this._register(new Ss(()=>this._hide(),2e3)),this._isVisible=!1,this._editor=e,this._state=t,this._keybindingService=i,this._domNode=document.createElement("div"),this._domNode.className="findOptionsWidget",this._domNode.style.display="none",this._domNode.style.top="10px",this._domNode.style.zIndex="12",this._domNode.setAttribute("role","presentation"),this._domNode.setAttribute("aria-hidden","true");const n={inputActiveOptionBorder:bd(aT),inputActiveOptionForeground:bd(rT),inputActiveOptionBackground:bd(i0)},s=this._register(IS());this.caseSensitive=this._register(new K2({appendTitle:this._keybindingLabelFor(Rn.ToggleCaseSensitiveCommand),isChecked:this._state.matchCase,hoverDelegate:s,...n})),this._domNode.appendChild(this.caseSensitive.domNode),this._register(this.caseSensitive.onChange(()=>{this._state.change({matchCase:this.caseSensitive.checked},!1)})),this.wholeWords=this._register(new Z2({appendTitle:this._keybindingLabelFor(Rn.ToggleWholeWordCommand),isChecked:this._state.wholeWord,hoverDelegate:s,...n})),this._domNode.appendChild(this.wholeWords.domNode),this._register(this.wholeWords.onChange(()=>{this._state.change({wholeWord:this.wholeWords.checked},!1)})),this.regex=this._register(new Y2({appendTitle:this._keybindingLabelFor(Rn.ToggleRegexCommand),isChecked:this._state.isRegex,hoverDelegate:s,...n})),this._domNode.appendChild(this.regex.domNode),this._register(this.regex.onChange(()=>{this._state.change({isRegex:this.regex.checked},!1)})),this._editor.addOverlayWidget(this),this._register(this._state.onFindReplaceStateChange(r=>{let a=!1;r.isRegex&&(this.regex.checked=this._state.isRegex,a=!0),r.wholeWord&&(this.wholeWords.checked=this._state.wholeWord,a=!0),r.matchCase&&(this.caseSensitive.checked=this._state.matchCase,a=!0),!this._state.isRevealed&&a&&this._revealTemporarily()})),this._register(wn(this._domNode,Zn.MOUSE_LEAVE,r=>this._onMouseLeave())),this._register(wn(this._domNode,"mouseover",r=>this._onMouseOver()))}_keybindingLabelFor(e){const t=this._keybindingService.lookupKeybinding(e);return t?` (${t.getLabel()})`:""}dispose(){this._editor.removeOverlayWidget(this),super.dispose()}getId(){return Fb.ID}getDomNode(){return this._domNode}getPosition(){return{preference:0}}highlightFindOptions(){this._revealTemporarily()}_revealTemporarily(){this._show(),this._hideSoon.schedule()}_onMouseLeave(){this._hideSoon.schedule()}_onMouseOver(){this._hideSoon.cancel()}_show(){this._isVisible||(this._isVisible=!0,this._domNode.style.display="block")}_hide(){this._isVisible&&(this._isVisible=!1,this._domNode.style.display="none")}};Fb.ID="editor.contrib.findOptionsWidget";let $C=Fb;function dm(o,e){return o===1?!0:o===2?!1:e}class Hz extends Dt{get searchString(){return this._searchString}get replaceString(){return this._replaceString}get isRevealed(){return this._isRevealed}get isReplaceRevealed(){return this._isReplaceRevealed}get isRegex(){return dm(this._isRegexOverride,this._isRegex)}get wholeWord(){return dm(this._wholeWordOverride,this._wholeWord)}get matchCase(){return dm(this._matchCaseOverride,this._matchCase)}get preserveCase(){return dm(this._preserveCaseOverride,this._preserveCase)}get actualIsRegex(){return this._isRegex}get actualWholeWord(){return this._wholeWord}get actualMatchCase(){return this._matchCase}get actualPreserveCase(){return this._preserveCase}get searchScope(){return this._searchScope}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get currentMatch(){return this._currentMatch}constructor(){super(),this._onFindReplaceStateChange=this._register(new Xi),this.onFindReplaceStateChange=this._onFindReplaceStateChange.event,this._searchString="",this._replaceString="",this._isRevealed=!1,this._isReplaceRevealed=!1,this._isRegex=!1,this._isRegexOverride=0,this._wholeWord=!1,this._wholeWordOverride=0,this._matchCase=!1,this._matchCaseOverride=0,this._preserveCase=!1,this._preserveCaseOverride=0,this._searchScope=null,this._matchesPosition=0,this._matchesCount=0,this._currentMatch=null,this._loop=!0,this._isSearching=!1,this._filters=null}changeMatchInfo(e,t,i){const n={moveCursor:!1,updateHistory:!1,searchString:!1,replaceString:!1,isRevealed:!1,isReplaceRevealed:!1,isRegex:!1,wholeWord:!1,matchCase:!1,preserveCase:!1,searchScope:!1,matchesPosition:!1,matchesCount:!1,currentMatch:!1,loop:!1,isSearching:!1,filters:!1};let s=!1;t===0&&(e=0),e>t&&(e=t),this._matchesPosition!==e&&(this._matchesPosition=e,n.matchesPosition=!0,s=!0),this._matchesCount!==t&&(this._matchesCount=t,n.matchesCount=!0,s=!0),typeof i<"u"&&(Z.equalsRange(this._currentMatch,i)||(this._currentMatch=i,n.currentMatch=!0,s=!0)),s&&this._onFindReplaceStateChange.fire(n)}change(e,t,i=!0){var f;const n={moveCursor:t,updateHistory:i,searchString:!1,replaceString:!1,isRevealed:!1,isReplaceRevealed:!1,isRegex:!1,wholeWord:!1,matchCase:!1,preserveCase:!1,searchScope:!1,matchesPosition:!1,matchesCount:!1,currentMatch:!1,loop:!1,isSearching:!1,filters:!1};let s=!1;const r=this.isRegex,a=this.wholeWord,d=this.matchCase,u=this.preserveCase;typeof e.searchString<"u"&&this._searchString!==e.searchString&&(this._searchString=e.searchString,n.searchString=!0,s=!0),typeof e.replaceString<"u"&&this._replaceString!==e.replaceString&&(this._replaceString=e.replaceString,n.replaceString=!0,s=!0),typeof e.isRevealed<"u"&&this._isRevealed!==e.isRevealed&&(this._isRevealed=e.isRevealed,n.isRevealed=!0,s=!0),typeof e.isReplaceRevealed<"u"&&this._isReplaceRevealed!==e.isReplaceRevealed&&(this._isReplaceRevealed=e.isReplaceRevealed,n.isReplaceRevealed=!0,s=!0),typeof e.isRegex<"u"&&(this._isRegex=e.isRegex),typeof e.wholeWord<"u"&&(this._wholeWord=e.wholeWord),typeof e.matchCase<"u"&&(this._matchCase=e.matchCase),typeof e.preserveCase<"u"&&(this._preserveCase=e.preserveCase),typeof e.searchScope<"u"&&((f=e.searchScope)!=null&&f.every(g=>{var p;return(p=this._searchScope)==null?void 0:p.some(w=>!Z.equalsRange(w,g))})||(this._searchScope=e.searchScope,n.searchScope=!0,s=!0)),typeof e.loop<"u"&&this._loop!==e.loop&&(this._loop=e.loop,n.loop=!0,s=!0),typeof e.isSearching<"u"&&this._isSearching!==e.isSearching&&(this._isSearching=e.isSearching,n.isSearching=!0,s=!0),typeof e.filters<"u"&&(this._filters?this._filters.update(e.filters):this._filters=e.filters,n.filters=!0,s=!0),this._isRegexOverride=typeof e.isRegexOverride<"u"?e.isRegexOverride:0,this._wholeWordOverride=typeof e.wholeWordOverride<"u"?e.wholeWordOverride:0,this._matchCaseOverride=typeof e.matchCaseOverride<"u"?e.matchCaseOverride:0,this._preserveCaseOverride=typeof e.preserveCaseOverride<"u"?e.preserveCaseOverride:0,r!==this.isRegex&&(s=!0,n.isRegex=!0),a!==this.wholeWord&&(s=!0,n.wholeWord=!0),d!==this.matchCase&&(s=!0,n.matchCase=!0),u!==this.preserveCase&&(s=!0,n.preserveCase=!0),s&&this._onFindReplaceStateChange.fire(n)}canNavigateBack(){return this.canNavigateInLoop()||this.matchesPosition!==1}canNavigateForward(){return this.canNavigateInLoop()||this.matchesPosition<this.matchesCount}canNavigateInLoop(){return this._loop||this.matchesCount>=lc}}const Wz=C("defaultLabel","input"),Bz=C("label.preserveCaseToggle","Preserve Case");class zz extends lT{constructor(e){super({icon:ji.preserveCase,title:Bz+e.appendTitle,isChecked:e.isChecked,hoverDelegate:e.hoverDelegate??Dy("element"),inputActiveOptionBorder:e.inputActiveOptionBorder,inputActiveOptionForeground:e.inputActiveOptionForeground,inputActiveOptionBackground:e.inputActiveOptionBackground})}}class Vz extends h_{constructor(e,t,i,n){super(),this._showOptionButtons=i,this.fixFocusOnOptionClickEnabled=!0,this.cachedOptionsWidth=0,this._onDidOptionChange=this._register(new Xi),this.onDidOptionChange=this._onDidOptionChange.event,this._onKeyDown=this._register(new Xi),this.onKeyDown=this._onKeyDown.event,this._onMouseDown=this._register(new Xi),this._onInput=this._register(new Xi),this._onKeyUp=this._register(new Xi),this._onPreserveCaseKeyDown=this._register(new Xi),this.onPreserveCaseKeyDown=this._onPreserveCaseKeyDown.event,this.contextViewProvider=t,this.placeholder=n.placeholder||"",this.validation=n.validation,this.label=n.label||Wz;const s=n.appendPreserveCaseLabel||"",r=n.history||[],a=!!n.flexibleHeight,d=!!n.flexibleWidth,u=n.flexibleMaxHeight;this.domNode=document.createElement("div"),this.domNode.classList.add("monaco-findInput"),this.inputBox=this._register(new X2(this.domNode,this.contextViewProvider,{ariaLabel:this.label||"",placeholder:this.placeholder||"",validationOptions:{validation:this.validation},history:r,showHistoryHint:n.showHistoryHint,flexibleHeight:a,flexibleWidth:d,flexibleMaxHeight:u,inputBoxStyles:n.inputBoxStyles})),this.preserveCase=this._register(new zz({appendTitle:s,isChecked:!1,...n.toggleStyles})),this._register(this.preserveCase.onChange(p=>{this._onDidOptionChange.fire(p),!p&&this.fixFocusOnOptionClickEnabled&&this.inputBox.focus(),this.validate()})),this._register(this.preserveCase.onKeyDown(p=>{this._onPreserveCaseKeyDown.fire(p)})),this._showOptionButtons?this.cachedOptionsWidth=this.preserveCase.width():this.cachedOptionsWidth=0;const f=[this.preserveCase.domNode];this.onkeydown(this.domNode,p=>{if(p.equals(15)||p.equals(17)||p.equals(9)){const w=f.indexOf(this.domNode.ownerDocument.activeElement);if(w>=0){let y=-1;p.equals(17)?y=(w+1)%f.length:p.equals(15)&&(w===0?y=f.length-1:y=w-1),p.equals(9)?(f[w].blur(),this.inputBox.focus()):y>=0&&f[y].focus(),sv.stop(p,!0)}}});const g=document.createElement("div");g.className="controls",g.style.display=this._showOptionButtons?"block":"none",g.appendChild(this.preserveCase.domNode),this.domNode.appendChild(g),e==null||e.appendChild(this.domNode),this.onkeydown(this.inputBox.inputElement,p=>this._onKeyDown.fire(p)),this.onkeyup(this.inputBox.inputElement,p=>this._onKeyUp.fire(p)),this.oninput(this.inputBox.inputElement,p=>this._onInput.fire()),this.onmousedown(this.inputBox.inputElement,p=>this._onMouseDown.fire(p))}enable(){this.domNode.classList.remove("disabled"),this.inputBox.enable(),this.preserveCase.enable()}disable(){this.domNode.classList.add("disabled"),this.inputBox.disable(),this.preserveCase.disable()}setEnabled(e){e?this.enable():this.disable()}select(){this.inputBox.select()}focus(){this.inputBox.focus()}getPreserveCase(){return this.preserveCase.checked}setPreserveCase(e){this.preserveCase.checked=e}focusOnPreserve(){this.preserveCase.focus()}validate(){var e;(e=this.inputBox)==null||e.validate()}set width(e){this.inputBox.paddingRight=this.cachedOptionsWidth,this.domNode.style.width=e+"px"}dispose(){super.dispose()}}var RR=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},NR=function(o,e){return function(t,i){e(t,i,o)}};const ok=new _n("suggestWidgetVisible",!1,C("suggestWidgetVisible","Whether suggestion are visible")),rk="historyNavigationWidgetFocus",AR="historyNavigationForwardsEnabled",OR="historyNavigationBackwardsEnabled";let bl;const um=[];function FR(o,e){if(um.includes(e))throw new Error("Cannot register the same widget multiple times");um.push(e);const t=new Lt,i=new _n(rk,!1).bindTo(o),n=new _n(AR,!0).bindTo(o),s=new _n(OR,!0).bindTo(o),r=()=>{i.set(!0),bl=e},a=()=>{i.set(!1),bl===e&&(bl=void 0)};return J2(e.element)&&r(),t.add(e.onDidFocus(()=>r())),t.add(e.onDidBlur(()=>a())),t.add(jn(()=>{um.splice(um.indexOf(e),1),a()})),{historyNavigationForwardsEnablement:n,historyNavigationBackwardsEnablement:s,dispose(){t.dispose()}}}let UC=class extends Q2{constructor(e,t,i,n){super(e,t,i);const s=this._register(n.createScoped(this.inputBox.element));this._register(FR(s,this.inputBox))}};UC=RR([NR(3,Sn)],UC);let qC=class extends Vz{constructor(e,t,i,n,s=!1){super(e,t,s,i);const r=this._register(n.createScoped(this.inputBox.element));this._register(FR(r,this.inputBox))}};qC=RR([NR(3,Sn)],qC);Ga.registerCommandAndKeybindingRule({id:"history.showPrevious",weight:200,when:Ae.and(Ae.has(rk),Ae.equals(OR,!0),Ae.not("isComposing"),ok.isEqualTo(!1)),primary:16,secondary:[528],handler:o=>{bl==null||bl.showPreviousValue()}});Ga.registerCommandAndKeybindingRule({id:"history.showNext",weight:200,when:Ae.and(Ae.has(rk),Ae.equals(AR,!0),Ae.not("isComposing"),ok.isEqualTo(!1)),primary:18,secondary:[530],handler:o=>{bl==null||bl.showNextValue()}});function PI(o){var e,t;return((e=o.lookupKeybinding("history.showPrevious"))==null?void 0:e.getElectronAccelerator())==="Up"&&((t=o.lookupKeybinding("history.showNext"))==null?void 0:t.getElectronAccelerator())==="Down"}const MI=is("find-collapsed",ji.chevronRight,C("findCollapsedIcon","Icon to indicate that the editor find widget is collapsed.")),RI=is("find-expanded",ji.chevronDown,C("findExpandedIcon","Icon to indicate that the editor find widget is expanded.")),jz=is("find-selection",ji.selection,C("findSelectionIcon","Icon for 'Find in Selection' in the editor find widget.")),$z=is("find-replace",ji.replace,C("findReplaceIcon","Icon for 'Replace' in the editor find widget.")),Uz=is("find-replace-all",ji.replaceAll,C("findReplaceAllIcon","Icon for 'Replace All' in the editor find widget.")),qz=is("find-previous-match",ji.arrowUp,C("findPreviousMatchIcon","Icon for 'Find Previous' in the editor find widget.")),Gz=is("find-next-match",ji.arrowDown,C("findNextMatchIcon","Icon for 'Find Next' in the editor find widget.")),Kz=C("label.findDialog","Find / Replace"),Zz=C("label.find","Find"),Yz=C("placeholder.find","Find"),Xz=C("label.previousMatchButton","Previous Match"),Qz=C("label.nextMatchButton","Next Match"),Jz=C("label.toggleSelectionFind","Find in Selection"),eV=C("label.closeButton","Close"),tV=C("label.replace","Replace"),iV=C("placeholder.replace","Replace"),nV=C("label.replaceButton","Replace"),sV=C("label.replaceAllButton","Replace All"),oV=C("label.toggleReplaceButton","Toggle Replace"),rV=C("title.matchesCountLimit","Only the first {0} results are highlighted, but all find operations work on the entire text.",lc),aV=C("label.matchesLocation","{0} of {1}"),NI=C("label.noResults","No results"),va=419,lV=275,cV=lV-54;let mg=69;const dV=33,AI="ctrlEnterReplaceAll.windows.donotask",OI=ja?256:2048;class qw{constructor(e){this.afterLineNumber=e,this.heightInPx=dV,this.suppressMouseDown=!1,this.domNode=document.createElement("div"),this.domNode.className="dock-find-viewzone"}}function FI(o,e,t){const i=!!e.match(/\n/);if(t&&i&&t.selectionStart>0){o.stopPropagation();return}}function HI(o,e,t){const i=!!e.match(/\n/);if(t&&i&&t.selectionEnd<t.value.length){o.stopPropagation();return}}const Hb=class Hb extends h_{constructor(e,t,i,n,s,r,a,d,u,f){super(),this._hoverService=f,this._cachedHeight=null,this._revealTimeouts=[],this._codeEditor=e,this._controller=t,this._state=i,this._contextViewProvider=n,this._keybindingService=s,this._contextKeyService=r,this._storageService=d,this._notificationService=u,this._ctrlEnterReplaceAllWarningPrompted=!!d.getBoolean(AI,0),this._isVisible=!1,this._isReplaceVisible=!1,this._ignoreChangeEvent=!1,this._updateHistoryDelayer=new Mc(500),this._register(jn(()=>this._updateHistoryDelayer.cancel())),this._register(this._state.onFindReplaceStateChange(g=>this._onStateChanged(g))),this._buildDomNode(),this._updateButtons(),this._tryUpdateWidgetWidth(),this._findInput.inputBox.layout(),this._register(this._codeEditor.onDidChangeConfiguration(g=>{if(g.hasChanged(92)&&(this._codeEditor.getOption(92)&&this._state.change({isReplaceRevealed:!1},!1),this._updateButtons()),g.hasChanged(146)&&this._tryUpdateWidgetWidth(),g.hasChanged(2)&&this.updateAccessibilitySupport(),g.hasChanged(41)){const p=this._codeEditor.getOption(41).loop;this._state.change({loop:p},!1);const w=this._codeEditor.getOption(41).addExtraSpaceOnTop;w&&!this._viewZone&&(this._viewZone=new qw(0),this._showViewZone()),!w&&this._viewZone&&this._removeViewZone()}})),this.updateAccessibilitySupport(),this._register(this._codeEditor.onDidChangeCursorSelection(()=>{this._isVisible&&this._updateToggleSelectionFindButton()})),this._register(this._codeEditor.onDidFocusEditorWidget(async()=>{if(this._isVisible){const g=await this._controller.getGlobalBufferTerm();g&&g!==this._state.searchString&&(this._state.change({searchString:g},!1),this._findInput.select())}})),this._findInputFocused=ew.bindTo(r),this._findFocusTracker=this._register(ff(this._findInput.inputBox.inputElement)),this._register(this._findFocusTracker.onDidFocus(()=>{this._findInputFocused.set(!0),this._updateSearchScope()})),this._register(this._findFocusTracker.onDidBlur(()=>{this._findInputFocused.set(!1)})),this._replaceInputFocused=sk.bindTo(r),this._replaceFocusTracker=this._register(ff(this._replaceInput.inputBox.inputElement)),this._register(this._replaceFocusTracker.onDidFocus(()=>{this._replaceInputFocused.set(!0),this._updateSearchScope()})),this._register(this._replaceFocusTracker.onDidBlur(()=>{this._replaceInputFocused.set(!1)})),this._codeEditor.addOverlayWidget(this),this._codeEditor.getOption(41).addExtraSpaceOnTop&&(this._viewZone=new qw(0)),this._register(this._codeEditor.onDidChangeModel(()=>{this._isVisible&&(this._viewZoneId=void 0)})),this._register(this._codeEditor.onDidScrollChange(g=>{if(g.scrollTopChanged){this._layoutViewZone();return}setTimeout(()=>{this._layoutViewZone()},0)}))}getId(){return Hb.ID}getDomNode(){return this._domNode}getPosition(){return this._isVisible?{preference:0}:null}_onStateChanged(e){if(e.searchString){try{this._ignoreChangeEvent=!0,this._findInput.setValue(this._state.searchString)}finally{this._ignoreChangeEvent=!1}this._updateButtons()}if(e.replaceString&&(this._replaceInput.inputBox.value=this._state.replaceString),e.isRevealed&&(this._state.isRevealed?this._reveal():this._hide(!0)),e.isReplaceRevealed&&(this._state.isReplaceRevealed?!this._codeEditor.getOption(92)&&!this._isReplaceVisible&&(this._isReplaceVisible=!0,this._replaceInput.width=wr(this._findInput.domNode),this._updateButtons(),this._replaceInput.inputBox.layout()):this._isReplaceVisible&&(this._isReplaceVisible=!1,this._updateButtons())),(e.isRevealed||e.isReplaceRevealed)&&(this._state.isRevealed||this._state.isReplaceRevealed)&&this._tryUpdateHeight()&&this._showViewZone(),e.isRegex&&this._findInput.setRegex(this._state.isRegex),e.wholeWord&&this._findInput.setWholeWords(this._state.wholeWord),e.matchCase&&this._findInput.setCaseSensitive(this._state.matchCase),e.preserveCase&&this._replaceInput.setPreserveCase(this._state.preserveCase),e.searchScope&&(this._state.searchScope?this._toggleSelectionFind.checked=!0:this._toggleSelectionFind.checked=!1,this._updateToggleSelectionFindButton()),e.searchString||e.matchesCount||e.matchesPosition){const t=this._state.searchString.length>0&&this._state.matchesCount===0;this._domNode.classList.toggle("no-results",t),this._updateMatchesCount(),this._updateButtons()}(e.searchString||e.currentMatch)&&this._layoutViewZone(),e.updateHistory&&this._delayedUpdateHistory(),e.loop&&this._updateButtons()}_delayedUpdateHistory(){this._updateHistoryDelayer.trigger(this._updateHistory.bind(this)).then(void 0,Nn)}_updateHistory(){this._state.searchString&&this._findInput.inputBox.addToHistory(),this._state.replaceString&&this._replaceInput.inputBox.addToHistory()}_updateMatchesCount(){var t;this._matchesCount.style.minWidth=mg+"px",this._state.matchesCount>=lc?this._matchesCount.title=rV:this._matchesCount.title="",(t=this._matchesCount.firstChild)==null||t.remove();let e;if(this._state.matchesCount>0){let i=String(this._state.matchesCount);this._state.matchesCount>=lc&&(i+="+");let n=String(this._state.matchesPosition);n==="0"&&(n="?"),e=h0(aV,n,i)}else e=NI;this._matchesCount.appendChild(document.createTextNode(e)),Ar(this._getAriaLabel(e,this._state.currentMatch,this._state.searchString)),mg=Math.max(mg,this._matchesCount.clientWidth)}_getAriaLabel(e,t,i){if(e===NI)return i===""?C("ariaSearchNoResultEmpty","{0} found",e):C("ariaSearchNoResult","{0} found for '{1}'",e,i);if(t){const n=C("ariaSearchNoResultWithLineNum","{0} found for '{1}', at {2}",e,i,t.startLineNumber+":"+t.startColumn),s=this._codeEditor.getModel();return s&&t.startLineNumber<=s.getLineCount()&&t.startLineNumber>=1?`${s.getLineContent(t.startLineNumber)}, ${n}`:n}return C("ariaSearchNoResultWithLineNumNoCurrentMatch","{0} found for '{1}'",e,i)}_updateToggleSelectionFindButton(){const e=this._codeEditor.getSelection(),t=e?e.startLineNumber!==e.endLineNumber||e.startColumn!==e.endColumn:!1,i=this._toggleSelectionFind.checked;this._isVisible&&(i||t)?this._toggleSelectionFind.enable():this._toggleSelectionFind.disable()}_updateButtons(){this._findInput.setEnabled(this._isVisible),this._replaceInput.setEnabled(this._isVisible&&this._isReplaceVisible),this._updateToggleSelectionFindButton(),this._closeBtn.setEnabled(this._isVisible);const e=this._state.searchString.length>0,t=!!this._state.matchesCount;this._prevBtn.setEnabled(this._isVisible&&e&&t&&this._state.canNavigateBack()),this._nextBtn.setEnabled(this._isVisible&&e&&t&&this._state.canNavigateForward()),this._replaceBtn.setEnabled(this._isVisible&&this._isReplaceVisible&&e),this._replaceAllBtn.setEnabled(this._isVisible&&this._isReplaceVisible&&e),this._domNode.classList.toggle("replaceToggled",this._isReplaceVisible),this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);const i=!this._codeEditor.getOption(92);this._toggleReplaceBtn.setEnabled(this._isVisible&&i)}_reveal(){if(this._revealTimeouts.forEach(e=>{clearTimeout(e)}),this._revealTimeouts=[],!this._isVisible){this._isVisible=!0;const e=this._codeEditor.getSelection();switch(this._codeEditor.getOption(41).autoFindInSelection){case"always":this._toggleSelectionFind.checked=!0;break;case"never":this._toggleSelectionFind.checked=!1;break;case"multiline":{const i=!!e&&e.startLineNumber!==e.endLineNumber;this._toggleSelectionFind.checked=i;break}}this._tryUpdateWidgetWidth(),this._updateButtons(),this._revealTimeouts.push(setTimeout(()=>{this._domNode.classList.add("visible"),this._domNode.setAttribute("aria-hidden","false")},0)),this._revealTimeouts.push(setTimeout(()=>{this._findInput.validate()},200)),this._codeEditor.layoutOverlayWidget(this);let t=!0;if(this._codeEditor.getOption(41).seedSearchStringFromSelection&&e){const i=this._codeEditor.getDomNode();if(i){const n=mo(i),s=this._codeEditor.getScrolledVisiblePosition(e.getStartPosition()),r=n.left+(s?s.left:0),a=s?s.top:0;if(this._viewZone&&a<this._viewZone.heightInPx){e.endLineNumber>e.startLineNumber&&(t=!1);const d=eO(this._domNode).left;r>d&&(t=!1);const u=this._codeEditor.getScrolledVisiblePosition(e.getEndPosition());n.left+(u?u.left:0)>d&&(t=!1)}}}this._showViewZone(t)}}_hide(e){this._revealTimeouts.forEach(t=>{clearTimeout(t)}),this._revealTimeouts=[],this._isVisible&&(this._isVisible=!1,this._updateButtons(),this._domNode.classList.remove("visible"),this._domNode.setAttribute("aria-hidden","true"),this._findInput.clearMessage(),e&&this._codeEditor.focus(),this._codeEditor.layoutOverlayWidget(this),this._removeViewZone())}_layoutViewZone(e){if(!this._codeEditor.getOption(41).addExtraSpaceOnTop){this._removeViewZone();return}if(!this._isVisible)return;const i=this._viewZone;this._viewZoneId!==void 0||!i||this._codeEditor.changeViewZones(n=>{i.heightInPx=this._getHeight(),this._viewZoneId=n.addZone(i),this._codeEditor.setScrollTop(e||this._codeEditor.getScrollTop()+i.heightInPx)})}_showViewZone(e=!0){if(!this._isVisible||!this._codeEditor.getOption(41).addExtraSpaceOnTop)return;this._viewZone===void 0&&(this._viewZone=new qw(0));const i=this._viewZone;this._codeEditor.changeViewZones(n=>{if(this._viewZoneId!==void 0){const s=this._getHeight();if(s===i.heightInPx)return;const r=s-i.heightInPx;i.heightInPx=s,n.layoutZone(this._viewZoneId),e&&this._codeEditor.setScrollTop(this._codeEditor.getScrollTop()+r);return}else{let s=this._getHeight();if(s-=this._codeEditor.getOption(84).top,s<=0)return;i.heightInPx=s,this._viewZoneId=n.addZone(i),e&&this._codeEditor.setScrollTop(this._codeEditor.getScrollTop()+s)}})}_removeViewZone(){this._codeEditor.changeViewZones(e=>{this._viewZoneId!==void 0&&(e.removeZone(this._viewZoneId),this._viewZoneId=void 0,this._viewZone&&(this._codeEditor.setScrollTop(this._codeEditor.getScrollTop()-this._viewZone.heightInPx),this._viewZone=void 0))})}_tryUpdateWidgetWidth(){if(!this._isVisible||!this._domNode.isConnected)return;const e=this._codeEditor.getLayoutInfo();if(e.contentWidth<=0){this._domNode.classList.add("hiddenEditor");return}else this._domNode.classList.contains("hiddenEditor")&&this._domNode.classList.remove("hiddenEditor");const i=e.width,n=e.minimap.minimapWidth;let s=!1,r=!1,a=!1;if(this._resized&&wr(this._domNode)>va){this._domNode.style.maxWidth=`${i-28-n-15}px`,this._replaceInput.width=wr(this._findInput.domNode);return}if(va+28+n>=i&&(r=!0),va+28+n-mg>=i&&(a=!0),va+28+n-mg>=i+50&&(s=!0),this._domNode.classList.toggle("collapsed-find-widget",s),this._domNode.classList.toggle("narrow-find-widget",a),this._domNode.classList.toggle("reduced-find-widget",r),!a&&!s&&(this._domNode.style.maxWidth=`${i-28-n-15}px`),this._findInput.layout({collapsedFindWidget:s,narrowFindWidget:a,reducedFindWidget:r}),this._resized){const d=this._findInput.inputBox.element.clientWidth;d>0&&(this._replaceInput.width=d)}else this._isReplaceVisible&&(this._replaceInput.width=wr(this._findInput.domNode))}_getHeight(){let e=0;return e+=4,e+=this._findInput.inputBox.height+2,this._isReplaceVisible&&(e+=4,e+=this._replaceInput.inputBox.height+2),e+=4,e}_tryUpdateHeight(){const e=this._getHeight();return this._cachedHeight!==null&&this._cachedHeight===e?!1:(this._cachedHeight=e,this._domNode.style.height=`${e}px`,!0)}focusFindInput(){this._findInput.select(),this._findInput.focus()}focusReplaceInput(){this._replaceInput.select(),this._replaceInput.focus()}highlightFindOptions(){this._findInput.highlightFindOptions()}_updateSearchScope(){if(this._codeEditor.hasModel()&&this._toggleSelectionFind.checked){const e=this._codeEditor.getSelections();e.map(t=>{t.endColumn===1&&t.endLineNumber>t.startLineNumber&&(t=t.setEndPosition(t.endLineNumber-1,this._codeEditor.getModel().getLineMaxColumn(t.endLineNumber-1)));const i=this._state.currentMatch;return t.startLineNumber!==t.endLineNumber&&!Z.equalsRange(t,i)?t:null}).filter(t=>!!t),e.length&&this._state.change({searchScope:e},!0)}}_onFindInputMouseDown(e){e.middleButton&&e.stopPropagation()}_onFindInputKeyDown(e){if(e.equals(OI|3))if(this._keybindingService.dispatchEvent(e,e.target)){e.preventDefault();return}else{this._findInput.inputBox.insertAtCursor(`
21
- `),e.preventDefault();return}if(e.equals(2)){this._isReplaceVisible?this._replaceInput.focus():this._findInput.focusOnCaseSensitive(),e.preventDefault();return}if(e.equals(2066)){this._codeEditor.focus(),e.preventDefault();return}if(e.equals(16))return FI(e,this._findInput.getValue(),this._findInput.domNode.querySelector("textarea"));if(e.equals(18))return HI(e,this._findInput.getValue(),this._findInput.domNode.querySelector("textarea"))}_onReplaceInputKeyDown(e){if(e.equals(OI|3))if(this._keybindingService.dispatchEvent(e,e.target)){e.preventDefault();return}else{vy&&jf&&!this._ctrlEnterReplaceAllWarningPrompted&&(this._notificationService.info(C("ctrlEnter.keybindingChanged","Ctrl+Enter now inserts line break instead of replacing all. You can modify the keybinding for editor.action.replaceAll to override this behavior.")),this._ctrlEnterReplaceAllWarningPrompted=!0,this._storageService.store(AI,!0,0,0)),this._replaceInput.inputBox.insertAtCursor(`
22
- `),e.preventDefault();return}if(e.equals(2)){this._findInput.focusOnCaseSensitive(),e.preventDefault();return}if(e.equals(1026)){this._findInput.focus(),e.preventDefault();return}if(e.equals(2066)){this._codeEditor.focus(),e.preventDefault();return}if(e.equals(16))return FI(e,this._replaceInput.inputBox.value,this._replaceInput.inputBox.element.querySelector("textarea"));if(e.equals(18))return HI(e,this._replaceInput.inputBox.value,this._replaceInput.inputBox.element.querySelector("textarea"))}getVerticalSashLeft(e){return 0}_keybindingLabelFor(e){const t=this._keybindingService.lookupKeybinding(e);return t?` (${t.getLabel()})`:""}_buildDomNode(){this._findInput=this._register(new UC(null,this._contextViewProvider,{width:cV,label:Zz,placeholder:Yz,appendCaseSensitiveLabel:this._keybindingLabelFor(Rn.ToggleCaseSensitiveCommand),appendWholeWordsLabel:this._keybindingLabelFor(Rn.ToggleWholeWordCommand),appendRegexLabel:this._keybindingLabelFor(Rn.ToggleRegexCommand),validation:f=>{if(f.length===0||!this._findInput.getRegex())return null;try{return new RegExp(f,"gu"),null}catch(g){return{content:g.message}}},flexibleHeight:!0,flexibleWidth:!0,flexibleMaxHeight:118,showCommonFindToggles:!0,showHistoryHint:()=>PI(this._keybindingService),inputBoxStyles:bL,toggleStyles:vL},this._contextKeyService)),this._findInput.setRegex(!!this._state.isRegex),this._findInput.setCaseSensitive(!!this._state.matchCase),this._findInput.setWholeWords(!!this._state.wholeWord),this._register(this._findInput.onKeyDown(f=>this._onFindInputKeyDown(f))),this._register(this._findInput.inputBox.onDidChange(()=>{this._ignoreChangeEvent||this._state.change({searchString:this._findInput.getValue()},!0)})),this._register(this._findInput.onDidOptionChange(()=>{this._state.change({isRegex:this._findInput.getRegex(),wholeWord:this._findInput.getWholeWords(),matchCase:this._findInput.getCaseSensitive()},!0)})),this._register(this._findInput.onCaseSensitiveKeyDown(f=>{f.equals(1026)&&this._isReplaceVisible&&(this._replaceInput.focus(),f.preventDefault())})),this._register(this._findInput.onRegexKeyDown(f=>{f.equals(2)&&this._isReplaceVisible&&(this._replaceInput.focusOnPreserve(),f.preventDefault())})),this._register(this._findInput.inputBox.onDidHeightChange(f=>{this._tryUpdateHeight()&&this._showViewZone()})),tO&&this._register(this._findInput.onMouseDown(f=>this._onFindInputMouseDown(f))),this._matchesCount=document.createElement("div"),this._matchesCount.className="matchesCount",this._updateMatchesCount();const i=this._register(IS());this._prevBtn=this._register(new ah({label:Xz+this._keybindingLabelFor(Rn.PreviousMatchFindAction),icon:qz,hoverDelegate:i,onTrigger:()=>{Lh(this._codeEditor.getAction(Rn.PreviousMatchFindAction)).run().then(void 0,Nn)}},this._hoverService)),this._nextBtn=this._register(new ah({label:Qz+this._keybindingLabelFor(Rn.NextMatchFindAction),icon:Gz,hoverDelegate:i,onTrigger:()=>{Lh(this._codeEditor.getAction(Rn.NextMatchFindAction)).run().then(void 0,Nn)}},this._hoverService));const n=document.createElement("div");n.className="find-part",n.appendChild(this._findInput.domNode);const s=document.createElement("div");s.className="find-actions",n.appendChild(s),s.appendChild(this._matchesCount),s.appendChild(this._prevBtn.domNode),s.appendChild(this._nextBtn.domNode),this._toggleSelectionFind=this._register(new lT({icon:jz,title:Jz+this._keybindingLabelFor(Rn.ToggleSearchScopeCommand),isChecked:!1,hoverDelegate:i,inputActiveOptionBackground:bd(i0),inputActiveOptionBorder:bd(aT),inputActiveOptionForeground:bd(rT)})),this._register(this._toggleSelectionFind.onChange(()=>{if(this._toggleSelectionFind.checked){if(this._codeEditor.hasModel()){let f=this._codeEditor.getSelections();f=f.map(g=>(g.endColumn===1&&g.endLineNumber>g.startLineNumber&&(g=g.setEndPosition(g.endLineNumber-1,this._codeEditor.getModel().getLineMaxColumn(g.endLineNumber-1))),g.isEmpty()?null:g)).filter(g=>!!g),f.length&&this._state.change({searchScope:f},!0)}}else this._state.change({searchScope:null},!0)})),s.appendChild(this._toggleSelectionFind.domNode),this._closeBtn=this._register(new ah({label:eV+this._keybindingLabelFor(Rn.CloseFindWidgetCommand),icon:cT,hoverDelegate:i,onTrigger:()=>{this._state.change({isRevealed:!1,searchScope:null},!1)},onKeyDown:f=>{f.equals(2)&&this._isReplaceVisible&&(this._replaceBtn.isEnabled()?this._replaceBtn.focus():this._codeEditor.focus(),f.preventDefault())}},this._hoverService)),this._replaceInput=this._register(new qC(null,void 0,{label:tV,placeholder:iV,appendPreserveCaseLabel:this._keybindingLabelFor(Rn.TogglePreserveCaseCommand),history:[],flexibleHeight:!0,flexibleWidth:!0,flexibleMaxHeight:118,showHistoryHint:()=>PI(this._keybindingService),inputBoxStyles:bL,toggleStyles:vL},this._contextKeyService,!0)),this._replaceInput.setPreserveCase(!!this._state.preserveCase),this._register(this._replaceInput.onKeyDown(f=>this._onReplaceInputKeyDown(f))),this._register(this._replaceInput.inputBox.onDidChange(()=>{this._state.change({replaceString:this._replaceInput.inputBox.value},!1)})),this._register(this._replaceInput.inputBox.onDidHeightChange(f=>{this._isReplaceVisible&&this._tryUpdateHeight()&&this._showViewZone()})),this._register(this._replaceInput.onDidOptionChange(()=>{this._state.change({preserveCase:this._replaceInput.getPreserveCase()},!0)})),this._register(this._replaceInput.onPreserveCaseKeyDown(f=>{f.equals(2)&&(this._prevBtn.isEnabled()?this._prevBtn.focus():this._nextBtn.isEnabled()?this._nextBtn.focus():this._toggleSelectionFind.enabled?this._toggleSelectionFind.focus():this._closeBtn.isEnabled()&&this._closeBtn.focus(),f.preventDefault())}));const r=this._register(IS());this._replaceBtn=this._register(new ah({label:nV+this._keybindingLabelFor(Rn.ReplaceOneAction),icon:$z,hoverDelegate:r,onTrigger:()=>{this._controller.replace()},onKeyDown:f=>{f.equals(1026)&&(this._closeBtn.focus(),f.preventDefault())}},this._hoverService)),this._replaceAllBtn=this._register(new ah({label:sV+this._keybindingLabelFor(Rn.ReplaceAllAction),icon:Uz,hoverDelegate:r,onTrigger:()=>{this._controller.replaceAll()}},this._hoverService));const a=document.createElement("div");a.className="replace-part",a.appendChild(this._replaceInput.domNode);const d=document.createElement("div");d.className="replace-actions",a.appendChild(d),d.appendChild(this._replaceBtn.domNode),d.appendChild(this._replaceAllBtn.domNode),this._toggleReplaceBtn=this._register(new ah({label:oV,className:"codicon toggle left",onTrigger:()=>{this._state.change({isReplaceRevealed:!this._isReplaceVisible},!1),this._isReplaceVisible&&(this._replaceInput.width=wr(this._findInput.domNode),this._replaceInput.inputBox.layout()),this._showViewZone()}},this._hoverService)),this._toggleReplaceBtn.setExpanded(this._isReplaceVisible),this._domNode=document.createElement("div"),this._domNode.className="editor-widget find-widget",this._domNode.setAttribute("aria-hidden","true"),this._domNode.ariaLabel=Kz,this._domNode.role="dialog",this._domNode.style.width=`${va}px`,this._domNode.appendChild(this._toggleReplaceBtn.domNode),this._domNode.appendChild(n),this._domNode.appendChild(this._closeBtn.domNode),this._domNode.appendChild(a),this._resizeSash=this._register(new Ch(this._domNode,this,{orientation:0,size:2})),this._resized=!1;let u=va;this._register(this._resizeSash.onDidStart(()=>{u=wr(this._domNode)})),this._register(this._resizeSash.onDidChange(f=>{this._resized=!0;const g=u+f.startX-f.currentX;if(g<va)return;const p=parseFloat(iO(this._domNode).maxWidth)||0;g>p||(this._domNode.style.width=`${g}px`,this._isReplaceVisible&&(this._replaceInput.width=wr(this._findInput.domNode)),this._findInput.inputBox.layout(),this._tryUpdateHeight())})),this._register(this._resizeSash.onDidReset(()=>{const f=wr(this._domNode);if(f<va)return;let g=va;if(!this._resized||f===va){const p=this._codeEditor.getLayoutInfo();g=p.width-28-p.minimap.minimapWidth-15,this._resized=!0}this._domNode.style.width=`${g}px`,this._isReplaceVisible&&(this._replaceInput.width=wr(this._findInput.domNode)),this._findInput.inputBox.layout()}))}updateAccessibilitySupport(){const e=this._codeEditor.getOption(2);this._findInput.setFocusInputOnOptionClick(e!==2)}};Hb.ID="editor.contrib.findWidget";let GC=Hb;class ah extends h_{constructor(e,t){super(),this._opts=e;let i="button";this._opts.className&&(i=i+" "+this._opts.className),this._opts.icon&&(i=i+" "+xn.asClassName(this._opts.icon)),this._domNode=document.createElement("div"),this._domNode.tabIndex=0,this._domNode.className=i,this._domNode.setAttribute("role","button"),this._domNode.setAttribute("aria-label",this._opts.label),this._register(t.setupManagedHover(e.hoverDelegate??Dy("element"),this._domNode,this._opts.label)),this.onclick(this._domNode,n=>{this._opts.onTrigger(),n.preventDefault()}),this.onkeydown(this._domNode,n=>{var s,r;if(n.equals(10)||n.equals(3)){this._opts.onTrigger(),n.preventDefault();return}(r=(s=this._opts).onKeyDown)==null||r.call(s,n)})}get domNode(){return this._domNode}isEnabled(){return this._domNode.tabIndex>=0}focus(){this._domNode.focus()}setEnabled(e){this._domNode.classList.toggle("disabled",!e),this._domNode.setAttribute("aria-disabled",String(!e)),this._domNode.tabIndex=e?0:-1}setExpanded(e){this._domNode.setAttribute("aria-expanded",String(!!e)),e?(this._domNode.classList.remove(...xn.asClassNameArray(MI)),this._domNode.classList.add(...xn.asClassNameArray(RI))):(this._domNode.classList.remove(...xn.asClassNameArray(RI)),this._domNode.classList.add(...xn.asClassNameArray(MI)))}}Sy((o,e)=>{const t=o.getColor(VD);t&&e.addRule(`.monaco-editor .findMatch { border: 1px ${hp(o.type)?"dotted":"solid"} ${t}; box-sizing: border-box; }`);const i=o.getColor(nO);i&&e.addRule(`.monaco-editor .findScope { border: 1px ${hp(o.type)?"dashed":"solid"} ${i}; }`);const n=o.getColor(Sl);n&&e.addRule(`.monaco-editor .find-widget { border: 1px solid ${n}; }`);const s=o.getColor(sO);s&&e.addRule(`.monaco-editor .findMatchInline { color: ${s}; }`);const r=o.getColor(oO);r&&e.addRule(`.monaco-editor .currentFindMatchInline { color: ${r}; }`)});var HR=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},or=function(o,e){return function(t,i){e(t,i,o)}},KC;const uV=524288;function ZC(o,e="single",t=!1){if(!o.hasModel())return null;const i=o.getSelection();if(e==="single"&&i.startLineNumber===i.endLineNumber||e==="multiple"){if(i.isEmpty()){const n=o.getConfiguredWordAtPosition(i.getStartPosition());if(n&&t===!1)return n.word}else if(o.getModel().getValueLengthInRange(i)<uV)return o.getModel().getValueInRange(i)}return null}var Gd;let bo=(Gd=class extends Dt{get editor(){return this._editor}static get(e){return e.getContribution(KC.ID)}constructor(e,t,i,n,s,r){super(),this._editor=e,this._findWidgetVisible=Hl.bindTo(t),this._contextKeyService=t,this._storageService=i,this._clipboardService=n,this._notificationService=s,this._hoverService=r,this._updateHistoryDelayer=new Mc(500),this._state=this._register(new Hz),this.loadQueryState(),this._register(this._state.onFindReplaceStateChange(a=>this._onStateChanged(a))),this._model=null,this._register(this._editor.onDidChangeModel(()=>{const a=this._editor.getModel()&&this._state.isRevealed;this.disposeModel(),this._state.change({searchScope:null,matchCase:this._storageService.getBoolean("editor.matchCase",1,!1),wholeWord:this._storageService.getBoolean("editor.wholeWord",1,!1),isRegex:this._storageService.getBoolean("editor.isRegex",1,!1),preserveCase:this._storageService.getBoolean("editor.preserveCase",1,!1)},!1),a&&this._start({forceRevealReplace:!1,seedSearchStringFromSelection:"none",seedSearchStringFromNonEmptySelection:!1,seedSearchStringFromGlobalClipboard:!1,shouldFocus:0,shouldAnimate:!1,updateSearchScope:!1,loop:this._editor.getOption(41).loop})}))}dispose(){this.disposeModel(),super.dispose()}disposeModel(){this._model&&(this._model.dispose(),this._model=null)}_onStateChanged(e){this.saveQueryState(e),e.isRevealed&&(this._state.isRevealed?this._findWidgetVisible.set(!0):(this._findWidgetVisible.reset(),this.disposeModel())),e.searchString&&this.setGlobalBufferTerm(this._state.searchString)}saveQueryState(e){e.isRegex&&this._storageService.store("editor.isRegex",this._state.actualIsRegex,1,1),e.wholeWord&&this._storageService.store("editor.wholeWord",this._state.actualWholeWord,1,1),e.matchCase&&this._storageService.store("editor.matchCase",this._state.actualMatchCase,1,1),e.preserveCase&&this._storageService.store("editor.preserveCase",this._state.actualPreserveCase,1,1)}loadQueryState(){this._state.change({matchCase:this._storageService.getBoolean("editor.matchCase",1,this._state.matchCase),wholeWord:this._storageService.getBoolean("editor.wholeWord",1,this._state.wholeWord),isRegex:this._storageService.getBoolean("editor.isRegex",1,this._state.isRegex),preserveCase:this._storageService.getBoolean("editor.preserveCase",1,this._state.preserveCase)},!1)}isFindInputFocused(){return!!ew.getValue(this._contextKeyService)}getState(){return this._state}closeFindWidget(){this._state.change({isRevealed:!1,searchScope:null},!1),this._editor.focus()}toggleCaseSensitive(){this._state.change({matchCase:!this._state.matchCase},!1),this._state.isRevealed||this.highlightFindOptions()}toggleWholeWords(){this._state.change({wholeWord:!this._state.wholeWord},!1),this._state.isRevealed||this.highlightFindOptions()}toggleRegex(){this._state.change({isRegex:!this._state.isRegex},!1),this._state.isRevealed||this.highlightFindOptions()}togglePreserveCase(){this._state.change({preserveCase:!this._state.preserveCase},!1),this._state.isRevealed||this.highlightFindOptions()}toggleSearchScope(){if(this._state.searchScope)this._state.change({searchScope:null},!0);else if(this._editor.hasModel()){let e=this._editor.getSelections();e=e.map(t=>(t.endColumn===1&&t.endLineNumber>t.startLineNumber&&(t=t.setEndPosition(t.endLineNumber-1,this._editor.getModel().getLineMaxColumn(t.endLineNumber-1))),t.isEmpty()?null:t)).filter(t=>!!t),e.length&&this._state.change({searchScope:e},!0)}}setSearchString(e){this._state.isRegex&&(e=fp(e)),this._state.change({searchString:e},!1)}highlightFindOptions(e=!1){}async _start(e,t){if(this.disposeModel(),!this._editor.hasModel())return;const i={...t,isRevealed:!0};if(e.seedSearchStringFromSelection==="single"){const n=ZC(this._editor,e.seedSearchStringFromSelection,e.seedSearchStringFromNonEmptySelection);n&&(this._state.isRegex?i.searchString=fp(n):i.searchString=n)}else if(e.seedSearchStringFromSelection==="multiple"&&!e.updateSearchScope){const n=ZC(this._editor,e.seedSearchStringFromSelection);n&&(i.searchString=n)}if(!i.searchString&&e.seedSearchStringFromGlobalClipboard){const n=await this.getGlobalBufferTerm();if(!this._editor.hasModel())return;n&&(i.searchString=n)}if(e.forceRevealReplace||i.isReplaceRevealed?i.isReplaceRevealed=!0:this._findWidgetVisible.get()||(i.isReplaceRevealed=!1),e.updateSearchScope){const n=this._editor.getSelections();n.some(s=>!s.isEmpty())&&(i.searchScope=n)}i.loop=e.loop,this._state.change(i,!1),this._model||(this._model=new Xg(this._editor,this._state))}start(e,t){return this._start(e,t)}moveToNextMatch(){return this._model?(this._model.moveToNextMatch(),!0):!1}moveToPrevMatch(){return this._model?(this._model.moveToPrevMatch(),!0):!1}goToMatch(e){return this._model?(this._model.moveToMatch(e),!0):!1}replace(){return this._model?(this._model.replace(),!0):!1}replaceAll(){var e;return this._model?(e=this._editor.getModel())!=null&&e.isTooLargeForHeapOperation()?(this._notificationService.warn(C("too.large.for.replaceall","The file is too large to perform a replace all operation.")),!1):(this._model.replaceAll(),!0):!1}selectAllMatches(){return this._model?(this._model.selectAllMatches(),this._editor.focus(),!0):!1}async getGlobalBufferTerm(){return this._editor.getOption(41).globalFindClipboard&&this._editor.hasModel()&&!this._editor.getModel().isTooLargeForSyncing()?this._clipboardService.readFindText():""}setGlobalBufferTerm(e){this._editor.getOption(41).globalFindClipboard&&this._editor.hasModel()&&!this._editor.getModel().isTooLargeForSyncing()&&this._clipboardService.writeFindText(e)}},KC=Gd,Gd.ID="editor.contrib.findController",Gd);bo=KC=HR([or(1,Sn),or(2,zc),or(3,Vf),or(4,co),or(5,p_)],bo);let YC=class extends bo{constructor(e,t,i,n,s,r,a,d,u){super(e,i,a,d,r,u),this._contextViewService=t,this._keybindingService=n,this._themeService=s,this._widget=null,this._findOptionsWidget=null}async _start(e,t){this._widget||this._createFindWidget();const i=this._editor.getSelection();let n=!1;switch(this._editor.getOption(41).autoFindInSelection){case"always":n=!0;break;case"never":n=!1;break;case"multiline":{n=!!i&&i.startLineNumber!==i.endLineNumber;break}}e.updateSearchScope=e.updateSearchScope||n,await super._start(e,t),this._widget&&(e.shouldFocus===2?this._widget.focusReplaceInput():e.shouldFocus===1&&this._widget.focusFindInput())}highlightFindOptions(e=!1){this._widget||this._createFindWidget(),this._state.isRevealed&&!e?this._widget.highlightFindOptions():this._findOptionsWidget.highlightFindOptions()}_createFindWidget(){this._widget=this._register(new GC(this._editor,this,this._state,this._contextViewService,this._keybindingService,this._contextKeyService,this._themeService,this._storageService,this._notificationService,this._hoverService)),this._findOptionsWidget=this._register(new $C(this._editor,this._state,this._keybindingService))}};YC=HR([or(1,wy),or(2,Sn),or(3,hs),or(4,Hr),or(5,co),or(6,zc),or(7,Vf),or(8,p_)],YC);const hV=dT(new uT({id:Rn.StartFindAction,label:C("startFindAction","Find"),alias:"Find",precondition:Ae.or(B.focus,Ae.has("editorIsOpen")),kbOpts:{kbExpr:null,primary:2084,weight:100},menuOpts:{menuId:Gt.MenubarEditMenu,group:"3_find",title:C({key:"miFind",comment:["&& denotes a mnemonic"]},"&&Find"),order:1}}));hV.addImplementation(0,(o,e,t)=>{const i=bo.get(e);return i?i.start({forceRevealReplace:!1,seedSearchStringFromSelection:e.getOption(41).seedSearchStringFromSelection!=="never"?"single":"none",seedSearchStringFromNonEmptySelection:e.getOption(41).seedSearchStringFromSelection==="selection",seedSearchStringFromGlobalClipboard:e.getOption(41).globalFindClipboard,shouldFocus:1,shouldAnimate:!0,updateSearchScope:!1,loop:e.getOption(41).loop}):!1});const fV={description:"Open a new In-Editor Find Widget.",args:[{name:"Open a new In-Editor Find Widget args",schema:{properties:{searchString:{type:"string"},replaceString:{type:"string"},isRegex:{type:"boolean"},matchWholeWord:{type:"boolean"},isCaseSensitive:{type:"boolean"},preserveCase:{type:"boolean"},findInSelection:{type:"boolean"}}}}]};class gV extends lt{constructor(){super({id:Rn.StartFindWithArgs,label:C("startFindWithArgsAction","Find With Arguments"),alias:"Find With Arguments",precondition:void 0,kbOpts:{kbExpr:null,primary:0,weight:100},metadata:fV})}async run(e,t,i){const n=bo.get(t);if(n){const s=i?{searchString:i.searchString,replaceString:i.replaceString,isReplaceRevealed:i.replaceString!==void 0,isRegex:i.isRegex,wholeWord:i.matchWholeWord,matchCase:i.isCaseSensitive,preserveCase:i.preserveCase}:{};await n.start({forceRevealReplace:!1,seedSearchStringFromSelection:n.getState().searchString.length===0&&t.getOption(41).seedSearchStringFromSelection!=="never"?"single":"none",seedSearchStringFromNonEmptySelection:t.getOption(41).seedSearchStringFromSelection==="selection",seedSearchStringFromGlobalClipboard:!0,shouldFocus:1,shouldAnimate:!0,updateSearchScope:(i==null?void 0:i.findInSelection)||!1,loop:t.getOption(41).loop},s),n.setGlobalBufferTerm(n.getState().searchString)}}}class pV extends lt{constructor(){super({id:Rn.StartFindWithSelection,label:C("startFindWithSelectionAction","Find With Selection"),alias:"Find With Selection",precondition:void 0,kbOpts:{kbExpr:null,primary:0,mac:{primary:2083},weight:100}})}async run(e,t){const i=bo.get(t);i&&(await i.start({forceRevealReplace:!1,seedSearchStringFromSelection:"multiple",seedSearchStringFromNonEmptySelection:!1,seedSearchStringFromGlobalClipboard:!1,shouldFocus:0,shouldAnimate:!0,updateSearchScope:!1,loop:t.getOption(41).loop}),i.setGlobalBufferTerm(i.getState().searchString))}}class WR extends lt{async run(e,t){const i=bo.get(t);i&&!this._run(i)&&(await i.start({forceRevealReplace:!1,seedSearchStringFromSelection:i.getState().searchString.length===0&&t.getOption(41).seedSearchStringFromSelection!=="never"?"single":"none",seedSearchStringFromNonEmptySelection:t.getOption(41).seedSearchStringFromSelection==="selection",seedSearchStringFromGlobalClipboard:!0,shouldFocus:0,shouldAnimate:!0,updateSearchScope:!1,loop:t.getOption(41).loop}),this._run(i))}}class _V extends WR{constructor(){super({id:Rn.NextMatchFindAction,label:C("findNextMatchAction","Find Next"),alias:"Find Next",precondition:void 0,kbOpts:[{kbExpr:B.focus,primary:61,mac:{primary:2085,secondary:[61]},weight:100},{kbExpr:Ae.and(B.focus,ew),primary:3,weight:100}]})}_run(e){return e.moveToNextMatch()?(e.editor.pushUndoStop(),!0):!1}}class mV extends WR{constructor(){super({id:Rn.PreviousMatchFindAction,label:C("findPreviousMatchAction","Find Previous"),alias:"Find Previous",precondition:void 0,kbOpts:[{kbExpr:B.focus,primary:1085,mac:{primary:3109,secondary:[1085]},weight:100},{kbExpr:Ae.and(B.focus,ew),primary:1027,weight:100}]})}_run(e){return e.moveToPrevMatch()}}class vV extends lt{constructor(){super({id:Rn.GoToMatchFindAction,label:C("findMatchAction.goToMatch","Go to Match..."),alias:"Go to Match...",precondition:Hl}),this._highlightDecorations=[]}run(e,t,i){const n=bo.get(t);if(!n)return;const s=n.getState().matchesCount;if(s<1){e.get(co).notify({severity:d0.Warning,message:C("findMatchAction.noResults","No matches. Try searching for something else.")});return}const r=e.get(Ml),a=new Lt,d=a.add(r.createInputBox());d.placeholder=C("findMatchAction.inputPlaceHolder","Type a number to go to a specific match (between 1 and {0})",s);const u=g=>{const p=parseInt(g);if(isNaN(p))return;const w=n.getState().matchesCount;if(p>0&&p<=w)return p-1;if(p<0&&p>=-w)return w+p},f=g=>{const p=u(g);if(typeof p=="number"){d.validationMessage=void 0,n.goToMatch(p);const w=n.getState().currentMatch;w&&this.addDecorations(t,w)}else d.validationMessage=C("findMatchAction.inputValidationMessage","Please type a number between 1 and {0}",n.getState().matchesCount),this.clearDecorations(t)};a.add(d.onDidChangeValue(g=>{f(g)})),a.add(d.onDidAccept(()=>{const g=u(d.value);typeof g=="number"?(n.goToMatch(g),d.hide()):d.validationMessage=C("findMatchAction.inputValidationMessage","Please type a number between 1 and {0}",n.getState().matchesCount)})),a.add(d.onDidHide(()=>{this.clearDecorations(t),a.dispose()})),d.show()}clearDecorations(e){e.changeDecorations(t=>{this._highlightDecorations=t.deltaDecorations(this._highlightDecorations,[])})}addDecorations(e,t){e.changeDecorations(i=>{this._highlightDecorations=i.deltaDecorations(this._highlightDecorations,[{range:t,options:{description:"find-match-quick-access-range-highlight",className:"rangeHighlight",isWholeLine:!0}},{range:t,options:{description:"find-match-quick-access-range-highlight-overview",overviewRuler:{color:_s(hT),position:Ha.Full}}}])})}}class BR extends lt{async run(e,t){const i=bo.get(t);if(!i)return;const n=ZC(t,"single",!1);n&&i.setSearchString(n),this._run(i)||(await i.start({forceRevealReplace:!1,seedSearchStringFromSelection:"none",seedSearchStringFromNonEmptySelection:!1,seedSearchStringFromGlobalClipboard:!1,shouldFocus:0,shouldAnimate:!0,updateSearchScope:!1,loop:t.getOption(41).loop}),this._run(i))}}class bV extends BR{constructor(){super({id:Rn.NextSelectionMatchFindAction,label:C("nextSelectionMatchFindAction","Find Next Selection"),alias:"Find Next Selection",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:2109,weight:100}})}_run(e){return e.moveToNextMatch()}}class yV extends BR{constructor(){super({id:Rn.PreviousSelectionMatchFindAction,label:C("previousSelectionMatchFindAction","Find Previous Selection"),alias:"Find Previous Selection",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:3133,weight:100}})}_run(e){return e.moveToPrevMatch()}}const wV=dT(new uT({id:Rn.StartFindReplaceAction,label:C("startReplace","Replace"),alias:"Replace",precondition:Ae.or(B.focus,Ae.has("editorIsOpen")),kbOpts:{kbExpr:null,primary:2086,mac:{primary:2596},weight:100},menuOpts:{menuId:Gt.MenubarEditMenu,group:"3_find",title:C({key:"miReplace",comment:["&& denotes a mnemonic"]},"&&Replace"),order:2}}));wV.addImplementation(0,(o,e,t)=>{if(!e.hasModel()||e.getOption(92))return!1;const i=bo.get(e);if(!i)return!1;const n=e.getSelection(),s=i.isFindInputFocused(),r=!n.isEmpty()&&n.startLineNumber===n.endLineNumber&&e.getOption(41).seedSearchStringFromSelection!=="never"&&!s,a=s||r?2:1;return i.start({forceRevealReplace:!0,seedSearchStringFromSelection:r?"single":"none",seedSearchStringFromNonEmptySelection:e.getOption(41).seedSearchStringFromSelection==="selection",seedSearchStringFromGlobalClipboard:e.getOption(41).seedSearchStringFromSelection!=="never",shouldFocus:a,shouldAnimate:!0,updateSearchScope:!1,loop:e.getOption(41).loop})});nn(bo.ID,YC,0);xe(gV);xe(pV);xe(_V);xe(mV);xe(vV);xe(bV);xe(yV);const pa=wo.bindToContribution(bo.get);bi(new pa({id:Rn.CloseFindWidgetCommand,precondition:Hl,handler:o=>o.closeFindWidget(),kbOpts:{weight:105,kbExpr:Ae.and(B.focus,Ae.not("isComposing")),primary:9,secondary:[1033]}}));bi(new pa({id:Rn.ToggleCaseSensitiveCommand,precondition:void 0,handler:o=>o.toggleCaseSensitive(),kbOpts:{weight:105,kbExpr:B.focus,primary:om.primary,mac:om.mac,win:om.win,linux:om.linux}}));bi(new pa({id:Rn.ToggleWholeWordCommand,precondition:void 0,handler:o=>o.toggleWholeWords(),kbOpts:{weight:105,kbExpr:B.focus,primary:rm.primary,mac:rm.mac,win:rm.win,linux:rm.linux}}));bi(new pa({id:Rn.ToggleRegexCommand,precondition:void 0,handler:o=>o.toggleRegex(),kbOpts:{weight:105,kbExpr:B.focus,primary:am.primary,mac:am.mac,win:am.win,linux:am.linux}}));bi(new pa({id:Rn.ToggleSearchScopeCommand,precondition:void 0,handler:o=>o.toggleSearchScope(),kbOpts:{weight:105,kbExpr:B.focus,primary:lm.primary,mac:lm.mac,win:lm.win,linux:lm.linux}}));bi(new pa({id:Rn.TogglePreserveCaseCommand,precondition:void 0,handler:o=>o.togglePreserveCase(),kbOpts:{weight:105,kbExpr:B.focus,primary:cm.primary,mac:cm.mac,win:cm.win,linux:cm.linux}}));bi(new pa({id:Rn.ReplaceOneAction,precondition:Hl,handler:o=>o.replace(),kbOpts:{weight:105,kbExpr:B.focus,primary:3094}}));bi(new pa({id:Rn.ReplaceOneAction,precondition:Hl,handler:o=>o.replace(),kbOpts:{weight:105,kbExpr:Ae.and(B.focus,sk),primary:3}}));bi(new pa({id:Rn.ReplaceAllAction,precondition:Hl,handler:o=>o.replaceAll(),kbOpts:{weight:105,kbExpr:B.focus,primary:2563}}));bi(new pa({id:Rn.ReplaceAllAction,precondition:Hl,handler:o=>o.replaceAll(),kbOpts:{weight:105,kbExpr:Ae.and(B.focus,sk),primary:void 0,mac:{primary:2051}}}));bi(new pa({id:Rn.SelectAllMatchesAction,precondition:Hl,handler:o=>o.selectAllMatches(),kbOpts:{weight:105,kbExpr:B.focus,primary:515}}));const SV={0:" ",1:"u",2:"r"},WI=65535,Jr=16777215,BI=4278190080;class Gw{constructor(e){const t=Math.ceil(e/32);this._states=new Uint32Array(t)}get(e){const t=e/32|0,i=e%32;return(this._states[t]&1<<i)!==0}set(e,t){const i=e/32|0,n=e%32,s=this._states[i];t?this._states[i]=s|1<<n:this._states[i]=s&~(1<<n)}}class Vo{constructor(e,t,i){if(e.length!==t.length||e.length>WI)throw new Error("invalid startIndexes or endIndexes size");this._startIndexes=e,this._endIndexes=t,this._collapseStates=new Gw(e.length),this._userDefinedStates=new Gw(e.length),this._recoveredStates=new Gw(e.length),this._types=i,this._parentsComputed=!1}ensureParentIndices(){if(!this._parentsComputed){this._parentsComputed=!0;const e=[],t=(i,n)=>{const s=e[e.length-1];return this.getStartLineNumber(s)<=i&&this.getEndLineNumber(s)>=n};for(let i=0,n=this._startIndexes.length;i<n;i++){const s=this._startIndexes[i],r=this._endIndexes[i];if(s>Jr||r>Jr)throw new Error("startLineNumber or endLineNumber must not exceed "+Jr);for(;e.length>0&&!t(s,r);)e.pop();const a=e.length>0?e[e.length-1]:-1;e.push(i),this._startIndexes[i]=s+((a&255)<<24),this._endIndexes[i]=r+((a&65280)<<16)}}}get length(){return this._startIndexes.length}getStartLineNumber(e){return this._startIndexes[e]&Jr}getEndLineNumber(e){return this._endIndexes[e]&Jr}getType(e){return this._types?this._types[e]:void 0}hasTypes(){return!!this._types}isCollapsed(e){return this._collapseStates.get(e)}setCollapsed(e,t){this._collapseStates.set(e,t)}isUserDefined(e){return this._userDefinedStates.get(e)}setUserDefined(e,t){return this._userDefinedStates.set(e,t)}isRecovered(e){return this._recoveredStates.get(e)}setRecovered(e,t){return this._recoveredStates.set(e,t)}getSource(e){return this.isUserDefined(e)?1:this.isRecovered(e)?2:0}setSource(e,t){t===1?(this.setUserDefined(e,!0),this.setRecovered(e,!1)):t===2?(this.setUserDefined(e,!1),this.setRecovered(e,!0)):(this.setUserDefined(e,!1),this.setRecovered(e,!1))}setCollapsedAllOfType(e,t){let i=!1;if(this._types)for(let n=0;n<this._types.length;n++)this._types[n]===e&&(this.setCollapsed(n,t),i=!0);return i}toRegion(e){return new CV(this,e)}getParentIndex(e){this.ensureParentIndices();const t=((this._startIndexes[e]&BI)>>>24)+((this._endIndexes[e]&BI)>>>16);return t===WI?-1:t}contains(e,t){return this.getStartLineNumber(e)<=t&&this.getEndLineNumber(e)>=t}findIndex(e){let t=0,i=this._startIndexes.length;if(i===0)return-1;for(;t<i;){const n=Math.floor((t+i)/2);e<this.getStartLineNumber(n)?i=n:t=n+1}return t-1}findRange(e){let t=this.findIndex(e);if(t>=0){if(this.getEndLineNumber(t)>=e)return t;for(t=this.getParentIndex(t);t!==-1;){if(this.contains(t,e))return t;t=this.getParentIndex(t)}}return-1}toString(){const e=[];for(let t=0;t<this.length;t++)e[t]=`[${SV[this.getSource(t)]}${this.isCollapsed(t)?"+":"-"}] ${this.getStartLineNumber(t)}/${this.getEndLineNumber(t)}`;return e.join(", ")}toFoldRange(e){return{startLineNumber:this._startIndexes[e]&Jr,endLineNumber:this._endIndexes[e]&Jr,type:this._types?this._types[e]:void 0,isCollapsed:this.isCollapsed(e),source:this.getSource(e)}}static fromFoldRanges(e){const t=e.length,i=new Uint32Array(t),n=new Uint32Array(t);let s=[],r=!1;for(let d=0;d<t;d++){const u=e[d];i[d]=u.startLineNumber,n[d]=u.endLineNumber,s.push(u.type),u.type&&(r=!0)}r||(s=void 0);const a=new Vo(i,n,s);for(let d=0;d<t;d++)e[d].isCollapsed&&a.setCollapsed(d,!0),a.setSource(d,e[d].source);return a}static sanitizeAndMerge(e,t,i,n){i=i??Number.MAX_VALUE;const s=(k,D)=>Array.isArray(k)?(M=>M<D?k[M]:void 0):(M=>M<D?k.toFoldRange(M):void 0),r=s(e,e.length),a=s(t,t.length);let d=0,u=0,f=r(0),g=a(0);const p=[];let w,y=0;const x=[];for(;f||g;){let k;if(g&&(!f||f.startLineNumber>=g.startLineNumber))f&&f.startLineNumber===g.startLineNumber?(g.source===1?k=g:(k=f,k.isCollapsed=g.isCollapsed&&(f.endLineNumber===g.endLineNumber||!(n!=null&&n.startsInside(f.startLineNumber+1,f.endLineNumber+1))),k.source=0),f=r(++d)):(k=g,g.isCollapsed&&g.source===0&&(k.source=2)),g=a(++u);else{let D=u,M=g;for(;;){if(!M||M.startLineNumber>f.endLineNumber){k=f;break}if(M.source===1&&M.endLineNumber>f.endLineNumber)break;M=a(++D)}f=r(++d)}if(k){for(;w&&w.endLineNumber<k.startLineNumber;)w=p.pop();k.endLineNumber>k.startLineNumber&&k.startLineNumber>y&&k.endLineNumber<=i&&(!w||w.endLineNumber>=k.endLineNumber)&&(x.push(k),y=k.startLineNumber,w&&p.push(w),w=k)}}return x}}class CV{constructor(e,t){this.ranges=e,this.index=t}get startLineNumber(){return this.ranges.getStartLineNumber(this.index)}get endLineNumber(){return this.ranges.getEndLineNumber(this.index)}get regionIndex(){return this.index}get parentIndex(){return this.ranges.getParentIndex(this.index)}get isCollapsed(){return this.ranges.isCollapsed(this.index)}containedBy(e){return e.startLineNumber<=this.startLineNumber&&e.endLineNumber>=this.endLineNumber}containsLine(e){return this.startLineNumber<=e&&e<=this.endLineNumber}}class xV{get regions(){return this._regions}get textModel(){return this._textModel}constructor(e,t){this._updateEventEmitter=new Xi,this.onDidChange=this._updateEventEmitter.event,this._textModel=e,this._decorationProvider=t,this._regions=new Vo(new Uint32Array(0),new Uint32Array(0)),this._editorDecorationIds=[]}toggleCollapseState(e){if(!e.length)return;e=e.sort((i,n)=>i.regionIndex-n.regionIndex);const t={};this._decorationProvider.changeDecorations(i=>{let n=0,s=-1,r=-1;const a=d=>{for(;n<d;){const u=this._regions.getEndLineNumber(n),f=this._regions.isCollapsed(n);if(u<=s){const g=this.regions.getSource(n)!==0;i.changeDecorationOptions(this._editorDecorationIds[n],this._decorationProvider.getDecorationOption(f,u<=r,g))}f&&u>r&&(r=u),n++}};for(const d of e){const u=d.regionIndex,f=this._editorDecorationIds[u];if(f&&!t[f]){t[f]=!0,a(u);const g=!this._regions.isCollapsed(u);this._regions.setCollapsed(u,g),s=Math.max(s,this._regions.getEndLineNumber(u))}}a(this._regions.length)}),this._updateEventEmitter.fire({model:this,collapseStateChanged:e})}removeManualRanges(e){const t=new Array,i=n=>{for(const s of e)if(!(s.startLineNumber>n.endLineNumber||n.startLineNumber>s.endLineNumber))return!0;return!1};for(let n=0;n<this._regions.length;n++){const s=this._regions.toFoldRange(n);(s.source===0||!i(s))&&t.push(s)}this.updatePost(Vo.fromFoldRanges(t))}update(e,t){const i=this._currentFoldedOrManualRanges(t),n=Vo.sanitizeAndMerge(e,i,this._textModel.getLineCount(),t);this.updatePost(Vo.fromFoldRanges(n))}updatePost(e){const t=[];let i=-1;for(let n=0,s=e.length;n<s;n++){const r=e.getStartLineNumber(n),a=e.getEndLineNumber(n),d=e.isCollapsed(n),u=e.getSource(n)!==0,f={startLineNumber:r,startColumn:this._textModel.getLineMaxColumn(r),endLineNumber:a,endColumn:this._textModel.getLineMaxColumn(a)+1};t.push({range:f,options:this._decorationProvider.getDecorationOption(d,a<=i,u)}),d&&a>i&&(i=a)}this._decorationProvider.changeDecorations(n=>this._editorDecorationIds=n.deltaDecorations(this._editorDecorationIds,t)),this._regions=e,this._updateEventEmitter.fire({model:this})}_currentFoldedOrManualRanges(e){const t=[];for(let i=0,n=this._regions.length;i<n;i++){let s=this.regions.isCollapsed(i);const r=this.regions.getSource(i);if(s||r!==0){const a=this._regions.toFoldRange(i),d=this._textModel.getDecorationRange(this._editorDecorationIds[i]);d&&(s&&(e!=null&&e.startsInside(d.startLineNumber+1,d.endLineNumber))&&(s=!1),t.push({startLineNumber:d.startLineNumber,endLineNumber:d.endLineNumber,type:a.type,isCollapsed:s,source:r}))}}return t}getMemento(){const e=this._currentFoldedOrManualRanges(),t=[],i=this._textModel.getLineCount();for(let n=0,s=e.length;n<s;n++){const r=e[n];if(r.startLineNumber>=r.endLineNumber||r.startLineNumber<1||r.endLineNumber>i)continue;const a=this._getLinesChecksum(r.startLineNumber+1,r.endLineNumber);t.push({startLineNumber:r.startLineNumber,endLineNumber:r.endLineNumber,isCollapsed:r.isCollapsed,source:r.source,checksum:a})}return t.length>0?t:void 0}applyMemento(e){if(!Array.isArray(e))return;const t=[],i=this._textModel.getLineCount();for(const s of e){if(s.startLineNumber>=s.endLineNumber||s.startLineNumber<1||s.endLineNumber>i)continue;const r=this._getLinesChecksum(s.startLineNumber+1,s.endLineNumber);(!s.checksum||r===s.checksum)&&t.push({startLineNumber:s.startLineNumber,endLineNumber:s.endLineNumber,type:void 0,isCollapsed:s.isCollapsed??!0,source:s.source??0})}const n=Vo.sanitizeAndMerge(this._regions,t,i);this.updatePost(Vo.fromFoldRanges(n))}_getLinesChecksum(e,t){return fT(this._textModel.getLineContent(e)+this._textModel.getLineContent(t))%1e6}dispose(){this._decorationProvider.removeDecorations(this._editorDecorationIds)}getAllRegionsAtLine(e,t){const i=[];if(this._regions){let n=this._regions.findRange(e),s=1;for(;n>=0;){const r=this._regions.toRegion(n);(!t||t(r,s))&&i.push(r),s++,n=r.parentIndex}}return i}getRegionAtLine(e){if(this._regions){const t=this._regions.findRange(e);if(t>=0)return this._regions.toRegion(t)}return null}getRegionsInside(e,t){const i=[],n=e?e.regionIndex+1:0,s=e?e.endLineNumber:Number.MAX_VALUE;if(t&&t.length===2){const r=[];for(let a=n,d=this._regions.length;a<d;a++){const u=this._regions.toRegion(a);if(this._regions.getStartLineNumber(a)<s){for(;r.length>0&&!u.containedBy(r[r.length-1]);)r.pop();r.push(u),t(u,r.length)&&i.push(u)}else break}}else for(let r=n,a=this._regions.length;r<a;r++){const d=this._regions.toRegion(r);if(this._regions.getStartLineNumber(r)<s)(!t||t(d))&&i.push(d);else break}return i}}function ak(o,e,t){const i=[];for(const n of t){const s=o.getRegionAtLine(n);if(s){const r=!s.isCollapsed;if(i.push(s),e>1){const a=o.getRegionsInside(s,(d,u)=>d.isCollapsed!==r&&u<e);i.push(...a)}}}o.toggleCollapseState(i)}function Xf(o,e,t=Number.MAX_VALUE,i){const n=[];if(i&&i.length>0)for(const s of i){const r=o.getRegionAtLine(s);if(r&&(r.isCollapsed!==e&&n.push(r),t>1)){const a=o.getRegionsInside(r,(d,u)=>d.isCollapsed!==e&&u<t);n.push(...a)}}else{const s=o.getRegionsInside(null,(r,a)=>r.isCollapsed!==e&&a<t);n.push(...s)}o.toggleCollapseState(n)}function zR(o,e,t,i){const n=[];for(const s of i){const r=o.getAllRegionsAtLine(s,(a,d)=>a.isCollapsed!==e&&d<=t);n.push(...r)}o.toggleCollapseState(n)}function kV(o,e,t){const i=[];for(const n of t){const s=o.getAllRegionsAtLine(n,r=>r.isCollapsed!==e);s.length>0&&i.push(s[0])}o.toggleCollapseState(i)}function LV(o,e,t,i){const n=(r,a)=>a===e&&r.isCollapsed!==t&&!i.some(d=>r.containsLine(d)),s=o.getRegionsInside(null,n);o.toggleCollapseState(s)}function VR(o,e,t){const i=[];for(const r of t){const a=o.getAllRegionsAtLine(r,void 0);a.length>0&&i.push(a[0])}const n=r=>i.every(a=>!a.containedBy(r)&&!r.containedBy(a))&&r.isCollapsed!==e,s=o.getRegionsInside(null,n);o.toggleCollapseState(s)}function lk(o,e,t){const i=o.textModel,n=o.regions,s=[];for(let r=n.length-1;r>=0;r--)if(t!==n.isCollapsed(r)){const a=n.getStartLineNumber(r);e.test(i.getLineContent(a))&&s.push(n.toRegion(r))}o.toggleCollapseState(s)}function ck(o,e,t){const i=o.regions,n=[];for(let s=i.length-1;s>=0;s--)t!==i.isCollapsed(s)&&e===i.getType(s)&&n.push(i.toRegion(s));o.toggleCollapseState(n)}function IV(o,e){let t=null;const i=e.getRegionAtLine(o);if(i!==null&&(t=i.startLineNumber,o===t)){const n=i.parentIndex;n!==-1?t=e.regions.getStartLineNumber(n):t=null}return t}function EV(o,e){let t=e.getRegionAtLine(o);if(t!==null&&t.startLineNumber===o){if(o!==t.startLineNumber)return t.startLineNumber;{const i=t.parentIndex;let n=0;for(i!==-1&&(n=e.regions.getStartLineNumber(t.parentIndex));t!==null;)if(t.regionIndex>0){if(t=e.regions.toRegion(t.regionIndex-1),t.startLineNumber<=n)return null;if(t.parentIndex===i)return t.startLineNumber}else return null}}else if(e.regions.length>0)for(t=e.regions.toRegion(e.regions.length-1);t!==null;){if(t.startLineNumber<o)return t.startLineNumber;t.regionIndex>0?t=e.regions.toRegion(t.regionIndex-1):t=null}return null}function DV(o,e){let t=e.getRegionAtLine(o);if(t!==null&&t.startLineNumber===o){const i=t.parentIndex;let n=0;if(i!==-1)n=e.regions.getEndLineNumber(t.parentIndex);else{if(e.regions.length===0)return null;n=e.regions.getEndLineNumber(e.regions.length-1)}for(;t!==null;)if(t.regionIndex<e.regions.length){if(t=e.regions.toRegion(t.regionIndex+1),t.startLineNumber>=n)return null;if(t.parentIndex===i)return t.startLineNumber}else return null}else if(e.regions.length>0)for(t=e.regions.toRegion(0);t!==null;){if(t.startLineNumber>o)return t.startLineNumber;t.regionIndex<e.regions.length?t=e.regions.toRegion(t.regionIndex+1):t=null}return null}class TV{get onDidChange(){return this._updateEventEmitter.event}get hiddenRanges(){return this._hiddenRanges}constructor(e){this._updateEventEmitter=new Xi,this._hasLineChanges=!1,this._foldingModel=e,this._foldingModelListener=e.onDidChange(t=>this.updateHiddenRanges()),this._hiddenRanges=[],e.regions.length&&this.updateHiddenRanges()}notifyChangeModelContent(e){this._hiddenRanges.length&&!this._hasLineChanges&&(this._hasLineChanges=e.changes.some(t=>t.range.endLineNumber!==t.range.startLineNumber||rO(t.text)[0]!==0))}updateHiddenRanges(){let e=!1;const t=[];let i=0,n=0,s=Number.MAX_VALUE,r=-1;const a=this._foldingModel.regions;for(;i<a.length;i++){if(!a.isCollapsed(i))continue;const d=a.getStartLineNumber(i)+1,u=a.getEndLineNumber(i);s<=d&&u<=r||(!e&&n<this._hiddenRanges.length&&this._hiddenRanges[n].startLineNumber===d&&this._hiddenRanges[n].endLineNumber===u?(t.push(this._hiddenRanges[n]),n++):(e=!0,t.push(new Z(d,1,u,1))),s=d,r=u)}(this._hasLineChanges||e||n<this._hiddenRanges.length)&&this.applyHiddenRanges(t)}applyHiddenRanges(e){this._hiddenRanges=e,this._hasLineChanges=!1,this._updateEventEmitter.fire(e)}hasRanges(){return this._hiddenRanges.length>0}isHidden(e){return zI(this._hiddenRanges,e)!==null}adjustSelections(e){let t=!1;const i=this._foldingModel.textModel;let n=null;const s=r=>((!n||!PV(r,n))&&(n=zI(this._hiddenRanges,r)),n?n.startLineNumber-1:null);for(let r=0,a=e.length;r<a;r++){let d=e[r];const u=s(d.startLineNumber);u&&(d=d.setStartPosition(u,i.getLineMaxColumn(u)),t=!0);const f=s(d.endLineNumber);f&&(d=d.setEndPosition(f,i.getLineMaxColumn(f)),t=!0),e[r]=d}return t}dispose(){this.hiddenRanges.length>0&&(this._hiddenRanges=[],this._updateEventEmitter.fire(this._hiddenRanges)),this._foldingModelListener&&(this._foldingModelListener.dispose(),this._foldingModelListener=null)}}function PV(o,e){return o>=e.startLineNumber&&o<=e.endLineNumber}function zI(o,e){const t=sT(o,i=>e<i.startLineNumber)-1;return t>=0&&o[t].endLineNumber>=e?o[t]:null}const MV=5e3,RV="indent";class dk{constructor(e,t,i){this.editorModel=e,this.languageConfigurationService=t,this.foldingRangesLimit=i,this.id=RV}dispose(){}compute(e){const t=this.languageConfigurationService.getLanguageConfiguration(this.editorModel.getLanguageId()).foldingRules,i=t&&!!t.offSide,n=t&&t.markers;return Promise.resolve(OV(this.editorModel,i,n,this.foldingRangesLimit))}}let NV=class{constructor(e){this._startIndexes=[],this._endIndexes=[],this._indentOccurrences=[],this._length=0,this._foldingRangesLimit=e}insertFirst(e,t,i){if(e>Jr||t>Jr)return;const n=this._length;this._startIndexes[n]=e,this._endIndexes[n]=t,this._length++,i<1e3&&(this._indentOccurrences[i]=(this._indentOccurrences[i]||0)+1)}toIndentRanges(e){const t=this._foldingRangesLimit.limit;if(this._length<=t){this._foldingRangesLimit.update(this._length,!1);const i=new Uint32Array(this._length),n=new Uint32Array(this._length);for(let s=this._length-1,r=0;s>=0;s--,r++)i[r]=this._startIndexes[s],n[r]=this._endIndexes[s];return new Vo(i,n)}else{this._foldingRangesLimit.update(this._length,t);let i=0,n=this._indentOccurrences.length;for(let d=0;d<this._indentOccurrences.length;d++){const u=this._indentOccurrences[d];if(u){if(u+i>t){n=d;break}i+=u}}const s=e.getOptions().tabSize,r=new Uint32Array(t),a=new Uint32Array(t);for(let d=this._length-1,u=0;d>=0;d--){const f=this._startIndexes[d],g=e.getLineContent(f),p=Qx(g,s);(p<n||p===n&&i++<t)&&(r[u]=f,a[u]=this._endIndexes[d],u++)}return new Vo(r,a)}}};const AV={limit:MV,update:()=>{}};function OV(o,e,t,i=AV){const n=o.getOptions().tabSize,s=new NV(i);let r;t&&(r=new RegExp(`(${t.start.source})|(?:${t.end.source})`));const a=[],d=o.getLineCount()+1;a.push({indent:-1,endAbove:d,line:d});for(let u=o.getLineCount();u>0;u--){const f=o.getLineContent(u),g=Qx(f,n);let p=a[a.length-1];if(g===-1){e&&(p.endAbove=u);continue}let w;if(r&&(w=f.match(r)))if(w[1]){let y=a.length-1;for(;y>0&&a[y].indent!==-2;)y--;if(y>0){a.length=y+1,p=a[y],s.insertFirst(u,p.line,g),p.line=u,p.indent=g,p.endAbove=u;continue}}else{a.push({indent:-2,endAbove:u,line:u});continue}if(p.indent>g){do a.pop(),p=a[a.length-1];while(p.indent>g);const y=p.endAbove-1;y-u>=1&&s.insertFirst(u,y,g)}p.indent===g?p.endAbove=u:a.push({indent:g,endAbove:u,line:u})}return s.toIndentRanges(o)}const FV=oi("editor.foldBackground",{light:Ba(yL,.3),dark:Ba(yL,.3),hcDark:null,hcLight:null},C("foldBackgroundBackground","Background color behind folded ranges. The color must not be opaque so as not to hide underlying decorations."),!0);oi("editor.foldPlaceholderForeground",{light:"#808080",dark:"#808080",hcDark:null,hcLight:null},C("collapsedTextColor","Color of the collapsed text after the first line of a folded range."));oi("editorGutter.foldingControlForeground",aO,C("editorGutter.foldingControlForeground","Color of the folding control in the editor gutter."));const Av=is("folding-expanded",ji.chevronDown,C("foldingExpandedIcon","Icon for expanded ranges in the editor glyph margin.")),Ov=is("folding-collapsed",ji.chevronRight,C("foldingCollapsedIcon","Icon for collapsed ranges in the editor glyph margin.")),VI=is("folding-manual-collapsed",Ov,C("foldingManualCollapedIcon","Icon for manually collapsed ranges in the editor glyph margin.")),jI=is("folding-manual-expanded",Av,C("foldingManualExpandedIcon","Icon for manually expanded ranges in the editor glyph margin.")),Kw={color:_s(FV),position:1},lh=C("linesCollapsed","Click to expand the range."),hm=C("linesExpanded","Click to collapse the range."),os=class os{constructor(e){this.editor=e,this.showFoldingControls="mouseover",this.showFoldingHighlights=!0}getDecorationOption(e,t,i){return t?os.HIDDEN_RANGE_DECORATION:this.showFoldingControls==="never"?e?this.showFoldingHighlights?os.NO_CONTROLS_COLLAPSED_HIGHLIGHTED_RANGE_DECORATION:os.NO_CONTROLS_COLLAPSED_RANGE_DECORATION:os.NO_CONTROLS_EXPANDED_RANGE_DECORATION:e?i?this.showFoldingHighlights?os.MANUALLY_COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION:os.MANUALLY_COLLAPSED_VISUAL_DECORATION:this.showFoldingHighlights?os.COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION:os.COLLAPSED_VISUAL_DECORATION:this.showFoldingControls==="mouseover"?i?os.MANUALLY_EXPANDED_AUTO_HIDE_VISUAL_DECORATION:os.EXPANDED_AUTO_HIDE_VISUAL_DECORATION:i?os.MANUALLY_EXPANDED_VISUAL_DECORATION:os.EXPANDED_VISUAL_DECORATION}changeDecorations(e){return this.editor.changeDecorations(e)}removeDecorations(e){this.editor.removeDecorations(e)}};os.COLLAPSED_VISUAL_DECORATION=dn.register({description:"folding-collapsed-visual-decoration",stickiness:0,afterContentClassName:"inline-folded",isWholeLine:!0,linesDecorationsTooltip:lh,firstLineDecorationClassName:xn.asClassName(Ov)}),os.COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION=dn.register({description:"folding-collapsed-highlighted-visual-decoration",stickiness:0,afterContentClassName:"inline-folded",className:"folded-background",minimap:Kw,isWholeLine:!0,linesDecorationsTooltip:lh,firstLineDecorationClassName:xn.asClassName(Ov)}),os.MANUALLY_COLLAPSED_VISUAL_DECORATION=dn.register({description:"folding-manually-collapsed-visual-decoration",stickiness:0,afterContentClassName:"inline-folded",isWholeLine:!0,linesDecorationsTooltip:lh,firstLineDecorationClassName:xn.asClassName(VI)}),os.MANUALLY_COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION=dn.register({description:"folding-manually-collapsed-highlighted-visual-decoration",stickiness:0,afterContentClassName:"inline-folded",className:"folded-background",minimap:Kw,isWholeLine:!0,linesDecorationsTooltip:lh,firstLineDecorationClassName:xn.asClassName(VI)}),os.NO_CONTROLS_COLLAPSED_RANGE_DECORATION=dn.register({description:"folding-no-controls-range-decoration",stickiness:0,afterContentClassName:"inline-folded",isWholeLine:!0,linesDecorationsTooltip:lh}),os.NO_CONTROLS_COLLAPSED_HIGHLIGHTED_RANGE_DECORATION=dn.register({description:"folding-no-controls-range-decoration",stickiness:0,afterContentClassName:"inline-folded",className:"folded-background",minimap:Kw,isWholeLine:!0,linesDecorationsTooltip:lh}),os.EXPANDED_VISUAL_DECORATION=dn.register({description:"folding-expanded-visual-decoration",stickiness:1,isWholeLine:!0,firstLineDecorationClassName:"alwaysShowFoldIcons "+xn.asClassName(Av),linesDecorationsTooltip:hm}),os.EXPANDED_AUTO_HIDE_VISUAL_DECORATION=dn.register({description:"folding-expanded-auto-hide-visual-decoration",stickiness:1,isWholeLine:!0,firstLineDecorationClassName:xn.asClassName(Av),linesDecorationsTooltip:hm}),os.MANUALLY_EXPANDED_VISUAL_DECORATION=dn.register({description:"folding-manually-expanded-visual-decoration",stickiness:0,isWholeLine:!0,firstLineDecorationClassName:"alwaysShowFoldIcons "+xn.asClassName(jI),linesDecorationsTooltip:hm}),os.MANUALLY_EXPANDED_AUTO_HIDE_VISUAL_DECORATION=dn.register({description:"folding-manually-expanded-auto-hide-visual-decoration",stickiness:0,isWholeLine:!0,firstLineDecorationClassName:xn.asClassName(jI),linesDecorationsTooltip:hm}),os.NO_CONTROLS_EXPANDED_RANGE_DECORATION=dn.register({description:"folding-no-controls-range-decoration",stickiness:0,isWholeLine:!0}),os.HIDDEN_RANGE_DECORATION=dn.register({description:"folding-hidden-range-decoration",stickiness:1});let XC=os;const HV={},WV="syntax";class uk{constructor(e,t,i,n,s){this.editorModel=e,this.providers=t,this.handleFoldingRangesChange=i,this.foldingRangesLimit=n,this.fallbackRangeProvider=s,this.id=WV,this.disposables=new Lt,s&&this.disposables.add(s);for(const r of t)typeof r.onDidChange=="function"&&this.disposables.add(r.onDidChange(i))}compute(e){return BV(this.providers,this.editorModel,e).then(t=>{var i;return t?VV(t,this.foldingRangesLimit):((i=this.fallbackRangeProvider)==null?void 0:i.compute(e))??null})}dispose(){this.disposables.dispose()}}function BV(o,e,t){let i=null;const n=o.map((s,r)=>Promise.resolve(s.provideFoldingRanges(e,HV,t)).then(a=>{if(!t.isCancellationRequested&&Array.isArray(a)){Array.isArray(i)||(i=[]);const d=e.getLineCount();for(const u of a)u.start>0&&u.end>u.start&&u.end<=d&&i.push({start:u.start,end:u.end,rank:r,kind:u.kind})}},rs));return Promise.all(n).then(s=>i)}class zV{constructor(e){this._startIndexes=[],this._endIndexes=[],this._nestingLevels=[],this._nestingLevelCounts=[],this._types=[],this._length=0,this._foldingRangesLimit=e}add(e,t,i,n){if(e>Jr||t>Jr)return;const s=this._length;this._startIndexes[s]=e,this._endIndexes[s]=t,this._nestingLevels[s]=n,this._types[s]=i,this._length++,n<30&&(this._nestingLevelCounts[n]=(this._nestingLevelCounts[n]||0)+1)}toIndentRanges(){const e=this._foldingRangesLimit.limit;if(this._length<=e){this._foldingRangesLimit.update(this._length,!1);const t=new Uint32Array(this._length),i=new Uint32Array(this._length);for(let n=0;n<this._length;n++)t[n]=this._startIndexes[n],i[n]=this._endIndexes[n];return new Vo(t,i,this._types)}else{this._foldingRangesLimit.update(this._length,e);let t=0,i=this._nestingLevelCounts.length;for(let a=0;a<this._nestingLevelCounts.length;a++){const d=this._nestingLevelCounts[a];if(d){if(d+t>e){i=a;break}t+=d}}const n=new Uint32Array(e),s=new Uint32Array(e),r=[];for(let a=0,d=0;a<this._length;a++){const u=this._nestingLevels[a];(u<i||u===i&&t++<e)&&(n[d]=this._startIndexes[a],s[d]=this._endIndexes[a],r[d]=this._types[a],d++)}return new Vo(n,s,r)}}}function VV(o,e){const t=o.sort((r,a)=>{let d=r.start-a.start;return d===0&&(d=r.rank-a.rank),d}),i=new zV(e);let n;const s=[];for(const r of t)if(!n)n=r,i.add(r.start,r.end,r.kind&&r.kind.value,s.length);else if(r.start>n.start)if(r.end<=n.end)s.push(n),n=r,i.add(r.start,r.end,r.kind&&r.kind.value,s.length);else{if(r.start>n.end){do n=s.pop();while(n&&r.start>n.end);n&&s.push(n),n=r}i.add(r.start,r.end,r.kind&&r.kind.value,s.length)}return i.toIndentRanges()}var jV=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},vg=function(o,e){return function(t,i){e(t,i,o)}},nd;const Vs=new _n("foldingEnabled",!1);var Kd;let Fc=(Kd=class extends Dt{static get(e){return e.getContribution(nd.ID)}static getFoldingRangeProviders(e,t){var n;const i=e.foldingRangeProvider.ordered(t);return((n=nd._foldingRangeSelector)==null?void 0:n.call(nd,i,t))??i}constructor(e,t,i,n,s,r){super(),this.contextKeyService=t,this.languageConfigurationService=i,this.languageFeaturesService=r,this.localToDispose=this._register(new Lt),this.editor=e,this._foldingLimitReporter=new jR(e);const a=this.editor.getOptions();this._isEnabled=a.get(43),this._useFoldingProviders=a.get(44)!=="indentation",this._unfoldOnClickAfterEndOfLine=a.get(48),this._restoringViewState=!1,this._currentModelHasFoldedImports=!1,this._foldingImportsByDefault=a.get(46),this.updateDebounceInfo=s.for(r.foldingRangeProvider,"Folding",{min:200}),this.foldingModel=null,this.hiddenRangeModel=null,this.rangeProvider=null,this.foldingRegionPromise=null,this.foldingModelPromise=null,this.updateScheduler=null,this.cursorChangedScheduler=null,this.mouseDownInfo=null,this.foldingDecorationProvider=new XC(e),this.foldingDecorationProvider.showFoldingControls=a.get(111),this.foldingDecorationProvider.showFoldingHighlights=a.get(45),this.foldingEnabled=Vs.bindTo(this.contextKeyService),this.foldingEnabled.set(this._isEnabled),this._register(this.editor.onDidChangeModel(()=>this.onModelChanged())),this._register(this.editor.onDidChangeConfiguration(d=>{if(d.hasChanged(43)&&(this._isEnabled=this.editor.getOptions().get(43),this.foldingEnabled.set(this._isEnabled),this.onModelChanged()),d.hasChanged(47)&&this.onModelChanged(),d.hasChanged(111)||d.hasChanged(45)){const u=this.editor.getOptions();this.foldingDecorationProvider.showFoldingControls=u.get(111),this.foldingDecorationProvider.showFoldingHighlights=u.get(45),this.triggerFoldingModelChanged()}d.hasChanged(44)&&(this._useFoldingProviders=this.editor.getOptions().get(44)!=="indentation",this.onFoldingStrategyChanged()),d.hasChanged(48)&&(this._unfoldOnClickAfterEndOfLine=this.editor.getOptions().get(48)),d.hasChanged(46)&&(this._foldingImportsByDefault=this.editor.getOptions().get(46))})),this.onModelChanged()}saveViewState(){const e=this.editor.getModel();if(!e||!this._isEnabled||e.isTooLargeForTokenization())return{};if(this.foldingModel){const t=this.foldingModel.getMemento(),i=this.rangeProvider?this.rangeProvider.id:void 0;return{collapsedRegions:t,lineCount:e.getLineCount(),provider:i,foldedImports:this._currentModelHasFoldedImports}}}restoreViewState(e){const t=this.editor.getModel();if(!(!t||!this._isEnabled||t.isTooLargeForTokenization()||!this.hiddenRangeModel)&&e&&(this._currentModelHasFoldedImports=!!e.foldedImports,e.collapsedRegions&&e.collapsedRegions.length>0&&this.foldingModel)){this._restoringViewState=!0;try{this.foldingModel.applyMemento(e.collapsedRegions)}finally{this._restoringViewState=!1}}}onModelChanged(){this.localToDispose.clear();const e=this.editor.getModel();!this._isEnabled||!e||e.isTooLargeForTokenization()||(this._currentModelHasFoldedImports=!1,this.foldingModel=new xV(e,this.foldingDecorationProvider),this.localToDispose.add(this.foldingModel),this.hiddenRangeModel=new TV(this.foldingModel),this.localToDispose.add(this.hiddenRangeModel),this.localToDispose.add(this.hiddenRangeModel.onDidChange(t=>this.onHiddenRangesChanges(t))),this.updateScheduler=new Mc(this.updateDebounceInfo.get(e)),this.cursorChangedScheduler=new Ss(()=>this.revealCursor(),200),this.localToDispose.add(this.cursorChangedScheduler),this.localToDispose.add(this.languageFeaturesService.foldingRangeProvider.onDidChange(()=>this.onFoldingStrategyChanged())),this.localToDispose.add(this.editor.onDidChangeModelLanguageConfiguration(()=>this.onFoldingStrategyChanged())),this.localToDispose.add(this.editor.onDidChangeModelContent(t=>this.onDidChangeModelContent(t))),this.localToDispose.add(this.editor.onDidChangeCursorPosition(()=>this.onCursorPositionChanged())),this.localToDispose.add(this.editor.onMouseDown(t=>this.onEditorMouseDown(t))),this.localToDispose.add(this.editor.onMouseUp(t=>this.onEditorMouseUp(t))),this.localToDispose.add({dispose:()=>{var t,i;this.foldingRegionPromise&&(this.foldingRegionPromise.cancel(),this.foldingRegionPromise=null),(t=this.updateScheduler)==null||t.cancel(),this.updateScheduler=null,this.foldingModel=null,this.foldingModelPromise=null,this.hiddenRangeModel=null,this.cursorChangedScheduler=null,(i=this.rangeProvider)==null||i.dispose(),this.rangeProvider=null}}),this.triggerFoldingModelChanged())}onFoldingStrategyChanged(){var e;(e=this.rangeProvider)==null||e.dispose(),this.rangeProvider=null,this.triggerFoldingModelChanged()}getRangeProvider(e){if(this.rangeProvider)return this.rangeProvider;const t=new dk(e,this.languageConfigurationService,this._foldingLimitReporter);if(this.rangeProvider=t,this._useFoldingProviders&&this.foldingModel){const i=nd.getFoldingRangeProviders(this.languageFeaturesService,e);i.length>0&&(this.rangeProvider=new uk(e,i,()=>this.triggerFoldingModelChanged(),this._foldingLimitReporter,t))}return this.rangeProvider}getFoldingModel(){return this.foldingModelPromise}onDidChangeModelContent(e){var t;(t=this.hiddenRangeModel)==null||t.notifyChangeModelContent(e),this.triggerFoldingModelChanged()}triggerFoldingModelChanged(){this.updateScheduler&&(this.foldingRegionPromise&&(this.foldingRegionPromise.cancel(),this.foldingRegionPromise=null),this.foldingModelPromise=this.updateScheduler.trigger(()=>{const e=this.foldingModel;if(!e)return null;const t=new Mo,i=this.getRangeProvider(e.textModel),n=this.foldingRegionPromise=Os(s=>i.compute(s));return n.then(s=>{if(s&&n===this.foldingRegionPromise){let r;if(this._foldingImportsByDefault&&!this._currentModelHasFoldedImports){const u=s.setCollapsedAllOfType(b_.Imports.value,!0);u&&(r=pf.capture(this.editor),this._currentModelHasFoldedImports=u)}const a=this.editor.getSelections();e.update(s,$V(a)),r==null||r.restore(this.editor);const d=this.updateDebounceInfo.update(e.textModel,t.elapsed());this.updateScheduler&&(this.updateScheduler.defaultDelay=d)}return e})}).then(void 0,e=>(Nn(e),null)))}onHiddenRangesChanges(e){if(this.hiddenRangeModel&&e.length&&!this._restoringViewState){const t=this.editor.getSelections();t&&this.hiddenRangeModel.adjustSelections(t)&&this.editor.setSelections(t)}this.editor.setHiddenAreas(e,this)}onCursorPositionChanged(){this.hiddenRangeModel&&this.hiddenRangeModel.hasRanges()&&this.cursorChangedScheduler.schedule()}revealCursor(){const e=this.getFoldingModel();e&&e.then(t=>{if(t){const i=this.editor.getSelections();if(i&&i.length>0){const n=[];for(const s of i){const r=s.selectionStartLineNumber;this.hiddenRangeModel&&this.hiddenRangeModel.isHidden(r)&&n.push(...t.getAllRegionsAtLine(r,a=>a.isCollapsed&&r>a.startLineNumber))}n.length&&(t.toggleCollapseState(n),this.reveal(i[0].getPosition()))}}}).then(void 0,Nn)}onEditorMouseDown(e){if(this.mouseDownInfo=null,!this.hiddenRangeModel||!e.target||!e.target.range||!e.event.leftButton&&!e.event.middleButton)return;const t=e.target.range;let i=!1;switch(e.target.type){case 4:{const n=e.target.detail,s=e.target.element.offsetLeft;if(n.offsetX-s<4)return;i=!0;break}case 7:{if(this._unfoldOnClickAfterEndOfLine&&this.hiddenRangeModel.hasRanges()&&!e.target.detail.isAfterLines)break;return}case 6:{if(this.hiddenRangeModel.hasRanges()){const n=this.editor.getModel();if(n&&t.startColumn===n.getLineMaxColumn(t.startLineNumber))break}return}default:return}this.mouseDownInfo={lineNumber:t.startLineNumber,iconClicked:i}}onEditorMouseUp(e){const t=this.foldingModel;if(!t||!this.mouseDownInfo||!e.target)return;const i=this.mouseDownInfo.lineNumber,n=this.mouseDownInfo.iconClicked,s=e.target.range;if(!s||s.startLineNumber!==i)return;if(n){if(e.target.type!==4)return}else{const a=this.editor.getModel();if(!a||s.startColumn!==a.getLineMaxColumn(i))return}const r=t.getRegionAtLine(i);if(r&&r.startLineNumber===i){const a=r.isCollapsed;if(n||a){const d=e.event.altKey;let u=[];if(d){const f=p=>!p.containedBy(r)&&!r.containedBy(p),g=t.getRegionsInside(null,f);for(const p of g)p.isCollapsed&&u.push(p);u.length===0&&(u=g)}else{const f=e.event.middleButton||e.event.shiftKey;if(f)for(const g of t.getRegionsInside(r))g.isCollapsed===a&&u.push(g);(a||!f||u.length===0)&&u.push(r)}t.toggleCollapseState(u),this.reveal({lineNumber:i,column:1})}}}reveal(e){this.editor.revealPositionInCenterIfOutsideViewport(e,0)}},nd=Kd,Kd.ID="editor.contrib.folding",Kd);Fc=nd=jV([vg(1,Sn),vg(2,Ds),vg(3,co),vg(4,ur),vg(5,pi)],Fc);class jR{constructor(e){this.editor=e,this._onDidChange=new Xi,this._computed=0,this._limited=!1}get limit(){return this.editor.getOptions().get(47)}update(e,t){(e!==this._computed||t!==this._limited)&&(this._computed=e,this._limited=t,this._onDidChange.fire())}}class Ys extends lt{runEditorCommand(e,t,i){const n=e.get(Ds),s=Fc.get(t);if(!s)return;const r=s.getFoldingModel();if(r)return this.reportTelemetry(e,t),r.then(a=>{if(a){this.invoke(s,a,t,i,n);const d=t.getSelection();d&&s.reveal(d.getStartPosition())}})}getSelectedLines(e){const t=e.getSelections();return t?t.map(i=>i.startLineNumber):[]}getLineNumbers(e,t){return e&&e.selectionLines?e.selectionLines.map(i=>i+1):this.getSelectedLines(t)}run(e,t){}}function $V(o){return!o||o.length===0?{startsInside:()=>!1}:{startsInside(e,t){for(const i of o){const n=i.startLineNumber;if(n>=e&&n<=t)return!0}return!1}}}function $R(o){if(!xg(o)){if(!gT(o))return!1;const e=o;if(!xg(e.levels)&&!wL(e.levels)||!xg(e.direction)&&!BD(e.direction)||!xg(e.selectionLines)&&(!Array.isArray(e.selectionLines)||!e.selectionLines.every(wL)))return!1}return!0}class UV extends Ys{constructor(){super({id:"editor.unfold",label:C("unfoldAction.label","Unfold"),alias:"Unfold",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:3166,mac:{primary:2654},weight:100},metadata:{description:"Unfold the content in the editor",args:[{name:"Unfold editor argument",description:`Property-value pairs that can be passed through this argument:
23
- * 'levels': Number of levels to unfold. If not set, defaults to 1.
24
- * 'direction': If 'up', unfold given number of levels up otherwise unfolds down.
25
- * 'selectionLines': Array of the start lines (0-based) of the editor selections to apply the unfold action to. If not set, the active selection(s) will be used.
26
- `,constraint:$R,schema:{type:"object",properties:{levels:{type:"number",default:1},direction:{type:"string",enum:["up","down"],default:"down"},selectionLines:{type:"array",items:{type:"number"}}}}}]}})}invoke(e,t,i,n){const s=n&&n.levels||1,r=this.getLineNumbers(n,i);n&&n.direction==="up"?zR(t,!1,s,r):Xf(t,!1,s,r)}}class qV extends Ys{constructor(){super({id:"editor.unfoldRecursively",label:C("unFoldRecursivelyAction.label","Unfold Recursively"),alias:"Unfold Recursively",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2142),weight:100}})}invoke(e,t,i,n){Xf(t,!1,Number.MAX_VALUE,this.getSelectedLines(i))}}class GV extends Ys{constructor(){super({id:"editor.fold",label:C("foldAction.label","Fold"),alias:"Fold",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:3164,mac:{primary:2652},weight:100},metadata:{description:"Fold the content in the editor",args:[{name:"Fold editor argument",description:`Property-value pairs that can be passed through this argument:
27
- * 'levels': Number of levels to fold.
28
- * 'direction': If 'up', folds given number of levels up otherwise folds down.
29
- * 'selectionLines': Array of the start lines (0-based) of the editor selections to apply the fold action to. If not set, the active selection(s) will be used.
30
- If no levels or direction is set, folds the region at the locations or if already collapsed, the first uncollapsed parent instead.
31
- `,constraint:$R,schema:{type:"object",properties:{levels:{type:"number"},direction:{type:"string",enum:["up","down"]},selectionLines:{type:"array",items:{type:"number"}}}}}]}})}invoke(e,t,i,n){const s=this.getLineNumbers(n,i),r=n&&n.levels,a=n&&n.direction;typeof r!="number"&&typeof a!="string"?kV(t,!0,s):a==="up"?zR(t,!0,r||1,s):Xf(t,!0,r||1,s)}}class KV extends Ys{constructor(){super({id:"editor.toggleFold",label:C("toggleFoldAction.label","Toggle Fold"),alias:"Toggle Fold",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2090),weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);ak(t,1,n)}}class ZV extends Ys{constructor(){super({id:"editor.foldRecursively",label:C("foldRecursivelyAction.label","Fold Recursively"),alias:"Fold Recursively",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2140),weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);Xf(t,!0,Number.MAX_VALUE,n)}}class YV extends Ys{constructor(){super({id:"editor.toggleFoldRecursively",label:C("toggleFoldRecursivelyAction.label","Toggle Fold Recursively"),alias:"Toggle Fold Recursively",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,3114),weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);ak(t,Number.MAX_VALUE,n)}}class XV extends Ys{constructor(){super({id:"editor.foldAllBlockComments",label:C("foldAllBlockComments.label","Fold All Block Comments"),alias:"Fold All Block Comments",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2138),weight:100}})}invoke(e,t,i,n,s){if(t.regions.hasTypes())ck(t,b_.Comment.value,!0);else{const r=i.getModel();if(!r)return;const a=s.getLanguageConfiguration(r.getLanguageId()).comments;if(a&&a.blockCommentStartToken){const d=new RegExp("^\\s*"+fp(a.blockCommentStartToken));lk(t,d,!0)}}}}class QV extends Ys{constructor(){super({id:"editor.foldAllMarkerRegions",label:C("foldAllMarkerRegions.label","Fold All Regions"),alias:"Fold All Regions",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2077),weight:100}})}invoke(e,t,i,n,s){if(t.regions.hasTypes())ck(t,b_.Region.value,!0);else{const r=i.getModel();if(!r)return;const a=s.getLanguageConfiguration(r.getLanguageId()).foldingRules;if(a&&a.markers&&a.markers.start){const d=new RegExp(a.markers.start);lk(t,d,!0)}}}}class JV extends Ys{constructor(){super({id:"editor.unfoldAllMarkerRegions",label:C("unfoldAllMarkerRegions.label","Unfold All Regions"),alias:"Unfold All Regions",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2078),weight:100}})}invoke(e,t,i,n,s){if(t.regions.hasTypes())ck(t,b_.Region.value,!1);else{const r=i.getModel();if(!r)return;const a=s.getLanguageConfiguration(r.getLanguageId()).foldingRules;if(a&&a.markers&&a.markers.start){const d=new RegExp(a.markers.start);lk(t,d,!1)}}}}class e6 extends Ys{constructor(){super({id:"editor.foldAllExcept",label:C("foldAllExcept.label","Fold All Except Selected"),alias:"Fold All Except Selected",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2136),weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);VR(t,!0,n)}}class t6 extends Ys{constructor(){super({id:"editor.unfoldAllExcept",label:C("unfoldAllExcept.label","Unfold All Except Selected"),alias:"Unfold All Except Selected",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2134),weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);VR(t,!1,n)}}class i6 extends Ys{constructor(){super({id:"editor.foldAll",label:C("foldAllAction.label","Fold All"),alias:"Fold All",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2069),weight:100}})}invoke(e,t,i){Xf(t,!0)}}class n6 extends Ys{constructor(){super({id:"editor.unfoldAll",label:C("unfoldAllAction.label","Unfold All"),alias:"Unfold All",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2088),weight:100}})}invoke(e,t,i){Xf(t,!1)}}const Fh=class Fh extends Ys{getFoldingLevel(){return parseInt(this.id.substr(Fh.ID_PREFIX.length))}invoke(e,t,i){LV(t,this.getFoldingLevel(),!0,this.getSelectedLines(i))}};Fh.ID_PREFIX="editor.foldLevel",Fh.ID=e=>Fh.ID_PREFIX+e;let Fv=Fh;class s6 extends Ys{constructor(){super({id:"editor.gotoParentFold",label:C("gotoParentFold.label","Go to Parent Fold"),alias:"Go to Parent Fold",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);if(n.length>0){const s=IV(n[0],t);s!==null&&i.setSelection({startLineNumber:s,startColumn:1,endLineNumber:s,endColumn:1})}}}class o6 extends Ys{constructor(){super({id:"editor.gotoPreviousFold",label:C("gotoPreviousFold.label","Go to Previous Folding Range"),alias:"Go to Previous Folding Range",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);if(n.length>0){const s=EV(n[0],t);s!==null&&i.setSelection({startLineNumber:s,startColumn:1,endLineNumber:s,endColumn:1})}}}class r6 extends Ys{constructor(){super({id:"editor.gotoNextFold",label:C("gotoNextFold.label","Go to Next Folding Range"),alias:"Go to Next Folding Range",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);if(n.length>0){const s=DV(n[0],t);s!==null&&i.setSelection({startLineNumber:s,startColumn:1,endLineNumber:s,endColumn:1})}}}class a6 extends Ys{constructor(){super({id:"editor.createFoldingRangeFromSelection",label:C("createManualFoldRange.label","Create Folding Range from Selection"),alias:"Create Folding Range from Selection",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2135),weight:100}})}invoke(e,t,i){var r;const n=[],s=i.getSelections();if(s){for(const a of s){let d=a.endLineNumber;a.endColumn===1&&--d,d>a.startLineNumber&&(n.push({startLineNumber:a.startLineNumber,endLineNumber:d,type:void 0,isCollapsed:!0,source:1}),i.setSelection({startLineNumber:a.startLineNumber,startColumn:1,endLineNumber:a.startLineNumber,endColumn:1}))}if(n.length>0){n.sort((d,u)=>d.startLineNumber-u.startLineNumber);const a=Vo.sanitizeAndMerge(t.regions,n,(r=i.getModel())==null?void 0:r.getLineCount());t.updatePost(Vo.fromFoldRanges(a))}}}}class l6 extends Ys{constructor(){super({id:"editor.removeManualFoldingRanges",label:C("removeManualFoldingRanges.label","Remove Manual Folding Ranges"),alias:"Remove Manual Folding Ranges",precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2137),weight:100}})}invoke(e,t,i){const n=i.getSelections();if(n){const s=[];for(const r of n){const{startLineNumber:a,endLineNumber:d}=r;s.push(d>=a?{startLineNumber:a,endLineNumber:d}:{endLineNumber:d,startLineNumber:a})}t.removeManualRanges(s),e.triggerFoldingModelChanged()}}}nn(Fc.ID,Fc,0);xe(UV);xe(qV);xe(GV);xe(ZV);xe(YV);xe(i6);xe(n6);xe(XV);xe(QV);xe(JV);xe(e6);xe(t6);xe(KV);xe(s6);xe(o6);xe(r6);xe(a6);xe(l6);for(let o=1;o<=7;o++)lO(new Fv({id:Fv.ID(o),label:C("foldLevelAction.label","Fold Level {0}",o),alias:`Fold Level ${o}`,precondition:Vs,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2048|21+o),weight:100}}));Wn.registerCommand("_executeFoldingRangeProvider",async function(o,...e){const[t]=e;if(!(t instanceof Pn))throw _l();const i=o.get(pi),n=o.get(uo).getModel(t);if(!n)throw _l();const s=o.get(Un);if(!s.getValue("editor.folding",{resource:t}))return[];const r=o.get(Ds),a=s.getValue("editor.foldingStrategy",{resource:t}),d={get limit(){return s.getValue("editor.foldingMaximumRegions",{resource:t})},update:(w,y)=>{}},u=new dk(n,r,d);let f=u;if(a!=="indentation"){const w=Fc.getFoldingRangeProviders(i,n);w.length&&(f=new uk(n,w,()=>{},d,u))}const g=await f.compute(Qi.None),p=[];try{if(g)for(let w=0;w<g.length;w++){const y=g.getType(w);p.push({start:g.getStartLineNumber(w),end:g.getEndLineNumber(w),kind:y?b_.fromValue(y):void 0})}return p}finally{f.dispose()}});class c6 extends lt{constructor(){super({id:"editor.action.fontZoomIn",label:C("EditorFontZoomIn.label","Increase Editor Font Size"),alias:"Increase Editor Font Size",precondition:void 0})}run(e,t){bp.setZoomLevel(bp.getZoomLevel()+1)}}class d6 extends lt{constructor(){super({id:"editor.action.fontZoomOut",label:C("EditorFontZoomOut.label","Decrease Editor Font Size"),alias:"Decrease Editor Font Size",precondition:void 0})}run(e,t){bp.setZoomLevel(bp.getZoomLevel()-1)}}class u6 extends lt{constructor(){super({id:"editor.action.fontZoomReset",label:C("EditorFontZoomReset.label","Reset Editor Font Size"),alias:"Reset Editor Font Size",precondition:void 0})}run(e,t){bp.setZoomLevel(0)}}xe(c6);xe(d6);xe(u6);var UR=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Qg=function(o,e){return function(t,i){e(t,i,o)}},nf;let Hv=(nf=class{constructor(e,t,i,n){this._editor=e,this._languageFeaturesService=t,this._workerService=i,this._accessibilitySignalService=n,this._disposables=new Lt,this._sessionDisposables=new Lt,this._disposables.add(t.onTypeFormattingEditProvider.onDidChange(this._update,this)),this._disposables.add(e.onDidChangeModel(()=>this._update())),this._disposables.add(e.onDidChangeModelLanguage(()=>this._update())),this._disposables.add(e.onDidChangeConfiguration(s=>{s.hasChanged(56)&&this._update()})),this._update()}dispose(){this._disposables.dispose(),this._sessionDisposables.dispose()}_update(){if(this._sessionDisposables.clear(),!this._editor.getOption(56)||!this._editor.hasModel())return;const e=this._editor.getModel(),[t]=this._languageFeaturesService.onTypeFormattingEditProvider.ordered(e);if(!t||!t.autoFormatTriggerCharacters)return;const i=new ov;for(const n of t.autoFormatTriggerCharacters)i.add(n.charCodeAt(0));this._sessionDisposables.add(this._editor.onDidType(n=>{const s=n.charCodeAt(n.length-1);i.has(s)&&this._trigger(String.fromCharCode(s))}))}_trigger(e){if(!this._editor.hasModel()||this._editor.getSelections().length>1||!this._editor.getSelection().isEmpty())return;const t=this._editor.getModel(),i=this._editor.getPosition(),n=new Fs,s=this._editor.onDidChangeModelContent(r=>{if(r.isFlush){n.cancel(),s.dispose();return}for(let a=0,d=r.changes.length;a<d;a++)if(r.changes[a].range.endLineNumber<=i.lineNumber){n.cancel(),s.dispose();return}});cO(this._workerService,this._languageFeaturesService,t,i,e,t.getFormattingOptions(),n.token).then(r=>{n.token.isCancellationRequested||$o(r)&&(this._accessibilitySignalService.playSignal(_T.format,{userGesture:!1}),dO.execute(this._editor,r,!0))}).finally(()=>{s.dispose()})}},nf.ID="editor.contrib.autoFormat",nf);Hv=UR([Qg(1,pi),Qg(2,Al),Qg(3,pT)],Hv);var sf;let Wv=(sf=class{constructor(e,t,i){this.editor=e,this._languageFeaturesService=t,this._instantiationService=i,this._callOnDispose=new Lt,this._callOnModel=new Lt,this._callOnDispose.add(e.onDidChangeConfiguration(()=>this._update())),this._callOnDispose.add(e.onDidChangeModel(()=>this._update())),this._callOnDispose.add(e.onDidChangeModelLanguage(()=>this._update())),this._callOnDispose.add(t.documentRangeFormattingEditProvider.onDidChange(this._update,this))}dispose(){this._callOnDispose.dispose(),this._callOnModel.dispose()}_update(){this._callOnModel.clear(),this.editor.getOption(55)&&this.editor.hasModel()&&this._languageFeaturesService.documentRangeFormattingEditProvider.has(this.editor.getModel())&&this._callOnModel.add(this.editor.onDidPaste(({range:e})=>this._trigger(e)))}_trigger(e){this.editor.hasModel()&&(this.editor.getSelections().length>1||this._instantiationService.invokeFunction(mT,this.editor,e,2,dl.None,Qi.None,!1).catch(Nn))}},sf.ID="editor.contrib.formatOnPaste",sf);Wv=UR([Qg(1,pi),Qg(2,Zi)],Wv);class h6 extends lt{constructor(){super({id:"editor.action.formatDocument",label:C("formatDocument.label","Format Document"),alias:"Format Document",precondition:Ae.and(B.notInCompositeEditor,B.writable,B.hasDocumentFormattingProvider),kbOpts:{kbExpr:B.editorTextFocus,primary:1572,linux:{primary:3111},weight:100},contextMenuOpts:{group:"1_modification",order:1.3}})}async run(e,t){if(t.hasModel()){const i=e.get(Zi);await e.get(c_).showWhile(i.invokeFunction(uO,t,1,dl.None,Qi.None,!0),250)}}}class f6 extends lt{constructor(){super({id:"editor.action.formatSelection",label:C("formatSelection.label","Format Selection"),alias:"Format Selection",precondition:Ae.and(B.writable,B.hasDocumentSelectionFormattingProvider),kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2084),weight:100},contextMenuOpts:{when:B.hasNonEmptySelection,group:"1_modification",order:1.31}})}async run(e,t){if(!t.hasModel())return;const i=e.get(Zi),n=t.getModel(),s=t.getSelections().map(a=>a.isEmpty()?new Z(a.startLineNumber,1,a.startLineNumber,n.getLineMaxColumn(a.startLineNumber)):a);await e.get(c_).showWhile(i.invokeFunction(mT,t,s,1,dl.None,Qi.None,!0),250)}}nn(Hv.ID,Hv,2);nn(Wv.ID,Wv,2);xe(h6);xe(f6);Wn.registerCommand("editor.action.format",async o=>{const e=o.get(as).getFocusedCodeEditor();if(!e||!e.hasModel())return;const t=o.get(Es);e.getSelection().isEmpty()?await t.executeCommand("editor.action.formatDocument"):await t.executeCommand("editor.action.formatSelection")});var g6=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Zw=function(o,e){return function(t,i){e(t,i,o)}};class Ph{remove(){var e;(e=this.parent)==null||e.children.delete(this.id)}static findId(e,t){let i;typeof e=="string"?i=`${t.id}/${e}`:(i=`${t.id}/${e.name}`,t.children.get(i)!==void 0&&(i=`${t.id}/${e.name}_${e.range.startLineNumber}_${e.range.startColumn}`));let n=i;for(let s=0;t.children.get(n)!==void 0;s++)n=`${i}_${s}`;return n}static empty(e){return e.children.size===0}}class QC extends Ph{constructor(e,t,i){super(),this.id=e,this.parent=t,this.symbol=i,this.children=new Map}}class qR extends Ph{constructor(e,t,i,n){super(),this.id=e,this.parent=t,this.label=i,this.order=n,this.children=new Map}}class sl extends Ph{static create(e,t,i){const n=new Fs(i),s=new sl(t.uri),r=e.ordered(t),a=r.map((u,f)=>{const g=Ph.findId(`provider_${f}`,s),p=new qR(g,s,u.displayName??"Unknown Outline Provider",f);return Promise.resolve(u.provideDocumentSymbols(t,n.token)).then(w=>{for(const y of w||[])sl._makeOutlineElement(y,p);return p},w=>(rs(w),p)).then(w=>{Ph.empty(w)?w.remove():s._groups.set(g,w)})}),d=e.onDidChange(()=>{const u=e.ordered(t);Va(u,r)||n.cancel()});return Promise.all(a).then(()=>n.token.isCancellationRequested&&!i.isCancellationRequested?sl.create(e,t,i):s._compact()).finally(()=>{n.dispose(),d.dispose(),n.dispose()})}static _makeOutlineElement(e,t){const i=Ph.findId(e,t),n=new QC(i,t,e);if(e.children)for(const s of e.children)sl._makeOutlineElement(s,n);t.children.set(n.id,n)}constructor(e){super(),this.uri=e,this.id="root",this.parent=void 0,this._groups=new Map,this.children=new Map,this.id="root",this.parent=void 0}_compact(){let e=0;for(const[t,i]of this._groups)i.children.size===0?this._groups.delete(t):e+=1;if(e!==1)this.children=this._groups;else{const t=pl.first(this._groups.values());for(const[,i]of t.children)i.parent=this,this.children.set(i.id,i)}return this}getTopLevelSymbols(){const e=[];for(const t of this.children.values())t instanceof QC?e.push(t.symbol):e.push(...pl.map(t.children.values(),i=>i.symbol));return e.sort((t,i)=>Z.compareRangesUsingStarts(t.range,i.range))}asListOfDocumentSymbols(){const e=this.getTopLevelSymbols(),t=[];return sl._flattenDocumentSymbols(t,e,""),t.sort((i,n)=>gi.compare(Z.getStartPosition(i.range),Z.getStartPosition(n.range))||gi.compare(Z.getEndPosition(n.range),Z.getEndPosition(i.range)))}static _flattenDocumentSymbols(e,t,i){for(const n of t)e.push({kind:n.kind,tags:n.tags,name:n.name,detail:n.detail,containerName:n.containerName||i,range:n.range,selectionRange:n.selectionRange,children:void 0}),n.children&&sl._flattenDocumentSymbols(e,n.children,n.name)}}const N_=Rl("IOutlineModelService");let JC=class{constructor(e,t,i){this._languageFeaturesService=e,this._disposables=new Lt,this._cache=new u_(10,.7),this._debounceInformation=t.for(e.documentSymbolProvider,"DocumentSymbols",{min:350}),this._disposables.add(i.onModelRemoved(n=>{this._cache.delete(n.id)}))}dispose(){this._disposables.dispose()}async getOrCreate(e,t){const i=this._languageFeaturesService.documentSymbolProvider,n=i.ordered(e);let s=this._cache.get(e.id);if(!s||s.versionId!==e.getVersionId()||!Va(s.provider,n)){const a=new Fs;s={versionId:e.getVersionId(),provider:n,promiseCnt:0,source:a,promise:sl.create(i,e,a.token),model:void 0},this._cache.set(e.id,s);const d=Date.now();s.promise.then(u=>{s.model=u,this._debounceInformation.update(e,Date.now()-d)}).catch(u=>{this._cache.delete(e.id)})}if(s.model)return s.model;s.promiseCnt+=1;const r=t.onCancellationRequested(()=>{--s.promiseCnt===0&&(s.source.cancel(),this._cache.delete(e.id))});try{return await s.promise}finally{r.dispose()}}};JC=g6([Zw(0,pi),Zw(1,ur),Zw(2,uo)],JC);Nl(N_,JC,1);Wn.registerCommand("_executeDocumentSymbolProvider",async function(o,...e){const[t]=e;Cn(Pn.isUri(t));const i=o.get(N_),s=await o.get(ga).createModelReference(t);try{return(await i.getOrCreate(s.object.textEditorModel,Qi.None)).getTopLevelSymbols()}finally{s.dispose()}});const xa=class xa extends Dt{constructor(e,t){super(),this.contextKeyService=e,this.model=t,this.inlineCompletionVisible=xa.inlineSuggestionVisible.bindTo(this.contextKeyService),this.inlineCompletionSuggestsIndentation=xa.inlineSuggestionHasIndentation.bindTo(this.contextKeyService),this.inlineCompletionSuggestsIndentationLessThanTabSize=xa.inlineSuggestionHasIndentationLessThanTabSize.bindTo(this.contextKeyService),this.suppressSuggestions=xa.suppressSuggestions.bindTo(this.contextKeyService),this._register(Kn(i=>{const n=this.model.read(i),s=n==null?void 0:n.state.read(i),r=!!(s!=null&&s.inlineCompletion)&&(s==null?void 0:s.primaryGhostText)!==void 0&&!(s!=null&&s.primaryGhostText.isEmpty());this.inlineCompletionVisible.set(r),s!=null&&s.primaryGhostText&&(s!=null&&s.inlineCompletion)&&this.suppressSuggestions.set(s.inlineCompletion.inlineCompletion.source.inlineCompletions.suppressSuggestions)})),this._register(Kn(i=>{const n=this.model.read(i);let s=!1,r=!0;const a=n==null?void 0:n.primaryGhostText.read(i);if(n!=null&&n.selectedSuggestItem&&a&&a.parts.length>0){const{column:d,lines:u}=a.parts[0],f=u[0],g=n.textModel.getLineIndentColumn(a.lineNumber);if(d<=g){let w=kS(f);w===-1&&(w=f.length-1),s=w>0;const y=n.textModel.getOptions().tabSize;r=hO.visibleColumnFromColumn(f,w+1,y)<y}}this.inlineCompletionSuggestsIndentation.set(s),this.inlineCompletionSuggestsIndentationLessThanTabSize.set(r)}))}};xa.inlineSuggestionVisible=new _n("inlineSuggestionVisible",!1,C("inlineSuggestionVisible","Whether an inline suggestion is visible")),xa.inlineSuggestionHasIndentation=new _n("inlineSuggestionHasIndentation",!1,C("inlineSuggestionHasIndentation","Whether the inline suggestion starts with whitespace")),xa.inlineSuggestionHasIndentationLessThanTabSize=new _n("inlineSuggestionHasIndentationLessThanTabSize",!0,C("inlineSuggestionHasIndentationLessThanTabSize","Whether the inline suggestion starts with whitespace that is less than what would be inserted by tab")),xa.suppressSuggestions=new _n("inlineSuggestionSuppressSuggestions",void 0,C("suppressSuggestions","Whether suggestions should be suppressed for the current suggestion"));let Po=xa;function p6(o){const e=new Lt,t=e.add(vT());return e.add(Kn(i=>{t.setStyle(o.read(i))})),e}class Np{constructor(e,t){this.lineNumber=e,this.parts=t}equals(e){return this.lineNumber===e.lineNumber&&this.parts.length===e.parts.length&&this.parts.every((t,i)=>t.equals(e.parts[i]))}renderForScreenReader(e){if(this.parts.length===0)return"";const t=this.parts[this.parts.length-1],i=e.substr(0,t.column-1);return new bT([...this.parts.map(s=>new xl(Z.fromPositions(new gi(1,s.column)),s.lines.join(`
32
- `)))]).applyToString(i).substring(this.parts[0].column-1)}isEmpty(){return this.parts.every(e=>e.lines.length===0)}get lineCount(){return 1+this.parts.reduce((e,t)=>e+t.lines.length-1,0)}}class Bv{constructor(e,t,i){this.column=e,this.text=t,this.preview=i,this.lines=Ty(this.text)}equals(e){return this.column===e.column&&this.lines.length===e.lines.length&&this.lines.every((t,i)=>t===e.lines[i])}}class e1{constructor(e,t,i,n=0){this.lineNumber=e,this.columnRange=t,this.text=i,this.additionalReservedLineCount=n,this.parts=[new Bv(this.columnRange.endColumnExclusive,this.text,!1)],this.newLines=Ty(this.text)}renderForScreenReader(e){return this.newLines.join(`
33
- `)}get lineCount(){return this.newLines.length}isEmpty(){return this.parts.every(e=>e.lines.length===0)}equals(e){return this.lineNumber===e.lineNumber&&this.columnRange.equals(e.columnRange)&&this.newLines.length===e.newLines.length&&this.newLines.every((t,i)=>t===e.newLines[i])&&this.additionalReservedLineCount===e.additionalReservedLineCount}}function $I(o,e){return Va(o,e,GR)}function GR(o,e){return o===e?!0:!o||!e?!1:o instanceof Np&&e instanceof Np||o instanceof e1&&e instanceof e1?o.equals(e):!1}const _6=[];function m6(){return _6}class KR{constructor(e,t){if(this.startColumn=e,this.endColumnExclusive=t,e>t)throw new bf(`startColumn ${e} cannot be after endColumnExclusive ${t}`)}toRange(e){return new Z(e,this.startColumn,e,this.endColumnExclusive)}equals(e){return this.startColumn===e.startColumn&&this.endColumnExclusive===e.endColumnExclusive}}function ZR(o,e){const t=new Lt,i=o.createDecorationsCollection();return t.add(fO({debugName:()=>`Apply decorations from ${e.debugName}`},n=>{const s=e.read(n);i.set(s)})),t.add({dispose:()=>{i.clear()}}),t}function v6(o,e){return new gi(o.lineNumber+e.lineNumber-1,e.lineNumber===1?o.column+e.column-1:e.column)}function UI(o,e){return new gi(o.lineNumber-e.lineNumber+1,o.lineNumber-e.lineNumber===0?o.column-e.column+1:o.column)}var b6=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},y6=function(o,e){return function(t,i){e(t,i,o)}};const qI="ghost-text";let t1=class extends Dt{constructor(e,t,i){super(),this.editor=e,this.model=t,this.languageService=i,this.isDisposed=Uo(this,!1),this.currentTextModel=Lo(this,this.editor.onDidChangeModel,()=>this.editor.getModel()),this.uiState=En(this,n=>{if(this.isDisposed.read(n))return;const s=this.currentTextModel.read(n);if(s!==this.model.targetTextModel.read(n))return;const r=this.model.ghostText.read(n);if(!r)return;const a=r instanceof e1?r.columnRange:void 0,d=[],u=[];function f(x,k){if(u.length>0){const D=u[u.length-1];k&&D.decorations.push(new yp(D.content.length+1,D.content.length+1+x[0].length,k,0)),D.content+=x[0],x=x.slice(1)}for(const D of x)u.push({content:D,decorations:k?[new yp(1,D.length+1,k,0)]:[]})}const g=s.getLineContent(r.lineNumber);let p,w=0;for(const x of r.parts){let k=x.lines;p===void 0?(d.push({column:x.column,text:k[0],preview:x.preview}),k=k.slice(1)):f([g.substring(w,x.column-1)],void 0),k.length>0&&(f(k,qI),p===void 0&&x.column<=g.length&&(p=x.column)),w=x.column-1}p!==void 0&&f([g.substring(w)],void 0);const y=p!==void 0?new KR(p,g.length+1):void 0;return{replacedRange:a,inlineTexts:d,additionalLines:u,hiddenRange:y,lineNumber:r.lineNumber,additionalReservedLineCount:this.model.minReservedLineCount.read(n),targetTextModel:s}}),this.decorations=En(this,n=>{const s=this.uiState.read(n);if(!s)return[];const r=[];s.replacedRange&&r.push({range:s.replacedRange.toRange(s.lineNumber),options:{inlineClassName:"inline-completion-text-to-replace",description:"GhostTextReplacement"}}),s.hiddenRange&&r.push({range:s.hiddenRange.toRange(s.lineNumber),options:{inlineClassName:"ghost-text-hidden",description:"ghost-text-hidden"}});for(const a of s.inlineTexts)r.push({range:Z.fromPositions(new gi(s.lineNumber,a.column)),options:{description:qI,after:{content:a.text,inlineClassName:a.preview?"ghost-text-decoration-preview":"ghost-text-decoration",cursorStops:kh.Left},showIfCollapsed:!0}});return r}),this.additionalLinesWidget=this._register(new w6(this.editor,this.languageService.languageIdCodec,En(n=>{const s=this.uiState.read(n);return s?{lineNumber:s.lineNumber,additionalLines:s.additionalLines,minReservedLineCount:s.additionalReservedLineCount,targetTextModel:s.targetTextModel}:void 0}))),this._register(jn(()=>{this.isDisposed.set(!0,void 0)})),this._register(ZR(this.editor,this.decorations))}ownsViewZone(e){return this.additionalLinesWidget.viewZoneId===e}};t1=b6([y6(2,fa)],t1);class w6 extends Dt{get viewZoneId(){return this._viewZoneId}constructor(e,t,i){super(),this.editor=e,this.languageIdCodec=t,this.lines=i,this._viewZoneId=void 0,this.editorOptionsChanged=wd("editorOptionChanged",ws.filter(this.editor.onDidChangeConfiguration,n=>n.hasChanged(33)||n.hasChanged(118)||n.hasChanged(100)||n.hasChanged(95)||n.hasChanged(51)||n.hasChanged(50)||n.hasChanged(67))),this._register(Kn(n=>{const s=this.lines.read(n);this.editorOptionsChanged.read(n),s?this.updateLines(s.lineNumber,s.additionalLines,s.minReservedLineCount):this.clear()}))}dispose(){super.dispose(),this.clear()}clear(){this.editor.changeViewZones(e=>{this._viewZoneId&&(e.removeZone(this._viewZoneId),this._viewZoneId=void 0)})}updateLines(e,t,i){const n=this.editor.getModel();if(!n)return;const{tabSize:s}=n.getOptions();this.editor.changeViewZones(r=>{this._viewZoneId&&(r.removeZone(this._viewZoneId),this._viewZoneId=void 0);const a=Math.max(t.length,i);if(a>0){const d=document.createElement("div");S6(d,s,t,this.editor.getOptions(),this.languageIdCodec),this._viewZoneId=r.addZone({afterLineNumber:e,heightInLines:a,domNode:d,afterColumnAffinity:1})}})}}function S6(o,e,t,i,n){const s=i.get(33),r=i.get(118),a="none",d=i.get(95),u=i.get(51),f=i.get(50),g=i.get(67),p=new wT(1e4);p.appendString('<div class="suggest-preview-text">');for(let x=0,k=t.length;x<k;x++){const D=t[x],M=D.content;p.appendString('<div class="view-line'),p.appendString('" style="top:'),p.appendString(String(x*g)),p.appendString('px;width:1000000px;">');const F=kT(M),K=gO(M),V=pO.createEmpty(M,n);ST(new CT(f.isMonospace&&!s,f.canUseHalfwidthRightwardsArrow,M,!1,F,K,0,V,D.decorations,e,0,f.spaceWidth,f.middotWidth,f.wsmiddotWidth,r,a,d,u!==_O.OFF,null),p),p.appendString("</div>")}p.appendString("</div>"),xT(o,f);const w=p.build(),y=GI?GI.createHTML(w):w;o.innerHTML=y}const GI=yT("editorGhostText",{createHTML:o=>o});function C6(o,e){const t=new yO,i=new vO(t,u=>e.getLanguageConfiguration(u)),n=new mO(new x6([o]),i),s=bO(n,[],void 0,!0);let r="";const a=o.getLineContent();function d(u,f){if(u.kind===2)if(d(u.openingBracket,f),f=fg(f,u.openingBracket.length),u.child&&(d(u.child,f),f=fg(f,u.child.length)),u.closingBracket)d(u.closingBracket,f),f=fg(f,u.closingBracket.length);else{const p=i.getSingleLanguageBracketTokens(u.openingBracket.languageId).findClosingTokenText(u.openingBracket.bracketIds);r+=p}else if(u.kind!==3){if(u.kind===0||u.kind===1)r+=a.substring(SL(f),SL(fg(f,u.length)));else if(u.kind===4)for(const g of u.children)d(g,f),f=fg(f,g.length)}}return d(s,wO),r}class x6{constructor(e){this.lines=e,this.tokenization={getLineTokens:t=>this.lines[t-1]}}getLineCount(){return this.lines.length}getLineLength(e){return this.lines[e-1].getLineContent().length}}async function YR(o,e,t,i,n=Qi.None,s){const r=e instanceof gi?I6(e,t):e,a=o.all(t),d=new SO;for(const D of a)D.groupId&&d.add(D.groupId,D);function u(D){if(!D.yieldsToGroupIds)return[];const M=[];for(const F of D.yieldsToGroupIds||[]){const K=d.get(F);for(const V of K)M.push(V)}return M}const f=new Map,g=new Set;function p(D,M){if(M=[...M,D],g.has(D))return M;g.add(D);try{const F=u(D);for(const K of F){const V=p(K,M);if(V)return V}}finally{g.delete(D)}}function w(D){const M=f.get(D);if(M)return M;const F=p(D,[]);F&&rs(new Error(`Inline completions: cyclic yield-to dependency detected. Path: ${F.map(V=>V.toString?V.toString():""+V).join(" -> ")}`));const K=new by;return f.set(D,K.p),(async()=>{var V;if(!F){const se=u(D);for(const te of se){const pe=await w(te);if(pe&&pe.items.length>0)return}}try{return e instanceof gi?await D.provideInlineCompletions(t,e,i,n):await((V=D.provideInlineEdits)==null?void 0:V.call(D,t,e,i,n))}catch(se){rs(se);return}})().then(V=>K.complete(V),V=>K.error(V)),K.p}const y=await Promise.all(a.map(async D=>({provider:D,completions:await w(D)}))),x=new Map,k=[];for(const D of y){const M=D.completions;if(!M)continue;const F=new L6(M,D.provider);k.push(F);for(const K of M.items){const V=zv.from(K,F,r,t,s);x.set(V.hash(),V)}}return new k6(Array.from(x.values()),new Set(x.keys()),k)}class k6{constructor(e,t,i){this.completions=e,this.hashs=t,this.providerResults=i}has(e){return this.hashs.has(e.hash())}dispose(){for(const e of this.providerResults)e.removeRef()}}class L6{constructor(e,t){this.inlineCompletions=e,this.provider=t,this.refCount=1}addRef(){this.refCount++}removeRef(){this.refCount--,this.refCount===0&&this.provider.freeInlineCompletions(this.inlineCompletions)}}class zv{static from(e,t,i,n,s){let r,a,d=e.range?Z.lift(e.range):i;if(typeof e.insertText=="string"){if(r=e.insertText,s&&e.completeBracketPairs){r=KI(r,d.getStartPosition(),n,s);const u=r.length-e.insertText.length;u!==0&&(d=new Z(d.startLineNumber,d.startColumn,d.endLineNumber,d.endColumn+u))}a=void 0}else if("snippet"in e.insertText){const u=e.insertText.snippet.length;if(s&&e.completeBracketPairs){e.insertText.snippet=KI(e.insertText.snippet,d.getStartPosition(),n,s);const g=e.insertText.snippet.length-u;g!==0&&(d=new Z(d.startLineNumber,d.startColumn,d.endLineNumber,d.endColumn+g))}const f=new ku().parse(e.insertText.snippet);f.children.length===1&&f.children[0]instanceof Io?(r=f.children[0].value,a=void 0):(r=f.toString(),a={snippet:e.insertText.snippet,range:d})}else CO(e.insertText);return new zv(r,e.command,d,r,a,e.additionalTextEdits||m6(),e,t)}constructor(e,t,i,n,s,r,a,d){this.filterText=e,this.command=t,this.range=i,this.insertText=n,this.snippetInfo=s,this.additionalTextEdits=r,this.sourceInlineCompletion=a,this.source=d,e=e.replace(/\r\n|\r/g,`
34
- `),n=e.replace(/\r\n|\r/g,`
35
- `)}withRange(e){return new zv(this.filterText,this.command,e,this.insertText,this.snippetInfo,this.additionalTextEdits,this.sourceInlineCompletion,this.source)}hash(){return JSON.stringify({insertText:this.insertText,range:this.range.toString()})}toSingleTextEdit(){return new xl(this.range,this.insertText)}}function I6(o,e){const t=e.getWordAtPosition(o),i=e.getLineMaxColumn(o.lineNumber);return t?new Z(o.lineNumber,t.startColumn,o.lineNumber,i):Z.fromPositions(o,o.with(void 0,i))}function KI(o,e,t,i){const s=t.getLineContent(e.lineNumber).substring(0,e.column-1)+o,r=t.tokenization.tokenizeLineWithEdit(e,s.length-(e.column-1),o),a=r==null?void 0:r.sliceAndInflate(e.column-1,s.length,0);return a?C6(a,i):o}function Ed(o,e,t){const i=t?o.range.intersectRanges(t):o.range;if(!i)return o;const n=e.getValueInRange(i,1),s=v_(n,o.text),r=rv.ofText(n.substring(0,s)).addToPosition(o.range.getStartPosition()),a=o.text.substring(s),d=Z.fromPositions(r,o.range.getEndPosition());return new xl(d,a)}function XR(o,e){return o.text.startsWith(e.text)&&E6(o.range,e.range)}function ZI(o,e,t,i,n=0){let s=Ed(o,e);if(s.range.endLineNumber!==s.range.startLineNumber)return;const r=e.getLineContent(s.range.startLineNumber),a=Ks(r).length;if(s.range.startColumn-1<=a){const y=Ks(s.text).length,x=r.substring(s.range.startColumn-1,a),[k,D]=[s.range.getStartPosition(),s.range.getEndPosition()],M=k.column+x.length<=D.column?k.delta(0,x.length):D,F=Z.fromPositions(M,D),K=s.text.startsWith(x)?s.text.substring(x.length):s.text.substring(y);s=new xl(F,K)}const u=e.getValueInRange(s.range),f=D6(u,s.text);if(!f)return;const g=s.range.startLineNumber,p=new Array;if(t==="prefix"){const y=f.filter(x=>x.originalLength===0);if(y.length>1||y.length===1&&y[0].originalStart!==u.length)return}const w=s.text.length-n;for(const y of f){const x=s.range.startColumn+y.originalStart+y.originalLength;if(t==="subwordSmart"&&i&&i.lineNumber===s.range.startLineNumber&&x<i.column||y.originalLength>0)return;if(y.modifiedLength===0)continue;const k=y.modifiedStart+y.modifiedLength,D=Math.max(y.modifiedStart,Math.min(k,w)),M=s.text.substring(y.modifiedStart,D),F=s.text.substring(D,Math.max(y.modifiedStart,k));M.length>0&&p.push(new Bv(x,M,!1)),F.length>0&&p.push(new Bv(x,F,!0))}return new Np(g,p)}function E6(o,e){return e.getStartPosition().equals(o.getStartPosition())&&e.getEndPosition().isBeforeOrEqual(o.getEndPosition())}let ba;function D6(o,e){if((ba==null?void 0:ba.originalValue)===o&&(ba==null?void 0:ba.newValue)===e)return ba==null?void 0:ba.changes;{let t=XI(o,e,!0);if(t){const i=YI(t);if(i>0){const n=XI(o,e,!1);n&&YI(n)<i&&(t=n)}}return ba={originalValue:o,newValue:e,changes:t},t}}function YI(o){let e=0;for(const t of o)e+=t.originalLength;return e}function XI(o,e,t){if(o.length>5e3||e.length>5e3)return;function i(u){let f=0;for(let g=0,p=u.length;g<p;g++){const w=u.charCodeAt(g);w>f&&(f=w)}return f}const n=Math.max(i(o),i(e));function s(u){if(u<0)throw new Error("unexpected");return n+u+1}function r(u){let f=0,g=0;const p=new Int32Array(u.length);for(let w=0,y=u.length;w<y;w++)if(t&&u[w]==="("){const x=g*100+f;p[w]=s(2*x),f++}else if(t&&u[w]===")"){f=Math.max(f-1,0);const x=g*100+f;p[w]=s(2*x+1),f===0&&g++}else p[w]=u.charCodeAt(w);return p}const a=r(o),d=r(e);return new xO({getElements:()=>a},{getElements:()=>d}).ComputeDiff(!1).changes}var T6=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},QI=function(o,e){return function(t,i){e(t,i,o)}};let i1=class extends Dt{constructor(e,t,i,n,s){super(),this.textModel=e,this.versionId=t,this._debounceValue=i,this.languageFeaturesService=n,this.languageConfigurationService=s,this._updateOperation=this._register(new Go),this.inlineCompletions=ES("inlineCompletions",void 0),this.suggestWidgetInlineCompletions=ES("suggestWidgetInlineCompletions",void 0),this._register(this.textModel.onDidChangeContent(()=>{this._updateOperation.clear()}))}fetch(e,t,i){var f,g;const n=new M6(e,t,this.textModel.getVersionId()),s=t.selectedSuggestionInfo?this.suggestWidgetInlineCompletions:this.inlineCompletions;if((f=this._updateOperation.value)!=null&&f.request.satisfies(n))return this._updateOperation.value.promise;if((g=s.get())!=null&&g.request.satisfies(n))return Promise.resolve(!0);const r=!!this._updateOperation.value;this._updateOperation.clear();const a=new Fs,d=(async()=>{if((r||t.triggerKind===ml.Automatic)&&await P6(this._debounceValue.get(this.textModel),a.token),a.token.isCancellationRequested||this._store.isDisposed||this.textModel.getVersionId()!==n.versionId)return!1;const w=new Date,y=await YR(this.languageFeaturesService.inlineCompletionsProvider,e,this.textModel,t,a.token,this.languageConfigurationService);if(a.token.isCancellationRequested||this._store.isDisposed||this.textModel.getVersionId()!==n.versionId)return!1;const x=new Date;this._debounceValue.update(this.textModel,x.getTime()-w.getTime());const k=new N6(y,n,this.textModel,this.versionId);if(i){const D=i.toInlineCompletion(void 0);i.canBeReused(this.textModel,e)&&!y.has(D)&&k.prepend(i.inlineCompletion,D.range,!0)}return this._updateOperation.clear(),Hu(D=>{s.set(k,D)}),!0})(),u=new R6(n,a,d);return this._updateOperation.value=u,d}clear(e){this._updateOperation.clear(),this.inlineCompletions.set(void 0,e),this.suggestWidgetInlineCompletions.set(void 0,e)}clearSuggestWidgetInlineCompletions(e){var t;(t=this._updateOperation.value)!=null&&t.request.context.selectedSuggestionInfo&&this._updateOperation.clear(),this.suggestWidgetInlineCompletions.set(void 0,e)}cancelUpdate(){this._updateOperation.clear()}};i1=T6([QI(3,pi),QI(4,Ds)],i1);function P6(o,e){return new Promise(t=>{let i;const n=setTimeout(()=>{i&&i.dispose(),t()},o);e&&(i=e.onCancellationRequested(()=>{clearTimeout(n),i&&i.dispose(),t()}))})}class M6{constructor(e,t,i){this.position=e,this.context=t,this.versionId=i}satisfies(e){return this.position.equals(e.position)&&kO(this.context.selectedSuggestionInfo,e.context.selectedSuggestionInfo,IO())&&(e.context.triggerKind===ml.Automatic||this.context.triggerKind===ml.Explicit)&&this.versionId===e.versionId}}class R6{constructor(e,t,i){this.request=e,this.cancellationTokenSource=t,this.promise=i}dispose(){this.cancellationTokenSource.cancel()}}class N6{get inlineCompletions(){return this._inlineCompletions}constructor(e,t,i,n){this.inlineCompletionProviderResult=e,this.request=t,this._textModel=i,this._versionId=n,this._refCount=1,this._prependedInlineCompletionItems=[];const s=i.deltaDecorations([],e.completions.map(r=>({range:r.range,options:{description:"inline-completion-tracking-range"}})));this._inlineCompletions=e.completions.map((r,a)=>new JI(r,s[a],this._textModel,this._versionId))}clone(){return this._refCount++,this}dispose(){if(this._refCount--,this._refCount===0){setTimeout(()=>{this._textModel.isDisposed()||this._textModel.deltaDecorations(this._inlineCompletions.map(e=>e.decorationId),[])},0),this.inlineCompletionProviderResult.dispose();for(const e of this._prependedInlineCompletionItems)e.source.removeRef()}}prepend(e,t,i){i&&e.source.addRef();const n=this._textModel.deltaDecorations([],[{range:t,options:{description:"inline-completion-tracking-range"}}])[0];this._inlineCompletions.unshift(new JI(e,n,this._textModel,this._versionId)),this._prependedInlineCompletionItems.push(e)}}class JI{get forwardStable(){return this.inlineCompletion.source.inlineCompletions.enableForwardStability??!1}constructor(e,t,i,n){this.inlineCompletion=e,this.decorationId=t,this._textModel=i,this._modelVersion=n,this.semanticId=JSON.stringify([this.inlineCompletion.filterText,this.inlineCompletion.insertText,this.inlineCompletion.range.getStartPosition().toString()]),this._updatedRange=cl({owner:this,equalsFn:Z.equalsRange},s=>(this._modelVersion.read(s),this._textModel.getDecorationRange(this.decorationId)))}toInlineCompletion(e){return this.inlineCompletion.withRange(this._updatedRange.read(e)??Yw)}toSingleTextEdit(e){return new xl(this._updatedRange.read(e)??Yw,this.inlineCompletion.insertText)}isVisible(e,t,i){const n=Ed(this._toFilterTextReplacement(i),e),s=this._updatedRange.read(i);if(!s||!this.inlineCompletion.range.getStartPosition().equals(s.getStartPosition())||t.lineNumber!==n.range.startLineNumber)return!1;const r=e.getValueInRange(n.range,1),a=n.text,d=Math.max(0,t.column-n.range.startColumn);let u=a.substring(0,d),f=a.substring(d),g=r.substring(0,d),p=r.substring(d);const w=e.getLineIndentColumn(n.range.startLineNumber);return n.range.startColumn<=w&&(g=g.trimStart(),g.length===0&&(p=p.trimStart()),u=u.trimStart(),u.length===0&&(f=f.trimStart())),u.startsWith(g)&&!!LO(p,f)}canBeReused(e,t){const i=this._updatedRange.read(void 0);return!!i&&i.containsPosition(t)&&this.isVisible(e,t,void 0)&&rv.ofRange(i).isGreaterThanOrEqualTo(rv.ofRange(this.inlineCompletion.range))}_toFilterTextReplacement(e){return new xl(this._updatedRange.read(e)??Yw,this.inlineCompletion.filterText)}}const Yw=new Z(1,1,1,1),Wi={Visible:ok,HasFocusedSuggestion:new _n("suggestWidgetHasFocusedSuggestion",!1,C("suggestWidgetHasSelection","Whether any suggestion is focused")),DetailsVisible:new _n("suggestWidgetDetailsVisible",!1,C("suggestWidgetDetailsVisible","Whether suggestion details are visible")),MultipleSuggestions:new _n("suggestWidgetMultipleSuggestions",!1,C("suggestWidgetMultipleSuggestions","Whether there are multiple suggestions to pick from")),MakesTextEdit:new _n("suggestionMakesTextEdit",!0,C("suggestionMakesTextEdit","Whether inserting the current suggestion yields in a change or has everything already been typed")),AcceptSuggestionsOnEnter:new _n("acceptSuggestionOnEnter",!0,C("acceptSuggestionOnEnter","Whether suggestions are inserted when pressing Enter")),HasInsertAndReplaceRange:new _n("suggestionHasInsertAndReplaceRange",!1,C("suggestionHasInsertAndReplaceRange","Whether the current suggestion has insert and replace behaviour")),InsertMode:new _n("suggestionInsertMode",void 0,{type:"string",description:C("suggestionInsertMode","Whether the default behaviour is to insert or replace")}),CanResolve:new _n("suggestionCanResolve",!1,C("suggestionCanResolve","Whether the current suggestion supports to resolve further details"))},gc=new Gt("suggestWidgetStatusBar");class A6{constructor(e,t,i,n){var s;this.position=e,this.completion=t,this.container=i,this.provider=n,this.isInvalid=!1,this.score=mp.Default,this.distance=0,this.textLabel=typeof t.label=="string"?t.label:(s=t.label)==null?void 0:s.label,this.labelLow=this.textLabel.toLowerCase(),this.isInvalid=!this.textLabel,this.sortTextLow=t.sortText&&t.sortText.toLowerCase(),this.filterTextLow=t.filterText&&t.filterText.toLowerCase(),this.extensionId=t.extensionId,Z.isIRange(t.range)?(this.editStart=new gi(t.range.startLineNumber,t.range.startColumn),this.editInsertEnd=new gi(t.range.endLineNumber,t.range.endColumn),this.editReplaceEnd=new gi(t.range.endLineNumber,t.range.endColumn),this.isInvalid=this.isInvalid||Z.spansMultipleLines(t.range)||t.range.startLineNumber!==e.lineNumber):(this.editStart=new gi(t.range.insert.startLineNumber,t.range.insert.startColumn),this.editInsertEnd=new gi(t.range.insert.endLineNumber,t.range.insert.endColumn),this.editReplaceEnd=new gi(t.range.replace.endLineNumber,t.range.replace.endColumn),this.isInvalid=this.isInvalid||Z.spansMultipleLines(t.range.insert)||Z.spansMultipleLines(t.range.replace)||t.range.insert.startLineNumber!==e.lineNumber||t.range.replace.startLineNumber!==e.lineNumber||t.range.insert.startColumn!==t.range.replace.startColumn),typeof n.resolveCompletionItem!="function"&&(this._resolveCache=Promise.resolve(),this._resolveDuration=0)}get isResolved(){return this._resolveDuration!==void 0}get resolveDuration(){return this._resolveDuration!==void 0?this._resolveDuration:-1}async resolve(e){if(!this._resolveCache){const t=e.onCancellationRequested(()=>{this._resolveCache=void 0,this._resolveDuration=void 0}),i=new Mo(!0);this._resolveCache=Promise.resolve(this.provider.resolveCompletionItem(this.completion,e)).then(n=>{Object.assign(this.completion,n),this._resolveDuration=i.elapsed()},n=>{Bc(n)&&(this._resolveCache=void 0,this._resolveDuration=void 0)}).finally(()=>{t.dispose()})}return this._resolveCache}}const Wb=class Wb{constructor(e=2,t=new Set,i=new Set,n=new Map,s=!0){this.snippetSortOrder=e,this.kindFilter=t,this.providerFilter=i,this.providerItemsToReuse=n,this.showDeprecated=s}};Wb.default=new Wb;let Ap=Wb;class O6{constructor(e,t,i,n){this.items=e,this.needsClipboard=t,this.durations=i,this.disposable=n}}async function hk(o,e,t,i=Ap.default,n={triggerKind:0},s=Qi.None){const r=new Mo;t=t.clone();const a=e.getWordAtPosition(t),d=a?new Z(t.lineNumber,a.startColumn,t.lineNumber,a.endColumn):Z.fromPositions(t),u={replace:d,insert:d.setEndPosition(t.lineNumber,t.column)},f=[],g=new Lt,p=[];let w=!1;const y=(k,D,M)=>{var K;let F=!1;if(!D)return F;for(const V of D.suggestions)if(!i.kindFilter.has(V.kind)){if(!i.showDeprecated&&((K=V==null?void 0:V.tags)!=null&&K.includes(1)))continue;V.range||(V.range=u),V.sortText||(V.sortText=typeof V.label=="string"?V.label:V.label.label),!w&&V.insertTextRules&&V.insertTextRules&4&&(w=ku.guessNeedsClipboard(V.insertText)),f.push(new A6(t,V,D,k)),F=!0}return LT(D)&&g.add(D),p.push({providerName:k._debugDisplayName??"unknown_provider",elapsedProvider:D.duration??-1,elapsedOverall:M.elapsed()}),F},x=(async()=>{})();for(const k of o.orderedGroups(e)){let D=!1;if(await Promise.all(k.map(async M=>{if(i.providerItemsToReuse.has(M)){const F=i.providerItemsToReuse.get(M);F.forEach(K=>f.push(K)),D=D||F.length>0;return}if(!(i.providerFilter.size>0&&!i.providerFilter.has(M)))try{const F=new Mo,K=await M.provideCompletionItems(e,t,n,s);D=y(M,K,F)||D}catch(F){rs(F)}})),D||s.isCancellationRequested)break}return await x,s.isCancellationRequested?(g.dispose(),Promise.reject(new yy)):new O6(f.sort(W6(i.snippetSortOrder)),w,{entries:p,elapsed:r.elapsed()},g)}function fk(o,e){if(o.sortTextLow&&e.sortTextLow){if(o.sortTextLow<e.sortTextLow)return-1;if(o.sortTextLow>e.sortTextLow)return 1}return o.textLabel<e.textLabel?-1:o.textLabel>e.textLabel?1:o.completion.kind-e.completion.kind}function F6(o,e){if(o.completion.kind!==e.completion.kind){if(o.completion.kind===27)return-1;if(e.completion.kind===27)return 1}return fk(o,e)}function H6(o,e){if(o.completion.kind!==e.completion.kind){if(o.completion.kind===27)return 1;if(e.completion.kind===27)return-1}return fk(o,e)}const tw=new Map;tw.set(0,F6);tw.set(2,H6);tw.set(1,fk);function W6(o){return tw.get(o)}Wn.registerCommand("_executeCompletionItemProvider",async(o,...e)=>{const[t,i,n,s]=e;Cn(Pn.isUri(t)),Cn(gi.isIPosition(i)),Cn(typeof n=="string"||!n),Cn(typeof s=="number"||!s);const{completionProvider:r}=o.get(pi),a=await o.get(ga).createModelReference(t);try{const d={incomplete:!1,suggestions:[]},u=[],f=a.object.textEditorModel.validatePosition(i),g=await hk(r,a.object.textEditorModel,f,void 0,{triggerCharacter:n??void 0,triggerKind:n?1:0});for(const p of g.items)u.length<(s??0)&&u.push(p.resolve(Qi.None)),d.incomplete=d.incomplete||p.container.incomplete,d.suggestions.push(p.completion);try{return await Promise.all(u),d}finally{setTimeout(()=>g.disposable.dispose(),100)}}finally{a.dispose()}});function B6(o,e){var t;(t=o.getContribution("editor.contrib.suggestController"))==null||t.triggerSuggest(new Set().add(e),void 0,!0)}class Mh{static isAllOff(e){return e.other==="off"&&e.comments==="off"&&e.strings==="off"}static isAllOn(e){return e.other==="on"&&e.comments==="on"&&e.strings==="on"}static valueFor(e,t){switch(t){case 1:return e.comments;case 2:return e.strings;default:return e.other}}}function eE(o,e=vy){return EO(o,e)?o.charAt(0).toUpperCase()+o.slice(1):o}var z6=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},V6=function(o,e){return function(t,i){e(t,i,o)}};class tE{constructor(e){this._delegates=e}resolve(e){for(const t of this._delegates){const i=t.resolve(e);if(i!==void 0)return i}}}class iE{constructor(e,t,i,n){this._model=e,this._selection=t,this._selectionIdx=i,this._overtypingCapturer=n}resolve(e){const{name:t}=e;if(t==="SELECTION"||t==="TM_SELECTED_TEXT"){let i=this._model.getValueInRange(this._selection)||void 0,n=this._selection.startLineNumber!==this._selection.endLineNumber;if(!i&&this._overtypingCapturer){const s=this._overtypingCapturer.getLastOvertypedInfo(this._selectionIdx);s&&(i=s.value,n=s.multiline)}if(i&&n&&e.snippet){const s=this._model.getLineContent(this._selection.startLineNumber),r=Ks(s,0,this._selection.startColumn-1);let a=r;e.snippet.walk(u=>u===e?!1:(u instanceof Io&&(a=Ks(Ty(u.value).pop())),!0));const d=v_(a,r);i=i.replace(/(\r\n|\r|\n)(.*)/g,(u,f,g)=>`${f}${a.substr(d)}${g}`)}return i}else{if(t==="TM_CURRENT_LINE")return this._model.getLineContent(this._selection.positionLineNumber);if(t==="TM_CURRENT_WORD"){const i=this._model.getWordAtPosition({lineNumber:this._selection.positionLineNumber,column:this._selection.positionColumn});return i&&i.word||void 0}else{if(t==="TM_LINE_INDEX")return String(this._selection.positionLineNumber-1);if(t==="TM_LINE_NUMBER")return String(this._selection.positionLineNumber);if(t==="CURSOR_INDEX")return String(this._selectionIdx);if(t==="CURSOR_NUMBER")return String(this._selectionIdx+1)}}}}class nE{constructor(e,t){this._labelService=e,this._model=t}resolve(e){const{name:t}=e;if(t==="TM_FILENAME")return Vg(this._model.uri.fsPath);if(t==="TM_FILENAME_BASE"){const i=Vg(this._model.uri.fsPath),n=i.lastIndexOf(".");return n<=0?i:i.slice(0,n)}else{if(t==="TM_DIRECTORY")return DO(this._model.uri.fsPath)==="."?"":this._labelService.getUriLabel(l0(this._model.uri));if(t==="TM_FILEPATH")return this._labelService.getUriLabel(this._model.uri);if(t==="RELATIVE_FILEPATH")return this._labelService.getUriLabel(this._model.uri,{relative:!0,noPrefix:!0})}}}class sE{constructor(e,t,i,n){this._readClipboardText=e,this._selectionIdx=t,this._selectionCount=i,this._spread=n}resolve(e){if(e.name!=="CLIPBOARD")return;const t=this._readClipboardText();if(t){if(this._spread){const i=t.split(/\r\n|\n|\r/).filter(n=>!TO(n));if(i.length===this._selectionCount)return i[this._selectionIdx]}return t}}}let Vv=class{constructor(e,t,i){this._model=e,this._selection=t,this._languageConfigurationService=i}resolve(e){const{name:t}=e,i=this._model.getLanguageIdAtPosition(this._selection.selectionStartLineNumber,this._selection.selectionStartColumn),n=this._languageConfigurationService.getLanguageConfiguration(i).comments;if(n){if(t==="LINE_COMMENT")return n.lineCommentToken||void 0;if(t==="BLOCK_COMMENT_START")return n.blockCommentStartToken||void 0;if(t==="BLOCK_COMMENT_END")return n.blockCommentEndToken||void 0}}};Vv=z6([V6(2,Ds)],Vv);const ka=class ka{constructor(){this._date=new Date}resolve(e){const{name:t}=e;if(t==="CURRENT_YEAR")return String(this._date.getFullYear());if(t==="CURRENT_YEAR_SHORT")return String(this._date.getFullYear()).slice(-2);if(t==="CURRENT_MONTH")return String(this._date.getMonth().valueOf()+1).padStart(2,"0");if(t==="CURRENT_DATE")return String(this._date.getDate().valueOf()).padStart(2,"0");if(t==="CURRENT_HOUR")return String(this._date.getHours().valueOf()).padStart(2,"0");if(t==="CURRENT_MINUTE")return String(this._date.getMinutes().valueOf()).padStart(2,"0");if(t==="CURRENT_SECOND")return String(this._date.getSeconds().valueOf()).padStart(2,"0");if(t==="CURRENT_DAY_NAME")return ka.dayNames[this._date.getDay()];if(t==="CURRENT_DAY_NAME_SHORT")return ka.dayNamesShort[this._date.getDay()];if(t==="CURRENT_MONTH_NAME")return ka.monthNames[this._date.getMonth()];if(t==="CURRENT_MONTH_NAME_SHORT")return ka.monthNamesShort[this._date.getMonth()];if(t==="CURRENT_SECONDS_UNIX")return String(Math.floor(this._date.getTime()/1e3));if(t==="CURRENT_TIMEZONE_OFFSET"){const i=this._date.getTimezoneOffset(),n=i>0?"-":"+",s=Math.trunc(Math.abs(i/60)),r=s<10?"0"+s:s,a=Math.abs(i)-s*60,d=a<10?"0"+a:a;return n+r+":"+d}}};ka.dayNames=[C("Sunday","Sunday"),C("Monday","Monday"),C("Tuesday","Tuesday"),C("Wednesday","Wednesday"),C("Thursday","Thursday"),C("Friday","Friday"),C("Saturday","Saturday")],ka.dayNamesShort=[C("SundayShort","Sun"),C("MondayShort","Mon"),C("TuesdayShort","Tue"),C("WednesdayShort","Wed"),C("ThursdayShort","Thu"),C("FridayShort","Fri"),C("SaturdayShort","Sat")],ka.monthNames=[C("January","January"),C("February","February"),C("March","March"),C("April","April"),C("May","May"),C("June","June"),C("July","July"),C("August","August"),C("September","September"),C("October","October"),C("November","November"),C("December","December")],ka.monthNamesShort=[C("JanuaryShort","Jan"),C("FebruaryShort","Feb"),C("MarchShort","Mar"),C("AprilShort","Apr"),C("MayShort","May"),C("JuneShort","Jun"),C("JulyShort","Jul"),C("AugustShort","Aug"),C("SeptemberShort","Sep"),C("OctoberShort","Oct"),C("NovemberShort","Nov"),C("DecemberShort","Dec")];let jv=ka;class oE{constructor(e){this._workspaceService=e}resolve(e){if(!this._workspaceService)return;const t=PO(this._workspaceService.getWorkspace());if(!MO(t)){if(e.name==="WORKSPACE_NAME")return this._resolveWorkspaceName(t);if(e.name==="WORKSPACE_FOLDER")return this._resoveWorkspacePath(t)}}_resolveWorkspaceName(e){if(CL(e))return Vg(e.uri.path);let t=Vg(e.configPath.path);return t.endsWith(xL)&&(t=t.substr(0,t.length-xL.length-1)),t}_resoveWorkspacePath(e){if(CL(e))return eE(e.uri.fsPath);const t=Vg(e.configPath.path);let i=e.configPath.fsPath;return i.endsWith(t)&&(i=i.substr(0,i.length-t.length-1)),i?eE(i):"/"}}class rE{resolve(e){const{name:t}=e;if(t==="RANDOM")return Math.random().toString().slice(-6);if(t==="RANDOM_HEX")return Math.random().toString(16).slice(-6);if(t==="UUID")return Uy()}}var j6=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},$6=function(o,e){return function(t,i){e(t,i,o)}},qr;const yr=class yr{constructor(e,t,i){this._editor=e,this._snippet=t,this._snippetLineLeadingWhitespace=i,this._offset=-1,this._nestingLevel=1,this._placeholderGroups=kL(t.placeholders,lr.compareByIndex),this._placeholderGroupsIdx=-1}initialize(e){this._offset=e.newPosition}dispose(){this._placeholderDecorations&&this._editor.removeDecorations([...this._placeholderDecorations.values()]),this._placeholderGroups.length=0}_initDecorations(){if(this._offset===-1)throw new Error("Snippet not initialized!");if(this._placeholderDecorations)return;this._placeholderDecorations=new Map;const e=this._editor.getModel();this._editor.changeDecorations(t=>{for(const i of this._snippet.placeholders){const n=this._snippet.offset(i),s=this._snippet.fullLen(i),r=Z.fromPositions(e.getPositionAt(this._offset+n),e.getPositionAt(this._offset+n+s)),a=i.isFinalTabstop?yr._decor.inactiveFinal:yr._decor.inactive,d=t.addDecoration(r,a);this._placeholderDecorations.set(i,d)}})}move(e){if(!this._editor.hasModel())return[];if(this._initDecorations(),this._placeholderGroupsIdx>=0){const n=[];for(const s of this._placeholderGroups[this._placeholderGroupsIdx])if(s.transform){const r=this._placeholderDecorations.get(s),a=this._editor.getModel().getDecorationRange(r),d=this._editor.getModel().getValueInRange(a),u=s.transform.resolve(d).split(/\r\n|\r|\n/);for(let f=1;f<u.length;f++)u[f]=this._editor.getModel().normalizeIndentation(this._snippetLineLeadingWhitespace+u[f]);n.push(Qn.replace(a,u.join(this._editor.getModel().getEOL())))}n.length>0&&this._editor.executeEdits("snippet.placeholderTransform",n)}let t=!1;e===!0&&this._placeholderGroupsIdx<this._placeholderGroups.length-1?(this._placeholderGroupsIdx+=1,t=!0):e===!1&&this._placeholderGroupsIdx>0&&(this._placeholderGroupsIdx-=1,t=!0);const i=this._editor.getModel().changeDecorations(n=>{const s=new Set,r=[];for(const a of this._placeholderGroups[this._placeholderGroupsIdx]){const d=this._placeholderDecorations.get(a),u=this._editor.getModel().getDecorationRange(d);r.push(new Fi(u.startLineNumber,u.startColumn,u.endLineNumber,u.endColumn)),t=t&&this._hasPlaceholderBeenCollapsed(a),n.changeDecorationOptions(d,a.isFinalTabstop?yr._decor.activeFinal:yr._decor.active),s.add(a);for(const f of this._snippet.enclosingPlaceholders(a)){const g=this._placeholderDecorations.get(f);n.changeDecorationOptions(g,f.isFinalTabstop?yr._decor.activeFinal:yr._decor.active),s.add(f)}}for(const[a,d]of this._placeholderDecorations)s.has(a)||n.changeDecorationOptions(d,a.isFinalTabstop?yr._decor.inactiveFinal:yr._decor.inactive);return r});return t?this.move(e):i??[]}_hasPlaceholderBeenCollapsed(e){let t=e;for(;t;){if(t instanceof lr){const i=this._placeholderDecorations.get(t);if(this._editor.getModel().getDecorationRange(i).isEmpty()&&t.toString().length>0)return!0}t=t.parent}return!1}get isAtFirstPlaceholder(){return this._placeholderGroupsIdx<=0||this._placeholderGroups.length===0}get isAtLastPlaceholder(){return this._placeholderGroupsIdx===this._placeholderGroups.length-1}get hasPlaceholder(){return this._snippet.placeholders.length>0}get isTrivialSnippet(){if(this._snippet.placeholders.length===0)return!0;if(this._snippet.placeholders.length===1){const[e]=this._snippet.placeholders;if(e.isFinalTabstop&&this._snippet.rightMostDescendant===e)return!0}return!1}computePossibleSelections(){const e=new Map;for(const t of this._placeholderGroups){let i;for(const n of t){if(n.isFinalTabstop)break;i||(i=[],e.set(n.index,i));const s=this._placeholderDecorations.get(n),r=this._editor.getModel().getDecorationRange(s);if(!r){e.delete(n.index);break}i.push(r)}}return e}get activeChoice(){if(!this._placeholderDecorations)return;const e=this._placeholderGroups[this._placeholderGroupsIdx][0];if(!(e!=null&&e.choice))return;const t=this._placeholderDecorations.get(e);if(!t)return;const i=this._editor.getModel().getDecorationRange(t);if(i)return{range:i,choice:e.choice}}get hasChoice(){let e=!1;return this._snippet.walk(t=>(e=t instanceof Yf,!e)),e}merge(e){const t=this._editor.getModel();this._nestingLevel*=10,this._editor.changeDecorations(i=>{for(const n of this._placeholderGroups[this._placeholderGroupsIdx]){const s=e.shift();console.assert(s._offset!==-1),console.assert(!s._placeholderDecorations);const r=s._snippet.placeholderInfo.last.index;for(const d of s._snippet.placeholderInfo.all)d.isFinalTabstop?d.index=n.index+(r+1)/this._nestingLevel:d.index=n.index+d.index/this._nestingLevel;this._snippet.replace(n,s._snippet.children);const a=this._placeholderDecorations.get(n);i.removeDecoration(a),this._placeholderDecorations.delete(n);for(const d of s._snippet.placeholders){const u=s._snippet.offset(d),f=s._snippet.fullLen(d),g=Z.fromPositions(t.getPositionAt(s._offset+u),t.getPositionAt(s._offset+u+f)),p=i.addDecoration(g,yr._decor.inactive);this._placeholderDecorations.set(d,p)}}this._placeholderGroups=kL(this._snippet.placeholders,lr.compareByIndex)})}};yr._decor={active:dn.register({description:"snippet-placeholder-1",stickiness:0,className:"snippet-placeholder"}),inactive:dn.register({description:"snippet-placeholder-2",stickiness:1,className:"snippet-placeholder"}),activeFinal:dn.register({description:"snippet-placeholder-3",stickiness:1,className:"finish-snippet-placeholder"}),inactiveFinal:dn.register({description:"snippet-placeholder-4",stickiness:1,className:"finish-snippet-placeholder"})};let $v=yr;const aE={overwriteBefore:0,overwriteAfter:0,adjustWhitespace:!0,clipboardText:void 0,overtypingCapturer:void 0};let Uv=qr=class{static adjustWhitespace(e,t,i,n,s){const r=e.getLineContent(t.lineNumber),a=Ks(r,0,t.column-1);let d;return n.walk(u=>{if(!(u instanceof Io)||u.parent instanceof Yf||s&&!s.has(u))return!0;const f=u.value.split(/\r\n|\r|\n/);if(i){const p=n.offset(u);if(p===0)f[0]=e.normalizeIndentation(f[0]);else{d=d??n.toString();const w=d.charCodeAt(p-1);(w===10||w===13)&&(f[0]=e.normalizeIndentation(a+f[0]))}for(let w=1;w<f.length;w++)f[w]=e.normalizeIndentation(a+f[w])}const g=f.join(e.getEOL());return g!==u.value&&(u.parent.replace(u,[new Io(g)]),d=void 0),!0}),a}static adjustSelection(e,t,i,n){if(i!==0||n!==0){const{positionLineNumber:s,positionColumn:r}=t,a=r-i,d=r+n,u=e.validateRange({startLineNumber:s,startColumn:a,endLineNumber:s,endColumn:d});t=Fi.createWithDirection(u.startLineNumber,u.startColumn,u.endLineNumber,u.endColumn,t.getDirection())}return t}static createEditsAndSnippetsFromSelections(e,t,i,n,s,r,a,d,u){const f=[],g=[];if(!e.hasModel())return{edits:f,snippets:g};const p=e.getModel(),w=e.invokeWithinContext(K=>K.get(uf)),y=e.invokeWithinContext(K=>new nE(K.get(_p),p)),x=()=>a,k=p.getValueInRange(qr.adjustSelection(p,e.getSelection(),i,0)),D=p.getValueInRange(qr.adjustSelection(p,e.getSelection(),0,n)),M=p.getLineFirstNonWhitespaceColumn(e.getSelection().positionLineNumber),F=e.getSelections().map((K,V)=>({selection:K,idx:V})).sort((K,V)=>Z.compareRangesUsingStarts(K.selection,V.selection));for(const{selection:K,idx:V}of F){let se=qr.adjustSelection(p,K,i,0),te=qr.adjustSelection(p,K,0,n);k!==p.getValueInRange(se)&&(se=K),D!==p.getValueInRange(te)&&(te=K);const pe=K.setStartPosition(se.startLineNumber,se.startColumn).setEndPosition(te.endLineNumber,te.endColumn),je=new ku().parse(t,!0,s),Ke=pe.getStartPosition(),ue=qr.adjustWhitespace(p,Ke,r||V>0&&M!==p.getLineFirstNonWhitespaceColumn(K.positionLineNumber),je);je.resolveVariables(new tE([y,new sE(x,V,F.length,e.getOption(79)==="spread"),new iE(p,K,V,d),new Vv(p,K,u),new jv,new oE(w),new rE])),f[V]=Qn.replace(pe,je.toString()),f[V].identifier={major:V,minor:0},f[V]._isTracked=!0,g[V]=new $v(e,je,ue)}return{edits:f,snippets:g}}static createEditsAndSnippetsFromEdits(e,t,i,n,s,r,a){if(!e.hasModel()||t.length===0)return{edits:[],snippets:[]};const d=[],u=e.getModel(),f=new ku,g=new I_,p=new tE([e.invokeWithinContext(y=>new nE(y.get(_p),u)),new sE(()=>s,0,e.getSelections().length,e.getOption(79)==="spread"),new iE(u,e.getSelection(),0,r),new Vv(u,e.getSelection(),a),new jv,new oE(e.invokeWithinContext(y=>y.get(uf))),new rE]);t=t.sort((y,x)=>Z.compareRangesUsingStarts(y.range,x.range));let w=0;for(let y=0;y<t.length;y++){const{range:x,template:k}=t[y];if(y>0){const V=t[y-1].range,se=Z.fromPositions(V.getEndPosition(),x.getStartPosition()),te=new Io(u.getValueInRange(se));g.appendChild(te),w+=te.value.length}const D=f.parseFragment(k,g);qr.adjustWhitespace(u,x.getStartPosition(),!0,g,new Set(D)),g.resolveVariables(p);const M=g.toString(),F=M.slice(w);w=M.length;const K=Qn.replace(x,F);K.identifier={major:y,minor:0},K._isTracked=!0,d.push(K)}return f.ensureFinalTabstop(g,i,!0),{edits:d,snippets:[new $v(e,g,"")]}}constructor(e,t,i=aE,n){this._editor=e,this._template=t,this._options=i,this._languageConfigurationService=n,this._templateMerges=[],this._snippets=[]}dispose(){no(this._snippets)}_logInfo(){return`template="${this._template}", merged_templates="${this._templateMerges.join(" -> ")}"`}insert(){if(!this._editor.hasModel())return;const{edits:e,snippets:t}=typeof this._template=="string"?qr.createEditsAndSnippetsFromSelections(this._editor,this._template,this._options.overwriteBefore,this._options.overwriteAfter,!1,this._options.adjustWhitespace,this._options.clipboardText,this._options.overtypingCapturer,this._languageConfigurationService):qr.createEditsAndSnippetsFromEdits(this._editor,this._template,!1,this._options.adjustWhitespace,this._options.clipboardText,this._options.overtypingCapturer,this._languageConfigurationService);this._snippets=t,this._editor.executeEdits("snippet",e,i=>{const n=i.filter(s=>!!s.identifier);for(let s=0;s<t.length;s++)t[s].initialize(n[s].textChange);return this._snippets[0].hasPlaceholder?this._move(!0):n.map(s=>Fi.fromPositions(s.range.getEndPosition()))}),this._editor.revealRange(this._editor.getSelections()[0])}merge(e,t=aE){if(!this._editor.hasModel())return;this._templateMerges.push([this._snippets[0]._nestingLevel,this._snippets[0]._placeholderGroupsIdx,e]);const{edits:i,snippets:n}=qr.createEditsAndSnippetsFromSelections(this._editor,e,t.overwriteBefore,t.overwriteAfter,!0,t.adjustWhitespace,t.clipboardText,t.overtypingCapturer,this._languageConfigurationService);this._editor.executeEdits("snippet",i,s=>{const r=s.filter(d=>!!d.identifier);for(let d=0;d<n.length;d++)n[d].initialize(r[d].textChange);const a=n[0].isTrivialSnippet;if(!a){for(const d of this._snippets)d.merge(n);console.assert(n.length===0)}return this._snippets[0].hasPlaceholder&&!a?this._move(void 0):r.map(d=>Fi.fromPositions(d.range.getEndPosition()))})}next(){const e=this._move(!0);this._editor.setSelections(e),this._editor.revealPositionInCenterIfOutsideViewport(e[0].getPosition())}prev(){const e=this._move(!1);this._editor.setSelections(e),this._editor.revealPositionInCenterIfOutsideViewport(e[0].getPosition())}_move(e){const t=[];for(const i of this._snippets){const n=i.move(e);t.push(...n)}return t}get isAtFirstPlaceholder(){return this._snippets[0].isAtFirstPlaceholder}get isAtLastPlaceholder(){return this._snippets[0].isAtLastPlaceholder}get hasPlaceholder(){return this._snippets[0].hasPlaceholder}get hasChoice(){return this._snippets[0].hasChoice}get activeChoice(){return this._snippets[0].activeChoice}isSelectionWithinPlaceholders(){if(!this.hasPlaceholder)return!1;const e=this._editor.getSelections();if(e.length<this._snippets.length)return!1;const t=new Map;for(const i of this._snippets){const n=i.computePossibleSelections();if(t.size===0)for(const[s,r]of n){r.sort(Z.compareRangesUsingStarts);for(const a of e)if(r[0].containsRange(a)){t.set(s,[]);break}}if(t.size===0)return!1;t.forEach((s,r)=>{s.push(...n.get(r))})}e.sort(Z.compareRangesUsingStarts);for(const[i,n]of t){if(n.length!==e.length){t.delete(i);continue}n.sort(Z.compareRangesUsingStarts);for(let s=0;s<n.length;s++)if(!n[s].containsRange(e[s])){t.delete(i);continue}}return t.size>0}};Uv=qr=j6([$6(3,Ds)],Uv);var U6=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},fm=function(o,e){return function(t,i){e(t,i,o)}},wh;const lE={overwriteBefore:0,overwriteAfter:0,undoStopBefore:!0,undoStopAfter:!0,adjustWhitespace:!0,clipboardText:void 0,overtypingCapturer:void 0};var Ra;let lo=(Ra=class{static get(e){return e.getContribution(wh.ID)}constructor(e,t,i,n,s){this._editor=e,this._logService=t,this._languageFeaturesService=i,this._languageConfigurationService=s,this._snippetListener=new Lt,this._modelVersionId=-1,this._inSnippet=wh.InSnippetMode.bindTo(n),this._hasNextTabstop=wh.HasNextTabstop.bindTo(n),this._hasPrevTabstop=wh.HasPrevTabstop.bindTo(n)}dispose(){var e;this._inSnippet.reset(),this._hasPrevTabstop.reset(),this._hasNextTabstop.reset(),(e=this._session)==null||e.dispose(),this._snippetListener.dispose()}insert(e,t){try{this._doInsert(e,typeof t>"u"?lE:{...lE,...t})}catch(i){this.cancel(),this._logService.error(i),this._logService.error("snippet_error"),this._logService.error("insert_template=",e),this._logService.error("existing_template=",this._session?this._session._logInfo():"<no_session>")}}_doInsert(e,t){var i;if(this._editor.hasModel()){if(this._snippetListener.clear(),t.undoStopBefore&&this._editor.getModel().pushStackElement(),this._session&&typeof e!="string"&&this.cancel(),this._session?(Cn(typeof e=="string"),this._session.merge(e,t)):(this._modelVersionId=this._editor.getModel().getAlternativeVersionId(),this._session=new Uv(this._editor,e,t,this._languageConfigurationService),this._session.insert()),t.undoStopAfter&&this._editor.getModel().pushStackElement(),(i=this._session)!=null&&i.hasChoice){const n={_debugDisplayName:"snippetChoiceCompletions",provideCompletionItems:(f,g)=>{if(!this._session||f!==this._editor.getModel()||!gi.equals(this._editor.getPosition(),g))return;const{activeChoice:p}=this._session;if(!p||p.choice.options.length===0)return;const w=f.getValueInRange(p.range),y=!!p.choice.options.find(k=>k.value===w),x=[];for(let k=0;k<p.choice.options.length;k++){const D=p.choice.options[k];x.push({kind:13,label:D.value,insertText:D.value,sortText:"a".repeat(k+1),range:p.range,filterText:y?`${w}_${D.value}`:void 0,command:{id:"jumpToNextSnippetPlaceholder",title:C("next","Go to next placeholder...")}})}return{suggestions:x}}},s=this._editor.getModel();let r,a=!1;const d=()=>{r==null||r.dispose(),a=!1},u=()=>{a||(r=this._languageFeaturesService.completionProvider.register({language:s.getLanguageId(),pattern:s.uri.fsPath,scheme:s.uri.scheme,exclusive:!0},n),this._snippetListener.add(r),a=!0)};this._choiceCompletions={provider:n,enable:u,disable:d}}this._updateState(),this._snippetListener.add(this._editor.onDidChangeModelContent(n=>n.isFlush&&this.cancel())),this._snippetListener.add(this._editor.onDidChangeModel(()=>this.cancel())),this._snippetListener.add(this._editor.onDidChangeCursorSelection(()=>this._updateState()))}}_updateState(){if(!(!this._session||!this._editor.hasModel())){if(this._modelVersionId===this._editor.getModel().getAlternativeVersionId())return this.cancel();if(!this._session.hasPlaceholder)return this.cancel();if(this._session.isAtLastPlaceholder||!this._session.isSelectionWithinPlaceholders())return this._editor.getModel().pushStackElement(),this.cancel();this._inSnippet.set(!0),this._hasPrevTabstop.set(!this._session.isAtFirstPlaceholder),this._hasNextTabstop.set(!this._session.isAtLastPlaceholder),this._handleChoice()}}_handleChoice(){var t;if(!this._session||!this._editor.hasModel()){this._currentChoice=void 0;return}const{activeChoice:e}=this._session;if(!e||!this._choiceCompletions){(t=this._choiceCompletions)==null||t.disable(),this._currentChoice=void 0;return}this._currentChoice!==e.choice&&(this._currentChoice=e.choice,this._choiceCompletions.enable(),queueMicrotask(()=>{B6(this._editor,this._choiceCompletions.provider)}))}finish(){for(;this._inSnippet.get();)this.next()}cancel(e=!1){var t;this._inSnippet.reset(),this._hasPrevTabstop.reset(),this._hasNextTabstop.reset(),this._snippetListener.clear(),this._currentChoice=void 0,(t=this._session)==null||t.dispose(),this._session=void 0,this._modelVersionId=-1,e&&this._editor.setSelections([this._editor.getSelection()])}prev(){var e;(e=this._session)==null||e.prev(),this._updateState()}next(){var e;(e=this._session)==null||e.next(),this._updateState()}isInSnippet(){return!!this._inSnippet.get()}},wh=Ra,Ra.ID="snippetController2",Ra.InSnippetMode=new _n("inSnippetMode",!1,C("inSnippetMode","Whether the editor in current in snippet mode")),Ra.HasNextTabstop=new _n("hasNextTabstop",!1,C("hasNextTabstop","Whether there is a next tab stop when in snippet mode")),Ra.HasPrevTabstop=new _n("hasPrevTabstop",!1,C("hasPrevTabstop","Whether there is a previous tab stop when in snippet mode")),Ra);lo=wh=U6([fm(1,Wu),fm(2,pi),fm(3,Sn),fm(4,Ds)],lo);nn(lo.ID,lo,4);const iw=wo.bindToContribution(lo.get);bi(new iw({id:"jumpToNextSnippetPlaceholder",precondition:Ae.and(lo.InSnippetMode,lo.HasNextTabstop),handler:o=>o.next(),kbOpts:{weight:130,kbExpr:B.textInputFocus,primary:2}}));bi(new iw({id:"jumpToPrevSnippetPlaceholder",precondition:Ae.and(lo.InSnippetMode,lo.HasPrevTabstop),handler:o=>o.prev(),kbOpts:{weight:130,kbExpr:B.textInputFocus,primary:1026}}));bi(new iw({id:"leaveSnippet",precondition:lo.InSnippetMode,handler:o=>o.cancel(!0),kbOpts:{weight:130,kbExpr:B.textInputFocus,primary:9,secondary:[1033]}}));bi(new iw({id:"acceptSnippet",precondition:lo.InSnippetMode,handler:o=>o.finish()}));var q6=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Xw=function(o,e){return function(t,i){e(t,i,o)}};let n1=class extends Dt{get isAcceptingPartially(){return this._isAcceptingPartially}constructor(e,t,i,n,s,r,a,d,u,f,g,p){super(),this.textModel=e,this.selectedSuggestItem=t,this._textModelVersionId=i,this._positions=n,this._debounceValue=s,this._suggestPreviewEnabled=r,this._suggestPreviewMode=a,this._inlineSuggestMode=d,this._enabled=u,this._instantiationService=f,this._commandService=g,this._languageConfigurationService=p,this._source=this._register(this._instantiationService.createInstance(i1,this.textModel,this._textModelVersionId,this._debounceValue)),this._isActive=Uo(this,!1),this._forceUpdateExplicitlySignal=f0(this),this._selectedInlineCompletionId=Uo(this,void 0),this._primaryPosition=En(this,y=>this._positions.read(y)[0]??new gi(1,1)),this._isAcceptingPartially=!1,this._preserveCurrentCompletionReasons=new Set([nl.Redo,nl.Undo,nl.AcceptWord]),this._fetchInlineCompletionsPromise=IT({owner:this,createEmptyChangeSummary:()=>({preserveCurrentCompletion:!1,inlineCompletionTriggerKind:ml.Automatic}),handleChange:(y,x)=>(y.didChange(this._textModelVersionId)&&this._preserveCurrentCompletionReasons.has(this._getReason(y.change))?x.preserveCurrentCompletion=!0:y.didChange(this._forceUpdateExplicitlySignal)&&(x.inlineCompletionTriggerKind=ml.Explicit),!0)},(y,x)=>{if(this._forceUpdateExplicitlySignal.read(y),!(this._enabled.read(y)&&this.selectedSuggestItem.read(y)||this._isActive.read(y))){this._source.cancelUpdate();return}this._textModelVersionId.read(y);const D=this._source.suggestWidgetInlineCompletions.get(),M=this.selectedSuggestItem.read(y);if(D&&!M){const te=this._source.inlineCompletions.get();Hu(pe=>{(!te||D.request.versionId>te.request.versionId)&&this._source.inlineCompletions.set(D.clone(),pe),this._source.clearSuggestWidgetInlineCompletions(pe)})}const F=this._primaryPosition.read(y),K={triggerKind:x.inlineCompletionTriggerKind,selectedSuggestionInfo:M==null?void 0:M.toSelectedSuggestionInfo()},V=this.selectedInlineCompletion.get(),se=x.preserveCurrentCompletion||V!=null&&V.forwardStable?V:void 0;return this._source.fetch(F,K,se)}),this._filteredInlineCompletionItems=cl({owner:this,equalsFn:DS()},y=>{const x=this._source.inlineCompletions.read(y);if(!x)return[];const k=this._primaryPosition.read(y);return x.inlineCompletions.filter(M=>M.isVisible(this.textModel,k,y))}),this.selectedInlineCompletionIndex=En(this,y=>{const x=this._selectedInlineCompletionId.read(y),k=this._filteredInlineCompletionItems.read(y),D=this._selectedInlineCompletionId===void 0?-1:k.findIndex(M=>M.semanticId===x);return D===-1?(this._selectedInlineCompletionId.set(void 0,void 0),0):D}),this.selectedInlineCompletion=En(this,y=>{const x=this._filteredInlineCompletionItems.read(y),k=this.selectedInlineCompletionIndex.read(y);return x[k]}),this.activeCommands=cl({owner:this,equalsFn:DS()},y=>{var x;return((x=this.selectedInlineCompletion.read(y))==null?void 0:x.inlineCompletion.source.inlineCompletions.commands)??[]}),this.lastTriggerKind=this._source.inlineCompletions.map(this,y=>y==null?void 0:y.request.context.triggerKind),this.inlineCompletionsCount=En(this,y=>{if(this.lastTriggerKind.read(y)===ml.Explicit)return this._filteredInlineCompletionItems.read(y).length}),this.state=cl({owner:this,equalsFn:(y,x)=>!y||!x?y===x:$I(y.ghostTexts,x.ghostTexts)&&y.inlineCompletion===x.inlineCompletion&&y.suggestItem===x.suggestItem},y=>{const x=this.textModel,k=this.selectedSuggestItem.read(y);if(k){const D=Ed(k.toSingleTextEdit(),x),M=this._computeAugmentation(D,y);if(!this._suggestPreviewEnabled.read(y)&&!M)return;const K=(M==null?void 0:M.edit)??D,V=M?M.edit.text.length-D.text.length:0,se=this._suggestPreviewMode.read(y),te=this._positions.read(y),pe=[K,...Qw(this.textModel,te,K)],je=pe.map((ue,He)=>ZI(ue,x,se,te[He],V)).filter(Pm),Ke=je[0]??new Np(K.range.endLineNumber,[]);return{edits:pe,primaryGhostText:Ke,ghostTexts:je,inlineCompletion:M==null?void 0:M.completion,suggestItem:k}}else{if(!this._isActive.read(y))return;const D=this.selectedInlineCompletion.read(y);if(!D)return;const M=D.toSingleTextEdit(y),F=this._inlineSuggestMode.read(y),K=this._positions.read(y),V=[M,...Qw(this.textModel,K,M)],se=V.map((te,pe)=>ZI(te,x,F,K[pe],0)).filter(Pm);return se[0]?{edits:V,primaryGhostText:se[0],ghostTexts:se,inlineCompletion:D,suggestItem:void 0}:void 0}}),this.ghostTexts=cl({owner:this,equalsFn:$I},y=>{const x=this.state.read(y);if(x)return x.ghostTexts}),this.primaryGhostText=cl({owner:this,equalsFn:GR},y=>{const x=this.state.read(y);if(x)return x==null?void 0:x.primaryGhostText}),this._register(ET(this._fetchInlineCompletionsPromise));let w;this._register(Kn(y=>{var D,M;const x=this.state.read(y),k=x==null?void 0:x.inlineCompletion;if((k==null?void 0:k.semanticId)!==(w==null?void 0:w.semanticId)&&(w=k,k)){const F=k.inlineCompletion,K=F.source;(M=(D=K.provider).handleItemDidShow)==null||M.call(D,K.inlineCompletions,F.sourceInlineCompletion,F.insertText)}}))}_getReason(e){return e!=null&&e.isUndoing?nl.Undo:e!=null&&e.isRedoing?nl.Redo:this.isAcceptingPartially?nl.AcceptWord:nl.Other}async trigger(e){this._isActive.set(!0,e),await this._fetchInlineCompletionsPromise.get()}async triggerExplicitly(e){av(e,t=>{this._isActive.set(!0,t),this._forceUpdateExplicitlySignal.trigger(t)}),await this._fetchInlineCompletionsPromise.get()}stop(e){av(e,t=>{this._isActive.set(!1,t),this._source.clear(t)})}_computeAugmentation(e,t){const i=this.textModel,n=this._source.suggestWidgetInlineCompletions.read(t),s=n?n.inlineCompletions:[this.selectedInlineCompletion.read(t)].filter(Pm);return RO(s,a=>{let d=a.toSingleTextEdit(t);return d=Ed(d,i,Z.fromPositions(d.range.getStartPosition(),e.range.getEndPosition())),XR(d,e)?{completion:a,edit:d}:void 0})}async _deltaSelectedInlineCompletionIndex(e){await this.triggerExplicitly();const t=this._filteredInlineCompletionItems.get()||[];if(t.length>0){const i=(this.selectedInlineCompletionIndex.get()+e+t.length)%t.length;this._selectedInlineCompletionId.set(t[i].semanticId,void 0)}else this._selectedInlineCompletionId.set(void 0,void 0)}async next(){await this._deltaSelectedInlineCompletionIndex(1)}async previous(){await this._deltaSelectedInlineCompletionIndex(-1)}async accept(e){var n;if(e.getModel()!==this.textModel)throw new bf;const t=this.state.get();if(!t||t.primaryGhostText.isEmpty()||!t.inlineCompletion)return;const i=t.inlineCompletion.toInlineCompletion(void 0);if(i.command&&i.source.addRef(),e.pushUndoStop(),i.snippetInfo)e.executeEdits("inlineSuggestion.accept",[Qn.replace(i.range,""),...i.additionalTextEdits]),e.setPosition(i.snippetInfo.range.getStartPosition(),"inlineCompletionAccept"),(n=lo.get(e))==null||n.insert(i.snippetInfo.snippet,{undoStopBefore:!1});else{const s=t.edits,r=cE(s).map(a=>Fi.fromPositions(a));e.executeEdits("inlineSuggestion.accept",[...s.map(a=>Qn.replace(a.range,a.text)),...i.additionalTextEdits]),e.setSelections(r,"inlineCompletionAccept")}this.stop(),i.command&&(await this._commandService.executeCommand(i.command.id,...i.command.arguments||[]).then(void 0,rs),i.source.removeRef())}async acceptNextWord(e){await this._acceptNext(e,(t,i)=>{const n=this.textModel.getLanguageIdAtPosition(t.lineNumber,t.column),s=this._languageConfigurationService.getLanguageConfiguration(n),r=new RegExp(s.wordDefinition.source,s.wordDefinition.flags.replace("g","")),a=i.match(r);let d=0;a&&a.index!==void 0?a.index===0?d=a[0].length:d=a.index:d=i.length;const f=/\s+/g.exec(i);return f&&f.index!==void 0&&f.index+f[0].length<d&&(d=f.index+f[0].length),d},0)}async acceptNextLine(e){await this._acceptNext(e,(t,i)=>{const n=i.match(/\n/);return n&&n.index!==void 0?n.index+1:i.length},1)}async _acceptNext(e,t,i){if(e.getModel()!==this.textModel)throw new bf;const n=this.state.get();if(!n||n.primaryGhostText.isEmpty()||!n.inlineCompletion)return;const s=n.primaryGhostText,r=n.inlineCompletion.toInlineCompletion(void 0);if(r.snippetInfo||r.filterText!==r.insertText){await this.accept(e);return}const a=s.parts[0],d=new gi(s.lineNumber,a.column),u=a.text,f=t(d,u);if(f===u.length&&s.parts.length===1){this.accept(e);return}const g=u.substring(0,f),p=this._positions.get(),w=p[0];r.source.addRef();try{this._isAcceptingPartially=!0;try{e.pushUndoStop();const y=Z.fromPositions(w,d),x=e.getModel().getValueInRange(y)+g,k=new xl(y,x),D=[k,...Qw(this.textModel,p,k)],M=cE(D).map(F=>Fi.fromPositions(F));e.executeEdits("inlineSuggestion.accept",D.map(F=>Qn.replace(F.range,F.text))),e.setSelections(M,"inlineCompletionPartialAccept"),e.revealPositionInCenterIfOutsideViewport(e.getPosition(),1)}finally{this._isAcceptingPartially=!1}if(r.source.provider.handlePartialAccept){const y=Z.fromPositions(r.range.getStartPosition(),rv.ofText(g).addToPosition(d)),x=e.getModel().getValueInRange(y,1);r.source.provider.handlePartialAccept(r.source.inlineCompletions,r.sourceInlineCompletion,x.length,{kind:i})}}finally{r.source.removeRef()}}handleSuggestAccepted(e){var s,r;const t=Ed(e.toSingleTextEdit(),this.textModel),i=this._computeAugmentation(t,void 0);if(!i)return;const n=i.completion.inlineCompletion;(r=(s=n.source.provider).handlePartialAccept)==null||r.call(s,n.source.inlineCompletions,n.sourceInlineCompletion,t.text.length,{kind:2})}};n1=q6([Xw(9,Zi),Xw(10,Es),Xw(11,Ds)],n1);var nl;(function(o){o[o.Undo=0]="Undo",o[o.Redo=1]="Redo",o[o.AcceptWord=2]="AcceptWord",o[o.Other=3]="Other"})(nl||(nl={}));function Qw(o,e,t){if(e.length===1)return[];const i=e[0],n=e.slice(1),s=t.range.getStartPosition(),r=t.range.getEndPosition(),a=o.getValueInRange(Z.fromPositions(i,r)),d=UI(i,s);if(d.lineNumber<1)return Nn(new bf(`positionWithinTextEdit line number should be bigger than 0.
36
- Invalid subtraction between ${i.toString()} and ${s.toString()}`)),[];const u=G6(t.text,d);return n.map(f=>{const g=v6(UI(f,s),r),p=o.getValueInRange(Z.fromPositions(f,g)),w=v_(a,p),y=Z.fromPositions(f,f.delta(0,w));return new xl(y,u)})}function G6(o,e){let t="";const i=AO(o);for(let n=e.lineNumber-1;n<i.length;n++)t+=i[n].substring(n===e.lineNumber-1?e.column-1:0);return t}function cE(o){const e=NO.createSortPermutation(o,__(s=>s.range,Z.compareRangesUsingStarts)),i=new bT(e.apply(o)).getNewRanges();return e.inverse().apply(i).map(s=>s.getEndPosition())}var K6=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},dE=function(o,e){return function(t,i){e(t,i,o)}},Tg;class gk{constructor(e){this.name=e}select(e,t,i){if(i.length===0)return 0;const n=i[0].score[0];for(let s=0;s<i.length;s++){const{score:r,completion:a}=i[s];if(r[0]!==n)break;if(a.preselect)return s}return 0}}class uE extends gk{constructor(){super("first")}memorize(e,t,i){}toJSON(){}fromJSON(){}}class Z6 extends gk{constructor(){super("recentlyUsed"),this._cache=new u_(300,.66),this._seq=0}memorize(e,t,i){const n=`${e.getLanguageId()}/${i.textLabel}`;this._cache.set(n,{touch:this._seq++,type:i.completion.kind,insertText:i.completion.insertText})}select(e,t,i){if(i.length===0)return 0;const n=e.getLineContent(t.lineNumber).substr(t.column-10,t.column-1);if(/\s$/.test(n))return super.select(e,t,i);const s=i[0].score[0];let r=-1,a=-1,d=-1;for(let u=0;u<i.length&&i[u].score[0]===s;u++){const f=`${e.getLanguageId()}/${i[u].textLabel}`,g=this._cache.peek(f);if(g&&g.touch>d&&g.type===i[u].completion.kind&&g.insertText===i[u].completion.insertText&&(d=g.touch,a=u),i[u].completion.preselect&&r===-1)return r=u}return a!==-1?a:r!==-1?r:0}toJSON(){return this._cache.toJSON()}fromJSON(e){this._cache.clear();const t=0;for(const[i,n]of e)n.touch=t,n.type=typeof n.type=="number"?n.type:g0.fromString(n.type),this._cache.set(i,n);this._seq=this._cache.size}}class Y6 extends gk{constructor(){super("recentlyUsedByPrefix"),this._trie=OO.forStrings(),this._seq=0}memorize(e,t,i){const{word:n}=e.getWordUntilPosition(t),s=`${e.getLanguageId()}/${n}`;this._trie.set(s,{type:i.completion.kind,insertText:i.completion.insertText,touch:this._seq++})}select(e,t,i){const{word:n}=e.getWordUntilPosition(t);if(!n)return super.select(e,t,i);const s=`${e.getLanguageId()}/${n}`;let r=this._trie.get(s);if(r||(r=this._trie.findSubstr(s)),r)for(let a=0;a<i.length;a++){const{kind:d,insertText:u}=i[a].completion;if(d===r.type&&u===r.insertText)return a}return super.select(e,t,i)}toJSON(){const e=[];return this._trie.forEach((t,i)=>e.push([i,t])),e.sort((t,i)=>-(t[1].touch-i[1].touch)).forEach((t,i)=>t[1].touch=i),e.slice(0,200)}fromJSON(e){if(this._trie.clear(),e.length>0){this._seq=e[0][1].touch+1;for(const[t,i]of e)i.type=typeof i.type=="number"?i.type:g0.fromString(i.type),this._trie.set(t,i)}}}var Cc;let s1=(Cc=class{constructor(e,t){this._storageService=e,this._configService=t,this._disposables=new Lt,this._persistSoon=new Ss(()=>this._saveState(),500),this._disposables.add(e.onWillSaveState(i=>{i.reason===s0.SHUTDOWN&&this._saveState()}))}dispose(){this._disposables.dispose(),this._persistSoon.dispose()}memorize(e,t,i){this._withStrategy(e,t).memorize(e,t,i),this._persistSoon.schedule()}select(e,t,i){return this._withStrategy(e,t).select(e,t,i)}_withStrategy(e,t){var n;const i=this._configService.getValue("editor.suggestSelection",{overrideIdentifier:e.getLanguageIdAtPosition(t.lineNumber,t.column),resource:e.uri});if(((n=this._strategy)==null?void 0:n.name)!==i){this._saveState();const s=Tg._strategyCtors.get(i)||uE;this._strategy=new s;try{const a=this._configService.getValue("editor.suggest.shareSuggestSelections")?0:1,d=this._storageService.get(`${Tg._storagePrefix}/${i}`,a);d&&this._strategy.fromJSON(JSON.parse(d))}catch{}}return this._strategy}_saveState(){if(this._strategy){const t=this._configService.getValue("editor.suggest.shareSuggestSelections")?0:1,i=JSON.stringify(this._strategy);this._storageService.store(`${Tg._storagePrefix}/${this._strategy.name}`,i,t,1)}}},Tg=Cc,Cc._strategyCtors=new Map([["recentlyUsedByPrefix",Y6],["recentlyUsed",Z6],["first",uE]]),Cc._storagePrefix="suggest/memories",Cc);s1=Tg=K6([dE(0,zc),dE(1,Un)],s1);const nw=Rl("ISuggestMemories");Nl(nw,s1,1);var X6=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Q6=function(o,e){return function(t,i){e(t,i,o)}},o1,Zd;let qv=(Zd=class{constructor(e,t){this._editor=e,this._enabled=!1,this._ckAtEnd=o1.AtEnd.bindTo(t),this._configListener=this._editor.onDidChangeConfiguration(i=>i.hasChanged(124)&&this._update()),this._update()}dispose(){var e;this._configListener.dispose(),(e=this._selectionListener)==null||e.dispose(),this._ckAtEnd.reset()}_update(){const e=this._editor.getOption(124)==="on";if(this._enabled!==e)if(this._enabled=e,this._enabled){const t=()=>{if(!this._editor.hasModel()){this._ckAtEnd.set(!1);return}const i=this._editor.getModel(),n=this._editor.getSelection(),s=i.getWordAtPosition(n.getStartPosition());if(!s){this._ckAtEnd.set(!1);return}this._ckAtEnd.set(s.endColumn===n.getStartPosition().column)};this._selectionListener=this._editor.onDidChangeCursorSelection(t),t()}else this._selectionListener&&(this._ckAtEnd.reset(),this._selectionListener.dispose(),this._selectionListener=void 0)}},o1=Zd,Zd.AtEnd=new _n("atEndOfWord",!1),Zd);qv=o1=X6([Q6(1,Sn)],qv);var J6=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ej=function(o,e){return function(t,i){e(t,i,o)}},Pg,Yd;let Af=(Yd=class{constructor(e,t){this._editor=e,this._index=0,this._ckOtherSuggestions=Pg.OtherSuggestions.bindTo(t)}dispose(){this.reset()}reset(){var e;this._ckOtherSuggestions.reset(),(e=this._listener)==null||e.dispose(),this._model=void 0,this._acceptNext=void 0,this._ignore=!1}set({model:e,index:t},i){if(e.items.length===0){this.reset();return}if(Pg._moveIndex(!0,e,t)===t){this.reset();return}this._acceptNext=i,this._model=e,this._index=t,this._listener=this._editor.onDidChangeCursorPosition(()=>{this._ignore||this.reset()}),this._ckOtherSuggestions.set(!0)}static _moveIndex(e,t,i){let n=i;for(let s=t.items.length;s>0&&(n=(n+t.items.length+(e?1:-1))%t.items.length,!(n===i||!t.items[n].completion.additionalTextEdits));s--);return n}next(){this._move(!0)}prev(){this._move(!1)}_move(e){if(this._model)try{this._ignore=!0,this._index=Pg._moveIndex(e,this._model,this._index),this._acceptNext({index:this._index,item:this._model.items[this._index],model:this._model})}finally{this._ignore=!1}}},Pg=Yd,Yd.OtherSuggestions=new _n("hasOtherSuggestions",!1),Yd);Af=Pg=J6([ej(1,Sn)],Af);class tj{constructor(e,t,i,n){this._disposables=new Lt,this._disposables.add(i.onDidSuggest(s=>{s.completionModel.items.length===0&&this.reset()})),this._disposables.add(i.onDidCancel(s=>{this.reset()})),this._disposables.add(t.onDidShow(()=>this._onItem(t.getFocusedItem()))),this._disposables.add(t.onDidFocus(this._onItem,this)),this._disposables.add(t.onDidHide(this.reset,this)),this._disposables.add(e.onWillType(s=>{if(this._active&&!t.isFrozen()&&i.state!==0){const r=s.charCodeAt(s.length-1);this._active.acceptCharacters.has(r)&&e.getOption(0)&&n(this._active.item)}}))}_onItem(e){if(!e||!$o(e.item.completion.commitCharacters)){this.reset();return}if(this._active&&this._active.item.item===e.item)return;const t=new ov;for(const i of e.item.completion.commitCharacters)i.length>0&&t.add(i.charCodeAt(0));this._active={acceptCharacters:t,item:e}}reset(){this._active=void 0}dispose(){this._disposables.dispose()}}const ir=class ir{async provideSelectionRanges(e,t){const i=[];for(const n of t){const s=[];i.push(s);const r=new Map;await new Promise(a=>ir._bracketsRightYield(a,0,e,n,r)),await new Promise(a=>ir._bracketsLeftYield(a,0,e,n,r,s))}return i}static _bracketsRightYield(e,t,i,n,s){const r=new Map,a=Date.now();for(;;){if(t>=ir._maxRounds){e();break}if(!n){e();break}const d=i.bracketPairs.findNextBracket(n);if(!d){e();break}if(Date.now()-a>ir._maxDuration){setTimeout(()=>ir._bracketsRightYield(e,t+1,i,n,s));break}if(d.bracketInfo.isOpeningBracket){const f=d.bracketInfo.bracketText,g=r.has(f)?r.get(f):0;r.set(f,g+1)}else{const f=d.bracketInfo.getOpeningBrackets()[0].bracketText;let g=r.has(f)?r.get(f):0;if(g-=1,r.set(f,Math.max(0,g)),g<0){let p=s.get(f);p||(p=new DT,s.set(f,p)),p.push(d.range)}}n=d.range.getEndPosition()}}static _bracketsLeftYield(e,t,i,n,s,r){const a=new Map,d=Date.now();for(;;){if(t>=ir._maxRounds&&s.size===0){e();break}if(!n){e();break}const u=i.bracketPairs.findPrevBracket(n);if(!u){e();break}if(Date.now()-d>ir._maxDuration){setTimeout(()=>ir._bracketsLeftYield(e,t+1,i,n,s,r));break}if(u.bracketInfo.isOpeningBracket){const g=u.bracketInfo.bracketText;let p=a.has(g)?a.get(g):0;if(p-=1,a.set(g,Math.max(0,p)),p<0){const w=s.get(g);if(w){const y=w.shift();w.size===0&&s.delete(g);const x=Z.fromPositions(u.range.getEndPosition(),y.getStartPosition()),k=Z.fromPositions(u.range.getStartPosition(),y.getEndPosition());r.push({range:x}),r.push({range:k}),ir._addBracketLeading(i,k,r)}}}else{const g=u.bracketInfo.getOpeningBrackets()[0].bracketText,p=a.has(g)?a.get(g):0;a.set(g,p+1)}n=u.range.getStartPosition()}}static _addBracketLeading(e,t,i){if(t.startLineNumber===t.endLineNumber)return;const n=t.startLineNumber,s=e.getLineFirstNonWhitespaceColumn(n);s!==0&&s!==t.startColumn&&(i.push({range:Z.fromPositions(new gi(n,s),t.getEndPosition())}),i.push({range:Z.fromPositions(new gi(n,1),t.getEndPosition())}));const r=n-1;if(r>0){const a=e.getLineFirstNonWhitespaceColumn(r);a===t.startColumn&&a!==e.getLineLastNonWhitespaceColumn(r)&&(i.push({range:Z.fromPositions(new gi(r,a),t.getEndPosition())}),i.push({range:Z.fromPositions(new gi(r,1),t.getEndPosition())}))}}};ir._maxDuration=30,ir._maxRounds=2;let Gv=ir;const La=class La{static async create(e,t){if(!t.getOption(119).localityBonus||!t.hasModel())return La.None;const i=t.getModel(),n=t.getPosition();if(!e.canComputeWordRanges(i.uri))return La.None;const[s]=await new Gv().provideSelectionRanges(i,[n]);if(s.length===0)return La.None;const r=await e.computeWordRanges(i.uri,s[0].range);if(!r)return La.None;const a=i.getWordUntilPosition(n);return delete r[a.word],new class extends La{distance(d,u){if(!n.equals(t.getPosition()))return 0;if(u.kind===17)return 2<<20;const f=typeof u.label=="string"?u.label:u.label.label,g=r[f];if(FO(g))return 2<<20;const p=lv(g,Z.fromPositions(d),Z.compareRangesUsingStarts),w=p>=0?g[p]:g[Math.max(0,~p-1)];let y=s.length;for(const x of s){if(!Z.containsRange(x.range,w))break;y-=1}return y}}}};La.None=new class extends La{distance(){return 0}};let Kv=La,hE=class{constructor(e,t){this.leadingLineContent=e,this.characterCountDelta=t}};class Jl{constructor(e,t,i,n,s,r,a=TT.default,d=void 0){this.clipboardText=d,this._snippetCompareFn=Jl._compareCompletionItems,this._items=e,this._column=t,this._wordDistance=n,this._options=s,this._refilterKind=1,this._lineContext=i,this._fuzzyScoreOptions=a,r==="top"?this._snippetCompareFn=Jl._compareCompletionItemsSnippetsUp:r==="bottom"&&(this._snippetCompareFn=Jl._compareCompletionItemsSnippetsDown)}get lineContext(){return this._lineContext}set lineContext(e){(this._lineContext.leadingLineContent!==e.leadingLineContent||this._lineContext.characterCountDelta!==e.characterCountDelta)&&(this._refilterKind=this._lineContext.characterCountDelta<e.characterCountDelta&&this._filteredItems?2:1,this._lineContext=e)}get items(){return this._ensureCachedState(),this._filteredItems}getItemsByProvider(){return this._ensureCachedState(),this._itemsByProvider}getIncompleteProvider(){this._ensureCachedState();const e=new Set;for(const[t,i]of this.getItemsByProvider())i.length>0&&i[0].container.incomplete&&e.add(t);return e}get stats(){return this._ensureCachedState(),this._stats}_ensureCachedState(){this._refilterKind!==0&&this._createCachedState()}_createCachedState(){this._itemsByProvider=new Map;const e=[],{leadingLineContent:t,characterCountDelta:i}=this._lineContext;let n="",s="";const r=this._refilterKind===1?this._items:this._filteredItems,a=[],d=!this._options.filterGraceful||r.length>2e3?PT:HO;for(let u=0;u<r.length;u++){const f=r[u];if(f.isInvalid)continue;const g=this._itemsByProvider.get(f.provider);g?g.push(f):this._itemsByProvider.set(f.provider,[f]);const p=f.position.column-f.editStart.column,w=p+i-(f.position.column-this._column);if(n.length!==w&&(n=w===0?"":t.slice(-w),s=n.toLowerCase()),f.word=n,w===0)f.score=mp.Default;else{let y=0;for(;y<p;){const x=n.charCodeAt(y);if(x===32||x===9)y+=1;else break}if(y>=w)f.score=mp.Default;else if(typeof f.completion.filterText=="string"){const x=d(n,s,y,f.completion.filterText,f.filterTextLow,0,this._fuzzyScoreOptions);if(!x)continue;WO(f.completion.filterText,f.textLabel)===0?f.score=x:(f.score=BO(n,s,y,f.textLabel,f.labelLow,0),f.score[0]=x[0])}else{const x=d(n,s,y,f.textLabel,f.labelLow,0,this._fuzzyScoreOptions);if(!x)continue;f.score=x}}f.idx=u,f.distance=this._wordDistance.distance(f.position,f.completion),a.push(f),e.push(f.textLabel.length)}this._filteredItems=a.sort(this._snippetCompareFn),this._refilterKind=0,this._stats={pLabelLen:e.length?zO(e.length-.85,e,(u,f)=>u-f):0}}static _compareCompletionItems(e,t){return e.score[0]>t.score[0]?-1:e.score[0]<t.score[0]?1:e.distance<t.distance?-1:e.distance>t.distance?1:e.idx<t.idx?-1:e.idx>t.idx?1:0}static _compareCompletionItemsSnippetsDown(e,t){if(e.completion.kind!==t.completion.kind){if(e.completion.kind===27)return 1;if(t.completion.kind===27)return-1}return Jl._compareCompletionItems(e,t)}static _compareCompletionItemsSnippetsUp(e,t){if(e.completion.kind!==t.completion.kind){if(e.completion.kind===27)return-1;if(t.completion.kind===27)return 1}return Jl._compareCompletionItems(e,t)}}var ij=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ul=function(o,e){return function(t,i){e(t,i,o)}},r1;class Jc{static shouldAutoTrigger(e){if(!e.hasModel())return!1;const t=e.getModel(),i=e.getPosition();t.tokenization.tokenizeIfCheap(i.lineNumber);const n=t.getWordAtPosition(i);return!(!n||n.endColumn!==i.column&&n.startColumn+1!==i.column||!isNaN(Number(n.word)))}constructor(e,t,i){this.leadingLineContent=e.getLineContent(t.lineNumber).substr(0,t.column-1),this.leadingWord=e.getWordUntilPosition(t),this.lineNumber=t.lineNumber,this.column=t.column,this.triggerOptions=i}}function nj(o,e,t){if(!e.getContextKeyValue(Po.inlineSuggestionVisible.key))return!0;const i=e.getContextKeyValue(Po.suppressSuggestions.key);return i!==void 0?!i:!o.getOption(62).suppressSuggestions}function sj(o,e,t){if(!e.getContextKeyValue("inlineSuggestionVisible"))return!0;const i=e.getContextKeyValue(Po.suppressSuggestions.key);return i!==void 0?!i:!o.getOption(62).suppressSuggestions}let Zv=r1=class{constructor(e,t,i,n,s,r,a,d,u){this._editor=e,this._editorWorkerService=t,this._clipboardService=i,this._telemetryService=n,this._logService=s,this._contextKeyService=r,this._configurationService=a,this._languageFeaturesService=d,this._envService=u,this._toDispose=new Lt,this._triggerCharacterListener=new Lt,this._triggerQuickSuggest=new l_,this._triggerState=void 0,this._completionDisposables=new Lt,this._onDidCancel=new Xi,this._onDidTrigger=new Xi,this._onDidSuggest=new Xi,this.onDidCancel=this._onDidCancel.event,this.onDidTrigger=this._onDidTrigger.event,this.onDidSuggest=this._onDidSuggest.event,this._telemetryGate=0,this._currentSelection=this._editor.getSelection()||new Fi(1,1,1,1),this._toDispose.add(this._editor.onDidChangeModel(()=>{this._updateTriggerCharacters(),this.cancel()})),this._toDispose.add(this._editor.onDidChangeModelLanguage(()=>{this._updateTriggerCharacters(),this.cancel()})),this._toDispose.add(this._editor.onDidChangeConfiguration(()=>{this._updateTriggerCharacters()})),this._toDispose.add(this._languageFeaturesService.completionProvider.onDidChange(()=>{this._updateTriggerCharacters(),this._updateActiveSuggestSession()}));let f=!1;this._toDispose.add(this._editor.onDidCompositionStart(()=>{f=!0})),this._toDispose.add(this._editor.onDidCompositionEnd(()=>{f=!1,this._onCompositionEnd()})),this._toDispose.add(this._editor.onDidChangeCursorSelection(g=>{f||this._onCursorChange(g)})),this._toDispose.add(this._editor.onDidChangeModelContent(()=>{!f&&this._triggerState!==void 0&&this._refilterCompletionItems()})),this._updateTriggerCharacters()}dispose(){no(this._triggerCharacterListener),no([this._onDidCancel,this._onDidSuggest,this._onDidTrigger,this._triggerQuickSuggest]),this._toDispose.dispose(),this._completionDisposables.dispose(),this.cancel()}_updateTriggerCharacters(){if(this._triggerCharacterListener.clear(),this._editor.getOption(92)||!this._editor.hasModel()||!this._editor.getOption(122))return;const e=new Map;for(const i of this._languageFeaturesService.completionProvider.all(this._editor.getModel()))for(const n of i.triggerCharacters||[]){let s=e.get(n);s||(s=new Set,e.set(n,s)),s.add(i)}const t=i=>{var r;if(!sj(this._editor,this._contextKeyService,this._configurationService)||Jc.shouldAutoTrigger(this._editor))return;if(!i){const a=this._editor.getPosition();i=this._editor.getModel().getLineContent(a.lineNumber).substr(0,a.column-1)}let n="";jO(i.charCodeAt(i.length-1))?$O(i.charCodeAt(i.length-2))&&(n=i.substr(i.length-2)):n=i.charAt(i.length-1);const s=e.get(n);if(s){const a=new Map;if(this._completionModel)for(const[d,u]of this._completionModel.getItemsByProvider())s.has(d)||a.set(d,u);this.trigger({auto:!0,triggerKind:1,triggerCharacter:n,retrigger:!!this._completionModel,clipboardText:(r=this._completionModel)==null?void 0:r.clipboardText,completionOptions:{providerFilter:s,providerItemsToReuse:a}})}};this._triggerCharacterListener.add(this._editor.onDidType(t)),this._triggerCharacterListener.add(this._editor.onDidCompositionEnd(()=>t()))}get state(){return this._triggerState?this._triggerState.auto?2:1:0}cancel(e=!1){var t;this._triggerState!==void 0&&(this._triggerQuickSuggest.cancel(),(t=this._requestToken)==null||t.cancel(),this._requestToken=void 0,this._triggerState=void 0,this._completionModel=void 0,this._context=void 0,this._onDidCancel.fire({retrigger:e}))}clear(){this._completionDisposables.clear()}_updateActiveSuggestSession(){this._triggerState!==void 0&&(!this._editor.hasModel()||!this._languageFeaturesService.completionProvider.has(this._editor.getModel())?this.cancel():this.trigger({auto:this._triggerState.auto,retrigger:!0}))}_onCursorChange(e){if(!this._editor.hasModel())return;const t=this._currentSelection;if(this._currentSelection=this._editor.getSelection(),!e.selection.isEmpty()||e.reason!==0&&e.reason!==3||e.source!=="keyboard"&&e.source!=="deleteLeft"){this.cancel();return}this._triggerState===void 0&&e.reason===0?(t.containsRange(this._currentSelection)||t.getEndPosition().isBeforeOrEqual(this._currentSelection.getPosition()))&&this._doTriggerQuickSuggest():this._triggerState!==void 0&&e.reason===3&&this._refilterCompletionItems()}_onCompositionEnd(){this._triggerState===void 0?this._doTriggerQuickSuggest():this._refilterCompletionItems()}_doTriggerQuickSuggest(){var e;Mh.isAllOff(this._editor.getOption(90))||this._editor.getOption(119).snippetsPreventQuickSuggestions&&((e=lo.get(this._editor))!=null&&e.isInSnippet())||(this.cancel(),this._triggerQuickSuggest.cancelAndSet(()=>{if(this._triggerState!==void 0||!Jc.shouldAutoTrigger(this._editor)||!this._editor.hasModel()||!this._editor.hasWidgetFocus())return;const t=this._editor.getModel(),i=this._editor.getPosition(),n=this._editor.getOption(90);if(!Mh.isAllOff(n)){if(!Mh.isAllOn(n)){t.tokenization.tokenizeIfCheap(i.lineNumber);const s=t.tokenization.getLineTokens(i.lineNumber),r=s.getStandardTokenType(s.findTokenIndexAtOffset(Math.max(i.column-1-1,0)));if(Mh.valueFor(n,r)!=="on")return}nj(this._editor,this._contextKeyService,this._configurationService)&&this._languageFeaturesService.completionProvider.has(t)&&this.trigger({auto:!0})}},this._editor.getOption(91)))}_refilterCompletionItems(){Cn(this._editor.hasModel()),Cn(this._triggerState!==void 0);const e=this._editor.getModel(),t=this._editor.getPosition(),i=new Jc(e,t,{...this._triggerState,refilter:!0});this._onNewContext(i)}trigger(e){var p,w,y;if(!this._editor.hasModel())return;const t=this._editor.getModel(),i=new Jc(t,this._editor.getPosition(),e);this.cancel(e.retrigger),this._triggerState=e,this._onDidTrigger.fire({auto:e.auto,shy:e.shy??!1,position:this._editor.getPosition()}),this._context=i;let n={triggerKind:e.triggerKind??0};e.triggerCharacter&&(n={triggerKind:1,triggerCharacter:e.triggerCharacter}),this._requestToken=new Fs;const s=this._editor.getOption(113);let r=1;switch(s){case"top":r=0;break;case"bottom":r=2;break}const{itemKind:a,showDeprecated:d}=r1.createSuggestFilter(this._editor),u=new Ap(r,((p=e.completionOptions)==null?void 0:p.kindFilter)??a,(w=e.completionOptions)==null?void 0:w.providerFilter,(y=e.completionOptions)==null?void 0:y.providerItemsToReuse,d),f=Kv.create(this._editorWorkerService,this._editor),g=hk(this._languageFeaturesService.completionProvider,t,this._editor.getPosition(),u,n,this._requestToken.token);Promise.all([g,f]).then(async([x,k])=>{var V;if((V=this._requestToken)==null||V.dispose(),!this._editor.hasModel())return;let D=e==null?void 0:e.clipboardText;if(!D&&x.needsClipboard&&(D=await this._clipboardService.readText()),this._triggerState===void 0)return;const M=this._editor.getModel(),F=new Jc(M,this._editor.getPosition(),e),K={...TT.default,firstMatchCanBeWeak:!this._editor.getOption(119).matchOnWordStartOnly};if(this._completionModel=new Jl(x.items,this._context.column,{leadingLineContent:F.leadingLineContent,characterCountDelta:F.column-this._context.column},k,this._editor.getOption(119),this._editor.getOption(113),K,D),this._completionDisposables.add(x.disposable),this._onNewContext(F),this._reportDurationsTelemetry(x.durations),!this._envService.isBuilt||this._envService.isExtensionDevelopment)for(const se of x.items)se.isInvalid&&this._logService.warn(`[suggest] did IGNORE invalid completion item from ${se.provider._debugDisplayName}`,se.completion)}).catch(Nn)}_reportDurationsTelemetry(e){this._telemetryGate++%230===0&&setTimeout(()=>{this._telemetryService.publicLog2("suggest.durations.json",{data:JSON.stringify(e)}),this._logService.debug("suggest.durations.json",e)})}static createSuggestFilter(e){const t=new Set;e.getOption(113)==="none"&&t.add(27);const n=e.getOption(119);return n.showMethods||t.add(0),n.showFunctions||t.add(1),n.showConstructors||t.add(2),n.showFields||t.add(3),n.showVariables||t.add(4),n.showClasses||t.add(5),n.showStructs||t.add(6),n.showInterfaces||t.add(7),n.showModules||t.add(8),n.showProperties||t.add(9),n.showEvents||t.add(10),n.showOperators||t.add(11),n.showUnits||t.add(12),n.showValues||t.add(13),n.showConstants||t.add(14),n.showEnums||t.add(15),n.showEnumMembers||t.add(16),n.showKeywords||t.add(17),n.showWords||t.add(18),n.showColors||t.add(19),n.showFiles||t.add(20),n.showReferences||t.add(21),n.showColors||t.add(22),n.showFolders||t.add(23),n.showTypeParameters||t.add(24),n.showSnippets||t.add(27),n.showUsers||t.add(25),n.showIssues||t.add(26),{itemKind:t,showDeprecated:n.showDeprecated}}_onNewContext(e){if(this._context){if(e.lineNumber!==this._context.lineNumber){this.cancel();return}if(Ks(e.leadingLineContent)!==Ks(this._context.leadingLineContent)){this.cancel();return}if(e.column<this._context.column){e.leadingWord.word?this.trigger({auto:this._context.triggerOptions.auto,retrigger:!0}):this.cancel();return}if(this._completionModel){if(e.leadingWord.word.length!==0&&e.leadingWord.startColumn>this._context.leadingWord.startColumn){if(Jc.shouldAutoTrigger(this._editor)&&this._context){const i=this._completionModel.getItemsByProvider();this.trigger({auto:this._context.triggerOptions.auto,retrigger:!0,clipboardText:this._completionModel.clipboardText,completionOptions:{providerItemsToReuse:i}})}return}if(e.column>this._context.column&&this._completionModel.getIncompleteProvider().size>0&&e.leadingWord.word.length!==0){const t=new Map,i=new Set;for(const[n,s]of this._completionModel.getItemsByProvider())s.length>0&&s[0].container.incomplete?i.add(n):t.set(n,s);this.trigger({auto:this._context.triggerOptions.auto,triggerKind:2,retrigger:!0,clipboardText:this._completionModel.clipboardText,completionOptions:{providerFilter:i,providerItemsToReuse:t}})}else{const t=this._completionModel.lineContext;let i=!1;if(this._completionModel.lineContext={leadingLineContent:e.leadingLineContent,characterCountDelta:e.column-this._context.column},this._completionModel.items.length===0){const n=Jc.shouldAutoTrigger(this._editor);if(!this._context){this.cancel();return}if(n&&this._context.leadingWord.endColumn<e.leadingWord.startColumn){this.trigger({auto:this._context.triggerOptions.auto,retrigger:!0});return}if(this._context.triggerOptions.auto){this.cancel();return}else if(this._completionModel.lineContext=t,i=this._completionModel.items.length>0,i&&e.leadingWord.word.length===0){this.cancel();return}}this._onDidSuggest.fire({completionModel:this._completionModel,triggerOptions:e.triggerOptions,isFrozen:i})}}}}};Zv=r1=ij([Ul(1,Al),Ul(2,Vf),Ul(3,ha),Ul(4,Wu),Ul(5,Sn),Ul(6,Un),Ul(7,pi),Ul(8,VO)],Zv);const Bb=class Bb{constructor(e,t){this._disposables=new Lt,this._lastOvertyped=[],this._locked=!1,this._disposables.add(e.onWillType(()=>{if(this._locked||!e.hasModel())return;const i=e.getSelections(),n=i.length;let s=!1;for(let a=0;a<n;a++)if(!i[a].isEmpty()){s=!0;break}if(!s){this._lastOvertyped.length!==0&&(this._lastOvertyped.length=0);return}this._lastOvertyped=[];const r=e.getModel();for(let a=0;a<n;a++){const d=i[a];if(r.getValueLengthInRange(d)>Bb._maxSelectionLength)return;this._lastOvertyped[a]={value:r.getValueInRange(d),multiline:d.startLineNumber!==d.endLineNumber}}})),this._disposables.add(t.onDidTrigger(i=>{this._locked=!0})),this._disposables.add(t.onDidCancel(i=>{this._locked=!1}))}getLastOvertypedInfo(e){if(e>=0&&e<this._lastOvertyped.length)return this._lastOvertyped[e]}dispose(){this._disposables.dispose()}};Bb._maxSelectionLength=51200;let a1=Bb;var oj=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Jw=function(o,e){return function(t,i){e(t,i,o)}};let l1=class{constructor(e,t,i,n,s){this._menuId=t,this._menuService=n,this._contextKeyService=s,this._menuDisposables=new Lt,this.element=ei(e,si(".suggest-status-bar"));const r=(a=>a instanceof vf?i.createInstance(UO,a,{useComma:!0}):void 0);this._leftActions=new up(this.element,{actionViewItemProvider:r}),this._rightActions=new up(this.element,{actionViewItemProvider:r}),this._leftActions.domNode.classList.add("left"),this._rightActions.domNode.classList.add("right")}dispose(){this._menuDisposables.dispose(),this._leftActions.dispose(),this._rightActions.dispose(),this.element.remove()}show(){const e=this._menuService.createMenu(this._menuId,this._contextKeyService),t=()=>{const i=[],n=[];for(const[s,r]of e.getActions())s==="left"?i.push(...r):n.push(...r);this._leftActions.clear(),this._leftActions.push(i),this._rightActions.clear(),this._rightActions.push(n)};this._menuDisposables.add(e.onDidChange(()=>t())),this._menuDisposables.add(e)}hide(){this._menuDisposables.clear()}};l1=oj([Jw(2,Zi),Jw(3,Fu),Jw(4,Sn)],l1);var rj=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},aj=function(o,e){return function(t,i){e(t,i,o)}};function pk(o){return!!o&&!!(o.completion.documentation||o.completion.detail&&o.completion.detail!==o.completion.label)}let c1=class{constructor(e,t){this._editor=e,this._onDidClose=new Xi,this.onDidClose=this._onDidClose.event,this._onDidChangeContents=new Xi,this.onDidChangeContents=this._onDidChangeContents.event,this._disposables=new Lt,this._renderDisposeable=new Lt,this._borderWidth=1,this._size=new On(330,0),this.domNode=si(".suggest-details"),this.domNode.classList.add("no-docs"),this._markdownRenderer=t.createInstance(Uf,{editor:e}),this._body=si(".body"),this._scrollbar=new MT(this._body,{alwaysConsumeMouseWheel:!0}),ei(this.domNode,this._scrollbar.getDomNode()),this._disposables.add(this._scrollbar),this._header=ei(this._body,si(".header")),this._close=ei(this._header,si("span"+xn.asCSSSelector(ji.close))),this._close.title=C("details.close","Close"),this._type=ei(this._header,si("p.type")),this._docs=ei(this._body,si("p.docs")),this._configureFont(),this._disposables.add(this._editor.onDidChangeConfiguration(i=>{i.hasChanged(50)&&this._configureFont()}))}dispose(){this._disposables.dispose(),this._renderDisposeable.dispose()}_configureFont(){const e=this._editor.getOptions(),t=e.get(50),i=t.getMassagedFontFamily(),n=e.get(120)||t.fontSize,s=e.get(121)||t.lineHeight,r=t.fontWeight,a=`${n}px`,d=`${s}px`;this.domNode.style.fontSize=a,this.domNode.style.lineHeight=`${s/n}`,this.domNode.style.fontWeight=r,this.domNode.style.fontFeatureSettings=t.fontFeatureSettings,this._type.style.fontFamily=i,this._close.style.height=d,this._close.style.width=d}getLayoutInfo(){const e=this._editor.getOption(121)||this._editor.getOption(50).lineHeight,t=this._borderWidth,i=t*2;return{lineHeight:e,borderWidth:t,borderHeight:i,verticalPadding:22,horizontalPadding:14}}renderLoading(){this._type.textContent=C("loading","Loading..."),this._docs.textContent="",this.domNode.classList.remove("no-docs","no-type"),this.layout(this.size.width,this.getLayoutInfo().lineHeight*2),this._onDidChangeContents.fire(this)}renderItem(e,t){var s;this._renderDisposeable.clear();let{detail:i,documentation:n}=e.completion;if(t){let r="";r+=`score: ${e.score[0]}
37
- `,r+=`prefix: ${e.word??"(no prefix)"}
38
- `,r+=`word: ${e.completion.filterText?e.completion.filterText+" (filterText)":e.textLabel}
39
- `,r+=`distance: ${e.distance} (localityBonus-setting)
40
- `,r+=`index: ${e.idx}, based on ${e.completion.sortText&&`sortText: "${e.completion.sortText}"`||"label"}
41
- `,r+=`commit_chars: ${(s=e.completion.commitCharacters)==null?void 0:s.join("")}
42
- `,n=new to().appendCodeblock("empty",r),i=`Provider: ${e.provider._debugDisplayName}`}if(!t&&!pk(e)){this.clearContents();return}if(this.domNode.classList.remove("no-docs","no-type"),i){const r=i.length>1e5?`${i.substr(0,1e5)}…`:i;this._type.textContent=r,this._type.title=r,Dr(this._type),this._type.classList.toggle("auto-wrap",!/\r?\n^\s+/gmi.test(r))}else Wa(this._type),this._type.title="",Bo(this._type),this.domNode.classList.add("no-type");if(Wa(this._docs),typeof n=="string")this._docs.classList.remove("markdown-docs"),this._docs.textContent=n;else if(n){this._docs.classList.add("markdown-docs"),Wa(this._docs);const r=this._markdownRenderer.render(n);this._docs.appendChild(r.element),this._renderDisposeable.add(r),this._renderDisposeable.add(this._markdownRenderer.onDidRenderAsync(()=>{this.layout(this._size.width,this._type.clientHeight+this._docs.clientHeight),this._onDidChangeContents.fire(this)}))}this.domNode.style.userSelect="text",this.domNode.tabIndex=-1,this._close.onmousedown=r=>{r.preventDefault(),r.stopPropagation()},this._close.onclick=r=>{r.preventDefault(),r.stopPropagation(),this._onDidClose.fire()},this._body.scrollTop=0,this.layout(this._size.width,this._type.clientHeight+this._docs.clientHeight),this._onDidChangeContents.fire(this)}clearContents(){this.domNode.classList.add("no-docs"),this._type.textContent="",this._docs.textContent=""}get isEmpty(){return this.domNode.classList.contains("no-docs")}get size(){return this._size}layout(e,t){const i=new On(e,t);On.equals(i,this._size)||(this._size=i,qO(this.domNode,e,t)),this._scrollbar.scanDomNode()}scrollDown(e=8){this._body.scrollTop+=e}scrollUp(e=8){this._body.scrollTop-=e}scrollTop(){this._body.scrollTop=0}scrollBottom(){this._body.scrollTop=this._body.scrollHeight}pageDown(){this.scrollDown(80)}pageUp(){this.scrollUp(80)}set borderWidth(e){this._borderWidth=e}get borderWidth(){return this._borderWidth}};c1=rj([aj(1,Zi)],c1);class lj{constructor(e,t){this.widget=e,this._editor=t,this.allowEditorOverflow=!0,this._disposables=new Lt,this._added=!1,this._preferAlignAtTop=!0,this._resizable=new K0,this._resizable.domNode.classList.add("suggest-details-container"),this._resizable.domNode.appendChild(e.domNode),this._resizable.enableSashes(!1,!0,!0,!1);let i,n,s=0,r=0;this._disposables.add(this._resizable.onDidWillResize(()=>{i=this._topLeft,n=this._resizable.size})),this._disposables.add(this._resizable.onDidResize(a=>{if(i&&n){this.widget.layout(a.dimension.width,a.dimension.height);let d=!1;a.west&&(r=n.width-a.dimension.width,d=!0),a.north&&(s=n.height-a.dimension.height,d=!0),d&&this._applyTopLeft({top:i.top+s,left:i.left+r})}a.done&&(i=void 0,n=void 0,s=0,r=0,this._userSize=a.dimension)})),this._disposables.add(this.widget.onDidChangeContents(()=>{this._anchorBox&&this._placeAtAnchor(this._anchorBox,this._userSize??this.widget.size,this._preferAlignAtTop)}))}dispose(){this._resizable.dispose(),this._disposables.dispose(),this.hide()}getId(){return"suggest.details"}getDomNode(){return this._resizable.domNode}getPosition(){return this._topLeft?{preference:this._topLeft}:null}show(){this._added||(this._editor.addOverlayWidget(this),this._added=!0)}hide(e=!1){this._resizable.clearSashHoverState(),this._added&&(this._editor.removeOverlayWidget(this),this._added=!1,this._anchorBox=void 0,this._topLeft=void 0),e&&(this._userSize=void 0,this.widget.clearContents())}placeAtAnchor(e,t){const i=e.getBoundingClientRect();this._anchorBox=i,this._preferAlignAtTop=t,this._placeAtAnchor(this._anchorBox,this._userSize??this.widget.size,t)}_placeAtAnchor(e,t,i){const n=g_(this.getDomNode().ownerDocument.body),s=this.widget.getLayoutInfo(),r=new On(220,2*s.lineHeight),a=e.top,d=(function(){const V=n.width-(e.left+e.width+s.borderWidth+s.horizontalPadding),se=-s.borderWidth+e.left+e.width,te=new On(V,n.height-e.top-s.borderHeight-s.verticalPadding),pe=te.with(void 0,e.top+e.height-s.borderHeight-s.verticalPadding);return{top:a,left:se,fit:V-t.width,maxSizeTop:te,maxSizeBottom:pe,minSize:r.with(Math.min(V,r.width))}})(),u=(function(){const V=e.left-s.borderWidth-s.horizontalPadding,se=Math.max(s.horizontalPadding,e.left-t.width-s.borderWidth),te=new On(V,n.height-e.top-s.borderHeight-s.verticalPadding),pe=te.with(void 0,e.top+e.height-s.borderHeight-s.verticalPadding);return{top:a,left:se,fit:V-t.width,maxSizeTop:te,maxSizeBottom:pe,minSize:r.with(Math.min(V,r.width))}})(),f=(function(){const V=e.left,se=-s.borderWidth+e.top+e.height,te=new On(e.width-s.borderHeight,n.height-e.top-e.height-s.verticalPadding);return{top:se,left:V,fit:te.height-t.height,maxSizeBottom:te,maxSizeTop:te,minSize:r.with(te.width)}})(),g=[d,u,f],p=g.find(V=>V.fit>=0)??g.sort((V,se)=>se.fit-V.fit)[0],w=e.top+e.height-s.borderHeight;let y,x=t.height;const k=Math.max(p.maxSizeTop.height,p.maxSizeBottom.height);x>k&&(x=k);let D;i?x<=p.maxSizeTop.height?(y=!0,D=p.maxSizeTop):(y=!1,D=p.maxSizeBottom):x<=p.maxSizeBottom.height?(y=!1,D=p.maxSizeBottom):(y=!0,D=p.maxSizeTop);let{top:M,left:F}=p;!y&&x>e.height&&(M=w-x);const K=this._editor.getDomNode();if(K){const V=K.getBoundingClientRect();M-=V.top,F-=V.left}this._applyTopLeft({left:F,top:M}),this._resizable.enableSashes(!y,p===d,y,p!==d),this._resizable.minSize=p.minSize,this._resizable.maxSize=D,this._resizable.layout(x,Math.min(D.width,t.width)),this.widget.layout(this._resizable.size.width,this._resizable.size.height)}_applyTopLeft(e){this._topLeft=e,this._editor.layoutOverlayWidget(this)}}var Fa;(function(o){o[o.FILE=0]="FILE",o[o.FOLDER=1]="FOLDER",o[o.ROOT_FOLDER=2]="ROOT_FOLDER"})(Fa||(Fa={}));const cj=/(?:\/|^)(?:([^\/]+)\/)?([^\/]+)$/;function gm(o,e,t,i,n){if(xn.isThemeIcon(n))return[`codicon-${n.id}`,"predefined-file-icon"];if(Pn.isUri(n))return[];const s=i===Fa.ROOT_FOLDER?["rootfolder-icon"]:i===Fa.FOLDER?["folder-icon"]:["file-icon"];if(t){let r;if(t.scheme===go.data)r=cv.parseMetaData(t).get(cv.META_DATA_LABEL);else{const a=t.path.match(cj);a?(r=pm(a[2].toLowerCase()),a[1]&&s.push(`${pm(a[1].toLowerCase())}-name-dir-icon`)):r=pm(t.authority.toLowerCase())}if(i===Fa.ROOT_FOLDER)s.push(`${r}-root-name-folder-icon`);else if(i===Fa.FOLDER)s.push(`${r}-name-folder-icon`);else{if(r){if(s.push(`${r}-name-file-icon`),s.push("name-file-icon"),r.length<=255){const d=r.split(".");for(let u=1;u<d.length;u++)s.push(`${d.slice(u).join(".")}-ext-file-icon`)}s.push("ext-file-icon")}const a=dj(o,e,t);a&&s.push(`${pm(a)}-lang-file-icon`)}}return s}function dj(o,e,t){if(!t)return null;let i=null;if(t.scheme===go.data){const s=cv.parseMetaData(t).get(cv.META_DATA_MIME);s&&(i=e.getLanguageIdByMimeType(s))}else{const n=o.getModel(t);n&&(i=n.getLanguageId())}return i&&i!==vp?i:e.guessLanguageIdByFilepathOrFirstLine(t)}function pm(o){return o.replace(/[\s]/g,"/")}var uj=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},eS=function(o,e){return function(t,i){e(t,i,o)}};function QR(o){return`suggest-aria-id:${o}`}const hj=is("suggest-more-info",ji.chevronRight,C("suggestMoreInfoIcon","Icon for more information in the suggest widget."));var ia;const fj=new(ia=class{extract(e,t){if(e.textLabel.match(ia._regexStrict))return t[0]=e.textLabel,!0;if(e.completion.detail&&e.completion.detail.match(ia._regexStrict))return t[0]=e.completion.detail,!0;if(e.completion.documentation){const i=typeof e.completion.documentation=="string"?e.completion.documentation:e.completion.documentation.value,n=ia._regexRelaxed.exec(i);if(n&&(n.index===0||n.index+n[0].length===i.length))return t[0]=n[0],!0}return!1}},ia._regexRelaxed=/(#([\da-fA-F]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1|0?\.\d+)\)|(rgb|hsl)\(\s*\d{1,3}%?(\s*,\s*\d{1,3}%?){2}\s*\))/,ia._regexStrict=new RegExp(`^${ia._regexRelaxed.source}$`,"i"),ia);let d1=class{constructor(e,t,i,n){this._editor=e,this._modelService=t,this._languageService=i,this._themeService=n,this._onDidToggleDetails=new Xi,this.onDidToggleDetails=this._onDidToggleDetails.event,this.templateId="suggestion"}dispose(){this._onDidToggleDetails.dispose()}renderTemplate(e){const t=new Lt,i=e;i.classList.add("show-file-icons");const n=ei(e,si(".icon")),s=ei(n,si("span.colorspan")),r=ei(e,si(".contents")),a=ei(r,si(".main")),d=ei(a,si(".icon-label.codicon")),u=ei(a,si("span.left")),f=ei(a,si("span.right")),g=new XD(u,{supportHighlights:!0,supportIcons:!0});t.add(g);const p=ei(u,si("span.signature-label")),w=ei(u,si("span.qualifier-label")),y=ei(f,si("span.details-label")),x=ei(f,si("span.readMore"+xn.asCSSSelector(hj)));return x.title=C("readMore","Read More"),{root:i,left:u,right:f,icon:n,colorspan:s,iconLabel:g,iconContainer:d,parametersLabel:p,qualifierLabel:w,detailsLabel:y,readMore:x,disposables:t,configureFont:()=>{const D=this._editor.getOptions(),M=D.get(50),F=M.getMassagedFontFamily(),K=M.fontFeatureSettings,V=D.get(120)||M.fontSize,se=D.get(121)||M.lineHeight,te=M.fontWeight,pe=M.letterSpacing,je=`${V}px`,Ke=`${se}px`,ue=`${pe}px`;i.style.fontSize=je,i.style.fontWeight=te,i.style.letterSpacing=ue,a.style.fontFamily=F,a.style.fontFeatureSettings=K,a.style.lineHeight=Ke,n.style.height=Ke,n.style.width=Ke,x.style.height=Ke,x.style.width=Ke}}}renderElement(e,t,i){i.configureFont();const{completion:n}=e;i.root.id=QR(t),i.colorspan.style.backgroundColor="";const s={labelEscapeNewLines:!0,matches:Iy(e.score)},r=[];if(n.kind===19&&fj.extract(e,r))i.icon.className="icon customcolor",i.iconContainer.className="icon hide",i.colorspan.style.backgroundColor=r[0];else if(n.kind===20&&this._themeService.getFileIconTheme().hasFileIcons){i.icon.className="icon hide",i.iconContainer.className="icon hide";const a=gm(this._modelService,this._languageService,Pn.from({scheme:"fake",path:e.textLabel}),Fa.FILE),d=gm(this._modelService,this._languageService,Pn.from({scheme:"fake",path:n.detail}),Fa.FILE);s.extraClasses=a.length>d.length?a:d}else n.kind===23&&this._themeService.getFileIconTheme().hasFolderIcons?(i.icon.className="icon hide",i.iconContainer.className="icon hide",s.extraClasses=[gm(this._modelService,this._languageService,Pn.from({scheme:"fake",path:e.textLabel}),Fa.FOLDER),gm(this._modelService,this._languageService,Pn.from({scheme:"fake",path:n.detail}),Fa.FOLDER)].flat()):(i.icon.className="icon hide",i.iconContainer.className="",i.iconContainer.classList.add("suggest-icon",...xn.asClassNameArray(g0.toIcon(n.kind))));n.tags&&n.tags.indexOf(1)>=0&&(s.extraClasses=(s.extraClasses||[]).concat(["deprecated"]),s.matches=[]),i.iconLabel.setLabel(e.textLabel,void 0,s),typeof n.label=="string"?(i.parametersLabel.textContent="",i.detailsLabel.textContent=tS(n.detail||""),i.root.classList.add("string-label")):(i.parametersLabel.textContent=tS(n.label.detail||""),i.detailsLabel.textContent=tS(n.label.description||""),i.root.classList.remove("string-label")),this._editor.getOption(119).showInlineDetails?Dr(i.detailsLabel):Bo(i.detailsLabel),pk(e)?(i.right.classList.add("can-expand-details"),Dr(i.readMore),i.readMore.onmousedown=a=>{a.stopPropagation(),a.preventDefault()},i.readMore.onclick=a=>{a.stopPropagation(),a.preventDefault(),this._onDidToggleDetails.fire()}):(i.right.classList.remove("can-expand-details"),Bo(i.readMore),i.readMore.onmousedown=null,i.readMore.onclick=null)}disposeTemplate(e){e.disposables.dispose()}};d1=uj([eS(1,uo),eS(2,fa),eS(3,Hr)],d1);function tS(o){return o.replace(/\r\n|\r|\n/g,"")}var gj=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},_m=function(o,e){return function(t,i){e(t,i,o)}},Sh;oi("editorSuggestWidget.background",RT,C("editorSuggestWidgetBackground","Background color of the suggest widget."));oi("editorSuggestWidget.border",GO,C("editorSuggestWidgetBorder","Border color of the suggest widget."));const pj=oi("editorSuggestWidget.foreground",m_,C("editorSuggestWidgetForeground","Foreground color of the suggest widget."));oi("editorSuggestWidget.selectedForeground",NT,C("editorSuggestWidgetSelectedForeground","Foreground color of the selected entry in the suggest widget."));oi("editorSuggestWidget.selectedIconForeground",KO,C("editorSuggestWidgetSelectedIconForeground","Icon foreground color of the selected entry in the suggest widget."));const _j=oi("editorSuggestWidget.selectedBackground",AT,C("editorSuggestWidgetSelectedBackground","Background color of the selected entry in the suggest widget."));oi("editorSuggestWidget.highlightForeground",OT,C("editorSuggestWidgetHighlightForeground","Color of the match highlights in the suggest widget."));oi("editorSuggestWidget.focusHighlightForeground",ZO,C("editorSuggestWidgetFocusHighlightForeground","Color of the match highlights in the suggest widget when an item is focused."));oi("editorSuggestWidgetStatus.foreground",Ba(pj,.5),C("editorSuggestWidgetStatusForeground","Foreground color of the suggest widget status."));class mj{constructor(e,t){this._service=e,this._key=`suggestWidget.size/${t.getEditorType()}/${t instanceof Fr}`}restore(){const e=this._service.get(this._key,0)??"";try{const t=JSON.parse(e);if(On.is(t))return On.lift(t)}catch{}}store(e){this._service.store(this._key,JSON.stringify(e),0,1)}reset(){this._service.remove(this._key,0)}}var xc;let u1=(xc=class{constructor(e,t,i,n,s){this.editor=e,this._storageService=t,this._state=0,this._isAuto=!1,this._pendingLayout=new Go,this._pendingShowDetails=new Go,this._ignoreFocusEvents=!1,this._forceRenderingAbove=!1,this._explainMode=!1,this._showTimeout=new l_,this._disposables=new Lt,this._onDidSelect=new LL,this._onDidFocus=new LL,this._onDidHide=new Xi,this._onDidShow=new Xi,this.onDidSelect=this._onDidSelect.event,this.onDidFocus=this._onDidFocus.event,this.onDidHide=this._onDidHide.event,this.onDidShow=this._onDidShow.event,this._onDetailsKeydown=new Xi,this.onDetailsKeyDown=this._onDetailsKeydown.event,this.element=new K0,this.element.domNode.classList.add("editor-widget","suggest-widget"),this._contentWidget=new vj(this,e),this._persistedSize=new mj(t,e);class r{constructor(w,y,x=!1,k=!1){this.persistedSize=w,this.currentSize=y,this.persistHeight=x,this.persistWidth=k}}let a;this._disposables.add(this.element.onDidWillResize(()=>{this._contentWidget.lockPreference(),a=new r(this._persistedSize.restore(),this.element.size)})),this._disposables.add(this.element.onDidResize(p=>{var w,y;if(this._resize(p.dimension.width,p.dimension.height),a&&(a.persistHeight=a.persistHeight||!!p.north||!!p.south,a.persistWidth=a.persistWidth||!!p.east||!!p.west),!!p.done){if(a){const{itemHeight:x,defaultSize:k}=this.getLayoutInfo(),D=Math.round(x/2);let{width:M,height:F}=this.element.size;(!a.persistHeight||Math.abs(a.currentSize.height-F)<=D)&&(F=((w=a.persistedSize)==null?void 0:w.height)??k.height),(!a.persistWidth||Math.abs(a.currentSize.width-M)<=D)&&(M=((y=a.persistedSize)==null?void 0:y.width)??k.width),this._persistedSize.store(new On(M,F))}this._contentWidget.unlockPreference(),a=void 0}})),this._messageElement=ei(this.element.domNode,si(".message")),this._listElement=ei(this.element.domNode,si(".tree"));const d=this._disposables.add(s.createInstance(c1,this.editor));d.onDidClose(this.toggleDetails,this,this._disposables),this._details=new lj(d,this.editor);const u=()=>this.element.domNode.classList.toggle("no-icons",!this.editor.getOption(119).showIcons);u();const f=s.createInstance(d1,this.editor);this._disposables.add(f),this._disposables.add(f.onDidToggleDetails(()=>this.toggleDetails())),this._list=new t0("SuggestWidget",this._listElement,{getHeight:p=>this.getLayoutInfo().itemHeight,getTemplateId:p=>"suggestion"},[f],{alwaysConsumeMouseWheel:!0,useShadows:!1,mouseSupport:!1,multipleSelectionSupport:!1,accessibilityProvider:{getRole:()=>"option",getWidgetAriaLabel:()=>C("suggest","Suggest"),getWidgetRole:()=>"listbox",getAriaLabel:p=>{let w=p.textLabel;if(typeof p.completion.label!="string"){const{detail:D,description:M}=p.completion.label;D&&M?w=C("label.full","{0} {1}, {2}",w,D,M):D?w=C("label.detail","{0} {1}",w,D):M&&(w=C("label.desc","{0}, {1}",w,M))}if(!p.isResolved||!this._isDetailsVisible())return w;const{documentation:y,detail:x}=p.completion,k=h0("{0}{1}",x||"",y?typeof y=="string"?y:y.value:"");return C("ariaCurrenttSuggestionReadDetails","{0}, docs: {1}",w,k)}}}),this._list.style(FT({listInactiveFocusBackground:_j,listInactiveFocusOutline:mu})),this._status=s.createInstance(l1,this.element.domNode,gc);const g=()=>this.element.domNode.classList.toggle("with-status-bar",this.editor.getOption(119).showStatusBar);g(),this._disposables.add(n.onDidColorThemeChange(p=>this._onThemeChange(p))),this._onThemeChange(n.getColorTheme()),this._disposables.add(this._list.onMouseDown(p=>this._onListMouseDownOrTap(p))),this._disposables.add(this._list.onTap(p=>this._onListMouseDownOrTap(p))),this._disposables.add(this._list.onDidChangeSelection(p=>this._onListSelection(p))),this._disposables.add(this._list.onDidChangeFocus(p=>this._onListFocus(p))),this._disposables.add(this.editor.onDidChangeCursorSelection(()=>this._onCursorSelectionChanged())),this._disposables.add(this.editor.onDidChangeConfiguration(p=>{p.hasChanged(119)&&(g(),u()),this._completionModel&&(p.hasChanged(50)||p.hasChanged(120)||p.hasChanged(121))&&this._list.splice(0,this._list.length,this._completionModel.items)})),this._ctxSuggestWidgetVisible=Wi.Visible.bindTo(i),this._ctxSuggestWidgetDetailsVisible=Wi.DetailsVisible.bindTo(i),this._ctxSuggestWidgetMultipleSuggestions=Wi.MultipleSuggestions.bindTo(i),this._ctxSuggestWidgetHasFocusedSuggestion=Wi.HasFocusedSuggestion.bindTo(i),this._disposables.add(Cl(this._details.widget.domNode,"keydown",p=>{this._onDetailsKeydown.fire(p)})),this._disposables.add(this.editor.onMouseDown(p=>this._onEditorMouseDown(p)))}dispose(){var e;this._details.widget.dispose(),this._details.dispose(),this._list.dispose(),this._status.dispose(),this._disposables.dispose(),(e=this._loadingTimeout)==null||e.dispose(),this._pendingLayout.dispose(),this._pendingShowDetails.dispose(),this._showTimeout.dispose(),this._contentWidget.dispose(),this.element.dispose()}_onEditorMouseDown(e){this._details.widget.domNode.contains(e.target.element)?this._details.widget.domNode.focus():this.element.domNode.contains(e.target.element)&&this.editor.focus()}_onCursorSelectionChanged(){this._state!==0&&this._contentWidget.layout()}_onListMouseDownOrTap(e){typeof e.element>"u"||typeof e.index>"u"||(e.browserEvent.preventDefault(),e.browserEvent.stopPropagation(),this._select(e.element,e.index))}_onListSelection(e){e.elements.length&&this._select(e.elements[0],e.indexes[0])}_select(e,t){const i=this._completionModel;i&&(this._onDidSelect.fire({item:e,index:t,model:i}),this.editor.focus())}_onThemeChange(e){this._details.widget.borderWidth=hp(e.type)?2:1}_onListFocus(e){var n;if(this._ignoreFocusEvents)return;if(!e.elements.length){this._currentSuggestionDetails&&(this._currentSuggestionDetails.cancel(),this._currentSuggestionDetails=void 0,this._focusedItem=void 0),this.editor.setAriaOptions({activeDescendant:void 0}),this._ctxSuggestWidgetHasFocusedSuggestion.set(!1);return}if(!this._completionModel)return;this._ctxSuggestWidgetHasFocusedSuggestion.set(!0);const t=e.elements[0],i=e.indexes[0];t!==this._focusedItem&&((n=this._currentSuggestionDetails)==null||n.cancel(),this._currentSuggestionDetails=void 0,this._focusedItem=t,this._list.reveal(i),this._currentSuggestionDetails=Os(async s=>{const r=dp(()=>{this._isDetailsVisible()&&this.showDetails(!0)},250),a=s.onCancellationRequested(()=>r.dispose());try{return await t.resolve(s)}finally{r.dispose(),a.dispose()}}),this._currentSuggestionDetails.then(()=>{i>=this._list.length||t!==this._list.element(i)||(this._ignoreFocusEvents=!0,this._list.splice(i,1,[t]),this._list.setFocus([i]),this._ignoreFocusEvents=!1,this._isDetailsVisible()?this.showDetails(!1):this.element.domNode.classList.remove("docs-side"),this.editor.setAriaOptions({activeDescendant:QR(i)}))}).catch(Nn)),this._onDidFocus.fire({item:t,index:i,model:this._completionModel})}_setState(e){if(this._state!==e)switch(this._state=e,this.element.domNode.classList.toggle("frozen",e===4),this.element.domNode.classList.remove("message"),e){case 0:Bo(this._messageElement,this._listElement,this._status.element),this._details.hide(!0),this._status.hide(),this._contentWidget.hide(),this._ctxSuggestWidgetVisible.reset(),this._ctxSuggestWidgetMultipleSuggestions.reset(),this._ctxSuggestWidgetHasFocusedSuggestion.reset(),this._showTimeout.cancel(),this.element.domNode.classList.remove("visible"),this._list.splice(0,this._list.length),this._focusedItem=void 0,this._cappedHeight=void 0,this._explainMode=!1;break;case 1:this.element.domNode.classList.add("message"),this._messageElement.textContent=Sh.LOADING_MESSAGE,Bo(this._listElement,this._status.element),Dr(this._messageElement),this._details.hide(),this._show(),this._focusedItem=void 0,gf(Sh.LOADING_MESSAGE);break;case 2:this.element.domNode.classList.add("message"),this._messageElement.textContent=Sh.NO_SUGGESTIONS_MESSAGE,Bo(this._listElement,this._status.element),Dr(this._messageElement),this._details.hide(),this._show(),this._focusedItem=void 0,gf(Sh.NO_SUGGESTIONS_MESSAGE);break;case 3:Bo(this._messageElement),Dr(this._listElement,this._status.element),this._show();break;case 4:Bo(this._messageElement),Dr(this._listElement,this._status.element),this._show();break;case 5:Bo(this._messageElement),Dr(this._listElement,this._status.element),this._details.show(),this._show();break}}_show(){this._status.show(),this._contentWidget.show(),this._layout(this._persistedSize.restore()),this._ctxSuggestWidgetVisible.set(!0),this._showTimeout.cancelAndSet(()=>{this.element.domNode.classList.add("visible"),this._onDidShow.fire(this)},100)}showTriggered(e,t){this._state===0&&(this._contentWidget.setPosition(this.editor.getPosition()),this._isAuto=!!e,this._isAuto||(this._loadingTimeout=dp(()=>this._setState(1),t)))}showSuggestions(e,t,i,n,s){var d,u;if(this._contentWidget.setPosition(this.editor.getPosition()),(d=this._loadingTimeout)==null||d.dispose(),(u=this._currentSuggestionDetails)==null||u.cancel(),this._currentSuggestionDetails=void 0,this._completionModel!==e&&(this._completionModel=e),i&&this._state!==2&&this._state!==0){this._setState(4);return}const r=this._completionModel.items.length,a=r===0;if(this._ctxSuggestWidgetMultipleSuggestions.set(r>1),a){this._setState(n?0:2),this._completionModel=void 0;return}this._focusedItem=void 0,this._onDidFocus.pause(),this._onDidSelect.pause();try{this._list.splice(0,this._list.length,this._completionModel.items),this._setState(i?4:3),this._list.reveal(t,0),this._list.setFocus(s?[]:[t])}finally{this._onDidFocus.resume(),this._onDidSelect.resume()}this._pendingLayout.value=IL(yd(this.element.domNode),()=>{this._pendingLayout.clear(),this._layout(this.element.size),this._details.widget.domNode.classList.remove("focused")})}focusSelected(){this._list.length>0&&this._list.setFocus([0])}selectNextPage(){switch(this._state){case 0:return!1;case 5:return this._details.widget.pageDown(),!0;case 1:return!this._isAuto;default:return this._list.focusNextPage(),!0}}selectNext(){switch(this._state){case 0:return!1;case 1:return!this._isAuto;default:return this._list.focusNext(1,!0),!0}}selectLast(){switch(this._state){case 0:return!1;case 5:return this._details.widget.scrollBottom(),!0;case 1:return!this._isAuto;default:return this._list.focusLast(),!0}}selectPreviousPage(){switch(this._state){case 0:return!1;case 5:return this._details.widget.pageUp(),!0;case 1:return!this._isAuto;default:return this._list.focusPreviousPage(),!0}}selectPrevious(){switch(this._state){case 0:return!1;case 1:return!this._isAuto;default:return this._list.focusPrevious(1,!0),!1}}selectFirst(){switch(this._state){case 0:return!1;case 5:return this._details.widget.scrollTop(),!0;case 1:return!this._isAuto;default:return this._list.focusFirst(),!0}}getFocusedItem(){if(this._state!==0&&this._state!==2&&this._state!==1&&this._completionModel&&this._list.getFocus().length>0)return{item:this._list.getFocusedElements()[0],index:this._list.getFocus()[0],model:this._completionModel}}toggleDetailsFocus(){this._state===5?(this._setState(3),this._details.widget.domNode.classList.remove("focused")):this._state===3&&this._isDetailsVisible()&&(this._setState(5),this._details.widget.domNode.classList.add("focused"))}toggleDetails(){this._isDetailsVisible()?(this._pendingShowDetails.clear(),this._ctxSuggestWidgetDetailsVisible.set(!1),this._setDetailsVisible(!1),this._details.hide(),this.element.domNode.classList.remove("shows-details")):(pk(this._list.getFocusedElements()[0])||this._explainMode)&&(this._state===3||this._state===5||this._state===4)&&(this._ctxSuggestWidgetDetailsVisible.set(!0),this._setDetailsVisible(!0),this.showDetails(!1))}showDetails(e){this._pendingShowDetails.value=IL(yd(this.element.domNode),()=>{this._pendingShowDetails.clear(),this._details.show(),e?this._details.widget.renderLoading():this._details.widget.renderItem(this._list.getFocusedElements()[0],this._explainMode),this._details.widget.isEmpty?this._details.hide():(this._positionDetails(),this.element.domNode.classList.add("shows-details")),this.editor.focus()})}toggleExplainMode(){this._list.getFocusedElements()[0]&&(this._explainMode=!this._explainMode,this._isDetailsVisible()?this.showDetails(!1):this.toggleDetails())}resetPersistedSize(){this._persistedSize.reset()}hideWidget(){var i;this._pendingLayout.clear(),this._pendingShowDetails.clear(),(i=this._loadingTimeout)==null||i.dispose(),this._setState(0),this._onDidHide.fire(this),this.element.clearSashHoverState();const e=this._persistedSize.restore(),t=Math.ceil(this.getLayoutInfo().itemHeight*4.3);e&&e.height<t&&this._persistedSize.store(e.with(void 0,t))}isFrozen(){return this._state===4}_afterRender(e){if(e===null){this._isDetailsVisible()&&this._details.hide();return}this._state===2||this._state===1||(this._isDetailsVisible()&&!this._details.widget.isEmpty&&this._details.show(),this._positionDetails())}_layout(e){var r,a;if(!this.editor.hasModel()||!this.editor.getDomNode())return;const t=g_(this.element.domNode.ownerDocument.body),i=this.getLayoutInfo();e||(e=i.defaultSize);let n=e.height,s=e.width;if(this._status.element.style.height=`${i.itemHeight}px`,this._state===2||this._state===1)n=i.itemHeight+i.borderHeight,s=i.defaultSize.width/2,this.element.enableSashes(!1,!1,!1,!1),this.element.minSize=this.element.maxSize=new On(s,n),this._contentWidget.setPreference(2);else{const d=t.width-i.borderHeight-2*i.horizontalPadding;s>d&&(s=d);const u=this._completionModel?this._completionModel.stats.pLabelLen*i.typicalHalfwidthCharacterWidth:s,f=i.statusBarHeight+this._list.contentHeight+i.borderHeight,g=i.itemHeight+i.statusBarHeight,p=mo(this.editor.getDomNode()),w=this.editor.getScrolledVisiblePosition(this.editor.getPosition()),y=p.top+w.top+w.height,x=Math.min(t.height-y-i.verticalPadding,f),k=p.top+w.top-i.verticalPadding,D=Math.min(k,f);let M=Math.min(Math.max(D,x)+i.borderHeight,f);n===((r=this._cappedHeight)==null?void 0:r.capped)&&(n=this._cappedHeight.wanted),n<g&&(n=g),n>M&&(n=M),n>x||this._forceRenderingAbove&&k>150?(this._contentWidget.setPreference(1),this.element.enableSashes(!0,!0,!1,!1),M=D):(this._contentWidget.setPreference(2),this.element.enableSashes(!1,!0,!0,!1),M=x),this.element.preferredSize=new On(u,i.defaultSize.height),this.element.maxSize=new On(d,M),this.element.minSize=new On(220,g),this._cappedHeight=n===f?{wanted:((a=this._cappedHeight)==null?void 0:a.wanted)??e.height,capped:n}:void 0}this._resize(s,n)}_resize(e,t){const{width:i,height:n}=this.element.maxSize;e=Math.min(i,e),t=Math.min(n,t);const{statusBarHeight:s}=this.getLayoutInfo();this._list.layout(t-s,e),this._listElement.style.height=`${t-s}px`,this.element.layout(t,e),this._contentWidget.layout(),this._positionDetails()}_positionDetails(){var e;this._isDetailsVisible()&&this._details.placeAtAnchor(this.element.domNode,((e=this._contentWidget.getPosition())==null?void 0:e.preference[0])===2)}getLayoutInfo(){const e=this.editor.getOption(50),t=YO(this.editor.getOption(121)||e.lineHeight,8,1e3),i=!this.editor.getOption(119).showStatusBar||this._state===2||this._state===1?0:t,n=this._details.widget.borderWidth,s=2*n;return{itemHeight:t,statusBarHeight:i,borderWidth:n,borderHeight:s,typicalHalfwidthCharacterWidth:e.typicalHalfwidthCharacterWidth,verticalPadding:22,horizontalPadding:14,defaultSize:new On(430,i+12*t+s)}}_isDetailsVisible(){return this._storageService.getBoolean("expandSuggestionDocs",0,!1)}_setDetailsVisible(e){this._storageService.store("expandSuggestionDocs",e,0,0)}forceRenderingAbove(){this._forceRenderingAbove||(this._forceRenderingAbove=!0,this._layout(this._persistedSize.restore()))}stopForceRenderingAbove(){this._forceRenderingAbove=!1}},Sh=xc,xc.LOADING_MESSAGE=C("suggestWidget.loading","Loading..."),xc.NO_SUGGESTIONS_MESSAGE=C("suggestWidget.noSuggestions","No suggestions."),xc);u1=Sh=gj([_m(1,zc),_m(2,Sn),_m(3,Hr),_m(4,Zi)],u1);class vj{constructor(e,t){this._widget=e,this._editor=t,this.allowEditorOverflow=!0,this.suppressMouseDown=!1,this._preferenceLocked=!1,this._added=!1,this._hidden=!1}dispose(){this._added&&(this._added=!1,this._editor.removeContentWidget(this))}getId(){return"editor.widget.suggestWidget"}getDomNode(){return this._widget.element.domNode}show(){this._hidden=!1,this._added||(this._added=!0,this._editor.addContentWidget(this))}hide(){this._hidden||(this._hidden=!0,this.layout())}layout(){this._editor.layoutContentWidget(this)}getPosition(){return this._hidden||!this._position||!this._preference?null:{position:this._position,preference:[this._preference]}}beforeRender(){const{height:e,width:t}=this._widget.element.size,{borderWidth:i,horizontalPadding:n}=this._widget.getLayoutInfo();return new On(t+2*i+n,e+2*i)}afterRender(e){this._widget._afterRender(e)}setPreference(e){this._preferenceLocked||(this._preference=e)}lockPreference(){this._preferenceLocked=!0}unlockPreference(){this._preferenceLocked=!1}setPosition(e){this._position=e}}var bj=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ch=function(o,e){return function(t,i){e(t,i,o)}},h1;class yj{constructor(e,t){if(this._model=e,this._position=t,this._decorationOptions=dn.register({description:"suggest-line-suffix",stickiness:1}),e.getLineMaxColumn(t.lineNumber)!==t.column){const n=e.getOffsetAt(t),s=e.getPositionAt(n+1);e.changeDecorations(r=>{this._marker&&r.removeDecoration(this._marker),this._marker=r.addDecoration(Z.fromPositions(t,s),this._decorationOptions)})}}dispose(){this._marker&&!this._model.isDisposed()&&this._model.changeDecorations(e=>{e.removeDecoration(this._marker),this._marker=void 0})}delta(e){if(this._model.isDisposed()||this._position.lineNumber!==e.lineNumber)return 0;if(this._marker){const t=this._model.getDecorationRange(this._marker);return this._model.getOffsetAt(t.getStartPosition())-this._model.getOffsetAt(e)}else return this._model.getLineMaxColumn(e.lineNumber)-e.column}}var Xd;let Pr=(Xd=class{static get(e){return e.getContribution(h1.ID)}constructor(e,t,i,n,s,r,a){this._memoryService=t,this._commandService=i,this._contextKeyService=n,this._instantiationService=s,this._logService=r,this._telemetryService=a,this._lineSuffix=new Go,this._toDispose=new Lt,this._selectors=new wj(g=>g.priority),this._onWillInsertSuggestItem=new Xi,this.onWillInsertSuggestItem=this._onWillInsertSuggestItem.event,this.editor=e,this.model=s.createInstance(Zv,this.editor),this._selectors.register({priority:0,select:(g,p,w)=>this._memoryService.select(g,p,w)});const d=Wi.InsertMode.bindTo(n);d.set(e.getOption(119).insertMode),this._toDispose.add(this.model.onDidTrigger(()=>d.set(e.getOption(119).insertMode))),this.widget=this._toDispose.add(new xw(yd(e.getDomNode()),()=>{const g=this._instantiationService.createInstance(u1,this.editor);this._toDispose.add(g),this._toDispose.add(g.onDidSelect(k=>this._insertSuggestion(k,0),this));const p=new tj(this.editor,g,this.model,k=>this._insertSuggestion(k,2));this._toDispose.add(p);const w=Wi.MakesTextEdit.bindTo(this._contextKeyService),y=Wi.HasInsertAndReplaceRange.bindTo(this._contextKeyService),x=Wi.CanResolve.bindTo(this._contextKeyService);return this._toDispose.add(jn(()=>{w.reset(),y.reset(),x.reset()})),this._toDispose.add(g.onDidFocus(({item:k})=>{const D=this.editor.getPosition(),M=k.editStart.column,F=D.column;let K=!0;this.editor.getOption(1)==="smart"&&this.model.state===2&&!k.completion.additionalTextEdits&&!(k.completion.insertTextRules&4)&&F-M===k.completion.insertText.length&&(K=this.editor.getModel().getValueInRange({startLineNumber:D.lineNumber,startColumn:M,endLineNumber:D.lineNumber,endColumn:F})!==k.completion.insertText),w.set(K),y.set(!gi.equals(k.editInsertEnd,k.editReplaceEnd)),x.set(!!k.provider.resolveCompletionItem||!!k.completion.documentation||k.completion.detail!==k.completion.label)})),this._toDispose.add(g.onDetailsKeyDown(k=>{if(k.toKeyCodeChord().equals(new EL(!0,!1,!1,!1,33))||ja&&k.toKeyCodeChord().equals(new EL(!1,!1,!1,!0,33))){k.stopPropagation();return}k.toKeyCodeChord().isModifierKey()||this.editor.focus()})),g})),this._overtypingCapturer=this._toDispose.add(new xw(yd(e.getDomNode()),()=>this._toDispose.add(new a1(this.editor,this.model)))),this._alternatives=this._toDispose.add(new xw(yd(e.getDomNode()),()=>this._toDispose.add(new Af(this.editor,this._contextKeyService)))),this._toDispose.add(s.createInstance(qv,e)),this._toDispose.add(this.model.onDidTrigger(g=>{this.widget.value.showTriggered(g.auto,g.shy?250:50),this._lineSuffix.value=new yj(this.editor.getModel(),g.position)})),this._toDispose.add(this.model.onDidSuggest(g=>{if(g.triggerOptions.shy)return;let p=-1;for(const y of this._selectors.itemsOrderedByPriorityDesc)if(p=y.select(this.editor.getModel(),this.editor.getPosition(),g.completionModel.items),p!==-1)break;if(p===-1&&(p=0),this.model.state===0)return;let w=!1;if(g.triggerOptions.auto){const y=this.editor.getOption(119);y.selectionMode==="never"||y.selectionMode==="always"?w=y.selectionMode==="never":y.selectionMode==="whenTriggerCharacter"?w=g.triggerOptions.triggerKind!==1:y.selectionMode==="whenQuickSuggestion"&&(w=g.triggerOptions.triggerKind===1&&!g.triggerOptions.refilter)}this.widget.value.showSuggestions(g.completionModel,p,g.isFrozen,g.triggerOptions.auto,w)})),this._toDispose.add(this.model.onDidCancel(g=>{g.retrigger||this.widget.value.hideWidget()})),this._toDispose.add(this.editor.onDidBlurEditorWidget(()=>{this.model.cancel(),this.model.clear()}));const u=Wi.AcceptSuggestionsOnEnter.bindTo(n),f=()=>{const g=this.editor.getOption(1);u.set(g==="on"||g==="smart")};this._toDispose.add(this.editor.onDidChangeConfiguration(()=>f())),f()}dispose(){this._alternatives.dispose(),this._toDispose.dispose(),this.widget.dispose(),this.model.dispose(),this._lineSuffix.dispose(),this._onWillInsertSuggestItem.dispose()}_insertSuggestion(e,t){if(!e||!e.item){this._alternatives.value.reset(),this.model.cancel(),this.model.clear();return}if(!this.editor.hasModel())return;const i=lo.get(this.editor);if(!i)return;this._onWillInsertSuggestItem.fire({item:e.item});const n=this.editor.getModel(),s=n.getAlternativeVersionId(),{item:r}=e,a=[],d=new Fs;t&1||this.editor.pushUndoStop();const u=this.getOverwriteInfo(r,!!(t&8));this._memoryService.memorize(n,this.editor.getPosition(),r);const f=r.isResolved;let g=-1,p=-1;if(Array.isArray(r.completion.additionalTextEdits)){this.model.cancel();const y=pf.capture(this.editor);this.editor.executeEdits("suggestController.additionalTextEdits.sync",r.completion.additionalTextEdits.map(x=>{let k=Z.lift(x.range);if(k.startLineNumber===r.position.lineNumber&&k.startColumn>r.position.column){const D=this.editor.getPosition().column-r.position.column,M=D,F=Z.spansMultipleLines(k)?0:D;k=new Z(k.startLineNumber,k.startColumn+M,k.endLineNumber,k.endColumn+F)}return Qn.replaceMove(k,x.text)})),y.restoreRelativeVerticalPositionOfCursor(this.editor)}else if(!f){const y=new Mo;let x;const k=n.onDidChangeContent(K=>{if(K.isFlush){d.cancel(),k.dispose();return}for(const V of K.changes){const se=Z.getEndPosition(V.range);(!x||gi.isBefore(se,x))&&(x=se)}}),D=t;t|=2;let M=!1;const F=this.editor.onWillType(()=>{F.dispose(),M=!0,D&2||this.editor.pushUndoStop()});a.push(r.resolve(d.token).then(()=>{if(!r.completion.additionalTextEdits||d.token.isCancellationRequested)return;if(x&&r.completion.additionalTextEdits.some(V=>gi.isBefore(x,Z.getStartPosition(V.range))))return!1;M&&this.editor.pushUndoStop();const K=pf.capture(this.editor);return this.editor.executeEdits("suggestController.additionalTextEdits.async",r.completion.additionalTextEdits.map(V=>Qn.replaceMove(Z.lift(V.range),V.text))),K.restoreRelativeVerticalPositionOfCursor(this.editor),(M||!(D&2))&&this.editor.pushUndoStop(),!0}).then(K=>{this._logService.trace("[suggest] async resolving of edits DONE (ms, applied?)",y.elapsed(),K),p=K===!0?1:K===!1?0:-2}).finally(()=>{k.dispose(),F.dispose()}))}let{insertText:w}=r.completion;if(r.completion.insertTextRules&4||(w=ku.escape(w)),this.model.cancel(),i.insert(w,{overwriteBefore:u.overwriteBefore,overwriteAfter:u.overwriteAfter,undoStopBefore:!1,undoStopAfter:!1,adjustWhitespace:!(r.completion.insertTextRules&1),clipboardText:e.model.clipboardText,overtypingCapturer:this._overtypingCapturer.value}),t&2||this.editor.pushUndoStop(),r.completion.command)if(r.completion.command.id===Yv.id)this.model.trigger({auto:!0,retrigger:!0});else{const y=new Mo;a.push(this._commandService.executeCommand(r.completion.command.id,...r.completion.command.arguments?[...r.completion.command.arguments]:[]).catch(x=>{r.completion.extensionId?rs(x):Nn(x)}).finally(()=>{g=y.elapsed()}))}t&4&&this._alternatives.value.set(e,y=>{for(d.cancel();n.canUndo();){s!==n.getAlternativeVersionId()&&n.undo(),this._insertSuggestion(y,3|(t&8?8:0));break}}),this._alertCompletionItem(r),Promise.all(a).finally(()=>{this._reportSuggestionAcceptedTelemetry(r,n,f,g,p,e.index,e.model.items),this.model.clear(),d.dispose()})}_reportSuggestionAcceptedTelemetry(e,t,i,n,s,r,a){var p;if(Math.floor(Math.random()*100)===0)return;const d=new Map;for(let w=0;w<Math.min(30,a.length);w++){const y=a[w].textLabel;d.has(y)?d.get(y).push(w):d.set(y,[w])}const u=d.get(e.textLabel),g=u&&u.length>1?u[0]:-1;this._telemetryService.publicLog2("suggest.acceptedSuggestion",{extensionId:((p=e.extensionId)==null?void 0:p.value)??"unknown",providerId:e.provider._debugDisplayName??"unknown",kind:e.completion.kind,basenameHash:fT($a(t.uri)).toString(16),languageId:t.getLanguageId(),fileExtension:XO(t.uri),resolveInfo:e.provider.resolveCompletionItem?i?1:0:-1,resolveDuration:e.resolveDuration,commandDuration:n,additionalEditsAsync:s,index:r,firstIndex:g})}getOverwriteInfo(e,t){Cn(this.editor.hasModel());let i=this.editor.getOption(119).insertMode==="replace";t&&(i=!i);const n=e.position.column-e.editStart.column,s=(i?e.editReplaceEnd.column:e.editInsertEnd.column)-e.position.column,r=this.editor.getPosition().column-e.position.column,a=this._lineSuffix.value?this._lineSuffix.value.delta(this.editor.getPosition()):0;return{overwriteBefore:n+r,overwriteAfter:s+a}}_alertCompletionItem(e){if($o(e.completion.additionalTextEdits)){const t=C("aria.alert.snippet","Accepting '{0}' made {1} additional edits",e.textLabel,e.completion.additionalTextEdits.length);Ar(t)}}triggerSuggest(e,t,i){this.editor.hasModel()&&(this.model.trigger({auto:t??!1,completionOptions:{providerFilter:e,kindFilter:i?new Set:void 0}}),this.editor.revealPosition(this.editor.getPosition(),0),this.editor.focus())}triggerSuggestAndAcceptBest(e){if(!this.editor.hasModel())return;const t=this.editor.getPosition(),i=()=>{t.equals(this.editor.getPosition())&&this._commandService.executeCommand(e.fallback)},n=s=>{if(s.completion.insertTextRules&4||s.completion.additionalTextEdits)return!0;const r=this.editor.getPosition(),a=s.editStart.column,d=r.column;return d-a!==s.completion.insertText.length?!0:this.editor.getModel().getValueInRange({startLineNumber:r.lineNumber,startColumn:a,endLineNumber:r.lineNumber,endColumn:d})!==s.completion.insertText};ws.once(this.model.onDidTrigger)(s=>{const r=[];ws.any(this.model.onDidTrigger,this.model.onDidCancel)(()=>{no(r),i()},void 0,r),this.model.onDidSuggest(({completionModel:a})=>{if(no(r),a.items.length===0){i();return}const d=this._memoryService.select(this.editor.getModel(),this.editor.getPosition(),a.items),u=a.items[d];if(!n(u)){i();return}this.editor.pushUndoStop(),this._insertSuggestion({index:d,item:u,model:a},7)},void 0,r)}),this.model.trigger({auto:!1,shy:!0}),this.editor.revealPosition(t,0),this.editor.focus()}acceptSelectedSuggestion(e,t){const i=this.widget.value.getFocusedItem();let n=0;e&&(n|=4),t&&(n|=8),this._insertSuggestion(i,n)}acceptNextSuggestion(){this._alternatives.value.next()}acceptPrevSuggestion(){this._alternatives.value.prev()}cancelSuggestWidget(){this.model.cancel(),this.model.clear(),this.widget.value.hideWidget()}focusSuggestion(){this.widget.value.focusSelected()}selectNextSuggestion(){this.widget.value.selectNext()}selectNextPageSuggestion(){this.widget.value.selectNextPage()}selectLastSuggestion(){this.widget.value.selectLast()}selectPrevSuggestion(){this.widget.value.selectPrevious()}selectPrevPageSuggestion(){this.widget.value.selectPreviousPage()}selectFirstSuggestion(){this.widget.value.selectFirst()}toggleSuggestionDetails(){this.widget.value.toggleDetails()}toggleExplainMode(){this.widget.value.toggleExplainMode()}toggleSuggestionFocus(){this.widget.value.toggleDetailsFocus()}resetWidgetSize(){this.widget.value.resetPersistedSize()}forceRenderingAbove(){this.widget.value.forceRenderingAbove()}stopForceRenderingAbove(){this.widget.isInitialized&&this.widget.value.stopForceRenderingAbove()}registerSelector(e){return this._selectors.register(e)}},h1=Xd,Xd.ID="editor.contrib.suggestController",Xd);Pr=h1=bj([ch(1,nw),ch(2,Es),ch(3,Sn),ch(4,Zi),ch(5,Wu),ch(6,ha)],Pr);class wj{constructor(e){this.prioritySelector=e,this._items=new Array}register(e){if(this._items.indexOf(e)!==-1)throw new Error("Value is already registered");return this._items.push(e),this._items.sort((t,i)=>this.prioritySelector(i)-this.prioritySelector(t)),{dispose:()=>{const t=this._items.indexOf(e);t>=0&&this._items.splice(t,1)}}}get itemsOrderedByPriorityDesc(){return this._items}}const zb=class zb extends lt{constructor(){super({id:zb.id,label:C("suggest.trigger.label","Trigger Suggest"),alias:"Trigger Suggest",precondition:Ae.and(B.writable,B.hasCompletionItemProvider,Wi.Visible.toNegated()),kbOpts:{kbExpr:B.textInputFocus,primary:2058,secondary:[2087],mac:{primary:266,secondary:[521,2087]},weight:100}})}run(e,t,i){const n=Pr.get(t);if(!n)return;let s;i&&typeof i=="object"&&i.auto===!0&&(s=!0),n.triggerSuggest(void 0,s,void 0)}};zb.id="editor.action.triggerSuggest";let Yv=zb;nn(Pr.ID,Pr,2);xe(Yv);const Ko=190,ho=wo.bindToContribution(Pr.get);bi(new ho({id:"acceptSelectedSuggestion",precondition:Ae.and(Wi.Visible,Wi.HasFocusedSuggestion),handler(o){o.acceptSelectedSuggestion(!0,!1)},kbOpts:[{primary:2,kbExpr:Ae.and(Wi.Visible,B.textInputFocus),weight:Ko},{primary:3,kbExpr:Ae.and(Wi.Visible,B.textInputFocus,Wi.AcceptSuggestionsOnEnter,Wi.MakesTextEdit),weight:Ko}],menuOpts:[{menuId:gc,title:C("accept.insert","Insert"),group:"left",order:1,when:Wi.HasInsertAndReplaceRange.toNegated()},{menuId:gc,title:C("accept.insert","Insert"),group:"left",order:1,when:Ae.and(Wi.HasInsertAndReplaceRange,Wi.InsertMode.isEqualTo("insert"))},{menuId:gc,title:C("accept.replace","Replace"),group:"left",order:1,when:Ae.and(Wi.HasInsertAndReplaceRange,Wi.InsertMode.isEqualTo("replace"))}]}));bi(new ho({id:"acceptAlternativeSelectedSuggestion",precondition:Ae.and(Wi.Visible,B.textInputFocus,Wi.HasFocusedSuggestion),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:1027,secondary:[1026]},handler(o){o.acceptSelectedSuggestion(!1,!0)},menuOpts:[{menuId:gc,group:"left",order:2,when:Ae.and(Wi.HasInsertAndReplaceRange,Wi.InsertMode.isEqualTo("insert")),title:C("accept.replace","Replace")},{menuId:gc,group:"left",order:2,when:Ae.and(Wi.HasInsertAndReplaceRange,Wi.InsertMode.isEqualTo("replace")),title:C("accept.insert","Insert")}]}));Wn.registerCommandAlias("acceptSelectedSuggestionOnEnter","acceptSelectedSuggestion");bi(new ho({id:"hideSuggestWidget",precondition:Wi.Visible,handler:o=>o.cancelSuggestWidget(),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:9,secondary:[1033]}}));bi(new ho({id:"selectNextSuggestion",precondition:Ae.and(Wi.Visible,Ae.or(Wi.MultipleSuggestions,Wi.HasFocusedSuggestion.negate())),handler:o=>o.selectNextSuggestion(),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:18,secondary:[2066],mac:{primary:18,secondary:[2066,300]}}}));bi(new ho({id:"selectNextPageSuggestion",precondition:Ae.and(Wi.Visible,Ae.or(Wi.MultipleSuggestions,Wi.HasFocusedSuggestion.negate())),handler:o=>o.selectNextPageSuggestion(),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:12,secondary:[2060]}}));bi(new ho({id:"selectLastSuggestion",precondition:Ae.and(Wi.Visible,Ae.or(Wi.MultipleSuggestions,Wi.HasFocusedSuggestion.negate())),handler:o=>o.selectLastSuggestion()}));bi(new ho({id:"selectPrevSuggestion",precondition:Ae.and(Wi.Visible,Ae.or(Wi.MultipleSuggestions,Wi.HasFocusedSuggestion.negate())),handler:o=>o.selectPrevSuggestion(),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:16,secondary:[2064],mac:{primary:16,secondary:[2064,302]}}}));bi(new ho({id:"selectPrevPageSuggestion",precondition:Ae.and(Wi.Visible,Ae.or(Wi.MultipleSuggestions,Wi.HasFocusedSuggestion.negate())),handler:o=>o.selectPrevPageSuggestion(),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:11,secondary:[2059]}}));bi(new ho({id:"selectFirstSuggestion",precondition:Ae.and(Wi.Visible,Ae.or(Wi.MultipleSuggestions,Wi.HasFocusedSuggestion.negate())),handler:o=>o.selectFirstSuggestion()}));bi(new ho({id:"focusSuggestion",precondition:Ae.and(Wi.Visible,Wi.HasFocusedSuggestion.negate()),handler:o=>o.focusSuggestion(),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:2058,secondary:[2087],mac:{primary:266,secondary:[2087]}}}));bi(new ho({id:"focusAndAcceptSuggestion",precondition:Ae.and(Wi.Visible,Wi.HasFocusedSuggestion.negate()),handler:o=>{o.focusSuggestion(),o.acceptSelectedSuggestion(!0,!1)}}));bi(new ho({id:"toggleSuggestionDetails",precondition:Ae.and(Wi.Visible,Wi.HasFocusedSuggestion),handler:o=>o.toggleSuggestionDetails(),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:2058,secondary:[2087],mac:{primary:266,secondary:[2087]}},menuOpts:[{menuId:gc,group:"right",order:1,when:Ae.and(Wi.DetailsVisible,Wi.CanResolve),title:C("detail.more","Show Less")},{menuId:gc,group:"right",order:1,when:Ae.and(Wi.DetailsVisible.toNegated(),Wi.CanResolve),title:C("detail.less","Show More")}]}));bi(new ho({id:"toggleExplainMode",precondition:Wi.Visible,handler:o=>o.toggleExplainMode(),kbOpts:{weight:100,primary:2138}}));bi(new ho({id:"toggleSuggestionFocus",precondition:Wi.Visible,handler:o=>o.toggleSuggestionFocus(),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:2570,mac:{primary:778}}}));bi(new ho({id:"insertBestCompletion",precondition:Ae.and(B.textInputFocus,Ae.equals("config.editor.tabCompletion","on"),qv.AtEnd,Wi.Visible.toNegated(),Af.OtherSuggestions.toNegated(),lo.InSnippetMode.toNegated()),handler:(o,e)=>{o.triggerSuggestAndAcceptBest(gT(e)?{fallback:"tab",...e}:{fallback:"tab"})},kbOpts:{weight:Ko,primary:2}}));bi(new ho({id:"insertNextSuggestion",precondition:Ae.and(B.textInputFocus,Ae.equals("config.editor.tabCompletion","on"),Af.OtherSuggestions,Wi.Visible.toNegated(),lo.InSnippetMode.toNegated()),handler:o=>o.acceptNextSuggestion(),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:2}}));bi(new ho({id:"insertPrevSuggestion",precondition:Ae.and(B.textInputFocus,Ae.equals("config.editor.tabCompletion","on"),Af.OtherSuggestions,Wi.Visible.toNegated(),lo.InSnippetMode.toNegated()),handler:o=>o.acceptPrevSuggestion(),kbOpts:{weight:Ko,kbExpr:B.textInputFocus,primary:1026}}));xe(class extends lt{constructor(){super({id:"editor.action.resetSuggestSize",label:C("suggest.reset.label","Reset Suggest Widget Size"),alias:"Reset Suggest Widget Size",precondition:void 0})}run(o,e){var t;(t=Pr.get(e))==null||t.resetWidgetSize()}});class Sj extends Dt{get selectedItem(){return this._currentSuggestItemInfo}constructor(e,t,i){super(),this.editor=e,this.suggestControllerPreselector=t,this.onWillAccept=i,this.isSuggestWidgetVisible=!1,this.isShiftKeyPressed=!1,this._isActive=!1,this._currentSuggestItemInfo=void 0,this._onDidSelectedItemChange=this._register(new Xi),this.onDidSelectedItemChange=this._onDidSelectedItemChange.event,this._register(e.onKeyDown(s=>{s.shiftKey&&!this.isShiftKeyPressed&&(this.isShiftKeyPressed=!0,this.update(this._isActive))})),this._register(e.onKeyUp(s=>{s.shiftKey&&this.isShiftKeyPressed&&(this.isShiftKeyPressed=!1,this.update(this._isActive))}));const n=Pr.get(this.editor);if(n){this._register(n.registerSelector({priority:100,select:(a,d,u)=>{const f=this.editor.getModel();if(!f)return-1;const g=this.suggestControllerPreselector(),p=g?Ed(g,f):void 0;if(!p)return-1;const w=gi.lift(d),y=u.map((k,D)=>{const M=Jg.fromSuggestion(n,f,w,k,this.isShiftKeyPressed),F=Ed(M.toSingleTextEdit(),f),K=XR(p,F);return{index:D,valid:K,prefixLength:F.text.length,suggestItem:k}}).filter(k=>k&&k.valid&&k.prefixLength>0),x=QO(y,__(k=>k.prefixLength,Ly));return x?x.index:-1}}));let s=!1;const r=()=>{s||(s=!0,this._register(n.widget.value.onDidShow(()=>{this.isSuggestWidgetVisible=!0,this.update(!0)})),this._register(n.widget.value.onDidHide(()=>{this.isSuggestWidgetVisible=!1,this.update(!1)})),this._register(n.widget.value.onDidFocus(()=>{this.isSuggestWidgetVisible=!0,this.update(!0)})))};this._register(ws.once(n.model.onDidTrigger)(a=>{r()})),this._register(n.onWillInsertSuggestItem(a=>{const d=this.editor.getPosition(),u=this.editor.getModel();if(!d||!u)return;const f=Jg.fromSuggestion(n,u,d,a.item,this.isShiftKeyPressed);this.onWillAccept(f)}))}this.update(this._isActive)}update(e){const t=this.getSuggestItemInfo();(this._isActive!==e||!Cj(this._currentSuggestItemInfo,t))&&(this._isActive=e,this._currentSuggestItemInfo=t,this._onDidSelectedItemChange.fire())}getSuggestItemInfo(){const e=Pr.get(this.editor);if(!e||!this.isSuggestWidgetVisible)return;const t=e.widget.value.getFocusedItem(),i=this.editor.getPosition(),n=this.editor.getModel();if(!(!t||!i||!n))return Jg.fromSuggestion(e,n,i,t.item,this.isShiftKeyPressed)}stopForceRenderingAbove(){const e=Pr.get(this.editor);e==null||e.stopForceRenderingAbove()}forceRenderingAbove(){const e=Pr.get(this.editor);e==null||e.forceRenderingAbove()}}class Jg{static fromSuggestion(e,t,i,n,s){let{insertText:r}=n.completion,a=!1;if(n.completion.insertTextRules&4){const u=new ku().parse(r);u.children.length<100&&Uv.adjustWhitespace(t,i,!0,u),r=u.toString(),a=!0}const d=e.getOverwriteInfo(n,s);return new Jg(Z.fromPositions(i.delta(0,-d.overwriteBefore),i.delta(0,Math.max(d.overwriteAfter,0))),r,n.completion.kind,a)}constructor(e,t,i,n){this.range=e,this.insertText=t,this.completionItemKind=i,this.isSnippetText=n}equals(e){return this.range.equalsRange(e.range)&&this.insertText===e.insertText&&this.completionItemKind===e.completionItemKind&&this.isSnippetText===e.isSnippetText}toSelectedSuggestionInfo(){return new JO(this.range,this.insertText,this.completionItemKind,this.isSnippetText)}toSingleTextEdit(){return new xl(this.range,this.insertText)}}function Cj(o,e){return o===e?!0:!o||!e?!1:o.equals(e)}var xj=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},el=function(o,e){return function(t,i){e(t,i,o)}},f1,Qd;let dr=(Qd=class extends Dt{static get(e){return e.getContribution(f1.ID)}constructor(e,t,i,n,s,r,a,d,u,f){super(),this.editor=e,this._instantiationService=t,this._contextKeyService=i,this._configurationService=n,this._commandService=s,this._debounceService=r,this._languageFeaturesService=a,this._accessibilitySignalService=d,this._keybindingService=u,this._accessibilityService=f,this._editorObs=Pa(this.editor),this._positions=En(this,p=>{var w;return((w=this._editorObs.selections.read(p))==null?void 0:w.map(y=>y.getEndPosition()))??[new gi(1,1)]}),this._suggestWidgetAdaptor=this._register(new Sj(this.editor,()=>{var p,w;return this._editorObs.forceUpdate(),(w=(p=this.model.get())==null?void 0:p.selectedInlineCompletion.get())==null?void 0:w.toSingleTextEdit(void 0)},p=>this._editorObs.forceUpdate(w=>{var y;(y=this.model.get())==null||y.handleSuggestAccepted(p)}))),this._suggestWidgetSelectedItem=Lo(this,p=>this._suggestWidgetAdaptor.onDidSelectedItemChange(()=>{this._editorObs.forceUpdate(w=>p(void 0))}),()=>this._suggestWidgetAdaptor.selectedItem),this._enabledInConfig=Lo(this,this.editor.onDidChangeConfiguration,()=>this.editor.getOption(62).enabled),this._isScreenReaderEnabled=Lo(this,this._accessibilityService.onDidChangeScreenReaderOptimized,()=>this._accessibilityService.isScreenReaderOptimized()),this._editorDictationInProgress=Lo(this,this._contextKeyService.onDidChangeContext,()=>this._contextKeyService.getContext(this.editor.getDomNode()).getValue("editorDictation.inProgress")===!0),this._enabled=En(this,p=>this._enabledInConfig.read(p)&&(!this._isScreenReaderEnabled.read(p)||!this._editorDictationInProgress.read(p))),this._debounceValue=this._debounceService.for(this._languageFeaturesService.inlineCompletionsProvider,"InlineCompletionsDebounce",{min:50,max:50}),this.model=Rc(this,p=>{if(this._editorObs.isReadonly.read(p))return;const w=this._editorObs.model.read(p);return w?this._instantiationService.createInstance(n1,w,this._suggestWidgetSelectedItem,this._editorObs.versionId,this._positions,this._debounceValue,Lo(this.editor.onDidChangeConfiguration,()=>this.editor.getOption(119).preview),Lo(this.editor.onDidChangeConfiguration,()=>this.editor.getOption(119).previewMode),Lo(this.editor.onDidChangeConfiguration,()=>this.editor.getOption(62).mode),this._enabled):void 0}).recomputeInitiallyAndOnChange(this._store),this._ghostTexts=En(this,p=>{const w=this.model.read(p);return(w==null?void 0:w.ghostTexts.read(p))??[]}),this._stablizedGhostTexts=kj(this._ghostTexts,this._store),this._ghostTextWidgets=eF(this,this._stablizedGhostTexts,(p,w)=>w.add(this._instantiationService.createInstance(t1,this.editor,{ghostText:p,minReservedLineCount:ul(0),targetTextModel:this.model.map(y=>y==null?void 0:y.textModel)}))).recomputeInitiallyAndOnChange(this._store),this._playAccessibilitySignal=f0(this),this._fontFamily=Lo(this,this.editor.onDidChangeConfiguration,()=>this.editor.getOption(62).fontFamily),this._register(new Po(this._contextKeyService,this.model)),this._register(DL(this._editorObs.onDidType,(p,w)=>{var y;this._enabled.get()&&((y=this.model.get())==null||y.trigger())})),this._register(this._commandService.onDidExecuteCommand(p=>{new Set([Mm.Tab.id,Mm.DeleteLeft.id,Mm.DeleteRight.id,rR,"acceptSelectedSuggestion"]).has(p.commandId)&&e.hasTextFocus()&&this._enabled.get()&&this._editorObs.forceUpdate(y=>{var x;(x=this.model.get())==null||x.trigger(y)})})),this._register(DL(this._editorObs.selections,(p,w)=>{var y;w.some(x=>x.reason===3||x.source==="api")&&((y=this.model.get())==null||y.stop())})),this._register(this.editor.onDidBlurEditorWidget(()=>{this._contextKeyService.getContextKeyValue("accessibleViewIsShown")||this._configurationService.getValue("editor.inlineSuggest.keepOnBlur")||e.getOption(62).keepOnBlur||Df.dropDownVisible||Hu(p=>{var w;(w=this.model.get())==null||w.stop(p)})})),this._register(Kn(p=>{var y;const w=(y=this.model.read(p))==null?void 0:y.state.read(p);w!=null&&w.suggestItem?w.primaryGhostText.lineCount>=2&&this._suggestWidgetAdaptor.forceRenderingAbove():this._suggestWidgetAdaptor.stopForceRenderingAbove()})),this._register(jn(()=>{this._suggestWidgetAdaptor.stopForceRenderingAbove()}));const g=xy(this,(p,w)=>{var k;const y=this.model.read(p),x=y==null?void 0:y.state.read(p);return this._suggestWidgetSelectedItem.get()?w:(k=x==null?void 0:x.inlineCompletion)==null?void 0:k.semanticId});this._register(tF(En(p=>(this._playAccessibilitySignal.read(p),g.read(p),{})),async(p,w,y)=>{const x=this.model.get(),k=x==null?void 0:x.state.get();if(!k||!x)return;const D=x.textModel.getLineContent(k.primaryGhostText.lineNumber);await Py(50,TS(y)),await iF(this._suggestWidgetSelectedItem,xg,()=>!1,TS(y)),await this._accessibilitySignalService.playSignal(_T.inlineSuggestion),this.editor.getOption(8)&&this._provideScreenReaderUpdate(k.primaryGhostText.renderForScreenReader(D))})),this._register(new yC(this.editor,this.model,this._instantiationService)),this._register(p6(En(p=>{const w=this._fontFamily.read(p);return w===""||w==="default"?"":`
43
- .monaco-editor .ghost-text-decoration,
44
- .monaco-editor .ghost-text-decoration-preview,
45
- .monaco-editor .ghost-text {
46
- font-family: ${w};
47
- }`}))),this._register(this._configurationService.onDidChangeConfiguration(p=>{p.affectsConfiguration("accessibility.verbosity.inlineCompletions")&&this.editor.updateOptions({inlineCompletionsAccessibilityVerbose:this._configurationService.getValue("accessibility.verbosity.inlineCompletions")})})),this.editor.updateOptions({inlineCompletionsAccessibilityVerbose:this._configurationService.getValue("accessibility.verbosity.inlineCompletions")})}playAccessibilitySignal(e){this._playAccessibilitySignal.trigger(e)}_provideScreenReaderUpdate(e){const t=this._contextKeyService.getContextKeyValue("accessibleViewIsShown"),i=this._keybindingService.lookupKeybinding("editor.action.accessibleView");let n;!t&&i&&this.editor.getOption(150)&&(n=C("showAccessibleViewHint","Inspect this in the accessible view ({0})",i.getAriaLabel())),Ar(n?e+", "+n:e)}shouldShowHoverAt(e){var i;const t=(i=this.model.get())==null?void 0:i.primaryGhostText.get();return t?t.parts.some(n=>e.containsPosition(new gi(t.lineNumber,n.column))):!1}shouldShowHoverAtViewZone(e){var t;return((t=this._ghostTextWidgets.get()[0])==null?void 0:t.ownsViewZone(e))??!1}},f1=Qd,Qd.ID="editor.contrib.inlineCompletionsController",Qd);dr=f1=xj([el(1,Zi),el(2,Sn),el(3,Un),el(4,Es),el(5,ur),el(6,pi),el(7,pT),el(8,hs),el(9,ky)],dr);function kj(o,e){const t=Uo("result",[]),i=[];return e.add(Kn(n=>{const s=o.read(n);Hu(r=>{if(s.length!==i.length){i.length=s.length;for(let a=0;a<i.length;a++)i[a]||(i[a]=Uo("item",s[a]));t.set([...i],r)}i.forEach((a,d)=>a.set(s[d],r))})})),t}const Vb=class Vb extends lt{constructor(){super({id:Vb.ID,label:C("action.inlineSuggest.showNext","Show Next Inline Suggestion"),alias:"Show Next Inline Suggestion",precondition:Ae.and(B.writable,Po.inlineSuggestionVisible),kbOpts:{weight:100,primary:606}})}async run(e,t){var n;const i=dr.get(t);(n=i==null?void 0:i.model.get())==null||n.next()}};Vb.ID=lR;let g1=Vb;const jb=class jb extends lt{constructor(){super({id:jb.ID,label:C("action.inlineSuggest.showPrevious","Show Previous Inline Suggestion"),alias:"Show Previous Inline Suggestion",precondition:Ae.and(B.writable,Po.inlineSuggestionVisible),kbOpts:{weight:100,primary:604}})}async run(e,t){var n;const i=dr.get(t);(n=i==null?void 0:i.model.get())==null||n.previous()}};jb.ID=aR;let p1=jb;class Lj extends lt{constructor(){super({id:"editor.action.inlineSuggest.trigger",label:C("action.inlineSuggest.trigger","Trigger Inline Suggestion"),alias:"Trigger Inline Suggestion",precondition:B.writable})}async run(e,t){const i=dr.get(t);await HT(async n=>{var s;await((s=i==null?void 0:i.model.get())==null?void 0:s.triggerExplicitly(n)),i==null||i.playAccessibilitySignal(n)})}}class Ij extends lt{constructor(){super({id:"editor.action.inlineSuggest.acceptNextWord",label:C("action.inlineSuggest.acceptNextWord","Accept Next Word Of Inline Suggestion"),alias:"Accept Next Word Of Inline Suggestion",precondition:Ae.and(B.writable,Po.inlineSuggestionVisible),kbOpts:{weight:101,primary:2065,kbExpr:Ae.and(B.writable,Po.inlineSuggestionVisible)},menuOpts:[{menuId:Gt.InlineSuggestionToolbar,title:C("acceptWord","Accept Word"),group:"primary",order:2}]})}async run(e,t){var n;const i=dr.get(t);await((n=i==null?void 0:i.model.get())==null?void 0:n.acceptNextWord(i.editor))}}class Ej extends lt{constructor(){super({id:"editor.action.inlineSuggest.acceptNextLine",label:C("action.inlineSuggest.acceptNextLine","Accept Next Line Of Inline Suggestion"),alias:"Accept Next Line Of Inline Suggestion",precondition:Ae.and(B.writable,Po.inlineSuggestionVisible),kbOpts:{weight:101},menuOpts:[{menuId:Gt.InlineSuggestionToolbar,title:C("acceptLine","Accept Line"),group:"secondary",order:2}]})}async run(e,t){var n;const i=dr.get(t);await((n=i==null?void 0:i.model.get())==null?void 0:n.acceptNextLine(i.editor))}}class Dj extends lt{constructor(){super({id:rR,label:C("action.inlineSuggest.accept","Accept Inline Suggestion"),alias:"Accept Inline Suggestion",precondition:Po.inlineSuggestionVisible,menuOpts:[{menuId:Gt.InlineSuggestionToolbar,title:C("accept","Accept"),group:"primary",order:1}],kbOpts:{primary:2,weight:200,kbExpr:Ae.and(Po.inlineSuggestionVisible,B.tabMovesFocus.toNegated(),Po.inlineSuggestionHasIndentationLessThanTabSize,Wi.Visible.toNegated(),B.hoverFocused.toNegated())}})}async run(e,t){var n;const i=dr.get(t);i&&((n=i.model.get())==null||n.accept(i.editor),i.editor.focus())}}const $b=class $b extends lt{constructor(){super({id:$b.ID,label:C("action.inlineSuggest.hide","Hide Inline Suggestion"),alias:"Hide Inline Suggestion",precondition:Po.inlineSuggestionVisible,kbOpts:{weight:100,primary:9}})}async run(e,t){const i=dr.get(t);Hu(n=>{var s;(s=i==null?void 0:i.model.get())==null||s.stop(n)})}};$b.ID="editor.action.inlineSuggest.hide";let _1=$b;const Ub=class Ub extends yo{constructor(){super({id:Ub.ID,title:C("action.inlineSuggest.alwaysShowToolbar","Always Show Toolbar"),f1:!1,precondition:void 0,menu:[{id:Gt.InlineSuggestionToolbar,group:"secondary",order:10}],toggled:Ae.equals("config.editor.inlineSuggest.showToolbar","always")})}async run(e,t){const i=e.get(Un),s=i.getValue("editor.inlineSuggest.showToolbar")==="always"?"onHover":"always";i.updateValue("editor.inlineSuggest.showToolbar",s)}};Ub.ID="editor.action.inlineSuggest.toggleAlwaysShowToolbar";let m1=Ub;var Tj=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},bg=function(o,e){return function(t,i){e(t,i,o)}};class Pj{constructor(e,t,i){this.owner=e,this.range=t,this.controller=i}isValidForHoverAnchor(e){return e.type===1&&this.range.startColumn<=e.range.startColumn&&this.range.endColumn>=e.range.endColumn}}let v1=class{constructor(e,t,i,n,s,r){this._editor=e,this._languageService=t,this._openerService=i,this.accessibilityService=n,this._instantiationService=s,this._telemetryService=r,this.hoverOrdinal=4}suggestHoverAnchor(e){const t=dr.get(this._editor);if(!t)return null;const i=e.target;if(i.type===8){const n=i.detail;if(t.shouldShowHoverAtViewZone(n.viewZoneId))return new zm(1e3,this,Z.fromPositions(this._editor.getModel().validatePosition(n.positionBefore||n.position)),e.event.posx,e.event.posy,!1)}return i.type===7&&t.shouldShowHoverAt(i.range)?new zm(1e3,this,i.range,e.event.posx,e.event.posy,!1):i.type===6&&i.detail.mightBeForeignElement&&t.shouldShowHoverAt(i.range)?new zm(1e3,this,i.range,e.event.posx,e.event.posy,!1):null}computeSync(e,t){if(this._editor.getOption(62).showToolbar!=="onHover")return[];const i=dr.get(this._editor);return i&&i.shouldShowHoverAt(e.range)?[new Pj(this,e.range,i)]:[]}renderHoverParts(e,t){const i=new Lt,n=t[0];this._telemetryService.publicLog2("inlineCompletionHover.shown"),this.accessibilityService.isScreenReaderOptimized()&&!this._editor.getOption(8)&&i.add(this.renderScreenReaderText(e,n));const s=n.controller.model.get(),r=this._instantiationService.createInstance(Df,this._editor,!1,ul(null),s.selectedInlineCompletionIndex,s.inlineCompletionsCount,s.activeCommands),a=r.getDomNode();e.fragment.appendChild(a),s.triggerExplicitly(),i.add(r);const d={hoverPart:n,hoverElement:a,dispose(){i.dispose()}};return new Du([d])}renderScreenReaderText(e,t){const i=new Lt,n=si,s=n("div.hover-row.markdown-hover"),r=ei(s,n("div.hover-contents",{"aria-live":"assertive"})),a=i.add(new Uf({editor:this._editor},this._languageService,this._openerService)),d=u=>{i.add(a.onDidRenderAsync(()=>{r.className="hover-contents code-hover-contents",e.onContentsChanged()}));const f=C("inlineSuggestionFollows","Suggestion:"),g=i.add(a.render(new to().appendText(f).appendCodeblock("text",u)));r.replaceChildren(g.element)};return i.add(Kn(u=>{var g;const f=(g=t.controller.model.read(u))==null?void 0:g.primaryGhostText.read(u);if(f){const p=this._editor.getModel().getLineContent(f.lineNumber);d(f.renderForScreenReader(p))}else nv(r)})),e.fragment.appendChild(s),i}};v1=Tj([bg(1,fa),bg(2,ua),bg(3,ky),bg(4,Zi),bg(5,ha)],v1);class Mj{}const sw=new class{constructor(){this._implementations=[]}register(e){return this._implementations.push(e),{dispose:()=>{const t=this._implementations.indexOf(e);t!==-1&&this._implementations.splice(t,1)}}}getImplementations(){return this._implementations}};nn(dr.ID,dr,3);xe(Lj);xe(g1);xe(p1);xe(Ij);xe(Ej);xe(Dj);xe(_1);Tn(m1);ju.register(v1);sw.register(new Mj);var Rj=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},iS=function(o,e){return function(t,i){e(t,i,o)}},Mg,kc;let Op=(kc=class{constructor(e,t,i,n){this.textModelResolverService=t,this.languageService=i,this.languageFeaturesService=n,this.toUnhook=new Lt,this.toUnhookForKeyboard=new Lt,this.currentWordAtPosition=null,this.previousPromise=null,this.editor=e,this.linkDecorations=this.editor.createDecorationsCollection();const s=new Yy(e);this.toUnhook.add(s),this.toUnhook.add(s.onMouseMoveOrRelevantKeyDown(([r,a])=>{this.startFindDefinitionFromMouse(r,a??void 0)})),this.toUnhook.add(s.onExecute(r=>{this.isEnabled(r)&&this.gotoDefinition(r.target.position,r.hasSideBySideModifier).catch(a=>{Nn(a)}).finally(()=>{this.removeLinkDecorations()})})),this.toUnhook.add(s.onCancel(()=>{this.removeLinkDecorations(),this.currentWordAtPosition=null}))}static get(e){return e.getContribution(Mg.ID)}async startFindDefinitionFromCursor(e){await this.startFindDefinition(e),this.toUnhookForKeyboard.add(this.editor.onDidChangeCursorPosition(()=>{this.currentWordAtPosition=null,this.removeLinkDecorations(),this.toUnhookForKeyboard.clear()})),this.toUnhookForKeyboard.add(this.editor.onKeyDown(t=>{t&&(this.currentWordAtPosition=null,this.removeLinkDecorations(),this.toUnhookForKeyboard.clear())}))}startFindDefinitionFromMouse(e,t){if(e.target.type===9&&this.linkDecorations.length>0)return;if(!this.editor.hasModel()||!this.isEnabled(e,t)){this.currentWordAtPosition=null,this.removeLinkDecorations();return}const i=e.target.position;this.startFindDefinition(i)}async startFindDefinition(e){var r;this.toUnhookForKeyboard.clear();const t=e?(r=this.editor.getModel())==null?void 0:r.getWordAtPosition(e):null;if(!t){this.currentWordAtPosition=null,this.removeLinkDecorations();return}if(this.currentWordAtPosition&&this.currentWordAtPosition.startColumn===t.startColumn&&this.currentWordAtPosition.endColumn===t.endColumn&&this.currentWordAtPosition.word===t.word)return;this.currentWordAtPosition=t;const i=new WT(this.editor,15);this.previousPromise&&(this.previousPromise.cancel(),this.previousPromise=null),this.previousPromise=Os(a=>this.findDefinition(e,a));let n;try{n=await this.previousPromise}catch(a){Nn(a);return}if(!n||!n.length||!i.validate(this.editor)){this.removeLinkDecorations();return}const s=n[0].originSelectionRange?Z.lift(n[0].originSelectionRange):new Z(e.lineNumber,t.startColumn,e.lineNumber,t.endColumn);if(n.length>1){let a=s;for(const{originSelectionRange:d}of n)d&&(a=Z.plusRange(a,d));this.addDecoration(a,new to().appendText(C("multipleResults","Click to show {0} definitions.",n.length)))}else{const a=n[0];if(!a.uri)return;this.textModelResolverService.createModelReference(a.uri).then(d=>{if(!d.object||!d.object.textEditorModel){d.dispose();return}const{object:{textEditorModel:u}}=d,{startLineNumber:f}=a.range;if(f<1||f>u.getLineCount()){d.dispose();return}const g=this.getPreviewValue(u,f,a),p=this.languageService.guessLanguageIdByFilepathOrFirstLine(u.uri);this.addDecoration(s,g?new to().appendCodeblock(p||"",g):void 0),d.dispose()})}}getPreviewValue(e,t,i){let n=i.range;return n.endLineNumber-n.startLineNumber>=Mg.MAX_SOURCE_PREVIEW_LINES&&(n=this.getPreviewRangeBasedOnIndentation(e,t)),this.stripIndentationFromPreviewRange(e,t,n)}stripIndentationFromPreviewRange(e,t,i){let s=e.getLineFirstNonWhitespaceColumn(t);for(let a=t+1;a<i.endLineNumber;a++){const d=e.getLineFirstNonWhitespaceColumn(a);s=Math.min(s,d)}return e.getValueInRange(i).replace(new RegExp(`^\\s{${s-1}}`,"gm"),"").trim()}getPreviewRangeBasedOnIndentation(e,t){const i=e.getLineFirstNonWhitespaceColumn(t),n=Math.min(e.getLineCount(),t+Mg.MAX_SOURCE_PREVIEW_LINES);let s=t+1;for(;s<n;s++){const r=e.getLineFirstNonWhitespaceColumn(s);if(i===r)break}return new Z(t,1,s+1,1)}addDecoration(e,t){const i={range:e,options:{description:"goto-definition-link",inlineClassName:"goto-definition-link",hoverMessage:t}};this.linkDecorations.set([i])}removeLinkDecorations(){this.linkDecorations.clear()}isEnabled(e,t){var i;return this.editor.hasModel()&&e.isLeftClick&&e.isNoneOrSingleMouseDown&&e.target.type===6&&!(((i=e.target.detail.injectedText)==null?void 0:i.options)instanceof u0)&&(e.hasTriggerModifier||(t?t.keyCodeIsTriggerKey:!1))&&this.languageFeaturesService.definitionProvider.has(this.editor.getModel())}findDefinition(e,t){const i=this.editor.getModel();return i?P_(this.languageFeaturesService.definitionProvider,i,e,!1,t):Promise.resolve(null)}gotoDefinition(e,t){return this.editor.setPosition(e),this.editor.invokeWithinContext(i=>{const n=!t&&this.editor.getOption(89)&&!this.isInPeekEditor(i);return new R_({openToSide:t,openInPeek:n,muteMessage:!0},{title:{value:"",original:""},id:"",precondition:void 0}).run(i)})}isInPeekEditor(e){const t=e.get(Sn);return vo.inPeekEditor.getValue(t)}dispose(){this.toUnhook.dispose(),this.toUnhookForKeyboard.dispose()}},Mg=kc,kc.ID="editor.contrib.gotodefinitionatposition",kc.MAX_SOURCE_PREVIEW_LINES=8,kc);Op=Mg=Rj([iS(1,ga),iS(2,fa),iS(3,pi)],Op);nn(Op.ID,Op,2);var JR=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Xv=function(o,e){return function(t,i){e(t,i,o)}};class fE{constructor(e,t,i){this.marker=e,this.index=t,this.total=i}}let b1=class{constructor(e,t,i){this._markerService=t,this._configService=i,this._onDidChange=new Xi,this.onDidChange=this._onDidChange.event,this._dispoables=new Lt,this._markers=[],this._nextIdx=-1,Pn.isUri(e)?this._resourceFilter=a=>a.toString()===e.toString():e&&(this._resourceFilter=e);const n=this._configService.getValue("problems.sortOrder"),s=(a,d)=>{let u=TL(a.resource.toString(),d.resource.toString());return u===0&&(n==="position"?u=Z.compareRangesUsingStarts(a,d)||so.compare(a.severity,d.severity):u=so.compare(a.severity,d.severity)||Z.compareRangesUsingStarts(a,d)),u},r=()=>{this._markers=this._markerService.read({resource:Pn.isUri(e)?e:void 0,severities:so.Error|so.Warning|so.Info}),typeof e=="function"&&(this._markers=this._markers.filter(a=>this._resourceFilter(a.resource))),this._markers.sort(s)};r(),this._dispoables.add(t.onMarkerChanged(a=>{(!this._resourceFilter||a.some(d=>this._resourceFilter(d)))&&(r(),this._nextIdx=-1,this._onDidChange.fire())}))}dispose(){this._dispoables.dispose(),this._onDidChange.dispose()}matches(e){return!this._resourceFilter&&!e?!0:!this._resourceFilter||!e?!1:this._resourceFilter(e)}get selected(){const e=this._markers[this._nextIdx];return e&&new fE(e,this._nextIdx+1,this._markers.length)}_initIdx(e,t,i){let n=!1,s=this._markers.findIndex(r=>r.resource.toString()===e.uri.toString());s<0&&(s=lv(this._markers,{resource:e.uri},(r,a)=>TL(r.resource.toString(),a.resource.toString())),s<0&&(s=~s));for(let r=s;r<this._markers.length;r++){let a=Z.lift(this._markers[r]);if(a.isEmpty()){const d=e.getWordAtPosition(a.getStartPosition());d&&(a=new Z(a.startLineNumber,d.startColumn,a.startLineNumber,d.endColumn))}if(t&&(a.containsPosition(t)||t.isBeforeOrEqual(a.getStartPosition()))){this._nextIdx=r,n=!0;break}if(this._markers[r].resource.toString()!==e.uri.toString())break}n||(this._nextIdx=i?0:this._markers.length-1),this._nextIdx<0&&(this._nextIdx=this._markers.length-1)}resetIndex(){this._nextIdx=-1}move(e,t,i){if(this._markers.length===0)return!1;const n=this._nextIdx;return this._nextIdx===-1?this._initIdx(t,i,e):e?this._nextIdx=(this._nextIdx+1)%this._markers.length:e||(this._nextIdx=(this._nextIdx-1+this._markers.length)%this._markers.length),n!==this._nextIdx}find(e,t){let i=this._markers.findIndex(n=>n.resource.toString()===e.toString());if(!(i<0)){for(;i<this._markers.length;i++)if(Z.containsPosition(this._markers[i],t))return new fE(this._markers[i],i+1,this._markers.length)}}};b1=JR([Xv(1,n0),Xv(2,Un)],b1);const eN=Rl("IMarkerNavigationService");let y1=class{constructor(e,t){this._markerService=e,this._configService=t,this._provider=new DT}getMarkerList(e){for(const t of this._provider){const i=t.getMarkerList(e);if(i)return i}return new b1(e,this._markerService,this._configService)}};y1=JR([Xv(0,n0),Xv(1,Un)],y1);Nl(eN,y1,1);var w1;(function(o){function e(t){switch(t){case Y_.Ignore:return"severity-ignore "+xn.asClassName(ji.info);case Y_.Info:return xn.asClassName(ji.info);case Y_.Warning:return xn.asClassName(ji.warning);case Y_.Error:return xn.asClassName(ji.error);default:return""}}o.className=e})(w1||(w1={}));var Nj=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},dh=function(o,e){return function(t,i){e(t,i,o)}},S1;class Aj{constructor(e,t,i,n,s){this._openerService=n,this._labelService=s,this._lines=0,this._longestLineLength=0,this._relatedDiagnostics=new WeakMap,this._disposables=new Lt,this._editor=t;const r=document.createElement("div");r.className="descriptioncontainer",this._messageBlock=document.createElement("div"),this._messageBlock.classList.add("message"),this._messageBlock.setAttribute("aria-live","assertive"),this._messageBlock.setAttribute("role","alert"),r.appendChild(this._messageBlock),this._relatedBlock=document.createElement("div"),r.appendChild(this._relatedBlock),this._disposables.add(Cl(this._relatedBlock,"click",a=>{a.preventDefault();const d=this._relatedDiagnostics.get(a.target);d&&i(d)})),this._scrollable=new cF(r,{horizontal:1,vertical:1,useShadows:!1,horizontalScrollbarSize:6,verticalScrollbarSize:6}),e.appendChild(this._scrollable.getDomNode()),this._disposables.add(this._scrollable.onScroll(a=>{r.style.left=`-${a.scrollLeft}px`,r.style.top=`-${a.scrollTop}px`})),this._disposables.add(this._scrollable)}dispose(){no(this._disposables)}update(e){const{source:t,message:i,relatedInformation:n,code:s}=e;let r=((t==null?void 0:t.length)||0)+2;s&&(typeof s=="string"?r+=s.length:r+=s.value.length);const a=Ty(i);this._lines=a.length,this._longestLineLength=0;for(const p of a)this._longestLineLength=Math.max(p.length+r,this._longestLineLength);Wa(this._messageBlock),this._messageBlock.setAttribute("aria-label",this.getAriaLabel(e)),this._editor.applyFontInfo(this._messageBlock);let d=this._messageBlock;for(const p of a)d=document.createElement("div"),d.innerText=p,p===""&&(d.style.height=this._messageBlock.style.lineHeight),this._messageBlock.appendChild(d);if(t||s){const p=document.createElement("span");if(p.classList.add("details"),d.appendChild(p),t){const w=document.createElement("span");w.innerText=t,w.classList.add("source"),p.appendChild(w)}if(s)if(typeof s=="string"){const w=document.createElement("span");w.innerText=`(${s})`,w.classList.add("code"),p.appendChild(w)}else{this._codeLink=si("a.code-link"),this._codeLink.setAttribute("href",`${s.target.toString()}`),this._codeLink.onclick=y=>{this._openerService.open(s.target,{allowCommands:!0}),y.preventDefault(),y.stopPropagation()};const w=ei(this._codeLink,si("span"));w.innerText=s.value,p.appendChild(this._codeLink)}}if(Wa(this._relatedBlock),this._editor.applyFontInfo(this._relatedBlock),$o(n)){const p=this._relatedBlock.appendChild(document.createElement("div"));p.style.paddingTop=`${Math.floor(this._editor.getOption(67)*.66)}px`,this._lines+=1;for(const w of n){const y=document.createElement("div"),x=document.createElement("a");x.classList.add("filename"),x.innerText=`${this._labelService.getUriBasenameLabel(w.resource)}(${w.startLineNumber}, ${w.startColumn}): `,x.title=this._labelService.getUriLabel(w.resource),this._relatedDiagnostics.set(x,w);const k=document.createElement("span");k.innerText=w.message,y.appendChild(x),y.appendChild(k),this._lines+=1,p.appendChild(y)}}const u=this._editor.getOption(50),f=Math.ceil(u.typicalFullwidthCharacterWidth*this._longestLineLength*.75),g=u.lineHeight*this._lines;this._scrollable.setScrollDimensions({scrollWidth:f,scrollHeight:g})}layout(e,t){this._scrollable.getDomNode().style.height=`${e}px`,this._scrollable.getDomNode().style.width=`${t}px`,this._scrollable.setScrollDimensions({width:t,height:e})}getHeightInLines(){return Math.min(17,this._lines)}getAriaLabel(e){let t="";switch(e.severity){case so.Error:t=C("Error","Error");break;case so.Warning:t=C("Warning","Warning");break;case so.Info:t=C("Info","Info");break;case so.Hint:t=C("Hint","Hint");break}let i=C("marker aria","{0} at {1}. ",t,e.startLineNumber+":"+e.startColumn);const n=this._editor.getModel();return n&&e.startLineNumber<=n.getLineCount()&&e.startLineNumber>=1&&(i=`${n.getLineContent(e.startLineNumber)}, ${i}`),i}}var Jd;let Fp=(Jd=class extends Ev{constructor(e,t,i,n,s,r,a){super(e,{showArrow:!0,showFrame:!0,isAccessible:!0,frameWidth:1},s),this._themeService=t,this._openerService=i,this._menuService=n,this._contextKeyService=r,this._labelService=a,this._callOnDispose=new Lt,this._onDidSelectRelatedInformation=new Xi,this.onDidSelectRelatedInformation=this._onDidSelectRelatedInformation.event,this._severity=so.Warning,this._backgroundColor=cn.white,this._applyTheme(t.getColorTheme()),this._callOnDispose.add(t.onDidColorThemeChange(this._applyTheme.bind(this))),this.create()}_applyTheme(e){this._backgroundColor=e.getColor(Wj);let t=C1,i=Oj;this._severity===so.Warning?(t=Um,i=Fj):this._severity===so.Info&&(t=x1,i=Hj);const n=e.getColor(t),s=e.getColor(i);this.style({arrowColor:n,frameColor:n,headerBackgroundColor:s,primaryHeadingColor:e.getColor(vR),secondaryHeadingColor:e.getColor(bR)})}_applyStyles(){this._parentContainer&&(this._parentContainer.style.backgroundColor=this._backgroundColor?this._backgroundColor.toString():""),super._applyStyles()}dispose(){this._callOnDispose.dispose(),super.dispose()}_fillHead(e){super._fillHead(e),this._disposables.add(this._actionbarWidget.actionRunner.onWillRun(n=>this.editor.focus()));const t=[],i=this._menuService.getMenuActions(S1.TitleMenu,this._contextKeyService);r0(i,t),this._actionbarWidget.push(t,{label:!1,icon:!0,index:0})}_fillTitleIcon(e){this._icon=ei(e,si(""))}_fillBody(e){this._parentContainer=e,e.classList.add("marker-widget"),this._parentContainer.tabIndex=0,this._parentContainer.setAttribute("role","tooltip"),this._container=document.createElement("div"),e.appendChild(this._container),this._message=new Aj(this._container,this.editor,t=>this._onDidSelectRelatedInformation.fire(t),this._openerService,this._labelService),this._disposables.add(this._message)}show(){throw new Error("call showAtMarker")}showAtMarker(e,t,i){this._container.classList.remove("stale"),this._message.update(e),this._severity=e.severity,this._applyTheme(this._themeService.getColorTheme());const n=Z.lift(e),s=this.editor.getPosition(),r=s&&n.containsPosition(s)?s:n.getStartPosition();super.show(r,this.computeRequiredHeight());const a=this.editor.getModel();if(a){const d=i>1?C("problems","{0} of {1} problems",t,i):C("change","{0} of {1} problem",t,i);this.setTitle($a(a.uri),d)}this._icon.className=`codicon ${w1.className(so.toSeverity(this._severity))}`,this.editor.revealPositionNearTop(r,0),this.editor.focus()}updateMarker(e){this._container.classList.remove("stale"),this._message.update(e)}showStale(){this._container.classList.add("stale"),this._relayout()}_doLayoutBody(e,t){super._doLayoutBody(e,t),this._heightInPixel=e,this._message.layout(e,t),this._container.style.height=`${e}px`}_onWidth(e){this._message.layout(this._heightInPixel,e)}_relayout(){super._relayout(this.computeRequiredHeight())}computeRequiredHeight(){return 3+this._message.getHeightInLines()}},S1=Jd,Jd.TitleMenu=new Gt("gotoErrorTitleMenu"),Jd);Fp=S1=Nj([dh(1,Hr),dh(2,ua),dh(3,Fu),dh(4,Zi),dh(5,Sn),dh(6,_p)],Fp);const gE=p0(sF,nF),pE=p0(rF,oF),_E=p0(xS,aF),C1=oi("editorMarkerNavigationError.background",{dark:gE,light:gE,hcDark:Sl,hcLight:Sl},C("editorMarkerNavigationError","Editor marker navigation widget error color.")),Oj=oi("editorMarkerNavigationError.headerBackground",{dark:Ba(C1,.1),light:Ba(C1,.1),hcDark:null,hcLight:null},C("editorMarkerNavigationErrorHeaderBackground","Editor marker navigation widget error heading background.")),Um=oi("editorMarkerNavigationWarning.background",{dark:pE,light:pE,hcDark:Sl,hcLight:Sl},C("editorMarkerNavigationWarning","Editor marker navigation widget warning color.")),Fj=oi("editorMarkerNavigationWarning.headerBackground",{dark:Ba(Um,.1),light:Ba(Um,.1),hcDark:"#0C141F",hcLight:Ba(Um,.2)},C("editorMarkerNavigationWarningBackground","Editor marker navigation widget warning heading background.")),x1=oi("editorMarkerNavigationInfo.background",{dark:_E,light:_E,hcDark:Sl,hcLight:Sl},C("editorMarkerNavigationInfo","Editor marker navigation widget info color.")),Hj=oi("editorMarkerNavigationInfo.headerBackground",{dark:Ba(x1,.1),light:Ba(x1,.1),hcDark:null,hcLight:null},C("editorMarkerNavigationInfoHeaderBackground","Editor marker navigation widget info heading background.")),Wj=oi("editorMarkerNavigation.background",lF,C("editorMarkerNavigationBackground","Editor marker navigation widget background."));var Bj=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},mm=function(o,e){return function(t,i){e(t,i,o)}},Rg,eu;let Mu=(eu=class{static get(e){return e.getContribution(Rg.ID)}constructor(e,t,i,n,s){this._markerNavigationService=t,this._contextKeyService=i,this._editorService=n,this._instantiationService=s,this._sessionDispoables=new Lt,this._editor=e,this._widgetVisible=tN.bindTo(this._contextKeyService)}dispose(){this._cleanUp(),this._sessionDispoables.dispose()}_cleanUp(){this._widgetVisible.reset(),this._sessionDispoables.clear(),this._widget=void 0,this._model=void 0}_getOrCreateModel(e){if(this._model&&this._model.matches(e))return this._model;let t=!1;return this._model&&(t=!0,this._cleanUp()),this._model=this._markerNavigationService.getMarkerList(e),t&&this._model.move(!0,this._editor.getModel(),this._editor.getPosition()),this._widget=this._instantiationService.createInstance(Fp,this._editor),this._widget.onDidClose(()=>this.close(),this,this._sessionDispoables),this._widgetVisible.set(!0),this._sessionDispoables.add(this._model),this._sessionDispoables.add(this._widget),this._sessionDispoables.add(this._editor.onDidChangeCursorPosition(i=>{var n,s,r;(!((n=this._model)!=null&&n.selected)||!Z.containsPosition((s=this._model)==null?void 0:s.selected.marker,i.position))&&((r=this._model)==null||r.resetIndex())})),this._sessionDispoables.add(this._model.onDidChange(()=>{if(!this._widget||!this._widget.position||!this._model)return;const i=this._model.find(this._editor.getModel().uri,this._widget.position);i?this._widget.updateMarker(i.marker):this._widget.showStale()})),this._sessionDispoables.add(this._widget.onDidSelectRelatedInformation(i=>{this._editorService.openCodeEditor({resource:i.resource,options:{pinned:!0,revealIfOpened:!0,selection:Z.lift(i).collapseToStart()}},this._editor),this.close(!1)})),this._sessionDispoables.add(this._editor.onDidChangeModel(()=>this._cleanUp())),this._model}close(e=!0){this._cleanUp(),e&&this._editor.focus()}showAtMarker(e){if(this._editor.hasModel()){const t=this._getOrCreateModel(this._editor.getModel().uri);t.resetIndex(),t.move(!0,this._editor.getModel(),new gi(e.startLineNumber,e.startColumn)),t.selected&&this._widget.showAtMarker(t.selected.marker,t.selected.index,t.selected.total)}}async nagivate(e,t){var i,n;if(this._editor.hasModel()){const s=this._getOrCreateModel(t?void 0:this._editor.getModel().uri);if(s.move(e,this._editor.getModel(),this._editor.getPosition()),!s.selected)return;if(s.selected.marker.resource.toString()!==this._editor.getModel().uri.toString()){this._cleanUp();const r=await this._editorService.openCodeEditor({resource:s.selected.marker.resource,options:{pinned:!1,revealIfOpened:!0,selectionRevealType:2,selection:s.selected.marker}},this._editor);r&&((i=Rg.get(r))==null||i.close(),(n=Rg.get(r))==null||n.nagivate(e,t))}else this._widget.showAtMarker(s.selected.marker,s.selected.index,s.selected.total)}}},Rg=eu,eu.ID="editor.contrib.markerController",eu);Mu=Rg=Bj([mm(1,eN),mm(2,Sn),mm(3,as),mm(4,Zi)],Mu);class ow extends lt{constructor(e,t,i){super(i),this._next=e,this._multiFile=t}async run(e,t){var i;t.hasModel()&&((i=Mu.get(t))==null||i.nagivate(this._next,this._multiFile))}}const ld=class ld extends ow{constructor(){super(!0,!1,{id:ld.ID,label:ld.LABEL,alias:"Go to Next Problem (Error, Warning, Info)",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:578,weight:100},menuOpts:{menuId:Fp.TitleMenu,title:ld.LABEL,icon:is("marker-navigation-next",ji.arrowDown,C("nextMarkerIcon","Icon for goto next marker.")),group:"navigation",order:1}})}};ld.ID="editor.action.marker.next",ld.LABEL=C("markerAction.next.label","Go to Next Problem (Error, Warning, Info)");let Qv=ld;const cd=class cd extends ow{constructor(){super(!1,!1,{id:cd.ID,label:cd.LABEL,alias:"Go to Previous Problem (Error, Warning, Info)",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:1602,weight:100},menuOpts:{menuId:Fp.TitleMenu,title:cd.LABEL,icon:is("marker-navigation-previous",ji.arrowUp,C("previousMarkerIcon","Icon for goto previous marker.")),group:"navigation",order:2}})}};cd.ID="editor.action.marker.prev",cd.LABEL=C("markerAction.previous.label","Go to Previous Problem (Error, Warning, Info)");let k1=cd;class zj extends ow{constructor(){super(!0,!0,{id:"editor.action.marker.nextInFiles",label:C("markerAction.nextInFiles.label","Go to Next Problem in Files (Error, Warning, Info)"),alias:"Go to Next Problem in Files (Error, Warning, Info)",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:66,weight:100},menuOpts:{menuId:Gt.MenubarGoMenu,title:C({key:"miGotoNextProblem",comment:["&& denotes a mnemonic"]},"Next &&Problem"),group:"6_problem_nav",order:1}})}}class Vj extends ow{constructor(){super(!1,!0,{id:"editor.action.marker.prevInFiles",label:C("markerAction.previousInFiles.label","Go to Previous Problem in Files (Error, Warning, Info)"),alias:"Go to Previous Problem in Files (Error, Warning, Info)",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:1090,weight:100},menuOpts:{menuId:Gt.MenubarGoMenu,title:C({key:"miGotoPreviousProblem",comment:["&& denotes a mnemonic"]},"Previous &&Problem"),group:"6_problem_nav",order:2}})}}nn(Mu.ID,Mu,4);xe(Qv);xe(k1);xe(zj);xe(Vj);const tN=new _n("markersNavigationVisible",!1),jj=wo.bindToContribution(Mu.get);bi(new jj({id:"closeMarkersNavigation",precondition:tN,handler:o=>o.close(),kbOpts:{weight:150,kbExpr:B.focus,primary:9,secondary:[1033]}}));var Zr;(function(o){o.NoAutoFocus="noAutoFocus",o.FocusIfVisible="focusIfVisible",o.AutoFocusImmediately="autoFocusImmediately"})(Zr||(Zr={}));class $j extends lt{constructor(){super({id:oR,label:C({key:"showOrFocusHover",comment:["Label for action that will trigger the showing/focusing of a hover in the editor.","If the hover is not visible, it will show the hover.","This allows for users to show the hover without using the mouse."]},"Show or Focus Hover"),metadata:{description:ui("showOrFocusHoverDescription","Show or focus the editor hover which shows documentation, references, and other content for a symbol at the current cursor position."),args:[{name:"args",schema:{type:"object",properties:{focus:{description:"Controls if and when the hover should take focus upon being triggered by this action.",enum:[Zr.NoAutoFocus,Zr.FocusIfVisible,Zr.AutoFocusImmediately],enumDescriptions:[C("showOrFocusHover.focus.noAutoFocus","The hover will not automatically take focus."),C("showOrFocusHover.focus.focusIfVisible","The hover will take focus only if it is already visible."),C("showOrFocusHover.focus.autoFocusImmediately","The hover will automatically take focus when it appears.")],default:Zr.FocusIfVisible}}}}]},alias:"Show or Focus Hover",precondition:void 0,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2087),weight:100}})}run(e,t,i){if(!t.hasModel())return;const n=eo.get(t);if(!n)return;const s=i==null?void 0:i.focus;let r=Zr.FocusIfVisible;Object.values(Zr).includes(s)?r=s:typeof s=="boolean"&&s&&(r=Zr.AutoFocusImmediately);const a=u=>{const f=t.getPosition(),g=new Z(f.lineNumber,f.column,f.lineNumber,f.column);n.showContentHover(g,1,1,u)},d=t.getOption(2)===2;n.isHoverVisible?r!==Zr.NoAutoFocus?n.focus():a(d):a(d||r===Zr.AutoFocusImmediately)}}class Uj extends lt{constructor(){super({id:lB,label:C({key:"showDefinitionPreviewHover",comment:["Label for action that will trigger the showing of definition preview hover in the editor.","This allows for users to show the definition preview hover without using the mouse."]},"Show Definition Preview Hover"),alias:"Show Definition Preview Hover",precondition:void 0,metadata:{description:ui("showDefinitionPreviewHoverDescription","Show the definition preview hover in the editor.")}})}run(e,t){const i=eo.get(t);if(!i)return;const n=t.getPosition();if(!n)return;const s=new Z(n.lineNumber,n.column,n.lineNumber,n.column),r=Op.get(t);if(!r)return;r.startFindDefinitionFromCursor(n).then(()=>{i.showContentHover(s,1,1,!0)})}}class qj extends lt{constructor(){super({id:cB,label:C({key:"scrollUpHover",comment:["Action that allows to scroll up in the hover widget with the up arrow when the hover widget is focused."]},"Scroll Up Hover"),alias:"Scroll Up Hover",precondition:B.hoverFocused,kbOpts:{kbExpr:B.hoverFocused,primary:16,weight:100},metadata:{description:ui("scrollUpHoverDescription","Scroll up the editor hover.")}})}run(e,t){const i=eo.get(t);i&&i.scrollUp()}}class Gj extends lt{constructor(){super({id:dB,label:C({key:"scrollDownHover",comment:["Action that allows to scroll down in the hover widget with the up arrow when the hover widget is focused."]},"Scroll Down Hover"),alias:"Scroll Down Hover",precondition:B.hoverFocused,kbOpts:{kbExpr:B.hoverFocused,primary:18,weight:100},metadata:{description:ui("scrollDownHoverDescription","Scroll down the editor hover.")}})}run(e,t){const i=eo.get(t);i&&i.scrollDown()}}class Kj extends lt{constructor(){super({id:uB,label:C({key:"scrollLeftHover",comment:["Action that allows to scroll left in the hover widget with the left arrow when the hover widget is focused."]},"Scroll Left Hover"),alias:"Scroll Left Hover",precondition:B.hoverFocused,kbOpts:{kbExpr:B.hoverFocused,primary:15,weight:100},metadata:{description:ui("scrollLeftHoverDescription","Scroll left the editor hover.")}})}run(e,t){const i=eo.get(t);i&&i.scrollLeft()}}class Zj extends lt{constructor(){super({id:hB,label:C({key:"scrollRightHover",comment:["Action that allows to scroll right in the hover widget with the right arrow when the hover widget is focused."]},"Scroll Right Hover"),alias:"Scroll Right Hover",precondition:B.hoverFocused,kbOpts:{kbExpr:B.hoverFocused,primary:17,weight:100},metadata:{description:ui("scrollRightHoverDescription","Scroll right the editor hover.")}})}run(e,t){const i=eo.get(t);i&&i.scrollRight()}}class Yj extends lt{constructor(){super({id:fB,label:C({key:"pageUpHover",comment:["Action that allows to page up in the hover widget with the page up command when the hover widget is focused."]},"Page Up Hover"),alias:"Page Up Hover",precondition:B.hoverFocused,kbOpts:{kbExpr:B.hoverFocused,primary:11,secondary:[528],weight:100},metadata:{description:ui("pageUpHoverDescription","Page up the editor hover.")}})}run(e,t){const i=eo.get(t);i&&i.pageUp()}}class Xj extends lt{constructor(){super({id:gB,label:C({key:"pageDownHover",comment:["Action that allows to page down in the hover widget with the page down command when the hover widget is focused."]},"Page Down Hover"),alias:"Page Down Hover",precondition:B.hoverFocused,kbOpts:{kbExpr:B.hoverFocused,primary:12,secondary:[530],weight:100},metadata:{description:ui("pageDownHoverDescription","Page down the editor hover.")}})}run(e,t){const i=eo.get(t);i&&i.pageDown()}}class Qj extends lt{constructor(){super({id:pB,label:C({key:"goToTopHover",comment:["Action that allows to go to the top of the hover widget with the home command when the hover widget is focused."]},"Go To Top Hover"),alias:"Go To Bottom Hover",precondition:B.hoverFocused,kbOpts:{kbExpr:B.hoverFocused,primary:14,secondary:[2064],weight:100},metadata:{description:ui("goToTopHoverDescription","Go to the top of the editor hover.")}})}run(e,t){const i=eo.get(t);i&&i.goToTop()}}class Jj extends lt{constructor(){super({id:_B,label:C({key:"goToBottomHover",comment:["Action that allows to go to the bottom in the hover widget with the end command when the hover widget is focused."]},"Go To Bottom Hover"),alias:"Go To Bottom Hover",precondition:B.hoverFocused,kbOpts:{kbExpr:B.hoverFocused,primary:13,secondary:[2066],weight:100},metadata:{description:ui("goToBottomHoverDescription","Go to the bottom of the editor hover.")}})}run(e,t){const i=eo.get(t);i&&i.goToBottom()}}class e5 extends lt{constructor(){super({id:Gy,label:mB,alias:"Increase Hover Verbosity Level",precondition:B.hoverVisible})}run(e,t,i){const n=eo.get(t);if(!n)return;const s=(i==null?void 0:i.index)!==void 0?i.index:n.focusedHoverPartIndex();n.updateHoverVerbosityLevel(ar.Increase,s,i==null?void 0:i.focus)}}class t5 extends lt{constructor(){super({id:Ky,label:vB,alias:"Decrease Hover Verbosity Level",precondition:B.hoverVisible})}run(e,t,i){var r;const n=eo.get(t);if(!n)return;const s=(i==null?void 0:i.index)!==void 0?i.index:n.focusedHoverPartIndex();(r=eo.get(t))==null||r.updateHoverVerbosityLevel(ar.Decrease,s,i==null?void 0:i.focus)}}var i5=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},nS=function(o,e){return function(t,i){e(t,i,o)}};const _r=si;class n5{constructor(e,t,i){this.owner=e,this.range=t,this.marker=i}isValidForHoverAnchor(e){return e.type===1&&this.range.startColumn<=e.range.startColumn&&this.range.endColumn>=e.range.endColumn}}const mE={type:1,filter:{include:Fn.QuickFix},triggerAction:Ro.QuickFixHover};let L1=class{constructor(e,t,i,n){this._editor=e,this._markerDecorationsService=t,this._openerService=i,this._languageFeaturesService=n,this.hoverOrdinal=1,this.recentMarkerCodeActionsInfo=void 0}computeSync(e,t){if(!this._editor.hasModel()||e.type!==1&&!e.supportsMarkerHover)return[];const i=this._editor.getModel(),n=e.range.startLineNumber,s=i.getLineMaxColumn(n),r=[];for(const a of t){const d=a.range.startLineNumber===n?a.range.startColumn:1,u=a.range.endLineNumber===n?a.range.endColumn:s,f=this._markerDecorationsService.getMarker(i.uri,a);if(!f)continue;const g=new Z(e.range.startLineNumber,d,e.range.startLineNumber,u);r.push(new n5(this,g,f))}return r}renderHoverParts(e,t){if(!t.length)return new Du([]);const i=new Lt,n=[];t.forEach(r=>{const a=this._renderMarkerHover(r);e.fragment.appendChild(a.hoverElement),n.push(a)});const s=t.length===1?t[0]:t.sort((r,a)=>so.compare(r.marker.severity,a.marker.severity))[0];return this.renderMarkerStatusbar(e,s,i),new Du(n)}_renderMarkerHover(e){const t=new Lt,i=_r("div.hover-row"),n=ei(i,_r("div.marker.hover-contents")),{source:s,message:r,code:a,relatedInformation:d}=e.marker;this._editor.applyFontInfo(n);const u=ei(n,_r("span"));if(u.style.whiteSpace="pre-wrap",u.innerText=r,s||a)if(a&&typeof a!="string"){const g=_r("span");if(s){const x=ei(g,_r("span"));x.innerText=s}const p=ei(g,_r("a.code-link"));p.setAttribute("href",a.target.toString()),t.add(wn(p,"click",x=>{this._openerService.open(a.target,{allowCommands:!0}),x.preventDefault(),x.stopPropagation()}));const w=ei(p,_r("span"));w.innerText=a.value;const y=ei(n,g);y.style.opacity="0.6",y.style.paddingLeft="6px"}else{const g=ei(n,_r("span"));g.style.opacity="0.6",g.style.paddingLeft="6px",g.innerText=s&&a?`${s}(${a})`:s||`(${a})`}if($o(d))for(const{message:g,resource:p,startLineNumber:w,startColumn:y}of d){const x=ei(n,_r("div"));x.style.marginTop="8px";const k=ei(x,_r("a"));k.innerText=`${$a(p)}(${w}, ${y}): `,k.style.cursor="pointer",t.add(wn(k,"click",M=>{if(M.stopPropagation(),M.preventDefault(),this._openerService){const F={selection:{startLineNumber:w,startColumn:y}};this._openerService.open(p,{fromUserGesture:!0,editorOptions:F}).catch(Nn)}}));const D=ei(x,_r("span"));D.innerText=g,this._editor.applyFontInfo(D)}return{hoverPart:e,hoverElement:i,dispose:()=>t.dispose()}}renderMarkerStatusbar(e,t,i){if(t.marker.severity===so.Error||t.marker.severity===so.Warning||t.marker.severity===so.Info){const n=Mu.get(this._editor);n&&e.statusBar.addAction({label:C("view problem","View Problem"),commandId:Qv.ID,run:()=>{e.hide(),n.showAtMarker(t.marker),this._editor.focus()}})}if(!this._editor.getOption(92)){const n=e.statusBar.append(_r("div"));this.recentMarkerCodeActionsInfo&&(PL.makeKey(this.recentMarkerCodeActionsInfo.marker)===PL.makeKey(t.marker)?this.recentMarkerCodeActionsInfo.hasCodeActions||(n.textContent=C("noQuickFixes","No quick fixes available")):this.recentMarkerCodeActionsInfo=void 0);const s=this.recentMarkerCodeActionsInfo&&!this.recentMarkerCodeActionsInfo.hasCodeActions?Dt.None:dp(()=>n.textContent=C("checkingForQuickFixes","Checking for quick fixes..."),200,i);n.textContent||(n.textContent=" ");const r=this.getCodeActions(t.marker);i.add(jn(()=>r.cancel())),r.then(a=>{if(s.dispose(),this.recentMarkerCodeActionsInfo={marker:t.marker,hasCodeActions:a.validActions.length>0},!this.recentMarkerCodeActionsInfo.hasCodeActions){a.dispose(),n.textContent=C("noQuickFixes","No quick fixes available");return}n.style.display="none";let d=!1;i.add(jn(()=>{d||a.dispose()})),e.statusBar.addAction({label:C("quick fixes","Quick Fix..."),commandId:$0,run:u=>{d=!0;const f=If.get(this._editor),g=mo(u);e.hide(),f==null||f.showCodeActions(mE,a,{x:g.left,y:g.top,width:g.width,height:g.height})}})},Nn)}}getCodeActions(e){return Os(t=>Eh(this._languageFeaturesService.codeActionProvider,this._editor.getModel(),new Z(e.startLineNumber,e.startColumn,e.endLineNumber,e.endColumn),mE,dl.None,t))}};L1=i5([nS(1,dF),nS(2,ua),nS(3,pi)],L1);class s5{get lineNumber(){return this._lineNumber}set lineNumber(e){this._lineNumber=e}get lane(){return this._laneOrLine}set lane(e){this._laneOrLine=e}constructor(e){this._editor=e,this._lineNumber=-1,this._laneOrLine=tv.Center}computeSync(){var s;const e=r=>({value:r}),t=this._editor.getLineDecorations(this._lineNumber),i=[],n=this._laneOrLine==="lineNo";if(!t)return i;for(const r of t){const a=((s=r.options.glyphMargin)==null?void 0:s.position)??tv.Center;if(!n&&a!==this._laneOrLine)continue;const d=n?r.options.lineNumberHoverMessage:r.options.glyphMarginHoverMessage;!d||pp(d)||i.push(...YD(d).map(e))}return i}}var o5=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},vE=function(o,e){return function(t,i){e(t,i,o)}},I1;const bE=si;var tu;let E1=(tu=class extends Dt{constructor(e,t,i){super(),this._renderDisposeables=this._register(new Lt),this._editor=e,this._isVisible=!1,this._messages=[],this._hover=this._register(new ZD),this._hover.containerDomNode.classList.toggle("hidden",!this._isVisible),this._markdownRenderer=this._register(new Uf({editor:this._editor},t,i)),this._computer=new s5(this._editor),this._hoverOperation=this._register(new cR(this._editor,this._computer)),this._register(this._hoverOperation.onResult(n=>{this._withResult(n.value)})),this._register(this._editor.onDidChangeModelDecorations(()=>this._onModelDecorationsChanged())),this._register(this._editor.onDidChangeConfiguration(n=>{n.hasChanged(50)&&this._updateFont()})),this._register(Cl(this._hover.containerDomNode,"mouseleave",n=>{this._onMouseLeave(n)})),this._editor.addOverlayWidget(this)}dispose(){this._editor.removeOverlayWidget(this),super.dispose()}getId(){return I1.ID}getDomNode(){return this._hover.containerDomNode}getPosition(){return null}_updateFont(){Array.prototype.slice.call(this._hover.contentsDomNode.getElementsByClassName("code")).forEach(t=>this._editor.applyFontInfo(t))}_onModelDecorationsChanged(){this._isVisible&&(this._hoverOperation.cancel(),this._hoverOperation.start(0))}showsOrWillShow(e){const t=e.target;return t.type===2&&t.detail.glyphMarginLane?(this._startShowingAt(t.position.lineNumber,t.detail.glyphMarginLane),!0):t.type===3?(this._startShowingAt(t.position.lineNumber,"lineNo"),!0):!1}_startShowingAt(e,t){this._computer.lineNumber===e&&this._computer.lane===t||(this._hoverOperation.cancel(),this.hide(),this._computer.lineNumber=e,this._computer.lane=t,this._hoverOperation.start(0))}hide(){this._computer.lineNumber=-1,this._hoverOperation.cancel(),this._isVisible&&(this._isVisible=!1,this._hover.containerDomNode.classList.toggle("hidden",!this._isVisible))}_withResult(e){this._messages=e,this._messages.length>0?this._renderMessages(this._computer.lineNumber,this._messages):this.hide()}_renderMessages(e,t){this._renderDisposeables.clear();const i=document.createDocumentFragment();for(const n of t){const s=bE("div.hover-row.markdown-hover"),r=ei(s,bE("div.hover-contents")),a=this._renderDisposeables.add(this._markdownRenderer.render(n.value));r.appendChild(a.element),i.appendChild(s)}this._updateContents(i),this._showAt(e)}_updateContents(e){this._hover.contentsDomNode.textContent="",this._hover.contentsDomNode.appendChild(e),this._updateFont()}_showAt(e){this._isVisible||(this._isVisible=!0,this._hover.containerDomNode.classList.toggle("hidden",!this._isVisible));const t=this._editor.getLayoutInfo(),i=this._editor.getTopForLineNumber(e),n=this._editor.getScrollTop(),s=this._editor.getOption(67),r=this._hover.containerDomNode.clientHeight,a=i-n-(r-s)/2,d=t.glyphMarginLeft+t.glyphMarginWidth+(this._computer.lane==="lineNo"?t.lineNumbersWidth:0);this._hover.containerDomNode.style.left=`${d}px`,this._hover.containerDomNode.style.top=`${Math.max(Math.round(a),0)}px`}_onMouseLeave(e){const t=this._editor.getDomNode();(!t||!Zy(t,e.x,e.y))&&this.hide()}},I1=tu,tu.ID="editor.contrib.modesGlyphHoverWidget",tu);E1=I1=o5([vE(1,fa),vE(2,ua)],E1);var r5=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},a5=function(o,e){return function(t,i){e(t,i,o)}},of;let Jv=(of=class extends Dt{constructor(e,t){super(),this._editor=e,this._instantiationService=t,this.shouldKeepOpenOnEditorMouseMoveOrLeave=!1,this._listenersStore=new Lt,this._hoverState={mouseDown:!1},this._reactToEditorMouseMoveRunner=this._register(new Ss(()=>this._reactToEditorMouseMove(this._mouseMoveEvent),0)),this._hookListeners(),this._register(this._editor.onDidChangeConfiguration(i=>{i.hasChanged(60)&&(this._unhookListeners(),this._hookListeners())}))}_hookListeners(){const e=this._editor.getOption(60);this._hoverSettings={enabled:e.enabled,sticky:e.sticky,hidingDelay:e.hidingDelay},e.enabled?(this._listenersStore.add(this._editor.onMouseDown(t=>this._onEditorMouseDown(t))),this._listenersStore.add(this._editor.onMouseUp(()=>this._onEditorMouseUp())),this._listenersStore.add(this._editor.onMouseMove(t=>this._onEditorMouseMove(t))),this._listenersStore.add(this._editor.onKeyDown(t=>this._onKeyDown(t)))):(this._listenersStore.add(this._editor.onMouseMove(t=>this._onEditorMouseMove(t))),this._listenersStore.add(this._editor.onKeyDown(t=>this._onKeyDown(t)))),this._listenersStore.add(this._editor.onMouseLeave(t=>this._onEditorMouseLeave(t))),this._listenersStore.add(this._editor.onDidChangeModel(()=>{this._cancelScheduler(),this._hideWidgets()})),this._listenersStore.add(this._editor.onDidChangeModelContent(()=>this._cancelScheduler())),this._listenersStore.add(this._editor.onDidScrollChange(t=>this._onEditorScrollChanged(t)))}_unhookListeners(){this._listenersStore.clear()}_cancelScheduler(){this._mouseMoveEvent=void 0,this._reactToEditorMouseMoveRunner.cancel()}_onEditorScrollChanged(e){(e.scrollTopChanged||e.scrollLeftChanged)&&this._hideWidgets()}_onEditorMouseDown(e){this._hoverState.mouseDown=!0,!this._isMouseOnMarginHoverWidget(e)&&this._hideWidgets()}_isMouseOnMarginHoverWidget(e){var i;const t=(i=this._glyphWidget)==null?void 0:i.getDomNode();return t?Zy(t,e.event.posx,e.event.posy):!1}_onEditorMouseUp(){this._hoverState.mouseDown=!1}_onEditorMouseLeave(e){this.shouldKeepOpenOnEditorMouseMoveOrLeave||(this._cancelScheduler(),this._isMouseOnMarginHoverWidget(e))||this._hideWidgets()}_shouldNotRecomputeCurrentHoverWidget(e){const t=this._hoverSettings.sticky,i=this._isMouseOnMarginHoverWidget(e);return t&&i}_onEditorMouseMove(e){if(this.shouldKeepOpenOnEditorMouseMoveOrLeave)return;if(this._mouseMoveEvent=e,this._shouldNotRecomputeCurrentHoverWidget(e)){this._reactToEditorMouseMoveRunner.cancel();return}this._reactToEditorMouseMove(e)}_reactToEditorMouseMove(e){!e||this._tryShowHoverWidget(e)||this._hideWidgets()}_tryShowHoverWidget(e){return this._getOrCreateGlyphWidget().showsOrWillShow(e)}_onKeyDown(e){this._editor.hasModel()&&(e.keyCode===5||e.keyCode===6||e.keyCode===57||e.keyCode===4||this._hideWidgets())}_hideWidgets(){var e;(e=this._glyphWidget)==null||e.hide()}_getOrCreateGlyphWidget(){return this._glyphWidget||(this._glyphWidget=this._instantiationService.createInstance(E1,this._editor)),this._glyphWidget}dispose(){var e;super.dispose(),this._unhookListeners(),this._listenersStore.dispose(),(e=this._glyphWidget)==null||e.dispose()}},of.ID="editor.contrib.marginHover",of);Jv=r5([a5(1,Zi)],Jv);class l5{}class c5{}class d5{}nn(eo.ID,eo,2);nn(Jv.ID,Jv,2);xe($j);xe(Uj);xe(qj);xe(Gj);xe(Kj);xe(Zj);xe(Yj);xe(Xj);xe(Qj);xe(Jj);xe(e5);xe(t5);ju.register(Pp);ju.register(L1);Sy((o,e)=>{const t=o.getColor(uF);t&&(e.addRule(`.monaco-editor .monaco-hover .hover-row:not(:first-child):not(:empty) { border-top: 1px solid ${t.transparent(.5)}; }`),e.addRule(`.monaco-editor .monaco-hover hr { border-top: 1px solid ${t.transparent(.5)}; }`),e.addRule(`.monaco-editor .monaco-hover hr { border-bottom: 0px solid ${t.transparent(.5)}; }`))});sw.register(new l5);sw.register(new c5);sw.register(new d5);function ko(o,e){let t=0;for(let i=0;i<o.length;i++)o.charAt(i)===" "?t+=e:t++;return t}function ep(o,e,t){o=o<0?0:o;let i="";if(!t){const n=Math.floor(o/e);o=o%e;for(let s=0;s<n;s++)i+=" "}for(let n=0;n<o;n++)i+=" ";return i}function iN(o,e,t,i){if(o.getLineCount()===1&&o.getLineMaxColumn(1)===1)return[];const n=e.getLanguageConfiguration(o.getLanguageId()).indentRulesSupport;if(!n)return[];const s=new hF(o,n,e);for(i=Math.min(i,o.getLineCount());t<=i&&s.shouldIgnore(t);)t++;if(t>i-1)return[];const{tabSize:r,indentSize:a,insertSpaces:d}=o.getOptions(),u=(x,k)=>(k=k||1,yf.shiftIndent(x,x.length+k,r,a,d)),f=(x,k)=>(k=k||1,yf.unshiftIndent(x,x.length+k,r,a,d)),g=[],p=o.getLineContent(t);let w=Ks(p),y=w;s.shouldIncrease(t)?(y=u(y),w=u(w)):s.shouldIndentNextLine(t)&&(y=u(y)),t++;for(let x=t;x<=i;x++){if(u5(o,x))continue;const k=o.getLineContent(x),D=Ks(k),M=y;s.shouldDecrease(x,M)&&(y=f(y),w=f(w)),D!==y&&g.push(Qn.replaceMove(new Fi(x,1,x,D.length+1),fF(y,a,d))),!s.shouldIgnore(x)&&(s.shouldIncrease(x,M)?(w=u(w),y=w):s.shouldIndentNextLine(x,M)?y=u(y):y=w)}return g}function u5(o,e){return o.tokenization.isCheapToTokenize(e)?o.tokenization.getLineTokens(e).getStandardTokenType(0)===2:!1}var h5=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},f5=function(o,e){return function(t,i){e(t,i,o)}};const qb=class qb extends lt{constructor(){super({id:qb.ID,label:C("indentationToSpaces","Convert Indentation to Spaces"),alias:"Convert Indentation to Spaces",precondition:B.writable,metadata:{description:ui("indentationToSpacesDescription","Convert the tab indentation to spaces.")}})}run(e,t){const i=t.getModel();if(!i)return;const n=i.getOptions(),s=t.getSelection();if(!s)return;const r=new v5(s,n.tabSize);t.pushUndoStop(),t.executeCommands(this.id,[r]),t.pushUndoStop(),i.updateOptions({insertSpaces:!0})}};qb.ID="editor.action.indentationToSpaces";let D1=qb;const Gb=class Gb extends lt{constructor(){super({id:Gb.ID,label:C("indentationToTabs","Convert Indentation to Tabs"),alias:"Convert Indentation to Tabs",precondition:B.writable,metadata:{description:ui("indentationToTabsDescription","Convert the spaces indentation to tabs.")}})}run(e,t){const i=t.getModel();if(!i)return;const n=i.getOptions(),s=t.getSelection();if(!s)return;const r=new b5(s,n.tabSize);t.pushUndoStop(),t.executeCommands(this.id,[r]),t.pushUndoStop(),i.updateOptions({insertSpaces:!1})}};Gb.ID="editor.action.indentationToTabs";let T1=Gb;class _k extends lt{constructor(e,t,i){super(i),this.insertSpaces=e,this.displaySizeOnly=t}run(e,t){const i=e.get(Ml),n=e.get(uo),s=t.getModel();if(!s)return;const r=n.getCreationOptions(s.getLanguageId(),s.uri,s.isForSimpleWidget),a=s.getOptions(),d=[1,2,3,4,5,6,7,8].map(f=>({id:f.toString(),label:f.toString(),description:f===r.tabSize&&f===a.tabSize?C("configuredTabSize","Configured Tab Size"):f===r.tabSize?C("defaultTabSize","Default Tab Size"):f===a.tabSize?C("currentTabSize","Current Tab Size"):void 0})),u=Math.min(s.getOptions().tabSize-1,7);setTimeout(()=>{i.pick(d,{placeHolder:C({key:"selectTabWidth",comment:["Tab corresponds to the tab key"]},"Select Tab Size for Current File"),activeItem:d[u]}).then(f=>{if(f&&s&&!s.isDisposed()){const g=parseInt(f.label,10);this.displaySizeOnly?s.updateOptions({tabSize:g}):s.updateOptions({tabSize:g,indentSize:g,insertSpaces:this.insertSpaces})}})},50)}}const Kb=class Kb extends _k{constructor(){super(!1,!1,{id:Kb.ID,label:C("indentUsingTabs","Indent Using Tabs"),alias:"Indent Using Tabs",precondition:void 0,metadata:{description:ui("indentUsingTabsDescription","Use indentation with tabs.")}})}};Kb.ID="editor.action.indentUsingTabs";let P1=Kb;const Zb=class Zb extends _k{constructor(){super(!0,!1,{id:Zb.ID,label:C("indentUsingSpaces","Indent Using Spaces"),alias:"Indent Using Spaces",precondition:void 0,metadata:{description:ui("indentUsingSpacesDescription","Use indentation with spaces.")}})}};Zb.ID="editor.action.indentUsingSpaces";let M1=Zb;const Yb=class Yb extends _k{constructor(){super(!0,!0,{id:Yb.ID,label:C("changeTabDisplaySize","Change Tab Display Size"),alias:"Change Tab Display Size",precondition:void 0,metadata:{description:ui("changeTabDisplaySizeDescription","Change the space size equivalent of the tab.")}})}};Yb.ID="editor.action.changeTabDisplaySize";let R1=Yb;const Xb=class Xb extends lt{constructor(){super({id:Xb.ID,label:C("detectIndentation","Detect Indentation from Content"),alias:"Detect Indentation from Content",precondition:void 0,metadata:{description:ui("detectIndentationDescription","Detect the indentation from content.")}})}run(e,t){const i=e.get(uo),n=t.getModel();if(!n)return;const s=i.getCreationOptions(n.getLanguageId(),n.uri,n.isForSimpleWidget);n.detectIndentation(s.insertSpaces,s.tabSize)}};Xb.ID="editor.action.detectIndentation";let N1=Xb;class g5 extends lt{constructor(){super({id:"editor.action.reindentlines",label:C("editor.reindentlines","Reindent Lines"),alias:"Reindent Lines",precondition:B.writable,metadata:{description:ui("editor.reindentlinesDescription","Reindent the lines of the editor.")}})}run(e,t){const i=e.get(Ds),n=t.getModel();if(!n)return;const s=iN(n,i,1,n.getLineCount());s.length>0&&(t.pushUndoStop(),t.executeEdits(this.id,s),t.pushUndoStop())}}class p5 extends lt{constructor(){super({id:"editor.action.reindentselectedlines",label:C("editor.reindentselectedlines","Reindent Selected Lines"),alias:"Reindent Selected Lines",precondition:B.writable,metadata:{description:ui("editor.reindentselectedlinesDescription","Reindent the selected lines of the editor.")}})}run(e,t){const i=e.get(Ds),n=t.getModel();if(!n)return;const s=t.getSelections();if(s===null)return;const r=[];for(const a of s){let d=a.startLineNumber,u=a.endLineNumber;if(d!==u&&a.endColumn===1&&u--,d===1){if(d===u)continue}else d--;const f=iN(n,i,d,u);r.push(...f)}r.length>0&&(t.pushUndoStop(),t.executeEdits(this.id,r),t.pushUndoStop())}}class _5{constructor(e,t){this._initialSelection=t,this._edits=[],this._selectionId=null;for(const i of e)i.range&&typeof i.text=="string"&&this._edits.push(i)}getEditOperations(e,t){for(const n of this._edits)t.addEditOperation(Z.lift(n.range),n.text);let i=!1;Array.isArray(this._edits)&&this._edits.length===1&&this._initialSelection.isEmpty()&&(this._edits[0].range.startColumn===this._initialSelection.endColumn&&this._edits[0].range.startLineNumber===this._initialSelection.endLineNumber?(i=!0,this._selectionId=t.trackSelection(this._initialSelection,!0)):this._edits[0].range.endColumn===this._initialSelection.startColumn&&this._edits[0].range.endLineNumber===this._initialSelection.startLineNumber&&(i=!0,this._selectionId=t.trackSelection(this._initialSelection,!1))),i||(this._selectionId=t.trackSelection(this._initialSelection))}computeCursorState(e,t){return t.getTrackedSelection(this._selectionId)}}var rf;let eb=(rf=class{constructor(e,t){this.editor=e,this._languageConfigurationService=t,this.callOnDispose=new Lt,this.callOnModel=new Lt,this.callOnDispose.add(e.onDidChangeConfiguration(()=>this.update())),this.callOnDispose.add(e.onDidChangeModel(()=>this.update())),this.callOnDispose.add(e.onDidChangeModelLanguage(()=>this.update()))}update(){this.callOnModel.clear(),!(this.editor.getOption(12)<4||this.editor.getOption(55))&&this.editor.hasModel()&&this.callOnModel.add(this.editor.onDidPaste(({range:e})=>{this.trigger(e)}))}trigger(e){const t=this.editor.getSelections();if(t===null||t.length>1)return;const i=this.editor.getModel();if(!i||this.rangeContainsOnlyWhitespaceCharacters(i,e)||m5(i,e)||!i.tokenization.isCheapToTokenize(e.getStartPosition().lineNumber))return;const s=this.editor.getOption(12),{tabSize:r,indentSize:a,insertSpaces:d}=i.getOptions(),u=[],f={shiftIndent:y=>yf.shiftIndent(y,y.length+1,r,a,d),unshiftIndent:y=>yf.unshiftIndent(y,y.length+1,r,a,d)};let g=e.startLineNumber;for(;g<=e.endLineNumber;){if(this.shouldIgnoreLine(i,g)){g++;continue}break}if(g>e.endLineNumber)return;let p=i.getLineContent(g);if(!/\S/.test(p.substring(0,e.startColumn-1))){const y=jg(s,i,i.getLanguageId(),g,f,this._languageConfigurationService);if(y!==null){const x=Ks(p),k=ko(y,r),D=ko(x,r);if(k!==D){const M=ep(k,r,d);u.push({range:new Z(g,1,g,x.length+1),text:M}),p=M+p.substring(x.length)}else{const M=BT(i,g,this._languageConfigurationService);if(M===0||M===8)return}}}const w=g;for(;g<e.endLineNumber;){if(!/\S/.test(i.getLineContent(g+1))){g++;continue}break}if(g!==e.endLineNumber){const x=jg(s,{tokenization:{getLineTokens:k=>i.tokenization.getLineTokens(k),getLanguageId:()=>i.getLanguageId(),getLanguageIdAtPosition:(k,D)=>i.getLanguageIdAtPosition(k,D)},getLineContent:k=>k===w?p:i.getLineContent(k)},i.getLanguageId(),g+1,f,this._languageConfigurationService);if(x!==null){const k=ko(x,r),D=ko(Ks(i.getLineContent(g+1)),r);if(k!==D){const M=k-D;for(let F=g+1;F<=e.endLineNumber;F++){const K=i.getLineContent(F),V=Ks(K),te=ko(V,r)+M,pe=ep(te,r,d);pe!==V&&u.push({range:new Z(F,1,F,V.length+1),text:pe})}}}}if(u.length>0){this.editor.pushUndoStop();const y=new _5(u,this.editor.getSelection());this.editor.executeCommand("autoIndentOnPaste",y),this.editor.pushUndoStop()}}rangeContainsOnlyWhitespaceCharacters(e,t){const i=s=>s.trim().length===0;let n=!0;if(t.startLineNumber===t.endLineNumber){const r=e.getLineContent(t.startLineNumber).substring(t.startColumn-1,t.endColumn-1);n=i(r)}else for(let s=t.startLineNumber;s<=t.endLineNumber;s++){const r=e.getLineContent(s);if(s===t.startLineNumber){const a=r.substring(t.startColumn-1);n=i(a)}else if(s===t.endLineNumber){const a=r.substring(0,t.endColumn-1);n=i(a)}else n=e.getLineFirstNonWhitespaceColumn(s)===0;if(!n)break}return n}shouldIgnoreLine(e,t){e.tokenization.forceTokenization(t);const i=e.getLineFirstNonWhitespaceColumn(t);if(i===0)return!0;const n=e.tokenization.getLineTokens(t);if(n.getCount()>0){const s=n.findTokenIndexAtOffset(i);if(s>=0&&n.getStandardTokenType(s)===1)return!0}return!1}dispose(){this.callOnDispose.dispose(),this.callOnModel.dispose()}},rf.ID="editor.contrib.autoIndentOnPaste",rf);eb=h5([f5(1,Ds)],eb);function m5(o,e){const t=i=>gF(o,i)===2;return t(e.getStartPosition())||t(e.getEndPosition())}function nN(o,e,t,i){if(o.getLineCount()===1&&o.getLineMaxColumn(1)===1)return;let n="";for(let r=0;r<t;r++)n+=" ";const s=new RegExp(n,"gi");for(let r=1,a=o.getLineCount();r<=a;r++){let d=o.getLineFirstNonWhitespaceColumn(r);if(d===0&&(d=o.getLineMaxColumn(r)),d===1)continue;const u=new Z(r,1,r,d),f=o.getValueInRange(u),g=i?f.replace(/\t/ig,n):f.replace(s," ");e.addEditOperation(u,g)}}class v5{constructor(e,t){this.selection=e,this.tabSize=t,this.selectionId=null}getEditOperations(e,t){this.selectionId=t.trackSelection(this.selection),nN(e,t,this.tabSize,!0)}computeCursorState(e,t){return t.getTrackedSelection(this.selectionId)}}class b5{constructor(e,t){this.selection=e,this.tabSize=t,this.selectionId=null}getEditOperations(e,t){this.selectionId=t.trackSelection(this.selection),nN(e,t,this.tabSize,!1)}computeCursorState(e,t){return t.getTrackedSelection(this.selectionId)}}nn(eb.ID,eb,2);xe(D1);xe(T1);xe(P1);xe(M1);xe(R1);xe(N1);xe(g5);xe(p5);nn(Rp.ID,Rp,1);ju.register(Mv);class y5{constructor(e,t,i){this._editRange=e,this._originalSelection=t,this._text=i}getEditOperations(e,t){t.addTrackedEditOperation(this._editRange,this._text)}computeCursorState(e,t){const n=t.getInverseEditOperations()[0].range;return this._originalSelection.isEmpty()?new Fi(n.endLineNumber,Math.min(this._originalSelection.positionColumn,n.endColumn),n.endLineNumber,Math.min(this._originalSelection.positionColumn,n.endColumn)):new Fi(n.endLineNumber,n.endColumn-this._text.length,n.endLineNumber,n.endColumn)}}var w5=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},S5=function(o,e){return function(t,i){e(t,i,o)}},qm,Lc;let Of=(Lc=class{static get(e){return e.getContribution(qm.ID)}constructor(e,t){this.editor=e,this.editorWorkerService=t,this.decorations=this.editor.createDecorationsCollection()}dispose(){}run(e,t){var d;(d=this.currentRequest)==null||d.cancel();const i=this.editor.getSelection(),n=this.editor.getModel();if(!n||!i)return;let s=i;if(s.startLineNumber!==s.endLineNumber)return;const r=new WT(this.editor,5),a=n.uri;return this.editorWorkerService.canNavigateValueSet(a)?(this.currentRequest=Os(u=>this.editorWorkerService.navigateValueSet(a,s,t)),this.currentRequest.then(u=>{var y;if(!u||!u.range||!u.value||!r.validate(this.editor))return;const f=Z.lift(u.range);let g=u.range;const p=u.value.length-(s.endColumn-s.startColumn);g={startLineNumber:g.startLineNumber,startColumn:g.startColumn,endLineNumber:g.endLineNumber,endColumn:g.startColumn+u.value.length},p>1&&(s=new Fi(s.startLineNumber,s.startColumn,s.endLineNumber,s.endColumn+p-1));const w=new y5(f,s,u.value);this.editor.pushUndoStop(),this.editor.executeCommand(e,w),this.editor.pushUndoStop(),this.decorations.set([{range:g,options:qm.DECORATION}]),(y=this.decorationRemover)==null||y.cancel(),this.decorationRemover=Py(350),this.decorationRemover.then(()=>this.decorations.clear()).catch(Nn)}).catch(Nn)):Promise.resolve(void 0)}},qm=Lc,Lc.ID="editor.contrib.inPlaceReplaceController",Lc.DECORATION=dn.register({description:"in-place-replace",className:"valueSetReplacement"}),Lc);Of=qm=w5([S5(1,Al)],Of);class C5 extends lt{constructor(){super({id:"editor.action.inPlaceReplace.up",label:C("InPlaceReplaceAction.previous.label","Replace with Previous Value"),alias:"Replace with Previous Value",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:3159,weight:100}})}run(e,t){const i=Of.get(t);return i?i.run(this.id,!1):Promise.resolve(void 0)}}class x5 extends lt{constructor(){super({id:"editor.action.inPlaceReplace.down",label:C("InPlaceReplaceAction.next.label","Replace with Next Value"),alias:"Replace with Next Value",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:3161,weight:100}})}run(e,t){const i=Of.get(t);return i?i.run(this.id,!0):Promise.resolve(void 0)}}nn(Of.ID,Of,4);xe(C5);xe(x5);class k5 extends lt{constructor(){super({id:"expandLineSelection",label:C("expandLineSelection","Expand Line Selection"),alias:"Expand Line Selection",precondition:void 0,kbOpts:{weight:0,kbExpr:B.textInputFocus,primary:2090}})}run(e,t,i){if(i=i||{},!t.hasModel())return;const n=t._getViewModel();n.model.pushStackElement(),n.setCursorStates(i.source,3,_0.expandLineSelection(n,n.getCursorStates())),n.revealAllCursors(i.source,!0)}}xe(k5);class L5{constructor(e,t,i){this._selection=e,this._cursors=t,this._selectionId=null,this._trimInRegexesAndStrings=i}getEditOperations(e,t){const i=I5(e,this._cursors,this._trimInRegexesAndStrings);for(let n=0,s=i.length;n<s;n++){const r=i[n];t.addEditOperation(r.range,r.text)}this._selectionId=t.trackSelection(this._selection)}computeCursorState(e,t){return t.getTrackedSelection(this._selectionId)}}function I5(o,e,t){e.sort((a,d)=>a.lineNumber===d.lineNumber?a.column-d.column:a.lineNumber-d.lineNumber);for(let a=e.length-2;a>=0;a--)e[a].lineNumber===e[a+1].lineNumber&&e.splice(a,1);const i=[];let n=0,s=0;const r=e.length;for(let a=1,d=o.getLineCount();a<=d;a++){const u=o.getLineContent(a),f=u.length+1;let g=0;if(s<r&&e[s].lineNumber===a&&(g=e[s].column,s++,g===f)||u.length===0)continue;const p=Rm(u);let w=0;if(p===-1)w=1;else if(p!==u.length-1)w=p+2;else continue;if(!t){if(!o.tokenization.hasAccurateTokensForLine(a))continue;const y=o.tokenization.getLineTokens(a),x=y.getStandardTokenType(y.findTokenIndexAtOffset(w));if(x===2||x===3)continue}w=Math.max(g,w),i[n++]=Qn.delete(new Z(a,w,a,f))}return i}class sN{constructor(e,t,i){this._selection=e,this._isCopyingDown=t,this._noop=i||!1,this._selectionDirection=0,this._selectionId=null,this._startLineNumberDelta=0,this._endLineNumberDelta=0}getEditOperations(e,t){let i=this._selection;this._startLineNumberDelta=0,this._endLineNumberDelta=0,i.startLineNumber<i.endLineNumber&&i.endColumn===1&&(this._endLineNumberDelta=1,i=i.setEndPosition(i.endLineNumber-1,e.getLineMaxColumn(i.endLineNumber-1)));const n=[];for(let r=i.startLineNumber;r<=i.endLineNumber;r++)n.push(e.getLineContent(r));const s=n.join(`
48
- `);s===""&&this._isCopyingDown&&(this._startLineNumberDelta++,this._endLineNumberDelta++),this._noop?t.addEditOperation(new Z(i.endLineNumber,e.getLineMaxColumn(i.endLineNumber),i.endLineNumber+1,1),i.endLineNumber===e.getLineCount()?"":`
49
- `):this._isCopyingDown?t.addEditOperation(new Z(i.startLineNumber,1,i.startLineNumber,1),s+`
50
- `):t.addEditOperation(new Z(i.endLineNumber,e.getLineMaxColumn(i.endLineNumber),i.endLineNumber,e.getLineMaxColumn(i.endLineNumber)),`
51
- `+s),this._selectionId=t.trackSelection(i),this._selectionDirection=this._selection.getDirection()}computeCursorState(e,t){let i=t.getTrackedSelection(this._selectionId);if(this._startLineNumberDelta!==0||this._endLineNumberDelta!==0){let n=i.startLineNumber,s=i.startColumn,r=i.endLineNumber,a=i.endColumn;this._startLineNumberDelta!==0&&(n=n+this._startLineNumberDelta,s=1),this._endLineNumberDelta!==0&&(r=r+this._endLineNumberDelta,a=1),i=Fi.createWithDirection(n,s,r,a,this._selectionDirection)}return i}}var E5=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},D5=function(o,e){return function(t,i){e(t,i,o)}};let A1=class{constructor(e,t,i,n){this._languageConfigurationService=n,this._selection=e,this._isMovingDown=t,this._autoIndent=i,this._selectionId=null,this._moveEndLineSelectionShrink=!1}getEditOperations(e,t){const i=()=>e.getLanguageId(),n=(g,p)=>e.getLanguageIdAtPosition(g,p),s=e.getLineCount();if(this._isMovingDown&&this._selection.endLineNumber===s){this._selectionId=t.trackSelection(this._selection);return}if(!this._isMovingDown&&this._selection.startLineNumber===1){this._selectionId=t.trackSelection(this._selection);return}this._moveEndPositionDown=!1;let r=this._selection;r.startLineNumber<r.endLineNumber&&r.endColumn===1&&(this._moveEndPositionDown=!0,r=r.setEndPosition(r.endLineNumber-1,e.getLineMaxColumn(r.endLineNumber-1)));const{tabSize:a,indentSize:d,insertSpaces:u}=e.getOptions(),f=this.buildIndentConverter(a,d,u);if(r.startLineNumber===r.endLineNumber&&e.getLineMaxColumn(r.startLineNumber)===1){const g=r.startLineNumber,p=this._isMovingDown?g+1:g-1;e.getLineMaxColumn(p)===1?t.addEditOperation(new Z(1,1,1,1),null):(t.addEditOperation(new Z(g,1,g,1),e.getLineContent(p)),t.addEditOperation(new Z(p,1,p,e.getLineMaxColumn(p)),null)),r=new Fi(p,1,p,1)}else{let g,p;if(this._isMovingDown){g=r.endLineNumber+1,p=e.getLineContent(g),t.addEditOperation(new Z(g-1,e.getLineMaxColumn(g-1),g,e.getLineMaxColumn(g)),null);let w=p;if(this.shouldAutoIndent(e,r)){const y=this.matchEnterRule(e,f,a,g,r.startLineNumber-1);if(y!==null){const k=Ks(e.getLineContent(g)),D=y+ko(k,a);w=ep(D,a,u)+this.trimStart(p)}else{const k={tokenization:{getLineTokens:M=>M===r.startLineNumber?e.tokenization.getLineTokens(g):e.tokenization.getLineTokens(M),getLanguageId:i,getLanguageIdAtPosition:n},getLineContent:M=>M===r.startLineNumber?e.getLineContent(g):e.getLineContent(M)},D=jg(this._autoIndent,k,e.getLanguageIdAtPosition(g,1),r.startLineNumber,f,this._languageConfigurationService);if(D!==null){const M=Ks(e.getLineContent(g)),F=ko(D,a),K=ko(M,a);F!==K&&(w=ep(F,a,u)+this.trimStart(p))}}t.addEditOperation(new Z(r.startLineNumber,1,r.startLineNumber,1),w+`
52
- `);const x=this.matchEnterRuleMovingDown(e,f,a,r.startLineNumber,g,w);if(x!==null)x!==0&&this.getIndentEditsOfMovingBlock(e,t,r,a,u,x);else{const k={tokenization:{getLineTokens:M=>M===r.startLineNumber?e.tokenization.getLineTokens(g):M>=r.startLineNumber+1&&M<=r.endLineNumber+1?e.tokenization.getLineTokens(M-1):e.tokenization.getLineTokens(M),getLanguageId:i,getLanguageIdAtPosition:n},getLineContent:M=>M===r.startLineNumber?w:M>=r.startLineNumber+1&&M<=r.endLineNumber+1?e.getLineContent(M-1):e.getLineContent(M)},D=jg(this._autoIndent,k,e.getLanguageIdAtPosition(g,1),r.startLineNumber+1,f,this._languageConfigurationService);if(D!==null){const M=Ks(e.getLineContent(r.startLineNumber)),F=ko(D,a),K=ko(M,a);if(F!==K){const V=F-K;this.getIndentEditsOfMovingBlock(e,t,r,a,u,V)}}}}else t.addEditOperation(new Z(r.startLineNumber,1,r.startLineNumber,1),w+`
53
- `)}else if(g=r.startLineNumber-1,p=e.getLineContent(g),t.addEditOperation(new Z(g,1,g+1,1),null),t.addEditOperation(new Z(r.endLineNumber,e.getLineMaxColumn(r.endLineNumber),r.endLineNumber,e.getLineMaxColumn(r.endLineNumber)),`
54
- `+p),this.shouldAutoIndent(e,r)){const w={tokenization:{getLineTokens:x=>x===g?e.tokenization.getLineTokens(r.startLineNumber):e.tokenization.getLineTokens(x),getLanguageId:i,getLanguageIdAtPosition:n},getLineContent:x=>x===g?e.getLineContent(r.startLineNumber):e.getLineContent(x)},y=this.matchEnterRule(e,f,a,r.startLineNumber,r.startLineNumber-2);if(y!==null)y!==0&&this.getIndentEditsOfMovingBlock(e,t,r,a,u,y);else{const x=jg(this._autoIndent,w,e.getLanguageIdAtPosition(r.startLineNumber,1),g,f,this._languageConfigurationService);if(x!==null){const k=Ks(e.getLineContent(r.startLineNumber)),D=ko(x,a),M=ko(k,a);if(D!==M){const F=D-M;this.getIndentEditsOfMovingBlock(e,t,r,a,u,F)}}}}}this._selectionId=t.trackSelection(r)}buildIndentConverter(e,t,i){return{shiftIndent:n=>yf.shiftIndent(n,n.length+1,e,t,i),unshiftIndent:n=>yf.unshiftIndent(n,n.length+1,e,t,i)}}parseEnterResult(e,t,i,n,s){if(s){let r=s.indentation;s.indentAction===X_.None||s.indentAction===X_.Indent?r=s.indentation+s.appendText:s.indentAction===X_.IndentOutdent?r=s.indentation:s.indentAction===X_.Outdent&&(r=t.unshiftIndent(s.indentation)+s.appendText);const a=e.getLineContent(n);if(this.trimStart(a).indexOf(this.trimStart(r))>=0){const d=Ks(e.getLineContent(n));let u=Ks(r);const f=BT(e,n,this._languageConfigurationService);f!==null&&f&2&&(u=t.unshiftIndent(u));const g=ko(u,i),p=ko(d,i);return g-p}}return null}matchEnterRuleMovingDown(e,t,i,n,s,r){if(Rm(r)>=0){const a=e.getLineMaxColumn(s),d=kw(this._autoIndent,e,new Z(s,a,s,a),this._languageConfigurationService);return this.parseEnterResult(e,t,i,n,d)}else{let a=n-1;for(;a>=1;){const f=e.getLineContent(a);if(Rm(f)>=0)break;a--}if(a<1||n>e.getLineCount())return null;const d=e.getLineMaxColumn(a),u=kw(this._autoIndent,e,new Z(a,d,a,d),this._languageConfigurationService);return this.parseEnterResult(e,t,i,n,u)}}matchEnterRule(e,t,i,n,s,r){let a=s;for(;a>=1;){let f;if(a===s&&r!==void 0?f=r:f=e.getLineContent(a),Rm(f)>=0)break;a--}if(a<1||n>e.getLineCount())return null;const d=e.getLineMaxColumn(a),u=kw(this._autoIndent,e,new Z(a,d,a,d),this._languageConfigurationService);return this.parseEnterResult(e,t,i,n,u)}trimStart(e){return e.replace(/^\s+/,"")}shouldAutoIndent(e,t){if(this._autoIndent<4||!e.tokenization.isCheapToTokenize(t.startLineNumber))return!1;const i=e.getLanguageIdAtPosition(t.startLineNumber,1),n=e.getLanguageIdAtPosition(t.endLineNumber,1);return!(i!==n||this._languageConfigurationService.getLanguageConfiguration(i).indentRulesSupport===null)}getIndentEditsOfMovingBlock(e,t,i,n,s,r){for(let a=i.startLineNumber;a<=i.endLineNumber;a++){const d=e.getLineContent(a),u=Ks(d),g=ko(u,n)+r,p=ep(g,n,s);p!==u&&(t.addEditOperation(new Z(a,1,a,u.length+1),p),a===i.endLineNumber&&i.endColumn<=u.length+1&&p===""&&(this._moveEndLineSelectionShrink=!0))}}computeCursorState(e,t){let i=t.getTrackedSelection(this._selectionId);return this._moveEndPositionDown&&(i=i.setEndPosition(i.endLineNumber+1,1)),this._moveEndLineSelectionShrink&&i.startLineNumber<i.endLineNumber&&(i=i.setEndPosition(i.endLineNumber,2)),i}};A1=E5([D5(3,Ds)],A1);const Hh=class Hh{static getCollator(){return Hh._COLLATOR||(Hh._COLLATOR=new Intl.Collator),Hh._COLLATOR}constructor(e,t){this.selection=e,this.descending=t,this.selectionId=null}getEditOperations(e,t){const i=T5(e,this.selection,this.descending);i&&t.addEditOperation(i.range,i.text),this.selectionId=t.trackSelection(this.selection)}computeCursorState(e,t){return t.getTrackedSelection(this.selectionId)}static canRun(e,t,i){if(e===null)return!1;const n=oN(e,t,i);if(!n)return!1;for(let s=0,r=n.before.length;s<r;s++)if(n.before[s]!==n.after[s])return!0;return!1}};Hh._COLLATOR=null;let Hp=Hh;function oN(o,e,t){const i=e.startLineNumber;let n=e.endLineNumber;if(e.endColumn===1&&n--,i>=n)return null;const s=[];for(let a=i;a<=n;a++)s.push(o.getLineContent(a));let r=s.slice(0);return r.sort(Hp.getCollator().compare),t===!0&&(r=r.reverse()),{startLineNumber:i,endLineNumber:n,before:s,after:r}}function T5(o,e,t){const i=oN(o,e,t);return i?Qn.replace(new Z(i.startLineNumber,1,i.endLineNumber,o.getLineMaxColumn(i.endLineNumber)),i.after.join(`
55
- `)):null}class rN extends lt{constructor(e,t){super(t),this.down=e}run(e,t){if(!t.hasModel())return;const i=t.getSelections().map((r,a)=>({selection:r,index:a,ignore:!1}));i.sort((r,a)=>Z.compareRangesUsingStarts(r.selection,a.selection));let n=i[0];for(let r=1;r<i.length;r++){const a=i[r];n.selection.endLineNumber===a.selection.startLineNumber&&(n.index<a.index?a.ignore=!0:(n.ignore=!0,n=a))}const s=[];for(const r of i)s.push(new sN(r.selection,this.down,r.ignore));t.pushUndoStop(),t.executeCommands(this.id,s),t.pushUndoStop()}}class P5 extends rN{constructor(){super(!1,{id:"editor.action.copyLinesUpAction",label:C("lines.copyUp","Copy Line Up"),alias:"Copy Line Up",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:1552,linux:{primary:3600},weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"2_line",title:C({key:"miCopyLinesUp",comment:["&& denotes a mnemonic"]},"&&Copy Line Up"),order:1}})}}class M5 extends rN{constructor(){super(!0,{id:"editor.action.copyLinesDownAction",label:C("lines.copyDown","Copy Line Down"),alias:"Copy Line Down",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:1554,linux:{primary:3602},weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"2_line",title:C({key:"miCopyLinesDown",comment:["&& denotes a mnemonic"]},"Co&&py Line Down"),order:2}})}}class R5 extends lt{constructor(){super({id:"editor.action.duplicateSelection",label:C("duplicateSelection","Duplicate Selection"),alias:"Duplicate Selection",precondition:B.writable,menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"2_line",title:C({key:"miDuplicateSelection",comment:["&& denotes a mnemonic"]},"&&Duplicate Selection"),order:5}})}run(e,t,i){if(!t.hasModel())return;const n=[],s=t.getSelections(),r=t.getModel();for(const a of s)if(a.isEmpty())n.push(new sN(a,!0));else{const d=new Fi(a.endLineNumber,a.endColumn,a.endLineNumber,a.endColumn);n.push(new pF(d,r.getValueInRange(a)))}t.pushUndoStop(),t.executeCommands(this.id,n),t.pushUndoStop()}}class aN extends lt{constructor(e,t){super(t),this.down=e}run(e,t){const i=e.get(Ds),n=[],s=t.getSelections()||[],r=t.getOption(12);for(const a of s)n.push(new A1(a,this.down,r,i));t.pushUndoStop(),t.executeCommands(this.id,n),t.pushUndoStop()}}class N5 extends aN{constructor(){super(!1,{id:"editor.action.moveLinesUpAction",label:C("lines.moveUp","Move Line Up"),alias:"Move Line Up",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:528,linux:{primary:528},weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"2_line",title:C({key:"miMoveLinesUp",comment:["&& denotes a mnemonic"]},"Mo&&ve Line Up"),order:3}})}}class A5 extends aN{constructor(){super(!0,{id:"editor.action.moveLinesDownAction",label:C("lines.moveDown","Move Line Down"),alias:"Move Line Down",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:530,linux:{primary:530},weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"2_line",title:C({key:"miMoveLinesDown",comment:["&& denotes a mnemonic"]},"Move &&Line Down"),order:4}})}}class lN extends lt{constructor(e,t){super(t),this.descending=e}run(e,t){if(!t.hasModel())return;const i=t.getModel();let n=t.getSelections();n.length===1&&n[0].isEmpty()&&(n=[new Fi(1,1,i.getLineCount(),i.getLineMaxColumn(i.getLineCount()))]);for(const r of n)if(!Hp.canRun(t.getModel(),r,this.descending))return;const s=[];for(let r=0,a=n.length;r<a;r++)s[r]=new Hp(n[r],this.descending);t.pushUndoStop(),t.executeCommands(this.id,s),t.pushUndoStop()}}class O5 extends lN{constructor(){super(!1,{id:"editor.action.sortLinesAscending",label:C("lines.sortAscending","Sort Lines Ascending"),alias:"Sort Lines Ascending",precondition:B.writable})}}class F5 extends lN{constructor(){super(!0,{id:"editor.action.sortLinesDescending",label:C("lines.sortDescending","Sort Lines Descending"),alias:"Sort Lines Descending",precondition:B.writable})}}class H5 extends lt{constructor(){super({id:"editor.action.removeDuplicateLines",label:C("lines.deleteDuplicates","Delete Duplicate Lines"),alias:"Delete Duplicate Lines",precondition:B.writable})}run(e,t){if(!t.hasModel())return;const i=t.getModel();if(i.getLineCount()===1&&i.getLineMaxColumn(1)===1)return;const n=[],s=[];let r=0,a=!0,d=t.getSelections();d.length===1&&d[0].isEmpty()&&(d=[new Fi(1,1,i.getLineCount(),i.getLineMaxColumn(i.getLineCount()))],a=!1);for(const u of d){const f=new Set,g=[];for(let x=u.startLineNumber;x<=u.endLineNumber;x++){const k=i.getLineContent(x);f.has(k)||(g.push(k),f.add(k))}const p=new Fi(u.startLineNumber,1,u.endLineNumber,i.getLineMaxColumn(u.endLineNumber)),w=u.startLineNumber-r,y=new Fi(w,1,w+g.length-1,g[g.length-1].length);n.push(Qn.replace(p,g.join(`
56
- `))),s.push(y),r+=u.endLineNumber-u.startLineNumber+1-g.length}t.pushUndoStop(),t.executeEdits(this.id,n,a?s:void 0),t.pushUndoStop()}}const Qb=class Qb extends lt{constructor(){super({id:Qb.ID,label:C("lines.trimTrailingWhitespace","Trim Trailing Whitespace"),alias:"Trim Trailing Whitespace",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:us(2089,2102),weight:100}})}run(e,t,i){let n=[];i.reason==="auto-save"&&(n=(t.getSelections()||[]).map(f=>new gi(f.positionLineNumber,f.positionColumn)));const s=t.getSelection();if(s===null)return;const r=e.get(Un),a=t.getModel(),d=r.getValue("files.trimTrailingWhitespaceInRegexAndStrings",{overrideIdentifier:a==null?void 0:a.getLanguageId(),resource:a==null?void 0:a.uri}),u=new L5(s,n,d);t.pushUndoStop(),t.executeCommands(this.id,[u]),t.pushUndoStop()}};Qb.ID="editor.action.trimTrailingWhitespace";let O1=Qb;class W5 extends lt{constructor(){super({id:"editor.action.deleteLines",label:C("lines.delete","Delete Line"),alias:"Delete Line",precondition:B.writable,kbOpts:{kbExpr:B.textInputFocus,primary:3113,weight:100}})}run(e,t){if(!t.hasModel())return;const i=this._getLinesToRemove(t),n=t.getModel();if(n.getLineCount()===1&&n.getLineMaxColumn(1)===1)return;let s=0;const r=[],a=[];for(let d=0,u=i.length;d<u;d++){const f=i[d];let g=f.startLineNumber,p=f.endLineNumber,w=1,y=n.getLineMaxColumn(p);p<n.getLineCount()?(p+=1,y=1):g>1&&(g-=1,w=n.getLineMaxColumn(g)),r.push(Qn.replace(new Fi(g,w,p,y),"")),a.push(new Fi(g-s,f.positionColumn,g-s,f.positionColumn)),s+=f.endLineNumber-f.startLineNumber+1}t.pushUndoStop(),t.executeEdits(this.id,r,a),t.pushUndoStop()}_getLinesToRemove(e){const t=e.getSelections().map(s=>{let r=s.endLineNumber;return s.startLineNumber<s.endLineNumber&&s.endColumn===1&&(r-=1),{startLineNumber:s.startLineNumber,selectionStartColumn:s.selectionStartColumn,endLineNumber:r,positionColumn:s.positionColumn}});t.sort((s,r)=>s.startLineNumber===r.startLineNumber?s.endLineNumber-r.endLineNumber:s.startLineNumber-r.startLineNumber);const i=[];let n=t[0];for(let s=1;s<t.length;s++)n.endLineNumber+1>=t[s].startLineNumber?n.endLineNumber=t[s].endLineNumber:(i.push(n),n=t[s]);return i.push(n),i}}class B5 extends lt{constructor(){super({id:"editor.action.indentLines",label:C("lines.indent","Indent Line"),alias:"Indent Line",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:2142,weight:100}})}run(e,t){const i=t._getViewModel();i&&(t.pushUndoStop(),t.executeCommands(this.id,_F.indent(i.cursorConfig,t.getModel(),t.getSelections())),t.pushUndoStop())}}class z5 extends lt{constructor(){super({id:"editor.action.outdentLines",label:C("lines.outdent","Outdent Line"),alias:"Outdent Line",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:2140,weight:100}})}run(e,t){Mm.Outdent.runEditorCommand(e,t,null)}}class V5 extends lt{constructor(){super({id:"editor.action.insertLineBefore",label:C("lines.insertBefore","Insert Line Above"),alias:"Insert Line Above",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:3075,weight:100}})}run(e,t){const i=t._getViewModel();i&&(t.pushUndoStop(),t.executeCommands(this.id,zT.lineInsertBefore(i.cursorConfig,t.getModel(),t.getSelections())))}}class j5 extends lt{constructor(){super({id:"editor.action.insertLineAfter",label:C("lines.insertAfter","Insert Line Below"),alias:"Insert Line Below",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:2051,weight:100}})}run(e,t){const i=t._getViewModel();i&&(t.pushUndoStop(),t.executeCommands(this.id,zT.lineInsertAfter(i.cursorConfig,t.getModel(),t.getSelections())))}}class cN extends lt{run(e,t){if(!t.hasModel())return;const i=t.getSelection(),n=this._getRangesToDelete(t),s=[];for(let d=0,u=n.length-1;d<u;d++){const f=n[d],g=n[d+1];Z.intersectRanges(f,g)===null?s.push(f):n[d+1]=Z.plusRange(f,g)}s.push(n[n.length-1]);const r=this._getEndCursorState(i,s),a=s.map(d=>Qn.replace(d,""));t.pushUndoStop(),t.executeEdits(this.id,a,r),t.pushUndoStop()}}class $5 extends cN{constructor(){super({id:"deleteAllLeft",label:C("lines.deleteAllLeft","Delete All Left"),alias:"Delete All Left",precondition:B.writable,kbOpts:{kbExpr:B.textInputFocus,primary:0,mac:{primary:2049},weight:100}})}_getEndCursorState(e,t){let i=null;const n=[];let s=0;return t.forEach(r=>{let a;if(r.endColumn===1&&s>0){const d=r.startLineNumber-s;a=new Fi(d,r.startColumn,d,r.startColumn)}else a=new Fi(r.startLineNumber,r.startColumn,r.startLineNumber,r.startColumn);s+=r.endLineNumber-r.startLineNumber,r.intersectRanges(e)?i=a:n.push(a)}),i&&n.unshift(i),n}_getRangesToDelete(e){const t=e.getSelections();if(t===null)return[];let i=t;const n=e.getModel();return n===null?[]:(i.sort(Z.compareRangesUsingStarts),i=i.map(s=>{if(s.isEmpty())if(s.startColumn===1){const r=Math.max(1,s.startLineNumber-1),a=s.startLineNumber===1?1:n.getLineLength(r)+1;return new Z(r,a,s.startLineNumber,1)}else return new Z(s.startLineNumber,1,s.startLineNumber,s.startColumn);else return new Z(s.startLineNumber,1,s.endLineNumber,s.endColumn)}),i)}}class U5 extends cN{constructor(){super({id:"deleteAllRight",label:C("lines.deleteAllRight","Delete All Right"),alias:"Delete All Right",precondition:B.writable,kbOpts:{kbExpr:B.textInputFocus,primary:0,mac:{primary:297,secondary:[2068]},weight:100}})}_getEndCursorState(e,t){let i=null;const n=[];for(let s=0,r=t.length,a=0;s<r;s++){const d=t[s],u=new Fi(d.startLineNumber-a,d.startColumn,d.startLineNumber-a,d.startColumn);d.intersectRanges(e)?i=u:n.push(u)}return i&&n.unshift(i),n}_getRangesToDelete(e){const t=e.getModel();if(t===null)return[];const i=e.getSelections();if(i===null)return[];const n=i.map(s=>{if(s.isEmpty()){const r=t.getLineMaxColumn(s.startLineNumber);return s.startColumn===r?new Z(s.startLineNumber,s.startColumn,s.startLineNumber+1,1):new Z(s.startLineNumber,s.startColumn,s.startLineNumber,r)}return s});return n.sort(Z.compareRangesUsingStarts),n}}class q5 extends lt{constructor(){super({id:"editor.action.joinLines",label:C("lines.joinLines","Join Lines"),alias:"Join Lines",precondition:B.writable,kbOpts:{kbExpr:B.editorTextFocus,primary:0,mac:{primary:296},weight:100}})}run(e,t){const i=t.getSelections();if(i===null)return;let n=t.getSelection();if(n===null)return;i.sort(Z.compareRangesUsingStarts);const s=[],r=i.reduce((p,w)=>p.isEmpty()?p.endLineNumber===w.startLineNumber?(n.equalsSelection(p)&&(n=w),w):w.startLineNumber>p.endLineNumber+1?(s.push(p),w):new Fi(p.startLineNumber,p.startColumn,w.endLineNumber,w.endColumn):w.startLineNumber>p.endLineNumber?(s.push(p),w):new Fi(p.startLineNumber,p.startColumn,w.endLineNumber,w.endColumn));s.push(r);const a=t.getModel();if(a===null)return;const d=[],u=[];let f=n,g=0;for(let p=0,w=s.length;p<w;p++){const y=s[p],x=y.startLineNumber,k=1;let D=0,M,F;const K=a.getLineLength(y.endLineNumber)-y.endColumn;if(y.isEmpty()||y.startLineNumber===y.endLineNumber){const te=y.getStartPosition();te.lineNumber<a.getLineCount()?(M=x+1,F=a.getLineMaxColumn(M)):(M=te.lineNumber,F=a.getLineMaxColumn(te.lineNumber))}else M=y.endLineNumber,F=a.getLineMaxColumn(M);let V=a.getLineContent(x);for(let te=x+1;te<=M;te++){const pe=a.getLineContent(te),je=a.getLineFirstNonWhitespaceColumn(te);if(je>=1){let Ke=!0;V===""&&(Ke=!1),Ke&&(V.charAt(V.length-1)===" "||V.charAt(V.length-1)===" ")&&(Ke=!1,V=V.replace(/[\s\uFEFF\xA0]+$/g," "));const ue=pe.substr(je-1);V+=(Ke?" ":"")+ue,Ke?D=ue.length+1:D=ue.length}else D=0}const se=new Z(x,k,M,F);if(!se.isEmpty()){let te;y.isEmpty()?(d.push(Qn.replace(se,V)),te=new Fi(se.startLineNumber-g,V.length-D+1,x-g,V.length-D+1)):y.startLineNumber===y.endLineNumber?(d.push(Qn.replace(se,V)),te=new Fi(y.startLineNumber-g,y.startColumn,y.endLineNumber-g,y.endColumn)):(d.push(Qn.replace(se,V)),te=new Fi(y.startLineNumber-g,y.startColumn,y.startLineNumber-g,V.length-K)),Z.intersectRanges(se,n)!==null?f=te:u.push(te)}g+=se.endLineNumber-se.startLineNumber}u.unshift(f),t.pushUndoStop(),t.executeEdits(this.id,d,u),t.pushUndoStop()}}class G5 extends lt{constructor(){super({id:"editor.action.transpose",label:C("editor.transpose","Transpose Characters around the Cursor"),alias:"Transpose Characters around the Cursor",precondition:B.writable})}run(e,t){const i=t.getSelections();if(i===null)return;const n=t.getModel();if(n===null)return;const s=[];for(let r=0,a=i.length;r<a;r++){const d=i[r];if(!d.isEmpty())continue;const u=d.getStartPosition(),f=n.getLineMaxColumn(u.lineNumber);if(u.column>=f){if(u.lineNumber===n.getLineCount())continue;const g=new Z(u.lineNumber,Math.max(1,u.column-1),u.lineNumber+1,1),p=n.getValueInRange(g).split("").reverse().join("");s.push(new r_(new Fi(u.lineNumber,Math.max(1,u.column-1),u.lineNumber+1,1),p))}else{const g=new Z(u.lineNumber,Math.max(1,u.column-1),u.lineNumber,u.column+1),p=n.getValueInRange(g).split("").reverse().join("");s.push(new oT(g,p,new Fi(u.lineNumber,u.column+1,u.lineNumber,u.column+1)))}}t.pushUndoStop(),t.executeCommands(this.id,s),t.pushUndoStop()}}class qu extends lt{run(e,t){const i=t.getSelections();if(i===null)return;const n=t.getModel();if(n===null)return;const s=t.getOption(132),r=[];for(const a of i)if(a.isEmpty()){const d=a.getStartPosition(),u=t.getConfiguredWordAtPosition(d);if(!u)continue;const f=new Z(d.lineNumber,u.startColumn,d.lineNumber,u.endColumn),g=n.getValueInRange(f);r.push(Qn.replace(f,this._modifyText(g,s)))}else{const d=n.getValueInRange(a);r.push(Qn.replace(a,this._modifyText(d,s)))}t.pushUndoStop(),t.executeEdits(this.id,r),t.pushUndoStop()}}class K5 extends qu{constructor(){super({id:"editor.action.transformToUppercase",label:C("editor.transformToUppercase","Transform to Uppercase"),alias:"Transform to Uppercase",precondition:B.writable})}_modifyText(e,t){return e.toLocaleUpperCase()}}class Z5 extends qu{constructor(){super({id:"editor.action.transformToLowercase",label:C("editor.transformToLowercase","Transform to Lowercase"),alias:"Transform to Lowercase",precondition:B.writable})}_modifyText(e,t){return e.toLocaleLowerCase()}}class yl{constructor(e,t){this._pattern=e,this._flags=t,this._actual=null,this._evaluated=!1}get(){if(!this._evaluated){this._evaluated=!0;try{this._actual=new RegExp(this._pattern,this._flags)}catch{}}return this._actual}isSupported(){return this.get()!==null}}const Jb=class Jb extends qu{constructor(){super({id:"editor.action.transformToTitlecase",label:C("editor.transformToTitlecase","Transform to Title Case"),alias:"Transform to Title Case",precondition:B.writable})}_modifyText(e,t){const i=Jb.titleBoundary.get();return i?e.toLocaleLowerCase().replace(i,n=>n.toLocaleUpperCase()):e}};Jb.titleBoundary=new yl("(^|[^\\p{L}\\p{N}']|((^|\\P{L})'))\\p{L}","gmu");let tb=Jb;const Wh=class Wh extends qu{constructor(){super({id:"editor.action.transformToSnakecase",label:C("editor.transformToSnakecase","Transform to Snake Case"),alias:"Transform to Snake Case",precondition:B.writable})}_modifyText(e,t){const i=Wh.caseBoundary.get(),n=Wh.singleLetters.get();return!i||!n?e:e.replace(i,"$1_$2").replace(n,"$1_$2$3").toLocaleLowerCase()}};Wh.caseBoundary=new yl("(\\p{Ll})(\\p{Lu})","gmu"),Wh.singleLetters=new yl("(\\p{Lu}|\\p{N})(\\p{Lu})(\\p{Ll})","gmu");let tp=Wh;const ey=class ey extends qu{constructor(){super({id:"editor.action.transformToCamelcase",label:C("editor.transformToCamelcase","Transform to Camel Case"),alias:"Transform to Camel Case",precondition:B.writable})}_modifyText(e,t){const i=ey.wordBoundary.get();if(!i)return e;const n=e.split(i);return n.shift()+n.map(r=>r.substring(0,1).toLocaleUpperCase()+r.substring(1)).join("")}};ey.wordBoundary=new yl("[_\\s-]","gm");let ib=ey;const Bh=class Bh extends qu{constructor(){super({id:"editor.action.transformToPascalcase",label:C("editor.transformToPascalcase","Transform to Pascal Case"),alias:"Transform to Pascal Case",precondition:B.writable})}_modifyText(e,t){const i=Bh.wordBoundary.get(),n=Bh.wordBoundaryToMaintain.get();return!i||!n?e:e.split(n).map(a=>a.split(i)).flat().map(a=>a.substring(0,1).toLocaleUpperCase()+a.substring(1)).join("")}};Bh.wordBoundary=new yl("[_\\s-]","gm"),Bh.wordBoundaryToMaintain=new yl("(?<=\\.)","gm");let nb=Bh;const Ql=class Ql extends qu{static isSupported(){return[this.caseBoundary,this.singleLetters,this.underscoreBoundary].every(t=>t.isSupported())}constructor(){super({id:"editor.action.transformToKebabcase",label:C("editor.transformToKebabcase","Transform to Kebab Case"),alias:"Transform to Kebab Case",precondition:B.writable})}_modifyText(e,t){const i=Ql.caseBoundary.get(),n=Ql.singleLetters.get(),s=Ql.underscoreBoundary.get();return!i||!n||!s?e:e.replace(s,"$1-$3").replace(i,"$1-$2").replace(n,"$1-$2").toLocaleLowerCase()}};Ql.caseBoundary=new yl("(\\p{Ll})(\\p{Lu})","gmu"),Ql.singleLetters=new yl("(\\p{Lu}|\\p{N})(\\p{Lu}\\p{Ll})","gmu"),Ql.underscoreBoundary=new yl("(\\S)(_)(\\S)","gm");let sb=Ql;xe(P5);xe(M5);xe(R5);xe(N5);xe(A5);xe(O5);xe(F5);xe(H5);xe(O1);xe(W5);xe(B5);xe(z5);xe(V5);xe(j5);xe($5);xe(U5);xe(q5);xe(G5);xe(K5);xe(Z5);tp.caseBoundary.isSupported()&&tp.singleLetters.isSupported()&&xe(tp);ib.wordBoundary.isSupported()&&xe(ib);nb.wordBoundary.isSupported()&&xe(nb);tb.titleBoundary.isSupported()&&xe(tb);sb.isSupported()&&xe(sb);var Y5=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},vm=function(o,e){return function(t,i){e(t,i,o)}},Gm;const dN=new _n("LinkedEditingInputVisible",!1),X5="linked-editing-decoration";var Ic;let Ff=(Ic=class extends Dt{static get(e){return e.getContribution(Gm.ID)}constructor(e,t,i,n,s){super(),this.languageConfigurationService=n,this._syncRangesToken=0,this._localToDispose=this._register(new Lt),this._editor=e,this._providers=i.linkedEditingRangeProvider,this._enabled=!1,this._visibleContextKey=dN.bindTo(t),this._debounceInformation=s.for(this._providers,"Linked Editing",{max:200}),this._currentDecorations=this._editor.createDecorationsCollection(),this._languageWordPattern=null,this._currentWordPattern=null,this._ignoreChangeEvent=!1,this._localToDispose=this._register(new Lt),this._rangeUpdateTriggerPromise=null,this._rangeSyncTriggerPromise=null,this._currentRequestCts=null,this._currentRequestPosition=null,this._currentRequestModelVersion=null,this._register(this._editor.onDidChangeModel(()=>this.reinitialize(!0))),this._register(this._editor.onDidChangeConfiguration(r=>{(r.hasChanged(70)||r.hasChanged(94))&&this.reinitialize(!1)})),this._register(this._providers.onDidChange(()=>this.reinitialize(!1))),this._register(this._editor.onDidChangeModelLanguage(()=>this.reinitialize(!0))),this.reinitialize(!0)}reinitialize(e){const t=this._editor.getModel(),i=t!==null&&(this._editor.getOption(70)||this._editor.getOption(94))&&this._providers.has(t);if(i===this._enabled&&!e||(this._enabled=i,this.clearRanges(),this._localToDispose.clear(),!i||t===null))return;this._localToDispose.add(ws.runAndSubscribe(t.onDidChangeLanguageConfiguration,()=>{this._languageWordPattern=this.languageConfigurationService.getLanguageConfiguration(t.getLanguageId()).getWordDefinition()}));const n=new Mc(this._debounceInformation.get(t)),s=()=>{this._rangeUpdateTriggerPromise=n.trigger(()=>this.updateRanges(),this._debounceDuration??this._debounceInformation.get(t))},r=new Mc(0),a=d=>{this._rangeSyncTriggerPromise=r.trigger(()=>this._syncRanges(d))};this._localToDispose.add(this._editor.onDidChangeCursorPosition(()=>{s()})),this._localToDispose.add(this._editor.onDidChangeModelContent(d=>{if(!this._ignoreChangeEvent&&this._currentDecorations.length>0){const u=this._currentDecorations.getRange(0);if(u&&d.changes.every(f=>u.intersectRanges(f.range))){a(this._syncRangesToken);return}}s()})),this._localToDispose.add({dispose:()=>{n.dispose(),r.dispose()}}),this.updateRanges()}_syncRanges(e){if(!this._editor.hasModel()||e!==this._syncRangesToken||this._currentDecorations.length===0)return;const t=this._editor.getModel(),i=this._currentDecorations.getRange(0);if(!i||i.startLineNumber!==i.endLineNumber)return this.clearRanges();const n=t.getValueInRange(i);if(this._currentWordPattern){const r=n.match(this._currentWordPattern);if((r?r[0].length:0)!==n.length)return this.clearRanges()}const s=[];for(let r=1,a=this._currentDecorations.length;r<a;r++){const d=this._currentDecorations.getRange(r);if(d)if(d.startLineNumber!==d.endLineNumber)s.push({range:d,text:n});else{let u=t.getValueInRange(d),f=n,g=d.startColumn,p=d.endColumn;const w=v_(u,f);g+=w,u=u.substr(w),f=f.substr(w);const y=mF(u,f);p-=y,u=u.substr(0,u.length-y),f=f.substr(0,f.length-y),(g!==p||f.length!==0)&&s.push({range:new Z(d.startLineNumber,g,d.endLineNumber,p),text:f})}}if(s.length!==0)try{this._editor.popUndoStop(),this._ignoreChangeEvent=!0;const r=this._editor._getViewModel().getPrevEditOperationType();this._editor.executeEdits("linkedEditing",s),this._editor._getViewModel().setPrevEditOperationType(r)}finally{this._ignoreChangeEvent=!1}}dispose(){this.clearRanges(),super.dispose()}clearRanges(){this._visibleContextKey.set(!1),this._currentDecorations.clear(),this._currentRequestCts&&(this._currentRequestCts.cancel(),this._currentRequestCts=null,this._currentRequestPosition=null)}async updateRanges(e=!1){if(!this._editor.hasModel()){this.clearRanges();return}const t=this._editor.getPosition();if(!this._enabled&&!e||this._editor.getSelections().length>1){this.clearRanges();return}const i=this._editor.getModel(),n=i.getVersionId();if(this._currentRequestPosition&&this._currentRequestModelVersion===n){if(t.equals(this._currentRequestPosition))return;if(this._currentDecorations.length>0){const r=this._currentDecorations.getRange(0);if(r&&r.containsPosition(t))return}}this.clearRanges(),this._currentRequestPosition=t,this._currentRequestModelVersion=n;const s=this._currentRequestCts=new Fs;try{const r=new Mo(!1),a=await uN(this._providers,i,t,s.token);if(this._debounceInformation.update(i,r.elapsed()),s!==this._currentRequestCts||(this._currentRequestCts=null,n!==i.getVersionId()))return;let d=[];a!=null&&a.ranges&&(d=a.ranges),this._currentWordPattern=(a==null?void 0:a.wordPattern)||this._languageWordPattern;let u=!1;for(let g=0,p=d.length;g<p;g++)if(Z.containsPosition(d[g],t)){if(u=!0,g!==0){const w=d[g];d.splice(g,1),d.unshift(w)}break}if(!u){this.clearRanges();return}const f=d.map(g=>({range:g,options:Gm.DECORATION}));this._visibleContextKey.set(!0),this._currentDecorations.set(f),this._syncRangesToken++}catch(r){Bc(r)||Nn(r),(this._currentRequestCts===s||!this._currentRequestCts)&&this.clearRanges()}}},Gm=Ic,Ic.ID="editor.contrib.linkedEditing",Ic.DECORATION=dn.register({description:"linked-editing",stickiness:0,className:X5}),Ic);Ff=Gm=Y5([vm(1,Sn),vm(2,pi),vm(3,Ds),vm(4,ur)],Ff);class Q5 extends lt{constructor(){super({id:"editor.action.linkedEditing",label:C("linkedEditing.label","Start Linked Editing"),alias:"Start Linked Editing",precondition:Ae.and(B.writable,B.hasRenameProvider),kbOpts:{kbExpr:B.editorTextFocus,primary:3132,weight:100}})}runCommand(e,t){const i=e.get(as),[n,s]=Array.isArray(t)&&t||[void 0,void 0];return Pn.isUri(n)&&gi.isIPosition(s)?i.openCodeEditor({resource:n},i.getActiveCodeEditor()).then(r=>{r&&(r.setPosition(s),r.invokeWithinContext(a=>(this.reportTelemetry(a,r),this.run(a,r))))},Nn):super.runCommand(e,t)}run(e,t){const i=Ff.get(t);return i?Promise.resolve(i.updateRanges(!0)):Promise.resolve()}}const J5=wo.bindToContribution(Ff.get);bi(new J5({id:"cancelLinkedEditingInput",precondition:dN,handler:o=>o.clearRanges(),kbOpts:{kbExpr:B.editorTextFocus,weight:199,primary:9,secondary:[1033]}}));function uN(o,e,t,i){const n=o.ordered(e);return m0(n.map(s=>async()=>{try{return await s.provideLinkedEditingRanges(e,t,i)}catch(r){rs(r);return}}),s=>!!s&&$o(s==null?void 0:s.ranges))}oi("editor.linkedEditingBackground",{dark:cn.fromHex("#f00").transparent(.3),light:cn.fromHex("#f00").transparent(.3),hcDark:cn.fromHex("#f00").transparent(.3),hcLight:cn.white},C("editorLinkedEditingBackground","Background color when the editor auto renames on type."));So("_executeLinkedEditingProvider",(o,e,t)=>{const{linkedEditingRangeProvider:i}=o.get(pi);return uN(i,e,t,Qi.None)});nn(Ff.ID,Ff,1);xe(Q5);let e$=class{constructor(e,t){this._link=e,this._provider=t}toJSON(){return{range:this.range,url:this.url,tooltip:this.tooltip}}get range(){return this._link.range}get url(){return this._link.url}get tooltip(){return this._link.tooltip}async resolve(e){return this._link.url?this._link.url:typeof this._provider.resolveLink=="function"?Promise.resolve(this._provider.resolveLink(this._link,e)).then(t=>(this._link=t||this._link,this._link.url?this.resolve(e):Promise.reject(new Error("missing")))):Promise.reject(new Error("missing"))}};class ob{constructor(e){this._disposables=new Lt;let t=[];for(const[i,n]of e){const s=i.links.map(r=>new e$(r,n));t=ob._union(t,s),LT(i)&&this._disposables.add(i)}this.links=t}dispose(){this._disposables.dispose(),this.links.length=0}static _union(e,t){const i=[];let n,s,r,a;for(n=0,r=0,s=e.length,a=t.length;n<s&&r<a;){const d=e[n],u=t[r];if(Z.areIntersectingOrTouching(d.range,u.range)){n++;continue}Z.compareRangesUsingStarts(d.range,u.range)<0?(i.push(d),n++):(i.push(u),r++)}for(;n<s;n++)i.push(e[n]);for(;r<a;r++)i.push(t[r]);return i}}function hN(o,e,t){const i=[],n=o.ordered(e).reverse().map((s,r)=>Promise.resolve(s.provideLinks(e,t)).then(a=>{a&&(i[r]=[a,s])},rs));return Promise.all(n).then(()=>{const s=new ob(wl(i));return t.isCancellationRequested?(s.dispose(),new ob([])):s})}Wn.registerCommand("_executeLinkProvider",async(o,...e)=>{let[t,i]=e;Cn(t instanceof Pn),typeof i!="number"&&(i=0);const{linkProvider:n}=o.get(pi),s=o.get(uo).getModel(t);if(!s)return[];const r=await hN(n,s,Qi.None);if(!r)return[];for(let d=0;d<Math.min(i,r.links.length);d++)await r.links[d].resolve(Qi.None);const a=r.links.slice(0);return r.dispose(),a});var t$=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},bm=function(o,e){return function(t,i){e(t,i,o)}},F1,iu;let Wp=(iu=class extends Dt{static get(e){return e.getContribution(F1.ID)}constructor(e,t,i,n,s){super(),this.editor=e,this.openerService=t,this.notificationService=i,this.languageFeaturesService=n,this.providers=this.languageFeaturesService.linkProvider,this.debounceInformation=s.for(this.providers,"Links",{min:1e3,max:4e3}),this.computeLinks=this._register(new Ss(()=>this.computeLinksNow(),1e3)),this.computePromise=null,this.activeLinksList=null,this.currentOccurrences={},this.activeLinkDecorationId=null;const r=this._register(new Yy(e));this._register(r.onMouseMoveOrRelevantKeyDown(([a,d])=>{this._onEditorMouseMove(a,d)})),this._register(r.onExecute(a=>{this.onEditorMouseUp(a)})),this._register(r.onCancel(a=>{this.cleanUpActiveLinkDecoration()})),this._register(e.onDidChangeConfiguration(a=>{a.hasChanged(71)&&(this.updateDecorations([]),this.stop(),this.computeLinks.schedule(0))})),this._register(e.onDidChangeModelContent(a=>{this.editor.hasModel()&&this.computeLinks.schedule(this.debounceInformation.get(this.editor.getModel()))})),this._register(e.onDidChangeModel(a=>{this.currentOccurrences={},this.activeLinkDecorationId=null,this.stop(),this.computeLinks.schedule(0)})),this._register(e.onDidChangeModelLanguage(a=>{this.stop(),this.computeLinks.schedule(0)})),this._register(this.providers.onDidChange(a=>{this.stop(),this.computeLinks.schedule(0)})),this.computeLinks.schedule(0)}async computeLinksNow(){if(!this.editor.hasModel()||!this.editor.getOption(71))return;const e=this.editor.getModel();if(!e.isTooLargeForSyncing()&&this.providers.has(e)){this.activeLinksList&&(this.activeLinksList.dispose(),this.activeLinksList=null),this.computePromise=Os(t=>hN(this.providers,e,t));try{const t=new Mo(!1);if(this.activeLinksList=await this.computePromise,this.debounceInformation.update(e,t.elapsed()),e.isDisposed())return;this.updateDecorations(this.activeLinksList.links)}catch(t){Nn(t)}finally{this.computePromise=null}}}updateDecorations(e){const t=this.editor.getOption(78)==="altKey",i=[],n=Object.keys(this.currentOccurrences);for(const r of n){const a=this.currentOccurrences[r];i.push(a.decorationId)}const s=[];if(e)for(const r of e)s.push($h.decoration(r,t));this.editor.changeDecorations(r=>{const a=r.deltaDecorations(i,s);this.currentOccurrences={},this.activeLinkDecorationId=null;for(let d=0,u=a.length;d<u;d++){const f=new $h(e[d],a[d]);this.currentOccurrences[f.decorationId]=f}})}_onEditorMouseMove(e,t){const i=this.editor.getOption(78)==="altKey";if(this.isEnabled(e,t)){this.cleanUpActiveLinkDecoration();const n=this.getLinkOccurrence(e.target.position);n&&this.editor.changeDecorations(s=>{n.activate(s,i),this.activeLinkDecorationId=n.decorationId})}else this.cleanUpActiveLinkDecoration()}cleanUpActiveLinkDecoration(){const e=this.editor.getOption(78)==="altKey";if(this.activeLinkDecorationId){const t=this.currentOccurrences[this.activeLinkDecorationId];t&&this.editor.changeDecorations(i=>{t.deactivate(i,e)}),this.activeLinkDecorationId=null}}onEditorMouseUp(e){if(!this.isEnabled(e))return;const t=this.getLinkOccurrence(e.target.position);t&&this.openLinkOccurrence(t,e.hasSideBySideModifier,!0)}openLinkOccurrence(e,t,i=!1){if(!this.openerService)return;const{link:n}=e;n.resolve(Qi.None).then(s=>{if(typeof s=="string"&&this.editor.hasModel()){const r=this.editor.getModel().uri;if(r.scheme===go.file&&s.startsWith(`${go.file}:`)){const a=Pn.parse(s);if(a.scheme===go.file){const d=vF(a);let u=null;d.startsWith("/./")||d.startsWith("\\.\\")?u=`.${d.substr(1)}`:(d.startsWith("//./")||d.startsWith("\\\\.\\"))&&(u=`.${d.substr(2)}`),u&&(s=bF(r,u))}}}return this.openerService.open(s,{openToSide:t,fromUserGesture:i,allowContributedOpeners:!0,allowCommands:!0,fromWorkspace:!0})},s=>{const r=s instanceof Error?s.message:s;r==="invalid"?this.notificationService.warn(C("invalid.url","Failed to open this link because it is not well-formed: {0}",n.url.toString())):r==="missing"?this.notificationService.warn(C("missing.url","Failed to open this link because its target is missing.")):Nn(s)})}getLinkOccurrence(e){if(!this.editor.hasModel()||!e)return null;const t=this.editor.getModel().getDecorationsInRange({startLineNumber:e.lineNumber,startColumn:e.column,endLineNumber:e.lineNumber,endColumn:e.column},0,!0);for(const i of t){const n=this.currentOccurrences[i.id];if(n)return n}return null}isEnabled(e,t){return!!(e.target.type===6&&(e.hasTriggerModifier||t&&t.keyCodeIsTriggerKey))}stop(){var e;this.computeLinks.cancel(),this.activeLinksList&&((e=this.activeLinksList)==null||e.dispose(),this.activeLinksList=null),this.computePromise&&(this.computePromise.cancel(),this.computePromise=null)}dispose(){super.dispose(),this.stop()}},F1=iu,iu.ID="editor.linkDetector",iu);Wp=F1=t$([bm(1,ua),bm(2,co),bm(3,pi),bm(4,ur)],Wp);const yE={general:dn.register({description:"detected-link",stickiness:1,collapseOnReplaceEdit:!0,inlineClassName:"detected-link"}),active:dn.register({description:"detected-link-active",stickiness:1,collapseOnReplaceEdit:!0,inlineClassName:"detected-link-active"})};class $h{static decoration(e,t){return{range:e.range,options:$h._getOptions(e,t,!1)}}static _getOptions(e,t,i){const n={...i?yE.active:yE.general};return n.hoverMessage=i$(e,t),n}constructor(e,t){this.link=e,this.decorationId=t}activate(e,t){e.changeDecorationOptions(this.decorationId,$h._getOptions(this.link,t,!0))}deactivate(e,t){e.changeDecorationOptions(this.decorationId,$h._getOptions(this.link,t,!1))}}function i$(o,e){const t=o.url&&/^command:/i.test(o.url.toString()),i=o.tooltip?o.tooltip:t?C("links.navigate.executeCmd","Execute command"):C("links.navigate.follow","Follow link"),n=e?ja?C("links.navigate.kb.meta.mac","cmd + click"):C("links.navigate.kb.meta","ctrl + click"):ja?C("links.navigate.kb.alt.mac","option + click"):C("links.navigate.kb.alt","alt + click");if(o.url){let s="";if(/^command:/i.test(o.url.toString())){const a=o.url.toString().match(/^command:([^?#]+)/);if(a){const d=a[1];s=C("tooltip.explanation","Execute command {0}",d)}}return new to("",!0).appendLink(o.url.toString(!0).replace(/ /g,"%20"),i,s).appendMarkdown(` (${n})`)}else return new to().appendText(`${i} (${n})`)}class n$ extends lt{constructor(){super({id:"editor.action.openLink",label:C("label","Open Link"),alias:"Open Link",precondition:void 0})}run(e,t){const i=Wp.get(t);if(!i||!t.hasModel())return;const n=t.getSelections();for(const s of n){const r=i.getLinkOccurrence(s.getEndPosition());r&&i.openLinkOccurrence(r,!1)}}}nn(Wp.ID,Wp,1);xe(n$);const $k=class $k extends Dt{constructor(e){super(),this._editor=e,this._register(this._editor.onMouseDown(t=>{const i=this._editor.getOption(118);i>=0&&t.target.type===6&&t.target.position.column>=i&&this._editor.updateOptions({stopRenderingLineAfter:-1})}))}};$k.ID="editor.contrib.longLinesHelper";let rb=$k;nn(rb.ID,rb,2);const s$=oi("editor.wordHighlightBackground",{dark:"#575757B8",light:"#57575740",hcDark:null,hcLight:null},C("wordHighlight","Background color of a symbol during read-access, like reading a variable. The color must not be opaque so as not to hide underlying decorations."),!0);oi("editor.wordHighlightStrongBackground",{dark:"#004972B8",light:"#0e639c40",hcDark:null,hcLight:null},C("wordHighlightStrong","Background color of a symbol during write-access, like writing to a variable. The color must not be opaque so as not to hide underlying decorations."),!0);oi("editor.wordHighlightTextBackground",s$,C("wordHighlightText","Background color of a textual occurrence for a symbol. The color must not be opaque so as not to hide underlying decorations."),!0);const o$=oi("editor.wordHighlightBorder",{light:null,dark:null,hcDark:mu,hcLight:mu},C("wordHighlightBorder","Border color of a symbol during read-access, like reading a variable."));oi("editor.wordHighlightStrongBorder",{light:null,dark:null,hcDark:mu,hcLight:mu},C("wordHighlightStrongBorder","Border color of a symbol during write-access, like writing to a variable."));oi("editor.wordHighlightTextBorder",o$,C("wordHighlightTextBorder","Border color of a textual occurrence for a symbol."));const r$=oi("editorOverviewRuler.wordHighlightForeground","#A0A0A0CC",C("overviewRulerWordHighlightForeground","Overview ruler marker color for symbol highlights. The color must not be opaque so as not to hide underlying decorations."),!0),a$=oi("editorOverviewRuler.wordHighlightStrongForeground","#C0A0C0CC",C("overviewRulerWordHighlightStrongForeground","Overview ruler marker color for write-access symbol highlights. The color must not be opaque so as not to hide underlying decorations."),!0),l$=oi("editorOverviewRuler.wordHighlightTextForeground",VT,C("overviewRulerWordHighlightTextForeground","Overview ruler marker color of a textual occurrence for a symbol. The color must not be opaque so as not to hide underlying decorations."),!0),c$=dn.register({description:"word-highlight-strong",stickiness:1,className:"wordHighlightStrong",overviewRuler:{color:_s(a$),position:Ha.Center},minimap:{color:_s(My),position:1}}),d$=dn.register({description:"word-highlight-text",stickiness:1,className:"wordHighlightText",overviewRuler:{color:_s(l$),position:Ha.Center},minimap:{color:_s(My),position:1}}),u$=dn.register({description:"selection-highlight-overview",stickiness:1,className:"selectionHighlight",overviewRuler:{color:_s(VT),position:Ha.Center},minimap:{color:_s(My),position:1}}),h$=dn.register({description:"selection-highlight",stickiness:1,className:"selectionHighlight"}),f$=dn.register({description:"word-highlight",stickiness:1,className:"wordHighlight",overviewRuler:{color:_s(r$),position:Ha.Center},minimap:{color:_s(My),position:1}});function g$(o){return o===dv.Write?c$:o===dv.Text?d$:f$}function p$(o){return o?h$:u$}Sy((o,e)=>{const t=o.getColor(yF);t&&e.addRule(`.monaco-editor .selectionHighlight { background-color: ${t.transparent(.5)}; }`)});var _$=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},m$=function(o,e){return function(t,i){e(t,i,o)}},H1;function Vc(o,e){const t=e.filter(i=>!o.find(n=>n.equals(i)));if(t.length>=1){const i=t.map(s=>`line ${s.viewState.position.lineNumber} column ${s.viewState.position.column}`).join(", "),n=t.length===1?C("cursorAdded","Cursor added: {0}",i):C("cursorsAdded","Cursors added: {0}",i);gf(n)}}class v$ extends lt{constructor(){super({id:"editor.action.insertCursorAbove",label:C("mutlicursor.insertAbove","Add Cursor Above"),alias:"Add Cursor Above",precondition:void 0,kbOpts:{kbExpr:B.editorTextFocus,primary:2576,linux:{primary:1552,secondary:[3088]},weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"3_multi",title:C({key:"miInsertCursorAbove",comment:["&& denotes a mnemonic"]},"&&Add Cursor Above"),order:2}})}run(e,t,i){if(!t.hasModel())return;let n=!0;i&&i.logicalLine===!1&&(n=!1);const s=t._getViewModel();if(s.cursorConfig.readOnly)return;s.model.pushStackElement();const r=s.getCursorStates();s.setCursorStates(i.source,3,_0.addCursorUp(s,r,n)),s.revealTopMostCursor(i.source),Vc(r,s.getCursorStates())}}class b$ extends lt{constructor(){super({id:"editor.action.insertCursorBelow",label:C("mutlicursor.insertBelow","Add Cursor Below"),alias:"Add Cursor Below",precondition:void 0,kbOpts:{kbExpr:B.editorTextFocus,primary:2578,linux:{primary:1554,secondary:[3090]},weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"3_multi",title:C({key:"miInsertCursorBelow",comment:["&& denotes a mnemonic"]},"A&&dd Cursor Below"),order:3}})}run(e,t,i){if(!t.hasModel())return;let n=!0;i&&i.logicalLine===!1&&(n=!1);const s=t._getViewModel();if(s.cursorConfig.readOnly)return;s.model.pushStackElement();const r=s.getCursorStates();s.setCursorStates(i.source,3,_0.addCursorDown(s,r,n)),s.revealBottomMostCursor(i.source),Vc(r,s.getCursorStates())}}class y$ extends lt{constructor(){super({id:"editor.action.insertCursorAtEndOfEachLineSelected",label:C("mutlicursor.insertAtEndOfEachLineSelected","Add Cursors to Line Ends"),alias:"Add Cursors to Line Ends",precondition:void 0,kbOpts:{kbExpr:B.editorTextFocus,primary:1575,weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"3_multi",title:C({key:"miInsertCursorAtEndOfEachLineSelected",comment:["&& denotes a mnemonic"]},"Add C&&ursors to Line Ends"),order:4}})}getCursorsForSelection(e,t,i){if(!e.isEmpty()){for(let n=e.startLineNumber;n<e.endLineNumber;n++){const s=t.getLineMaxColumn(n);i.push(new Fi(n,s,n,s))}e.endColumn>1&&i.push(new Fi(e.endLineNumber,e.endColumn,e.endLineNumber,e.endColumn))}}run(e,t){if(!t.hasModel())return;const i=t.getModel(),n=t.getSelections(),s=t._getViewModel(),r=s.getCursorStates(),a=[];n.forEach(d=>this.getCursorsForSelection(d,i,a)),a.length>0&&t.setSelections(a),Vc(r,s.getCursorStates())}}class w$ extends lt{constructor(){super({id:"editor.action.addCursorsToBottom",label:C("mutlicursor.addCursorsToBottom","Add Cursors To Bottom"),alias:"Add Cursors To Bottom",precondition:void 0})}run(e,t){if(!t.hasModel())return;const i=t.getSelections(),n=t.getModel().getLineCount(),s=[];for(let d=i[0].startLineNumber;d<=n;d++)s.push(new Fi(d,i[0].startColumn,d,i[0].endColumn));const r=t._getViewModel(),a=r.getCursorStates();s.length>0&&t.setSelections(s),Vc(a,r.getCursorStates())}}class S$ extends lt{constructor(){super({id:"editor.action.addCursorsToTop",label:C("mutlicursor.addCursorsToTop","Add Cursors To Top"),alias:"Add Cursors To Top",precondition:void 0})}run(e,t){if(!t.hasModel())return;const i=t.getSelections(),n=[];for(let a=i[0].startLineNumber;a>=1;a--)n.push(new Fi(a,i[0].startColumn,a,i[0].endColumn));const s=t._getViewModel(),r=s.getCursorStates();n.length>0&&t.setSelections(n),Vc(r,s.getCursorStates())}}class ym{constructor(e,t,i){this.selections=e,this.revealRange=t,this.revealScrollType=i}}class Bp{static create(e,t){if(!e.hasModel())return null;const i=t.getState();if(!e.hasTextFocus()&&i.isRevealed&&i.searchString.length>0)return new Bp(e,t,!1,i.searchString,i.wholeWord,i.matchCase,null);let n=!1,s,r;const a=e.getSelections();a.length===1&&a[0].isEmpty()?(n=!0,s=!0,r=!0):(s=i.wholeWord,r=i.matchCase);const d=e.getSelection();let u,f=null;if(d.isEmpty()){const g=e.getConfiguredWordAtPosition(d.getStartPosition());if(!g)return null;u=g.word,f=new Fi(d.startLineNumber,g.startColumn,d.startLineNumber,g.endColumn)}else u=e.getModel().getValueInRange(d).replace(/\r\n/g,`
57
- `);return new Bp(e,t,n,u,s,r,f)}constructor(e,t,i,n,s,r,a){this._editor=e,this.findController=t,this.isDisconnectedFromFindController=i,this.searchText=n,this.wholeWord=s,this.matchCase=r,this.currentMatch=a}addSelectionToNextFindMatch(){if(!this._editor.hasModel())return null;const e=this._getNextMatch();if(!e)return null;const t=this._editor.getSelections();return new ym(t.concat(e),e,0)}moveSelectionToNextFindMatch(){if(!this._editor.hasModel())return null;const e=this._getNextMatch();if(!e)return null;const t=this._editor.getSelections();return new ym(t.slice(0,t.length-1).concat(e),e,0)}_getNextMatch(){if(!this._editor.hasModel())return null;if(this.currentMatch){const n=this.currentMatch;return this.currentMatch=null,n}this.findController.highlightFindOptions();const e=this._editor.getSelections(),t=e[e.length-1],i=this._editor.getModel().findNextMatch(this.searchText,t.getEndPosition(),!1,this.matchCase,this.wholeWord?this._editor.getOption(132):null,!1);return i?new Fi(i.range.startLineNumber,i.range.startColumn,i.range.endLineNumber,i.range.endColumn):null}addSelectionToPreviousFindMatch(){if(!this._editor.hasModel())return null;const e=this._getPreviousMatch();if(!e)return null;const t=this._editor.getSelections();return new ym(t.concat(e),e,0)}moveSelectionToPreviousFindMatch(){if(!this._editor.hasModel())return null;const e=this._getPreviousMatch();if(!e)return null;const t=this._editor.getSelections();return new ym(t.slice(0,t.length-1).concat(e),e,0)}_getPreviousMatch(){if(!this._editor.hasModel())return null;if(this.currentMatch){const n=this.currentMatch;return this.currentMatch=null,n}this.findController.highlightFindOptions();const e=this._editor.getSelections(),t=e[e.length-1],i=this._editor.getModel().findPreviousMatch(this.searchText,t.getStartPosition(),!1,this.matchCase,this.wholeWord?this._editor.getOption(132):null,!1);return i?new Fi(i.range.startLineNumber,i.range.startColumn,i.range.endLineNumber,i.range.endColumn):null}selectAll(e){if(!this._editor.hasModel())return[];this.findController.highlightFindOptions();const t=this._editor.getModel();return e?t.findMatches(this.searchText,e,!1,this.matchCase,this.wholeWord?this._editor.getOption(132):null,!1,1073741824):t.findMatches(this.searchText,!0,!1,this.matchCase,this.wholeWord?this._editor.getOption(132):null,!1,1073741824)}}const ty=class ty extends Dt{static get(e){return e.getContribution(ty.ID)}constructor(e){super(),this._sessionDispose=this._register(new Lt),this._editor=e,this._ignoreSelectionChange=!1,this._session=null}dispose(){this._endSession(),super.dispose()}_beginSessionIfNeeded(e){if(!this._session){const t=Bp.create(this._editor,e);if(!t)return;this._session=t;const i={searchString:this._session.searchText};this._session.isDisconnectedFromFindController&&(i.wholeWordOverride=1,i.matchCaseOverride=1,i.isRegexOverride=2),e.getState().change(i,!1),this._sessionDispose.add(this._editor.onDidChangeCursorSelection(n=>{this._ignoreSelectionChange||this._endSession()})),this._sessionDispose.add(this._editor.onDidBlurEditorText(()=>{this._endSession()})),this._sessionDispose.add(e.getState().onFindReplaceStateChange(n=>{(n.matchCase||n.wholeWord)&&this._endSession()}))}}_endSession(){if(this._sessionDispose.clear(),this._session&&this._session.isDisconnectedFromFindController){const e={wholeWordOverride:0,matchCaseOverride:0,isRegexOverride:0};this._session.findController.getState().change(e,!1)}this._session=null}_setSelections(e){this._ignoreSelectionChange=!0,this._editor.setSelections(e),this._ignoreSelectionChange=!1}_expandEmptyToWord(e,t){if(!t.isEmpty())return t;const i=this._editor.getConfiguredWordAtPosition(t.getStartPosition());return i?new Fi(t.startLineNumber,i.startColumn,t.startLineNumber,i.endColumn):t}_applySessionResult(e){e&&(this._setSelections(e.selections),e.revealRange&&this._editor.revealRangeInCenterIfOutsideViewport(e.revealRange,e.revealScrollType))}getSession(e){return this._session}addSelectionToNextFindMatch(e){if(this._editor.hasModel()){if(!this._session){const t=this._editor.getSelections();if(t.length>1){const n=e.getState().matchCase;if(!fN(this._editor.getModel(),t,n)){const r=this._editor.getModel(),a=[];for(let d=0,u=t.length;d<u;d++)a[d]=this._expandEmptyToWord(r,t[d]);this._editor.setSelections(a);return}}}this._beginSessionIfNeeded(e),this._session&&this._applySessionResult(this._session.addSelectionToNextFindMatch())}}addSelectionToPreviousFindMatch(e){this._beginSessionIfNeeded(e),this._session&&this._applySessionResult(this._session.addSelectionToPreviousFindMatch())}moveSelectionToNextFindMatch(e){this._beginSessionIfNeeded(e),this._session&&this._applySessionResult(this._session.moveSelectionToNextFindMatch())}moveSelectionToPreviousFindMatch(e){this._beginSessionIfNeeded(e),this._session&&this._applySessionResult(this._session.moveSelectionToPreviousFindMatch())}selectAll(e){if(!this._editor.hasModel())return;let t=null;const i=e.getState();if(i.isRevealed&&i.searchString.length>0&&i.isRegex){const n=this._editor.getModel();i.searchScope?t=n.findMatches(i.searchString,i.searchScope,i.isRegex,i.matchCase,i.wholeWord?this._editor.getOption(132):null,!1,1073741824):t=n.findMatches(i.searchString,!0,i.isRegex,i.matchCase,i.wholeWord?this._editor.getOption(132):null,!1,1073741824)}else{if(this._beginSessionIfNeeded(e),!this._session)return;t=this._session.selectAll(i.searchScope)}if(t.length>0){const n=this._editor.getSelection();for(let s=0,r=t.length;s<r;s++){const a=t[s];if(a.range.intersectRanges(n)){t[s]=t[0],t[0]=a;break}}this._setSelections(t.map(s=>new Fi(s.range.startLineNumber,s.range.startColumn,s.range.endLineNumber,s.range.endColumn)))}}};ty.ID="editor.contrib.multiCursorController";let Hf=ty;class Qf extends lt{run(e,t){const i=Hf.get(t);if(!i)return;const n=t._getViewModel();if(n){const s=n.getCursorStates(),r=bo.get(t);if(r)this._run(i,r);else{const a=e.get(Zi).createInstance(bo,t);this._run(i,a),a.dispose()}Vc(s,n.getCursorStates())}}}class C$ extends Qf{constructor(){super({id:"editor.action.addSelectionToNextFindMatch",label:C("addSelectionToNextFindMatch","Add Selection To Next Find Match"),alias:"Add Selection To Next Find Match",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:2082,weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"3_multi",title:C({key:"miAddSelectionToNextFindMatch",comment:["&& denotes a mnemonic"]},"Add &&Next Occurrence"),order:5}})}_run(e,t){e.addSelectionToNextFindMatch(t)}}class x$ extends Qf{constructor(){super({id:"editor.action.addSelectionToPreviousFindMatch",label:C("addSelectionToPreviousFindMatch","Add Selection To Previous Find Match"),alias:"Add Selection To Previous Find Match",precondition:void 0,menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"3_multi",title:C({key:"miAddSelectionToPreviousFindMatch",comment:["&& denotes a mnemonic"]},"Add P&&revious Occurrence"),order:6}})}_run(e,t){e.addSelectionToPreviousFindMatch(t)}}class k$ extends Qf{constructor(){super({id:"editor.action.moveSelectionToNextFindMatch",label:C("moveSelectionToNextFindMatch","Move Last Selection To Next Find Match"),alias:"Move Last Selection To Next Find Match",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:us(2089,2082),weight:100}})}_run(e,t){e.moveSelectionToNextFindMatch(t)}}class L$ extends Qf{constructor(){super({id:"editor.action.moveSelectionToPreviousFindMatch",label:C("moveSelectionToPreviousFindMatch","Move Last Selection To Previous Find Match"),alias:"Move Last Selection To Previous Find Match",precondition:void 0})}_run(e,t){e.moveSelectionToPreviousFindMatch(t)}}class I$ extends Qf{constructor(){super({id:"editor.action.selectHighlights",label:C("selectAllOccurrencesOfFindMatch","Select All Occurrences of Find Match"),alias:"Select All Occurrences of Find Match",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:3114,weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"3_multi",title:C({key:"miSelectHighlights",comment:["&& denotes a mnemonic"]},"Select All &&Occurrences"),order:7}})}_run(e,t){e.selectAll(t)}}class E$ extends Qf{constructor(){super({id:"editor.action.changeAll",label:C("changeAll.label","Change All Occurrences"),alias:"Change All Occurrences",precondition:Ae.and(B.writable,B.editorTextFocus),kbOpts:{kbExpr:B.editorTextFocus,primary:2108,weight:100},contextMenuOpts:{group:"1_modification",order:1.2}})}_run(e,t){e.selectAll(t)}}class D${constructor(e,t,i,n,s){this._model=e,this._searchText=t,this._matchCase=i,this._wordSeparators=n,this._modelVersionId=this._model.getVersionId(),this._cachedFindMatches=null,s&&this._model===s._model&&this._searchText===s._searchText&&this._matchCase===s._matchCase&&this._wordSeparators===s._wordSeparators&&this._modelVersionId===s._modelVersionId&&(this._cachedFindMatches=s._cachedFindMatches)}findMatches(){return this._cachedFindMatches===null&&(this._cachedFindMatches=this._model.findMatches(this._searchText,!0,!1,this._matchCase,this._wordSeparators,!1).map(e=>e.range),this._cachedFindMatches.sort(Z.compareRangesUsingStarts)),this._cachedFindMatches}}var nu;let ab=(nu=class extends Dt{constructor(e,t){super(),this._languageFeaturesService=t,this.editor=e,this._isEnabled=e.getOption(109),this._decorations=e.createDecorationsCollection(),this.updateSoon=this._register(new Ss(()=>this._update(),300)),this.state=null,this._register(e.onDidChangeConfiguration(n=>{this._isEnabled=e.getOption(109)})),this._register(e.onDidChangeCursorSelection(n=>{this._isEnabled&&(n.selection.isEmpty()?n.reason===3?(this.state&&this._setState(null),this.updateSoon.schedule()):this._setState(null):this._update())})),this._register(e.onDidChangeModel(n=>{this._setState(null)})),this._register(e.onDidChangeModelContent(n=>{this._isEnabled&&this.updateSoon.schedule()}));const i=bo.get(e);i&&this._register(i.getState().onFindReplaceStateChange(n=>{this._update()})),this.updateSoon.schedule()}_update(){this._setState(H1._createState(this.state,this._isEnabled,this.editor))}static _createState(e,t,i){if(!t||!i.hasModel())return null;const n=i.getSelection();if(n.startLineNumber!==n.endLineNumber)return null;const s=Hf.get(i);if(!s)return null;const r=bo.get(i);if(!r)return null;let a=s.getSession(r);if(!a){const f=i.getSelections();if(f.length>1){const p=r.getState().matchCase;if(!fN(i.getModel(),f,p))return null}a=Bp.create(i,r)}if(!a||a.currentMatch||/^[ \t]+$/.test(a.searchText)||a.searchText.length>200)return null;const d=r.getState(),u=d.matchCase;if(d.isRevealed){let f=d.searchString;u||(f=f.toLowerCase());let g=a.searchText;if(u||(g=g.toLowerCase()),f===g&&a.matchCase===d.matchCase&&a.wholeWord===d.wholeWord&&!d.isRegex)return null}return new D$(i.getModel(),a.searchText,a.matchCase,a.wholeWord?i.getOption(132):null,e)}_setState(e){if(this.state=e,!this.state){this._decorations.clear();return}if(!this.editor.hasModel())return;const t=this.editor.getModel();if(t.isTooLargeForTokenization())return;const i=this.state.findMatches(),n=this.editor.getSelections();n.sort(Z.compareRangesUsingStarts);const s=[];for(let u=0,f=0,g=i.length,p=n.length;u<g;){const w=i[u];if(f>=p)s.push(w),u++;else{const y=Z.compareRangesUsingStarts(w,n[f]);y<0?((n[f].isEmpty()||!Z.areIntersecting(w,n[f]))&&s.push(w),u++):(y>0||u++,f++)}}const r=this.editor.getOption(81)!=="off",a=this._languageFeaturesService.documentHighlightProvider.has(t)&&r,d=s.map(u=>({range:u,options:p$(a)}));this._decorations.set(d)}dispose(){this._setState(null),super.dispose()}},H1=nu,nu.ID="editor.contrib.selectionHighlighter",nu);ab=H1=_$([m$(1,pi)],ab);function fN(o,e,t){const i=wE(o,e[0],!t);for(let n=1,s=e.length;n<s;n++){const r=e[n];if(r.isEmpty())return!1;const a=wE(o,r,!t);if(i!==a)return!1}return!0}function wE(o,e,t){const i=o.getValueInRange(e);return t?i.toLowerCase():i}class T$ extends lt{constructor(){super({id:"editor.action.focusNextCursor",label:C("mutlicursor.focusNextCursor","Focus Next Cursor"),metadata:{description:C("mutlicursor.focusNextCursor.description","Focuses the next cursor"),args:[]},alias:"Focus Next Cursor",precondition:void 0})}run(e,t,i){if(!t.hasModel())return;const n=t._getViewModel();if(n.cursorConfig.readOnly)return;n.model.pushStackElement();const s=Array.from(n.getCursorStates()),r=s.shift();r&&(s.push(r),n.setCursorStates(i.source,3,s),n.revealPrimaryCursor(i.source,!0),Vc(s,n.getCursorStates()))}}class P$ extends lt{constructor(){super({id:"editor.action.focusPreviousCursor",label:C("mutlicursor.focusPreviousCursor","Focus Previous Cursor"),metadata:{description:C("mutlicursor.focusPreviousCursor.description","Focuses the previous cursor"),args:[]},alias:"Focus Previous Cursor",precondition:void 0})}run(e,t,i){if(!t.hasModel())return;const n=t._getViewModel();if(n.cursorConfig.readOnly)return;n.model.pushStackElement();const s=Array.from(n.getCursorStates()),r=s.pop();r&&(s.unshift(r),n.setCursorStates(i.source,3,s),n.revealPrimaryCursor(i.source,!0),Vc(s,n.getCursorStates()))}}nn(Hf.ID,Hf,4);nn(ab.ID,ab,1);xe(v$);xe(b$);xe(y$);xe(C$);xe(x$);xe(k$);xe(L$);xe(I$);xe(E$);xe(w$);xe(S$);xe(T$);xe(P$);const M$="editor.action.inlineEdit.accept",R$="editor.action.inlineEdit.reject",N$="editor.action.inlineEdit.jumpTo",A$="editor.action.inlineEdit.jumpBack";var O$=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},F$=function(o,e){return function(t,i){e(t,i,o)}};const sS="inline-edit";let W1=class extends Dt{constructor(e,t,i){super(),this.editor=e,this.model=t,this.languageService=i,this.isDisposed=Uo(this,!1),this.currentTextModel=Lo(this,this.editor.onDidChangeModel,()=>this.editor.getModel()),this.uiState=En(this,n=>{var M;if(this.isDisposed.read(n))return;const s=this.currentTextModel.read(n);if(s!==this.model.targetTextModel.read(n))return;const r=this.model.ghostText.read(n);if(!r)return;let a=(M=this.model.range)==null?void 0:M.read(n);a&&a.startLineNumber===a.endLineNumber&&a.startColumn===a.endColumn&&(a=void 0);const d=(a?a.startLineNumber===a.endLineNumber:!0)&&r.parts.length===1&&r.parts[0].lines.length===1,u=r.parts.length===1&&r.parts[0].lines.every(F=>F.length===0),f=[],g=[];function p(F,K){if(g.length>0){const V=g[g.length-1];K&&V.decorations.push(new yp(V.content.length+1,V.content.length+1+F[0].length,K,0)),V.content+=F[0],F=F.slice(1)}for(const V of F)g.push({content:V,decorations:K?[new yp(1,V.length+1,K,0)]:[]})}const w=s.getLineContent(r.lineNumber);let y,x=0;if(!u&&(d||!a)){for(const F of r.parts){let K=F.lines;a&&!d&&(p(K,sS),K=[]),y===void 0?(f.push({column:F.column,text:K[0],preview:F.preview}),K=K.slice(1)):p([w.substring(x,F.column-1)],void 0),K.length>0&&(p(K,sS),y===void 0&&F.column<=w.length&&(y=F.column)),x=F.column-1}y!==void 0&&p([w.substring(x)],void 0)}const k=y!==void 0?new KR(y,w.length+1):void 0,D=d||!a?r.lineNumber:a.endLineNumber-1;return{inlineTexts:f,additionalLines:g,hiddenRange:k,lineNumber:D,additionalReservedLineCount:this.model.minReservedLineCount.read(n),targetTextModel:s,range:a,isSingleLine:d,isPureRemove:u}}),this.decorations=En(this,n=>{const s=this.uiState.read(n);if(!s)return[];const r=[];if(s.hiddenRange&&r.push({range:s.hiddenRange.toRange(s.lineNumber),options:{inlineClassName:"inline-edit-hidden",description:"inline-edit-hidden"}}),s.range){const a=[];if(s.isSingleLine)a.push(s.range);else if(!s.isPureRemove){const d=s.range.endLineNumber-s.range.startLineNumber;for(let u=0;u<d;u++){const f=s.range.startLineNumber+u,g=s.targetTextModel.getLineFirstNonWhitespaceColumn(f),p=s.targetTextModel.getLineLastNonWhitespaceColumn(f),w=new Z(f,g,f,p);a.push(w)}}for(const d of a)r.push({range:d,options:v0})}if(s.range&&!s.isSingleLine&&s.isPureRemove){const a=new Z(s.range.startLineNumber,1,s.range.endLineNumber-1,1);r.push({range:a,options:b0})}for(const a of s.inlineTexts)r.push({range:Z.fromPositions(new gi(s.lineNumber,a.column)),options:{description:sS,after:{content:a.text,inlineClassName:a.preview?"inline-edit-decoration-preview":"inline-edit-decoration",cursorStops:kh.Left},showIfCollapsed:!0}});return r}),this._register(jn(()=>{this.isDisposed.set(!0,void 0)})),this._register(ZR(this.editor,this.decorations))}};W1=O$([F$(2,fa)],W1);var mk=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Da=function(o,e){return function(t,i){e(t,i,o)}},Km;let B1=class extends Dt{constructor(e,t,i){super(),this.editor=e,this.model=t,this.instantiationService=i,this.alwaysShowToolbar=Lo(this,this.editor.onDidChangeConfiguration,()=>this.editor.getOption(63).showToolbar==="always"),this.sessionPosition=void 0,this.position=En(this,n=>{var d,u;const s=(d=this.model.read(n))==null?void 0:d.model.ghostText.read(n);if(!this.alwaysShowToolbar.read(n)||!s||s.parts.length===0)return this.sessionPosition=void 0,null;const r=s.parts[0].column;this.sessionPosition&&this.sessionPosition.lineNumber!==s.lineNumber&&(this.sessionPosition=void 0);const a=new gi(s.lineNumber,Math.min(r,((u=this.sessionPosition)==null?void 0:u.column)??Number.MAX_SAFE_INTEGER));return this.sessionPosition=a,a}),this._register(f_((n,s)=>{if(!this.model.read(n)||!this.alwaysShowToolbar.read(n))return;const a=s.add(this.instantiationService.createInstance(z1,this.editor,!0,this.position));e.addContentWidget(a),s.add(jn(()=>e.removeContentWidget(a)))}))}};B1=mk([Da(2,Zi)],B1);var Ec;let z1=(Ec=class extends Dt{constructor(e,t,i,n,s,r){super(),this.editor=e,this.withBorder=t,this._position=i,this._contextKeyService=s,this._menuService=r,this.id=`InlineEditHintsContentWidget${Km.id++}`,this.allowEditorOverflow=!0,this.suppressMouseDown=!1,this.nodes=Er("div.inlineEditHints",{className:this.withBorder?".withBorder":""},[Er("div@toolBar")]),this.inlineCompletionsActionsMenus=this._register(this._menuService.createMenu(Gt.InlineEditActions,this._contextKeyService)),this.toolBar=this._register(n.createInstance(V1,this.nodes.toolBar,this.editor,Gt.InlineEditToolbar,{menuOptions:{renderShortTitle:!0},toolbarOptions:{primaryGroup:a=>a.startsWith("primary")},actionViewItemProvider:(a,d)=>{if(a instanceof vf)return n.createInstance(H$,a,void 0)},telemetrySource:"InlineEditToolbar"})),this._register(this.toolBar.onDidChangeDropdownVisibility(a=>{Km._dropDownVisible=a})),this._register(Kn(a=>{this._position.read(a),this.editor.layoutContentWidget(this)})),this._register(Kn(a=>{const d=[];for(const[u,f]of this.inlineCompletionsActionsMenus.getActions())for(const g of f)g instanceof vf&&d.push(g);d.length>0&&d.unshift(new gp),this.toolBar.setAdditionalSecondaryActions(d)}))}getId(){return this.id}getDomNode(){return this.nodes.root}getPosition(){return{position:this._position.get(),preference:[1,2],positionAffinity:3}}},Km=Ec,Ec._dropDownVisible=!1,Ec.id=0,Ec);z1=Km=mk([Da(3,Zi),Da(4,Sn),Da(5,Fu)],z1);class H$ extends UD{updateLabel(){const e=this._keybindingService.lookupKeybinding(this._action.id,this._contextKeyService);if(!e)return super.updateLabel();if(this.label){const t=Er("div.keybinding").root;this._register(new Jx(t,e0,{disableTitle:!0,...qD})).set(e),this.label.textContent=this._action.label,this.label.appendChild(t),this.label.classList.add("inlineEditStatusBarItemLabel")}}updateTooltip(){}}let V1=class extends GD{constructor(e,t,i,n,s,r,a,d,u,f){super(e,{resetMenu:i,...n},s,r,a,d,u,f),this.editor=t,this.menuId=i,this.options2=n,this.menuService=s,this.contextKeyService=r,this.menu=this._store.add(this.menuService.createMenu(this.menuId,this.contextKeyService,{emitEventsForSubmenuChanges:!0})),this.additionalActions=[],this.prependedPrimaryActions=[],this._store.add(this.menu.onDidChange(()=>this.updateToolbar())),this._store.add(this.editor.onDidChangeCursorPosition(()=>this.updateToolbar())),this.updateToolbar()}updateToolbar(){var i,n,s,r,a,d,u;const e=[],t=[];r0(this.menu,(i=this.options2)==null?void 0:i.menuOptions,{primary:e,secondary:t},(s=(n=this.options2)==null?void 0:n.toolbarOptions)==null?void 0:s.primaryGroup,(a=(r=this.options2)==null?void 0:r.toolbarOptions)==null?void 0:a.shouldInlineSubmenu,(u=(d=this.options2)==null?void 0:d.toolbarOptions)==null?void 0:u.useSeparatorsInPrimaryActions),t.push(...this.additionalActions),e.unshift(...this.prependedPrimaryActions),this.setActions(e,t)}setAdditionalSecondaryActions(e){Va(this.additionalActions,e,(t,i)=>t===i)||(this.additionalActions=e,this.updateToolbar())}};V1=mk([Da(4,Fu),Da(5,Sn),Da(6,zf),Da(7,hs),Da(8,Es),Da(9,ha)],V1);var gN=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Zm=function(o,e){return function(t,i){e(t,i,o)}},Ng,j1;function*W$(o,e,t=1){e===void 0&&([e,o]=[o,0]);for(let i=o;i<e;i+=t)yield i}function oS(o){var i;const e=((i=o[0].match(/^\s*/))==null?void 0:i[0])??"",t=e.length;return{text:o.map(n=>n.replace(new RegExp("^"+e),"")),shift:t}}var su;let $1=(su=class extends Dt{static _createUniqueUri(){return Pn.from({scheme:"inline-edit-widget",path:new Date().toString()+String(Ng._modelId++)})}constructor(e,t,i,n,s){super(),this._editor=e,this._model=t,this._instantiationService=i,this._diffProviderFactoryService=n,this._modelService=s,this._position=En(this,r=>{const a=this._model.read(r);if(!a||a.text.length===0||a.range.startLineNumber===a.range.endLineNumber&&!(a.range.startColumn===a.range.endColumn&&a.range.startColumn===1))return null;const d=this._editor.getModel();if(!d)return null;const u=Array.from(W$(a.range.startLineNumber,a.range.endLineNumber+1)),f=u.map(x=>d.getLineLastNonWhitespaceColumn(x)),g=Math.max(...f),p=u[f.indexOf(g)],w=new gi(p,g);return{top:a.range.startLineNumber,left:w}}),this._text=En(this,r=>{const a=this._model.read(r);if(!a)return{text:"",shift:0};const d=oS(a.text.split(`
58
- `));return{text:d.text.join(`
59
- `),shift:d.shift}}),this._originalModel=Rc(()=>this._modelService.createModel("",null,Ng._createUniqueUri())).keepObserved(this._store),this._modifiedModel=Rc(()=>this._modelService.createModel("",null,Ng._createUniqueUri())).keepObserved(this._store),this._diff=En(this,r=>{var a,d;return(d=(a=this._diffPromise.read(r))==null?void 0:a.promiseResult.read(r))==null?void 0:d.data}),this._diffPromise=En(this,r=>{const a=this._model.read(r);if(!a)return;const d=this._editor.getModel();if(!d)return;const u=oS(d.getValueInRange(a.range).split(`
60
- `)).text.join(`
61
- `),f=oS(a.text.split(`
62
- `)).text.join(`
63
- `);this._originalModel.get().setValue(u),this._modifiedModel.get().setValue(f);const g=this._diffProviderFactoryService.createDiffProvider({diffAlgorithm:"advanced"});return jT.fromFn(async()=>{const p=await g.computeDiff(this._originalModel.get(),this._modifiedModel.get(),{computeMoves:!1,ignoreTrimWhitespace:!1,maxComputationTimeMs:1e3},Qi.None);if(!p.identical)return p.changes})}),this._register(f_((r,a)=>{if(!this._model.read(r)||this._position.get()===null)return;const u=a.add(this._instantiationService.createInstance(U1,this._editor,this._position,this._text.map(f=>f.text),this._text.map(f=>f.shift),this._diff));e.addOverlayWidget(u),a.add(jn(()=>e.removeOverlayWidget(u)))}))}},Ng=su,su._modelId=0,su);$1=Ng=gN([Zm(2,Zi),Zm(3,y0),Zm(4,uo)],$1);var ou;let U1=(ou=class extends Dt{constructor(e,t,i,n,s,r){var a;super(),this._editor=e,this._position=t,this._text=i,this._shift=n,this._diff=s,this._instantiationService=r,this.id=`InlineEditSideBySideContentWidget${j1.id++}`,this.allowEditorOverflow=!1,this._nodes=si("div.inlineEditSideBySide",void 0),this._scrollChanged=wd("editor.onDidScrollChange",this._editor.onDidScrollChange),this._previewEditor=this._register(this._instantiationService.createInstance(Fr,this._nodes,{glyphMargin:!1,lineNumbers:"off",minimap:{enabled:!1},guides:{indentation:!1,bracketPairs:!1,bracketPairsHorizontal:!1,highlightActiveIndentation:!1},folding:!1,selectOnLineNumbers:!1,selectionHighlight:!1,columnSelection:!1,overviewRulerBorder:!1,overviewRulerLanes:0,lineDecorationsWidth:0,lineNumbersMinChars:0,scrollbar:{vertical:"hidden",horizontal:"hidden",alwaysConsumeMouseWheel:!1,handleMouseWheel:!1},readOnly:!0,wordWrap:"off",wordWrapOverride1:"off",wordWrapOverride2:"off",wrappingIndent:"none",wrappingStrategy:void 0},{contributions:[],isSimpleWidget:!0},this._editor)),this._previewEditorObs=Pa(this._previewEditor),this._editorObs=Pa(this._editor),this._previewTextModel=this._register(this._instantiationService.createInstance(sc,"",((a=this._editor.getModel())==null?void 0:a.getLanguageId())??vp,sc.DEFAULT_CREATION_OPTIONS,null)),this._setText=En(d=>{const u=this._text.read(d);u&&this._previewTextModel.setValue(u)}).recomputeInitiallyAndOnChange(this._store),this._decorations=En(this,d=>{this._setText.read(d);const u=this._position.read(d);if(!u)return{org:[],mod:[]};const f=this._diff.read(d);if(!f)return{org:[],mod:[]};const g=[],p=[];if(f.length===1&&f[0].innerChanges[0].modifiedRange.equalsRange(this._previewTextModel.getFullModelRange()))return{org:[],mod:[]};const w=this._shift.get(),y=x=>new Z(x.startLineNumber+u.top-1,x.startColumn+w,x.endLineNumber+u.top-1,x.endColumn+w);for(const x of f)if(x.original.isEmpty||g.push({range:y(x.original.toInclusiveRange()),options:b0}),x.modified.isEmpty||p.push({range:x.modified.toInclusiveRange(),options:$T}),x.modified.isEmpty||x.original.isEmpty)x.original.isEmpty||g.push({range:y(x.original.toInclusiveRange()),options:UT}),x.modified.isEmpty||p.push({range:x.modified.toInclusiveRange(),options:qT});else for(const k of x.innerChanges||[])x.original.contains(k.originalRange.startLineNumber)&&g.push({range:y(k.originalRange),options:k.originalRange.isEmpty()?GT:v0}),x.modified.contains(k.modifiedRange.startLineNumber)&&p.push({range:k.modifiedRange,options:k.modifiedRange.isEmpty()?KT:ZT});return{org:g,mod:p}}),this._originalDecorations=En(this,d=>this._decorations.read(d).org),this._modifiedDecorations=En(this,d=>this._decorations.read(d).mod),this._previewEditor.setModel(this._previewTextModel),this._register(this._editorObs.setDecorations(this._originalDecorations)),this._register(this._previewEditorObs.setDecorations(this._modifiedDecorations)),this._register(Kn(d=>{const u=this._previewEditorObs.contentWidth.read(d),f=this._text.read(d).split(`
64
- `).length-1,g=this._editor.getOption(67)*f;u<=0||this._previewEditor.layout({height:g,width:u})})),this._register(Kn(d=>{this._position.read(d),this._editor.layoutOverlayWidget(this)})),this._register(Kn(d=>{this._scrollChanged.read(d),this._position.read(d)&&this._editor.layoutOverlayWidget(this)}))}getId(){return this.id}getDomNode(){return this._nodes}getPosition(){const e=this._position.get();if(!e)return null;const t=this._editor.getLayoutInfo(),i=this._editor.getScrolledVisiblePosition(new gi(e.top,1));if(!i)return null;const n=i.top-1,s=this._editor.getOffsetForColumn(e.left.lineNumber,e.left.column);return{preference:{left:t.contentLeft+s+10,top:n}}}},j1=ou,ou.id=0,ou);U1=j1=gN([Zm(5,Zi)],U1);var B$=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ed=function(o,e){return function(t,i){e(t,i,o)}},Ag,rr;let oo=(rr=class extends Dt{static get(e){return e.getContribution(Ag.ID)}constructor(e,t,i,n,s,r,a,d){super(),this.editor=e,this.instantiationService=t,this.contextKeyService=i,this.languageFeaturesService=n,this._commandService=s,this._configurationService=r,this._diffProviderFactoryService=a,this._modelService=d,this._isVisibleContext=Ag.inlineEditVisibleContext.bindTo(this.contextKeyService),this._isCursorAtInlineEditContext=Ag.cursorAtInlineEditContext.bindTo(this.contextKeyService),this._currentEdit=Uo(this,void 0),this._currentWidget=Rc(this._currentEdit,y=>{const x=this._currentEdit.read(y);if(!x)return;const k=x.range.endLineNumber,D=x.range.endColumn,M=x.text.endsWith(`
65
- `)&&!(x.range.startLineNumber===x.range.endLineNumber&&x.range.startColumn===x.range.endColumn)?x.text.slice(0,-1):x.text,F=new Np(k,[new Bv(D,M,!1)]),K=x.range.startLineNumber===x.range.endLineNumber&&F.parts.length===1&&F.parts[0].lines.length===1,V=x.text==="";return!K&&!V?void 0:this.instantiationService.createInstance(W1,this.editor,{ghostText:ul(F),minReservedLineCount:ul(0),targetTextModel:ul(this.editor.getModel()??void 0),range:ul(x.range)})}),this._isAccepting=Uo(this,!1),this._enabled=Lo(this,this.editor.onDidChangeConfiguration,()=>this.editor.getOption(63).enabled),this._fontFamily=Lo(this,this.editor.onDidChangeConfiguration,()=>this.editor.getOption(63).fontFamily);const u=wd("InlineEditController.modelContentChangedSignal",e.onDidChangeModelContent);this._register(Kn(y=>{this._enabled.read(y)&&(u.read(y),!this._isAccepting.read(y)&&this.getInlineEdit(e,!0))}));const f=Lo(this,e.onDidChangeCursorPosition,()=>e.getPosition());this._register(Kn(y=>{if(!this._enabled.read(y))return;const x=f.read(y);x&&this.checkCursorPosition(x)})),this._register(Kn(y=>{const x=this._currentEdit.read(y);if(this._isCursorAtInlineEditContext.set(!1),!x){this._isVisibleContext.set(!1);return}this._isVisibleContext.set(!0);const k=e.getPosition();k&&this.checkCursorPosition(k)}));const g=wd("InlineEditController.editorBlurSignal",e.onDidBlurEditorWidget);this._register(Kn(async y=>{var x;this._enabled.read(y)&&(g.read(y),!(this._configurationService.getValue("editor.experimentalInlineEdit.keepOnBlur")||e.getOption(63).keepOnBlur)&&((x=this._currentRequestCts)==null||x.dispose(!0),this._currentRequestCts=void 0,await this.clear(!1)))}));const p=wd("InlineEditController.editorFocusSignal",e.onDidFocusEditorText);this._register(Kn(y=>{this._enabled.read(y)&&(p.read(y),this.getInlineEdit(e,!0))}));const w=this._register(vT());this._register(Kn(y=>{const x=this._fontFamily.read(y);w.setStyle(x===""||x==="default"?"":`
66
- .monaco-editor .inline-edit-decoration,
67
- .monaco-editor .inline-edit-decoration-preview,
68
- .monaco-editor .inline-edit {
69
- font-family: ${x};
70
- }`)})),this._register(new B1(this.editor,this._currentWidget,this.instantiationService)),this._register(new $1(this.editor,this._currentEdit,this.instantiationService,this._diffProviderFactoryService,this._modelService))}checkCursorPosition(e){if(!this._currentEdit){this._isCursorAtInlineEditContext.set(!1);return}const t=this._currentEdit.get();if(!t){this._isCursorAtInlineEditContext.set(!1);return}this._isCursorAtInlineEditContext.set(Z.containsPosition(t.range,e))}validateInlineEdit(e,t){var i;if(t.text.includes(`
71
- `)&&t.range.startLineNumber!==t.range.endLineNumber&&t.range.startColumn!==t.range.endColumn){if(t.range.startColumn!==1)return!1;const s=t.range.endLineNumber,r=t.range.endColumn,a=((i=e.getModel())==null?void 0:i.getLineLength(s))??0;if(r!==a+1)return!1}return!0}async fetchInlineEdit(e,t){this._currentRequestCts&&this._currentRequestCts.dispose(!0);const i=e.getModel();if(!i)return;const n=i.getVersionId(),s=this.languageFeaturesService.inlineEditProvider.all(i);if(s.length===0)return;const r=s[0];this._currentRequestCts=new Fs;const a=this._currentRequestCts.token,d=t?ML.Automatic:ML.Invoke;if(t&&await z$(50,a),a.isCancellationRequested||i.isDisposed()||i.getVersionId()!==n)return;const f=await r.provideInlineEdit(i,{triggerKind:d},a);if(f&&!(a.isCancellationRequested||i.isDisposed()||i.getVersionId()!==n)&&this.validateInlineEdit(e,f))return f}async getInlineEdit(e,t){this._isCursorAtInlineEditContext.set(!1),await this.clear();const i=await this.fetchInlineEdit(e,t);i&&this._currentEdit.set(i,void 0)}async trigger(){await this.getInlineEdit(this.editor,!1)}async jumpBack(){this._jumpBackPosition&&(this.editor.setPosition(this._jumpBackPosition),this.editor.revealPositionInCenterIfOutsideViewport(this._jumpBackPosition))}async accept(){this._isAccepting.set(!0,void 0);const e=this._currentEdit.get();if(!e)return;let t=e.text;e.text.startsWith(`
72
- `)&&(t=e.text.substring(1)),this.editor.pushUndoStop(),this.editor.executeEdits("acceptCurrent",[Qn.replace(Z.lift(e.range),t)]),e.accepted&&await this._commandService.executeCommand(e.accepted.id,...e.accepted.arguments||[]).then(void 0,rs),this.freeEdit(e),Hu(i=>{this._currentEdit.set(void 0,i),this._isAccepting.set(!1,i)})}jumpToCurrent(){var i;this._jumpBackPosition=(i=this.editor.getSelection())==null?void 0:i.getStartPosition();const e=this._currentEdit.get();if(!e)return;const t=gi.lift({lineNumber:e.range.startLineNumber,column:e.range.startColumn});this.editor.setPosition(t),this.editor.revealPositionInCenterIfOutsideViewport(t)}async clear(e=!0){const t=this._currentEdit.get();t&&(t!=null&&t.rejected)&&e&&await this._commandService.executeCommand(t.rejected.id,...t.rejected.arguments||[]).then(void 0,rs),t&&this.freeEdit(t),this._currentEdit.set(void 0,void 0)}freeEdit(e){const t=this.editor.getModel();if(!t)return;const i=this.languageFeaturesService.inlineEditProvider.all(t);i.length!==0&&i[0].freeInlineEdit(e)}},Ag=rr,rr.ID="editor.contrib.inlineEditController",rr.inlineEditVisibleKey="inlineEditVisible",rr.inlineEditVisibleContext=new _n(rr.inlineEditVisibleKey,!1),rr.cursorAtInlineEditKey="cursorAtInlineEdit",rr.cursorAtInlineEditContext=new _n(rr.cursorAtInlineEditKey,!1),rr);oo=Ag=B$([ed(1,Zi),ed(2,Sn),ed(3,pi),ed(4,Es),ed(5,Un),ed(6,y0),ed(7,uo)],oo);function z$(o,e){return new Promise(t=>{let i;const n=setTimeout(()=>{i&&i.dispose(),t()},o);e&&(i=e.onCancellationRequested(()=>{clearTimeout(n),i&&i.dispose(),t()}))})}let V$=class extends lt{constructor(){super({id:M$,label:"Accept Inline Edit",alias:"Accept Inline Edit",precondition:Ae.and(B.writable,oo.inlineEditVisibleContext),kbOpts:[{weight:101,primary:2,kbExpr:Ae.and(B.writable,oo.inlineEditVisibleContext,oo.cursorAtInlineEditContext)}],menuOpts:[{menuId:Gt.InlineEditToolbar,title:"Accept",group:"primary",order:1}]})}async run(e,t){const i=oo.get(t);await(i==null?void 0:i.accept())}};class j$ extends lt{constructor(){const e=Ae.and(B.writable,Ae.not(oo.inlineEditVisibleKey));super({id:"editor.action.inlineEdit.trigger",label:"Trigger Inline Edit",alias:"Trigger Inline Edit",precondition:e,kbOpts:{weight:101,primary:2646,kbExpr:e}})}async run(e,t){const i=oo.get(t);i==null||i.trigger()}}class $$ extends lt{constructor(){const e=Ae.and(B.writable,oo.inlineEditVisibleContext,Ae.not(oo.cursorAtInlineEditKey));super({id:N$,label:"Jump to Inline Edit",alias:"Jump to Inline Edit",precondition:e,kbOpts:{weight:101,primary:2646,kbExpr:e},menuOpts:[{menuId:Gt.InlineEditToolbar,title:"Jump To Edit",group:"primary",order:3,when:e}]})}async run(e,t){const i=oo.get(t);i==null||i.jumpToCurrent()}}class U$ extends lt{constructor(){const e=Ae.and(B.writable,oo.cursorAtInlineEditContext);super({id:A$,label:"Jump Back from Inline Edit",alias:"Jump Back from Inline Edit",precondition:e,kbOpts:{weight:110,primary:2646,kbExpr:e},menuOpts:[{menuId:Gt.InlineEditToolbar,title:"Jump Back",group:"primary",order:3,when:e}]})}async run(e,t){const i=oo.get(t);i==null||i.jumpBack()}}class q$ extends lt{constructor(){const e=Ae.and(B.writable,oo.inlineEditVisibleContext);super({id:R$,label:"Reject Inline Edit",alias:"Reject Inline Edit",precondition:e,kbOpts:{weight:100,primary:9,kbExpr:e},menuOpts:[{menuId:Gt.InlineEditToolbar,title:"Reject",group:"secondary",order:2}]})}async run(e,t){const i=oo.get(t);await(i==null?void 0:i.clear())}}xe(V$);xe(q$);xe($$);xe(U$);xe(j$);nn(oo.ID,oo,3);const G$="editor.action.inlineEdits.accept",K$="editor.action.inlineEdits.showPrevious",Z$="editor.action.inlineEdits.showNext",Wf=new _n("inlineEditsVisible",!1,C("inlineEditsVisible","Whether an inline edit is visible")),Y$=new _n("inlineEditsIsPinned",!1,C("isPinned","Whether an inline edit is visible")),Uk=class Uk extends Dt{constructor(e){super(),this._editor=e,this._editorObs=Pa(this._editor),this._placeholderText=this._editorObs.getOption(88),this._state=cl({owner:this,equalsFn:YT},t=>{const i=this._placeholderText.read(t);if(i&&this._editorObs.valueIsEmpty.read(t))return{placeholder:i}}),this._shouldViewBeAlive=X$(this,t=>{var i;return((i=this._state.read(t))==null?void 0:i.placeholder)!==void 0}),this._view=KD((t,i)=>{if(!this._shouldViewBeAlive.read(t))return;const n=Er("div.editorPlaceholder");i.add(Kn(s=>{const r=this._state.read(s),a=(r==null?void 0:r.placeholder)!==void 0;n.root.style.display=a?"block":"none",n.root.innerText=(r==null?void 0:r.placeholder)??""})),i.add(Kn(s=>{const r=this._editorObs.layoutInfo.read(s);n.root.style.left=`${r.contentLeft}px`,n.root.style.width=r.contentWidth-r.verticalScrollbarWidth+"px",n.root.style.top=`${this._editor.getTopForLineNumber(0)}px`})),i.add(Kn(s=>{n.root.style.fontFamily=this._editorObs.getOption(49).read(s),n.root.style.fontSize=this._editorObs.getOption(52).read(s)+"px",n.root.style.lineHeight=this._editorObs.getOption(67).read(s)+"px"})),i.add(this._editorObs.createOverlayWidget({allowEditorOverflow:!1,minContentWidthInPx:ul(0),position:ul(null),domNode:n.root}))}),this._view.recomputeInitiallyAndOnChange(this._store)}};Uk.ID="editor.contrib.placeholderText";let zp=Uk;function X$(o,e){return xy(o,(t,i)=>i===!0?!0:e(t))}var Q$=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},J$=function(o,e){return function(t,i){e(t,i,o)}};class e8{constructor(e,t,i){this.range=e,this.newLines=t,this.changes=i}}let q1=class extends Dt{constructor(e,t,i,n){super(),this._editor=e,this._edit=t,this._userPrompt=i,this._instantiationService=n,this._editorObs=Pa(this._editor),this._elements=Er("div.inline-edits-widget",{style:{position:"absolute",overflow:"visible",top:"0px",left:"0px"}},[Er("div@editorContainer",{style:{position:"absolute",top:"0px",left:"0px",width:"500px",height:"500px"}},[Er("div.toolbar@toolbar",{style:{position:"absolute",top:"-25px",left:"0px"}}),Er("div.promptEditor@promptEditor",{style:{position:"absolute",top:"-25px",left:"80px",width:"300px",height:"22px"}}),Er("div.preview@editor",{style:{position:"absolute",top:"0px",left:"0px"}})]),eh("svg",{style:{overflow:"visible",pointerEvents:"none"}},[eh("defs",[eh("linearGradient",{id:"Gradient2",x1:"0",y1:"0",x2:"1",y2:"0"},[eh("stop",{offset:"0%",class:"gradient-stop"}),eh("stop",{offset:"100%",class:"gradient-stop"})])]),eh("path@path",{d:"",fill:"url(#Gradient2)"})])]),this._previewTextModel=this._register(this._instantiationService.createInstance(sc,"",vp,sc.DEFAULT_CREATION_OPTIONS,null)),this._setText=En(r=>{const a=this._edit.read(r);a&&this._previewTextModel.setValue(a.newLines.join(`
73
- `))}).recomputeInitiallyAndOnChange(this._store),this._promptTextModel=this._register(this._instantiationService.createInstance(sc,"",vp,sc.DEFAULT_CREATION_OPTIONS,null)),this._promptEditor=this._register(this._instantiationService.createInstance(Fr,this._elements.promptEditor,{glyphMargin:!1,lineNumbers:"off",minimap:{enabled:!1},guides:{indentation:!1,bracketPairs:!1,bracketPairsHorizontal:!1,highlightActiveIndentation:!1},folding:!1,selectOnLineNumbers:!1,selectionHighlight:!1,columnSelection:!1,overviewRulerBorder:!1,overviewRulerLanes:0,lineDecorationsWidth:0,lineNumbersMinChars:0,placeholder:"Describe the change you want...",fontFamily:wF},{contributions:SF.getSomeEditorContributions([Pr.ID,zp.ID,Pf.ID]),isSimpleWidget:!0},this._editor)),this._previewEditor=this._register(this._instantiationService.createInstance(Fr,this._elements.editor,{glyphMargin:!1,lineNumbers:"off",minimap:{enabled:!1},guides:{indentation:!1,bracketPairs:!1,bracketPairsHorizontal:!1,highlightActiveIndentation:!1},folding:!1,selectOnLineNumbers:!1,selectionHighlight:!1,columnSelection:!1,overviewRulerBorder:!1,overviewRulerLanes:0,lineDecorationsWidth:0,lineNumbersMinChars:0},{contributions:[]},this._editor)),this._previewEditorObs=Pa(this._previewEditor),this._decorations=En(this,r=>{var f;this._setText.read(r);const a=(f=this._edit.read(r))==null?void 0:f.changes;if(!a)return[];const d=[],u=[];if(a.length===1&&a[0].innerChanges[0].modifiedRange.equalsRange(this._previewTextModel.getFullModelRange()))return[];for(const g of a)if(g.original.isEmpty||d.push({range:g.original.toInclusiveRange(),options:b0}),g.modified.isEmpty||u.push({range:g.modified.toInclusiveRange(),options:$T}),g.modified.isEmpty||g.original.isEmpty)g.original.isEmpty||d.push({range:g.original.toInclusiveRange(),options:UT}),g.modified.isEmpty||u.push({range:g.modified.toInclusiveRange(),options:qT});else for(const p of g.innerChanges||[])g.original.contains(p.originalRange.startLineNumber)&&d.push({range:p.originalRange,options:p.originalRange.isEmpty()?GT:v0}),g.modified.contains(p.modifiedRange.startLineNumber)&&u.push({range:p.modifiedRange,options:p.modifiedRange.isEmpty()?KT:ZT});return u}),this._layout1=En(this,r=>{const a=this._editor.getModel(),d=this._edit.read(r);if(!d)return null;const u=d.range;let f=0;for(let w=u.startLineNumber;w<u.endLineNumberExclusive;w++){const y=a.getLineMaxColumn(w),x=this._editor.getOffsetForColumn(w,y);f=Math.max(f,x)}return{left:this._editor.getLayoutInfo().contentLeft+f}}),this._layout=En(this,r=>{const a=this._edit.read(r);if(!a)return null;const d=a.range,u=this._editorObs.scrollLeft.read(r),f=this._layout1.read(r).left+20-u,g=this._editor.getTopForLineNumber(d.startLineNumber)-this._editorObs.scrollTop.read(r),p=this._editor.getTopForLineNumber(d.endLineNumberExclusive)-this._editorObs.scrollTop.read(r),w=new Rh(f,g),y=new Rh(f,p),x=p-g,k=50,D=this._editor.getOption(67)*a.newLines.length,M=x-D,F=new Rh(f+k,g+M/2),K=new Rh(f+k,p-M/2);return{topCode:w,bottomCode:y,codeHeight:x,topEdit:F,bottomEdit:K,editHeight:D}});const s=En(this,r=>this._edit.read(r)!==void 0||this._userPrompt.read(r)!==void 0);this._register(CF(this._elements.root,{display:En(this,r=>s.read(r)?"block":"none")})),this._register(xF(this._editor.getDomNode(),this._elements.root)),this._register(Pa(e).createOverlayWidget({domNode:this._elements.root,position:ul(null),allowEditorOverflow:!1,minContentWidthInPx:En(r=>{var u;const a=(u=this._layout1.read(r))==null?void 0:u.left;if(a===void 0)return 0;const d=this._previewEditorObs.contentWidth.read(r);return a+d})})),this._previewEditor.setModel(this._previewTextModel),this._register(this._previewEditorObs.setDecorations(this._decorations)),this._register(Kn(r=>{const a=this._layout.read(r);if(!a)return;const{topCode:d,bottomCode:u,topEdit:f,bottomEdit:g,editHeight:p}=a,w=10,y=0,x=40,k=new i8().moveTo(d).lineTo(d.deltaX(w)).curveTo(d.deltaX(w+x),f.deltaX(-x-y),f.deltaX(-y)).lineTo(f).lineTo(g).lineTo(g.deltaX(-y)).curveTo(g.deltaX(-x-y),u.deltaX(w+x),u.deltaX(w)).lineTo(u).build();this._elements.path.setAttribute("d",k),this._elements.editorContainer.style.top=`${f.y}px`,this._elements.editorContainer.style.left=`${f.x}px`,this._elements.editorContainer.style.height=`${p}px`;const D=this._previewEditorObs.contentWidth.read(r);this._previewEditor.layout({height:p,width:D})})),this._promptEditor.setModel(this._promptTextModel),this._promptEditor.layout(),this._register(n8(t8(this._userPrompt,r=>r??"",r=>r),Pa(this._promptEditor).value)),this._register(Kn(r=>{const a=Pa(this._promptEditor).isFocused.read(r);this._elements.root.classList.toggle("focused",a)}))}};q1=Q$([J$(3,Zi)],q1);function t8(o,e,t){return XT(void 0,i=>e(o.read(i)),(i,n)=>o.set(t(i),n))}class Rh{constructor(e,t){this.x=e,this.y=t}deltaX(e){return new Rh(this.x+e,this.y)}}class i8{constructor(){this._data=""}moveTo(e){return this._data+=`M ${e.x} ${e.y} `,this}lineTo(e){return this._data+=`L ${e.x} ${e.y} `,this}curveTo(e,t,i){return this._data+=`C ${e.x} ${e.y} ${t.x} ${t.y} ${i.x} ${i.y} `,this}build(){return this._data}}function n8(o,e){const t=new Lt;return t.add(Kn(i=>{const n=o.read(i);e.set(n,void 0)})),t.add(Kn(i=>{const n=e.read(i);o.set(n,void 0)})),t}var s8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},rS=function(o,e){return function(t,i){e(t,i,o)}},Og,ru;let G1=(ru=class extends Dt{static _createUniqueUri(){return Pn.from({scheme:"inline-edits",path:new Date().toString()+String(Og._modelId++)})}constructor(e,t,i,n,s,r,a){super(),this.textModel=e,this._textModelVersionId=t,this._selection=i,this._debounceValue=n,this.languageFeaturesService=s,this._diffProviderFactoryService=r,this._modelService=a,this._forceUpdateExplicitlySignal=f0(this),this._selectedInlineCompletionId=Uo(this,void 0),this._isActive=Uo(this,!1),this._originalModel=Rc(()=>this._modelService.createModel("",null,Og._createUniqueUri())).keepObserved(this._store),this._modifiedModel=Rc(()=>this._modelService.createModel("",null,Og._createUniqueUri())).keepObserved(this._store),this._pinnedRange=new r8(this.textModel,this._textModelVersionId),this.isPinned=this._pinnedRange.range.map(d=>!!d),this.userPrompt=Uo(this,void 0),this.inlineEdit=En(this,d=>{var u,f;return(f=(u=this._inlineEdit.read(d))==null?void 0:u.promiseResult.read(d))==null?void 0:f.data}),this._inlineEdit=En(this,d=>{const u=this.selectedInlineEdit.read(d);if(!u)return;const f=u.inlineCompletion.range;if(u.inlineCompletion.insertText.trim()==="")return;let g=u.inlineCompletion.insertText.split(/\r\n|\r|\n/);function p(k){var M;const D=((M=k[0].match(/^\s*/))==null?void 0:M[0])??"";return k.map(F=>F.replace(new RegExp("^"+D),""))}g=p(g);let y=this.textModel.getValueInRange(f).split(/\r\n|\r|\n/);y=p(y),this._originalModel.get().setValue(y.join(`
74
- `)),this._modifiedModel.get().setValue(g.join(`
75
- `));const x=this._diffProviderFactoryService.createDiffProvider({diffAlgorithm:"advanced"});return jT.fromFn(async()=>{const k=await x.computeDiff(this._originalModel.get(),this._modifiedModel.get(),{computeMoves:!1,ignoreTrimWhitespace:!1,maxComputationTimeMs:1e3},Qi.None);if(!k.identical)return new e8(kF.fromRangeInclusive(f),p(g),k.changes)})}),this._fetchStore=this._register(new Lt),this._inlineEditsFetchResult=ES(this,void 0),this._inlineEdits=cl({owner:this,equalsFn:YT},d=>{var u;return((u=this._inlineEditsFetchResult.read(d))==null?void 0:u.completions.map(f=>new o8(f)))??[]}),this._fetchInlineEditsPromise=IT({owner:this,createEmptyChangeSummary:()=>({inlineCompletionTriggerKind:ml.Automatic}),handleChange:(d,u)=>(d.didChange(this._forceUpdateExplicitlySignal)&&(u.inlineCompletionTriggerKind=ml.Explicit),!0)},async(d,u)=>{this._fetchStore.clear(),this._forceUpdateExplicitlySignal.read(d),this._textModelVersionId.read(d);function f(x,k){return k(x)}const g=this._pinnedRange.range.read(d)??f(this._selection.read(d),x=>x.isEmpty()?void 0:x);if(!g){this._inlineEditsFetchResult.set(void 0,void 0),this.userPrompt.set(void 0,void 0);return}const p={triggerKind:u.inlineCompletionTriggerKind,selectedSuggestionInfo:void 0,userPrompt:this.userPrompt.read(d)},w=TS(this._fetchStore);await Py(200,w);const y=await YR(this.languageFeaturesService.inlineCompletionsProvider,g,this.textModel,p,w);w.isCancellationRequested||this._inlineEditsFetchResult.set(y,void 0)}),this._filteredInlineEditItems=cl({owner:this,equalsFn:DS()},d=>this._inlineEdits.read(d)),this.selectedInlineCompletionIndex=En(this,d=>{const u=this._selectedInlineCompletionId.read(d),f=this._filteredInlineEditItems.read(d),g=this._selectedInlineCompletionId===void 0?-1:f.findIndex(p=>p.semanticId===u);return g===-1?(this._selectedInlineCompletionId.set(void 0,void 0),0):g}),this.selectedInlineEdit=En(this,d=>{const u=this._filteredInlineEditItems.read(d),f=this.selectedInlineCompletionIndex.read(d);return u[f]}),this._register(ET(this._fetchInlineEditsPromise))}async triggerExplicitly(e){av(e,t=>{this._isActive.set(!0,t),this._forceUpdateExplicitlySignal.trigger(t)}),await this._fetchInlineEditsPromise.get()}stop(e){av(e,t=>{this.userPrompt.set(void 0,t),this._isActive.set(!1,t),this._inlineEditsFetchResult.set(void 0,t),this._pinnedRange.setRange(void 0,t)})}async _deltaSelectedInlineCompletionIndex(e){await this.triggerExplicitly();const t=this._filteredInlineEditItems.get()||[];if(t.length>0){const i=(this.selectedInlineCompletionIndex.get()+e+t.length)%t.length;this._selectedInlineCompletionId.set(t[i].semanticId,void 0)}else this._selectedInlineCompletionId.set(void 0,void 0)}async next(){await this._deltaSelectedInlineCompletionIndex(1)}async previous(){await this._deltaSelectedInlineCompletionIndex(-1)}async accept(e){if(e.getModel()!==this.textModel)throw new bf;const t=this.selectedInlineEdit.get();t&&(e.pushUndoStop(),e.executeEdits("inlineSuggestion.accept",[t.inlineCompletion.toSingleTextEdit().toSingleEditOperation()]),this.stop())}},Og=ru,ru._modelId=0,ru);G1=Og=s8([rS(4,pi),rS(5,y0),rS(6,uo)],G1);class o8{constructor(e){this.inlineCompletion=e,this.semanticId=this.inlineCompletion.hash()}}class r8 extends Dt{constructor(e,t){super(),this._textModel=e,this._versionId=t,this._decorations=Uo(this,[]),this.range=En(this,i=>{this._versionId.read(i);const n=this._decorations.read(i)[0];return n?this._textModel.getDecorationRange(n)??null:null}),this._register(jn(()=>{this._textModel.deltaDecorations(this._decorations.get(),[])}))}setRange(e,t){this._decorations.set(this._textModel.deltaDecorations(this._decorations.get(),e?[{range:e,options:{description:"trackedRange"}}]:[]),t)}}var a8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},yg=function(o,e){return function(t,i){e(t,i,o)}},K1,au;let Dl=(au=class extends Dt{static get(e){return e.getContribution(K1.ID)}constructor(e,t,i,n,s,r){super(),this.editor=e,this._instantiationService=t,this._contextKeyService=i,this._debounceService=n,this._languageFeaturesService=s,this._configurationService=r,this._enabled=LF("editor.inlineEdits.enabled",!1,this._configurationService),this._editorObs=Pa(this.editor),this._selection=En(this,a=>this._editorObs.cursorSelection.read(a)??new Fi(1,1,1,1)),this._debounceValue=this._debounceService.for(this._languageFeaturesService.inlineCompletionsProvider,"InlineEditsDebounce",{min:50,max:50}),this.model=Rc(this,a=>{if(!this._enabled.read(a)||this._editorObs.isReadonly.read(a))return;const d=this._editorObs.model.read(a);return d?this._instantiationService.createInstance(PS(G1,a),d,this._editorObs.versionId,this._selection,this._debounceValue):void 0}),this._hadInlineEdit=xy(this,(a,d)=>{var u;return d||((u=this.model.read(a))==null?void 0:u.inlineEdit.read(a))!==void 0}),this._widget=Rc(this,a=>{if(this._hadInlineEdit.read(a))return this._instantiationService.createInstance(PS(q1,a),this.editor,this.model.map((d,u)=>d==null?void 0:d.inlineEdit.read(u)),l8(d=>{var u;return((u=this.model.read(d))==null?void 0:u.userPrompt)??Uo("empty","")}))}),this._register(RL(Wf,this._contextKeyService,a=>{var d;return!!((d=this.model.read(a))!=null&&d.inlineEdit.read(a))})),this._register(RL(Y$,this._contextKeyService,a=>{var d;return!!((d=this.model.read(a))!=null&&d.isPinned.read(a))})),this.model.recomputeInitiallyAndOnChange(this._store),this._widget.recomputeInitiallyAndOnChange(this._store)}},K1=au,au.ID="editor.contrib.inlineEditsController",au);Dl=K1=a8([yg(1,Zi),yg(2,Sn),yg(3,ur),yg(4,pi),yg(5,Un)],Dl);function l8(o){return XT(void 0,e=>o(e).read(e),(e,t)=>{o(void 0).set(e,t)})}function A_(o){return{label:o.value,alias:o.original}}const iy=class iy extends lt{constructor(){super({id:iy.ID,...A_(ui("action.inlineEdits.showNext","Show Next Inline Edit")),precondition:Ae.and(B.writable,Wf),kbOpts:{weight:100,primary:606}})}async run(e,t){var n;const i=Dl.get(t);(n=i==null?void 0:i.model.get())==null||n.next()}};iy.ID=Z$;let Z1=iy;const ny=class ny extends lt{constructor(){super({id:ny.ID,...A_(ui("action.inlineEdits.showPrevious","Show Previous Inline Edit")),precondition:Ae.and(B.writable,Wf),kbOpts:{weight:100,primary:604}})}async run(e,t){var n;const i=Dl.get(t);(n=i==null?void 0:i.model.get())==null||n.previous()}};ny.ID=K$;let Y1=ny;class c8 extends lt{constructor(){super({id:"editor.action.inlineEdits.trigger",...A_(ui("action.inlineEdits.trigger","Trigger Inline Edit")),precondition:B.writable})}async run(e,t){const i=Dl.get(t);await HT(async n=>{var s;await((s=i==null?void 0:i.model.get())==null?void 0:s.triggerExplicitly(n))})}}class d8 extends lt{constructor(){super({id:G$,...A_(ui("action.inlineEdits.accept","Accept Inline Edit")),precondition:Wf,menuOpts:{menuId:Gt.InlineEditsActions,title:C("inlineEditsActions","Accept Inline Edit"),group:"primary",order:1,icon:ji.check},kbOpts:{primary:2058,weight:2e4,kbExpr:Wf}})}async run(e,t){var n;t instanceof Fr&&(t=t.getParentEditor());const i=Dl.get(t);i&&((n=i.model.get())==null||n.accept(i.editor),i.editor.focus())}}const sy=class sy extends lt{constructor(){super({id:sy.ID,...A_(ui("action.inlineEdits.hide","Hide Inline Edit")),precondition:Wf,kbOpts:{weight:100,primary:9}})}async run(e,t){const i=Dl.get(t);Hu(n=>{var s;(s=i==null?void 0:i.model.get())==null||s.stop(n)})}};sy.ID="editor.action.inlineEdits.hide";let X1=sy;nn(Dl.ID,Dl,3);xe(c8);xe(Z1);xe(Y1);xe(d8);xe(X1);const Ru={Visible:new _n("parameterHintsVisible",!1),MultipleSignatures:new _n("parameterHintsMultipleSignatures",!1)};async function pN(o,e,t,i,n){const s=o.ordered(e);for(const r of s)try{const a=await r.provideSignatureHelp(e,t,n,i);if(a)return a}catch(a){rs(a)}}Wn.registerCommand("_executeSignatureHelpProvider",async(o,...e)=>{const[t,i,n]=e;Cn(Pn.isUri(t)),Cn(gi.isIPosition(i)),Cn(typeof n=="string"||!n);const s=o.get(pi),r=await o.get(ga).createModelReference(t);try{const a=await pN(s.signatureHelpProvider,r.object.textEditorModel,gi.lift(i),{triggerKind:uc.Invoke,isRetrigger:!1,triggerCharacter:n},Qi.None);return a?(setTimeout(()=>a.dispose(),0),a.value):void 0}finally{r.dispose()}});var Zl;(function(o){o.Default={type:0};class e{constructor(n,s){this.request=n,this.previouslyActiveHints=s,this.type=2}}o.Pending=e;class t{constructor(n){this.hints=n,this.type=1}}o.Active=t})(Zl||(Zl={}));const oy=class oy extends Dt{constructor(e,t,i=oy.DEFAULT_DELAY){super(),this._onChangedHints=this._register(new Xi),this.onChangedHints=this._onChangedHints.event,this.triggerOnType=!1,this._state=Zl.Default,this._pendingTriggers=[],this._lastSignatureHelpResult=this._register(new Go),this.triggerChars=new ov,this.retriggerChars=new ov,this.triggerId=0,this.editor=e,this.providers=t,this.throttledDelayer=new Mc(i),this._register(this.editor.onDidBlurEditorWidget(()=>this.cancel())),this._register(this.editor.onDidChangeConfiguration(()=>this.onEditorConfigurationChange())),this._register(this.editor.onDidChangeModel(n=>this.onModelChanged())),this._register(this.editor.onDidChangeModelLanguage(n=>this.onModelChanged())),this._register(this.editor.onDidChangeCursorSelection(n=>this.onCursorChange(n))),this._register(this.editor.onDidChangeModelContent(n=>this.onModelContentChange())),this._register(this.providers.onDidChange(this.onModelChanged,this)),this._register(this.editor.onDidType(n=>this.onDidType(n))),this.onEditorConfigurationChange(),this.onModelChanged()}get state(){return this._state}set state(e){this._state.type===2&&this._state.request.cancel(),this._state=e}cancel(e=!1){this.state=Zl.Default,this.throttledDelayer.cancel(),e||this._onChangedHints.fire(void 0)}trigger(e,t){const i=this.editor.getModel();if(!i||!this.providers.has(i))return;const n=++this.triggerId;this._pendingTriggers.push(e),this.throttledDelayer.trigger(()=>this.doTrigger(n),t).catch(Nn)}next(){if(this.state.type!==1)return;const e=this.state.hints.signatures.length,t=this.state.hints.activeSignature,i=t%e===e-1,n=this.editor.getOption(86).cycle;if((e<2||i)&&!n){this.cancel();return}this.updateActiveSignature(i&&n?0:t+1)}previous(){if(this.state.type!==1)return;const e=this.state.hints.signatures.length,t=this.state.hints.activeSignature,i=t===0,n=this.editor.getOption(86).cycle;if((e<2||i)&&!n){this.cancel();return}this.updateActiveSignature(i&&n?e-1:t-1)}updateActiveSignature(e){this.state.type===1&&(this.state=new Zl.Active({...this.state.hints,activeSignature:e}),this._onChangedHints.fire(this.state.hints))}async doTrigger(e){const t=this.state.type===1||this.state.type===2,i=this.getLastActiveHints();if(this.cancel(!0),this._pendingTriggers.length===0)return!1;const n=this._pendingTriggers.reduce(u8);this._pendingTriggers=[];const s={triggerKind:n.triggerKind,triggerCharacter:n.triggerCharacter,isRetrigger:t,activeSignatureHelp:i};if(!this.editor.hasModel())return!1;const r=this.editor.getModel(),a=this.editor.getPosition();this.state=new Zl.Pending(Os(d=>pN(this.providers,r,a,s,d)),i);try{const d=await this.state.request;return e!==this.triggerId?(d==null||d.dispose(),!1):!d||!d.value.signatures||d.value.signatures.length===0?(d==null||d.dispose(),this._lastSignatureHelpResult.clear(),this.cancel(),!1):(this.state=new Zl.Active(d.value),this._lastSignatureHelpResult.value=d,this._onChangedHints.fire(this.state.hints),!0)}catch(d){return e===this.triggerId&&(this.state=Zl.Default),Nn(d),!1}}getLastActiveHints(){switch(this.state.type){case 1:return this.state.hints;case 2:return this.state.previouslyActiveHints;default:return}}get isTriggered(){return this.state.type===1||this.state.type===2||this.throttledDelayer.isTriggered()}onModelChanged(){this.cancel(),this.triggerChars.clear(),this.retriggerChars.clear();const e=this.editor.getModel();if(e)for(const t of this.providers.ordered(e)){for(const i of t.signatureHelpTriggerCharacters||[])if(i.length){const n=i.charCodeAt(0);this.triggerChars.add(n),this.retriggerChars.add(n)}for(const i of t.signatureHelpRetriggerCharacters||[])i.length&&this.retriggerChars.add(i.charCodeAt(0))}}onDidType(e){if(!this.triggerOnType)return;const t=e.length-1,i=e.charCodeAt(t);(this.triggerChars.has(i)||this.isTriggered&&this.retriggerChars.has(i))&&this.trigger({triggerKind:uc.TriggerCharacter,triggerCharacter:e.charAt(t)})}onCursorChange(e){e.source==="mouse"?this.cancel():this.isTriggered&&this.trigger({triggerKind:uc.ContentChange})}onModelContentChange(){this.isTriggered&&this.trigger({triggerKind:uc.ContentChange})}onEditorConfigurationChange(){this.triggerOnType=this.editor.getOption(86).enabled,this.triggerOnType||this.cancel()}dispose(){this.cancel(!0),super.dispose()}};oy.DEFAULT_DELAY=120;let Q1=oy;function u8(o,e){switch(e.triggerKind){case uc.Invoke:return e;case uc.ContentChange:return o;case uc.TriggerCharacter:default:return e}}var h8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},wm=function(o,e){return function(t,i){e(t,i,o)}},J1;const Oo=si,f8=is("parameter-hints-next",ji.chevronDown,C("parameterHintsNextIcon","Icon for show next parameter hint.")),g8=is("parameter-hints-previous",ji.chevronUp,C("parameterHintsPreviousIcon","Icon for show previous parameter hint."));var lu;let ex=(lu=class extends Dt{constructor(e,t,i,n,s,r){super(),this.editor=e,this.model=t,this.telemetryService=r,this.renderDisposeables=this._register(new Lt),this.visible=!1,this.announcedLabel=null,this.allowEditorOverflow=!0,this.markdownRenderer=this._register(new Uf({editor:e},s,n)),this.keyVisible=Ru.Visible.bindTo(i),this.keyMultipleSignatures=Ru.MultipleSignatures.bindTo(i)}createParameterHintDOMNodes(){const e=Oo(".editor-widget.parameter-hints-widget"),t=ei(e,Oo(".phwrapper"));t.tabIndex=-1;const i=ei(t,Oo(".controls")),n=ei(i,Oo(".button"+xn.asCSSSelector(g8))),s=ei(i,Oo(".overloads")),r=ei(i,Oo(".button"+xn.asCSSSelector(f8)));this._register(wn(n,"click",p=>{sv.stop(p),this.previous()})),this._register(wn(r,"click",p=>{sv.stop(p),this.next()}));const a=Oo(".body"),d=new MT(a,{alwaysConsumeMouseWheel:!0});this._register(d),t.appendChild(d.getDomNode());const u=ei(a,Oo(".signature")),f=ei(a,Oo(".docs"));e.style.userSelect="text",this.domNodes={element:e,signature:u,overloads:s,docs:f,scrollbar:d},this.editor.addContentWidget(this),this.hide(),this._register(this.editor.onDidChangeCursorSelection(p=>{this.visible&&this.editor.layoutContentWidget(this)}));const g=()=>{if(!this.domNodes)return;const p=this.editor.getOption(50),w=this.domNodes.element;w.style.fontSize=`${p.fontSize}px`,w.style.lineHeight=`${p.lineHeight/p.fontSize}`,w.style.setProperty("--vscode-parameterHintsWidget-editorFontFamily",p.fontFamily),w.style.setProperty("--vscode-parameterHintsWidget-editorFontFamilyDefault",o0.fontFamily)};g(),this._register(ws.chain(this.editor.onDidChangeConfiguration.bind(this.editor),p=>p.filter(w=>w.hasChanged(50)))(g)),this._register(this.editor.onDidLayoutChange(p=>this.updateMaxHeight())),this.updateMaxHeight()}show(){this.visible||(this.domNodes||this.createParameterHintDOMNodes(),this.keyVisible.set(!0),this.visible=!0,setTimeout(()=>{var e;(e=this.domNodes)==null||e.element.classList.add("visible")},100),this.editor.layoutContentWidget(this))}hide(){var e;this.renderDisposeables.clear(),this.visible&&(this.keyVisible.reset(),this.visible=!1,this.announcedLabel=null,(e=this.domNodes)==null||e.element.classList.remove("visible"),this.editor.layoutContentWidget(this))}getPosition(){return this.visible?{position:this.editor.getPosition(),preference:[1,2]}:null}render(e){if(this.renderDisposeables.clear(),!this.domNodes)return;const t=e.signatures.length>1;this.domNodes.element.classList.toggle("multiple",t),this.keyMultipleSignatures.set(t),this.domNodes.signature.innerText="",this.domNodes.docs.innerText="";const i=e.signatures[e.activeSignature];if(!i)return;const n=ei(this.domNodes.signature,Oo(".code")),s=i.parameters.length>0,r=i.activeParameter??e.activeParameter;if(s)this.renderParameters(n,i,r);else{const u=ei(n,Oo("span"));u.textContent=i.label}const a=i.parameters[r];if(a!=null&&a.documentation){const u=Oo("span.documentation");if(typeof a.documentation=="string")u.textContent=a.documentation;else{const f=this.renderMarkdownDocs(a.documentation);u.appendChild(f.element)}ei(this.domNodes.docs,Oo("p",{},u))}if(i.documentation!==void 0)if(typeof i.documentation=="string")ei(this.domNodes.docs,Oo("p",{},i.documentation));else{const u=this.renderMarkdownDocs(i.documentation);ei(this.domNodes.docs,u.element)}const d=this.hasDocs(i,a);if(this.domNodes.signature.classList.toggle("has-docs",d),this.domNodes.docs.classList.toggle("empty",!d),this.domNodes.overloads.textContent=String(e.activeSignature+1).padStart(e.signatures.length.toString().length,"0")+"/"+e.signatures.length,a){let u="";const f=i.parameters[r];Array.isArray(f.label)?u=i.label.substring(f.label[0],f.label[1]):u=f.label,f.documentation&&(u+=typeof f.documentation=="string"?`, ${f.documentation}`:`, ${f.documentation.value}`),i.documentation&&(u+=typeof i.documentation=="string"?`, ${i.documentation}`:`, ${i.documentation.value}`),this.announcedLabel!==u&&(Ar(C("hint","{0}, hint",u)),this.announcedLabel=u)}this.editor.layoutContentWidget(this),this.domNodes.scrollbar.scanDomNode()}renderMarkdownDocs(e){const t=new Mo,i=this.renderDisposeables.add(this.markdownRenderer.render(e,{asyncRenderCallback:()=>{var s;(s=this.domNodes)==null||s.scrollbar.scanDomNode()}}));i.element.classList.add("markdown-docs");const n=t.elapsed();return n>300&&this.telemetryService.publicLog2("parameterHints.parseMarkdown",{renderDuration:n}),i}hasDocs(e,t){return!!(t&&typeof t.documentation=="string"&&Lh(t.documentation).length>0||t&&typeof t.documentation=="object"&&Lh(t.documentation).value.length>0||e.documentation&&typeof e.documentation=="string"&&Lh(e.documentation).length>0||e.documentation&&typeof e.documentation=="object"&&Lh(e.documentation.value).length>0)}renderParameters(e,t,i){const[n,s]=this.getParameterLabelOffsets(t,i),r=document.createElement("span");r.textContent=t.label.substring(0,n);const a=document.createElement("span");a.textContent=t.label.substring(n,s),a.className="parameter active";const d=document.createElement("span");d.textContent=t.label.substring(s),ei(e,r,a,d)}getParameterLabelOffsets(e,t){const i=e.parameters[t];if(i){if(Array.isArray(i.label))return i.label;if(i.label.length){const n=new RegExp(`(\\W|^)${fp(i.label)}(?=\\W|$)`,"g");n.test(e.label);const s=n.lastIndex-i.label.length;return s>=0?[s,n.lastIndex]:[0,0]}else return[0,0]}else return[0,0]}next(){this.editor.focus(),this.model.next()}previous(){this.editor.focus(),this.model.previous()}getDomNode(){return this.domNodes||this.createParameterHintDOMNodes(),this.domNodes.element}getId(){return J1.ID}updateMaxHeight(){if(!this.domNodes)return;const t=`${Math.max(this.editor.getLayoutInfo().height/4,250)}px`;this.domNodes.element.style.maxHeight=t;const i=this.domNodes.element.getElementsByClassName("phwrapper");i.length&&(i[0].style.maxHeight=t)}},J1=lu,lu.ID="editor.widget.parameterHintsWidget",lu);ex=J1=h8([wm(2,Sn),wm(3,ua),wm(4,fa),wm(5,ha)],ex);oi("editorHoverWidget.highlightForeground",OT,C("editorHoverWidgetHighlightForeground","Foreground color of the active item in the parameter hint."));var p8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},SE=function(o,e){return function(t,i){e(t,i,o)}},tx,cu;let Bf=(cu=class extends Dt{static get(e){return e.getContribution(tx.ID)}constructor(e,t,i){super(),this.editor=e,this.model=this._register(new Q1(e,i.signatureHelpProvider)),this._register(this.model.onChangedHints(n=>{var s;n?(this.widget.value.show(),this.widget.value.render(n)):(s=this.widget.rawValue)==null||s.hide()})),this.widget=new Xx(()=>this._register(t.createInstance(ex,this.editor,this.model)))}cancel(){this.model.cancel()}previous(){var e;(e=this.widget.rawValue)==null||e.previous()}next(){var e;(e=this.widget.rawValue)==null||e.next()}trigger(e){this.model.trigger(e,0)}},tx=cu,cu.ID="editor.controller.parameterHints",cu);Bf=tx=p8([SE(1,Zi),SE(2,pi)],Bf);class _8 extends lt{constructor(){super({id:"editor.action.triggerParameterHints",label:C("parameterHints.trigger.label","Trigger Parameter Hints"),alias:"Trigger Parameter Hints",precondition:B.hasSignatureHelpProvider,kbOpts:{kbExpr:B.editorTextFocus,primary:3082,weight:100}})}run(e,t){const i=Bf.get(t);i==null||i.trigger({triggerKind:uc.Invoke})}}nn(Bf.ID,Bf,2);xe(_8);const vk=175,bk=wo.bindToContribution(Bf.get);bi(new bk({id:"closeParameterHints",precondition:Ru.Visible,handler:o=>o.cancel(),kbOpts:{weight:vk,kbExpr:B.focus,primary:9,secondary:[1033]}}));bi(new bk({id:"showPrevParameterHint",precondition:Ae.and(Ru.Visible,Ru.MultipleSignatures),handler:o=>o.previous(),kbOpts:{weight:vk,kbExpr:B.focus,primary:16,secondary:[528],mac:{primary:16,secondary:[528,302]}}}));bi(new bk({id:"showNextParameterHint",precondition:Ae.and(Ru.Visible,Ru.MultipleSignatures),handler:o=>o.next(),kbOpts:{weight:vk,kbExpr:B.focus,primary:18,secondary:[530],mac:{primary:18,secondary:[530,300]}}}));var m8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},v8=function(o,e){return function(t,i){e(t,i,o)}};class b8{constructor(e){this.instantiationService=e}init(...e){}}function y8(o,e){return class extends e{constructor(){super(...arguments),this._autorun=void 0}init(...i){this._autorun=f_((n,s)=>{const r=PS(o(),n);s.add(this.instantiationService.createInstance(r,...i))})}dispose(){var i;(i=this._autorun)==null||i.dispose()}}}function w8(o){return IF()?y8(o,ix):o()}let ix=class extends b8{constructor(e,t){super(t),this.init(e)}};ix=m8([v8(1,Zi)],ix);nn(zp.ID,w8(()=>zp),0);oi("editor.placeholder.foreground",EF,C("placeholderForeground","Foreground color of the placeholder text in the editor."));var S8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Sm=function(o,e){return function(t,i){e(t,i,o)}};const Jf=new _n("renameInputVisible",!1,C("renameInputVisible","Whether the rename input widget is visible"));new _n("renameInputFocused",!1,C("renameInputFocused","Whether the rename input widget is focused"));let nx=class{constructor(e,t,i,n,s,r){this._editor=e,this._acceptKeybindings=t,this._themeService=i,this._keybindingService=n,this._logService=r,this.allowEditorOverflow=!0,this._disposables=new Lt,this._visibleContextKey=Jf.bindTo(s),this._isEditingRenameCandidate=!1,this._nRenameSuggestionsInvocations=0,this._hadAutomaticRenameSuggestionsInvocation=!1,this._candidates=new Set,this._beforeFirstInputFieldEditSW=new Mo,this._inputWithButton=new C8,this._disposables.add(this._inputWithButton),this._editor.addContentWidget(this),this._disposables.add(this._editor.onDidChangeConfiguration(a=>{a.hasChanged(50)&&this._updateFont()})),this._disposables.add(i.onDidColorThemeChange(this._updateStyles,this))}dispose(){this._disposables.dispose(),this._editor.removeContentWidget(this)}getId(){return"__renameInputWidget"}getDomNode(){return this._domNode||(this._domNode=document.createElement("div"),this._domNode.className="monaco-editor rename-box",this._domNode.appendChild(this._inputWithButton.domNode),this._renameCandidateListView=this._disposables.add(new yk(this._domNode,{fontInfo:this._editor.getOption(50),onFocusChange:e=>{this._inputWithButton.input.value=e,this._isEditingRenameCandidate=!1},onSelectionChange:()=>{this._isEditingRenameCandidate=!1,this.acceptInput(!1)}})),this._disposables.add(this._inputWithButton.onDidInputChange(()=>{var e,t,i;((e=this._renameCandidateListView)==null?void 0:e.focusedCandidate)!==void 0&&(this._isEditingRenameCandidate=!0),this._timeBeforeFirstInputFieldEdit??(this._timeBeforeFirstInputFieldEdit=this._beforeFirstInputFieldEditSW.elapsed()),((t=this._renameCandidateProvidersCts)==null?void 0:t.token.isCancellationRequested)===!1&&this._renameCandidateProvidersCts.cancel(),(i=this._renameCandidateListView)==null||i.clearFocus()})),this._label=document.createElement("div"),this._label.className="rename-label",this._domNode.appendChild(this._label),this._updateFont(),this._updateStyles(this._themeService.getColorTheme())),this._domNode}_updateStyles(e){if(!this._domNode)return;const t=e.getColor(DF),i=e.getColor(TF);this._domNode.style.backgroundColor=String(e.getColor(RT)??""),this._domNode.style.boxShadow=t?` 0 0 8px 2px ${t}`:"",this._domNode.style.border=i?`1px solid ${i}`:"",this._domNode.style.color=String(e.getColor(PF)??"");const n=e.getColor(MF);this._inputWithButton.domNode.style.backgroundColor=String(e.getColor(NL)??""),this._inputWithButton.input.style.backgroundColor=String(e.getColor(NL)??""),this._inputWithButton.domNode.style.borderWidth=n?"1px":"0px",this._inputWithButton.domNode.style.borderStyle=n?"solid":"none",this._inputWithButton.domNode.style.borderColor=(n==null?void 0:n.toString())??"none"}_updateFont(){if(this._domNode===void 0)return;Cn(this._label!==void 0,"RenameWidget#_updateFont: _label must not be undefined given _domNode is defined"),this._editor.applyFontInfo(this._inputWithButton.input);const e=this._editor.getOption(50);this._label.style.fontSize=`${this._computeLabelFontSize(e.fontSize)}px`}_computeLabelFontSize(e){return e*.8}getPosition(){if(!this._visible||!this._editor.hasModel()||!this._editor.getDomNode())return null;const e=g_(this.getDomNode().ownerDocument.body),t=mo(this._editor.getDomNode()),i=this._getTopForPosition();this._nPxAvailableAbove=i+t.top,this._nPxAvailableBelow=e.height-this._nPxAvailableAbove;const n=this._editor.getOption(67),{totalHeight:s}=Vp.getLayoutInfo({lineHeight:n}),r=this._nPxAvailableBelow>s*6?[2,1]:[1,2];return{position:this._position,preference:r}}beforeRender(){var i,n;const[e,t]=this._acceptKeybindings;return this._label.innerText=C({key:"label",comment:['placeholders are keybindings, e.g "F2 to Rename, Shift+F2 to Preview"']},"{0} to Rename, {1} to Preview",(i=this._keybindingService.lookupKeybinding(e))==null?void 0:i.getLabel(),(n=this._keybindingService.lookupKeybinding(t))==null?void 0:n.getLabel()),this._domNode.style.minWidth="200px",null}afterRender(e){if(e===null){this.cancelInput(!0,"afterRender (because position is null)");return}if(!this._editor.hasModel()||!this._editor.getDomNode())return;Cn(this._renameCandidateListView),Cn(this._nPxAvailableAbove!==void 0),Cn(this._nPxAvailableBelow!==void 0);const t=xh(this._inputWithButton.domNode),i=xh(this._label);let n;e===2?n=this._nPxAvailableBelow:n=this._nPxAvailableAbove,this._renameCandidateListView.layout({height:n-i-t,width:wr(this._inputWithButton.domNode)})}acceptInput(e){var t;this._trace("invoking acceptInput"),(t=this._currentAcceptInput)==null||t.call(this,e)}cancelInput(e,t){var i;(i=this._currentCancelInput)==null||i.call(this,e)}focusNextRenameSuggestion(){var e;(e=this._renameCandidateListView)!=null&&e.focusNext()||(this._inputWithButton.input.value=this._currentName)}focusPreviousRenameSuggestion(){var e;(e=this._renameCandidateListView)!=null&&e.focusPrevious()||(this._inputWithButton.input.value=this._currentName)}getInput(e,t,i,n,s){const{start:r,end:a}=this._getSelection(e,t);this._renameCts=s;const d=new Lt;this._nRenameSuggestionsInvocations=0,this._hadAutomaticRenameSuggestionsInvocation=!1,n===void 0?this._inputWithButton.button.style.display="none":(this._inputWithButton.button.style.display="flex",this._requestRenameCandidatesOnce=n,this._requestRenameCandidates(t,!1),d.add(wn(this._inputWithButton.button,"click",()=>this._requestRenameCandidates(t,!0))),d.add(wn(this._inputWithButton.button,Zn.KEY_DOWN,f=>{const g=new w0(f);(g.equals(3)||g.equals(10))&&(g.stopPropagation(),g.preventDefault(),this._requestRenameCandidates(t,!0))}))),this._isEditingRenameCandidate=!1,this._domNode.classList.toggle("preview",i),this._position=new gi(e.startLineNumber,e.startColumn),this._currentName=t,this._inputWithButton.input.value=t,this._inputWithButton.input.setAttribute("selectionStart",r.toString()),this._inputWithButton.input.setAttribute("selectionEnd",a.toString()),this._inputWithButton.input.size=Math.max((e.endColumn-e.startColumn)*1.1,20),this._beforeFirstInputFieldEditSW.reset(),d.add(jn(()=>{this._renameCts=void 0,s.dispose(!0)})),d.add(jn(()=>{this._renameCandidateProvidersCts!==void 0&&(this._renameCandidateProvidersCts.dispose(!0),this._renameCandidateProvidersCts=void 0)})),d.add(jn(()=>this._candidates.clear()));const u=new by;return u.p.finally(()=>{d.dispose(),this._hide()}),this._currentCancelInput=f=>{var g;return this._trace("invoking _currentCancelInput"),this._currentAcceptInput=void 0,this._currentCancelInput=void 0,(g=this._renameCandidateListView)==null||g.clearCandidates(),u.complete(f),!0},this._currentAcceptInput=f=>{this._trace("invoking _currentAcceptInput"),Cn(this._renameCandidateListView!==void 0);const g=this._renameCandidateListView.nCandidates;let p,w;const y=this._renameCandidateListView.focusedCandidate;if(y!==void 0?(this._trace("using new name from renameSuggestion"),p=y,w={k:"renameSuggestion"}):(this._trace("using new name from inputField"),p=this._inputWithButton.input.value,w=this._isEditingRenameCandidate?{k:"userEditedRenameSuggestion"}:{k:"inputField"}),p===t||p.trim().length===0){this.cancelInput(!0,"_currentAcceptInput (because newName === value || newName.trim().length === 0)");return}this._currentAcceptInput=void 0,this._currentCancelInput=void 0,this._renameCandidateListView.clearCandidates(),u.complete({newName:p,wantsPreview:i&&f,stats:{source:w,nRenameSuggestions:g,timeBeforeFirstInputFieldEdit:this._timeBeforeFirstInputFieldEdit,nRenameSuggestionsInvocations:this._nRenameSuggestionsInvocations,hadAutomaticRenameSuggestionsInvocation:this._hadAutomaticRenameSuggestionsInvocation}})},d.add(s.token.onCancellationRequested(()=>this.cancelInput(!0,"cts.token.onCancellationRequested"))),d.add(this._editor.onDidBlurEditorWidget(()=>{var f;return this.cancelInput(!((f=this._domNode)!=null&&f.ownerDocument.hasFocus()),"editor.onDidBlurEditorWidget")})),this._show(),u.p}_requestRenameCandidates(e,t){if(this._requestRenameCandidatesOnce!==void 0&&(this._renameCandidateProvidersCts!==void 0&&this._renameCandidateProvidersCts.dispose(!0),Cn(this._renameCts),this._inputWithButton.buttonState!=="stop")){this._renameCandidateProvidersCts=new Fs;const i=t?MS.Invoke:MS.Automatic,n=this._requestRenameCandidatesOnce(i,this._renameCandidateProvidersCts.token);if(n.length===0){this._inputWithButton.setSparkleButton();return}t||(this._hadAutomaticRenameSuggestionsInvocation=!0),this._nRenameSuggestionsInvocations+=1,this._inputWithButton.setStopButton(),this._updateRenameCandidates(n,e,this._renameCts.token)}}_getSelection(e,t){Cn(this._editor.hasModel());const i=this._editor.getSelection();let n=0,s=t.length;return!Z.isEmpty(i)&&!Z.spansMultipleLines(i)&&Z.containsRange(e,i)&&(n=Math.max(0,i.startColumn-e.startColumn),s=Math.min(e.endColumn,i.endColumn)-e.startColumn),{start:n,end:s}}_show(){this._trace("invoking _show"),this._editor.revealLineInCenterIfOutsideViewport(this._position.lineNumber,0),this._visible=!0,this._visibleContextKey.set(!0),this._editor.layoutContentWidget(this),setTimeout(()=>{this._inputWithButton.input.focus(),this._inputWithButton.input.setSelectionRange(parseInt(this._inputWithButton.input.getAttribute("selectionStart")),parseInt(this._inputWithButton.input.getAttribute("selectionEnd")))},100)}async _updateRenameCandidates(e,t,i){const n=(...u)=>this._trace("_updateRenameCandidates",...u);n("start");const s=await a_(Promise.allSettled(e),i);if(this._inputWithButton.setSparkleButton(),s===void 0){n("returning early - received updateRenameCandidates results - undefined");return}const r=s.flatMap(u=>u.status==="fulfilled"&&Pm(u.value)?u.value:[]);n(`received updateRenameCandidates results - total (unfiltered) ${r.length} candidates.`);const a=HD(r,u=>u.newSymbolName);n(`distinct candidates - ${a.length} candidates.`);const d=a.filter(({newSymbolName:u})=>u.trim().length>0&&u!==this._inputWithButton.input.value&&u!==t&&!this._candidates.has(u));if(n(`valid distinct candidates - ${r.length} candidates.`),d.forEach(u=>this._candidates.add(u.newSymbolName)),d.length<1){n("returning early - no valid distinct candidates");return}n("setting candidates"),this._renameCandidateListView.setCandidates(d),n("asking editor to re-layout"),this._editor.layoutContentWidget(this)}_hide(){this._trace("invoked _hide"),this._visible=!1,this._visibleContextKey.reset(),this._editor.layoutContentWidget(this)}_getTopForPosition(){const e=this._editor.getVisibleRanges();let t;return e.length>0?t=e[0].startLineNumber:(this._logService.warn("RenameWidget#_getTopForPosition: this should not happen - visibleRanges is empty"),t=Math.max(1,this._position.lineNumber-5)),this._editor.getTopForLineNumber(this._position.lineNumber)-this._editor.getTopForLineNumber(t)}_trace(...e){this._logService.trace("RenameWidget",...e)}};nx=S8([Sm(2,Hr),Sm(3,hs),Sm(4,Sn),Sm(5,Wu)],nx);class yk{constructor(e,t){this._disposables=new Lt,this._availableHeight=0,this._minimumWidth=0,this._lineHeight=t.fontInfo.lineHeight,this._typicalHalfwidthCharacterWidth=t.fontInfo.typicalHalfwidthCharacterWidth,this._listContainer=document.createElement("div"),this._listContainer.className="rename-box rename-candidate-list-container",e.appendChild(this._listContainer),this._listWidget=yk._createListWidget(this._listContainer,this._candidateViewHeight,t.fontInfo),this._listWidget.onDidChangeFocus(i=>{i.elements.length===1&&t.onFocusChange(i.elements[0].newSymbolName)},this._disposables),this._listWidget.onDidChangeSelection(i=>{i.elements.length===1&&t.onSelectionChange()},this._disposables),this._disposables.add(this._listWidget.onDidBlur(i=>{this._listWidget.setFocus([])})),this._listWidget.style(FT({listInactiveFocusForeground:NT,listInactiveFocusBackground:AT}))}dispose(){this._listWidget.dispose(),this._disposables.dispose()}layout({height:e,width:t}){this._availableHeight=e,this._minimumWidth=t}setCandidates(e){this._listWidget.splice(0,0,e);const t=this._pickListHeight(this._listWidget.length),i=this._pickListWidth(e);this._listWidget.layout(t,i),this._listContainer.style.height=`${t}px`,this._listContainer.style.width=`${i}px`,gf(C("renameSuggestionsReceivedAria","Received {0} rename suggestions",e.length))}clearCandidates(){this._listContainer.style.height="0px",this._listContainer.style.width="0px",this._listWidget.splice(0,this._listWidget.length,[])}get nCandidates(){return this._listWidget.length}get focusedCandidate(){if(this._listWidget.length===0)return;const e=this._listWidget.getSelectedElements()[0];if(e!==void 0)return e.newSymbolName;const t=this._listWidget.getFocusedElements()[0];if(t!==void 0)return t.newSymbolName}focusNext(){if(this._listWidget.length===0)return!1;const e=this._listWidget.getFocus();if(e.length===0)return this._listWidget.focusFirst(),this._listWidget.reveal(0),!0;if(e[0]===this._listWidget.length-1)return this._listWidget.setFocus([]),this._listWidget.reveal(0),!1;{this._listWidget.focusNext();const t=this._listWidget.getFocus()[0];return this._listWidget.reveal(t),!0}}focusPrevious(){if(this._listWidget.length===0)return!1;const e=this._listWidget.getFocus();if(e.length===0){this._listWidget.focusLast();const t=this._listWidget.getFocus()[0];return this._listWidget.reveal(t),!0}else{if(e[0]===0)return this._listWidget.setFocus([]),!1;{this._listWidget.focusPrevious();const t=this._listWidget.getFocus()[0];return this._listWidget.reveal(t),!0}}}clearFocus(){this._listWidget.setFocus([])}get _candidateViewHeight(){const{totalHeight:e}=Vp.getLayoutInfo({lineHeight:this._lineHeight});return e}_pickListHeight(e){const t=this._candidateViewHeight*e;return Math.min(t,this._availableHeight,this._candidateViewHeight*7)}_pickListWidth(e){const t=Math.ceil(Math.max(...e.map(n=>n.newSymbolName.length))*this._typicalHalfwidthCharacterWidth);return Math.max(this._minimumWidth,25+t+10)}static _createListWidget(e,t,i){const n=new class{getTemplateId(r){return"candidate"}getHeight(r){return t}},s=new class{constructor(){this.templateId="candidate"}renderTemplate(r){return new Vp(r,i)}renderElement(r,a,d){d.populate(r)}disposeTemplate(r){r.dispose()}};return new t0("NewSymbolNameCandidates",e,n,[s],{keyboardSupport:!1,mouseSupport:!0,multipleSelectionSupport:!1})}}class C8{constructor(){this._onDidInputChange=new Xi,this.onDidInputChange=this._onDidInputChange.event,this._disposables=new Lt}get domNode(){return this._domNode||(this._domNode=document.createElement("div"),this._domNode.className="rename-input-with-button",this._domNode.style.display="flex",this._domNode.style.flexDirection="row",this._domNode.style.alignItems="center",this._inputNode=document.createElement("input"),this._inputNode.className="rename-input",this._inputNode.type="text",this._inputNode.style.border="none",this._inputNode.setAttribute("aria-label",C("renameAriaLabel","Rename input. Type new name and press Enter to commit.")),this._domNode.appendChild(this._inputNode),this._buttonNode=document.createElement("div"),this._buttonNode.className="rename-suggestions-button",this._buttonNode.setAttribute("tabindex","0"),this._buttonGenHoverText=C("generateRenameSuggestionsButton","Generate new name suggestions"),this._buttonCancelHoverText=C("cancelRenameSuggestionsButton","Cancel"),this._buttonHover=RF().setupManagedHover(Dy("element"),this._buttonNode,this._buttonGenHoverText),this._disposables.add(this._buttonHover),this._domNode.appendChild(this._buttonNode),this._disposables.add(wn(this.input,Zn.INPUT,()=>this._onDidInputChange.fire())),this._disposables.add(wn(this.input,Zn.KEY_DOWN,e=>{const t=new w0(e);(t.keyCode===15||t.keyCode===17)&&this._onDidInputChange.fire()})),this._disposables.add(wn(this.input,Zn.CLICK,()=>this._onDidInputChange.fire())),this._disposables.add(wn(this.input,Zn.FOCUS,()=>{this.domNode.style.outlineWidth="1px",this.domNode.style.outlineStyle="solid",this.domNode.style.outlineOffset="-1px",this.domNode.style.outlineColor="var(--vscode-focusBorder)"})),this._disposables.add(wn(this.input,Zn.BLUR,()=>{this.domNode.style.outline="none"}))),this._domNode}get input(){return Cn(this._inputNode),this._inputNode}get button(){return Cn(this._buttonNode),this._buttonNode}get buttonState(){return this._buttonState}setSparkleButton(){var e;this._buttonState="sparkle",this._sparkleIcon??(this._sparkleIcon=RS(ji.sparkle)),Wa(this.button),this.button.appendChild(this._sparkleIcon),this.button.setAttribute("aria-label","Generating new name suggestions"),(e=this._buttonHover)==null||e.update(this._buttonGenHoverText),this.input.focus()}setStopButton(){var e;this._buttonState="stop",this._stopIcon??(this._stopIcon=RS(ji.primitiveSquare)),Wa(this.button),this.button.appendChild(this._stopIcon),this.button.setAttribute("aria-label","Cancel generating new name suggestions"),(e=this._buttonHover)==null||e.update(this._buttonCancelHoverText),this.input.focus()}dispose(){this._disposables.dispose()}}const cp=class cp{constructor(e,t){this._domNode=document.createElement("div"),this._domNode.className="rename-box rename-candidate",this._domNode.style.display="flex",this._domNode.style.columnGap="5px",this._domNode.style.alignItems="center",this._domNode.style.height=`${t.lineHeight}px`,this._domNode.style.padding=`${cp._PADDING}px`;const i=document.createElement("div");i.style.display="flex",i.style.alignItems="center",i.style.width=i.style.height=`${t.lineHeight*.8}px`,this._domNode.appendChild(i),this._icon=RS(ji.sparkle),this._icon.style.display="none",i.appendChild(this._icon),this._label=document.createElement("div"),xT(this._label,t),this._domNode.appendChild(this._label),e.appendChild(this._domNode)}populate(e){this._updateIcon(e),this._updateLabel(e)}_updateIcon(e){var i;const t=!!((i=e.tags)!=null&&i.includes(NF.AIGenerated));this._icon.style.display=t?"inherit":"none"}_updateLabel(e){this._label.innerText=e.newSymbolName}static getLayoutInfo({lineHeight:e}){return{totalHeight:e+cp._PADDING*2}}dispose(){}};cp._PADDING=2;let Vp=cp;var x8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ql=function(o,e){return function(t,i){e(t,i,o)}},sx;class wk{constructor(e,t,i){this.model=e,this.position=t,this._providerRenameIdx=0,this._providers=i.ordered(e)}hasProvider(){return this._providers.length>0}async resolveRenameLocation(e){const t=[];for(this._providerRenameIdx=0;this._providerRenameIdx<this._providers.length;this._providerRenameIdx++){const n=this._providers[this._providerRenameIdx];if(!n.resolveRenameLocation)break;const s=await n.resolveRenameLocation(this.model,this.position,e);if(s){if(s.rejectReason){t.push(s.rejectReason);continue}return s}}this._providerRenameIdx=0;const i=this.model.getWordAtPosition(this.position);return i?{range:new Z(this.position.lineNumber,i.startColumn,this.position.lineNumber,i.endColumn),text:i.word,rejectReason:t.length>0?t.join(`
76
- `):void 0}:{range:Z.fromPositions(this.position),text:"",rejectReason:t.length>0?t.join(`
77
- `):void 0}}async provideRenameEdits(e,t){return this._provideRenameEdits(e,this._providerRenameIdx,[],t)}async _provideRenameEdits(e,t,i,n){const s=this._providers[t];if(!s)return{edits:[],rejectReason:i.join(`
78
- `)};const r=await s.provideRenameEdits(this.model,this.position,e,n);if(r){if(r.rejectReason)return this._provideRenameEdits(e,t+1,i.concat(r.rejectReason),n)}else return this._provideRenameEdits(e,t+1,i.concat(C("no result","No result.")),n);return r}}async function k8(o,e,t,i){const n=new wk(e,t,o),s=await n.resolveRenameLocation(Qi.None);return s!=null&&s.rejectReason?{edits:[],rejectReason:s.rejectReason}:n.provideRenameEdits(i,Qi.None)}var du;let Hc=(du=class{static get(e){return e.getContribution(sx.ID)}constructor(e,t,i,n,s,r,a,d,u){this.editor=e,this._instaService=t,this._notificationService=i,this._bulkEditService=n,this._progressService=s,this._logService=r,this._configService=a,this._languageFeaturesService=d,this._telemetryService=u,this._disposableStore=new Lt,this._cts=new Fs,this._renameWidget=this._disposableStore.add(this._instaService.createInstance(nx,this.editor,["acceptRenameInput","acceptRenameInputWithPreview"]))}dispose(){this._disposableStore.dispose(),this._cts.dispose(!0)}async run(){var y,x;const e=this._logService.trace.bind(this._logService,"[rename]");if(this._cts.dispose(!0),this._cts=new Fs,!this.editor.hasModel()){e("editor has no model");return}const t=this.editor.getPosition(),i=new wk(this.editor.getModel(),t,this._languageFeaturesService.renameProvider);if(!i.hasProvider()){e("skeleton has no provider");return}const n=new hf(this.editor,5,void 0,this._cts.token);let s;try{e("resolving rename location");const k=i.resolveRenameLocation(n.token);this._progressService.showWhile(k,250),s=await k,e("resolved rename location")}catch(k){k instanceof yy?e("resolve rename location cancelled",JSON.stringify(k,null," ")):(e("resolve rename location failed",k instanceof Error?k:JSON.stringify(k,null," ")),(typeof k=="string"||Dm(k))&&((y=Do.get(this.editor))==null||y.showMessage(k||C("resolveRenameLocationFailed","An unknown error occurred while resolving rename location"),t)));return}finally{n.dispose()}if(!s){e("returning early - no loc");return}if(s.rejectReason){e(`returning early - rejected with reason: ${s.rejectReason}`,s.rejectReason),(x=Do.get(this.editor))==null||x.showMessage(s.rejectReason,t);return}if(n.token.isCancellationRequested){e("returning early - cts1 cancelled");return}const r=new hf(this.editor,5,s.range,this._cts.token),a=this.editor.getModel(),d=this._languageFeaturesService.newSymbolNamesProvider.all(a),u=await Promise.all(d.map(async k=>[k,await k.supportsAutomaticNewSymbolNamesTriggerKind??!1])),f=(k,D)=>{let M=u.slice();return k===MS.Automatic&&(M=M.filter(([F,K])=>K)),M.map(([F])=>F.provideNewSymbolNames(a,s.range,k,D))};e("creating rename input field and awaiting its result");const g=this._bulkEditService.hasPreviewHandler()&&this._configService.getValue(this.editor.getModel().uri,"editor.rename.enablePreview"),p=await this._renameWidget.getInput(s.range,s.text,g,d.length>0?f:void 0,r);if(e("received response from rename input field"),d.length>0&&this._reportTelemetry(d.length,a.getLanguageId(),p),typeof p=="boolean"){e(`returning early - rename input field response - ${p}`),p&&this.editor.focus(),r.dispose();return}this.editor.focus(),e("requesting rename edits");const w=a_(i.provideRenameEdits(p.newName,r.token),r.token).then(async k=>{if(!k){e("returning early - no rename edits result");return}if(!this.editor.hasModel()){e("returning early - no model after rename edits are provided");return}if(k.rejectReason){e(`returning early - rejected with reason: ${k.rejectReason}`),this._notificationService.info(k.rejectReason);return}this.editor.setSelection(Z.fromPositions(this.editor.getSelection().getPosition())),e("applying edits"),this._bulkEditService.apply(k,{editor:this.editor,showPreview:p.wantsPreview,label:C("label","Renaming '{0}' to '{1}'",s==null?void 0:s.text,p.newName),code:"undoredo.rename",quotableLabel:C("quotableLabel","Renaming {0} to {1}",s==null?void 0:s.text,p.newName),respectAutoSaveConfig:!0}).then(D=>{e("edits applied"),D.ariaSummary&&Ar(C("aria","Successfully renamed '{0}' to '{1}'. Summary: {2}",s.text,p.newName,D.ariaSummary))}).catch(D=>{e(`error when applying edits ${JSON.stringify(D,null," ")}`),this._notificationService.error(C("rename.failedApply","Rename failed to apply edits")),this._logService.error(D)})},k=>{e("error when providing rename edits",JSON.stringify(k,null," ")),this._notificationService.error(C("rename.failed","Rename failed to compute edits")),this._logService.error(k)}).finally(()=>{r.dispose()});return e("returning rename operation"),this._progressService.showWhile(w,250),w}acceptRenameInput(e){this._renameWidget.acceptInput(e)}cancelRenameInput(){this._renameWidget.cancelInput(!0,"cancelRenameInput command")}focusNextRenameSuggestion(){this._renameWidget.focusNextRenameSuggestion()}focusPreviousRenameSuggestion(){this._renameWidget.focusPreviousRenameSuggestion()}_reportTelemetry(e,t,i){const n=typeof i=="boolean"?{kind:"cancelled",languageId:t,nRenameSuggestionProviders:e}:{kind:"accepted",languageId:t,nRenameSuggestionProviders:e,source:i.stats.source.k,nRenameSuggestions:i.stats.nRenameSuggestions,timeBeforeFirstInputFieldEdit:i.stats.timeBeforeFirstInputFieldEdit,wantsPreview:i.wantsPreview,nRenameSuggestionsInvocations:i.stats.nRenameSuggestionsInvocations,hadAutomaticRenameSuggestionsInvocation:i.stats.hadAutomaticRenameSuggestionsInvocation};this._telemetryService.publicLog2("renameInvokedEvent",n)}},sx=du,du.ID="editor.contrib.renameController",du);Hc=sx=x8([ql(1,Zi),ql(2,co),ql(3,my),ql(4,c_),ql(5,Wu),ql(6,AF),ql(7,pi),ql(8,ha)],Hc);class L8 extends lt{constructor(){super({id:"editor.action.rename",label:C("rename.label","Rename Symbol"),alias:"Rename Symbol",precondition:Ae.and(B.writable,B.hasRenameProvider),kbOpts:{kbExpr:B.editorTextFocus,primary:60,weight:100},contextMenuOpts:{group:"1_modification",order:1.1}})}runCommand(e,t){const i=e.get(as),[n,s]=Array.isArray(t)&&t||[void 0,void 0];return Pn.isUri(n)&&gi.isIPosition(s)?i.openCodeEditor({resource:n},i.getActiveCodeEditor()).then(r=>{r&&(r.setPosition(s),r.invokeWithinContext(a=>(this.reportTelemetry(a,r),this.run(a,r))))},Nn):super.runCommand(e,t)}run(e,t){const i=e.get(Wu),n=Hc.get(t);return n?(i.trace("[RenameAction] got controller, running..."),n.run()):(i.trace("[RenameAction] returning early - controller missing"),Promise.resolve())}}nn(Hc.ID,Hc,4);xe(L8);const Sk=wo.bindToContribution(Hc.get);bi(new Sk({id:"acceptRenameInput",precondition:Jf,handler:o=>o.acceptRenameInput(!1),kbOpts:{weight:199,kbExpr:Ae.and(B.focus,Ae.not("isComposing")),primary:3}}));bi(new Sk({id:"acceptRenameInputWithPreview",precondition:Ae.and(Jf,Ae.has("config.editor.rename.enablePreview")),handler:o=>o.acceptRenameInput(!0),kbOpts:{weight:199,kbExpr:Ae.and(B.focus,Ae.not("isComposing")),primary:2051}}));bi(new Sk({id:"cancelRenameInput",precondition:Jf,handler:o=>o.cancelRenameInput(),kbOpts:{weight:199,kbExpr:B.focus,primary:9,secondary:[1033]}}));Tn(class extends yo{constructor(){super({id:"focusNextRenameSuggestion",title:{...ui("focusNextRenameSuggestion","Focus Next Rename Suggestion")},precondition:Jf,keybinding:[{primary:18,weight:199}]})}run(e){const t=e.get(as).getFocusedCodeEditor();if(!t)return;const i=Hc.get(t);i&&i.focusNextRenameSuggestion()}});Tn(class extends yo{constructor(){super({id:"focusPreviousRenameSuggestion",title:{...ui("focusPreviousRenameSuggestion","Focus Previous Rename Suggestion")},precondition:Jf,keybinding:[{primary:16,weight:199}]})}run(e){const t=e.get(as).getFocusedCodeEditor();if(!t)return;const i=Hc.get(t);i&&i.focusPreviousRenameSuggestion()}});So("_executeDocumentRenameProvider",function(o,e,t,...i){const[n]=i;Cn(typeof n=="string");const{renameProvider:s}=o.get(pi);return k8(s,e,t,n)});So("_executePrepareRename",async function(o,e,t){const{renameProvider:i}=o.get(pi),s=await new wk(e,t,i).resolveRenameLocation(Qi.None);if(s!=null&&s.rejectReason)throw new Error(s.rejectReason);return s});da.as(d_.Configuration).registerConfiguration({id:"editor",properties:{"editor.rename.enablePreview":{scope:5,description:C("enablePreview","Enable/disable the ability to preview changes before renaming"),default:!0,type:"boolean"}}});var I8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},CE=function(o,e){return function(t,i){e(t,i,o)}},af;let lb=(af=class extends Dt{constructor(e,t,i){super(),this.editor=e,this.languageConfigurationService=t,this.editorWorkerService=i,this.decorations=this.editor.createDecorationsCollection(),this.options=this.createOptions(e.getOption(73)),this.computePromise=null,this.currentOccurrences={},this._register(e.onDidChangeModel(n=>{this.currentOccurrences={},this.options=this.createOptions(e.getOption(73)),this.stop(),this.computeSectionHeaders.schedule(0)})),this._register(e.onDidChangeModelLanguage(n=>{this.currentOccurrences={},this.options=this.createOptions(e.getOption(73)),this.stop(),this.computeSectionHeaders.schedule(0)})),this._register(t.onDidChange(n=>{var r;const s=(r=this.editor.getModel())==null?void 0:r.getLanguageId();s&&n.affects(s)&&(this.currentOccurrences={},this.options=this.createOptions(e.getOption(73)),this.stop(),this.computeSectionHeaders.schedule(0))})),this._register(e.onDidChangeConfiguration(n=>{this.options&&!n.hasChanged(73)||(this.options=this.createOptions(e.getOption(73)),this.updateDecorations([]),this.stop(),this.computeSectionHeaders.schedule(0))})),this._register(this.editor.onDidChangeModelContent(n=>{this.computeSectionHeaders.schedule()})),this._register(e.onDidChangeModelTokens(n=>{this.computeSectionHeaders.isScheduled()||this.computeSectionHeaders.schedule(1e3)})),this.computeSectionHeaders=this._register(new Ss(()=>{this.findSectionHeaders()},250)),this.computeSectionHeaders.schedule(0)}createOptions(e){if(!e||!this.editor.hasModel())return;const t=this.editor.getModel().getLanguageId();if(!t)return;const i=this.languageConfigurationService.getLanguageConfiguration(t).comments,n=this.languageConfigurationService.getLanguageConfiguration(t).foldingRules;if(!(!i&&!(n!=null&&n.markers)))return{foldingRules:n,findMarkSectionHeaders:e.showMarkSectionHeaders,findRegionSectionHeaders:e.showRegionSectionHeaders}}findSectionHeaders(){var i,n;if(!this.editor.hasModel()||!((i=this.options)!=null&&i.findMarkSectionHeaders)&&!((n=this.options)!=null&&n.findRegionSectionHeaders))return;const e=this.editor.getModel();if(e.isDisposed()||e.isTooLargeForSyncing())return;const t=e.getVersionId();this.editorWorkerService.findSectionHeaders(e.uri,this.options).then(s=>{e.isDisposed()||e.getVersionId()!==t||this.updateDecorations(s)})}updateDecorations(e){const t=this.editor.getModel();t&&(e=e.filter(s=>{if(!s.shouldBeInComments)return!0;const r=t.validateRange(s.range),a=t.tokenization.getLineTokens(r.startLineNumber),d=a.findTokenIndexAtOffset(r.startColumn-1),u=a.getStandardTokenType(d);return a.getLanguageId(d)===t.getLanguageId()&&u===1}));const i=Object.values(this.currentOccurrences).map(s=>s.decorationId),n=e.map(s=>E8(s));this.editor.changeDecorations(s=>{const r=s.deltaDecorations(i,n);this.currentOccurrences={};for(let a=0,d=r.length;a<d;a++){const u={sectionHeader:e[a],decorationId:r[a]};this.currentOccurrences[u.decorationId]=u}})}stop(){this.computeSectionHeaders.cancel(),this.computePromise&&(this.computePromise.cancel(),this.computePromise=null)}dispose(){super.dispose(),this.stop(),this.decorations.clear()}},af.ID="editor.sectionHeaderDetector",af);lb=I8([CE(1,Ds),CE(2,Al)],lb);function E8(o){return{range:o.range,options:dn.createDynamic({description:"section-header",stickiness:3,collapseOnReplaceEdit:!0,minimap:{color:void 0,position:1,sectionHeaderStyle:o.hasSeparatorLine?2:1,sectionHeaderText:o.text}})}}nn(lb.ID,lb,1);function D8(o){for(let e=0,t=o.length;e<t;e+=4){const i=o[e+0],n=o[e+1],s=o[e+2],r=o[e+3];o[e+0]=r,o[e+1]=s,o[e+2]=n,o[e+3]=i}}function T8(o){const e=new Uint8Array(o.buffer,o.byteOffset,o.length*4);return OF()||D8(e),FF.wrap(e)}function _N(o){const e=new Uint32Array(P8(o));let t=0;if(e[t++]=o.id,o.type==="full")e[t++]=1,e[t++]=o.data.length,e.set(o.data,t),t+=o.data.length;else{e[t++]=2,e[t++]=o.deltas.length;for(const i of o.deltas)e[t++]=i.start,e[t++]=i.deleteCount,i.data?(e[t++]=i.data.length,e.set(i.data,t),t+=i.data.length):e[t++]=0}return T8(e)}function P8(o){let e=0;if(e+=2,o.type==="full")e+=1+o.data.length;else{e+=1,e+=3*o.deltas.length;for(const t of o.deltas)t.data&&(e+=t.data.length)}return e}function rw(o){return o&&!!o.data}function mN(o){return o&&Array.isArray(o.edits)}class M8{constructor(e,t,i){this.provider=e,this.tokens=t,this.error=i}}function vN(o,e){return o.has(e)}function R8(o,e){const t=o.orderedGroups(e);return t.length>0?t[0]:[]}async function bN(o,e,t,i,n){const s=R8(o,e),r=await Promise.all(s.map(async a=>{let d,u=null;try{d=await a.provideDocumentSemanticTokens(e,a===t?i:null,n)}catch(f){u=f,d=null}return(!d||!rw(d)&&!mN(d))&&(d=null),new M8(a,d,u)}));for(const a of r){if(a.error)throw a.error;if(a.tokens)return a}return r.length>0?r[0]:null}function N8(o,e){const t=o.orderedGroups(e);return t.length>0?t[0]:null}class A8{constructor(e,t){this.provider=e,this.tokens=t}}function O8(o,e){return o.has(e)}function yN(o,e){const t=o.orderedGroups(e);return t.length>0?t[0]:[]}async function Ck(o,e,t,i){const n=yN(o,e),s=await Promise.all(n.map(async r=>{let a;try{a=await r.provideDocumentRangeSemanticTokens(e,t,i)}catch(d){rs(d),a=null}return(!a||!rw(a))&&(a=null),new A8(r,a)}));for(const r of s)if(r.tokens)return r;return s.length>0?s[0]:null}Wn.registerCommand("_provideDocumentSemanticTokensLegend",async(o,...e)=>{const[t]=e;Cn(t instanceof Pn);const i=o.get(uo).getModel(t);if(!i)return;const{documentSemanticTokensProvider:n}=o.get(pi),s=N8(n,i);return s?s[0].getLegend():o.get(Es).executeCommand("_provideDocumentRangeSemanticTokensLegend",t)});Wn.registerCommand("_provideDocumentSemanticTokens",async(o,...e)=>{const[t]=e;Cn(t instanceof Pn);const i=o.get(uo).getModel(t);if(!i)return;const{documentSemanticTokensProvider:n}=o.get(pi);if(!vN(n,i))return o.get(Es).executeCommand("_provideDocumentRangeSemanticTokens",t,i.getFullModelRange());const s=await bN(n,i,null,null,Qi.None);if(!s)return;const{provider:r,tokens:a}=s;if(!a||!rw(a))return;const d=_N({id:0,type:"full",data:a.data});return a.resultId&&r.releaseDocumentSemanticTokens(a.resultId),d});Wn.registerCommand("_provideDocumentRangeSemanticTokensLegend",async(o,...e)=>{const[t,i]=e;Cn(t instanceof Pn);const n=o.get(uo).getModel(t);if(!n)return;const{documentRangeSemanticTokensProvider:s}=o.get(pi),r=yN(s,n);if(r.length===0)return;if(r.length===1)return r[0].getLegend();if(!i||!Z.isIRange(i))return console.warn("provideDocumentRangeSemanticTokensLegend might be out-of-sync with provideDocumentRangeSemanticTokens unless a range argument is passed in"),r[0].getLegend();const a=await Ck(s,n,Z.lift(i),Qi.None);if(a)return a.provider.getLegend()});Wn.registerCommand("_provideDocumentRangeSemanticTokens",async(o,...e)=>{const[t,i]=e;Cn(t instanceof Pn),Cn(Z.isIRange(i));const n=o.get(uo).getModel(t);if(!n)return;const{documentRangeSemanticTokensProvider:s}=o.get(pi),r=await Ck(s,n,Z.lift(i),Qi.None);if(!(!r||!r.tokens))return _N({id:0,type:"full",data:r.tokens.data})});const xk="editor.semanticHighlighting";function Ym(o,e,t){var n;const i=(n=t.getValue(xk,{overrideIdentifier:o.getLanguageId(),resource:o.uri}))==null?void 0:n.enabled;return typeof i=="boolean"?i:e.getColorTheme().semanticHighlighting}var wN=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ta=function(o,e){return function(t,i){e(t,i,o)}},Kl;let ox=class extends Dt{constructor(e,t,i,n,s,r){super(),this._watchers=Object.create(null);const a=f=>{this._watchers[f.uri.toString()]=new rx(f,e,i,s,r)},d=(f,g)=>{g.dispose(),delete this._watchers[f.uri.toString()]},u=()=>{for(const f of t.getModels()){const g=this._watchers[f.uri.toString()];Ym(f,i,n)?g||a(f):g&&d(f,g)}};t.getModels().forEach(f=>{Ym(f,i,n)&&a(f)}),this._register(t.onModelAdded(f=>{Ym(f,i,n)&&a(f)})),this._register(t.onModelRemoved(f=>{const g=this._watchers[f.uri.toString()];g&&d(f,g)})),this._register(n.onDidChangeConfiguration(f=>{f.affectsConfiguration(xk)&&u()})),this._register(i.onDidColorThemeChange(u))}dispose(){for(const e of Object.values(this._watchers))e.dispose();super.dispose()}};ox=wN([Ta(0,S0),Ta(1,uo),Ta(2,Hr),Ta(3,Un),Ta(4,ur),Ta(5,pi)],ox);var Dc;let rx=(Dc=class extends Dt{constructor(e,t,i,n,s){super(),this._semanticTokensStylingService=t,this._isDisposed=!1,this._model=e,this._provider=s.documentSemanticTokensProvider,this._debounceInformation=n.for(this._provider,"DocumentSemanticTokens",{min:Kl.REQUEST_MIN_DELAY,max:Kl.REQUEST_MAX_DELAY}),this._fetchDocumentSemanticTokens=this._register(new Ss(()=>this._fetchDocumentSemanticTokensNow(),Kl.REQUEST_MIN_DELAY)),this._currentDocumentResponse=null,this._currentDocumentRequestCancellationTokenSource=null,this._documentProvidersChangeListeners=[],this._providersChangedDuringRequest=!1,this._register(this._model.onDidChangeContent(()=>{this._fetchDocumentSemanticTokens.isScheduled()||this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._register(this._model.onDidChangeAttached(()=>{this._fetchDocumentSemanticTokens.isScheduled()||this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._register(this._model.onDidChangeLanguage(()=>{this._currentDocumentResponse&&(this._currentDocumentResponse.dispose(),this._currentDocumentResponse=null),this._currentDocumentRequestCancellationTokenSource&&(this._currentDocumentRequestCancellationTokenSource.cancel(),this._currentDocumentRequestCancellationTokenSource=null),this._setDocumentSemanticTokens(null,null,null,[]),this._fetchDocumentSemanticTokens.schedule(0)}));const r=()=>{no(this._documentProvidersChangeListeners),this._documentProvidersChangeListeners=[];for(const a of this._provider.all(e))typeof a.onDidChange=="function"&&this._documentProvidersChangeListeners.push(a.onDidChange(()=>{if(this._currentDocumentRequestCancellationTokenSource){this._providersChangedDuringRequest=!0;return}this._fetchDocumentSemanticTokens.schedule(0)}))};r(),this._register(this._provider.onDidChange(()=>{r(),this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._register(i.onDidColorThemeChange(a=>{this._setDocumentSemanticTokens(null,null,null,[]),this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._fetchDocumentSemanticTokens.schedule(0)}dispose(){this._currentDocumentResponse&&(this._currentDocumentResponse.dispose(),this._currentDocumentResponse=null),this._currentDocumentRequestCancellationTokenSource&&(this._currentDocumentRequestCancellationTokenSource.cancel(),this._currentDocumentRequestCancellationTokenSource=null),no(this._documentProvidersChangeListeners),this._documentProvidersChangeListeners=[],this._setDocumentSemanticTokens(null,null,null,[]),this._isDisposed=!0,super.dispose()}_fetchDocumentSemanticTokensNow(){if(this._currentDocumentRequestCancellationTokenSource)return;if(!vN(this._provider,this._model)){this._currentDocumentResponse&&this._model.tokenization.setSemanticTokens(null,!1);return}if(!this._model.isAttachedToEditor())return;const e=new Fs,t=this._currentDocumentResponse?this._currentDocumentResponse.provider:null,i=this._currentDocumentResponse&&this._currentDocumentResponse.resultId||null,n=bN(this._provider,this._model,t,i,e.token);this._currentDocumentRequestCancellationTokenSource=e,this._providersChangedDuringRequest=!1;const s=[],r=this._model.onDidChangeContent(d=>{s.push(d)}),a=new Mo(!1);n.then(d=>{if(this._debounceInformation.update(this._model,a.elapsed()),this._currentDocumentRequestCancellationTokenSource=null,r.dispose(),!d)this._setDocumentSemanticTokens(null,null,null,s);else{const{provider:u,tokens:f}=d,g=this._semanticTokensStylingService.getStyling(u);this._setDocumentSemanticTokens(u,f||null,g,s)}},d=>{d&&(Bc(d)||typeof d.message=="string"&&d.message.indexOf("busy")!==-1)||Nn(d),this._currentDocumentRequestCancellationTokenSource=null,r.dispose(),(s.length>0||this._providersChangedDuringRequest)&&(this._fetchDocumentSemanticTokens.isScheduled()||this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model)))})}static _copy(e,t,i,n,s){s=Math.min(s,i.length-n,e.length-t);for(let r=0;r<s;r++)i[n+r]=e[t+r]}_setDocumentSemanticTokens(e,t,i,n){const s=this._currentDocumentResponse,r=()=>{(n.length>0||this._providersChangedDuringRequest)&&!this._fetchDocumentSemanticTokens.isScheduled()&&this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))};if(this._currentDocumentResponse&&(this._currentDocumentResponse.dispose(),this._currentDocumentResponse=null),this._isDisposed){e&&t&&e.releaseDocumentSemanticTokens(t.resultId);return}if(!e||!i){this._model.tokenization.setSemanticTokens(null,!1);return}if(!t){this._model.tokenization.setSemanticTokens(null,!0),r();return}if(mN(t)){if(!s){this._model.tokenization.setSemanticTokens(null,!0);return}if(t.edits.length===0)t={resultId:t.resultId,data:s.data};else{let a=0;for(const p of t.edits)a+=(p.data?p.data.length:0)-p.deleteCount;const d=s.data,u=new Uint32Array(d.length+a);let f=d.length,g=u.length;for(let p=t.edits.length-1;p>=0;p--){const w=t.edits[p];if(w.start>d.length){i.warnInvalidEditStart(s.resultId,t.resultId,p,w.start,d.length),this._model.tokenization.setSemanticTokens(null,!0);return}const y=f-(w.start+w.deleteCount);y>0&&(Kl._copy(d,f-y,u,g-y,y),g-=y),w.data&&(Kl._copy(w.data,0,u,g-w.data.length,w.data.length),g-=w.data.length),f=w.start}f>0&&Kl._copy(d,0,u,0,f),t={resultId:t.resultId,data:u}}}if(rw(t)){this._currentDocumentResponse=new F8(e,t.resultId,t.data);const a=QT(t,i,this._model.getLanguageId());if(n.length>0)for(const d of n)for(const u of a)for(const f of d.changes)u.applyEdit(f.range,f.text);this._model.tokenization.setSemanticTokens(a,!0)}else this._model.tokenization.setSemanticTokens(null,!0);r()}},Kl=Dc,Dc.REQUEST_MIN_DELAY=300,Dc.REQUEST_MAX_DELAY=2e3,Dc);rx=Kl=wN([Ta(1,S0),Ta(2,Hr),Ta(3,ur),Ta(4,pi)],rx);class F8{constructor(e,t,i){this.provider=e,this.resultId=t,this.data=i}dispose(){this.provider.releaseDocumentSemanticTokens(this.resultId)}}$f(ox);var H8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},wg=function(o,e){return function(t,i){e(t,i,o)}},lf;let cb=(lf=class extends Dt{constructor(e,t,i,n,s,r){super(),this._semanticTokensStylingService=t,this._themeService=i,this._configurationService=n,this._editor=e,this._provider=r.documentRangeSemanticTokensProvider,this._debounceInformation=s.for(this._provider,"DocumentRangeSemanticTokens",{min:100,max:500}),this._tokenizeViewport=this._register(new Ss(()=>this._tokenizeViewportNow(),100)),this._outstandingRequests=[];const a=()=>{this._editor.hasModel()&&this._tokenizeViewport.schedule(this._debounceInformation.get(this._editor.getModel()))};this._register(this._editor.onDidScrollChange(()=>{a()})),this._register(this._editor.onDidChangeModel(()=>{this._cancelAll(),a()})),this._register(this._editor.onDidChangeModelContent(d=>{this._cancelAll(),a()})),this._register(this._provider.onDidChange(()=>{this._cancelAll(),a()})),this._register(this._configurationService.onDidChangeConfiguration(d=>{d.affectsConfiguration(xk)&&(this._cancelAll(),a())})),this._register(this._themeService.onDidColorThemeChange(()=>{this._cancelAll(),a()})),a()}_cancelAll(){for(const e of this._outstandingRequests)e.cancel();this._outstandingRequests=[]}_removeOutstandingRequest(e){for(let t=0,i=this._outstandingRequests.length;t<i;t++)if(this._outstandingRequests[t]===e){this._outstandingRequests.splice(t,1);return}}_tokenizeViewportNow(){if(!this._editor.hasModel())return;const e=this._editor.getModel();if(e.tokenization.hasCompleteSemanticTokens())return;if(!Ym(e,this._themeService,this._configurationService)){e.tokenization.hasSomeSemanticTokens()&&e.tokenization.setSemanticTokens(null,!1);return}if(!O8(this._provider,e)){e.tokenization.hasSomeSemanticTokens()&&e.tokenization.setSemanticTokens(null,!1);return}const t=this._editor.getVisibleRangesPlusViewportAboveBelow();this._outstandingRequests=this._outstandingRequests.concat(t.map(i=>this._requestRange(e,i)))}_requestRange(e,t){const i=e.getVersionId(),n=Os(r=>Promise.resolve(Ck(this._provider,e,t,r))),s=new Mo(!1);return n.then(r=>{if(this._debounceInformation.update(e,s.elapsed()),!r||!r.tokens||e.isDisposed()||e.getVersionId()!==i)return;const{provider:a,tokens:d}=r,u=this._semanticTokensStylingService.getStyling(a);e.tokenization.setPartialSemanticTokens(t,QT(d,u,e.getLanguageId()))}).then(()=>this._removeOutstandingRequest(n),()=>this._removeOutstandingRequest(n)),n}},lf.ID="editor.contrib.viewportSemanticTokens",lf);cb=H8([wg(1,S0),wg(2,Hr),wg(3,Un),wg(4,ur),wg(5,pi)],cb);nn(cb.ID,cb,1);class W8{constructor(e=!0){this.selectSubwords=e}provideSelectionRanges(e,t){const i=[];for(const n of t){const s=[];i.push(s),this.selectSubwords&&this._addInWordRanges(s,e,n),this._addWordRanges(s,e,n),this._addWhitespaceLine(s,e,n),s.push({range:e.getFullModelRange()})}return i}_addInWordRanges(e,t,i){const n=t.getWordAtPosition(i);if(!n)return;const{word:s,startColumn:r}=n,a=i.column-r;let d=a,u=a,f=0;for(;d>=0;d--){const g=s.charCodeAt(d);if(d!==a&&(g===95||g===45))break;if(AL(g)&&OL(f))break;f=g}for(d+=1;u<s.length;u++){const g=s.charCodeAt(u);if(OL(g)&&AL(f))break;if(g===95||g===45)break;f=g}d<u&&e.push({range:new Z(i.lineNumber,r+d,i.lineNumber,r+u)})}_addWordRanges(e,t,i){const n=t.getWordAtPosition(i);n&&e.push({range:new Z(i.lineNumber,n.startColumn,i.lineNumber,n.endColumn)})}_addWhitespaceLine(e,t,i){t.getLineLength(i.lineNumber)>0&&t.getLineFirstNonWhitespaceColumn(i.lineNumber)===0&&t.getLineLastNonWhitespaceColumn(i.lineNumber)===0&&e.push({range:new Z(i.lineNumber,1,i.lineNumber,t.getLineMaxColumn(i.lineNumber))})}}var B8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},z8=function(o,e){return function(t,i){e(t,i,o)}},ax;class kk{constructor(e,t){this.index=e,this.ranges=t}mov(e){const t=this.index+(e?1:-1);if(t<0||t>=this.ranges.length)return this;const i=new kk(t,this.ranges);return i.ranges[t].equalsRange(this.ranges[this.index])?i.mov(e):i}}var uu;let jp=(uu=class{static get(e){return e.getContribution(ax.ID)}constructor(e,t){this._editor=e,this._languageFeaturesService=t,this._ignoreSelection=!1}dispose(){var e;(e=this._selectionListener)==null||e.dispose()}async run(e){if(!this._editor.hasModel())return;const t=this._editor.getSelections(),i=this._editor.getModel();if(this._state||await CN(this._languageFeaturesService.selectionRangeProvider,i,t.map(s=>s.getPosition()),this._editor.getOption(114),Qi.None).then(s=>{var r;if(!(!$o(s)||s.length!==t.length)&&!(!this._editor.hasModel()||!Va(this._editor.getSelections(),t,(a,d)=>a.equalsSelection(d)))){for(let a=0;a<s.length;a++)s[a]=s[a].filter(d=>d.containsPosition(t[a].getStartPosition())&&d.containsPosition(t[a].getEndPosition())),s[a].unshift(t[a]);this._state=s.map(a=>new kk(0,a)),(r=this._selectionListener)==null||r.dispose(),this._selectionListener=this._editor.onDidChangeCursorPosition(()=>{var a;this._ignoreSelection||((a=this._selectionListener)==null||a.dispose(),this._state=void 0)})}}),!this._state)return;this._state=this._state.map(s=>s.mov(e));const n=this._state.map(s=>Fi.fromPositions(s.ranges[s.index].getStartPosition(),s.ranges[s.index].getEndPosition()));this._ignoreSelection=!0;try{this._editor.setSelections(n)}finally{this._ignoreSelection=!1}}},ax=uu,uu.ID="editor.contrib.smartSelectController",uu);jp=ax=B8([z8(1,pi)],jp);class SN extends lt{constructor(e,t){super(t),this._forward=e}async run(e,t){const i=jp.get(t);i&&await i.run(this._forward)}}class V8 extends SN{constructor(){super(!0,{id:"editor.action.smartSelect.expand",label:C("smartSelect.expand","Expand Selection"),alias:"Expand Selection",precondition:void 0,kbOpts:{kbExpr:B.editorTextFocus,primary:1553,mac:{primary:3345,secondary:[1297]},weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"1_basic",title:C({key:"miSmartSelectGrow",comment:["&& denotes a mnemonic"]},"&&Expand Selection"),order:2}})}}Wn.registerCommandAlias("editor.action.smartSelect.grow","editor.action.smartSelect.expand");class j8 extends SN{constructor(){super(!1,{id:"editor.action.smartSelect.shrink",label:C("smartSelect.shrink","Shrink Selection"),alias:"Shrink Selection",precondition:void 0,kbOpts:{kbExpr:B.editorTextFocus,primary:1551,mac:{primary:3343,secondary:[1295]},weight:100},menuOpts:{menuId:Gt.MenubarSelectionMenu,group:"1_basic",title:C({key:"miSmartSelectShrink",comment:["&& denotes a mnemonic"]},"&&Shrink Selection"),order:3}})}}nn(jp.ID,jp,4);xe(V8);xe(j8);async function CN(o,e,t,i,n){const s=o.all(e).concat(new W8(i.selectSubwords));s.length===1&&s.unshift(new Gv);const r=[],a=[];for(const d of s)r.push(Promise.resolve(d.provideSelectionRanges(e,t,n)).then(u=>{if($o(u)&&u.length===t.length)for(let f=0;f<t.length;f++){a[f]||(a[f]=[]);for(const g of u[f])Z.isIRange(g.range)&&Z.containsPosition(g.range,t[f])&&a[f].push(Z.lift(g.range))}},rs));return await Promise.all(r),a.map(d=>{if(d.length===0)return[];d.sort((p,w)=>gi.isBefore(p.getStartPosition(),w.getStartPosition())?1:gi.isBefore(w.getStartPosition(),p.getStartPosition())||gi.isBefore(p.getEndPosition(),w.getEndPosition())?-1:gi.isBefore(w.getEndPosition(),p.getEndPosition())?1:0);const u=[];let f;for(const p of d)(!f||Z.containsRange(p,f)&&!Z.equalsRange(p,f))&&(u.push(p),f=p);if(!i.selectLeadingAndTrailingWhitespace)return u;const g=[u[0]];for(let p=1;p<u.length;p++){const w=u[p-1],y=u[p];if(y.startLineNumber!==w.startLineNumber||y.endLineNumber!==w.endLineNumber){const x=new Z(w.startLineNumber,e.getLineFirstNonWhitespaceColumn(w.startLineNumber),w.endLineNumber,e.getLineLastNonWhitespaceColumn(w.endLineNumber));x.containsRange(w)&&!x.equalsRange(w)&&y.containsRange(x)&&!y.equalsRange(x)&&g.push(x);const k=new Z(w.startLineNumber,1,w.endLineNumber,e.getLineMaxColumn(w.endLineNumber));k.containsRange(w)&&!k.equalsRange(x)&&y.containsRange(k)&&!y.equalsRange(k)&&g.push(k)}g.push(y)}return g})}Wn.registerCommand("_executeSelectionRangeProvider",async function(o,...e){const[t,i]=e;Cn(Pn.isUri(t));const n=o.get(pi).selectionRangeProvider,s=await o.get(ga).createModelReference(t);try{return CN(n,s.object.textEditorModel,i,{selectLeadingAndTrailingWhitespace:!0,selectSubwords:!0},Qi.None)}finally{s.dispose()}});const $8=Object.freeze({View:ui("view","View"),Help:ui("help","Help"),Test:ui("test","Test"),File:ui("file","File"),Preferences:ui("preferences","Preferences"),Developer:ui({key:"developer",comment:["A developer on Code itself or someone diagnosing issues in Code"]},"Developer")});class ip{constructor(e,t,i,n=null){this.startLineNumbers=e,this.endLineNumbers=t,this.lastLineRelativePosition=i,this.showEndForLine=n}equals(e){return!!e&&this.lastLineRelativePosition===e.lastLineRelativePosition&&this.showEndForLine===e.showEndForLine&&Va(this.startLineNumbers,e.startLineNumbers)&&Va(this.endLineNumbers,e.endLineNumbers)}static get Empty(){return new ip([],[],0)}}const xE=yT("stickyScrollViewLayer",{createHTML:o=>o}),aS="data-sticky-line-index",kE="data-sticky-is-line",U8="data-sticky-is-line-number",LE="data-sticky-is-folding-icon";class q8 extends Dt{constructor(e){super(),this._editor=e,this._foldingIconStore=new Lt,this._rootDomNode=document.createElement("div"),this._lineNumbersDomNode=document.createElement("div"),this._linesDomNodeScrollable=document.createElement("div"),this._linesDomNode=document.createElement("div"),this._lineHeight=this._editor.getOption(67),this._renderedStickyLines=[],this._lineNumbers=[],this._lastLineRelativePosition=0,this._minContentWidthInPx=0,this._isOnGlyphMargin=!1,this._lineNumbersDomNode.className="sticky-widget-line-numbers",this._lineNumbersDomNode.setAttribute("role","none"),this._linesDomNode.className="sticky-widget-lines",this._linesDomNode.setAttribute("role","list"),this._linesDomNodeScrollable.className="sticky-widget-lines-scrollable",this._linesDomNodeScrollable.appendChild(this._linesDomNode),this._rootDomNode.className="sticky-widget",this._rootDomNode.classList.toggle("peek",e instanceof Fr),this._rootDomNode.appendChild(this._lineNumbersDomNode),this._rootDomNode.appendChild(this._linesDomNodeScrollable);const t=()=>{this._linesDomNode.style.left=this._editor.getOption(116).scrollWithEditor?`-${this._editor.getScrollLeft()}px`:"0px"};this._register(this._editor.onDidChangeConfiguration(i=>{i.hasChanged(116)&&t(),i.hasChanged(67)&&(this._lineHeight=this._editor.getOption(67))})),this._register(this._editor.onDidScrollChange(i=>{i.scrollLeftChanged&&t(),i.scrollWidthChanged&&this._updateWidgetWidth()})),this._register(this._editor.onDidChangeModel(()=>{t(),this._updateWidgetWidth()})),this._register(this._foldingIconStore),t(),this._register(this._editor.onDidLayoutChange(i=>{this._updateWidgetWidth()})),this._updateWidgetWidth()}get lineNumbers(){return this._lineNumbers}get lineNumberCount(){return this._lineNumbers.length}getRenderedStickyLine(e){return this._renderedStickyLines.find(t=>t.lineNumber===e)}getCurrentLines(){return this._lineNumbers}setState(e,t,i){if(i===void 0&&(!this._previousState&&!e||this._previousState&&this._previousState.equals(e)))return;const n=this._isWidgetHeightZero(e),s=n?void 0:e,r=n?0:this._findLineToRebuildWidgetFrom(e,i);this._renderRootNode(s,t,r),this._previousState=e}_isWidgetHeightZero(e){if(!e)return!0;const t=e.startLineNumbers.length*this._lineHeight+e.lastLineRelativePosition;if(t>0){this._lastLineRelativePosition=e.lastLineRelativePosition;const i=[...e.startLineNumbers];e.showEndForLine!==null&&(i[e.showEndForLine]=e.endLineNumbers[e.showEndForLine]),this._lineNumbers=i}else this._lastLineRelativePosition=0,this._lineNumbers=[];return t===0}_findLineToRebuildWidgetFrom(e,t){if(!e||!this._previousState)return 0;if(t!==void 0)return t;const i=this._previousState,n=e.startLineNumbers.findIndex(s=>!i.startLineNumbers.includes(s));return n===-1?0:n}_updateWidgetWidth(){const e=this._editor.getLayoutInfo(),t=e.contentLeft;this._lineNumbersDomNode.style.width=`${t}px`,this._linesDomNodeScrollable.style.setProperty("--vscode-editorStickyScroll-scrollableWidth",`${this._editor.getScrollWidth()-e.verticalScrollbarWidth}px`),this._rootDomNode.style.width=`${e.width-e.verticalScrollbarWidth}px`}_clearStickyLinesFromLine(e){this._foldingIconStore.clear();for(let t=e;t<this._renderedStickyLines.length;t++){const i=this._renderedStickyLines[t];i.lineNumberDomNode.remove(),i.lineDomNode.remove()}this._renderedStickyLines=this._renderedStickyLines.slice(0,e),this._rootDomNode.style.display="none"}_useFoldingOpacityTransition(e){this._lineNumbersDomNode.style.setProperty("--vscode-editorStickyScroll-foldingOpacityTransition",`opacity ${e?.5:0}s`)}_setFoldingIconsVisibility(e){for(const t of this._renderedStickyLines){const i=t.foldingIcon;i&&i.setVisible(e?!0:i.isCollapsed)}}async _renderRootNode(e,t,i){if(this._clearStickyLinesFromLine(i),!e)return;for(const a of this._renderedStickyLines)this._updateTopAndZIndexOfStickyLine(a);const n=this._editor.getLayoutInfo(),s=this._lineNumbers.slice(i);for(const[a,d]of s.entries()){const u=this._renderChildNode(a+i,d,t,n);u&&(this._linesDomNode.appendChild(u.lineDomNode),this._lineNumbersDomNode.appendChild(u.lineNumberDomNode),this._renderedStickyLines.push(u))}t&&(this._setFoldingHoverListeners(),this._useFoldingOpacityTransition(!this._isOnGlyphMargin));const r=this._lineNumbers.length*this._lineHeight+this._lastLineRelativePosition;this._rootDomNode.style.display="block",this._lineNumbersDomNode.style.height=`${r}px`,this._linesDomNodeScrollable.style.height=`${r}px`,this._rootDomNode.style.height=`${r}px`,this._rootDomNode.style.marginLeft="0px",this._minContentWidthInPx=Math.max(...this._renderedStickyLines.map(a=>a.scrollWidth))+n.verticalScrollbarWidth,this._editor.layoutOverlayWidget(this)}_setFoldingHoverListeners(){this._editor.getOption(111)==="mouseover"&&(this._foldingIconStore.add(wn(this._lineNumbersDomNode,Zn.MOUSE_ENTER,()=>{this._isOnGlyphMargin=!0,this._setFoldingIconsVisibility(!0)})),this._foldingIconStore.add(wn(this._lineNumbersDomNode,Zn.MOUSE_LEAVE,()=>{this._isOnGlyphMargin=!1,this._useFoldingOpacityTransition(!0),this._setFoldingIconsVisibility(!1)})))}_renderChildNode(e,t,i,n){const s=this._editor._getViewModel();if(!s)return;const r=s.coordinatesConverter.convertModelPositionToViewPosition(new gi(t,1)).lineNumber,a=s.getViewLineRenderingData(r),d=this._editor.getOption(68);let u;try{u=yp.filter(a.inlineDecorations,r,a.minColumn,a.maxColumn)}catch{u=[]}const f=new CT(!0,!0,a.content,a.continuesWithWrappedLine,a.isBasicASCII,a.containsRTL,0,a.tokens,u,a.tabSize,a.startVisibleColumn,1,1,1,500,"none",!0,!0,null),g=new wT(2e3),p=ST(f,g);let w;xE?w=xE.createHTML(g.build()):w=g.build();const y=document.createElement("span");y.setAttribute(aS,String(e)),y.setAttribute(kE,""),y.setAttribute("role","listitem"),y.tabIndex=0,y.className="sticky-line-content",y.classList.add(`stickyLine${t}`),y.style.lineHeight=`${this._lineHeight}px`,y.innerHTML=w;const x=document.createElement("span");x.setAttribute(aS,String(e)),x.setAttribute(U8,""),x.className="sticky-line-number",x.style.lineHeight=`${this._lineHeight}px`;const k=n.contentLeft;x.style.width=`${k}px`;const D=document.createElement("span");d.renderType===1||d.renderType===3&&t%10===0?D.innerText=t.toString():d.renderType===2&&(D.innerText=Math.abs(t-this._editor.getPosition().lineNumber).toString()),D.className="sticky-line-number-inner",D.style.lineHeight=`${this._lineHeight}px`,D.style.width=`${n.lineNumbersWidth}px`,D.style.paddingLeft=`${n.lineNumbersLeft}px`,x.appendChild(D);const M=this._renderFoldingIconForLine(i,t);M&&x.appendChild(M.domNode),this._editor.applyFontInfo(y),this._editor.applyFontInfo(D),x.style.lineHeight=`${this._lineHeight}px`,y.style.lineHeight=`${this._lineHeight}px`,x.style.height=`${this._lineHeight}px`,y.style.height=`${this._lineHeight}px`;const F=new G8(e,t,y,x,M,p.characterMapping,y.scrollWidth);return this._updateTopAndZIndexOfStickyLine(F)}_updateTopAndZIndexOfStickyLine(e){var f;const t=e.index,i=e.lineDomNode,n=e.lineNumberDomNode,s=t===this._lineNumbers.length-1,r="0",a="1";i.style.zIndex=s?r:a,n.style.zIndex=s?r:a;const d=`${t*this._lineHeight+this._lastLineRelativePosition+((f=e.foldingIcon)!=null&&f.isCollapsed?1:0)}px`,u=`${t*this._lineHeight}px`;return i.style.top=s?d:u,n.style.top=s?d:u,e}_renderFoldingIconForLine(e,t){const i=this._editor.getOption(111);if(!e||i==="never")return;const n=e.regions,s=n.findRange(t),r=n.getStartLineNumber(s);if(!(t===r))return;const d=n.isCollapsed(s),u=new K8(d,r,n.getEndLineNumber(s),this._lineHeight);return u.setVisible(this._isOnGlyphMargin?!0:d||i==="always"),u.domNode.setAttribute(LE,""),u}getId(){return"editor.contrib.stickyScrollWidget"}getDomNode(){return this._rootDomNode}getPosition(){return{preference:2,stackOridinal:10}}getMinContentWidthInPx(){return this._minContentWidthInPx}focusLineWithIndex(e){0<=e&&e<this._renderedStickyLines.length&&this._renderedStickyLines[e].lineDomNode.focus()}getEditorPositionFromNode(e){if(!e||e.children.length>0)return null;const t=this._getRenderedStickyLineFromChildDomNode(e);if(!t)return null;const i=HF(t.characterMapping,e,0);return new gi(t.lineNumber,i)}getLineNumberFromChildDomNode(e){var t;return((t=this._getRenderedStickyLineFromChildDomNode(e))==null?void 0:t.lineNumber)??null}_getRenderedStickyLineFromChildDomNode(e){const t=this.getLineIndexFromChildDomNode(e);return t===null||t<0||t>=this._renderedStickyLines.length?null:this._renderedStickyLines[t]}getLineIndexFromChildDomNode(e){const t=this._getAttributeValue(e,aS);return t?parseInt(t,10):null}isInStickyLine(e){return this._getAttributeValue(e,kE)!==void 0}isInFoldingIconDomNode(e){return this._getAttributeValue(e,LE)!==void 0}_getAttributeValue(e,t){for(;e&&e!==this._rootDomNode;){const i=e.getAttribute(t);if(i!==null)return i;e=e.parentElement}}}class G8{constructor(e,t,i,n,s,r,a){this.index=e,this.lineNumber=t,this.lineDomNode=i,this.lineNumberDomNode=n,this.foldingIcon=s,this.characterMapping=r,this.scrollWidth=a}}class K8{constructor(e,t,i,n){this.isCollapsed=e,this.foldingStartLine=t,this.foldingEndLine=i,this.dimension=n,this.domNode=document.createElement("div"),this.domNode.style.width=`${n}px`,this.domNode.style.height=`${n}px`,this.domNode.className=xn.asClassName(e?Ov:Av)}setVisible(e){this.domNode.style.cursor=e?"pointer":"default",this.domNode.style.opacity=e?"1":"0"}}class np{constructor(e,t){this.startLineNumber=e,this.endLineNumber=t}}class db{constructor(e,t,i){this.range=e,this.children=t,this.parent=i}}class xN{constructor(e,t,i,n){this.uri=e,this.version=t,this.element=i,this.outlineProviderId=n}}var aw=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},$p=function(o,e){return function(t,i){e(t,i,o)}},sp;(function(o){o.OUTLINE_MODEL="outlineModel",o.FOLDING_PROVIDER_MODEL="foldingProviderModel",o.INDENTATION_MODEL="indentationModel"})(sp||(sp={}));var cc;(function(o){o[o.VALID=0]="VALID",o[o.INVALID=1]="INVALID",o[o.CANCELED=2]="CANCELED"})(cc||(cc={}));let lx=class extends Dt{constructor(e,t,i,n){switch(super(),this._editor=e,this._modelProviders=[],this._modelPromise=null,this._updateScheduler=this._register(new Mc(300)),this._updateOperation=this._register(new Lt),this._editor.getOption(116).defaultModel){case sp.OUTLINE_MODEL:this._modelProviders.push(new cx(this._editor,n));case sp.FOLDING_PROVIDER_MODEL:this._modelProviders.push(new ux(this._editor,t,n));case sp.INDENTATION_MODEL:this._modelProviders.push(new dx(this._editor,i));break}}dispose(){this._modelProviders.forEach(e=>e.dispose()),this._updateOperation.clear(),this._cancelModelPromise(),super.dispose()}_cancelModelPromise(){this._modelPromise&&(this._modelPromise.cancel(),this._modelPromise=null)}async update(e){return this._updateOperation.clear(),this._updateOperation.add({dispose:()=>{this._cancelModelPromise(),this._updateScheduler.cancel()}}),this._cancelModelPromise(),await this._updateScheduler.trigger(async()=>{for(const t of this._modelProviders){const{statusPromise:i,modelPromise:n}=t.computeStickyModel(e);this._modelPromise=n;const s=await i;if(this._modelPromise!==n)return null;switch(s){case cc.CANCELED:return this._updateOperation.clear(),null;case cc.VALID:return t.stickyModel}}return null}).catch(t=>(Nn(t),null))}};lx=aw([$p(2,Zi),$p(3,pi)],lx);class kN extends Dt{constructor(e){super(),this._editor=e,this._stickyModel=null}get stickyModel(){return this._stickyModel}_invalid(){return this._stickyModel=null,cc.INVALID}computeStickyModel(e){if(e.isCancellationRequested||!this.isProviderValid())return{statusPromise:this._invalid(),modelPromise:null};const t=Os(i=>this.createModelFromProvider(i));return{statusPromise:t.then(i=>this.isModelValid(i)?e.isCancellationRequested?cc.CANCELED:(this._stickyModel=this.createStickyModel(e,i),cc.VALID):this._invalid()).then(void 0,i=>(Nn(i),cc.CANCELED)),modelPromise:t}}isModelValid(e){return!0}isProviderValid(){return!0}}let cx=class extends kN{constructor(e,t){super(e),this._languageFeaturesService=t}createModelFromProvider(e){return sl.create(this._languageFeaturesService.documentSymbolProvider,this._editor.getModel(),e)}createStickyModel(e,t){var r;const{stickyOutlineElement:i,providerID:n}=this._stickyModelFromOutlineModel(t,(r=this._stickyModel)==null?void 0:r.outlineProviderId),s=this._editor.getModel();return new xN(s.uri,s.getVersionId(),i,n)}isModelValid(e){return e&&e.children.size>0}_stickyModelFromOutlineModel(e,t){let i;if(pl.first(e.children.values())instanceof qR){const a=pl.find(e.children.values(),d=>d.id===t);if(a)i=a.children;else{let d="",u=-1,f;for(const[g,p]of e.children.entries()){const w=this._findSumOfRangesOfGroup(p);w>u&&(f=p,u=w,d=p.id)}t=d,i=f.children}}else i=e.children;const n=[],s=Array.from(i.values()).sort((a,d)=>{const u=new np(a.symbol.range.startLineNumber,a.symbol.range.endLineNumber),f=new np(d.symbol.range.startLineNumber,d.symbol.range.endLineNumber);return this._comparator(u,f)});for(const a of s)n.push(this._stickyModelFromOutlineElement(a,a.symbol.selectionRange.startLineNumber));return{stickyOutlineElement:new db(void 0,n,void 0),providerID:t}}_stickyModelFromOutlineElement(e,t){const i=[];for(const s of e.children.values())if(s.symbol.selectionRange.startLineNumber!==s.symbol.range.endLineNumber)if(s.symbol.selectionRange.startLineNumber!==t)i.push(this._stickyModelFromOutlineElement(s,s.symbol.selectionRange.startLineNumber));else for(const r of s.children.values())i.push(this._stickyModelFromOutlineElement(r,s.symbol.selectionRange.startLineNumber));i.sort((s,r)=>this._comparator(s.range,r.range));const n=new np(e.symbol.selectionRange.startLineNumber,e.symbol.range.endLineNumber);return new db(n,i,void 0)}_comparator(e,t){return e.startLineNumber!==t.startLineNumber?e.startLineNumber-t.startLineNumber:t.endLineNumber-e.endLineNumber}_findSumOfRangesOfGroup(e){let t=0;for(const i of e.children.values())t+=this._findSumOfRangesOfGroup(i);return e instanceof QC?t+e.symbol.range.endLineNumber-e.symbol.selectionRange.startLineNumber:t}};cx=aw([$p(1,pi)],cx);class LN extends kN{constructor(e){super(e),this._foldingLimitReporter=new jR(e)}createStickyModel(e,t){const i=this._fromFoldingRegions(t),n=this._editor.getModel();return new xN(n.uri,n.getVersionId(),i,void 0)}isModelValid(e){return e!==null}_fromFoldingRegions(e){const t=e.length,i=[],n=new db(void 0,[],void 0);for(let s=0;s<t;s++){const r=e.getParentIndex(s);let a;r!==-1?a=i[r]:a=n;const d=new db(new np(e.getStartLineNumber(s),e.getEndLineNumber(s)+1),[],a);a.children.push(d),i.push(d)}return n}}let dx=class extends LN{constructor(e,t){super(e),this._languageConfigurationService=t,this.provider=this._register(new dk(e.getModel(),this._languageConfigurationService,this._foldingLimitReporter))}async createModelFromProvider(e){return this.provider.compute(e)}};dx=aw([$p(1,Ds)],dx);let ux=class extends LN{constructor(e,t,i){super(e),this._languageFeaturesService=i;const n=Fc.getFoldingRangeProviders(this._languageFeaturesService,e.getModel());n.length>0&&(this.provider=this._register(new uk(e.getModel(),n,t,this._foldingLimitReporter,void 0)))}isProviderValid(){return this.provider!==void 0}async createModelFromProvider(e){var t;return((t=this.provider)==null?void 0:t.compute(e))??null}};ux=aw([$p(2,pi)],ux);var Z8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},IE=function(o,e){return function(t,i){e(t,i,o)}};class Y8{constructor(e,t,i){this.startLineNumber=e,this.endLineNumber=t,this.nestingDepth=i}}let hx=class extends Dt{constructor(e,t,i){super(),this._languageFeaturesService=t,this._languageConfigurationService=i,this._onDidChangeStickyScroll=this._register(new Xi),this.onDidChangeStickyScroll=this._onDidChangeStickyScroll.event,this._model=null,this._cts=null,this._stickyModelProvider=null,this._editor=e,this._sessionStore=this._register(new Lt),this._updateSoon=this._register(new Ss(()=>this.update(),50)),this._register(this._editor.onDidChangeConfiguration(n=>{n.hasChanged(116)&&this.readConfiguration()})),this.readConfiguration()}readConfiguration(){this._sessionStore.clear(),this._editor.getOption(116).enabled&&(this._sessionStore.add(this._editor.onDidChangeModel(()=>{this._model=null,this.updateStickyModelProvider(),this._onDidChangeStickyScroll.fire(),this.update()})),this._sessionStore.add(this._editor.onDidChangeHiddenAreas(()=>this.update())),this._sessionStore.add(this._editor.onDidChangeModelContent(()=>this._updateSoon.schedule())),this._sessionStore.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(()=>this.update())),this._sessionStore.add(jn(()=>{var t;(t=this._stickyModelProvider)==null||t.dispose(),this._stickyModelProvider=null})),this.updateStickyModelProvider(),this.update())}getVersionId(){var e;return(e=this._model)==null?void 0:e.version}updateStickyModelProvider(){var t;(t=this._stickyModelProvider)==null||t.dispose(),this._stickyModelProvider=null;const e=this._editor;e.hasModel()&&(this._stickyModelProvider=new lx(e,()=>this._updateSoon.schedule(),this._languageConfigurationService,this._languageFeaturesService))}async update(){var e;(e=this._cts)==null||e.dispose(!0),this._cts=new Fs,await this.updateStickyModel(this._cts.token),this._onDidChangeStickyScroll.fire()}async updateStickyModel(e){if(!this._editor.hasModel()||!this._stickyModelProvider||this._editor.getModel().isTooLargeForTokenization()){this._model=null;return}const t=await this._stickyModelProvider.update(e);e.isCancellationRequested||(this._model=t)}updateIndex(e){return e===-1?e=0:e<0&&(e=-e-2),e}getCandidateStickyLinesIntersectingFromStickyModel(e,t,i,n,s){if(t.children.length===0)return;let r=s;const a=[];for(let f=0;f<t.children.length;f++){const g=t.children[f];g.range&&a.push(g.range.startLineNumber)}const d=this.updateIndex(lv(a,e.startLineNumber,(f,g)=>f-g)),u=this.updateIndex(lv(a,e.startLineNumber+n,(f,g)=>f-g));for(let f=d;f<=u;f++){const g=t.children[f];if(!g)return;if(g.range){const p=g.range.startLineNumber,w=g.range.endLineNumber;e.startLineNumber<=w+1&&p-1<=e.endLineNumber&&p!==r&&(r=p,i.push(new Y8(p,w-1,n+1)),this.getCandidateStickyLinesIntersectingFromStickyModel(e,g,i,n+1,p))}else this.getCandidateStickyLinesIntersectingFromStickyModel(e,g,i,n,s)}}getCandidateStickyLinesIntersecting(e){var n,s;if(!((n=this._model)!=null&&n.element))return[];let t=[];this.getCandidateStickyLinesIntersectingFromStickyModel(e,this._model.element,t,0,-1);const i=(s=this._editor._getViewModel())==null?void 0:s.getHiddenAreas();if(i)for(const r of i)t=t.filter(a=>!(a.startLineNumber>=r.startLineNumber&&a.endLineNumber<=r.endLineNumber+1));return t}};hx=Z8([IE(1,pi),IE(2,Ds)],hx);var X8=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},uh=function(o,e){return function(t,i){e(t,i,o)}},fx,hu;let Tl=(hu=class extends Dt{constructor(e,t,i,n,s,r,a){super(),this._editor=e,this._contextMenuService=t,this._languageFeaturesService=i,this._instaService=n,this._contextKeyService=a,this._sessionStore=new Lt,this._maxStickyLines=Number.MAX_SAFE_INTEGER,this._candidateDefinitionsLength=-1,this._focusedStickyElementIndex=-1,this._enabled=!1,this._focused=!1,this._positionRevealed=!1,this._onMouseDown=!1,this._endLineNumbers=[],this._stickyScrollWidget=new q8(this._editor),this._stickyLineCandidateProvider=new hx(this._editor,i,s),this._register(this._stickyScrollWidget),this._register(this._stickyLineCandidateProvider),this._widgetState=ip.Empty,this._onDidResize(),this._readConfiguration();const d=this._stickyScrollWidget.getDomNode();this._register(this._editor.onDidChangeConfiguration(f=>{this._readConfigurationChange(f)})),this._register(wn(d,Zn.CONTEXT_MENU,async f=>{this._onContextMenu(yd(d),f)})),this._stickyScrollFocusedContextKey=B.stickyScrollFocused.bindTo(this._contextKeyService),this._stickyScrollVisibleContextKey=B.stickyScrollVisible.bindTo(this._contextKeyService);const u=this._register(ff(d));this._register(u.onDidBlur(f=>{this._positionRevealed===!1&&d.clientHeight===0?(this._focusedStickyElementIndex=-1,this.focus()):this._disposeFocusStickyScrollStore()})),this._register(u.onDidFocus(f=>{this.focus()})),this._registerMouseListeners(),this._register(wn(d,Zn.MOUSE_DOWN,f=>{this._onMouseDown=!0}))}static get(e){return e.getContribution(fx.ID)}_disposeFocusStickyScrollStore(){var e;this._stickyScrollFocusedContextKey.set(!1),(e=this._focusDisposableStore)==null||e.dispose(),this._focused=!1,this._positionRevealed=!1,this._onMouseDown=!1}focus(){if(this._onMouseDown){this._onMouseDown=!1,this._editor.focus();return}this._stickyScrollFocusedContextKey.get()!==!0&&(this._focused=!0,this._focusDisposableStore=new Lt,this._stickyScrollFocusedContextKey.set(!0),this._focusedStickyElementIndex=this._stickyScrollWidget.lineNumbers.length-1,this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex))}focusNext(){this._focusedStickyElementIndex<this._stickyScrollWidget.lineNumberCount-1&&this._focusNav(!0)}focusPrevious(){this._focusedStickyElementIndex>0&&this._focusNav(!1)}selectEditor(){this._editor.focus()}_focusNav(e){this._focusedStickyElementIndex=e?this._focusedStickyElementIndex+1:this._focusedStickyElementIndex-1,this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex)}goToFocused(){const e=this._stickyScrollWidget.lineNumbers;this._disposeFocusStickyScrollStore(),this._revealPosition({lineNumber:e[this._focusedStickyElementIndex],column:1})}_revealPosition(e){this._reveaInEditor(e,()=>this._editor.revealPosition(e))}_revealLineInCenterIfOutsideViewport(e){this._reveaInEditor(e,()=>this._editor.revealLineInCenterIfOutsideViewport(e.lineNumber,0))}_reveaInEditor(e,t){this._focused&&this._disposeFocusStickyScrollStore(),this._positionRevealed=!0,t(),this._editor.setSelection(Z.fromPositions(e)),this._editor.focus()}_registerMouseListeners(){const e=this._register(new Lt),t=this._register(new Yy(this._editor,{extractLineNumberFromMouseEvent:s=>{const r=this._stickyScrollWidget.getEditorPositionFromNode(s.target.element);return r?r.lineNumber:0}})),i=s=>{if(!this._editor.hasModel()||s.target.type!==12||s.target.detail!==this._stickyScrollWidget.getId())return null;const r=s.target.element;if(!r||r.innerText!==r.innerHTML)return null;const a=this._stickyScrollWidget.getEditorPositionFromNode(r);return a?{range:new Z(a.lineNumber,a.column,a.lineNumber,a.column+r.innerText.length),textElement:r}:null},n=this._stickyScrollWidget.getDomNode();this._register(Cl(n,Zn.CLICK,s=>{if(s.ctrlKey||s.altKey||s.metaKey||!s.leftButton)return;if(s.shiftKey){const u=this._stickyScrollWidget.getLineIndexFromChildDomNode(s.target);if(u===null)return;const f=new gi(this._endLineNumbers[u],1);this._revealLineInCenterIfOutsideViewport(f);return}if(this._stickyScrollWidget.isInFoldingIconDomNode(s.target)){const u=this._stickyScrollWidget.getLineNumberFromChildDomNode(s.target);this._toggleFoldingRegionForLine(u);return}if(!this._stickyScrollWidget.isInStickyLine(s.target))return;let d=this._stickyScrollWidget.getEditorPositionFromNode(s.target);if(!d){const u=this._stickyScrollWidget.getLineNumberFromChildDomNode(s.target);if(u===null)return;d=new gi(u,1)}this._revealPosition(d)})),this._register(Cl(n,Zn.MOUSE_MOVE,s=>{if(s.shiftKey){const r=this._stickyScrollWidget.getLineIndexFromChildDomNode(s.target);if(r===null||this._showEndForLine!==null&&this._showEndForLine===r)return;this._showEndForLine=r,this._renderStickyScroll();return}this._showEndForLine!==void 0&&(this._showEndForLine=void 0,this._renderStickyScroll())})),this._register(wn(n,Zn.MOUSE_LEAVE,s=>{this._showEndForLine!==void 0&&(this._showEndForLine=void 0,this._renderStickyScroll())})),this._register(t.onMouseMoveOrRelevantKeyDown(([s,r])=>{const a=i(s);if(!a||!s.hasTriggerModifier||!this._editor.hasModel()){e.clear();return}const{range:d,textElement:u}=a;if(!d.equalsRange(this._stickyRangeProjectedOnEditor))this._stickyRangeProjectedOnEditor=d,e.clear();else if(u.style.textDecoration==="underline")return;const f=new Fs;e.add(jn(()=>f.dispose(!0)));let g;P_(this._languageFeaturesService.definitionProvider,this._editor.getModel(),new gi(d.startLineNumber,d.startColumn+1),!1,f.token).then((p=>{if(!f.token.isCancellationRequested)if(p.length!==0){this._candidateDefinitionsLength=p.length;const w=u;g!==w?(e.clear(),g=w,g.style.textDecoration="underline",e.add(jn(()=>{g.style.textDecoration="none"}))):g||(g=w,g.style.textDecoration="underline",e.add(jn(()=>{g.style.textDecoration="none"})))}else e.clear()}))})),this._register(t.onCancel(()=>{e.clear()})),this._register(t.onExecute(async s=>{if(s.target.type!==12||s.target.detail!==this._stickyScrollWidget.getId())return;const r=this._stickyScrollWidget.getEditorPositionFromNode(s.target.element);r&&(!this._editor.hasModel()||!this._stickyRangeProjectedOnEditor||(this._candidateDefinitionsLength>1&&(this._focused&&this._disposeFocusStickyScrollStore(),this._revealPosition({lineNumber:r.lineNumber,column:1})),this._instaService.invokeFunction(LR,s,this._editor,{uri:this._editor.getModel().uri,range:this._stickyRangeProjectedOnEditor})))}))}_onContextMenu(e,t){const i=new WF(e,t);this._contextMenuService.showContextMenu({menuId:Gt.StickyScrollContext,getAnchor:()=>i})}_toggleFoldingRegionForLine(e){if(!this._foldingModel||e===null)return;const t=this._stickyScrollWidget.getRenderedStickyLine(e),i=t==null?void 0:t.foldingIcon;if(!i)return;ak(this._foldingModel,Number.MAX_VALUE,[e]),i.isCollapsed=!i.isCollapsed;const n=(i.isCollapsed?this._editor.getTopForLineNumber(i.foldingEndLine):this._editor.getTopForLineNumber(i.foldingStartLine))-this._editor.getOption(67)*t.index+1;this._editor.setScrollTop(n),this._renderStickyScroll(e)}_readConfiguration(){const e=this._editor.getOption(116);if(e.enabled===!1){this._editor.removeOverlayWidget(this._stickyScrollWidget),this._sessionStore.clear(),this._enabled=!1;return}else e.enabled&&!this._enabled&&(this._editor.addOverlayWidget(this._stickyScrollWidget),this._sessionStore.add(this._editor.onDidScrollChange(i=>{i.scrollTopChanged&&(this._showEndForLine=void 0,this._renderStickyScroll())})),this._sessionStore.add(this._editor.onDidLayoutChange(()=>this._onDidResize())),this._sessionStore.add(this._editor.onDidChangeModelTokens(i=>this._onTokensChange(i))),this._sessionStore.add(this._stickyLineCandidateProvider.onDidChangeStickyScroll(()=>{this._showEndForLine=void 0,this._renderStickyScroll()})),this._enabled=!0);this._editor.getOption(68).renderType===2&&this._sessionStore.add(this._editor.onDidChangeCursorPosition(()=>{this._showEndForLine=void 0,this._renderStickyScroll(0)}))}_readConfigurationChange(e){(e.hasChanged(116)||e.hasChanged(73)||e.hasChanged(67)||e.hasChanged(111)||e.hasChanged(68))&&this._readConfiguration(),e.hasChanged(68)&&this._renderStickyScroll(0)}_needsUpdate(e){const t=this._stickyScrollWidget.getCurrentLines();for(const i of t)for(const n of e.ranges)if(i>=n.fromLineNumber&&i<=n.toLineNumber)return!0;return!1}_onTokensChange(e){this._needsUpdate(e)&&this._renderStickyScroll(0)}_onDidResize(){const t=this._editor.getLayoutInfo().height/this._editor.getOption(67);this._maxStickyLines=Math.round(t*.25)}async _renderStickyScroll(e){const t=this._editor.getModel();if(!t||t.isTooLargeForTokenization()){this._resetState();return}const i=this._updateAndGetMinRebuildFromLine(e),n=this._stickyLineCandidateProvider.getVersionId();if(n===void 0||n===t.getVersionId())if(!this._focused)await this._updateState(i);else if(this._focusedStickyElementIndex===-1)await this._updateState(i),this._focusedStickyElementIndex=this._stickyScrollWidget.lineNumberCount-1,this._focusedStickyElementIndex!==-1&&this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex);else{const r=this._stickyScrollWidget.lineNumbers[this._focusedStickyElementIndex];await this._updateState(i),this._stickyScrollWidget.lineNumberCount===0?this._focusedStickyElementIndex=-1:(this._stickyScrollWidget.lineNumbers.includes(r)||(this._focusedStickyElementIndex=this._stickyScrollWidget.lineNumberCount-1),this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex))}}_updateAndGetMinRebuildFromLine(e){if(e!==void 0){const t=this._minRebuildFromLine!==void 0?this._minRebuildFromLine:1/0;this._minRebuildFromLine=Math.min(e,t)}return this._minRebuildFromLine}async _updateState(e){var i;this._minRebuildFromLine=void 0,this._foldingModel=await((i=Fc.get(this._editor))==null?void 0:i.getFoldingModel())??void 0,this._widgetState=this.findScrollWidgetState();const t=this._widgetState.startLineNumbers.length>0;this._stickyScrollVisibleContextKey.set(t),this._stickyScrollWidget.setState(this._widgetState,this._foldingModel,e)}async _resetState(){this._minRebuildFromLine=void 0,this._foldingModel=void 0,this._widgetState=ip.Empty,this._stickyScrollVisibleContextKey.set(!1),this._stickyScrollWidget.setState(void 0,void 0)}findScrollWidgetState(){const e=this._editor.getOption(67),t=Math.min(this._maxStickyLines,this._editor.getOption(116).maxLineCount),i=this._editor.getScrollTop();let n=0;const s=[],r=[],a=this._editor.getVisibleRanges();if(a.length!==0){const d=new np(a[0].startLineNumber,a[a.length-1].endLineNumber),u=this._stickyLineCandidateProvider.getCandidateStickyLinesIntersecting(d);for(const f of u){const g=f.startLineNumber,p=f.endLineNumber,w=f.nestingDepth;if(p-g>0){const y=(w-1)*e,x=w*e,k=this._editor.getBottomForLineNumber(g)-i,D=this._editor.getTopForLineNumber(p)-i,M=this._editor.getBottomForLineNumber(p)-i;if(y>D&&y<=M){s.push(g),r.push(p+1),n=M-x;break}else x>k&&x<=M&&(s.push(g),r.push(p+1));if(s.length===t)break}}}return this._endLineNumbers=r,new ip(s,r,n,this._showEndForLine)}dispose(){super.dispose(),this._sessionStore.dispose()}},fx=hu,hu.ID="store.contrib.stickyScrollController",hu);Tl=fx=X8([uh(1,zf),uh(2,pi),uh(3,Zi),uh(4,Ds),uh(5,ur),uh(6,Sn)],Tl);class Q8 extends yo{constructor(){super({id:"editor.action.toggleStickyScroll",title:{...ui("toggleEditorStickyScroll","Toggle Editor Sticky Scroll"),mnemonicTitle:C({key:"mitoggleStickyScroll",comment:["&& denotes a mnemonic"]},"&&Toggle Editor Sticky Scroll")},metadata:{description:ui("toggleEditorStickyScroll.description","Toggle/enable the editor sticky scroll which shows the nested scopes at the top of the viewport")},category:$8.View,toggled:{condition:Ae.equals("config.editor.stickyScroll.enabled",!0),title:C("stickyScroll","Sticky Scroll"),mnemonicTitle:C({key:"miStickyScroll",comment:["&& denotes a mnemonic"]},"&&Sticky Scroll")},menu:[{id:Gt.CommandPalette},{id:Gt.MenubarAppearanceMenu,group:"4_editor",order:3},{id:Gt.StickyScrollContext}]})}async run(e){const t=e.get(Un),i=!t.getValue("editor.stickyScroll.enabled");return t.updateValue("editor.stickyScroll.enabled",i)}}const lw=100;class J8 extends ca{constructor(){super({id:"editor.action.focusStickyScroll",title:{...ui("focusStickyScroll","Focus on the editor sticky scroll"),mnemonicTitle:C({key:"mifocusStickyScroll",comment:["&& denotes a mnemonic"]},"&&Focus Sticky Scroll")},precondition:Ae.and(Ae.has("config.editor.stickyScroll.enabled"),B.stickyScrollVisible),menu:[{id:Gt.CommandPalette}]})}runEditorCommand(e,t){var i;(i=Tl.get(t))==null||i.focus()}}class e7 extends ca{constructor(){super({id:"editor.action.selectNextStickyScrollLine",title:ui("selectNextStickyScrollLine.title","Select the next editor sticky scroll line"),precondition:B.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:lw,primary:18}})}runEditorCommand(e,t){var i;(i=Tl.get(t))==null||i.focusNext()}}class t7 extends ca{constructor(){super({id:"editor.action.selectPreviousStickyScrollLine",title:ui("selectPreviousStickyScrollLine.title","Select the previous sticky scroll line"),precondition:B.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:lw,primary:16}})}runEditorCommand(e,t){var i;(i=Tl.get(t))==null||i.focusPrevious()}}class i7 extends ca{constructor(){super({id:"editor.action.goToFocusedStickyScrollLine",title:ui("goToFocusedStickyScrollLine.title","Go to the focused sticky scroll line"),precondition:B.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:lw,primary:3}})}runEditorCommand(e,t){var i;(i=Tl.get(t))==null||i.goToFocused()}}class n7 extends ca{constructor(){super({id:"editor.action.selectEditor",title:ui("selectEditor.title","Select Editor"),precondition:B.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:lw,primary:9}})}runEditorCommand(e,t){var i;(i=Tl.get(t))==null||i.selectEditor()}}nn(Tl.ID,Tl,1);Tn(Q8);Tn(J8);Tn(t7);Tn(e7);Tn(i7);Tn(n7);var IN=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Fg=function(o,e){return function(t,i){e(t,i,o)}};class s7{constructor(e,t,i,n,s,r){this.range=e,this.insertText=t,this.filterText=i,this.additionalTextEdits=n,this.command=s,this.completion=r}}let gx=class extends BF{constructor(e,t,i,n,s,r){super(s.disposable),this.model=e,this.line=t,this.word=i,this.completionModel=n,this._suggestMemoryService=r}canBeReused(e,t,i){return this.model===e&&this.line===t&&this.word.word.length>0&&this.word.startColumn===i.startColumn&&this.word.endColumn<i.endColumn&&this.completionModel.getIncompleteProvider().size===0}get items(){const e=[],{items:t}=this.completionModel,i=this._suggestMemoryService.select(this.model,{lineNumber:this.line,column:this.word.endColumn+this.completionModel.lineContext.characterCountDelta},t),n=pl.slice(t,i),s=pl.slice(t,0,i);let r=5;for(const a of pl.concat(n,s)){if(a.score===mp.Default)continue;const d=new Z(a.editStart.lineNumber,a.editStart.column,a.editInsertEnd.lineNumber,a.editInsertEnd.column+this.completionModel.lineContext.characterCountDelta),u=a.completion.insertTextRules&&a.completion.insertTextRules&4?{snippet:a.completion.insertText}:a.completion.insertText;e.push(new s7(d,u,a.filterTextLow??a.labelLow,a.completion.additionalTextEdits,a.completion.command,a)),r-->=0&&a.resolve(Qi.None)}return e}};gx=IN([Fg(5,nw)],gx);let px=class extends Dt{constructor(e,t,i,n){super(),this._languageFeatureService=e,this._clipboardService=t,this._suggestMemoryService=i,this._editorService=n,this._store.add(e.inlineCompletionsProvider.register("*",this))}async provideInlineCompletions(e,t,i,n){var w;if(i.selectedSuggestionInfo)return;let s;for(const y of this._editorService.listCodeEditors())if(y.getModel()===e){s=y;break}if(!s)return;const r=s.getOption(90);if(Mh.isAllOff(r))return;e.tokenization.tokenizeIfCheap(t.lineNumber);const a=e.tokenization.getLineTokens(t.lineNumber),d=a.getStandardTokenType(a.findTokenIndexAtOffset(Math.max(t.column-1-1,0)));if(Mh.valueFor(r,d)!=="inline")return;let u=e.getWordAtPosition(t),f;if(u!=null&&u.word||(f=this._getTriggerCharacterInfo(e,t)),!(u!=null&&u.word)&&!f||(u||(u=e.getWordUntilPosition(t)),u.endColumn!==t.column))return;let g;const p=e.getValueInRange(new Z(t.lineNumber,1,t.lineNumber,t.column));if(!f&&((w=this._lastResult)!=null&&w.canBeReused(e,t.lineNumber,u))){const y=new hE(p,t.column-this._lastResult.word.endColumn);this._lastResult.completionModel.lineContext=y,this._lastResult.acquire(),g=this._lastResult}else{const y=await hk(this._languageFeatureService.completionProvider,e,t,new Ap(void 0,Zv.createSuggestFilter(s).itemKind,f==null?void 0:f.providers),f&&{triggerKind:1,triggerCharacter:f.ch},n);let x;y.needsClipboard&&(x=await this._clipboardService.readText());const k=new Jl(y.items,t.column,new hE(p,0),Kv.None,s.getOption(119),s.getOption(113),{boostFullMatch:!1,firstMatchCanBeWeak:!1},x);g=new gx(e,t.lineNumber,u,k,y,this._suggestMemoryService)}return this._lastResult=g,g}handleItemDidShow(e,t){t.completion.resolve(Qi.None)}freeInlineCompletions(e){e.release()}_getTriggerCharacterInfo(e,t){var s;const i=e.getValueInRange(Z.fromPositions({lineNumber:t.lineNumber,column:t.column-1},t)),n=new Set;for(const r of this._languageFeatureService.completionProvider.all(e))(s=r.triggerCharacters)!=null&&s.includes(i)&&n.add(r);if(n.size!==0)return{providers:n,ch:i}}};px=IN([Fg(0,pi),Fg(1,Vf),Fg(2,nw),Fg(3,as)],px);$f(px);class o7 extends lt{constructor(){super({id:"editor.action.forceRetokenize",label:C("forceRetokenize","Developer: Force Retokenize"),alias:"Developer: Force Retokenize",precondition:void 0})}run(e,t){if(!t.hasModel())return;const i=t.getModel();i.tokenization.resetTokenization();const n=new Mo;i.tokenization.forceTokenization(i.getLineCount()),n.stop(),console.log(`tokenization took ${n.elapsed()}`)}}xe(o7);const ry=class ry extends yo{constructor(){super({id:ry.ID,title:ui({key:"toggle.tabMovesFocus",comment:["Turn on/off use of tab key for moving focus around VS Code"]},"Toggle Tab Key Moves Focus"),precondition:void 0,keybinding:{primary:2091,mac:{primary:1323},weight:100},metadata:{description:ui("tabMovesFocusDescriptions","Determines whether the tab key moves focus around the workbench or inserts the tab character in the current editor. This is also called tab trapping, tab navigation, or tab focus mode.")},f1:!0})}run(){const t=!FL.getTabFocusMode();FL.setTabFocusMode(t),t?Ar(C("toggle.tabMovesFocus.on","Pressing Tab will now move focus to the next focusable element")):Ar(C("toggle.tabMovesFocus.off","Pressing Tab will now insert the tab character"))}};ry.ID="editor.action.toggleTabFocusMode";let _x=ry;Tn(_x);var r7=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},EE=function(o,e){return function(t,i){e(t,i,o)}};let mx=class extends Dt{get enabled(){return this._enabled}set enabled(e){e?(this.el.setAttribute("aria-disabled","false"),this.el.tabIndex=0,this.el.style.pointerEvents="auto",this.el.style.opacity="1",this.el.style.cursor="pointer",this._enabled=!1):(this.el.setAttribute("aria-disabled","true"),this.el.tabIndex=-1,this.el.style.pointerEvents="none",this.el.style.opacity="0.4",this.el.style.cursor="default",this._enabled=!0),this._enabled=e}constructor(e,t,i={},n,s){super(),this._link=t,this._hoverService=n,this._enabled=!0,this.el=ei(e,si("a.monaco-link",{tabIndex:t.tabIndex??0,href:t.href},t.label)),this.hoverDelegate=i.hoverDelegate??Dy("mouse"),this.setTooltip(t.title),this.el.setAttribute("role","button");const r=this._register(new Lw(this.el,"click")),a=this._register(new Lw(this.el,"keypress")),d=ws.chain(a.event,g=>g.map(p=>new w0(p)).filter(p=>p.keyCode===3)),u=this._register(new Lw(this.el,zF.Tap)).event;this._register(zD.addTarget(this.el));const f=ws.any(r.event,d,u);this._register(f(g=>{this.enabled&&(sv.stop(g,!0),i!=null&&i.opener?i.opener(this._link.href):s.open(this._link.href,{allowCommands:!0}))})),this.enabled=!0}setTooltip(e){this.hoverDelegate.showNativeHover?this.el.title=e??"":!this.hover&&e?this.hover=this._register(this._hoverService.setupManagedHover(this.hoverDelegate,this.el,e)):this.hover&&this.hover.update(e)}};mx=r7([EE(3,p_),EE(4,ua)],mx);var EN=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},DN=function(o,e){return function(t,i){e(t,i,o)}};const a7=26;let vx=class extends Dt{constructor(e,t){super(),this._editor=e,this.instantiationService=t,this.banner=this._register(this.instantiationService.createInstance(bx))}hide(){this._editor.setBanner(null,0),this.banner.clear()}show(e){this.banner.show({...e,onClose:()=>{var t;this.hide(),(t=e.onClose)==null||t.call(e)}}),this._editor.setBanner(this.banner.element,a7)}};vx=EN([DN(1,Zi)],vx);let bx=class extends Dt{constructor(e){super(),this.instantiationService=e,this.markdownRenderer=this.instantiationService.createInstance(Uf,{}),this.element=si("div.editor-banner"),this.element.tabIndex=0}getAriaLabel(e){if(e.ariaLabel)return e.ariaLabel;if(typeof e.message=="string")return e.message}getBannerMessage(e){if(typeof e=="string"){const t=si("span");return t.innerText=e,t}return this.markdownRenderer.render(e).element}clear(){Wa(this.element)}show(e){Wa(this.element);const t=this.getAriaLabel(e);t&&this.element.setAttribute("aria-label",t);const i=ei(this.element,si("div.icon-container"));i.setAttribute("aria-hidden","true"),e.icon&&i.appendChild(si(`div${xn.asCSSSelector(e.icon)}`));const n=ei(this.element,si("div.message-container"));if(n.setAttribute("aria-hidden","true"),n.appendChild(this.getBannerMessage(e.message)),this.messageActionsContainer=ei(this.element,si("div.message-actions-container")),e.actions)for(const r of e.actions)this._register(this.instantiationService.createInstance(mx,this.messageActionsContainer,{...r,tabIndex:-1},{}));const s=ei(this.element,si("div.action-container"));this.actionBar=this._register(new up(s)),this.actionBar.push(this._register(new mf("banner.close","Close Banner",xn.asClassName(cT),!0,()=>{typeof e.onClose=="function"&&e.onClose()})),{icon:!0,label:!1}),this.actionBar.setFocusable(!1)}};bx=EN([DN(0,Zi)],bx);var Lk=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Uh=function(o,e){return function(t,i){e(t,i,o)}};const l7=is("extensions-warning-message",ji.warning,C("warningIcon","Icon shown with a warning message in the extensions editor."));var cf;let Up=(cf=class extends Dt{constructor(e,t,i,n){super(),this._editor=e,this._editorWorkerService=t,this._workspaceTrustService=i,this._highlighter=null,this._bannerClosed=!1,this._updateState=s=>{if(s&&s.hasMore){if(this._bannerClosed)return;const r=Math.max(s.ambiguousCharacterCount,s.nonBasicAsciiCharacterCount,s.invisibleCharacterCount);let a;if(s.nonBasicAsciiCharacterCount>=r)a={message:C("unicodeHighlighting.thisDocumentHasManyNonBasicAsciiUnicodeCharacters","This document contains many non-basic ASCII unicode characters"),command:new Gp};else if(s.ambiguousCharacterCount>=r)a={message:C("unicodeHighlighting.thisDocumentHasManyAmbiguousUnicodeCharacters","This document contains many ambiguous unicode characters"),command:new Nu};else if(s.invisibleCharacterCount>=r)a={message:C("unicodeHighlighting.thisDocumentHasManyInvisibleUnicodeCharacters","This document contains many invisible unicode characters"),command:new qp};else throw new Error("Unreachable");this._bannerController.show({id:"unicodeHighlightBanner",message:a.message,icon:l7,actions:[{label:a.command.shortLabel,href:`command:${a.command.id}`}],onClose:()=>{this._bannerClosed=!0}})}else this._bannerController.hide()},this._bannerController=this._register(n.createInstance(vx,e)),this._register(this._editor.onDidChangeModel(()=>{this._bannerClosed=!1,this._updateHighlighter()})),this._options=e.getOption(126),this._register(i.onDidChangeTrust(s=>{this._updateHighlighter()})),this._register(e.onDidChangeConfiguration(s=>{s.hasChanged(126)&&(this._options=e.getOption(126),this._updateHighlighter())})),this._updateHighlighter()}dispose(){this._highlighter&&(this._highlighter.dispose(),this._highlighter=null),super.dispose()}_updateHighlighter(){if(this._updateState(null),this._highlighter&&(this._highlighter.dispose(),this._highlighter=null),!this._editor.hasModel())return;const e=c7(this._workspaceTrustService.isWorkspaceTrusted(),this._options);if([e.nonBasicASCII,e.ambiguousCharacters,e.invisibleCharacters].every(i=>i===!1))return;const t={nonBasicASCII:e.nonBasicASCII,ambiguousCharacters:e.ambiguousCharacters,invisibleCharacters:e.invisibleCharacters,includeComments:e.includeComments,includeStrings:e.includeStrings,allowedCodePoints:Object.keys(e.allowedCharacters).map(i=>i.codePointAt(0)),allowedLocales:Object.keys(e.allowedLocales).map(i=>i==="_os"?new Intl.NumberFormat().resolvedOptions().locale:i==="_vscode"?VF:i)};this._editorWorkerService.canComputeUnicodeHighlights(this._editor.getModel().uri)?this._highlighter=new yx(this._editor,t,this._updateState,this._editorWorkerService):this._highlighter=new d7(this._editor,t,this._updateState)}getDecorationInfo(e){return this._highlighter?this._highlighter.getDecorationInfo(e):null}},cf.ID="editor.contrib.unicodeHighlighter",cf);Up=Lk([Uh(1,Al),Uh(2,jF),Uh(3,Zi)],Up);function c7(o,e){return{nonBasicASCII:e.nonBasicASCII===Iw?!o:e.nonBasicASCII,ambiguousCharacters:e.ambiguousCharacters,invisibleCharacters:e.invisibleCharacters,includeComments:e.includeComments===Iw?!o:e.includeComments,includeStrings:e.includeStrings===Iw?!o:e.includeStrings,allowedCharacters:e.allowedCharacters,allowedLocales:e.allowedLocales}}let yx=class extends Dt{constructor(e,t,i,n){super(),this._editor=e,this._options=t,this._updateState=i,this._editorWorkerService=n,this._model=this._editor.getModel(),this._decorations=this._editor.createDecorationsCollection(),this._updateSoon=this._register(new Ss(()=>this._update(),250)),this._register(this._editor.onDidChangeModelContent(()=>{this._updateSoon.schedule()})),this._updateSoon.schedule()}dispose(){this._decorations.clear(),super.dispose()}_update(){if(this._model.isDisposed())return;if(!this._model.mightContainNonBasicASCII()){this._decorations.clear();return}const e=this._model.getVersionId();this._editorWorkerService.computedUnicodeHighlights(this._model.uri,this._options).then(t=>{if(this._model.isDisposed()||this._model.getVersionId()!==e)return;this._updateState(t);const i=[];if(!t.hasMore)for(const n of t.ranges)i.push({range:n,options:ub.instance.getDecorationFromOptions(this._options)});this._decorations.set(i)})}getDecorationInfo(e){if(!this._decorations.has(e))return null;const t=this._editor.getModel();if(!JT(t,e))return null;const i=t.getValueInRange(e.range);return{reason:PN(i,this._options),inComment:tP(t,e),inString:eP(t,e)}}};yx=Lk([Uh(3,Al)],yx);class d7 extends Dt{constructor(e,t,i){super(),this._editor=e,this._options=t,this._updateState=i,this._model=this._editor.getModel(),this._decorations=this._editor.createDecorationsCollection(),this._updateSoon=this._register(new Ss(()=>this._update(),250)),this._register(this._editor.onDidLayoutChange(()=>{this._updateSoon.schedule()})),this._register(this._editor.onDidScrollChange(()=>{this._updateSoon.schedule()})),this._register(this._editor.onDidChangeHiddenAreas(()=>{this._updateSoon.schedule()})),this._register(this._editor.onDidChangeModelContent(()=>{this._updateSoon.schedule()})),this._updateSoon.schedule()}dispose(){this._decorations.clear(),super.dispose()}_update(){if(this._model.isDisposed())return;if(!this._model.mightContainNonBasicASCII()){this._decorations.clear();return}const e=this._editor.getVisibleRanges(),t=[],i={ranges:[],ambiguousCharacterCount:0,invisibleCharacterCount:0,nonBasicAsciiCharacterCount:0,hasMore:!1};for(const n of e){const s=iP.computeUnicodeHighlights(this._model,this._options,n);for(const r of s.ranges)i.ranges.push(r);i.ambiguousCharacterCount+=i.ambiguousCharacterCount,i.invisibleCharacterCount+=i.invisibleCharacterCount,i.nonBasicAsciiCharacterCount+=i.nonBasicAsciiCharacterCount,i.hasMore=i.hasMore||s.hasMore}if(!i.hasMore)for(const n of i.ranges)t.push({range:n,options:ub.instance.getDecorationFromOptions(this._options)});this._updateState(i),this._decorations.set(t)}getDecorationInfo(e){if(!this._decorations.has(e))return null;const t=this._editor.getModel(),i=t.getValueInRange(e.range);return JT(t,e)?{reason:PN(i,this._options),inComment:tP(t,e),inString:eP(t,e)}:null}}const TN=C("unicodeHighlight.configureUnicodeHighlightOptions","Configure Unicode Highlight Options");let wx=class{constructor(e,t,i){this._editor=e,this._languageService=t,this._openerService=i,this.hoverOrdinal=5}computeSync(e,t){if(!this._editor.hasModel()||e.type!==1)return[];const i=this._editor.getModel(),n=this._editor.getContribution(Up.ID);if(!n)return[];const s=[],r=new Set;let a=300;for(const d of t){const u=n.getDecorationInfo(d);if(!u)continue;const g=i.getValueInRange(d.range).codePointAt(0),p=lS(g);let w;switch(u.reason.kind){case 0:{kT(u.reason.confusableWith)?w=C("unicodeHighlight.characterIsAmbiguousASCII","The character {0} could be confused with the ASCII character {1}, which is more common in source code.",p,lS(u.reason.confusableWith.codePointAt(0))):w=C("unicodeHighlight.characterIsAmbiguous","The character {0} could be confused with the character {1}, which is more common in source code.",p,lS(u.reason.confusableWith.codePointAt(0)));break}case 1:w=C("unicodeHighlight.characterIsInvisible","The character {0} is invisible.",p);break;case 2:w=C("unicodeHighlight.characterIsNonBasicAscii","The character {0} is not a basic ASCII character.",p);break}if(r.has(w))continue;r.add(w);const y={codePoint:g,reason:u.reason,inComment:u.inComment,inString:u.inString},x=C("unicodeHighlight.adjustSettings","Adjust settings"),k=`command:${hb.ID}?${encodeURIComponent(JSON.stringify(y))}`,D=new to("",!0).appendMarkdown(w).appendText(" ").appendLink(k,x,TN);s.push(new Tr(this,d.range,[D],!1,a++))}return s}renderHoverParts(e,t){return WB(e,t,this._editor,this._languageService,this._openerService)}};wx=Lk([Uh(1,fa),Uh(2,ua)],wx);function Sx(o){return`U+${o.toString(16).padStart(4,"0")}`}function lS(o){let e=`\`${Sx(o)}\``;return nP.isInvisibleCharacter(o)||(e+=` "${`${u7(o)}`}"`),e}function u7(o){return o===96?"`` ` ``":"`"+String.fromCodePoint(o)+"`"}function PN(o,e){return iP.computeUnicodeHighlightReason(o,e)}const ay=class ay{constructor(){this.map=new Map}getDecorationFromOptions(e){return this.getDecoration(!e.includeComments,!e.includeStrings)}getDecoration(e,t){const i=`${e}${t}`;let n=this.map.get(i);return n||(n=dn.createDynamic({description:"unicode-highlight",stickiness:1,className:"unicode-highlight",showIfCollapsed:!0,overviewRuler:null,minimap:null,hideInCommentTokens:e,hideInStringTokens:t}),this.map.set(i,n)),n}};ay.instance=new ay;let ub=ay;class h7 extends lt{constructor(){super({id:Nu.ID,label:C("action.unicodeHighlight.disableHighlightingInComments","Disable highlighting of characters in comments"),alias:"Disable highlighting of characters in comments",precondition:void 0}),this.shortLabel=C("unicodeHighlight.disableHighlightingInComments.shortLabel","Disable Highlight In Comments")}async run(e,t,i){const n=e==null?void 0:e.get(Un);n&&this.runAction(n)}async runAction(e){await e.updateValue(kl.includeComments,!1,2)}}class f7 extends lt{constructor(){super({id:Nu.ID,label:C("action.unicodeHighlight.disableHighlightingInStrings","Disable highlighting of characters in strings"),alias:"Disable highlighting of characters in strings",precondition:void 0}),this.shortLabel=C("unicodeHighlight.disableHighlightingInStrings.shortLabel","Disable Highlight In Strings")}async run(e,t,i){const n=e==null?void 0:e.get(Un);n&&this.runAction(n)}async runAction(e){await e.updateValue(kl.includeStrings,!1,2)}}const ly=class ly extends lt{constructor(){super({id:ly.ID,label:C("action.unicodeHighlight.disableHighlightingOfAmbiguousCharacters","Disable highlighting of ambiguous characters"),alias:"Disable highlighting of ambiguous characters",precondition:void 0}),this.shortLabel=C("unicodeHighlight.disableHighlightingOfAmbiguousCharacters.shortLabel","Disable Ambiguous Highlight")}async run(e,t,i){const n=e==null?void 0:e.get(Un);n&&this.runAction(n)}async runAction(e){await e.updateValue(kl.ambiguousCharacters,!1,2)}};ly.ID="editor.action.unicodeHighlight.disableHighlightingOfAmbiguousCharacters";let Nu=ly;const cy=class cy extends lt{constructor(){super({id:cy.ID,label:C("action.unicodeHighlight.disableHighlightingOfInvisibleCharacters","Disable highlighting of invisible characters"),alias:"Disable highlighting of invisible characters",precondition:void 0}),this.shortLabel=C("unicodeHighlight.disableHighlightingOfInvisibleCharacters.shortLabel","Disable Invisible Highlight")}async run(e,t,i){const n=e==null?void 0:e.get(Un);n&&this.runAction(n)}async runAction(e){await e.updateValue(kl.invisibleCharacters,!1,2)}};cy.ID="editor.action.unicodeHighlight.disableHighlightingOfInvisibleCharacters";let qp=cy;const dy=class dy extends lt{constructor(){super({id:dy.ID,label:C("action.unicodeHighlight.disableHighlightingOfNonBasicAsciiCharacters","Disable highlighting of non basic ASCII characters"),alias:"Disable highlighting of non basic ASCII characters",precondition:void 0}),this.shortLabel=C("unicodeHighlight.disableHighlightingOfNonBasicAsciiCharacters.shortLabel","Disable Non ASCII Highlight")}async run(e,t,i){const n=e==null?void 0:e.get(Un);n&&this.runAction(n)}async runAction(e){await e.updateValue(kl.nonBasicASCII,!1,2)}};dy.ID="editor.action.unicodeHighlight.disableHighlightingOfNonBasicAsciiCharacters";let Gp=dy;const uy=class uy extends lt{constructor(){super({id:uy.ID,label:C("action.unicodeHighlight.showExcludeOptions","Show Exclude Options"),alias:"Show Exclude Options",precondition:void 0})}async run(e,t,i){const{codePoint:n,reason:s,inString:r,inComment:a}=i,d=String.fromCodePoint(n),u=e.get(Ml),f=e.get(Un);function g(y){return nP.isInvisibleCharacter(y)?C("unicodeHighlight.excludeInvisibleCharFromBeingHighlighted","Exclude {0} (invisible character) from being highlighted",Sx(y)):C("unicodeHighlight.excludeCharFromBeingHighlighted","Exclude {0} from being highlighted",`${Sx(y)} "${d}"`)}const p=[];if(s.kind===0)for(const y of s.notAmbiguousInLocales)p.push({label:C("unicodeHighlight.allowCommonCharactersInLanguage",'Allow unicode characters that are more common in the language "{0}".',y),run:async()=>{p7(f,[y])}});if(p.push({label:g(n),run:()=>g7(f,[n])}),a){const y=new h7;p.push({label:y.label,run:async()=>y.runAction(f)})}else if(r){const y=new f7;p.push({label:y.label,run:async()=>y.runAction(f)})}if(s.kind===0){const y=new Nu;p.push({label:y.label,run:async()=>y.runAction(f)})}else if(s.kind===1){const y=new qp;p.push({label:y.label,run:async()=>y.runAction(f)})}else if(s.kind===2){const y=new Gp;p.push({label:y.label,run:async()=>y.runAction(f)})}else _7(s);const w=await u.pick(p,{title:TN});w&&await w.run()}};uy.ID="editor.action.unicodeHighlight.showExcludeOptions";let hb=uy;async function g7(o,e){const t=o.getValue(kl.allowedCharacters);let i;typeof t=="object"&&t?i=t:i={};for(const n of e)i[String.fromCodePoint(n)]=!0;await o.updateValue(kl.allowedCharacters,i,2)}async function p7(o,e){var n;const t=(n=o.inspect(kl.allowedLocales).user)==null?void 0:n.value;let i;typeof t=="object"&&t?i=Object.assign({},t):i={};for(const s of e)i[s]=!0;await o.updateValue(kl.allowedLocales,i,2)}function _7(o){throw new Error(`Unexpected value: ${o}`)}xe(Nu);xe(qp);xe(Gp);xe(hb);nn(Up.ID,Up,1);ju.register(wx);var m7=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},DE=function(o,e){return function(t,i){e(t,i,o)}};const MN="ignoreUnusualLineTerminators";function v7(o,e,t){o.setModelProperty(e.uri,MN,t)}function b7(o,e){return o.getModelProperty(e.uri,MN)}var df;let fb=(df=class extends Dt{constructor(e,t,i){super(),this._editor=e,this._dialogService=t,this._codeEditorService=i,this._isPresentingDialog=!1,this._config=this._editor.getOption(127),this._register(this._editor.onDidChangeConfiguration(n=>{n.hasChanged(127)&&(this._config=this._editor.getOption(127),this._checkForUnusualLineTerminators())})),this._register(this._editor.onDidChangeModel(()=>{this._checkForUnusualLineTerminators()})),this._register(this._editor.onDidChangeModelContent(n=>{n.isUndoing||this._checkForUnusualLineTerminators()})),this._checkForUnusualLineTerminators()}async _checkForUnusualLineTerminators(){if(this._config==="off"||!this._editor.hasModel())return;const e=this._editor.getModel();if(!e.mightContainUnusualLineTerminators()||b7(this._codeEditorService,e)===!0||this._editor.getOption(92))return;if(this._config==="auto"){e.removeUnusualLineTerminators(this._editor.getSelections());return}if(this._isPresentingDialog)return;let i;try{this._isPresentingDialog=!0,i=await this._dialogService.confirm({title:C("unusualLineTerminators.title","Unusual Line Terminators"),message:C("unusualLineTerminators.message","Detected unusual line terminators"),detail:C("unusualLineTerminators.detail","The file '{0}' contains one or more unusual line terminator characters, like Line Separator (LS) or Paragraph Separator (PS).\n\nIt is recommended to remove them from the file. This can be configured via `editor.unusualLineTerminators`.",$a(e.uri)),primaryButton:C({key:"unusualLineTerminators.fix",comment:["&& denotes a mnemonic"]},"&&Remove Unusual Line Terminators"),cancelButton:C("unusualLineTerminators.ignore","Ignore")})}finally{this._isPresentingDialog=!1}if(!i.confirmed){v7(this._codeEditorService,e,!0);return}e.removeUnusualLineTerminators(this._editor.getSelections())}},df.ID="editor.contrib.unusualLineTerminatorsDetector",df);fb=m7([DE(1,C0),DE(2,as)],fb);nn(fb.ID,fb,1);var y7=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},w7=function(o,e){return function(t,i){e(t,i,o)}};class TE{constructor(){this.selector={language:"*"}}provideDocumentHighlights(e,t,i){const n=[],s=e.getWordAtPosition({lineNumber:t.lineNumber,column:t.column});return s?e.isDisposed()?void 0:e.findMatches(s.word,!0,!1,!0,HL,!1).map(a=>({range:a.range,kind:dv.Text})):Promise.resolve(n)}provideMultiDocumentHighlights(e,t,i,n){const s=new Pc,r=e.getWordAtPosition({lineNumber:t.lineNumber,column:t.column});if(!r)return Promise.resolve(s);for(const a of[e,...i]){if(a.isDisposed())continue;const u=a.findMatches(r.word,!0,!1,!0,HL,!1).map(f=>({range:f.range,kind:dv.Text}));u&&s.set(a.uri,u)}return s}}let Cx=class extends Dt{constructor(e){super(),this._register(e.documentHighlightProvider.register("*",new TE)),this._register(e.multiDocumentHighlightProvider.register("*",new TE))}};Cx=y7([w7(0,pi)],Cx);var RN=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Xm=function(o,e){return function(t,i){e(t,i,o)}},ts,xx;const Ik=new _n("hasWordHighlights",!1);function NN(o,e,t,i){const n=o.ordered(e);return m0(n.map(s=>()=>Promise.resolve(s.provideDocumentHighlights(e,t,i)).then(void 0,rs)),s=>s!=null).then(s=>{if(s){const r=new Pc;return r.set(e.uri,s),r}return new Pc})}function S7(o,e,t,i,n,s){const r=o.ordered(e);return m0(r.map(a=>()=>{const d=s.filter(u=>UF(u)).filter(u=>qF(a.selector,u.uri,u.getLanguageId(),!0,void 0,void 0)>0);return Promise.resolve(a.provideMultiDocumentHighlights(e,t,d,n)).then(void 0,rs)}),a=>a!=null)}class AN{constructor(e,t,i){this._model=e,this._selection=t,this._wordSeparators=i,this._wordRange=this._getCurrentWordRange(e,t),this._result=null}get result(){return this._result||(this._result=Os(e=>this._compute(this._model,this._selection,this._wordSeparators,e))),this._result}_getCurrentWordRange(e,t){const i=e.getWordAtPosition(t.getPosition());return i?new Z(t.startLineNumber,i.startColumn,t.startLineNumber,i.endColumn):null}isValid(e,t,i){const n=t.startLineNumber,s=t.startColumn,r=t.endColumn,a=this._getCurrentWordRange(e,t);let d=!!(this._wordRange&&this._wordRange.equalsRange(a));for(let u=0,f=i.length;!d&&u<f;u++){const g=i.getRange(u);g&&g.startLineNumber===n&&g.startColumn<=s&&g.endColumn>=r&&(d=!0)}return d}cancel(){this.result.cancel()}}class C7 extends AN{constructor(e,t,i,n){super(e,t,i),this._providers=n}_compute(e,t,i,n){return NN(this._providers,e,t.getPosition(),n).then(s=>s||new Pc)}}class x7 extends AN{constructor(e,t,i,n,s){super(e,t,i),this._providers=n,this._otherModels=s}_compute(e,t,i,n){return S7(this._providers,e,t.getPosition(),i,n,this._otherModels).then(s=>s||new Pc)}}function k7(o,e,t,i,n){return new C7(e,t,n,o)}function L7(o,e,t,i,n,s){return new x7(e,t,n,o,s)}So("_executeDocumentHighlights",async(o,e,t)=>{const i=o.get(pi),n=await NN(i.documentHighlightProvider,e,t,Qi.None);return n==null?void 0:n.get(e.uri)});var Tc;let kx=(Tc=class{constructor(e,t,i,n,s){this.toUnhook=new Lt,this.workerRequestTokenId=0,this.workerRequestCompleted=!1,this.workerRequestValue=new Pc,this.lastCursorPositionChangeTime=0,this.renderDecorationsTimer=-1,this.runDelayer=this.toUnhook.add(new Mc(50)),this.editor=e,this.providers=t,this.multiDocumentProviders=i,this.codeEditorService=s,this._hasWordHighlights=Ik.bindTo(n),this._ignorePositionChangeEvent=!1,this.occurrencesHighlight=this.editor.getOption(81),this.model=this.editor.getModel(),this.toUnhook.add(e.onDidChangeCursorPosition(r=>{this._ignorePositionChangeEvent||this.occurrencesHighlight!=="off"&&this.runDelayer.trigger(()=>{this._onPositionChanged(r)})})),this.toUnhook.add(e.onDidFocusEditorText(r=>{this.occurrencesHighlight!=="off"&&(this.workerRequest||this.runDelayer.trigger(()=>{this._run()}))})),this.toUnhook.add(e.onDidChangeModelContent(r=>{$F(this.model.uri,"output")||this._stopAll()})),this.toUnhook.add(e.onDidChangeModel(r=>{!r.newModelUrl&&r.oldModelUrl?this._stopSingular():ts.query&&this._run()})),this.toUnhook.add(e.onDidChangeConfiguration(r=>{var d,u;const a=this.editor.getOption(81);if(this.occurrencesHighlight!==a)switch(this.occurrencesHighlight=a,a){case"off":this._stopAll();break;case"singleFile":this._stopAll((u=(d=ts.query)==null?void 0:d.modelInfo)==null?void 0:u.model);break;case"multiFile":ts.query&&this._run(!0);break;default:console.warn("Unknown occurrencesHighlight setting value:",a);break}})),this.decorations=this.editor.createDecorationsCollection(),this.workerRequestTokenId=0,this.workerRequest=null,this.workerRequestCompleted=!1,this.lastCursorPositionChangeTime=0,this.renderDecorationsTimer=-1,ts.query&&this._run()}hasDecorations(){return this.decorations.length>0}restore(){this.occurrencesHighlight!=="off"&&(this.runDelayer.cancel(),this._run())}_getSortedHighlights(){return this.decorations.getRanges().sort(Z.compareRangesUsingStarts)}moveNext(){const e=this._getSortedHighlights(),i=(e.findIndex(s=>s.containsPosition(this.editor.getPosition()))+1)%e.length,n=e[i];try{this._ignorePositionChangeEvent=!0,this.editor.setPosition(n.getStartPosition()),this.editor.revealRangeInCenterIfOutsideViewport(n);const s=this._getWord();if(s){const r=this.editor.getModel().getLineContent(n.startLineNumber);Ar(`${r}, ${i+1} of ${e.length} for '${s.word}'`)}}finally{this._ignorePositionChangeEvent=!1}}moveBack(){const e=this._getSortedHighlights(),i=(e.findIndex(s=>s.containsPosition(this.editor.getPosition()))-1+e.length)%e.length,n=e[i];try{this._ignorePositionChangeEvent=!0,this.editor.setPosition(n.getStartPosition()),this.editor.revealRangeInCenterIfOutsideViewport(n);const s=this._getWord();if(s){const r=this.editor.getModel().getLineContent(n.startLineNumber);Ar(`${r}, ${i+1} of ${e.length} for '${s.word}'`)}}finally{this._ignorePositionChangeEvent=!1}}_removeSingleDecorations(){if(!this.editor.hasModel())return;const e=ts.storedDecorationIDs.get(this.editor.getModel().uri);e&&(this.editor.removeDecorations(e),ts.storedDecorationIDs.delete(this.editor.getModel().uri),this.decorations.length>0&&(this.decorations.clear(),this._hasWordHighlights.set(!1)))}_removeAllDecorations(e){const t=this.codeEditorService.listCodeEditors(),i=[];for(const n of t){if(!n.hasModel()||iv(n.getModel().uri,e==null?void 0:e.uri))continue;const s=ts.storedDecorationIDs.get(n.getModel().uri);if(!s)continue;n.removeDecorations(s),i.push(n.getModel().uri);const r=Wc.get(n);r!=null&&r.wordHighlighter&&r.wordHighlighter.decorations.length>0&&(r.wordHighlighter.decorations.clear(),r.wordHighlighter.workerRequest=null,r.wordHighlighter._hasWordHighlights.set(!1))}for(const n of i)ts.storedDecorationIDs.delete(n)}_stopSingular(){var e,t,i,n;this._removeSingleDecorations(),this.editor.hasTextFocus()&&(((e=this.editor.getModel())==null?void 0:e.uri.scheme)!==go.vscodeNotebookCell&&((i=(t=ts.query)==null?void 0:t.modelInfo)==null?void 0:i.model.uri.scheme)!==go.vscodeNotebookCell?(ts.query=null,this._run()):(n=ts.query)!=null&&n.modelInfo&&(ts.query.modelInfo=null)),this.renderDecorationsTimer!==-1&&(clearTimeout(this.renderDecorationsTimer),this.renderDecorationsTimer=-1),this.workerRequest!==null&&(this.workerRequest.cancel(),this.workerRequest=null),this.workerRequestCompleted||(this.workerRequestTokenId++,this.workerRequestCompleted=!0)}_stopAll(e){this._removeAllDecorations(e),this.renderDecorationsTimer!==-1&&(clearTimeout(this.renderDecorationsTimer),this.renderDecorationsTimer=-1),this.workerRequest!==null&&(this.workerRequest.cancel(),this.workerRequest=null),this.workerRequestCompleted||(this.workerRequestTokenId++,this.workerRequestCompleted=!0)}_onPositionChanged(e){var t;if(this.occurrencesHighlight==="off"){this._stopAll();return}if(e.reason!==3&&((t=this.editor.getModel())==null?void 0:t.uri.scheme)!==go.vscodeNotebookCell){this._stopAll();return}this._run()}_getWord(){const e=this.editor.getSelection(),t=e.startLineNumber,i=e.startColumn;return this.model.isDisposed()?null:this.model.getWordAtPosition({lineNumber:t,column:i})}getOtherModelsToHighlight(e){if(!e)return[];if(e.uri.scheme===go.vscodeNotebookCell){const s=[],r=this.codeEditorService.listCodeEditors();for(const a of r){const d=a.getModel();d&&d!==e&&d.uri.scheme===go.vscodeNotebookCell&&s.push(d)}return s}const i=[],n=this.codeEditorService.listCodeEditors();for(const s of n){if(!sP(s))continue;const r=s.getModel();r&&e===r.modified&&i.push(r.modified)}if(i.length)return i;if(this.occurrencesHighlight==="singleFile")return[];for(const s of n){const r=s.getModel();r&&r!==e&&i.push(r)}return i}_run(e){var n,s;let t;if(this.editor.hasTextFocus()){const r=this.editor.getSelection();if(!r||r.startLineNumber!==r.endLineNumber){ts.query=null,this._stopAll();return}const a=r.startColumn,d=r.endColumn,u=this._getWord();if(!u||u.startColumn>a||u.endColumn<d){ts.query=null,this._stopAll();return}t=this.workerRequest&&this.workerRequest.isValid(this.model,r,this.decorations),ts.query={modelInfo:{model:this.model,selection:r},word:u}}else if(!ts.query){this._stopAll();return}if(this.lastCursorPositionChangeTime=new Date().getTime(),t)this.workerRequestCompleted&&this.renderDecorationsTimer!==-1&&(clearTimeout(this.renderDecorationsTimer),this.renderDecorationsTimer=-1,this._beginRenderDecorations());else if(iv(this.editor.getModel().uri,(n=ts.query.modelInfo)==null?void 0:n.model.uri)){if(!e){const d=this.decorations.getRanges();for(const u of d)if(u.containsPosition(this.editor.getPosition()))return}this._stopAll(e?this.model:void 0);const r=++this.workerRequestTokenId;this.workerRequestCompleted=!1;const a=this.getOtherModelsToHighlight(this.editor.getModel());if(!ts.query||!ts.query.modelInfo||ts.query.modelInfo.model.isDisposed())return;this.workerRequest=this.computeWithModel(ts.query.modelInfo.model,ts.query.modelInfo.selection,ts.query.word,a),(s=this.workerRequest)==null||s.result.then(d=>{r===this.workerRequestTokenId&&(this.workerRequestCompleted=!0,this.workerRequestValue=d||[],this._beginRenderDecorations())},Nn)}}computeWithModel(e,t,i,n){return n.length?L7(this.multiDocumentProviders,e,t,i,this.editor.getOption(132),n):k7(this.providers,e,t,i,this.editor.getOption(132))}_beginRenderDecorations(){const e=new Date().getTime(),t=this.lastCursorPositionChangeTime+250;e>=t?(this.renderDecorationsTimer=-1,this.renderDecorations()):this.renderDecorationsTimer=setTimeout(()=>{this.renderDecorations()},t-e)}renderDecorations(){var t,i,n;this.renderDecorationsTimer=-1;const e=this.codeEditorService.listCodeEditors();for(const s of e){const r=Wc.get(s);if(!r)continue;const a=[],d=(t=s.getModel())==null?void 0:t.uri;if(d&&this.workerRequestValue.has(d)){const u=ts.storedDecorationIDs.get(d),f=this.workerRequestValue.get(d);if(f)for(const p of f)p.range&&a.push({range:p.range,options:g$(p.kind)});let g=[];s.changeDecorations(p=>{g=p.deltaDecorations(u??[],a)}),ts.storedDecorationIDs=ts.storedDecorationIDs.set(d,g),a.length>0&&((i=r.wordHighlighter)==null||i.decorations.set(a),(n=r.wordHighlighter)==null||n._hasWordHighlights.set(!0))}}}dispose(){this._stopSingular(),this.toUnhook.dispose()}},ts=Tc,Tc.storedDecorationIDs=new Pc,Tc.query=null,Tc);kx=ts=RN([Xm(4,as)],kx);var fu;let Wc=(fu=class extends Dt{static get(e){return e.getContribution(xx.ID)}constructor(e,t,i,n){super(),this._wordHighlighter=null;const s=()=>{e.hasModel()&&!e.getModel().isTooLargeForTokenization()&&(this._wordHighlighter=new kx(e,i.documentHighlightProvider,i.multiDocumentHighlightProvider,t,n))};this._register(e.onDidChangeModel(r=>{this._wordHighlighter&&(this._wordHighlighter.dispose(),this._wordHighlighter=null),s()})),s()}get wordHighlighter(){return this._wordHighlighter}saveViewState(){return!!(this._wordHighlighter&&this._wordHighlighter.hasDecorations())}moveNext(){var e;(e=this._wordHighlighter)==null||e.moveNext()}moveBack(){var e;(e=this._wordHighlighter)==null||e.moveBack()}restoreViewState(e){this._wordHighlighter&&e&&this._wordHighlighter.restore()}dispose(){this._wordHighlighter&&(this._wordHighlighter.dispose(),this._wordHighlighter=null),super.dispose()}},xx=fu,fu.ID="editor.contrib.wordHighlighter",fu);Wc=xx=RN([Xm(1,Sn),Xm(2,pi),Xm(3,as)],Wc);class ON extends lt{constructor(e,t){super(t),this._isNext=e}run(e,t){const i=Wc.get(t);i&&(this._isNext?i.moveNext():i.moveBack())}}class I7 extends ON{constructor(){super(!0,{id:"editor.action.wordHighlight.next",label:C("wordHighlight.next.label","Go to Next Symbol Highlight"),alias:"Go to Next Symbol Highlight",precondition:Ik,kbOpts:{kbExpr:B.editorTextFocus,primary:65,weight:100}})}}class E7 extends ON{constructor(){super(!1,{id:"editor.action.wordHighlight.prev",label:C("wordHighlight.previous.label","Go to Previous Symbol Highlight"),alias:"Go to Previous Symbol Highlight",precondition:Ik,kbOpts:{kbExpr:B.editorTextFocus,primary:1089,weight:100}})}}class D7 extends lt{constructor(){super({id:"editor.action.wordHighlight.trigger",label:C("wordHighlight.trigger.label","Trigger Symbol Highlight"),alias:"Trigger Symbol Highlight",precondition:void 0,kbOpts:{kbExpr:B.editorTextFocus,primary:0,weight:100}})}run(e,t,i){const n=Wc.get(t);n&&n.restoreViewState(!0)}}nn(Wc.ID,Wc,0);xe(I7);xe(E7);xe(D7);$f(Cx);class cw extends wo{constructor(e){super(e),this._inSelectionMode=e.inSelectionMode,this._wordNavigationType=e.wordNavigationType}runEditorCommand(e,t,i){if(!t.hasModel())return;const n=Bu(t.getOption(132),t.getOption(131)),s=t.getModel(),r=t.getSelections(),a=r.length>1,d=r.map(u=>{const f=new gi(u.positionLineNumber,u.positionColumn),g=this._move(n,s,f,this._wordNavigationType,a);return this._moveTo(u,g,this._inSelectionMode)});if(s.pushStackElement(),t._getViewModel().setCursorStates("moveWordCommand",3,d.map(u=>GF.fromModelSelection(u))),d.length===1){const u=new gi(d[0].positionLineNumber,d[0].positionColumn);t.revealPosition(u,0)}}_moveTo(e,t,i){return i?new Fi(e.selectionStartLineNumber,e.selectionStartColumn,t.lineNumber,t.column):new Fi(t.lineNumber,t.column,t.lineNumber,t.column)}}class jc extends cw{_move(e,t,i,n,s){return y_.moveWordLeft(e,t,i,n,s)}}class $c extends cw{_move(e,t,i,n,s){return y_.moveWordRight(e,t,i,n)}}class T7 extends jc{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:"cursorWordStartLeft",precondition:void 0})}}class P7 extends jc{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:"cursorWordEndLeft",precondition:void 0})}}class M7 extends jc{constructor(){var e;super({inSelectionMode:!1,wordNavigationType:1,id:"cursorWordLeft",precondition:void 0,kbOpts:{kbExpr:Ae.and(B.textInputFocus,(e=Ae.and(Ry,Ny))==null?void 0:e.negate()),primary:2063,mac:{primary:527},weight:100}})}}class R7 extends jc{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:"cursorWordStartLeftSelect",precondition:void 0})}}class N7 extends jc{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:"cursorWordEndLeftSelect",precondition:void 0})}}class A7 extends jc{constructor(){var e;super({inSelectionMode:!0,wordNavigationType:1,id:"cursorWordLeftSelect",precondition:void 0,kbOpts:{kbExpr:Ae.and(B.textInputFocus,(e=Ae.and(Ry,Ny))==null?void 0:e.negate()),primary:3087,mac:{primary:1551},weight:100}})}}class O7 extends jc{constructor(){super({inSelectionMode:!1,wordNavigationType:3,id:"cursorWordAccessibilityLeft",precondition:void 0})}_move(e,t,i,n,s){return super._move(Bu(Ay.wordSeparators.defaultValue,e.intlSegmenterLocales),t,i,n,s)}}class F7 extends jc{constructor(){super({inSelectionMode:!0,wordNavigationType:3,id:"cursorWordAccessibilityLeftSelect",precondition:void 0})}_move(e,t,i,n,s){return super._move(Bu(Ay.wordSeparators.defaultValue,e.intlSegmenterLocales),t,i,n,s)}}class H7 extends $c{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:"cursorWordStartRight",precondition:void 0})}}class W7 extends $c{constructor(){var e;super({inSelectionMode:!1,wordNavigationType:2,id:"cursorWordEndRight",precondition:void 0,kbOpts:{kbExpr:Ae.and(B.textInputFocus,(e=Ae.and(Ry,Ny))==null?void 0:e.negate()),primary:2065,mac:{primary:529},weight:100}})}}class B7 extends $c{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:"cursorWordRight",precondition:void 0})}}class z7 extends $c{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:"cursorWordStartRightSelect",precondition:void 0})}}class V7 extends $c{constructor(){var e;super({inSelectionMode:!0,wordNavigationType:2,id:"cursorWordEndRightSelect",precondition:void 0,kbOpts:{kbExpr:Ae.and(B.textInputFocus,(e=Ae.and(Ry,Ny))==null?void 0:e.negate()),primary:3089,mac:{primary:1553},weight:100}})}}class j7 extends $c{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:"cursorWordRightSelect",precondition:void 0})}}class $7 extends $c{constructor(){super({inSelectionMode:!1,wordNavigationType:3,id:"cursorWordAccessibilityRight",precondition:void 0})}_move(e,t,i,n,s){return super._move(Bu(Ay.wordSeparators.defaultValue,e.intlSegmenterLocales),t,i,n,s)}}class U7 extends $c{constructor(){super({inSelectionMode:!0,wordNavigationType:3,id:"cursorWordAccessibilityRightSelect",precondition:void 0})}_move(e,t,i,n,s){return super._move(Bu(Ay.wordSeparators.defaultValue,e.intlSegmenterLocales),t,i,n,s)}}class dw extends wo{constructor(e){super(e),this._whitespaceHeuristics=e.whitespaceHeuristics,this._wordNavigationType=e.wordNavigationType}runEditorCommand(e,t,i){const n=e.get(Ds);if(!t.hasModel())return;const s=Bu(t.getOption(132),t.getOption(131)),r=t.getModel(),a=t.getSelections(),d=t.getOption(6),u=t.getOption(11),f=n.getLanguageConfiguration(r.getLanguageId()).getAutoClosingPairs(),g=t._getViewModel(),p=a.map(w=>{const y=this._delete({wordSeparators:s,model:r,selection:w,whitespaceHeuristics:this._whitespaceHeuristics,autoClosingDelete:t.getOption(9),autoClosingBrackets:d,autoClosingQuotes:u,autoClosingPairs:f,autoClosedCharacters:g.getCursorAutoClosedCharacters()},this._wordNavigationType);return new r_(y,"")});t.pushUndoStop(),t.executeCommands(this.id,p),t.pushUndoStop()}}class Ek extends dw{_delete(e,t){const i=y_.deleteWordLeft(e,t);return i||new Z(1,1,1,1)}}class Dk extends dw{_delete(e,t){const i=y_.deleteWordRight(e,t);if(i)return i;const n=e.model.getLineCount(),s=e.model.getLineMaxColumn(n);return new Z(n,s,n,s)}}class q7 extends Ek{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:0,id:"deleteWordStartLeft",precondition:B.writable})}}class G7 extends Ek{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:2,id:"deleteWordEndLeft",precondition:B.writable})}}class K7 extends Ek{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:0,id:"deleteWordLeft",precondition:B.writable,kbOpts:{kbExpr:B.textInputFocus,primary:2049,mac:{primary:513},weight:100}})}}class Z7 extends Dk{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:0,id:"deleteWordStartRight",precondition:B.writable})}}class Y7 extends Dk{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:2,id:"deleteWordEndRight",precondition:B.writable})}}class X7 extends Dk{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:2,id:"deleteWordRight",precondition:B.writable,kbOpts:{kbExpr:B.textInputFocus,primary:2068,mac:{primary:532},weight:100}})}}class Q7 extends lt{constructor(){super({id:"deleteInsideWord",precondition:B.writable,label:C("deleteInsideWord","Delete Word"),alias:"Delete Word"})}run(e,t,i){if(!t.hasModel())return;const n=Bu(t.getOption(132),t.getOption(131)),s=t.getModel(),a=t.getSelections().map(d=>{const u=y_.deleteInsideWord(n,s,d);return new r_(u,"")});t.pushUndoStop(),t.executeCommands(this.id,a),t.pushUndoStop()}}bi(new T7);bi(new P7);bi(new M7);bi(new R7);bi(new N7);bi(new A7);bi(new H7);bi(new W7);bi(new B7);bi(new z7);bi(new V7);bi(new j7);bi(new O7);bi(new F7);bi(new $7);bi(new U7);bi(new q7);bi(new G7);bi(new K7);bi(new Z7);bi(new Y7);bi(new X7);xe(Q7);class J7 extends dw{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:0,id:"deleteWordPartLeft",precondition:B.writable,kbOpts:{kbExpr:B.textInputFocus,primary:0,mac:{primary:769},weight:100}})}_delete(e,t){const i=Oy.deleteWordPartLeft(e);return i||new Z(1,1,1,1)}}class eU extends dw{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:2,id:"deleteWordPartRight",precondition:B.writable,kbOpts:{kbExpr:B.textInputFocus,primary:0,mac:{primary:788},weight:100}})}_delete(e,t){const i=Oy.deleteWordPartRight(e);if(i)return i;const n=e.model.getLineCount(),s=e.model.getLineMaxColumn(n);return new Z(n,s,n,s)}}class FN extends cw{_move(e,t,i,n,s){return Oy.moveWordPartLeft(e,t,i,s)}}class tU extends FN{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:"cursorWordPartLeft",precondition:void 0,kbOpts:{kbExpr:B.textInputFocus,primary:0,mac:{primary:783},weight:100}})}}Wn.registerCommandAlias("cursorWordPartStartLeft","cursorWordPartLeft");class iU extends FN{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:"cursorWordPartLeftSelect",precondition:void 0,kbOpts:{kbExpr:B.textInputFocus,primary:0,mac:{primary:1807},weight:100}})}}Wn.registerCommandAlias("cursorWordPartStartLeftSelect","cursorWordPartLeftSelect");class HN extends cw{_move(e,t,i,n,s){return Oy.moveWordPartRight(e,t,i)}}class nU extends HN{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:"cursorWordPartRight",precondition:void 0,kbOpts:{kbExpr:B.textInputFocus,primary:0,mac:{primary:785},weight:100}})}}class sU extends HN{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:"cursorWordPartRightSelect",precondition:void 0,kbOpts:{kbExpr:B.textInputFocus,primary:0,mac:{primary:1809},weight:100}})}}bi(new J7);bi(new eU);bi(new tU);bi(new iU);bi(new nU);bi(new sU);const qk=class qk extends Dt{constructor(e){super(),this.editor=e,this._register(this.editor.onDidAttemptReadOnlyEdit(()=>this._onDidAttemptReadOnlyEdit()))}_onDidAttemptReadOnlyEdit(){const e=Do.get(this.editor);if(e&&this.editor.hasModel()){let t=this.editor.getOptions().get(93);t||(this.editor.isSimpleWidget?t=new to(C("editor.simple.readonly","Cannot edit in read-only input")):t=new to(C("editor.readonly","Cannot edit in read-only editor"))),e.showMessage(t,this.editor.getPosition())}}};qk.ID="editor.contrib.readOnlyMessageController";let gb=qk;nn(gb.ID,gb,2);var oU=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},PE=function(o,e){return function(t,i){e(t,i,o)}};let Lx=class extends Dt{constructor(e,t,i){super(),this._textModel=e,this._languageFeaturesService=t,this._outlineModelService=i,this._currentModel=Uo(this,void 0);const n=wd("documentSymbolProvider.onDidChange",this._languageFeaturesService.documentSymbolProvider.onDidChange),s=wd("_textModel.onDidChangeContent",ws.debounce(r=>this._textModel.onDidChangeContent(r),()=>{},100));this._register(f_(async(r,a)=>{n.read(r),s.read(r);const d=a.add(new YF),u=await this._outlineModelService.getOrCreate(this._textModel,d.token);a.isDisposed||this._currentModel.set(u,void 0)}))}getBreadcrumbItems(e,t){const i=this._currentModel.read(t);if(!i)return[];const n=i.asListOfDocumentSymbols().filter(s=>e.contains(s.range.startLineNumber)&&!e.contains(s.range.endLineNumber));return n.sort(ZF(__(s=>s.range.endLineNumber-s.range.startLineNumber,Ly))),n.map(s=>({name:s.name,kind:s.kind,startLineNumber:s.range.startLineNumber}))}};Lx=oU([PE(1,pi),PE(2,N_)],Lx);KF.setBreadcrumbsSourceFactory((o,e)=>e.createInstance(Lx,o));const Gk=class Gk extends Dt{constructor(e){super(),this.editor=e,this.widget=null,LS&&(this._register(e.onDidChangeConfiguration(()=>this.update())),this.update())}update(){const e=!this.editor.getOption(92);!this.widget&&e?this.widget=new Ix(this.editor):this.widget&&!e&&(this.widget.dispose(),this.widget=null)}dispose(){super.dispose(),this.widget&&(this.widget.dispose(),this.widget=null)}};Gk.ID="editor.contrib.iPadShowKeyboard";let pb=Gk;const hy=class hy extends Dt{constructor(e){super(),this.editor=e,this._domNode=document.createElement("textarea"),this._domNode.className="iPadShowKeyboard",this._register(wn(this._domNode,"touchstart",t=>{this.editor.focus()})),this._register(wn(this._domNode,"focus",t=>{this.editor.focus()})),this.editor.addOverlayWidget(this)}dispose(){this.editor.removeOverlayWidget(this),super.dispose()}getId(){return hy.ID}getDomNode(){return this._domNode}getPosition(){return{preference:1}}};hy.ID="editor.contrib.ShowKeyboardWidget";let Ix=hy;nn(pb.ID,pb,3);var rU=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ME=function(o,e){return function(t,i){e(t,i,o)}},Ex,gu;let Kp=(gu=class extends Dt{static get(e){return e.getContribution(Ex.ID)}constructor(e,t,i){super(),this._editor=e,this._languageService=i,this._widget=null,this._register(this._editor.onDidChangeModel(n=>this.stop())),this._register(this._editor.onDidChangeModelLanguage(n=>this.stop())),this._register(Ey.onDidChange(n=>this.stop())),this._register(this._editor.onKeyUp(n=>n.keyCode===9&&this.stop()))}dispose(){this.stop(),super.dispose()}launch(){this._widget||this._editor.hasModel()&&(this._widget=new Dx(this._editor,this._languageService))}stop(){this._widget&&(this._widget.dispose(),this._widget=null)}},Ex=gu,gu.ID="editor.contrib.inspectTokens",gu);Kp=Ex=rU([ME(1,oP),ME(2,fa)],Kp);class aU extends lt{constructor(){super({id:"editor.action.inspectTokens",label:e3.inspectTokensAction,alias:"Developer: Inspect Tokens",precondition:void 0})}run(e,t){const i=Kp.get(t);i==null||i.launch()}}function lU(o){let e="";for(let t=0,i=o.length;t<i;t++){const n=o.charCodeAt(t);switch(n){case 9:e+="→";break;case 32:e+="·";break;default:e+=String.fromCharCode(n)}}return e}function cU(o,e){const t=Ey.get(e);if(t)return t;const i=o.encodeLanguageId(e);return{getInitialState:()=>XF,tokenize:(n,s,r)=>JF(e,r),tokenizeEncoded:(n,s,r)=>QF(i,r)}}const fy=class fy extends Dt{constructor(e,t){super(),this.allowEditorOverflow=!0,this._editor=e,this._languageService=t,this._model=this._editor.getModel(),this._domNode=document.createElement("div"),this._domNode.className="tokens-inspect-widget",this._tokenizationSupport=cU(this._languageService.languageIdCodec,this._model.getLanguageId()),this._compute(this._editor.getPosition()),this._register(this._editor.onDidChangeCursorPosition(i=>this._compute(this._editor.getPosition()))),this._editor.addContentWidget(this)}dispose(){this._editor.removeContentWidget(this),super.dispose()}getId(){return fy._ID}_compute(e){const t=this._getTokensAtLine(e.lineNumber);let i=0;for(let d=t.tokens1.length-1;d>=0;d--){const u=t.tokens1[d];if(e.column-1>=u.offset){i=d;break}}let n=0;for(let d=t.tokens2.length>>>1;d>=0;d--)if(e.column-1>=t.tokens2[d<<1]){n=d;break}const s=this._model.getLineContent(e.lineNumber);let r="";if(i<t.tokens1.length){const d=t.tokens1[i].offset,u=i+1<t.tokens1.length?t.tokens1[i+1].offset:s.length;r=s.substring(d,u)}nv(this._domNode,si("h2.tm-token",void 0,lU(r),si("span.tm-token-length",void 0,`${r.length} ${r.length===1?"char":"chars"}`))),ei(this._domNode,si("hr.tokens-inspect-separator",{style:"clear:both"}));const a=(n<<1)+1<t.tokens2.length?this._decodeMetadata(t.tokens2[(n<<1)+1]):null;ei(this._domNode,si("table.tm-metadata-table",void 0,si("tbody",void 0,si("tr",void 0,si("td.tm-metadata-key",void 0,"language"),si("td.tm-metadata-value",void 0,`${a?a.languageId:"-?-"}`)),si("tr",void 0,si("td.tm-metadata-key",void 0,"token type"),si("td.tm-metadata-value",void 0,`${a?this._tokenTypeToString(a.tokenType):"-?-"}`)),si("tr",void 0,si("td.tm-metadata-key",void 0,"font style"),si("td.tm-metadata-value",void 0,`${a?this._fontStyleToString(a.fontStyle):"-?-"}`)),si("tr",void 0,si("td.tm-metadata-key",void 0,"foreground"),si("td.tm-metadata-value",void 0,`${a?cn.Format.CSS.formatHex(a.foreground):"-?-"}`)),si("tr",void 0,si("td.tm-metadata-key",void 0,"background"),si("td.tm-metadata-value",void 0,`${a?cn.Format.CSS.formatHex(a.background):"-?-"}`))))),ei(this._domNode,si("hr.tokens-inspect-separator")),i<t.tokens1.length&&ei(this._domNode,si("span.tm-token-type",void 0,t.tokens1[i].type)),this._editor.layoutContentWidget(this)}_decodeMetadata(e){const t=Ey.getColorMap(),i=gg.getLanguageId(e),n=gg.getTokenType(e),s=gg.getFontStyle(e),r=gg.getForeground(e),a=gg.getBackground(e);return{languageId:this._languageService.languageIdCodec.decodeLanguageId(i),tokenType:n,fontStyle:s,foreground:t[r],background:t[a]}}_tokenTypeToString(e){switch(e){case 0:return"Other";case 1:return"Comment";case 2:return"String";case 3:return"RegEx";default:return"??"}}_fontStyleToString(e){let t="";return e&1&&(t+="italic "),e&2&&(t+="bold "),e&4&&(t+="underline "),e&8&&(t+="strikethrough "),t.length===0&&(t="---"),t}_getTokensAtLine(e){const t=this._getStateBeforeLine(e),i=this._tokenizationSupport.tokenize(this._model.getLineContent(e),!0,t),n=this._tokenizationSupport.tokenizeEncoded(this._model.getLineContent(e),!0,t);return{startState:t,tokens1:i.tokens,tokens2:n.tokens,endState:i.endState}}_getStateBeforeLine(e){let t=this._tokenizationSupport.getInitialState();for(let i=1;i<e;i++)t=this._tokenizationSupport.tokenize(this._model.getLineContent(i),!0,t).endState;return t}getDomNode(){return this._domNode}getPosition(){return{position:this._editor.getPosition(),preference:[2,1]}}};fy._ID="editor.contrib.inspectTokensWidget";let Dx=fy;nn(Kp.ID,Kp,4);xe(aU);var dU=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},RE=function(o,e){return function(t,i){e(t,i,o)}},Hg,pu;let Tx=(pu=class{constructor(e,t){this.quickInputService=e,this.keybindingService=t,this.registry=da.as(w_.Quickaccess)}provide(e){const t=new Lt;return t.add(e.onDidAccept(()=>{const[i]=e.selectedItems;i&&this.quickInputService.quickAccess.show(i.prefix,{preserveValue:!0})})),t.add(e.onDidChangeValue(i=>{const n=this.registry.getQuickAccessProvider(i.substr(Hg.PREFIX.length));n&&n.prefix&&n.prefix!==Hg.PREFIX&&this.quickInputService.quickAccess.show(n.prefix,{preserveValue:!0})})),e.items=this.getQuickAccessProviders().filter(i=>i.prefix!==Hg.PREFIX),t}getQuickAccessProviders(){return this.registry.getQuickAccessProviders().sort((t,i)=>t.prefix.localeCompare(i.prefix)).flatMap(t=>this.createPicks(t))}createPicks(e){return e.helpEntries.map(t=>{const i=t.prefix||e.prefix,n=i||"…";return{prefix:i,label:n,keybinding:t.commandId?this.keybindingService.lookupKeybinding(t.commandId):void 0,ariaLabel:C("helpPickAriaLabel","{0}, {1}",n,t.description),description:t.description}})}},Hg=pu,pu.PREFIX="?",pu);Tx=Hg=dU([RE(0,Ml),RE(1,hs)],Tx);da.as(w_.Quickaccess).registerQuickAccessProvider({ctor:Tx,prefix:"",helpEntries:[{description:t3.helpQuickAccessActionLabel}]});class WN{constructor(e){this.options=e,this.rangeHighlightDecorationId=void 0}provide(e,t,i){var r;const n=new Lt;e.canAcceptInBackground=!!((r=this.options)!=null&&r.canAcceptInBackground),e.matchOnLabel=e.matchOnDescription=e.matchOnDetail=e.sortByLabel=!1;const s=n.add(new Go);return s.value=this.doProvide(e,t,i),n.add(this.onDidActiveTextEditorControlChange(()=>{s.value=void 0,s.value=this.doProvide(e,t)})),n}doProvide(e,t,i){const n=new Lt,s=this.activeTextEditorControl;if(s&&this.canProvideWithTextEditor(s)){const r={editor:s},a=rP(s);if(a){let d=s.saveViewState()??void 0;n.add(a.onDidChangeCursorPosition(()=>{d=s.saveViewState()??void 0})),r.restoreViewState=()=>{d&&s===this.activeTextEditorControl&&s.restoreViewState(d)},n.add(aP(t.onCancellationRequested)(()=>{var u;return(u=r.restoreViewState)==null?void 0:u.call(r)}))}n.add(jn(()=>this.clearDecorations(s))),n.add(this.provideWithTextEditor(r,e,t,i))}else n.add(this.provideWithoutTextEditor(e,t));return n}canProvideWithTextEditor(e){return!0}gotoLocation({editor:e},t){e.setSelection(t.range,"code.jump"),e.revealRangeInCenter(t.range,0),t.preserveFocus||e.focus();const i=e.getModel();i&&"getLineContent"in i&&gf(`${i.getLineContent(t.range.startLineNumber)}`)}getModel(e){var t;return sP(e)?(t=e.getModel())==null?void 0:t.modified:e.getModel()}addDecorations(e,t){e.changeDecorations(i=>{const n=[];this.rangeHighlightDecorationId&&(n.push(this.rangeHighlightDecorationId.overviewRulerDecorationId),n.push(this.rangeHighlightDecorationId.rangeHighlightId),this.rangeHighlightDecorationId=void 0);const s=[{range:t,options:{description:"quick-access-range-highlight",className:"rangeHighlight",isWholeLine:!0}},{range:t,options:{description:"quick-access-range-highlight-overview",overviewRuler:{color:_s(hT),position:Ha.Full}}}],[r,a]=i.deltaDecorations(n,s);this.rangeHighlightDecorationId={rangeHighlightId:r,overviewRulerDecorationId:a}})}clearDecorations(e){const t=this.rangeHighlightDecorationId;t&&(e.changeDecorations(i=>{i.deltaDecorations([t.overviewRulerDecorationId,t.rangeHighlightId],[])}),this.rangeHighlightDecorationId=void 0)}}const gy=class gy extends WN{constructor(){super({canAcceptInBackground:!0})}provideWithoutTextEditor(e){const t=C("cannotRunGotoLine","Open a text editor first to go to a line.");return e.items=[{label:t}],e.ariaLabel=t,Dt.None}provideWithTextEditor(e,t,i){const n=e.editor,s=new Lt;s.add(t.onDidAccept(d=>{const[u]=t.selectedItems;if(u){if(!this.isValidLineNumber(n,u.lineNumber))return;this.gotoLocation(e,{range:this.toRange(u.lineNumber,u.column),keyMods:t.keyMods,preserveFocus:d.inBackground}),d.inBackground||t.hide()}}));const r=()=>{const d=this.parsePosition(n,t.value.trim().substr(gy.PREFIX.length)),u=this.getPickLabel(n,d.lineNumber,d.column);if(t.items=[{lineNumber:d.lineNumber,column:d.column,label:u}],t.ariaLabel=u,!this.isValidLineNumber(n,d.lineNumber)){this.clearDecorations(n);return}const f=this.toRange(d.lineNumber,d.column);n.revealRangeInCenter(f,0),this.addDecorations(n,f)};r(),s.add(t.onDidChangeValue(()=>r()));const a=rP(n);return a&&a.getOptions().get(68).renderType===2&&(a.updateOptions({lineNumbers:"on"}),s.add(jn(()=>a.updateOptions({lineNumbers:"relative"})))),s}toRange(e=1,t=1){return{startLineNumber:e,startColumn:t,endLineNumber:e,endColumn:t}}parsePosition(e,t){const i=t.split(/,|:|#/).map(s=>parseInt(s,10)).filter(s=>!isNaN(s)),n=this.lineCount(e)+1;return{lineNumber:i[0]>0?i[0]:n+i[0],column:i[1]}}getPickLabel(e,t,i){if(this.isValidLineNumber(e,t))return this.isValidColumn(e,t,i)?C("gotoLineColumnLabel","Go to line {0} and character {1}.",t,i):C("gotoLineLabel","Go to line {0}.",t);const n=e.getPosition()||{lineNumber:1,column:1},s=this.lineCount(e);return s>1?C("gotoLineLabelEmptyWithLimit","Current Line: {0}, Character: {1}. Type a line number between 1 and {2} to navigate to.",n.lineNumber,n.column,s):C("gotoLineLabelEmpty","Current Line: {0}, Character: {1}. Type a line number to navigate to.",n.lineNumber,n.column)}isValidLineNumber(e,t){return!t||typeof t!="number"?!1:t>0&&t<=this.lineCount(e)}isValidColumn(e,t,i){if(!i||typeof i!="number")return!1;const n=this.getModel(e);if(!n)return!1;const s={lineNumber:t,column:i};return n.validatePosition(s).equals(s)}lineCount(e){var t;return((t=this.getModel(e))==null?void 0:t.getLineCount())??0}};gy.PREFIX=":";let Px=gy;var uU=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},hU=function(o,e){return function(t,i){e(t,i,o)}};let Zp=class extends Px{constructor(e){super(),this.editorService=e,this.onDidActiveTextEditorControlChange=ws.None}get activeTextEditorControl(){return this.editorService.getFocusedCodeEditor()??void 0}};Zp=uU([hU(0,as)],Zp);var _u;let BN=(_u=class extends lt{constructor(){super({id:_u.ID,label:lP.gotoLineActionLabel,alias:"Go to Line/Column...",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:2085,mac:{primary:293},weight:100}})}run(e){e.get(Ml).quickAccess.show(Zp.PREFIX)}},_u.ID="editor.action.gotoLine",_u);xe(BN);da.as(w_.Quickaccess).registerQuickAccessProvider({ctor:Zp,prefix:Zp.PREFIX,helpEntries:[{description:lP.gotoLineActionLabel,commandId:BN.ID}]});const zN=[void 0,[]];function cS(o,e,t=0,i=0){const n=e;return n.values&&n.values.length>1?fU(o,n.values,t,i):VN(o,e,t,i)}function fU(o,e,t,i){let n=0;const s=[];for(const r of e){const[a,d]=VN(o,r,t,i);if(typeof a!="number")return zN;n+=a,s.push(...d)}return[n,gU(s)]}function VN(o,e,t,i){const n=PT(e.original,e.originalLowercase,t,o,o.toLowerCase(),i,{firstMatchCanBeWeak:!0,boostFullMatch:!0});return n?[n[0],Iy(n)]:zN}function gU(o){const e=o.sort((n,s)=>n.start-s.start),t=[];let i;for(const n of e)!i||!pU(i,n)?(i=n,t.push(n)):(i.start=Math.min(i.start,n.start),i.end=Math.max(i.end,n.end));return t}function pU(o,e){return!(o.end<e.start||e.end<o.start)}function NE(o){return o.startsWith('"')&&o.endsWith('"')}const jN=" ";function Mx(o){typeof o!="string"&&(o="");const e=o.toLowerCase(),{pathNormalized:t,normalized:i,normalizedLowercase:n}=AE(o),s=t.indexOf(NS)>=0,r=NE(o);let a;const d=o.split(jN);if(d.length>1)for(const u of d){const f=NE(u),{pathNormalized:g,normalized:p,normalizedLowercase:w}=AE(u);p&&(a||(a=[]),a.push({original:u,originalLowercase:u.toLowerCase(),pathNormalized:g,normalized:p,normalizedLowercase:w,expectContiguousMatch:f}))}return{original:o,originalLowercase:e,pathNormalized:t,normalized:i,normalizedLowercase:n,values:a,containsPathSeparator:s,expectContiguousMatch:r}}function AE(o){let e;vy?e=o.replace(/\//g,NS):e=o.replace(/\\/g,NS);const t=i3(e).replace(/\s|"/g,"");return{pathNormalized:e,normalized:t,normalizedLowercase:t.toLowerCase()}}function OE(o){return Array.isArray(o)?Mx(o.map(e=>e.original).join(jN)):Mx(o.original)}var _U=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},FE=function(o,e){return function(t,i){e(t,i,o)}},Qm,na;let Dd=(na=class extends WN{constructor(e,t,i=Object.create(null)){super(i),this._languageFeaturesService=e,this._outlineModelService=t,this.options=i,this.options.canAcceptInBackground=!0}provideWithoutTextEditor(e){return this.provideLabelPick(e,C("cannotRunGotoSymbolWithoutEditor","To go to a symbol, first open a text editor with symbol information.")),Dt.None}provideWithTextEditor(e,t,i,n){const s=e.editor,r=this.getModel(s);return r?this._languageFeaturesService.documentSymbolProvider.has(r)?this.doProvideWithEditorSymbols(e,r,t,i,n):this.doProvideWithoutEditorSymbols(e,r,t,i):Dt.None}doProvideWithoutEditorSymbols(e,t,i,n){const s=new Lt;return this.provideLabelPick(i,C("cannotRunGotoSymbolWithoutSymbolProvider","The active text editor does not provide symbol information.")),(async()=>!await this.waitForLanguageSymbolRegistry(t,s)||n.isCancellationRequested||s.add(this.doProvideWithEditorSymbols(e,t,i,n)))(),s}provideLabelPick(e,t){e.items=[{label:t,index:0,kind:14}],e.ariaLabel=t}async waitForLanguageSymbolRegistry(e,t){if(this._languageFeaturesService.documentSymbolProvider.has(e))return!0;const i=new by,n=t.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(()=>{this._languageFeaturesService.documentSymbolProvider.has(e)&&(n.dispose(),i.complete(!0))}));return t.add(jn(()=>i.complete(!1))),i.p}doProvideWithEditorSymbols(e,t,i,n,s){var g;const r=e.editor,a=new Lt;a.add(i.onDidAccept(p=>{var y;const[w]=i.selectedItems;w&&w.range&&(this.gotoLocation(e,{range:w.range.selection,keyMods:i.keyMods,preserveFocus:p.inBackground}),(y=s==null?void 0:s.handleAccept)==null||y.call(s,w),p.inBackground||i.hide())})),a.add(i.onDidTriggerItemButton(({item:p})=>{p&&p.range&&(this.gotoLocation(e,{range:p.range.selection,keyMods:i.keyMods,forceSideBySide:!0}),i.hide())}));const d=this.getDocumentSymbols(t,n);let u;const f=async p=>{u==null||u.dispose(!0),i.busy=!1,u=new Fs(n),i.busy=!0;try{const w=Mx(i.value.substr(Qm.PREFIX.length).trim()),y=await this.doGetSymbolPicks(d,w,void 0,u.token,t);if(n.isCancellationRequested)return;if(y.length>0){if(i.items=y,p&&w.original.length===0){const x=r3(y,k=>!!(k.type!=="separator"&&k.range&&Z.containsPosition(k.range.decoration,p)));x&&(i.activeItems=[x])}}else w.original.length>0?this.provideLabelPick(i,C("noMatchingSymbolResults","No matching editor symbols")):this.provideLabelPick(i,C("noSymbolResults","No editor symbols"))}finally{n.isCancellationRequested||(i.busy=!1)}};return a.add(i.onDidChangeValue(()=>f(void 0))),f((g=r.getSelection())==null?void 0:g.getPosition()),a.add(i.onDidChangeActive(()=>{const[p]=i.activeItems;p&&p.range&&(r.revealRangeInCenter(p.range.selection,0),this.addDecorations(r,p.range.decoration))})),a}async doGetSymbolPicks(e,t,i,n,s){var k,D;const r=await e;if(n.isCancellationRequested)return[];const a=t.original.indexOf(Qm.SCOPE_PREFIX)===0,d=a?1:0;let u,f;t.values&&t.values.length>1?(u=OE(t.values[0]),f=OE(t.values.slice(1))):u=t;let g;const p=(D=(k=this.options)==null?void 0:k.openSideBySideDirection)==null?void 0:D.call(k);p&&(g=[{iconClass:p==="right"?xn.asClassName(ji.splitHorizontal):xn.asClassName(ji.splitVertical),tooltip:p==="right"?C("openToSide","Open to the Side"):C("openToBottom","Open to the Bottom")}]);const w=[];for(let M=0;M<r.length;M++){const F=r[M],K=n3(F.name),V=`$(${s3.toIcon(F.kind).id}) ${K}`,se=V.length-K.length;let te=F.containerName;i!=null&&i.extraContainerLabel&&(te?te=`${i.extraContainerLabel} • ${te}`:te=i.extraContainerLabel);let pe,je,Ke,ue;if(t.original.length>d){let dt=!1;if(u!==t&&([pe,je]=cS(V,{...t,values:void 0},d,se),typeof pe=="number"&&(dt=!0)),typeof pe!="number"&&([pe,je]=cS(V,u,d,se),typeof pe!="number"))continue;if(!dt&&f){if(te&&f.original.length>0&&([Ke,ue]=cS(te,f)),typeof Ke!="number")continue;typeof pe=="number"&&(pe+=Ke)}}const He=F.tags&&F.tags.indexOf(1)>=0;w.push({index:M,kind:F.kind,score:pe,label:V,ariaLabel:o3(F.name,F.kind),description:te,highlights:He?void 0:{label:je,description:ue},range:{selection:Z.collapseToStart(F.selectionRange),decoration:F.range},uri:s.uri,symbolName:K,strikethrough:He,buttons:g})}const y=w.sort((M,F)=>a?this.compareByKindAndScore(M,F):this.compareByScore(M,F));let x=[];if(a){let V=function(){F&&typeof M=="number"&&K>0&&(F.label=h0(uS[M]||dS,K))},M,F,K=0;for(const se of y)M!==se.kind?(V(),M=se.kind,K=1,F={type:"separator"},x.push(F)):K++,x.push(se);V()}else y.length>0&&(x=[{label:C("symbols","symbols ({0})",w.length),type:"separator"},...y]);return x}compareByScore(e,t){if(typeof e.score!="number"&&typeof t.score=="number")return 1;if(typeof e.score=="number"&&typeof t.score!="number")return-1;if(typeof e.score=="number"&&typeof t.score=="number"){if(e.score>t.score)return-1;if(e.score<t.score)return 1}return e.index<t.index?-1:e.index>t.index?1:0}compareByKindAndScore(e,t){const i=uS[e.kind]||dS,n=uS[t.kind]||dS,s=i.localeCompare(n);return s===0?this.compareByScore(e,t):s}async getDocumentSymbols(e,t){const i=await this._outlineModelService.getOrCreate(e,t);return t.isCancellationRequested?[]:i.asListOfDocumentSymbols()}},Qm=na,na.PREFIX="@",na.SCOPE_PREFIX=":",na.PREFIX_BY_CATEGORY=`${na.PREFIX}${na.SCOPE_PREFIX}`,na);Dd=Qm=_U([FE(0,pi),FE(1,N_)],Dd);const dS=C("property","properties ({0})"),uS={5:C("method","methods ({0})"),11:C("function","functions ({0})"),8:C("_constructor","constructors ({0})"),12:C("variable","variables ({0})"),4:C("class","classes ({0})"),22:C("struct","structs ({0})"),23:C("event","events ({0})"),24:C("operator","operators ({0})"),10:C("interface","interfaces ({0})"),2:C("namespace","namespaces ({0})"),3:C("package","packages ({0})"),25:C("typeParameter","type parameters ({0})"),1:C("modules","modules ({0})"),6:C("property","properties ({0})"),9:C("enum","enumerations ({0})"),21:C("enumMember","enumeration members ({0})"),14:C("string","strings ({0})"),0:C("file","files ({0})"),17:C("array","arrays ({0})"),15:C("number","numbers ({0})"),16:C("boolean","booleans ({0})"),18:C("object","objects ({0})"),19:C("key","keys ({0})"),7:C("field","fields ({0})"),13:C("constant","constants ({0})")};var mU=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},hS=function(o,e){return function(t,i){e(t,i,o)}};let Rx=class extends Dd{constructor(e,t,i){super(t,i),this.editorService=e,this.onDidActiveTextEditorControlChange=ws.None}get activeTextEditorControl(){return this.editorService.getFocusedCodeEditor()??void 0}};Rx=mU([hS(0,as),hS(1,pi),hS(2,N_)],Rx);const py=class py extends lt{constructor(){super({id:py.ID,label:AS.quickOutlineActionLabel,alias:"Go to Symbol...",precondition:B.hasDocumentSymbolProvider,kbOpts:{kbExpr:B.focus,primary:3117,weight:100},contextMenuOpts:{group:"navigation",order:3}})}run(e){e.get(Ml).quickAccess.show(Dd.PREFIX,{itemActivation:a3.NONE})}};py.ID="editor.action.quickOutline";let _b=py;xe(_b);da.as(w_.Quickaccess).registerQuickAccessProvider({ctor:Rx,prefix:Dd.PREFIX,helpEntries:[{description:AS.quickOutlineActionLabel,prefix:Dd.PREFIX,commandId:_b.ID},{description:AS.quickOutlineByCategoryActionLabel,prefix:Dd.PREFIX_BY_CATEGORY}]});function vU(o){const e=new Map;for(const t of o)e.set(t,(e.get(t)??0)+1);return e}class op{constructor(){this.chunkCount=0,this.chunkOccurrences=new Map,this.documents=new Map}calculateScores(e,t){const i=this.computeEmbedding(e),n=new Map,s=[];for(const[r,a]of this.documents){if(t.isCancellationRequested)return[];for(const d of a.chunks){const u=this.computeSimilarityScore(d,i,n);u>0&&s.push({key:r,score:u})}}return s}static termFrequencies(e){return vU(op.splitTerms(e))}static*splitTerms(e){const t=i=>i.toLowerCase();for(const[i]of e.matchAll(new RegExp("\\b\\p{Letter}[\\p{Letter}\\d]{2,}\\b","gu"))){yield t(i);const n=i.replace(/([a-z])([A-Z])/g,"$1 $2").split(/\s+/g);if(n.length>1)for(const s of n)s.length>2&&new RegExp("\\p{Letter}{3,}","gu").test(s)&&(yield t(s))}}updateDocuments(e){for(const{key:t}of e)this.deleteDocument(t);for(const t of e){const i=[];for(const n of t.textChunks){const s=op.termFrequencies(n);for(const r of s.keys())this.chunkOccurrences.set(r,(this.chunkOccurrences.get(r)??0)+1);i.push({text:n,tf:s})}this.chunkCount+=i.length,this.documents.set(t.key,{chunks:i})}return this}deleteDocument(e){const t=this.documents.get(e);if(t){this.documents.delete(e),this.chunkCount-=t.chunks.length;for(const i of t.chunks)for(const n of i.tf.keys()){const s=this.chunkOccurrences.get(n);if(typeof s=="number"){const r=s-1;r<=0?this.chunkOccurrences.delete(n):this.chunkOccurrences.set(n,r)}}}}computeSimilarityScore(e,t,i){let n=0;for(const[s,r]of Object.entries(t)){const a=e.tf.get(s);if(!a)continue;let d=i.get(s);typeof d!="number"&&(d=this.computeIdf(s),i.set(s,d));const u=a*d;n+=u*r}return n}computeEmbedding(e){const t=op.termFrequencies(e);return this.computeTfidf(t)}computeIdf(e){const t=this.chunkOccurrences.get(e)??0;return t>0?Math.log((this.chunkCount+1)/t):0}computeTfidf(e){const t=Object.create(null);for(const[i,n]of e){const s=this.computeIdf(i);s>0&&(t[i]=n*s)}return t}}function bU(o){var i;const e=o.slice(0);e.sort((n,s)=>s.score-n.score);const t=((i=e[0])==null?void 0:i.score)??0;if(t>0)for(const n of e)n.score/=t;return e}var Nh;(function(o){o[o.NO_ACTION=0]="NO_ACTION",o[o.CLOSE_PICKER=1]="CLOSE_PICKER",o[o.REFRESH_PICKER=2]="REFRESH_PICKER",o[o.REMOVE_ITEM=3]="REMOVE_ITEM"})(Nh||(Nh={}));function fS(o){return Array.isArray(o.items)}function HE(o){const e=o;return!!e.picks&&e.additionalPicks instanceof Promise}class yU extends Dt{constructor(e,t){super(),this.prefix=e,this.options=t}provide(e,t,i){var u;const n=new Lt;e.canAcceptInBackground=!!((u=this.options)!=null&&u.canAcceptInBackground),e.matchOnLabel=e.matchOnDescription=e.matchOnDetail=e.sortByLabel=!1;let s;const r=n.add(new Go),a=async()=>{var k;const f=r.value=new Lt;s==null||s.dispose(!0),e.busy=!1,s=new Fs(t);const g=s.token;let p=e.value.substring(this.prefix.length);(k=this.options)!=null&&k.shouldSkipTrimPickFilter||(p=p.trim());const w=this._getPicks(p,f,g,i),y=(D,M)=>{var V;let F,K;if(fS(D)?(F=D.items,K=D.active):F=D,F.length===0){if(M)return!1;(p.length>0||e.hideInput)&&((V=this.options)!=null&&V.noResultsPick)&&(l3(this.options.noResultsPick)?F=[this.options.noResultsPick(p)]:F=[this.options.noResultsPick])}return e.items=F,K&&(e.activeItems=[K]),!0},x=async D=>{let M=!1,F=!1;await Promise.all([(async()=>{typeof D.mergeDelay=="number"&&(await Py(D.mergeDelay),g.isCancellationRequested)||F||(M=y(D.picks,!0))})(),(async()=>{e.busy=!0;try{const K=await D.additionalPicks;if(g.isCancellationRequested)return;let V,se;fS(D.picks)?(V=D.picks.items,se=D.picks.active):V=D.picks;let te,pe;if(fS(K)?(te=K.items,pe=K.active):te=K,te.length>0||!M){let je;if(!se&&!pe){const Ke=e.activeItems[0];Ke&&V.indexOf(Ke)!==-1&&(je=Ke)}y({items:[...V,...te],active:se||pe||je})}}finally{g.isCancellationRequested||(e.busy=!1),F=!0}})()])};if(w!==null)if(HE(w))await x(w);else if(!(w instanceof Promise))y(w);else{e.busy=!0;try{const D=await w;if(g.isCancellationRequested)return;HE(D)?await x(D):y(D)}finally{g.isCancellationRequested||(e.busy=!1)}}};n.add(e.onDidChangeValue(()=>a())),a(),n.add(e.onDidAccept(f=>{var p;if(i!=null&&i.handleAccept){f.inBackground||e.hide(),(p=i.handleAccept)==null||p.call(i,e.activeItems[0]);return}const[g]=e.selectedItems;typeof(g==null?void 0:g.accept)=="function"&&(f.inBackground||e.hide(),g.accept(e.keyMods,f))}));const d=async(f,g)=>{var w;if(typeof g.trigger!="function")return;const p=((w=g.buttons)==null?void 0:w.indexOf(f))??-1;if(p>=0){const y=g.trigger(p,e.keyMods),x=typeof y=="number"?y:await y;if(t.isCancellationRequested)return;switch(x){case Nh.NO_ACTION:break;case Nh.CLOSE_PICKER:e.hide();break;case Nh.REFRESH_PICKER:a();break;case Nh.REMOVE_ITEM:{const k=e.items.indexOf(g);if(k!==-1){const D=e.items.slice(),M=D.splice(k,1),F=e.activeItems.filter(V=>V!==M[0]),K=e.keepScrollPosition;e.keepScrollPosition=!0,e.items=D,F&&(e.activeItems=F),e.keepScrollPosition=K}break}}}};return n.add(e.onDidTriggerItemButton(({button:f,item:g})=>d(f,g))),n.add(e.onDidTriggerSeparatorButton(({button:f,separator:g})=>d(f,g))),n}}var $N=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ec=function(o,e){return function(t,i){e(t,i,o)}},sd,cs,Na;let Nx=(Na=class extends yU{constructor(e,t,i,n,s,r){super(sd.PREFIX,e),this.instantiationService=t,this.keybindingService=i,this.commandService=n,this.telemetryService=s,this.dialogService=r,this.commandsHistory=this._register(this.instantiationService.createInstance(Ax)),this.options=e}async _getPicks(e,t,i,n){var w,y;const s=await this.getCommandPicks(i);if(i.isCancellationRequested)return[];const r=aP(()=>{const x=new op;x.updateDocuments(s.map(D=>({key:D.commandId,textChunks:[this.getTfIdfChunk(D)]})));const k=x.calculateScores(e,i);return bU(k).filter(D=>D.score>sd.TFIDF_THRESHOLD).slice(0,sd.TFIDF_MAX_RESULTS)}),a=[];for(const x of s){const k=sd.WORD_FILTER(e,x.label)??void 0,D=x.commandAlias?sd.WORD_FILTER(e,x.commandAlias)??void 0:void 0;if(k||D)x.highlights={label:k,detail:this.options.showAlias?D:void 0},a.push(x);else if(e===x.commandId)a.push(x);else if(e.length>=3){const M=r();if(i.isCancellationRequested)return[];const F=M.find(K=>K.key===x.commandId);F&&(x.tfIdfScore=F.score,a.push(x))}}const d=new Map;for(const x of a){const k=d.get(x.label);k?(x.description=x.commandId,k.description=k.commandId):d.set(x.label,x)}a.sort((x,k)=>{if(x.tfIdfScore&&k.tfIdfScore)return x.tfIdfScore===k.tfIdfScore?x.label.localeCompare(k.label):k.tfIdfScore-x.tfIdfScore;if(x.tfIdfScore)return 1;if(k.tfIdfScore)return-1;const D=this.commandsHistory.peek(x.commandId),M=this.commandsHistory.peek(k.commandId);if(D&&M)return D>M?-1:1;if(D)return-1;if(M)return 1;if(this.options.suggestedCommandIds){const F=this.options.suggestedCommandIds.has(x.commandId),K=this.options.suggestedCommandIds.has(k.commandId);if(F&&K)return 0;if(F)return-1;if(K)return 1}return x.label.localeCompare(k.label)});const u=[];let f=!1,g=!0,p=!!this.options.suggestedCommandIds;for(let x=0;x<a.length;x++){const k=a[x];x===0&&this.commandsHistory.peek(k.commandId)&&(u.push({type:"separator",label:C("recentlyUsed","recently used")}),f=!0),g&&k.tfIdfScore!==void 0&&(u.push({type:"separator",label:C("suggested","similar commands")}),g=!1),p&&k.tfIdfScore===void 0&&!this.commandsHistory.peek(k.commandId)&&((w=this.options.suggestedCommandIds)!=null&&w.has(k.commandId))&&(u.push({type:"separator",label:C("commonlyUsed","commonly used")}),f=!0,p=!1),f&&k.tfIdfScore===void 0&&!this.commandsHistory.peek(k.commandId)&&!((y=this.options.suggestedCommandIds)!=null&&y.has(k.commandId))&&(u.push({type:"separator",label:C("morecCommands","other commands")}),f=!1),u.push(this.toCommandPick(k,n))}return this.hasAdditionalCommandPicks(e,i)?{picks:u,additionalPicks:(async()=>{var D;const x=await this.getAdditionalCommandPicks(s,a,e,i);if(i.isCancellationRequested)return[];const k=x.map(M=>this.toCommandPick(M,n));return g&&((D=k[0])==null?void 0:D.type)!=="separator"&&k.unshift({type:"separator",label:C("suggested","similar commands")}),k})()}:u}toCommandPick(e,t){if(e.type==="separator")return e;const i=this.keybindingService.lookupKeybinding(e.commandId),n=i?C("commandPickAriaLabelWithKeybinding","{0}, {1}",e.label,i.getAriaLabel()):e.label;return{...e,ariaLabel:n,detail:this.options.showAlias&&e.commandAlias!==e.label?e.commandAlias:void 0,keybinding:i,accept:async()=>{var s;this.commandsHistory.push(e.commandId),this.telemetryService.publicLog2("workbenchActionExecuted",{id:e.commandId,from:(t==null?void 0:t.from)??"quick open"});try{(s=e.args)!=null&&s.length?await this.commandService.executeCommand(e.commandId,...e.args):await this.commandService.executeCommand(e.commandId)}catch(r){Bc(r)||this.dialogService.error(C("canNotRun","Command '{0}' resulted in an error",e.label),Sv(r))}}}}getTfIdfChunk({label:e,commandAlias:t,commandDescription:i}){let n=e;return t&&t!==e&&(n+=` - ${t}`),i&&i.value!==e&&(n+=` - ${i.value===i.original?i.value:`${i.value} (${i.original})`}`),n}},sd=Na,Na.PREFIX=">",Na.TFIDF_THRESHOLD=.5,Na.TFIDF_MAX_RESULTS=5,Na.WORD_FILTER=c3(h3,u3,d3),Na);Nx=sd=$N([ec(1,Zi),ec(2,hs),ec(3,Es),ec(4,ha),ec(5,C0)],Nx);var sa;let Ax=(sa=class extends Dt{constructor(e,t,i){super(),this.storageService=e,this.configurationService=t,this.logService=i,this.configuredCommandsHistoryLength=0,this.updateConfiguration(),this.load(),this.registerListeners()}registerListeners(){this._register(this.configurationService.onDidChangeConfiguration(e=>this.updateConfiguration(e))),this._register(this.storageService.onWillSaveState(e=>{e.reason===s0.SHUTDOWN&&this.saveState()}))}updateConfiguration(e){e&&!e.affectsConfiguration("workbench.commandPalette.history")||(this.configuredCommandsHistoryLength=cs.getConfiguredCommandHistoryLength(this.configurationService),cs.cache&&cs.cache.limit!==this.configuredCommandsHistoryLength&&(cs.cache.limit=this.configuredCommandsHistoryLength,cs.hasChanges=!0))}load(){const e=this.storageService.get(cs.PREF_KEY_CACHE,0);let t;if(e)try{t=JSON.parse(e)}catch(n){this.logService.error(`[CommandsHistory] invalid data: ${n}`)}const i=cs.cache=new u_(this.configuredCommandsHistoryLength,1);if(t){let n;t.usesLRU?n=t.entries:n=t.entries.sort((s,r)=>s.value-r.value),n.forEach(s=>i.set(s.key,s.value))}cs.counter=this.storageService.getNumber(cs.PREF_KEY_COUNTER,0,cs.counter)}push(e){cs.cache&&(cs.cache.set(e,cs.counter++),cs.hasChanges=!0)}peek(e){var t;return(t=cs.cache)==null?void 0:t.peek(e)}saveState(){if(!cs.cache||!cs.hasChanges)return;const e={usesLRU:!0,entries:[]};cs.cache.forEach((t,i)=>e.entries.push({key:i,value:t})),this.storageService.store(cs.PREF_KEY_CACHE,JSON.stringify(e),0,0),this.storageService.store(cs.PREF_KEY_COUNTER,cs.counter,0,0),cs.hasChanges=!1}static getConfiguredCommandHistoryLength(e){var n,s;const i=(s=(n=e.getValue().workbench)==null?void 0:n.commandPalette)==null?void 0:s.history;return typeof i=="number"?i:cs.DEFAULT_COMMANDS_HISTORY_LENGTH}},cs=sa,sa.DEFAULT_COMMANDS_HISTORY_LENGTH=50,sa.PREF_KEY_CACHE="commandPalette.mru.cache",sa.PREF_KEY_COUNTER="commandPalette.mru.counter",sa.counter=1,sa.hasChanges=!1,sa);Ax=cs=$N([ec(0,zc),ec(1,Un),ec(2,Wu)],Ax);class wU extends Nx{constructor(e,t,i,n,s,r){super(e,t,i,n,s,r)}getCodeEditorCommandPicks(){var i;const e=this.activeTextEditorControl;if(!e)return[];const t=[];for(const n of e.getSupportedActions()){let s;(i=n.metadata)!=null&&i.description&&(f3(n.metadata.description)?s=n.metadata.description:s={original:n.metadata.description,value:n.metadata.description}),t.push({commandId:n.id,commandAlias:n.alias,commandDescription:s,label:g3(n.label)||n.id})}return t}}var SU=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},hh=function(o,e){return function(t,i){e(t,i,o)}};let Yp=class extends wU{get activeTextEditorControl(){return this.codeEditorService.getFocusedCodeEditor()??void 0}constructor(e,t,i,n,s,r){super({showAlias:!1},e,i,n,s,r),this.codeEditorService=t}async getCommandPicks(){return this.getCodeEditorCommandPicks()}hasAdditionalCommandPicks(){return!1}async getAdditionalCommandPicks(){return[]}};Yp=SU([hh(0,Zi),hh(1,as),hh(2,hs),hh(3,Es),hh(4,ha),hh(5,C0)],Yp);const _y=class _y extends lt{constructor(){super({id:_y.ID,label:cP.quickCommandActionLabel,alias:"Command Palette",precondition:void 0,kbOpts:{kbExpr:B.focus,primary:59,weight:100},contextMenuOpts:{group:"z_commands",order:1}})}run(e){e.get(Ml).quickAccess.show(Yp.PREFIX)}};_y.ID="editor.action.quickCommand";let mb=_y;xe(mb);da.as(w_.Quickaccess).registerQuickAccessProvider({ctor:Yp,prefix:Yp.PREFIX,helpEntries:[{description:cP.quickCommandHelp,commandId:mb.ID}]});var CU=function(o,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var a=o.length-1;a>=0;a--)(r=o[a])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},fh=function(o,e){return function(t,i){e(t,i,o)}};let Ox=class extends Tu{constructor(e,t,i,n,s,r,a){super(!0,e,t,i,n,s,r,a)}};Ox=CU([fh(1,Sn),fh(2,as),fh(3,co),fh(4,Zi),fh(5,zc),fh(6,Un)],Ox);nn(Tu.ID,Ox,4);class xU extends lt{constructor(){super({id:"editor.action.toggleHighContrast",label:p3.toggleHighContrast,alias:"Toggle High Contrast Theme",precondition:void 0}),this._originalThemeName=null}run(e,t){const i=e.get(oP),n=i.getColorTheme();hp(n.type)?(i.setTheme(this._originalThemeName||(WL(n.type)?_3:m3)),this._originalThemeName=null):(i.setTheme(WL(n.type)?v3:b3),this._originalThemeName=n.themeName)}}xe(xU);let Fx=null;function kU(o){Fx=o}function LU(o={}){return{"Content-Type":"application/json",...o}}async function Wt(o,e,t){const i=await fetch(e,{method:o,headers:LU(),body:t!==void 0?JSON.stringify(t):void 0});if(i.status===401)throw Fx&&Fx(),new Error("Unauthorized");if(!i.ok){const n=await i.json().catch(()=>({error:i.statusText}));throw new Error(n.error??i.statusText)}return i.json()}async function IU(){return await(await fetch("/she/auth/mode")).json()}async function EU(o){const e=await fetch("/she/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:o})});if(!e.ok){const t=await e.json().catch(()=>({error:e.statusText}));throw new Error(t.error??"Login failed")}}async function DU(){await fetch("/she/auth/logout",{method:"POST"})}async function TU(o,e,t,i){const n=await fetch("/she/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:o,password:e,proxyHeader:t,proxyLogoutUrl:i})});if(!n.ok){const s=await n.json().catch(()=>({error:n.statusText}));throw new Error(s.error??"Setup failed")}}function PU(){return Wt("GET","/she/scripts/tree")}function gS(o){return Wt("GET",`/she/scripts/${o}`)}function td(o,e){return Wt("PUT",`/she/scripts/${o}`,{content:e})}function Cm(o){return Wt("DELETE",`/she/scripts/${o}`)}function WE(o,e){return Wt("POST",`/she/scripts/${o}/rename`,{newPath:e})}function MU(o){return Wt("POST","/she/scripts/mkdir",{path:o})}function RU(){return Wt("GET","/she/git/status")}function Wg(){return Wt("GET","/she/status")}function UN(){return Wt("POST","/she/restart")}function NU(){return Wt("POST","/she/update")}function AU(){return Wt("POST","/she/check-update")}function OU(o,e){return Wt("POST","/she/git/commit",{path:o,message:e})}function BE(o,e){return Wt("POST","/she/git/commit",{files:o,message:e})}function zE(o){return Wt("POST","/she/git/commit",{message:o})}function xm(o){return Wt("POST","/she/git/push",{remote:o})}function FU(o,e){return Wt("GET",`/she/git/log?path=${encodeURIComponent(o)}&limit=${e}`)}function HU(o,e){return Wt("GET",`/she/git/show?hash=${encodeURIComponent(o)}&path=${encodeURIComponent(e)}`)}function Pl(){return Wt("GET","/she/config")}function Xp(o){return Wt("PUT","/she/config",o)}function qN(){return Wt("GET","/she/db/docs")}function WU(o){return Wt("GET",`/she/db/docs/${o}`)}function VE(o,e){return Wt("PUT",`/she/db/docs/${o}`,e)}function BU(o){return Wt("DELETE",`/she/db/docs/${o}`)}function GN(){return Wt("GET","/she/db/views")}function zU(o){return Wt("GET",`/she/db/views/${o}`)}function jE(o,e){return Wt("PUT",`/she/db/views/${o}`,e)}function VU(o){return Wt("DELETE",`/she/db/views/${o}`)}function jU(){return Wt("GET","/she/deps")}function $U(o){return Wt("GET",`/she/deps/search?q=${encodeURIComponent(o)}`)}function UU(o,e){return Wt("POST","/she/deps/install",{name:o,version:null})}function qU(o){return Wt("POST","/she/deps/remove",{name:o})}function GU(o){return Wt("POST","/she/deps/update",{name:o})}function KN(){return Wt("GET","/she/deps/outdated")}function KU(){return Wt("POST","/she/deps/check-outdated")}function ZU(){return Wt("GET","/she/ai/conversations")}function $E(o){return Wt("GET",`/she/ai/conversations/${encodeURIComponent(o)}`)}function YU(o,e,t){return Wt("PUT",`/she/ai/conversations/${encodeURIComponent(o)}`,{title:e,messages:t})}function XU(o){return Wt("DELETE",`/she/ai/conversations/${encodeURIComponent(o)}`)}function pS(o){return Wt("GET",`/she/db/views/${o}/result`)}function ZN(){return Wt("GET","/she/matter/devices")}function Jm(o){return Wt("GET",`/she/matter/devices/${o}`)}function QU(o){return Wt("POST","/she/matter/commission",o)}function JU(o){return Wt("DELETE",`/she/matter/devices/${o}`)}function eq(o,e,t,i,n){return Wt("POST",`/she/matter/devices/${o}/command`,{endpointId:e,clusterName:t,command:i,args:n})}function YN(){return Wt("GET","/she/mqtt/state")}function UE(o,e,t=!1,i=0){return Wt("POST","/she/mqtt/publish",{topic:o,payload:e,retain:t,qos:i})}function XN(){return Wt("GET","/she/ai/config")}function QN(){return Wt("GET","/she/ai/models")}function Hx(o){return Wt("GET",`/she/ai/model-info?model=${encodeURIComponent(o)}`)}function JN(o){return Wt("POST","/she/ai/prompt",o)}async function eA(o,e,t,i){const s=await fetch("/she/ai/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),signal:t});if(!s.ok){const u=await s.json().catch(()=>({error:s.statusText}));throw new Error(u.error??s.statusText)}const r=s.body.getReader(),a=new TextDecoder;let d="";try{for(;;){const{done:u,value:f}=await r.read();if(u)break;d+=a.decode(f,{stream:!0});const g=d.split(`
79
- `);d=g.pop()??"";for(const p of g){if(!p.startsWith("data: "))continue;const w=p.slice(6).trim();if(w==="[DONE]")return;try{const y=JSON.parse(w);if(y.error)throw new Error(y.error);if(y.type==="tool_call"||y.type==="tool_result"){i==null||i({type:y.type,name:y.name??"",args:y.args,content:y.content});continue}y.token&&e(y.token)}catch(y){if(y instanceof SyntaxError)continue;throw y}}}}finally{r.releaseLock()}}function Tk(){return Wt("GET","/she/broker/status")}function tq(){return Wt("GET","/she/broker/local/check")}function iq(){return Wt("GET","/she/broker/ip-addresses")}function Pk(){return Wt("GET","/she/broker/config")}function tA(o){return Wt("PUT","/she/broker/config",o)}function iA(){return Wt("POST","/she/broker/reload")}function nq(){return Wt("POST","/she/broker/restart")}function sq(){return Wt("POST","/she/broker/wizard/deactivate")}function oq(){return Wt("POST","/she/broker/wizard/reinit")}function rq(){return Wt("GET","/she/broker/wizard/diagnose")}function nA(){return Wt("GET","/she/broker/users")}function aq(o,e){return Wt("POST","/she/broker/users",{username:o,password:e})}function lq(o){return Wt("DELETE",`/she/broker/users/${encodeURIComponent(o)}`)}function cq(o,e){return Wt("PUT",`/she/broker/users/${encodeURIComponent(o)}/password`,{password:e})}function dq(o,e){return Wt("POST",`/she/broker/users/${encodeURIComponent(o)}/roles`,{rolename:e})}function uq(o,e){return Wt("DELETE",`/she/broker/users/${encodeURIComponent(o)}/roles/${encodeURIComponent(e)}`)}function sA(){return Wt("GET","/she/broker/roles")}function hq(o){return Wt("POST","/she/broker/roles",{rolename:o})}function fq(o){return Wt("DELETE",`/she/broker/roles/${encodeURIComponent(o)}`)}function gq(o,e){return Wt("POST",`/she/broker/roles/${encodeURIComponent(o)}/acls`,e)}function pq(o,e,t){return Wt("DELETE",`/she/broker/roles/${encodeURIComponent(o)}/acls`,{acltype:e,topic:t})}function oA(){return Wt("GET","/she/broker/groups")}function _q(o){return Wt("POST","/she/broker/groups",{groupname:o})}function mq(o){return Wt("DELETE",`/she/broker/groups/${encodeURIComponent(o)}`)}function qE(o,e){return Wt("POST",`/she/broker/groups/${encodeURIComponent(o)}/clients`,{username:e})}function GE(o,e){return Wt("DELETE",`/she/broker/groups/${encodeURIComponent(o)}/clients/${encodeURIComponent(e)}`)}function vq(o,e){return Wt("POST",`/she/broker/groups/${encodeURIComponent(o)}/roles`,{rolename:e})}function bq(o,e){return Wt("DELETE",`/she/broker/groups/${encodeURIComponent(o)}/roles/${encodeURIComponent(e)}`)}function rA(){return Wt("GET","/she/broker/acl-defaults")}function yq(o){return Wt("PUT","/she/broker/acl-defaults",{acls:o})}function wq(){return Wt("GET","/she/broker/anonymous-group")}function Sq(o){return Wt("PUT","/she/broker/anonymous-group",{groupname:o})}function Cq(){return Wt("GET","/she/broker/ca/server")}function xq(o){return Wt("POST","/she/broker/ca/server/generate",o)}function kq(o){return Wt("POST","/she/broker/ca/server/csr",o)}function _S(o){return Wt("POST","/she/broker/ca/server/import",o)}function Lq(){return Wt("GET","/she/broker/ca/trusted")}function Iq(o){return Wt("POST","/she/broker/ca/trusted",{pem:o})}function Eq(o){return Wt("DELETE",`/she/broker/ca/trusted/${encodeURIComponent(o)}`)}function Dq(o){return Wt("GET",`/she/broker/fs/complete?path=${encodeURIComponent(o)}`)}function Tq(o){return Wt("POST","/she/broker/ca/server/pathlink",o)}function Pq(o){return Wt("POST","/she/broker/ca/trusted/addpath",{path:o})}const Mq=2e3,ev=[];function aA(){return ev.slice()}let dc=null;const vb=new Set,Ah=new Map;let Wx=null;function Qp(){let o=vb.size;for(const e of Ah.values())o+=e.size;return o}function Rq(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/she/ws`}function Mk(){if(dc)return;const o=Rq(),e=new WebSocket(o);dc=e,e.onmessage=t=>{try{const i=JSON.parse(t.data);if(i.type==="log"){const s={level:i.level,msg:i.msg,ts:i.ts};ev.length>=Mq&&ev.shift(),ev.push(s),vb.forEach(r=>r(s))}const n=Ah.get(i.type);n&&n.forEach(s=>s(i))}catch{}},e.onclose=()=>{dc===e&&(dc=null),Qp()>0&&(Wx=setTimeout(Mk,3e3))},e.onerror=()=>{e.close()}}function lA(){Wx&&clearTimeout(Wx),dc==null||dc.close(),dc=null}function Rk(o){return vb.add(o),Qp()===1&&Mk(),()=>{vb.delete(o),Qp()===0&&lA()}}function cr(o,e){return Ah.has(o)||Ah.set(o,new Set),Ah.get(o).add(e),Qp()===1&&Mk(),()=>{var t;(t=Ah.get(o))==null||t.delete(e),Qp()===0&&lA()}}var Nq=T('<button class="cancel svelte-1eh8v5n">Cancel</button>'),Aq=T('<div class="backdrop svelte-1eh8v5n" role="presentation"></div> <div class="dialog svelte-1eh8v5n" role="dialog" aria-modal="true"><p class="svelte-1eh8v5n"> </p> <div class="actions svelte-1eh8v5n"><!> <button> </button></div></div>',1);function Uc(o,e){Ts(e,!0);let t=P(!1),i=P(""),n=P("Confirm"),s=P(!1),r=P(!1),a=null;function d(x,k){return v(i,x,!0),v(n,(k==null?void 0:k.confirm)??(k!=null&&k.alert?"OK":"Confirm"),!0),v(s,(k==null?void 0:k.danger)??!1,!0),v(r,(k==null?void 0:k.alert)??!1,!0),v(t,!0),new Promise(D=>a=D)}function u(x){v(t,!1),a==null||a(x),a=null}function f(x){c(t)&&(x.key==="Escape"&&u(!1),x.key==="Enter"&&u(!0))}var g={show:d},p=As();ds("keydown",xd,f);var w=xt(p);{var y=x=>{var k=Aq(),D=xt(k),M=m(D,2),F=b(M),K=b(F),V=m(F,2),se=b(V);{var te=ue=>{var He=Nq();z("click",He,()=>u(!1)),I(ue,He)};O(se,ue=>{c(r)||ue(te)})}var pe=m(se,2);let je;var Ke=b(pe);H(()=>{N(K,c(i)),je=kt(pe,1,"svelte-1eh8v5n",null,je,{danger:c(s)}),N(Ke,c(n))}),z("click",D,()=>u(!1)),z("click",pe,()=>u(!0)),I(x,k)};O(w,x=>{c(t)&&x(y)})}return I(o,p),Ps(g)}zs(["click"]);var Oq=T('<div class="backdrop svelte-1vi95tb" role="presentation"></div> <div class="dialog svelte-1vi95tb" role="dialog" aria-modal="true"><p class="svelte-1vi95tb"> </p> <input class="svelte-1vi95tb"/> <div class="actions svelte-1vi95tb"><button class="cancel svelte-1vi95tb">Cancel</button> <button class="svelte-1vi95tb"> </button></div></div>',1);function Fq(o,e){Ts(e,!0);let t=P(!1),i=P(""),n=P(""),s=P("OK"),r=P(""),a=null,d=P(void 0);function u(D,M){return v(i,D,!0),v(n,(M==null?void 0:M.placeholder)??"",!0),v(s,(M==null?void 0:M.confirm)??"OK",!0),v(r,(M==null?void 0:M.initial)??"",!0),v(t,!0),setTimeout(()=>{if(c(d)){c(d).focus();const F=c(d).value.length;c(d).setSelectionRange(F,F)}},0),new Promise(F=>a=F)}function f(){const D=c(r).trim();D&&(v(t,!1),a==null||a(D),a=null,v(r,""))}function g(){v(t,!1),a==null||a(null),a=null,v(r,"")}function p(D){c(t)&&D.key==="Escape"&&(D.stopPropagation(),g())}var w={show:u},y=As();ds("keydown",xd,p);var x=xt(y);{var k=D=>{var M=Oq(),F=xt(M),K=m(F,2),V=b(K),se=b(V),te=m(V,2);vs(te,He=>v(d,He),()=>c(d));var pe=m(te,2),je=b(pe),Ke=m(je,2),ue=b(Ke);H(He=>{N(se,c(i)),ln(te,"placeholder",c(n)),Ke.disabled=He,N(ue,c(s))},[()=>!c(r).trim()]),z("click",F,g),z("keydown",te,He=>{He.key==="Enter"&&(He.preventDefault(),f())}),Ht(te,()=>c(r),He=>v(r,He)),z("click",je,g),z("click",Ke,f),I(D,M)};O(x,D=>{c(t)&&D(k)})}return I(o,y),Ps(w)}zs(["click","keydown"]);function cA(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var mS,KE;function Hq(){if(KE)return mS;KE=1;function o(j){return j instanceof Map?j.clear=j.delete=j.set=function(){throw new Error("map is read-only")}:j instanceof Set&&(j.add=j.clear=j.delete=function(){throw new Error("set is read-only")}),Object.freeze(j),Object.getOwnPropertyNames(j).forEach(ce=>{const ke=j[ce],ze=typeof ke;(ze==="object"||ze==="function")&&!Object.isFrozen(ke)&&o(ke)}),j}class e{constructor(ce){ce.data===void 0&&(ce.data={}),this.data=ce.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function t(j){return j.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function i(j,...ce){const ke=Object.create(null);for(const ze in j)ke[ze]=j[ze];return ce.forEach(function(ze){for(const st in ze)ke[st]=ze[st]}),ke}const n="</span>",s=j=>!!j.scope,r=(j,{prefix:ce})=>{if(j.startsWith("language:"))return j.replace("language:","language-");if(j.includes(".")){const ke=j.split(".");return[`${ce}${ke.shift()}`,...ke.map((ze,st)=>`${ze}${"_".repeat(st+1)}`)].join(" ")}return`${ce}${j}`};class a{constructor(ce,ke){this.buffer="",this.classPrefix=ke.classPrefix,ce.walk(this)}addText(ce){this.buffer+=t(ce)}openNode(ce){if(!s(ce))return;const ke=r(ce.scope,{prefix:this.classPrefix});this.span(ke)}closeNode(ce){s(ce)&&(this.buffer+=n)}value(){return this.buffer}span(ce){this.buffer+=`<span class="${ce}">`}}const d=(j={})=>{const ce={children:[]};return Object.assign(ce,j),ce};class u{constructor(){this.rootNode=d(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ce){this.top.children.push(ce)}openNode(ce){const ke=d({scope:ce});this.add(ke),this.stack.push(ke)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ce){return this.constructor._walk(ce,this.rootNode)}static _walk(ce,ke){return typeof ke=="string"?ce.addText(ke):ke.children&&(ce.openNode(ke),ke.children.forEach(ze=>this._walk(ce,ze)),ce.closeNode(ke)),ce}static _collapse(ce){typeof ce!="string"&&ce.children&&(ce.children.every(ke=>typeof ke=="string")?ce.children=[ce.children.join("")]:ce.children.forEach(ke=>{u._collapse(ke)}))}}class f extends u{constructor(ce){super(),this.options=ce}addText(ce){ce!==""&&this.add(ce)}startScope(ce){this.openNode(ce)}endScope(){this.closeNode()}__addSublanguage(ce,ke){const ze=ce.root;ke&&(ze.scope=`language:${ke}`),this.add(ze)}toHTML(){return new a(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(j){return j?typeof j=="string"?j:j.source:null}function p(j){return x("(?=",j,")")}function w(j){return x("(?:",j,")*")}function y(j){return x("(?:",j,")?")}function x(...j){return j.map(ke=>g(ke)).join("")}function k(j){const ce=j[j.length-1];return typeof ce=="object"&&ce.constructor===Object?(j.splice(j.length-1,1),ce):{}}function D(...j){return"("+(k(j).capture?"":"?:")+j.map(ze=>g(ze)).join("|")+")"}function M(j){return new RegExp(j.toString()+"|").exec("").length-1}function F(j,ce){const ke=j&&j.exec(ce);return ke&&ke.index===0}const K=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function V(j,{joinWith:ce}){let ke=0;return j.map(ze=>{ke+=1;const st=ke;let X=g(ze),ae="";for(;X.length>0;){const me=K.exec(X);if(!me){ae+=X;break}ae+=X.substring(0,me.index),X=X.substring(me.index+me[0].length),me[0][0]==="\\"&&me[1]?ae+="\\"+String(Number(me[1])+st):(ae+=me[0],me[0]==="("&&ke++)}return ae}).map(ze=>`(${ze})`).join(ce)}const se=/\b\B/,te="[a-zA-Z]\\w*",pe="[a-zA-Z_]\\w*",je="\\b\\d+(\\.\\d+)?",Ke="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",ue="\\b(0b[01]+)",He="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",dt=(j={})=>{const ce=/^#![ ]*\//;return j.binary&&(j.begin=x(ce,/.*\b/,j.binary,/\b.*/)),i({scope:"meta",begin:ce,end:/$/,relevance:0,"on:begin":(ke,ze)=>{ke.index!==0&&ze.ignoreMatch()}},j)},we={begin:"\\\\[\\s\\S]",relevance:0},gt={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[we]},ot={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[we]},Pt={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Oe=function(j,ce,ke={}){const ze=i({scope:"comment",begin:j,end:ce,contains:[]},ke);ze.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const st=D("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return ze.contains.push({begin:x(/[ ]+/,"(",st,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ze},Mt=Oe("//","$"),et=Oe("/\\*","\\*/"),ct=Oe("#","$"),Nt={scope:"number",begin:je,relevance:0},ti={scope:"number",begin:Ke,relevance:0},ri={scope:"number",begin:ue,relevance:0},Vt={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[we,{begin:/\[/,end:/\]/,relevance:0,contains:[we]}]},Me={scope:"title",begin:te,relevance:0},jt={scope:"title",begin:pe,relevance:0},ft={begin:"\\.\\s*"+pe,relevance:0};var he=Object.freeze({__proto__:null,APOS_STRING_MODE:gt,BACKSLASH_ESCAPE:we,BINARY_NUMBER_MODE:ri,BINARY_NUMBER_RE:ue,COMMENT:Oe,C_BLOCK_COMMENT_MODE:et,C_LINE_COMMENT_MODE:Mt,C_NUMBER_MODE:ti,C_NUMBER_RE:Ke,END_SAME_AS_BEGIN:function(j){return Object.assign(j,{"on:begin":(ce,ke)=>{ke.data._beginMatch=ce[1]},"on:end":(ce,ke)=>{ke.data._beginMatch!==ce[1]&&ke.ignoreMatch()}})},HASH_COMMENT_MODE:ct,IDENT_RE:te,MATCH_NOTHING_RE:se,METHOD_GUARD:ft,NUMBER_MODE:Nt,NUMBER_RE:je,PHRASAL_WORDS_MODE:Pt,QUOTE_STRING_MODE:ot,REGEXP_MODE:Vt,RE_STARTERS_RE:He,SHEBANG:dt,TITLE_MODE:Me,UNDERSCORE_IDENT_RE:pe,UNDERSCORE_TITLE_MODE:jt});function Xe(j,ce){j.input[j.index-1]==="."&&ce.ignoreMatch()}function Ut(j,ce){j.className!==void 0&&(j.scope=j.className,delete j.className)}function wi(j,ce){ce&&j.beginKeywords&&(j.begin="\\b("+j.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",j.__beforeBegin=Xe,j.keywords=j.keywords||j.beginKeywords,delete j.beginKeywords,j.relevance===void 0&&(j.relevance=0))}function Ri(j,ce){Array.isArray(j.illegal)&&(j.illegal=D(...j.illegal))}function ci(j,ce){if(j.match){if(j.begin||j.end)throw new Error("begin & end are not supported with match");j.begin=j.match,delete j.match}}function Bt(j,ce){j.relevance===void 0&&(j.relevance=1)}const Xt=(j,ce)=>{if(!j.beforeMatch)return;if(j.starts)throw new Error("beforeMatch cannot be used with starts");const ke=Object.assign({},j);Object.keys(j).forEach(ze=>{delete j[ze]}),j.keywords=ke.keywords,j.begin=x(ke.beforeMatch,p(ke.begin)),j.starts={relevance:0,contains:[Object.assign(ke,{endsParent:!0})]},j.relevance=0,delete ke.beforeMatch},pt=["of","and","for","in","not","or","if","then","parent","list","value"],Bi="keyword";function Ti(j,ce,ke=Bi){const ze=Object.create(null);return typeof j=="string"?st(ke,j.split(" ")):Array.isArray(j)?st(ke,j):Object.keys(j).forEach(function(X){Object.assign(ze,Ti(j[X],ce,X))}),ze;function st(X,ae){ce&&(ae=ae.map(me=>me.toLowerCase())),ae.forEach(function(me){const Ze=me.split("|");ze[Ze[0]]=[X,Ni(Ze[0],Ze[1])]})}}function Ni(j,ce){return ce?Number(ce):Ki(j)?0:1}function Ki(j){return pt.includes(j.toLowerCase())}const Ai={},Di=j=>{console.error(j)},$i=(j,...ce)=>{console.log(`WARN: ${j}`,...ce)},Gi=(j,ce)=>{Ai[`${j}/${ce}`]||(console.log(`Deprecated as of ${j}. ${ce}`),Ai[`${j}/${ce}`]=!0)},Ui=new Error;function mn(j,ce,{key:ke}){let ze=0;const st=j[ke],X={},ae={};for(let me=1;me<=ce.length;me++)ae[me+ze]=st[me],X[me+ze]=!0,ze+=M(ce[me-1]);j[ke]=ae,j[ke]._emit=X,j[ke]._multi=!0}function rt(j){if(Array.isArray(j.begin)){if(j.skip||j.excludeBegin||j.returnBegin)throw Di("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Ui;if(typeof j.beginScope!="object"||j.beginScope===null)throw Di("beginScope must be object"),Ui;mn(j,j.begin,{key:"beginScope"}),j.begin=V(j.begin,{joinWith:""})}}function Kt(j){if(Array.isArray(j.end)){if(j.skip||j.excludeEnd||j.returnEnd)throw Di("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Ui;if(typeof j.endScope!="object"||j.endScope===null)throw Di("endScope must be object"),Ui;mn(j,j.end,{key:"endScope"}),j.end=V(j.end,{joinWith:""})}}function _i(j){j.scope&&typeof j.scope=="object"&&j.scope!==null&&(j.beginScope=j.scope,delete j.scope)}function Pi(j){_i(j),typeof j.beginScope=="string"&&(j.beginScope={_wrap:j.beginScope}),typeof j.endScope=="string"&&(j.endScope={_wrap:j.endScope}),rt(j),Kt(j)}function Li(j){function ce(ae,me){return new RegExp(g(ae),"m"+(j.case_insensitive?"i":"")+(j.unicodeRegex?"u":"")+(me?"g":""))}class ke{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(me,Ze){Ze.position=this.position++,this.matchIndexes[this.matchAt]=Ze,this.regexes.push([Ze,me]),this.matchAt+=M(me)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const me=this.regexes.map(Ze=>Ze[1]);this.matcherRe=ce(V(me,{joinWith:"|"}),!0),this.lastIndex=0}exec(me){this.matcherRe.lastIndex=this.lastIndex;const Ze=this.matcherRe.exec(me);if(!Ze)return null;const Zt=Ze.findIndex((We,At)=>At>0&&We!==void 0),bt=this.matchIndexes[Zt];return Ze.splice(0,Zt),Object.assign(Ze,bt)}}class ze{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(me){if(this.multiRegexes[me])return this.multiRegexes[me];const Ze=new ke;return this.rules.slice(me).forEach(([Zt,bt])=>Ze.addRule(Zt,bt)),Ze.compile(),this.multiRegexes[me]=Ze,Ze}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(me,Ze){this.rules.push([me,Ze]),Ze.type==="begin"&&this.count++}exec(me){const Ze=this.getMatcher(this.regexIndex);Ze.lastIndex=this.lastIndex;let Zt=Ze.exec(me);if(this.resumingScanAtSamePosition()&&!(Zt&&Zt.index===this.lastIndex)){const bt=this.getMatcher(0);bt.lastIndex=this.lastIndex+1,Zt=bt.exec(me)}return Zt&&(this.regexIndex+=Zt.position+1,this.regexIndex===this.count&&this.considerAll()),Zt}}function st(ae){const me=new ze;return ae.contains.forEach(Ze=>me.addRule(Ze.begin,{rule:Ze,type:"begin"})),ae.terminatorEnd&&me.addRule(ae.terminatorEnd,{type:"end"}),ae.illegal&&me.addRule(ae.illegal,{type:"illegal"}),me}function X(ae,me){const Ze=ae;if(ae.isCompiled)return Ze;[Ut,ci,Pi,Xt].forEach(bt=>bt(ae,me)),j.compilerExtensions.forEach(bt=>bt(ae,me)),ae.__beforeBegin=null,[wi,Ri,Bt].forEach(bt=>bt(ae,me)),ae.isCompiled=!0;let Zt=null;return typeof ae.keywords=="object"&&ae.keywords.$pattern&&(ae.keywords=Object.assign({},ae.keywords),Zt=ae.keywords.$pattern,delete ae.keywords.$pattern),Zt=Zt||/\w+/,ae.keywords&&(ae.keywords=Ti(ae.keywords,j.case_insensitive)),Ze.keywordPatternRe=ce(Zt,!0),me&&(ae.begin||(ae.begin=/\B|\b/),Ze.beginRe=ce(Ze.begin),!ae.end&&!ae.endsWithParent&&(ae.end=/\B|\b/),ae.end&&(Ze.endRe=ce(Ze.end)),Ze.terminatorEnd=g(Ze.end)||"",ae.endsWithParent&&me.terminatorEnd&&(Ze.terminatorEnd+=(ae.end?"|":"")+me.terminatorEnd)),ae.illegal&&(Ze.illegalRe=ce(ae.illegal)),ae.contains||(ae.contains=[]),ae.contains=[].concat(...ae.contains.map(function(bt){return Oi(bt==="self"?ae:bt)})),ae.contains.forEach(function(bt){X(bt,Ze)}),ae.starts&&X(ae.starts,me),Ze.matcher=st(Ze),Ze}if(j.compilerExtensions||(j.compilerExtensions=[]),j.contains&&j.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return j.classNameAliases=i(j.classNameAliases||{}),X(j)}function Si(j){return j?j.endsWithParent||Si(j.starts):!1}function Oi(j){return j.variants&&!j.cachedVariants&&(j.cachedVariants=j.variants.map(function(ce){return i(j,{variants:null},ce)})),j.cachedVariants?j.cachedVariants:Si(j)?i(j,{starts:j.starts?i(j.starts):null}):Object.isFrozen(j)?i(j):j}var qi="11.11.1";class mi extends Error{constructor(ce,ke){super(ce),this.name="HTMLInjectionError",this.html=ke}}const Ue=t,J=i,Qe=Symbol("nomatch"),_t=7,yt=function(j){const ce=Object.create(null),ke=Object.create(null),ze=[];let st=!0;const X="Could not find the language '{}', did you forget to load/include a language module?",ae={disableAutodetect:!0,name:"Plain text",contains:[]};let me={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:f};function Ze(W){return me.noHighlightRe.test(W)}function Zt(W){let Q=W.className+" ";Q+=W.parentNode?W.parentNode.className:"";const oe=me.languageDetectRe.exec(Q);if(oe){const $=Qt(oe[1]);return $||($i(X.replace("{}",oe[1])),$i("Falling back to no-highlight mode for this block.",W)),$?oe[1]:"no-highlight"}return Q.split(/\s+/).find($=>Ze($)||Qt($))}function bt(W,Q,oe){let $="",A="";typeof Q=="object"?($=W,oe=Q.ignoreIllegals,A=Q.language):(Gi("10.7.0","highlight(lang, code, ...args) has been deprecated."),Gi("10.7.0",`Please use highlight(code, options) instead.
80
- https://github.com/highlightjs/highlight.js/issues/2277`),A=W,$=Q),oe===void 0&&(oe=!0);const G={code:$,language:A};It("before:highlight",G);const ie=G.result?G.result:We(G.language,G.code,oe);return ie.code=G.code,It("after:highlight",ie),ie}function We(W,Q,oe,$){const A=Object.create(null);function G(de,Pe){return de.keywords[Pe]}function ie(){if(!qe.keywords){it.addText(ye);return}let de=0;qe.keywordPatternRe.lastIndex=0;let Pe=qe.keywordPatternRe.exec(ye),at="";for(;Pe;){at+=ye.substring(de,Pe.index);const ut=Ie.case_insensitive?Pe[0].toLowerCase():Pe[0],Je=G(qe,ut);if(Je){const[$t,Jt]=Je;if(it.addText(at),at="",A[ut]=(A[ut]||0)+1,A[ut]<=_t&&(Ne+=Jt),$t.startsWith("_"))at+=Pe[0];else{const Mi=Ie.classNameAliases[$t]||$t;le(Pe[0],Mi)}}else at+=Pe[0];de=qe.keywordPatternRe.lastIndex,Pe=qe.keywordPatternRe.exec(ye)}at+=ye.substring(de),it.addText(at)}function fe(){if(ye==="")return;let de=null;if(typeof qe.subLanguage=="string"){if(!ce[qe.subLanguage]){it.addText(ye);return}de=We(qe.subLanguage,ye,!0,Tt[qe.subLanguage]),Tt[qe.subLanguage]=de._top}else de=ai(ye,qe.subLanguage.length?qe.subLanguage:null);qe.relevance>0&&(Ne+=de.relevance),it.__addSublanguage(de._emitter,de.language)}function Y(){qe.subLanguage!=null?fe():ie(),ye=""}function le(de,Pe){de!==""&&(it.startScope(Pe),it.addText(de),it.endScope())}function Re(de,Pe){let at=1;const ut=Pe.length-1;for(;at<=ut;){if(!de._emit[at]){at++;continue}const Je=Ie.classNameAliases[de[at]]||de[at],$t=Pe[at];Je?le($t,Je):(ye=$t,ie(),ye=""),at++}}function _e(de,Pe){return de.scope&&typeof de.scope=="string"&&it.openNode(Ie.classNameAliases[de.scope]||de.scope),de.beginScope&&(de.beginScope._wrap?(le(ye,Ie.classNameAliases[de.beginScope._wrap]||de.beginScope._wrap),ye=""):de.beginScope._multi&&(Re(de.beginScope,Pe),ye="")),qe=Object.create(de,{parent:{value:qe}}),qe}function ge(de,Pe,at){let ut=F(de.endRe,at);if(ut){if(de["on:end"]){const Je=new e(de);de["on:end"](Pe,Je),Je.isMatchIgnored&&(ut=!1)}if(ut){for(;de.endsParent&&de.parent;)de=de.parent;return de}}if(de.endsWithParent)return ge(de.parent,Pe,at)}function tt(de){return qe.matcher.regexIndex===0?(ye+=de[0],1):(nt=!0,0)}function U(de){const Pe=de[0],at=de.rule,ut=new e(at),Je=[at.__beforeBegin,at["on:begin"]];for(const $t of Je)if($t&&($t(de,ut),ut.isMatchIgnored))return tt(Pe);return at.skip?ye+=Pe:(at.excludeBegin&&(ye+=Pe),Y(),!at.returnBegin&&!at.excludeBegin&&(ye=Pe)),_e(at,de),at.returnBegin?0:Pe.length}function ne(de){const Pe=de[0],at=Q.substring(de.index),ut=ge(qe,de,at);if(!ut)return Qe;const Je=qe;qe.endScope&&qe.endScope._wrap?(Y(),le(Pe,qe.endScope._wrap)):qe.endScope&&qe.endScope._multi?(Y(),Re(qe.endScope,de)):Je.skip?ye+=Pe:(Je.returnEnd||Je.excludeEnd||(ye+=Pe),Y(),Je.excludeEnd&&(ye=Pe));do qe.scope&&it.closeNode(),!qe.skip&&!qe.subLanguage&&(Ne+=qe.relevance),qe=qe.parent;while(qe!==ut.parent);return ut.starts&&_e(ut.starts,de),Je.returnEnd?0:Pe.length}function Le(){const de=[];for(let Pe=qe;Pe!==Ie;Pe=Pe.parent)Pe.scope&&de.unshift(Pe.scope);de.forEach(Pe=>it.openNode(Pe))}let Ve={};function De(de,Pe){const at=Pe&&Pe[0];if(ye+=de,at==null)return Y(),0;if(Ve.type==="begin"&&Pe.type==="end"&&Ve.index===Pe.index&&at===""){if(ye+=Q.slice(Pe.index,Pe.index+1),!st){const ut=new Error(`0 width match regex (${W})`);throw ut.languageName=W,ut.badRule=Ve.rule,ut}return 1}if(Ve=Pe,Pe.type==="begin")return U(Pe);if(Pe.type==="illegal"&&!oe){const ut=new Error('Illegal lexeme "'+at+'" for mode "'+(qe.scope||"<unnamed>")+'"');throw ut.mode=qe,ut}else if(Pe.type==="end"){const ut=ne(Pe);if(ut!==Qe)return ut}if(Pe.type==="illegal"&&at==="")return ye+=`
81
- `,1;if(Se>1e5&&Se>Pe.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ye+=at,at.length}const Ie=Qt(W);if(!Ie)throw Di(X.replace("{}",W)),new Error('Unknown language: "'+W+'"');const St=Li(Ie);let mt="",qe=$||St;const Tt={},it=new me.__emitter(me);Le();let ye="",Ne=0,Ee=0,Se=0,nt=!1;try{if(Ie.__emitTokens)Ie.__emitTokens(Q,it);else{for(qe.matcher.considerAll();;){Se++,nt?nt=!1:qe.matcher.considerAll(),qe.matcher.lastIndex=Ee;const de=qe.matcher.exec(Q);if(!de)break;const Pe=Q.substring(Ee,de.index),at=De(Pe,de);Ee=de.index+at}De(Q.substring(Ee))}return it.finalize(),mt=it.toHTML(),{language:W,value:mt,relevance:Ne,illegal:!1,_emitter:it,_top:qe}}catch(de){if(de.message&&de.message.includes("Illegal"))return{language:W,value:Ue(Q),illegal:!0,relevance:0,_illegalBy:{message:de.message,index:Ee,context:Q.slice(Ee-100,Ee+100),mode:de.mode,resultSoFar:mt},_emitter:it};if(st)return{language:W,value:Ue(Q),illegal:!1,relevance:0,errorRaised:de,_emitter:it,_top:qe};throw de}}function At(W){const Q={value:Ue(W),illegal:!1,relevance:0,_top:ae,_emitter:new me.__emitter(me)};return Q._emitter.addText(W),Q}function ai(W,Q){Q=Q||me.languages||Object.keys(ce);const oe=At(W),$=Q.filter(Qt).filter(Ge).map(Y=>We(Y,W,!1));$.unshift(oe);const A=$.sort((Y,le)=>{if(Y.relevance!==le.relevance)return le.relevance-Y.relevance;if(Y.language&&le.language){if(Qt(Y.language).supersetOf===le.language)return 1;if(Qt(le.language).supersetOf===Y.language)return-1}return 0}),[G,ie]=A,fe=G;return fe.secondBest=ie,fe}function zt(W,Q,oe){const $=Q&&ke[Q]||oe;W.classList.add("hljs"),W.classList.add(`language-${$}`)}function vi(W){let Q=null;const oe=Zt(W);if(Ze(oe))return;if(It("before:highlightElement",{el:W,language:oe}),W.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",W);return}if(W.children.length>0&&(me.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(W)),me.throwUnescapedHTML))throw new mi("One of your code blocks includes unescaped HTML.",W.innerHTML);Q=W;const $=Q.textContent,A=oe?bt($,{language:oe,ignoreIllegals:!0}):ai($);W.innerHTML=A.value,W.dataset.highlighted="yes",zt(W,oe,A.language),W.result={language:A.language,re:A.relevance,relevance:A.relevance},A.secondBest&&(W.secondBest={language:A.secondBest.language,relevance:A.secondBest.relevance}),It("after:highlightElement",{el:W,result:A,text:$})}function hi(W){me=J(me,W)}const Ci=()=>{Fe(),Gi("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function zi(){Fe(),Gi("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let $e=!1;function Fe(){function W(){Fe()}if(document.readyState==="loading"){$e||window.addEventListener("DOMContentLoaded",W,!1),$e=!0;return}document.querySelectorAll(me.cssSelector).forEach(vi)}function Ft(W,Q){let oe=null;try{oe=Q(j)}catch($){if(Di("Language definition for '{}' could not be registered.".replace("{}",W)),st)Di($);else throw $;oe=ae}oe.name||(oe.name=W),ce[W]=oe,oe.rawDefinition=Q.bind(null,j),oe.aliases&&re(oe.aliases,{languageName:W})}function Yt(W){delete ce[W];for(const Q of Object.keys(ke))ke[Q]===W&&delete ke[Q]}function qt(){return Object.keys(ce)}function Qt(W){return W=(W||"").toLowerCase(),ce[W]||ce[ke[W]]}function re(W,{languageName:Q}){typeof W=="string"&&(W=[W]),W.forEach(oe=>{ke[oe.toLowerCase()]=Q})}function Ge(W){const Q=Qt(W);return Q&&!Q.disableAutodetect}function wt(W){W["before:highlightBlock"]&&!W["before:highlightElement"]&&(W["before:highlightElement"]=Q=>{W["before:highlightBlock"](Object.assign({block:Q.el},Q))}),W["after:highlightBlock"]&&!W["after:highlightElement"]&&(W["after:highlightElement"]=Q=>{W["after:highlightBlock"](Object.assign({block:Q.el},Q))})}function vt(W){wt(W),ze.push(W)}function di(W){const Q=ze.indexOf(W);Q!==-1&&ze.splice(Q,1)}function It(W,Q){const oe=W;ze.forEach(function($){$[oe]&&$[oe](Q)})}function Ii(W){return Gi("10.7.0","highlightBlock will be removed entirely in v12.0"),Gi("10.7.0","Please use highlightElement now."),vi(W)}Object.assign(j,{highlight:bt,highlightAuto:ai,highlightAll:Fe,highlightElement:vi,highlightBlock:Ii,configure:hi,initHighlighting:Ci,initHighlightingOnLoad:zi,registerLanguage:Ft,unregisterLanguage:Yt,listLanguages:qt,getLanguage:Qt,registerAliases:re,autoDetection:Ge,inherit:J,addPlugin:vt,removePlugin:di}),j.debugMode=function(){st=!1},j.safeMode=function(){st=!0},j.versionString=qi,j.regex={concat:x,lookahead:p,either:D,optional:y,anyNumberOfTimes:w};for(const W in he)typeof he[W]=="object"&&o(he[W]);return Object.assign(j,he),j},Ot=yt({});return Ot.newInstance=()=>yt({}),mS=Ot,Ot.HighlightJS=Ot,Ot.default=Ot,mS}var Wq=Hq();const bb=cA(Wq),ZE="[A-Za-z$_][0-9A-Za-z$_]*",Bq=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],zq=["true","false","null","undefined","NaN","Infinity"],dA=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],uA=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],hA=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Vq=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],jq=[].concat(hA,dA,uA);function fA(o){const e=o.regex,t=(Oe,{after:Mt})=>{const et="</"+Oe[0].slice(1);return Oe.input.indexOf(et,Mt)!==-1},i=ZE,n={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,r={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Oe,Mt)=>{const et=Oe[0].length+Oe.index,ct=Oe.input[et];if(ct==="<"||ct===","){Mt.ignoreMatch();return}ct===">"&&(t(Oe,{after:et})||Mt.ignoreMatch());let Nt;const ti=Oe.input.substring(et);if(Nt=ti.match(/^\s*=/)){Mt.ignoreMatch();return}if((Nt=ti.match(/^\s+extends\s+/))&&Nt.index===0){Mt.ignoreMatch();return}}},a={$pattern:ZE,keyword:Bq,literal:zq,built_in:jq,"variable.language":Vq},d="[0-9](_?[0-9])*",u=`\\.(${d})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${f})((${u})|\\.)?|(${u}))[eE][+-]?(${d})\\b`},{begin:`\\b(${f})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[o.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[o.BACKSLASH_ESCAPE,p],subLanguage:"css"}},x={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[o.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},k={className:"string",begin:"`",end:"`",contains:[o.BACKSLASH_ESCAPE,p]},M={className:"comment",variants:[o.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),o.C_BLOCK_COMMENT_MODE,o.C_LINE_COMMENT_MODE]},F=[o.APOS_STRING_MODE,o.QUOTE_STRING_MODE,w,y,x,k,{match:/\$\d+/},g];p.contains=F.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(F)});const K=[].concat(M,p.contains),V=K.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(K)}]),se={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:V},te={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,e.concat(i,"(",e.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},pe={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...dA,...uA]}},je={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},Ke={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[se],illegal:/%/},ue={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function He(Oe){return e.concat("(?!",Oe.join("|"),")")}const dt={match:e.concat(/\b/,He([...hA,"super","import"].map(Oe=>`${Oe}\\s*\\(`)),i,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},we={begin:e.concat(/\./,e.lookahead(e.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},gt={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},se]},ot="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+o.UNDERSCORE_IDENT_RE+")\\s*=>",Pt={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(ot)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[se]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:V,CLASS_REFERENCE:pe},illegal:/#(?![$_A-z])/,contains:[o.SHEBANG({label:"shebang",binary:"node",relevance:5}),je,o.APOS_STRING_MODE,o.QUOTE_STRING_MODE,w,y,x,k,M,{match:/\$\d+/},g,pe,{scope:"attr",match:i+e.lookahead(":"),relevance:0},Pt,{begin:"("+o.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[M,o.REGEXP_MODE,{className:"function",begin:ot,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:o.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:V}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:n.begin,end:n.end},{match:s},{begin:r.begin,"on:begin":r.isTrulyOpeningTag,end:r.end}],subLanguage:"xml",contains:[{begin:r.begin,end:r.end,skip:!0,contains:["self"]}]}]},Ke,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+o.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[se,o.inherit(o.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},we,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[se]},dt,ue,te,gt,{match:/\$[(.]/}]}}function Nk(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Gu=Nk();function gA(o){Gu=o}var ad={exec:()=>null};function gh(o){let e=[];return t=>{let i=Math.max(0,Math.min(3,t-1)),n=e[i];return n||(n=o(i),e[i]=n),n}}function Hn(o,e=""){let t=typeof o=="string"?o:o.source,i={replace:(n,s)=>{let r=typeof s=="string"?s:s.source;return r=r.replace(_o.caret,"$1"),t=t.replace(n,r),i},getRegex:()=>new RegExp(t,e)};return i}var $q=((o="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+o)}catch{return!1}})(),_o={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:o=>new RegExp(`^( {0,3}${o})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:gh(o=>new RegExp(`^ {0,${o}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:gh(o=>new RegExp(`^ {0,${o}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:gh(o=>new RegExp(`^ {0,${o}}(?:\`\`\`|~~~)`)),headingBeginRegex:gh(o=>new RegExp(`^ {0,${o}}#`)),htmlBeginRegex:gh(o=>new RegExp(`^ {0,${o}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:gh(o=>new RegExp(`^ {0,${o}}>`))},Uq=/^(?:[ \t]*(?:\n|$))+/,qq=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Gq=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,O_=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Kq=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ak=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,pA=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_A=Hn(pA).replace(/bull/g,Ak).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Zq=Hn(pA).replace(/bull/g,Ak).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ok=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Yq=/^[^\n]+/,Fk=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Xq=Hn(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Fk).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qq=Hn(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ak).getRegex(),uw="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Hk=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Jq=Hn("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Hk).replace("tag",uw).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),mA=Hn(Ok).replace("hr",O_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",uw).getRegex(),e9=Hn(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",mA).getRegex(),Wk={blockquote:e9,code:qq,def:Xq,fences:Gq,heading:Kq,hr:O_,html:Jq,lheading:_A,list:Qq,newline:Uq,paragraph:mA,table:ad,text:Yq},YE=Hn("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",O_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",uw).getRegex(),t9={...Wk,lheading:Zq,table:YE,paragraph:Hn(Ok).replace("hr",O_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",YE).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",uw).getRegex()},i9={...Wk,html:Hn(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Hk).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ad,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Hn(Ok).replace("hr",O_).replace("heading",` *#{1,6} *[^
82
- ]`).replace("lheading",_A).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},n9=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,s9=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,vA=/^( {2,}|\\)\n(?!\s*$)/,o9=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,eg=/[\p{P}\p{S}]/u,hw=/[\s\p{P}\p{S}]/u,Bk=/[^\s\p{P}\p{S}]/u,r9=Hn(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,hw).getRegex(),bA=/(?!~)[\p{P}\p{S}]/u,a9=/(?!~)[\s\p{P}\p{S}]/u,l9=/(?:[^\s\p{P}\p{S}]|~)/u,c9=Hn(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",$q?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),yA=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,d9=Hn(yA,"u").replace(/punct/g,eg).getRegex(),u9=Hn(yA,"u").replace(/punct/g,bA).getRegex(),wA="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",h9=Hn(wA,"gu").replace(/notPunctSpace/g,Bk).replace(/punctSpace/g,hw).replace(/punct/g,eg).getRegex(),f9=Hn(wA,"gu").replace(/notPunctSpace/g,l9).replace(/punctSpace/g,a9).replace(/punct/g,bA).getRegex(),g9=Hn("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Bk).replace(/punctSpace/g,hw).replace(/punct/g,eg).getRegex(),p9=Hn(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,eg).getRegex(),_9="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",m9=Hn(_9,"gu").replace(/notPunctSpace/g,Bk).replace(/punctSpace/g,hw).replace(/punct/g,eg).getRegex(),v9=Hn(/\\(punct)/,"gu").replace(/punct/g,eg).getRegex(),b9=Hn(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),y9=Hn(Hk).replace("(?:-->|$)","-->").getRegex(),w9=Hn("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",y9).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yb=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,S9=Hn(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",yb).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),SA=Hn(/^!?\[(label)\]\[(ref)\]/).replace("label",yb).replace("ref",Fk).getRegex(),CA=Hn(/^!?\[(ref)\](?:\[\])?/).replace("ref",Fk).getRegex(),C9=Hn("reflink|nolink(?!\\()","g").replace("reflink",SA).replace("nolink",CA).getRegex(),XE=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,zk={_backpedal:ad,anyPunctuation:v9,autolink:b9,blockSkip:c9,br:vA,code:s9,del:ad,delLDelim:ad,delRDelim:ad,emStrongLDelim:d9,emStrongRDelimAst:h9,emStrongRDelimUnd:g9,escape:n9,link:S9,nolink:CA,punctuation:r9,reflink:SA,reflinkSearch:C9,tag:w9,text:o9,url:ad},x9={...zk,link:Hn(/^!?\[(label)\]\((.*?)\)/).replace("label",yb).getRegex(),reflink:Hn(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yb).getRegex()},Bx={...zk,emStrongRDelimAst:f9,emStrongLDelim:u9,delLDelim:p9,delRDelim:m9,url:Hn(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",XE).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Hn(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",XE).getRegex()},k9={...Bx,br:Hn(vA).replace("{2,}","*").getRegex(),text:Hn(Bx.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},km={normal:Wk,gfm:t9,pedantic:i9},Sg={normal:zk,gfm:Bx,breaks:k9,pedantic:x9},L9={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},QE=o=>L9[o];function Sa(o,e){if(e){if(_o.escapeTest.test(o))return o.replace(_o.escapeReplace,QE)}else if(_o.escapeTestNoEncode.test(o))return o.replace(_o.escapeReplaceNoEncode,QE);return o}function JE(o){try{o=encodeURI(o).replace(_o.percentDecode,"%")}catch{return null}return o}function eD(o,e){var s;let t=o.replace(_o.findPipe,(r,a,d)=>{let u=!1,f=a;for(;--f>=0&&d[f]==="\\";)u=!u;return u?"|":" |"}),i=t.split(_o.splitPipe),n=0;if(i[0].trim()||i.shift(),i.length>0&&!((s=i.at(-1))!=null&&s.trim())&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(_o.slashPipe,"|");return i}function Gl(o,e,t){let i=o.length;if(i===0)return"";let n=0;for(;n<i&&o.charAt(i-n-1)===e;)n++;return o.slice(0,i-n)}function tD(o){let e=o.split(`
83
- `),t=e.length-1;for(;t>=0&&_o.blankLine.test(e[t]);)t--;return e.length-t<=2?o:e.slice(0,t+1).join(`
84
- `)}function I9(o,e){if(o.indexOf(e[1])===-1)return-1;let t=0;for(let i=0;i<o.length;i++)if(o[i]==="\\")i++;else if(o[i]===e[0])t++;else if(o[i]===e[1]&&(t--,t<0))return i;return t>0?-2:-1}function E9(o,e=0){let t=e,i="";for(let n of o)if(n===" "){let s=4-t%4;i+=" ".repeat(s),t+=s}else i+=n,t++;return i}function iD(o,e,t,i,n){let s=e.href,r=e.title||null,a=o[1].replace(n.other.outputLinkReplace,"$1");i.state.inLink=!0;let d={type:o[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:r,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,d}function D9(o,e,t){let i=o.match(t.other.indentCodeCompensation);if(i===null)return e;let n=i[1];return e.split(`
85
- `).map(s=>{let r=s.match(t.other.beginningSpace);if(r===null)return s;let[a]=r;return a.length>=n.length?s.slice(n.length):s}).join(`
86
- `)}var wb=class{constructor(o){yn(this,"options");yn(this,"rules");yn(this,"lexer");this.options=o||Gu}space(o){let e=this.rules.block.newline.exec(o);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(o){let e=this.rules.block.code.exec(o);if(e){let t=this.options.pedantic?e[0]:tD(e[0]),i=t.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t,codeBlockStyle:"indented",text:i}}}fences(o){let e=this.rules.block.fences.exec(o);if(e){let t=e[0],i=D9(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:i}}}heading(o){let e=this.rules.block.heading.exec(o);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let i=Gl(t,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(t=i.trim())}return{type:"heading",raw:Gl(e[0],`
87
- `),depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(o){let e=this.rules.block.hr.exec(o);if(e)return{type:"hr",raw:Gl(e[0],`
88
- `)}}blockquote(o){let e=this.rules.block.blockquote.exec(o);if(e){let t=Gl(e[0],`
89
- `).split(`
90
- `),i="",n="",s=[];for(;t.length>0;){let r=!1,a=[],d;for(d=0;d<t.length;d++)if(this.rules.other.blockquoteStart.test(t[d]))a.push(t[d]),r=!0;else if(!r)a.push(t[d]);else break;t=t.slice(d);let u=a.join(`
91
- `),f=u.replace(this.rules.other.blockquoteSetextReplace,`
92
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
93
- ${u}`:u,n=n?`${n}
94
- ${f}`:f;let g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,s,!0),this.lexer.state.top=g,t.length===0)break;let p=s.at(-1);if((p==null?void 0:p.type)==="code")break;if((p==null?void 0:p.type)==="blockquote"){let w=p,y=w.raw+`
95
- `+t.join(`
96
- `),x=this.blockquote(y);s[s.length-1]=x,i=i.substring(0,i.length-w.raw.length)+x.raw,n=n.substring(0,n.length-w.text.length)+x.text;break}else if((p==null?void 0:p.type)==="list"){let w=p,y=w.raw+`
97
- `+t.join(`
98
- `),x=this.list(y);s[s.length-1]=x,i=i.substring(0,i.length-p.raw.length)+x.raw,n=n.substring(0,n.length-w.raw.length)+x.raw,t=y.substring(s.at(-1).raw.length).split(`
99
- `);continue}}return{type:"blockquote",raw:i,tokens:s,text:n}}}list(o){let e=this.rules.block.list.exec(o);if(e){let t=e[1].trim(),i=t.length>1,n={type:"list",raw:"",ordered:i,start:i?+t.slice(0,-1):"",loose:!1,items:[]};t=i?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=i?t:"[*+-]");let s=this.rules.other.listItemRegex(t),r=!1;for(;o;){let d=!1,u="",f="";if(!(e=s.exec(o))||this.rules.block.hr.test(o))break;u=e[0],o=o.substring(u.length);let g=E9(e[2].split(`
100
- `,1)[0],e[1].length),p=o.split(`
101
- `,1)[0],w=!g.trim(),y=0;if(this.options.pedantic?(y=2,f=g.trimStart()):w?y=e[1].length+1:(y=g.search(this.rules.other.nonSpaceChar),y=y>4?1:y,f=g.slice(y),y+=e[1].length),w&&this.rules.other.blankLine.test(p)&&(u+=p+`
102
- `,o=o.substring(p.length+1),d=!0),!d){let x=this.rules.other.nextBulletRegex(y),k=this.rules.other.hrRegex(y),D=this.rules.other.fencesBeginRegex(y),M=this.rules.other.headingBeginRegex(y),F=this.rules.other.htmlBeginRegex(y),K=this.rules.other.blockquoteBeginRegex(y);for(;o;){let V=o.split(`
103
- `,1)[0],se;if(p=V,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),se=p):se=p.replace(this.rules.other.tabCharGlobal," "),D.test(p)||M.test(p)||F.test(p)||K.test(p)||x.test(p)||k.test(p))break;if(se.search(this.rules.other.nonSpaceChar)>=y||!p.trim())f+=`
104
- `+se.slice(y);else{if(w||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||D.test(g)||M.test(g)||k.test(g))break;f+=`
105
- `+p}w=!p.trim(),u+=V+`
106
- `,o=o.substring(V.length+1),g=se.slice(y)}}n.loose||(r?n.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(r=!0)),n.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(f),loose:!1,text:f,tokens:[]}),n.raw+=u}let a=n.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let d of n.items){this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]);let u=d.tokens[0];if(d.task&&((u==null?void 0:u.type)==="text"||(u==null?void 0:u.type)==="paragraph")){d.text=d.text.replace(this.rules.other.listReplaceTask,""),u.raw=u.raw.replace(this.rules.other.listReplaceTask,""),u.text=u.text.replace(this.rules.other.listReplaceTask,"");for(let g=this.lexer.inlineQueue.length-1;g>=0;g--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[g].src)){this.lexer.inlineQueue[g].src=this.lexer.inlineQueue[g].src.replace(this.rules.other.listReplaceTask,"");break}let f=this.rules.other.listTaskCheckbox.exec(d.raw);if(f){let g={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};d.checked=g.checked,n.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=g.raw+d.tokens[0].raw,d.tokens[0].text=g.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(g)):d.tokens.unshift({type:"paragraph",raw:g.raw,text:g.raw,tokens:[g]}):d.tokens.unshift(g)}}else d.task&&(d.task=!1);if(!n.loose){let f=d.tokens.filter(p=>p.type==="space"),g=f.length>0&&f.some(p=>this.rules.other.anyLine.test(p.raw));n.loose=g}}if(n.loose)for(let d of n.items){d.loose=!0;for(let u of d.tokens)u.type==="text"&&(u.type="paragraph")}return n}}html(o){let e=this.rules.block.html.exec(o);if(e){let t=tD(e[0]);return{type:"html",block:!0,raw:t,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:t}}}def(o){let e=this.rules.block.def.exec(o);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:Gl(e[0],`
107
- `),href:i,title:n}}}table(o){var r;let e=this.rules.block.table.exec(o);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=eD(e[1]),i=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=(r=e[3])!=null&&r.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
108
- `):[],s={type:"table",raw:Gl(e[0],`
109
- `),header:[],align:[],rows:[]};if(t.length===i.length){for(let a of i)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<t.length;a++)s.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:s.align[a]});for(let a of n)s.rows.push(eD(a,s.header.length).map((d,u)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:s.align[u]})));return s}}lheading(o){let e=this.rules.block.lheading.exec(o);if(e){let t=e[1].trim();return{type:"heading",raw:Gl(e[0],`
110
- `),depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(o){let e=this.rules.block.paragraph.exec(o);if(e){let t=e[1].charAt(e[1].length-1)===`
111
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(o){let e=this.rules.block.text.exec(o);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(o){let e=this.rules.inline.escape.exec(o);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(o){let e=this.rules.inline.tag.exec(o);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(o){let e=this.rules.inline.link.exec(o);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let s=Gl(t.slice(0,-1),"\\");if((t.length-s.length)%2===0)return}else{let s=I9(e[2],"()");if(s===-2)return;if(s>-1){let r=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,r).trim(),e[3]=""}}let i=e[2],n="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(i);s&&(i=s[1],n=s[3])}else n=e[3]?e[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?i=i.slice(1):i=i.slice(1,-1)),iD(e,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(o,e){let t;if((t=this.rules.inline.reflink.exec(o))||(t=this.rules.inline.nolink.exec(o))){let i=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[i.toLowerCase()];if(!n){let s=t[0].charAt(0);return{type:"text",raw:s,text:s}}return iD(t,n,t[0],this.lexer,this.rules)}}emStrong(o,e,t=""){let i=this.rules.inline.emStrongLDelim.exec(o);if(!(!i||!i[1]&&!i[2]&&!i[3]&&!i[4]||i[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[3])||!t||this.rules.inline.punctuation.exec(t))){let n=[...i[0]].length-1,s,r,a=n,d=0,u=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*o.length+n);(i=u.exec(e))!==null;){if(s=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!s)continue;if(r=[...s].length,i[3]||i[4]){a+=r;continue}else if((i[5]||i[6])&&n%3&&!((n+r)%3)){d+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+d);let f=[...i[0]][0].length,g=o.slice(0,n+i.index+f+r);if(Math.min(n,r)%2){let w=g.slice(1,-1);return{type:"em",raw:g,text:w,tokens:this.lexer.inlineTokens(w)}}let p=g.slice(2,-2);return{type:"strong",raw:g,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(o){let e=this.rules.inline.code.exec(o);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(t),n=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return i&&n&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(o){let e=this.rules.inline.br.exec(o);if(e)return{type:"br",raw:e[0]}}del(o,e,t=""){let i=this.rules.inline.delLDelim.exec(o);if(i&&(!i[1]||!t||this.rules.inline.punctuation.exec(t))){let n=[...i[0]].length-1,s,r,a=n,d=this.rules.inline.delRDelim;for(d.lastIndex=0,e=e.slice(-1*o.length+n);(i=d.exec(e))!==null;){if(s=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!s||(r=[...s].length,r!==n))continue;if(i[3]||i[4]){a+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a);let u=[...i[0]][0].length,f=o.slice(0,n+i.index+u+r),g=f.slice(n,-n);return{type:"del",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}autolink(o){let e=this.rules.inline.autolink.exec(o);if(e){let t,i;return e[2]==="@"?(t=e[1],i="mailto:"+t):(t=e[1],i=t),{type:"link",raw:e[0],text:t,href:i,tokens:[{type:"text",raw:t,text:t}]}}}url(o){var t;let e;if(e=this.rules.inline.url.exec(o)){let i,n;if(e[2]==="@")i=e[0],n="mailto:"+i;else{let s;do s=e[0],e[0]=((t=this.rules.inline._backpedal.exec(e[0]))==null?void 0:t[0])??"";while(s!==e[0]);i=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:i,href:n,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(o){let e=this.rules.inline.text.exec(o);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},ea=class zx{constructor(e){yn(this,"tokens");yn(this,"options");yn(this,"state");yn(this,"inlineQueue");yn(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Gu,this.options.tokenizer=this.options.tokenizer||new wb,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:_o,block:km.normal,inline:Sg.normal};this.options.pedantic?(t.block=km.pedantic,t.inline=Sg.pedantic):this.options.gfm&&(t.block=km.gfm,this.options.breaks?t.inline=Sg.breaks:t.inline=Sg.gfm),this.tokenizer.rules=t}static get rules(){return{block:km,inline:Sg}}static lex(e,t){return new zx(t).lex(e)}static lexInline(e,t){return new zx(t).inlineTokens(e)}lex(e){e=e.replace(_o.carriageReturn,`
112
- `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let i=this.inlineQueue[t];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],i=!1){var s,r,a;this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(_o.tabCharGlobal," ").replace(_o.spaceLine,""));let n=1/0;for(;e;){if(e.length<n)n=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let d;if((r=(s=this.options.extensions)==null?void 0:s.block)!=null&&r.some(f=>(d=f.call({lexer:this},e,t))?(e=e.substring(d.raw.length),t.push(d),!0):!1))continue;if(d=this.tokenizer.space(e)){e=e.substring(d.raw.length);let f=t.at(-1);d.raw.length===1&&f!==void 0?f.raw+=`
113
- `:t.push(d);continue}if(d=this.tokenizer.code(e)){e=e.substring(d.raw.length);let f=t.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
114
- `)?"":`
115
- `)+d.raw,f.text+=`
116
- `+d.text,this.inlineQueue.at(-1).src=f.text):t.push(d);continue}if(d=this.tokenizer.fences(e)){e=e.substring(d.raw.length),t.push(d);continue}if(d=this.tokenizer.heading(e)){e=e.substring(d.raw.length),t.push(d);continue}if(d=this.tokenizer.hr(e)){e=e.substring(d.raw.length),t.push(d);continue}if(d=this.tokenizer.blockquote(e)){e=e.substring(d.raw.length),t.push(d);continue}if(d=this.tokenizer.list(e)){e=e.substring(d.raw.length),t.push(d);continue}if(d=this.tokenizer.html(e)){e=e.substring(d.raw.length),t.push(d);continue}if(d=this.tokenizer.def(e)){e=e.substring(d.raw.length);let f=t.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
117
- `)?"":`
118
- `)+d.raw,f.text+=`
119
- `+d.raw,this.inlineQueue.at(-1).src=f.text):this.tokens.links[d.tag]||(this.tokens.links[d.tag]={href:d.href,title:d.title},t.push(d));continue}if(d=this.tokenizer.table(e)){e=e.substring(d.raw.length),t.push(d);continue}if(d=this.tokenizer.lheading(e)){e=e.substring(d.raw.length),t.push(d);continue}let u=e;if((a=this.options.extensions)!=null&&a.startBlock){let f=1/0,g=e.slice(1),p;this.options.extensions.startBlock.forEach(w=>{p=w.call({lexer:this},g),typeof p=="number"&&p>=0&&(f=Math.min(f,p))}),f<1/0&&f>=0&&(u=e.substring(0,f+1))}if(this.state.top&&(d=this.tokenizer.paragraph(u))){let f=t.at(-1);i&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=(f.raw.endsWith(`
120
- `)?"":`
121
- `)+d.raw,f.text+=`
122
- `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):t.push(d),i=u.length!==e.length,e=e.substring(d.raw.length);continue}if(d=this.tokenizer.text(e)){e=e.substring(d.raw.length);let f=t.at(-1);(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
123
- `)?"":`
124
- `)+d.raw,f.text+=`
125
- `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):t.push(d);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var u,f,g,p,w;this.tokenizer.lexer=this;let i=e,n=null;if(this.tokens.links){let y=Object.keys(this.tokens.links);if(y.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(i))!==null;)y.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(i))!==null;)i=i.slice(0,n.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(n=this.tokenizer.rules.inline.blockSkip.exec(i))!==null;)s=n[2]?n[2].length:0,i=i.slice(0,n.index+s)+"["+"a".repeat(n[0].length-s-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((f=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:f.call({lexer:this},i))??i;let r=!1,a="",d=1/0;for(;e;){if(e.length<d)d=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(a=""),r=!1;let y;if((p=(g=this.options.extensions)==null?void 0:g.inline)!=null&&p.some(k=>(y=k.call({lexer:this},e,t))?(e=e.substring(y.raw.length),t.push(y),!0):!1))continue;if(y=this.tokenizer.escape(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.tag(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.link(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(y.raw.length);let k=t.at(-1);y.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(y=this.tokenizer.emStrong(e,i,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.codespan(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.br(e)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.del(e,i,a)){e=e.substring(y.raw.length),t.push(y);continue}if(y=this.tokenizer.autolink(e)){e=e.substring(y.raw.length),t.push(y);continue}if(!this.state.inLink&&(y=this.tokenizer.url(e))){e=e.substring(y.raw.length),t.push(y);continue}let x=e;if((w=this.options.extensions)!=null&&w.startInline){let k=1/0,D=e.slice(1),M;this.options.extensions.startInline.forEach(F=>{M=F.call({lexer:this},D),typeof M=="number"&&M>=0&&(k=Math.min(k,M))}),k<1/0&&k>=0&&(x=e.substring(0,k+1))}if(y=this.tokenizer.inlineText(x)){e=e.substring(y.raw.length),y.raw.slice(-1)!=="_"&&(a=y.raw.slice(-1)),r=!0;let k=t.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=y.raw,k.text+=y.text):t.push(y);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(this.options.silent)console.error(t);else throw new Error(t)}},Sb=class{constructor(o){yn(this,"options");yn(this,"parser");this.options=o||Gu}space(o){return""}code({text:o,lang:e,escaped:t}){var s;let i=(s=(e||"").match(_o.notSpaceStart))==null?void 0:s[0],n=o.replace(_o.endingNewline,"")+`
126
- `;return i?'<pre><code class="language-'+Sa(i)+'">'+(t?n:Sa(n,!0))+`</code></pre>
127
- `:"<pre><code>"+(t?n:Sa(n,!0))+`</code></pre>
128
- `}blockquote({tokens:o}){return`<blockquote>
129
- ${this.parser.parse(o)}</blockquote>
130
- `}html({text:o}){return o}def(o){return""}heading({tokens:o,depth:e}){return`<h${e}>${this.parser.parseInline(o)}</h${e}>
131
- `}hr(o){return`<hr>
132
- `}list(o){let e=o.ordered,t=o.start,i="";for(let r=0;r<o.items.length;r++){let a=o.items[r];i+=this.listitem(a)}let n=e?"ol":"ul",s=e&&t!==1?' start="'+t+'"':"";return"<"+n+s+`>
133
- `+i+"</"+n+`>
134
- `}listitem(o){return`<li>${this.parser.parse(o.tokens)}</li>
135
- `}checkbox({checked:o}){return"<input "+(o?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:o}){return`<p>${this.parser.parseInline(o)}</p>
136
- `}table(o){let e="",t="";for(let n=0;n<o.header.length;n++)t+=this.tablecell(o.header[n]);e+=this.tablerow({text:t});let i="";for(let n=0;n<o.rows.length;n++){let s=o.rows[n];t="";for(let r=0;r<s.length;r++)t+=this.tablecell(s[r]);i+=this.tablerow({text:t})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
137
- <thead>
138
- `+e+`</thead>
139
- `+i+`</table>
140
- `}tablerow({text:o}){return`<tr>
141
- ${o}</tr>
142
- `}tablecell(o){let e=this.parser.parseInline(o.tokens),t=o.header?"th":"td";return(o.align?`<${t} align="${o.align}">`:`<${t}>`)+e+`</${t}>
143
- `}strong({tokens:o}){return`<strong>${this.parser.parseInline(o)}</strong>`}em({tokens:o}){return`<em>${this.parser.parseInline(o)}</em>`}codespan({text:o}){return`<code>${Sa(o,!0)}</code>`}br(o){return"<br>"}del({tokens:o}){return`<del>${this.parser.parseInline(o)}</del>`}link({href:o,title:e,tokens:t}){let i=this.parser.parseInline(t),n=JE(o);if(n===null)return i;o=n;let s='<a href="'+o+'"';return e&&(s+=' title="'+Sa(e)+'"'),s+=">"+i+"</a>",s}image({href:o,title:e,text:t,tokens:i}){i&&(t=this.parser.parseInline(i,this.parser.textRenderer));let n=JE(o);if(n===null)return Sa(t);o=n;let s=`<img src="${o}" alt="${Sa(t)}"`;return e&&(s+=` title="${Sa(e)}"`),s+=">",s}text(o){return"tokens"in o&&o.tokens?this.parser.parseInline(o.tokens):"escaped"in o&&o.escaped?o.text:Sa(o.text)}},Vk=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ta=class Vx{constructor(e){yn(this,"options");yn(this,"renderer");yn(this,"textRenderer");this.options=e||Gu,this.options.renderer=this.options.renderer||new Sb,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Vk}static parse(e,t){return new Vx(t).parse(e)}static parseInline(e,t){return new Vx(t).parseInline(e)}parse(e){var i,n;this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let r=e[s];if((n=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&n[r.type]){let d=r,u=this.options.extensions.renderers[d.type].call({parser:this},d);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(d.type)){t+=u||"";continue}}let a=r;switch(a.type){case"space":{t+=this.renderer.space(a);break}case"hr":{t+=this.renderer.hr(a);break}case"heading":{t+=this.renderer.heading(a);break}case"code":{t+=this.renderer.code(a);break}case"table":{t+=this.renderer.table(a);break}case"blockquote":{t+=this.renderer.blockquote(a);break}case"list":{t+=this.renderer.list(a);break}case"checkbox":{t+=this.renderer.checkbox(a);break}case"html":{t+=this.renderer.html(a);break}case"def":{t+=this.renderer.def(a);break}case"paragraph":{t+=this.renderer.paragraph(a);break}case"text":{t+=this.renderer.text(a);break}default:{let d='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return t}parseInline(e,t=this.renderer){var n,s;this.renderer.parser=this;let i="";for(let r=0;r<e.length;r++){let a=e[r];if((s=(n=this.options.extensions)==null?void 0:n.renderers)!=null&&s[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){i+=u||"";continue}}let d=a;switch(d.type){case"escape":{i+=t.text(d);break}case"html":{i+=t.html(d);break}case"link":{i+=t.link(d);break}case"image":{i+=t.image(d);break}case"checkbox":{i+=t.checkbox(d);break}case"strong":{i+=t.strong(d);break}case"em":{i+=t.em(d);break}case"codespan":{i+=t.codespan(d);break}case"br":{i+=t.br(d);break}case"del":{i+=t.del(d);break}case"text":{i+=t.text(d);break}default:{let u='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return i}},Em,Bg=(Em=class{constructor(o){yn(this,"options");yn(this,"block");this.options=o||Gu}preprocess(o){return o}postprocess(o){return o}processAllTokens(o){return o}emStrongMask(o){return o}provideLexer(o=this.block){return o?ea.lex:ea.lexInline}provideParser(o=this.block){return o?ta.parse:ta.parseInline}},yn(Em,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),yn(Em,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Em),T9=class{constructor(...o){yn(this,"defaults",Nk());yn(this,"options",this.setOptions);yn(this,"parse",this.parseMarkdown(!0));yn(this,"parseInline",this.parseMarkdown(!1));yn(this,"Parser",ta);yn(this,"Renderer",Sb);yn(this,"TextRenderer",Vk);yn(this,"Lexer",ea);yn(this,"Tokenizer",wb);yn(this,"Hooks",Bg);this.use(...o)}walkTokens(o,e){var i,n;let t=[];for(let s of o)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let r=s;for(let a of r.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of r.rows)for(let d of a)t=t.concat(this.walkTokens(d.tokens,e));break}case"list":{let r=s;t=t.concat(this.walkTokens(r.items,e));break}default:{let r=s;(n=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&n[r.type]?this.defaults.extensions.childTokens[r.type].forEach(a=>{let d=r[a].flat(1/0);t=t.concat(this.walkTokens(d,e))}):r.tokens&&(t=t.concat(this.walkTokens(r.tokens,e)))}}return t}use(...o){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return o.forEach(t=>{let i={...t};if(i.async=this.defaults.async||i.async||!1,t.extensions&&(t.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let s=e.renderers[n.name];s?e.renderers[n.name]=function(...r){let a=n.renderer.apply(this,r);return a===!1&&(a=s.apply(this,r)),a}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[n.level];s?s.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),i.extensions=e),t.renderer){let n=this.defaults.renderer||new Sb(this.defaults);for(let s in t.renderer){if(!(s in n))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let r=s,a=t.renderer[r],d=n[r];n[r]=(...u)=>{let f=a.apply(n,u);return f===!1&&(f=d.apply(n,u)),f||""}}i.renderer=n}if(t.tokenizer){let n=this.defaults.tokenizer||new wb(this.defaults);for(let s in t.tokenizer){if(!(s in n))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let r=s,a=t.tokenizer[r],d=n[r];n[r]=(...u)=>{let f=a.apply(n,u);return f===!1&&(f=d.apply(n,u)),f}}i.tokenizer=n}if(t.hooks){let n=this.defaults.hooks||new Bg;for(let s in t.hooks){if(!(s in n))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let r=s,a=t.hooks[r],d=n[r];Bg.passThroughHooks.has(s)?n[r]=u=>{if(this.defaults.async&&Bg.passThroughHooksRespectAsync.has(s))return(async()=>{let g=await a.call(n,u);return d.call(n,g)})();let f=a.call(n,u);return d.call(n,f)}:n[r]=(...u)=>{if(this.defaults.async)return(async()=>{let g=await a.apply(n,u);return g===!1&&(g=await d.apply(n,u)),g})();let f=a.apply(n,u);return f===!1&&(f=d.apply(n,u)),f}}i.hooks=n}if(t.walkTokens){let n=this.defaults.walkTokens,s=t.walkTokens;i.walkTokens=function(r){let a=[];return a.push(s.call(this,r)),n&&(a=a.concat(n.call(this,r))),a}}this.defaults={...this.defaults,...i}}),this}setOptions(o){return this.defaults={...this.defaults,...o},this}lexer(o,e){return ea.lex(o,e??this.defaults)}parser(o,e){return ta.parse(o,e??this.defaults)}parseMarkdown(o){return(e,t)=>{let i={...t},n={...this.defaults,...i},s=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&i.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=o),n.async)return(async()=>{let r=n.hooks?await n.hooks.preprocess(e):e,a=await(n.hooks?await n.hooks.provideLexer(o):o?ea.lex:ea.lexInline)(r,n),d=n.hooks?await n.hooks.processAllTokens(a):a;n.walkTokens&&await Promise.all(this.walkTokens(d,n.walkTokens));let u=await(n.hooks?await n.hooks.provideParser(o):o?ta.parse:ta.parseInline)(d,n);return n.hooks?await n.hooks.postprocess(u):u})().catch(s);try{n.hooks&&(e=n.hooks.preprocess(e));let r=(n.hooks?n.hooks.provideLexer(o):o?ea.lex:ea.lexInline)(e,n);n.hooks&&(r=n.hooks.processAllTokens(r)),n.walkTokens&&this.walkTokens(r,n.walkTokens);let a=(n.hooks?n.hooks.provideParser(o):o?ta.parse:ta.parseInline)(r,n);return n.hooks&&(a=n.hooks.postprocess(a)),a}catch(r){return s(r)}}}onError(o,e){return t=>{if(t.message+=`
144
- Please report this to https://github.com/markedjs/marked.`,o){let i="<p>An error occurred:</p><pre>"+Sa(t.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(t);throw t}}},Au=new T9;function qn(o,e){return Au.parse(o,e)}qn.options=qn.setOptions=function(o){return Au.setOptions(o),qn.defaults=Au.defaults,gA(qn.defaults),qn};qn.getDefaults=Nk;qn.defaults=Gu;qn.use=function(...o){return Au.use(...o),qn.defaults=Au.defaults,gA(qn.defaults),qn};qn.walkTokens=function(o,e){return Au.walkTokens(o,e)};qn.parseInline=Au.parseInline;qn.Parser=ta;qn.parser=ta.parse;qn.Renderer=Sb;qn.TextRenderer=Vk;qn.Lexer=ea;qn.lexer=ea.lex;qn.Tokenizer=wb;qn.Hooks=Bg;qn.parse=qn;qn.options;qn.setOptions;qn.use;qn.walkTokens;qn.parseInline;ta.parse;ea.lex;var P9=T('<span class="chat-model svelte-10ayso4"><!></span>'),M9=T('<button class="clear-btn svelte-10ayso4" title="New conversation">+</button>'),R9=T('<p class="history-empty svelte-10ayso4">No saved conversations.</p>'),N9=T('<li><button class="history-load svelte-10ayso4"> </button> <button class="history-del svelte-10ayso4" title="Delete">✕</button></li>'),A9=T('<ul class="history-list svelte-10ayso4"></ul>'),O9=T('<div class="history-panel svelte-10ayso4"><div class="history-hdr svelte-10ayso4"><span class="svelte-10ayso4">Conversations</span> <button class="new-conv-btn svelte-10ayso4">+ New</button></div> <!></div>'),F9=T('<div class="unconfigured svelte-10ayso4">Configure an AI provider in the <strong class="svelte-10ayso4">Config</strong> tab to use the AI assistant.</div>'),H9=T('Chatting in context of <code class="svelte-10ayso4"> </code>',1),W9=T('<button class="chip svelte-10ayso4"> </button>'),B9=T('<div class="suggestions svelte-10ayso4"><p class="suggestions-hint svelte-10ayso4"><!></p> <!></div>'),z9=T('<div class="msg-content user-text svelte-10ayso4"> </div>'),nD=T('<span class="tool-args svelte-10ayso4"> </span>'),sD=T('<div class="tool-event tool-call svelte-10ayso4"><span class="tool-icon svelte-10ayso4">🔧</span> <span class="tool-name svelte-10ayso4"> </span> <!></div>'),oD=T('<div class="tool-event tool-result svelte-10ayso4"><span class="tool-icon svelte-10ayso4">✓</span> <span class="tool-name svelte-10ayso4"> </span></div>'),rD=T('<div class="tool-events svelte-10ayso4"></div>'),aD=T('<div class="text-block svelte-10ayso4"></div>'),V9=T('<button class="create-btn svelte-10ayso4">Save as new file…</button>'),j9=T('<span class="auto-badge svelte-10ayso4" title="Auto-applying AI code to this script in this session">auto ✓</span>'),$9=T('<button class="apply-auto-btn svelte-10ayso4" title="Apply and always apply for this script in this session">always</button>'),U9=T('<button class="apply-btn svelte-10ayso4">Apply</button> <!>',1),q9=T('<button class="expand-btn svelte-10ayso4"> </button>'),G9=T('<div class="code-block svelte-10ayso4"><div class="code-header svelte-10ayso4"><span class="code-lang svelte-10ayso4"> </span> <div class="code-actions svelte-10ayso4"><button class="svelte-10ayso4">Copy</button> <!></div></div> <div><pre class="svelte-10ayso4"><code class="hljs svelte-10ayso4"></code></pre> <!></div></div>'),K9=T('<!> <div class="msg-content svelte-10ayso4"></div>',1),Z9=T("<div><!></div>"),Y9=T('<div class="message assistant svelte-10ayso4"><div class="msg-content svelte-10ayso4"><span class="status-shimmer svelte-10ayso4"> </span></div></div>'),X9=T('<div class="code-block svelte-10ayso4"><div class="code-header svelte-10ayso4"><span class="code-lang svelte-10ayso4"> </span></div> <pre class="svelte-10ayso4"><code class="hljs svelte-10ayso4"></code></pre></div>'),Q9=T('<div class="message assistant streaming svelte-10ayso4"><div class="msg-content svelte-10ayso4"></div></div>'),J9=T('<div class="chat-error svelte-10ayso4"> </div>'),eG=T('<span class="ctx-indicator svelte-10ayso4"><svg width="12" height="12" viewBox="0 0 12 12" class="svelte-10ayso4"><circle cx="6" cy="6" r="5" fill="none" stroke="var(--border-sub)" stroke-width="2" class="svelte-10ayso4"></circle><circle cx="6" cy="6" r="5" fill="none" stroke-width="2" stroke-dashoffset="7.85" stroke-linecap="round" class="svelte-10ayso4"></circle></svg></span>'),tG=T('<span><span> </span> <span class="chip-name svelte-10ayso4"> </span> <button class="chip-remove svelte-10ayso4"> </button></span>'),iG=T('<span class="file-chip svelte-10ayso4"><span> </span> <span class="chip-name svelte-10ayso4"> </span> <button class="chip-remove svelte-10ayso4" title="Remove from context">×</button></span>'),nG=T('<button class="stop-btn svelte-10ayso4" title="Stop generation">■</button>'),sG=T('<button class="send-btn svelte-10ayso4">↑</button>'),oG=T('<option class="svelte-10ayso4"> </option>'),rG=T('<select class="model-select svelte-10ayso4"></select>'),aG=T('<span class="model-name svelte-10ayso4"> </span>'),lG=T('<button class="info-btn svelte-10ayso4" title="Model info">ℹ</button>'),cG=T('<div class="model-bar svelte-10ayso4"><span class="model-provider svelte-10ayso4"> </span> <!> <!></div>'),dG=T('<p class="info-status svelte-10ayso4">Loading…</p>'),uG=T('<p class="info-status info-err svelte-10ayso4"> </p>'),hG=T('<dt class="svelte-10ayso4">Ollama version</dt><dd class="svelte-10ayso4"> </dd>',1),fG=T('<dt class="svelte-10ayso4">Family</dt><dd class="svelte-10ayso4"> </dd>',1),gG=T('<dt class="svelte-10ayso4">Parameters</dt><dd class="svelte-10ayso4"> </dd>',1),pG=T('<dt class="svelte-10ayso4">Quantization</dt><dd class="svelte-10ayso4"> </dd>',1),_G=T('<dt class="svelte-10ayso4">Format</dt><dd class="svelte-10ayso4"> </dd>',1),mG=T('<div class="running-model svelte-10ayso4"> </div>'),vG=T('<dt class="svelte-10ayso4">Loaded</dt> <dd class="svelte-10ayso4"></dd>',1),bG=T('<dt class="svelte-10ayso4">Loaded</dt><dd class="dim svelte-10ayso4">Not in memory</dd>',1),yG=T('<dl class="svelte-10ayso4"><!> <!> <!> <!> <!> <!></dl>'),wG=T('<div class="info-overlay svelte-10ayso4"><div class="info-popup svelte-10ayso4"><div class="info-popup-header svelte-10ayso4"><span class="svelte-10ayso4"> </span> <button title="Close" class="svelte-10ayso4">✕</button></div> <div class="info-popup-body svelte-10ayso4"><!></div></div></div>'),SG=T('<div class="chat-panel svelte-10ayso4"><div class="chat-header svelte-10ayso4"><span class="chat-title svelte-10ayso4">AI Assistant</span> <!> <button title="Conversation history"><svg width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" class="svelte-10ayso4"><circle cx="8" cy="8" r="6" class="svelte-10ayso4"></circle><polyline points="8,5 8,8 10,10" class="svelte-10ayso4"></polyline></svg></button> <!></div> <!> <div class="messages svelte-10ayso4"><!> <!> <!> <!> <!></div> <!> <div class="context-row svelte-10ayso4"><label title="Include she API reference in context" class="svelte-10ayso4"><input type="checkbox" class="svelte-10ayso4"/><span class="checkmark svelte-10ayso4"></span> she API</label> <label title="Let the AI query MQTT state, sheDB documents and Matter devices on demand. Disables real-time streaming." class="svelte-10ayso4"><input type="checkbox" class="svelte-10ayso4"/><span class="checkmark svelte-10ayso4"></span> 😎 Agent</label> <span class="req-size svelte-10ayso4"> <!></span></div> <div class="files-row svelte-10ayso4"><!> <!> <button class="add-file-btn svelte-10ayso4" title="Attach file to context">+</button> <input type="file" multiple="" class="file-input-hidden svelte-10ayso4"/></div> <div><div><textarea rows="3" class="svelte-10ayso4"></textarea></div> <!></div> <!></div> <!>',1);function CG(o,e){Ts(e,!0),bb.registerLanguage("javascript",fA),qn.use({breaks:!0,gfm:!0});let t=Su(e,"currentScript",3,null),i=Su(e,"extraFiles",31,()=>yi([])),n=P(yi([])),s=P(null),r=P(""),a=P(!1),d=P(""),u=P(null);const f="she:conversationId";function g(){return crypto.randomUUID().replace(/-/g,"").slice(0,16)}let p=P(yi(localStorage.getItem(f)??g())),w=P(yi([])),y=P(!1);Vn(()=>{localStorage.setItem(f,c(p))});let x=P(yi([])),k=P(yi(localStorage.getItem("she:selectedModel")??"")),D=P(null);const M=Ct(()=>{var U;return c(D)!==null&&((U=t())==null?void 0:U.path)===c(D)});let F=P(yi(new Set)),K=P(!1),V=P(null),se=P(!1),te=P(""),pe=P(0),je=null,Ke=P(0);const ue=["[core] reticulating splines…","[io] calibrating the flux capacitor…","[net] pinging the oracle (no response)…","[gpu] overclocking the neurons…","[fs] loading sarcasm module v4.2…","[mem] defragmenting the embedding space…","[sched] running gradient descent into madness…","[net] synchronizing with the hive mind…","[model] tickling the transformer…","[io] consulting rubber duck debugger…","[core] solving P=NP as a warmup…","[gpu] burning GPU cycles for warmth…","[mem] compressing knowledge into tensors…","[net] asking my inner voice (busy)…","[fs] mining opinions from the void…","[core] summoning attention heads…","[io] tokenizing the vibes…","[sched] hallucinating thoughtfully…","[net] traversing the knowledge graph…","[model] manifesting an answer…"];let He=P(!0),dt=P(!0),we=P(!0),gt=P(!1),ot,Pt=P(yi([])),Oe,Mt;const et=Ct(()=>({apiref:c(He),tools:c(dt)})),ct=Ct(()=>{var U;return((U=c(u))==null?void 0:U.configured)??!1}),Nt=Ct(()=>{var U;return c(ct)||!!((U=c(u))!=null&&U.provider)&&!!c(k)}),ti=Ct(()=>c(pe)+new TextEncoder().encode(c(r)).length),ri=Ct(()=>c(we)?t():null);Vn(()=>{var ne;const U=(ne=t())==null?void 0:ne.path;v(we,!0),c(D)!==null&&U!==c(D)&&v(D,null)}),Vn(()=>{var Ve;if(!c(M))return;const U=c(n).at(-1);if(!U||U.role!=="assistant")return;const Le=Me(U.content).find(De=>De.type==="code"&&ci(De.lang));if(Le){const De=Bt(Le.text);(Ve=e.onApply)==null||Ve.call(e,De?De.code:Le.text)}});async function Vt(){try{const U=await XN();v(u,U,!0),U.configured&&!c(k)&&v(k,U.model,!0)}catch{}}Vn(()=>(window.addEventListener("she:config-changed",Vt),()=>window.removeEventListener("she:config-changed",Vt))),Vn(()=>{c(k)&&localStorage.setItem("she:selectedModel",c(k))}),Vn(()=>{var U;(U=c(u))!=null&&U.provider&&QN().then(ne=>{v(x,ne.models,!0),!c(k)&&ne.models.length>0&&v(k,ne.models[0],!0)}).catch(()=>{})}),Vn(()=>{c(k),v(V,null),v(te,"")}),Vn(()=>{var ne,Le;if(((ne=c(u))==null?void 0:ne.provider)!=="ollama")return;const U=c(k)||((Le=c(u))==null?void 0:Le.model);!U||c(V)||Hx(U).then(Ve=>{v(V,Ve,!0)}).catch(()=>{})}),Vn(()=>{if(!c(a))return;v(Ke,Math.floor(Math.random()*ue.length),!0);const U=setInterval(()=>{v(Ke,(c(Ke)+1)%ue.length)},1e4);return()=>clearInterval(U)}),Vn(()=>{var U;Mt&&(c(n).length+(((U=c(s))==null?void 0:U.length)??0),requestAnimationFrame(()=>{Mt&&(Mt.scrollTop=Mt.scrollHeight)}))}),Vn(()=>{const U=c(et),ne=c(ri),Le=i();c(Nt)&&JN({context:U,currentScript:ne??null,extraFiles:Le.length>0?Le:void 0}).then(Ve=>{v(pe,new TextEncoder().encode(Ve.prompt).length,!0)}).catch(()=>{})});function Me(U){const ne=U.replace(/(\n|^)(\/{2} @[a-z-]+:[^\n]+)\n(```\w*)\n/g,`$1$3
145
- $2
146
- `),Le=[],Ve=/```(\w*)\n([\s\S]*?)```/g;let De=0,Ie;for(;(Ie=Ve.exec(ne))!==null;)Ie.index>De&&Le.push({type:"text",text:ne.slice(De,Ie.index)}),Le.push({type:"code",lang:Ie[1]||"text",text:Ie[2].trimEnd()}),De=Ie.index+Ie[0].length;return De<ne.length&&Le.push({type:"text",text:ne.slice(De)}),Le}const jt=15;function ft(U){return U.split(`
147
- `).length>jt}function ht(U){const ne=new Set(c(F));ne.has(U)?ne.delete(U):ne.add(U),v(F,ne,!0)}function he(U,ne){if(ci(ne))try{return bb.highlight(U,{language:"javascript"}).value}catch{}return U.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Xe(U){return qn.parse(U)}function Ut(U){const ne=U.replace(/(\n|^)(\/{2} @[a-z-]+:[^\n]+)\n(```\w*)\n/g,`$1$3
148
- $2
149
- `),Le=[],Ve=/```(\w*)\n([\s\S]*?)```/g;let De=0,Ie;for(;(Ie=Ve.exec(ne))!==null;)Ie.index>De&&Le.push({type:"text",text:ne.slice(De,Ie.index)}),Le.push({type:"code",lang:Ie[1]||"text",text:Ie[2].trimEnd()}),De=Ie.index+Ie[0].length;const St=ne.slice(De),mt=St.match(/```(\w*)\n([\s\S]*)$/);return mt?(mt.index>0&&Le.push({type:"text",text:St.slice(0,mt.index)}),Le.push({type:"code",lang:mt[1]||"text",text:mt[2]})):St&&Le.push({type:"text",text:St}),Le}function wi(U){navigator.clipboard.writeText(U).catch(()=>{})}function Ri(U,ne=!1){var Le;ne&&t()&&v(D,t().path,!0),(Le=e.onApply)==null||Le.call(e,U)}function ci(U){return!U||U==="js"||U==="javascript"}function Bt(U){const ne=U.match(/^\/\/ @new-file:\s*(\S+\.js)[ \t]*\n/);return ne?{filename:ne[1],code:U.slice(ne[0].length)}:null}function Xt(U){return U>=1e9?`${(U/1e9).toFixed(1)} GB`:U>=1e6?`${(U/1e6).toFixed(0)} MB`:U>=1024?`${(U/1024).toFixed(1)} kB`:`${U} B`}async function pt(){if(v(K,!0),!(c(V)||c(se))){v(se,!0),v(te,"");try{v(V,await Hx(c(k)||c(u).model),!0)}catch(U){v(te,U.message,!0)}v(se,!1)}}function Bi(U){const ne=U.match(/\.([^.]+)$/);return ne?ne[1].toUpperCase():"?"}function Ti(U){switch(U){case"SH":case"BASH":return"$";case"MD":case"MARKDOWN":return"⇓";case"JSON":case"JSONC":return"{}";default:return U}}function Ni(U){i(i().filter((ne,Le)=>Le!==U))}function Ki(){ot.click()}async function Ai(U){if(!(!U||U.length===0))for(const ne of Array.from(U)){const Le=await ne.text();i([...i(),{name:ne.name,content:Le}])}}function Di(U){const ne=U.target;Ai(ne.files),ne.value=""}function $i(U){var ne;U.preventDefault(),v(gt,!1),Ai(((ne=U.dataTransfer)==null?void 0:ne.files)??null)}function Gi(U){var ne;(ne=U.dataTransfer)!=null&&ne.types.includes("Files")&&(U.preventDefault(),v(gt,!0))}function Ui(){v(gt,!1)}async function mn(){try{v(w,await ZU(),!0)}catch{}}async function rt(){var ne;if(c(n).length===0)return;const U=((ne=c(n).find(Le=>Le.role==="user"))==null?void 0:ne.content.slice(0,80))??c(p);try{await YU(c(p),U,c(n)),await mn()}catch{}}async function Kt(U){try{const ne=await $E(U);v(n,ne.messages,!0),v(p,U,!0),v(y,!1),v(d,"")}catch{}}async function _i(U){try{await XU(U),await mn(),U===c(p)&&Pi()}catch{}}function Pi(){v(n,[],!0),v(d,""),v(p,g(),!0),v(y,!1)}Bs(async()=>{Vt();try{const U=await $E(c(p));v(n,U.messages,!0)}catch{}await mn()});async function Li(){const U=c(r).trim();if(!U||c(a))return;v(r,""),v(d,""),v(a,!0);const ne={role:"user",content:U};v(n,[...c(n),ne],!0),je=new AbortController,v(Pt,[],!0);try{await eA({messages:c(n),currentScript:c(ri),context:c(et),modelOverride:c(k)||void 0,extraFiles:i().length>0?i():void 0},Le=>{v(s,(c(s)??"")+Le)},je.signal,Le=>{v(Pt,[...c(Pt),Le],!0)}),v(n,[...c(n),{role:"assistant",content:c(s)??"",toolEvents:c(Pt).length>0?[...c(Pt)]:void 0}],!0),v(Pt,[],!0)}catch(Le){if(Le.name==="AbortError"){const Ve=c(s);Ve&&Ve.trim()&&v(n,[...c(n),{role:"assistant",content:Ve+`
150
-
151
- *[stopped]*`,toolEvents:c(Pt).length>0?[...c(Pt)]:void 0}],!0)}else v(d,Le.message,!0)}finally{je=null,v(s,null),v(Pt,[],!0),v(a,!1),rt()}}function Si(){je==null||je.abort()}function Oi(U){U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),Li())}function qi(){Pi()}const mi=["Explain what this script does","Add error handling","Add a 30-minute schedule before sunrise","Write a new script that forwards MQTT topic A to topic B","Write a new script that turns lights on at sunset"];function Ue(U){v(r,U,!0),Oe==null||Oe.focus()}var J=SG(),Qe=xt(J),_t=b(Qe),yt=m(b(_t),2);{var Ot=U=>{var ne=P9(),Le=b(ne);{var Ve=St=>{var mt=po();H(()=>N(mt,`${c(u).provider??""} · ${(c(k)||c(u).model)??""}`)),I(St,mt)},De=St=>{var mt=po();H(()=>N(mt,`${c(u).provider??""} · pick a model below`)),I(St,mt)},Ie=St=>{var mt=po("Not configured");I(St,mt)};O(Le,St=>{c(Nt)?St(Ve):c(u).provider?St(De,1):St(Ie,-1)})}H(()=>ln(ne,"title",`Provider: ${c(u).provider??""}`)),I(U,ne)};O(yt,U=>{c(u)&&U(Ot)})}var j=m(yt,2);let ce;var ke=m(j,2);{var ze=U=>{var ne=M9();z("click",ne,qi),I(U,ne)};O(ke,U=>{c(n).length>0&&U(ze)})}var st=m(_t,2);{var X=U=>{var ne=O9(),Le=b(ne),Ve=m(b(Le),2),De=m(Le,2);{var Ie=mt=>{var qe=R9();I(mt,qe)},St=mt=>{var qe=A9();ni(qe,21,()=>c(w),Tt=>Tt.id,(Tt,it)=>{var ye=N9();let Ne;var Ee=b(ye),Se=b(Ee),nt=m(Ee,2);H(()=>{Ne=kt(ye,1,"history-item svelte-10ayso4",null,Ne,{"history-active":c(it).id===c(p)}),ln(Ee,"title",c(it).id),N(Se,c(it).title||c(it).id)}),z("click",Ee,()=>Kt(c(it).id)),z("click",nt,()=>_i(c(it).id)),I(Tt,ye)}),I(mt,qe)};O(De,mt=>{c(w).length===0?mt(Ie):mt(St,-1)})}z("click",Ve,Pi),I(U,ne)};O(st,U=>{c(y)&&U(X)})}var ae=m(st,2),me=b(ae);{var Ze=U=>{var ne=F9();I(U,ne)},Zt=U=>{var ne=B9(),Le=b(ne),Ve=b(Le);{var De=mt=>{var qe=H9(),Tt=m(xt(qe)),it=b(Tt);H(ye=>N(it,ye),[()=>t().path.split("/").pop()]),I(mt,qe)},Ie=mt=>{var qe=po("No script open. Ask a general she scripting question.");I(mt,qe)};O(Ve,mt=>{t()?mt(De):mt(Ie,-1)})}var St=m(Le,2);ni(St,17,()=>mi,Vi,(mt,qe)=>{var Tt=W9(),it=b(Tt);H(()=>N(it,c(qe))),z("click",Tt,()=>Ue(c(qe))),I(mt,Tt)}),I(U,ne)};O(me,U=>{c(ct)?c(n).length===0&&c(s)===null&&U(Zt,1):U(Ze)})}var bt=m(me,2);ni(bt,17,()=>c(n),Vi,(U,ne,Le)=>{var Ve=Z9(),De=b(Ve);{var Ie=mt=>{var qe=z9(),Tt=b(qe);H(()=>N(Tt,c(ne).content)),I(mt,qe)},St=mt=>{const qe=Ct(()=>Me(c(ne).content));var Tt=K9(),it=xt(Tt);{var ye=Ee=>{var Se=rD();ni(Se,21,()=>c(ne).toolEvents,Vi,(nt,de)=>{var Pe=As(),at=xt(Pe);{var ut=$t=>{var Jt=sD(),Mi=m(b(Jt),2),ii=b(Mi),xi=m(Mi,2);{var Ji=li=>{var un=nD(),rn=b(un);H(es=>N(rn,es),[()=>Object.entries(c(de).args).map(([es,js])=>`${es}=${JSON.stringify(js)}`).join(", ")]),I(li,un)},Hi=Ct(()=>c(de).args&&Object.keys(c(de).args).length>0);O(xi,li=>{c(Hi)&&li(Ji)})}H(li=>N(ii,li),[()=>c(de).name.replace(/_/g," ")]),I($t,Jt)},Je=$t=>{var Jt=oD(),Mi=m(b(Jt),2),ii=b(Mi);H(xi=>N(ii,xi),[()=>c(de).name.replace(/_/g," ")]),I($t,Jt)};O(at,$t=>{c(de).type==="tool_call"?$t(ut):$t(Je,-1)})}I(nt,Pe)}),I(Ee,Se)};O(it,Ee=>{var Se;(Se=c(ne).toolEvents)!=null&&Se.length&&Ee(ye)})}var Ne=m(it,2);ni(Ne,21,()=>c(qe),Vi,(Ee,Se,nt)=>{var de=As(),Pe=xt(de);{var at=Je=>{var $t=aD();rc($t,()=>Xe(c(Se).text),!0),I(Je,$t)},ut=Je=>{const $t=Ct(()=>ci(c(Se).lang)?Bt(c(Se).text):null),Jt=Ct(()=>c($t)?c($t).code:c(Se).text),Mi=Ct(()=>`${Le}:${nt}`),ii=Ct(()=>ft(c(Jt))),xi=Ct(()=>c(F).has(c(Mi)));var Ji=G9(),Hi=b(Ji),li=b(Hi),un=b(li),rn=m(li,2),es=b(rn),js=m(es,2);{var fo=ns=>{var Rs=V9();z("click",Rs,()=>e.onCreateFile(c($t).filename,c($t).code)),I(ns,Rs)},Zo=ns=>{var Rs=U9(),Wr=xt(Rs),Za=m(Wr,2);{var Wl=Xo=>{var Br=j9();I(Xo,Br)},Ya=Xo=>{var Br=$9();z("click",Br,()=>Ri(c(Se).text,!0)),I(Xo,Br)};O(Za,Xo=>{c(M)?Xo(Wl):Xo(Ya,-1)})}z("click",Wr,()=>Ri(c(Se).text)),I(ns,Rs)},hr=Ct(()=>ci(c(Se).lang)&&t());O(js,ns=>{c($t)&&e.onCreateFile?ns(fo):c(hr)&&ns(Zo,1)})}var Yn=m(Hi,2);let Yo;var fr=b(Yn),vn=b(fr);rc(vn,()=>he(c(Jt),c(Se).lang??""),!0);var Ms=m(fr,2);{var fs=ns=>{var Rs=q9(),Wr=b(Rs);H(()=>N(Wr,c(xi)?"▲ collapse":"▼ expand")),z("click",Rs,()=>ht(c(Mi))),I(ns,Rs)};O(Ms,ns=>{c(ii)&&ns(fs)})}H(()=>{N(un,c($t)?`new: ${c($t).filename}`:c(Se).lang),Yo=kt(Yn,1,"code-body svelte-10ayso4",null,Yo,{collapsed:c(ii)&&!c(xi)})}),z("click",es,()=>wi(c(Jt))),I(Je,Ji)};O(Pe,Je=>{c(Se).type==="text"?Je(at):Je(ut,-1)})}I(Ee,de)}),I(mt,Tt)};O(De,mt=>{c(ne).role==="user"?mt(Ie):mt(St,-1)})}H(()=>kt(Ve,1,`message ${c(ne).role??""}`,"svelte-10ayso4")),I(U,Ve)});var We=m(bt,2);{var At=U=>{var ne=rD();ni(ne,21,()=>c(Pt),Vi,(Le,Ve)=>{var De=As(),Ie=xt(De);{var St=qe=>{var Tt=sD(),it=m(b(Tt),2),ye=b(it),Ne=m(it,2);{var Ee=nt=>{var de=nD(),Pe=b(de);H(at=>N(Pe,at),[()=>Object.entries(c(Ve).args).map(([at,ut])=>`${at}=${JSON.stringify(ut)}`).join(", ")]),I(nt,de)},Se=Ct(()=>c(Ve).args&&Object.keys(c(Ve).args).length>0);O(Ne,nt=>{c(Se)&&nt(Ee)})}H(nt=>N(ye,nt),[()=>c(Ve).name.replace(/_/g," ")]),I(qe,Tt)},mt=qe=>{var Tt=oD(),it=m(b(Tt),2),ye=b(it);H(Ne=>N(ye,Ne),[()=>c(Ve).name.replace(/_/g," ")]),I(qe,Tt)};O(Ie,qe=>{c(Ve).type==="tool_call"?qe(St):qe(mt,-1)})}I(Le,De)}),I(U,ne)};O(We,U=>{c(Pt).length>0&&U(At)})}var ai=m(We,2);{var zt=U=>{var ne=Y9(),Le=b(ne),Ve=b(Le),De=b(Ve);H(()=>N(De,ue[c(Ke)])),I(U,ne)};O(ai,U=>{c(a)&&c(s)===null&&c(Pt).length===0&&U(zt)})}var vi=m(ai,2);{var hi=U=>{var ne=Q9(),Le=b(ne);ni(Le,21,()=>Ut(c(s)),Vi,(Ve,De)=>{var Ie=As(),St=xt(Ie);{var mt=Tt=>{var it=aD();rc(it,()=>Xe(c(De).text),!0),I(Tt,it)},qe=Tt=>{var it=X9(),ye=b(it),Ne=b(ye),Ee=b(Ne),Se=m(ye,2),nt=b(Se);rc(nt,()=>he(c(De).text,c(De).lang??""),!0),H(()=>N(Ee,c(De).lang)),I(Tt,it)};O(St,Tt=>{c(De).type==="text"?Tt(mt):Tt(qe,-1)})}I(Ve,Ie)}),I(U,ne)};O(vi,U=>{c(s)!==null&&U(hi)})}vs(ae,U=>Mt=U,()=>Mt);var Ci=m(ae,2);{var zi=U=>{var ne=J9(),Le=b(ne);H(()=>N(Le,c(d))),I(U,ne)};O(Ci,U=>{c(d)&&U(zi)})}var $e=m(Ci,2),Fe=b($e),Ft=b(Fe),Yt=m(Fe,2),qt=b(Yt),Qt=m(Yt,2),re=b(Qt),Ge=m(re);{var wt=U=>{const ne=Ct(()=>Math.min(100,Math.round(c(ti)/4/c(V).contextLength*100)));var Le=eG(),Ve=b(Le),De=m(b(Ve));H((Ie,St)=>{ln(Le,"title",`~${c(ne)??""}% of ${Ie??""} token context window used`),ln(De,"stroke",c(ne)>80?"var(--fg-err)":c(ne)>50?"var(--fg-warn)":"var(--fg-ok)"),ln(De,"stroke-dasharray",`${St??""} 31.4`)},[()=>c(V).contextLength.toLocaleString(),()=>(c(ne)/100*31.4).toFixed(1)]),I(U,Le)};O(Ge,U=>{var ne;(ne=c(V))!=null&&ne.contextLength&&U(wt)})}var vt=m($e,2),di=b(vt);{var It=U=>{const ne=Ct(()=>Bi(t().path.split("/").pop()??t().path));var Le=tG();let Ve;var De=b(Le),Ie=b(De),St=m(De,2),mt=b(St),qe=m(St,2),Tt=b(qe);H((it,ye)=>{Ve=kt(Le,1,"file-chip svelte-10ayso4",null,Ve,{inactive:!c(we)}),kt(De,1,`badge badge-${it??""}`,"svelte-10ayso4"),N(Ie,ye),N(mt,t().path),ln(qe,"title",c(we)?"Remove from context":"Re-add to context"),N(Tt,c(we)?"×":"+")},[()=>c(ne).toLowerCase(),()=>Ti(c(ne))]),z("click",qe,()=>v(we,!c(we))),I(U,Le)};O(di,U=>{t()&&U(It)})}var Ii=m(di,2);ni(Ii,17,i,Vi,(U,ne,Le)=>{const Ve=Ct(()=>Bi(c(ne).name));var De=iG(),Ie=b(De),St=b(Ie),mt=m(Ie,2),qe=b(mt),Tt=m(mt,2);H((it,ye)=>{kt(Ie,1,`badge badge-${it??""}`,"svelte-10ayso4"),N(St,ye),N(qe,c(ne).name)},[()=>c(Ve).toLowerCase(),()=>Ti(c(Ve))]),z("click",Tt,()=>Ni(Le)),I(U,De)});var W=m(Ii,2),Q=m(W,2);vs(Q,U=>ot=U,()=>ot);var oe=m(vt,2);let $;var A=b(oe);let G;var ie=b(A);vs(ie,U=>Oe=U,()=>Oe);var fe=m(A,2);{var Y=U=>{var ne=nG();z("click",ne,Si),I(U,ne)},le=U=>{var ne=sG();H(Le=>ne.disabled=Le,[()=>!c(r).trim()||!c(Nt)]),z("click",ne,Li),I(U,ne)};O(fe,U=>{c(a)?U(Y):U(le,-1)})}var Re=m(oe,2);{var _e=U=>{var ne=cG(),Le=b(ne),Ve=b(Le),De=m(Le,2);{var Ie=Tt=>{var it=rG();ni(it,21,()=>c(x),Vi,(ye,Ne)=>{var Ee=oG(),Se=b(Ee),nt={};H(()=>{N(Se,c(Ne)),nt!==(nt=c(Ne))&&(Ee.value=(Ee.__value=c(Ne))??"")}),I(ye,Ee)}),H(()=>it.disabled=c(a)),ys(it,()=>c(k),ye=>v(k,ye)),I(Tt,it)},St=Tt=>{var it=aG(),ye=b(it);H(()=>N(ye,c(k)||c(u).model)),I(Tt,it)};O(De,Tt=>{c(x).length>0?Tt(Ie):Tt(St,-1)})}var mt=m(De,2);{var qe=Tt=>{var it=lG();z("click",it,pt),I(Tt,it)};O(mt,Tt=>{c(u).provider==="ollama"&&Tt(qe)})}H(()=>N(Ve,c(u).provider)),I(U,ne)};O(Re,U=>{var ne;(ne=c(u))!=null&&ne.provider&&(c(ct)||c(x).length>0)&&U(_e)})}var ge=m(Qe,2);{var tt=U=>{var ne=wG(),Le=b(ne),Ve=b(Le),De=b(Ve),Ie=b(De),St=m(De,2),mt=m(Ve,2),qe=b(mt);{var Tt=Ne=>{var Ee=dG();I(Ne,Ee)},it=Ne=>{var Ee=uG(),Se=b(Ee);H(()=>N(Se,c(te))),I(Ne,Ee)},ye=Ne=>{var Ee=yG(),Se=b(Ee);{var nt=Hi=>{var li=hG(),un=m(xt(li)),rn=b(un);H(()=>N(rn,c(V).version)),I(Hi,li)};O(Se,Hi=>{c(V).version&&Hi(nt)})}var de=m(Se,2);{var Pe=Hi=>{var li=fG(),un=m(xt(li)),rn=b(un);H(()=>N(rn,c(V).details.family)),I(Hi,li)};O(de,Hi=>{var li;(li=c(V).details)!=null&&li.family&&Hi(Pe)})}var at=m(de,2);{var ut=Hi=>{var li=gG(),un=m(xt(li)),rn=b(un);H(()=>N(rn,c(V).details.parameter_size)),I(Hi,li)};O(at,Hi=>{var li;(li=c(V).details)!=null&&li.parameter_size&&Hi(ut)})}var Je=m(at,2);{var $t=Hi=>{var li=pG(),un=m(xt(li)),rn=b(un);H(()=>N(rn,c(V).details.quantization_level)),I(Hi,li)};O(Je,Hi=>{var li;(li=c(V).details)!=null&&li.quantization_level&&Hi($t)})}var Jt=m(Je,2);{var Mi=Hi=>{var li=_G(),un=m(xt(li)),rn=b(un);H(()=>N(rn,c(V).details.format)),I(Hi,li)};O(Jt,Hi=>{var li;(li=c(V).details)!=null&&li.format&&Hi(Mi)})}var ii=m(Jt,2);{var xi=Hi=>{var li=vG(),un=m(xt(li),2);ni(un,21,()=>c(V).running,Vi,(rn,es)=>{var js=mG(),fo=b(js);H(Zo=>N(fo,`${c(es).name??""} · ${Zo??""} VRAM`),[()=>Xt(c(es).size_vram)]),I(rn,js)}),I(Hi,li)},Ji=Hi=>{var li=bG();I(Hi,li)};O(ii,Hi=>{c(V).running&&c(V).running.length>0?Hi(xi):c(V).running!==null&&Hi(Ji,1)})}I(Ne,Ee)};O(qe,Ne=>{c(se)?Ne(Tt):c(te)?Ne(it,1):c(V)&&Ne(ye,2)})}H(()=>{var Ne;return N(Ie,`Ollama · ${(c(k)||((Ne=c(u))==null?void 0:Ne.model))??""}`)}),z("click",ne,()=>v(K,!1)),z("click",Le,Ne=>Ne.stopPropagation()),z("click",St,()=>v(K,!1)),I(U,ne)};O(ge,U=>{c(K)&&U(tt)})}H(U=>{ce=kt(j,1,"icon-hdr-btn svelte-10ayso4",null,ce,{active:c(y)}),N(re,U),$=kt(oe,1,"input-row svelte-10ayso4",null,$,{"drag-over":c(gt)}),G=kt(A,1,"textarea-wrap svelte-10ayso4",null,G,{loading:c(a)}),ln(ie,"placeholder",c(Nt)?"Ask anything… (Enter to send, Shift+Enter for newline, drag & drop files to add context)":c(ct)?"Select a model above to start chatting":"AI not configured"),ie.disabled=c(a)||!c(Nt)},[()=>Xt(c(ti))]),z("click",j,()=>v(y,!c(y))),ms(Ft,()=>c(He),U=>v(He,U)),ms(qt,()=>c(dt),U=>v(dt,U)),z("click",W,Ki),z("change",Q,Di),ds("dragover",oe,Gi),ds("dragleave",oe,Ui),ds("drop",oe,$i),z("keydown",ie,Oi),Ht(ie,()=>c(r),U=>v(r,U)),I(o,J),Ps()}zs(["click","change","keydown"]);const xG={OnOff:["onOff","globalSceneControl","onTime","offWaitTime"],LevelControl:["currentLevel","remainingTime","minLevel","maxLevel","currentFrequency","onOffTransitionTime","onLevel"],ColorControl:["currentHue","currentSaturation","remainingTime","currentX","currentY","colorTemperatureMireds","colorMode","colorTempPhysicalMinMireds","colorTempPhysicalMaxMireds"],BasicInformation:["vendorName","vendorId","productName","productId","nodeLabel","location","softwareVersion","softwareVersionString","serialNumber"],Identify:["identifyTime","identifyType"],Groups:["nameSupport"],OccupancySensing:["occupancy","occupancySensorType"],IlluminanceMeasurement:["measuredValue","minMeasuredValue","maxMeasuredValue","tolerance","lightSensorType"],TemperatureMeasurement:["measuredValue","minMeasuredValue","maxMeasuredValue","tolerance"],RelativeHumidityMeasurement:["measuredValue","minMeasuredValue","maxMeasuredValue","tolerance"],PressureMeasurement:["measuredValue","minMeasuredValue","maxMeasuredValue"],Thermostat:["localTemperature","outdoorTemperature","occupiedCoolingSetpoint","occupiedHeatingSetpoint","unoccupiedCoolingSetpoint","unoccupiedHeatingSetpoint","minHeatSetpointLimit","maxHeatSetpointLimit","systemMode","thermostatRunningMode","occupancy"],DoorLock:["lockState","lockType","actuatorEnabled","doorState"],WindowCovering:["type","currentPositionLiftPercent100ths","currentPositionTiltPercent100ths","operationalStatus","targetPositionLiftPercent100ths","targetPositionTiltPercent100ths","endProductType","mode"],FanControl:["fanMode","fanModeSequence","percentSetting","percentCurrent","speedMax","speedSetting","speedCurrent"],Descriptor:["deviceTypeList","serverList","clientList","partsList"],PowerSource:["status","order","description","wiredCurrentType","wiredMaximumCurrent","batteryVoltage","batteryPercentRemaining","batChargeLevel"],Switch:["numberOfPositions","currentPosition","multiPressMax"],BooleanState:["stateValue"],FlowMeasurement:["measuredValue","minMeasuredValue","maxMeasuredValue"]},kG={OnOff:["on","off","toggle"],LevelControl:["moveToLevel","move","step","stop","moveToLevelWithOnOff","moveWithOnOff","stepWithOnOff","stopWithOnOff"],ColorControl:["moveToHue","moveHue","stepHue","moveToSaturation","moveSaturation","stepSaturation","moveToHueAndSaturation","moveToColor","moveColor","stepColor","moveToColorTemperature","moveColorTemperature","stepColorTemperature"],Identify:["identify","triggerEffect"],Groups:["addGroup","viewGroup","getGroupMembership","removeGroup","removeAllGroups","addGroupIfIdentifying"],Thermostat:["setpointRaiseLower","setWeeklySchedule","getWeeklySchedule","clearWeeklySchedule"],DoorLock:["lockDoor","unlockDoor","unlockWithTimeout"],WindowCovering:["upOrOpen","downOrClose","stopMotion","goToLiftValue","goToLiftPercentage","goToTiltValue","goToTiltPercentage"],FanControl:[]};let jx=[],$x=[],Ux=[];const Cb=new Map;let xA=[];const qx=new Map,Gx=new Map;async function lD(){try{jx=(await YN()).map(e=>e.topic)}catch{}}async function cD(){try{const[o,e]=await Promise.all([qN(),GN()]);$x=o,Ux=e}catch{}}async function dD(){try{const o=await ZN();xA=o.map(e=>e.nodeId),qx.clear(),Gx.clear();for(const e of o)e.name&&(qx.set(e.nodeId,e.name),Gx.set(e.name,e.nodeId));await Promise.all(o.map(async e=>{if(!Cb.has(e.nodeId))try{Cb.set(e.nodeId,await Jm(e.nodeId))}catch{}}))}catch{}}function LG(o){const e=/(?:she\.mqtt\.(?:sub|pub|get|set|link|age|getProp|or|and|max|min|timer)|she\.(?:getValue|setValue|getProp))\s*\([^)]*?['"]([^'"]*)\s*$/,t=o.match(e);if(t)return{type:"mqtt",prefix:t[1]};const i=/she\.db\.sub\s*\([^)]*?['"]([^'"]*)\s*$/,n=o.match(i);if(n)return{type:"db",prefix:n[1],includeViews:!0};const s=/she\.db\.(?:get|set|extend|delete|prop|query)\s*\([^)]*?['"]([^'"]*)\s*$/,r=o.match(s);if(r)return{type:"db",prefix:r[1],includeViews:!1};const a=/she\.matter\.(?:sub|get|send|on)\s*\(\s*(.*)\s*$/,d=o.match(a);if(d){const u=d[1],f=IG(u),g=EG(u);if(f===0)return{type:"matter-nodeId",prefix:g};if(f===1){const p=ph(u,0);if(p)return{type:"matter-endpointId",nodeId:p}}if(f===2){const p=ph(u,0),w=uD(u,1)??ph(u,1);if(p&&w!==null)return{type:"matter-cluster",nodeId:p,endpointId:w}}if(f>=3){const p=ph(u,0),w=uD(u,1)??ph(u,1),y=ph(u,2),x=/she\.matter\.send\s*\(/.test(o);if(p&&w!==null&&y)return{type:"matter-attr",nodeId:p,endpointId:w,cluster:y,isSend:x}}}return null}function IG(o){let e=0,t=0,i=!1,n="";for(const s of o){if(i){s===n&&(i=!1);continue}if(s==='"'||s==="'"){i=!0,n=s;continue}if(s==="("||s==="["||s==="{"){e++;continue}if(s===")"||s==="]"||s==="}"){e--;continue}s===","&&e===0&&t++}return t}function EG(o){const e=o.match(/['"]([^'"]*)\s*$/);return e?e[1]:""}function ph(o,e){var s;const i=(s=kA(o)[e])==null?void 0:s.trim();if(!i)return null;const n=i.match(/^['"](.*)['"]$/);return n?n[1]:null}function uD(o,e){var s;const i=(s=kA(o)[e])==null?void 0:s.trim();if(!i)return null;const n=parseInt(i,10);return isNaN(n)?null:n}function kA(o){const e=[];let t="",i=0,n=!1,s="";for(const r of o){if(n){r===s&&(n=!1),t+=r;continue}if(r==='"'||r==="'"){n=!0,s=r,t+=r;continue}if(r==="("||r==="["||r==="{"){i++,t+=r;continue}if(r===")"||r==="]"||r==="}"){i--,t+=r;continue}if(r===","&&i===0){e.push(t),t="";continue}t+=r}return e.push(t),e}const Ou=od.CompletionItemKind;function DG(o,e){return(e?jx.filter(i=>i.startsWith(e)):jx).map(i=>({label:i,kind:Ou.Value,insertText:i,range:o,detail:"MQTT topic",sortText:"0"+i}))}function TG(o,e,t){const i=t?[...$x,...Ux]:$x;return(e?i.filter(s=>s.startsWith(e)):i).map(s=>({label:s,kind:Ou.Value,insertText:s,range:o,detail:Ux.includes(s)?"sheDB view":"sheDB document",sortText:"0"+s}))}function PG(o,e){return xA.map(t=>{const i=qx.get(t)??t;return e&&!i.startsWith(e)&&!t.startsWith(e)?null:{label:i,kind:Ou.Value,insertText:i,range:o,detail:i!==t?`Node ID: ${t}`:"Matter node",sortText:"0"+i}}).filter(Boolean)}function LA(o){return Gx.get(o)??o}function MG(o,e){if(typeof e=="number")return o.endpoints.find(i=>i.endpointId===e);const t=parseInt(e,10);return isNaN(t)?o.endpoints.find(i=>i.name===e):o.endpoints.find(i=>i.endpointId===t)}function RG(o,e){const t=Cb.get(LA(e));return t?t.endpoints.map(i=>{const n=i.name??String(i.endpointId),s=i.clusters.map(r=>r.name).join(", ");return{label:n,kind:Ou.Value,insertText:n,range:o,detail:i.name?`Endpoint ${i.endpointId} — ${s}`:`Clusters: ${s}`,sortText:"0"+String(i.endpointId).padStart(4,"0")}}):[]}function NG(o,e,t){const i=Cb.get(LA(e));if(!i)return[];const n=MG(i,t);return n?n.clusters.map(s=>({label:s.name,kind:Ou.Value,insertText:s.name,range:o,detail:"Matter cluster",sortText:"0"+s.name})):[]}function AG(o,e,t){return(t?kG[e]??[]:xG[e]??[]).map(n=>({label:n,kind:t?Ou.Function:Ou.Property,insertText:n,range:o,detail:t?`${e} command`:`${e} attribute`,sortText:"0"+n}))}let hD=!1;function OG(){hD||(hD=!0,lD(),cD(),dD(),setInterval(lD,15e3),setInterval(cD,1e4),setInterval(dD,6e4),od.registerCompletionItemProvider("javascript",{triggerCharacters:["'",'"',"(",","," "],provideCompletionItems(o,e){const t=o.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column}),i=LG(t);if(!i)return null;const n=o.getWordUntilPosition(e),s=Math.max(t.lastIndexOf("'"),t.lastIndexOf('"')),r=s>=0?s+2:n.startColumn,a={startLineNumber:e.lineNumber,endLineNumber:e.lineNumber,startColumn:r,endColumn:e.column};switch(i.type){case"mqtt":return{suggestions:DG(a,i.prefix)};case"db":return{suggestions:TG(a,i.prefix,i.includeViews)};case"matter-nodeId":return{suggestions:PG(a,i.prefix)};case"matter-endpointId":return{suggestions:RG(a,i.nodeId)};case"matter-cluster":return{suggestions:NG(a,i.nodeId,i.endpointId)};case"matter-attr":return{suggestions:AG(a,i.cluster,i.isSend)};default:return null}}}))}var FG=T('<button class="svelte-1pyfjii">New file here</button> <button class="svelte-1pyfjii">New subfolder here</button> <hr class="svelte-1pyfjii"/> <button class="svelte-1pyfjii">Rename folder…</button> <button class="danger svelte-1pyfjii">Delete folder…</button>',1),HG=T('<button class="svelte-1pyfjii">Show git history</button>'),WG=T('<button class="svelte-1pyfjii">Open</button> <button class="svelte-1pyfjii">Rename…</button> <button class="svelte-1pyfjii">Add to AI context</button> <!> <hr class="svelte-1pyfjii"/> <button class="danger svelte-1pyfjii">Delete</button>',1),BG=T('<div class="ctx-backdrop svelte-1pyfjii" role="presentation"></div> <div class="ctx-menu svelte-1pyfjii"><!></div>',1),zG=T('<div class="lib-tip-float svelte-1pyfjii">Library directory — files here are not auto-loaded as scripts</div>'),fD=T('<span class="git-mod svelte-1pyfjii" title="Uncommitted changes">M</span>'),VG=T('<ul class="tree-children svelte-1pyfjii"></ul>'),jG=T('<li class="tree-dir svelte-1pyfjii"><div role="treeitem" tabindex="-1" draggable="true"><button>›</button> <span role="button" tabindex="0"> </span> <!> <label class="lib-label svelte-1pyfjii" title="Library directory — files here are not auto-loaded as scripts"><input type="checkbox" class="svelte-1pyfjii"/> <span class="lib-checkmark svelte-1pyfjii"></span> <svg width="11" height="11" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3h8a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H3V3z"></path><line x1="3" y1="12" x2="13" y2="12"></line><line x1="6" y1="3" x2="6" y2="12"></line></svg></label> <label class="dis-label svelte-1pyfjii" title="Disable — scripts in this folder will not be executed"><input type="checkbox" class="svelte-1pyfjii"/> <span class="dis-checkmark svelte-1pyfjii"></span> <svg width="11" height="11" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><circle cx="8" cy="8" r="6"></circle><line x1="3.8" y1="12.2" x2="12.2" y2="3.8"></line></svg></label></div> <!></li>'),$G=T('<span class="dirty-dot svelte-1pyfjii">●</span>'),UG=T('<span class="run-dot svelte-1pyfjii" title="Running">●</span>'),qG=T('<span class="err-dot svelte-1pyfjii">●</span>'),GG=T('<label><input type="checkbox" class="svelte-1pyfjii"/> <span class="dis-checkmark svelte-1pyfjii"></span> <svg width="11" height="11" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><circle cx="8" cy="8" r="6"></circle><line x1="3.8" y1="12.2" x2="12.2" y2="3.8"></line></svg></label>'),KG=T('<span class="dis-spacer svelte-1pyfjii"></span>'),ZG=T('<li draggable="true"><div class="file-row svelte-1pyfjii"><button><span> </span> <span class="fname svelte-1pyfjii"> </span> <!><!> <!> <!></button> <!></div></li>'),YG=T('<div class="err svelte-1pyfjii"> </div>'),XG=T('<div class="history-empty svelte-1pyfjii">Loading…</div>'),QG=T('<div class="history-empty svelte-1pyfjii">No commits found.</div>'),JG=T('<button class="history-row svelte-1pyfjii"><span class="history-subject svelte-1pyfjii"> </span> <span class="history-meta svelte-1pyfjii"> </span></button>'),eK=T('<button class="history-load-more svelte-1pyfjii"> </button>'),tK=T("<!> <!>",1),iK=T('<div class="history-panel svelte-1pyfjii"><div class="history-resize-handle svelte-1pyfjii" role="separator"></div> <div class="history-hdr svelte-1pyfjii"><span class="history-title svelte-1pyfjii"> </span> <button class="history-close svelte-1pyfjii">✕</button></div> <div class="history-body svelte-1pyfjii"><!></div></div>'),nK=T('<span class="tab-dirty svelte-1pyfjii">●</span>'),sK=T('<div role="button" tabindex="0"><span class="tab-label svelte-1pyfjii"> </span> <!> <button class="tab-close svelte-1pyfjii" title="Close">×</button></div>'),oK=T('<div class="tab-bar svelte-1pyfjii"></div>'),rK=T('<li class="changes-item svelte-1pyfjii"><input type="checkbox" class="changes-check svelte-1pyfjii"/> <span class="changes-status svelte-1pyfjii"> </span> <span class="changes-file svelte-1pyfjii"> </span></li>'),aK=T('<div class="changes-err svelte-1pyfjii"> </div>'),lK=T('<div class="changes-backdrop svelte-1pyfjii" role="presentation"></div> <div class="changes-popup svelte-1pyfjii"><div class="changes-popup-hdr svelte-1pyfjii">Uncommitted changes</div> <ul class="changes-list svelte-1pyfjii"></ul> <div class="changes-commit-row svelte-1pyfjii"><input class="changes-msg-input svelte-1pyfjii" type="text" placeholder="Commit message…"/> <button class="changes-commit-btn svelte-1pyfjii"> </button></div> <!></div>',1),cK=T('<div class="changes-wrap svelte-1pyfjii"><button class="git-changes svelte-1pyfjii"> </button> <!></div>'),dK=T('<div class="changes-backdrop svelte-1pyfjii" role="presentation"></div> <div class="changes-popup svelte-1pyfjii"><div class="changes-popup-hdr svelte-1pyfjii"> </div> <div class="changes-commit-row svelte-1pyfjii"><button class="changes-commit-btn svelte-1pyfjii">Push</button></div></div>',1),uK=T('<div class="changes-wrap svelte-1pyfjii"><button class="git-ahead svelte-1pyfjii"> </button> <!></div>'),hK=T('<span class="git-behind svelte-1pyfjii"> </span>'),fK=T('<span class="git-status svelte-1pyfjii"><span class="git-branch svelte-1pyfjii"> </span> <!> <!> <!></span>'),gK=T('<div class="split-backdrop svelte-1pyfjii" role="presentation"></div> <div class="split-menu svelte-1pyfjii"><button class="svelte-1pyfjii">Save</button> <button class="svelte-1pyfjii">Save &amp; Commit</button></div>',1),pK=T('<button class="danger svelte-1pyfjii">Delete</button>'),_K=T(`<div class="welcome svelte-1pyfjii"><div class="welcome-inner svelte-1pyfjii"><div class="welcome-logo svelte-1pyfjii">she</div> <p class="welcome-sub svelte-1pyfjii">Smart Home Engine — a scriptable smart home automation engine</p> <div class="welcome-hint svelte-1pyfjii"><strong>Quick start:</strong> click <kbd class="svelte-1pyfjii">+ File</kbd> in the sidebar to create your first script,
152
- or click an existing file to open it. Scripts run in a sandboxed VM with access to the <code class="svelte-1pyfjii">she</code> object for MQTT, scheduling, and more.</div> <div class="welcome-links svelte-1pyfjii"><a href="https://github.com/hobbyquaker/she" target="_blank" rel="noopener" class="svelte-1pyfjii">GitHub</a> <span class="svelte-1pyfjii">·</span> <a href="https://github.com/hobbyquaker/she/blob/main/doc/sandbox-api.md" target="_blank" rel="noopener" class="svelte-1pyfjii">API reference</a> <span class="svelte-1pyfjii">·</span> <a href="https://github.com/hobbyquaker/she/blob/main/README.md" target="_blank" rel="noopener" class="svelte-1pyfjii">README</a></div> <div class="welcome-shortcuts svelte-1pyfjii"><div class="welcome-shortcuts-title svelte-1pyfjii">Keyboard shortcuts</div> <div class="welcome-shortcuts-grid svelte-1pyfjii"><span class="keys svelte-1pyfjii"><kbd class="svelte-1pyfjii">Ctrl</kbd><kbd class="svelte-1pyfjii">S</kbd></span><span class="svelte-1pyfjii">Save</span> <span class="keys svelte-1pyfjii"><kbd class="svelte-1pyfjii">Ctrl</kbd><kbd class="svelte-1pyfjii">F</kbd></span><span class="svelte-1pyfjii">Find</span> <span class="keys svelte-1pyfjii"><kbd class="svelte-1pyfjii">Ctrl</kbd><kbd class="svelte-1pyfjii">H</kbd></span><span class="svelte-1pyfjii">Find &amp; Replace</span> <span class="keys svelte-1pyfjii"><kbd class="svelte-1pyfjii">Ctrl</kbd><kbd class="svelte-1pyfjii">G</kbd></span><span class="svelte-1pyfjii">Go to line</span> <span class="keys svelte-1pyfjii"><kbd class="svelte-1pyfjii">Ctrl</kbd><kbd class="svelte-1pyfjii">Z</kbd></span><span class="svelte-1pyfjii">Undo</span> <span class="keys svelte-1pyfjii"><kbd class="svelte-1pyfjii">Ctrl</kbd><kbd class="svelte-1pyfjii">Shift</kbd><kbd class="svelte-1pyfjii">Z</kbd></span><span class="svelte-1pyfjii">Redo</span> <span class="keys svelte-1pyfjii"><kbd class="svelte-1pyfjii">Ctrl</kbd><kbd class="svelte-1pyfjii">/</kbd></span><span class="svelte-1pyfjii">Toggle comment</span> <span class="keys svelte-1pyfjii"><kbd class="svelte-1pyfjii">Alt</kbd><kbd class="svelte-1pyfjii">↑ / ↓</kbd></span><span class="svelte-1pyfjii">Move line up / down</span></div></div></div></div>`),mK=T('<button class="svelte-1pyfjii">Always accept in this session</button>'),vK=T('<button class="svelte-1pyfjii">Disable auto-accept</button>'),bK=T('<div class="split-backdrop svelte-1pyfjii" role="presentation"></div> <div class="split-menu svelte-1pyfjii"><!></div>',1),yK=T('<div class="diff-overlay svelte-1pyfjii"><div class="diff-bar svelte-1pyfjii"><span class="diff-title svelte-1pyfjii">Proposed changes — <em class="svelte-1pyfjii"> </em></span> <div class="diff-actions svelte-1pyfjii"><div class="split-wrap svelte-1pyfjii"><div class="split-btn accept-split svelte-1pyfjii"><button class="split-main svelte-1pyfjii"> </button> <button class="split-arrow svelte-1pyfjii" aria-label="Accept options">▾</button></div> <!></div> <button class="discard-btn svelte-1pyfjii">Discard</button></div></div> <div class="diff-container svelte-1pyfjii"></div></div>'),wK=T('<div class="history-diff-notice svelte-1pyfjii">Binary file — diff not available.</div>'),SK=T('<div class="diff-container svelte-1pyfjii"></div>'),CK=T('<div class="diff-overlay svelte-1pyfjii"><div class="diff-bar svelte-1pyfjii"><span class="diff-title svelte-1pyfjii">Commit <code> </code> → current — <em class="svelte-1pyfjii"> </em></span> <div class="diff-actions svelte-1pyfjii"><button class="discard-btn svelte-1pyfjii">Close</button></div></div> <!></div>'),xK=T('<div class="log-resize-handle svelte-1pyfjii" role="separator"></div>'),kK=T('<span class="log-file svelte-1pyfjii"> </span>'),LK=T("<option> </option>"),IK=T('<select class="log-filter-level svelte-1pyfjii"></select> <input class="log-filter-text svelte-1pyfjii" type="search" placeholder="Filter…"/> <label class="log-filter-regex svelte-1pyfjii" title="Interpret filter as a regular expression"><input type="checkbox" class="svelte-1pyfjii"/> <span class="log-filter-checkmark svelte-1pyfjii"></span> Regex</label> <button class="log-clear svelte-1pyfjii">Clear</button>',1),EK=T('<div><span class="ts svelte-1pyfjii"> </span> <span class="lvl svelte-1pyfjii"> </span> <span class="msg svelte-1pyfjii"> </span></div>'),DK=T('<span class="log-empty svelte-1pyfjii">No log output for this script.</span>'),TK=T('<div class="log-body svelte-1pyfjii"><!> <!></div>'),PK=T('<div class="chat-resize-handle svelte-1pyfjii" role="separator"></div> <div class="chat-container svelte-1pyfjii"><!></div>',1),MK=T('<!> <!> <!> <!> <div class="layout svelte-1pyfjii"><aside class="svelte-1pyfjii"><div class="toolbar svelte-1pyfjii"><button title="New script" class="svelte-1pyfjii">+ File</button> <button title="New folder" class="svelte-1pyfjii">+ Folder</button> <button title="Refresh" class="refresh svelte-1pyfjii">↻</button></div> <!> <ul class="tree svelte-1pyfjii"><li role="presentation"></li> <!></ul> <!></aside> <div class="sidebar-resize-handle svelte-1pyfjii" role="separator"></div> <div class="editor-area svelte-1pyfjii"><!> <div class="editor-toolbar svelte-1pyfjii"><span class="filename svelte-1pyfjii"> </span> <!> <div class="split-wrap svelte-1pyfjii"><div class="split-btn svelte-1pyfjii"><button class="split-main svelte-1pyfjii"> </button> <button class="split-arrow svelte-1pyfjii" aria-label="Save options">▾</button></div> <!></div> <!> <button><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"><line x1="5.5" y1="5" x2="4" y2="2.5"></line><line x1="10.5" y1="5" x2="12" y2="2.5"></line><path d="M3 11 V7 A5 3.5 0 0 0 13 7 V11 Z" stroke-linejoin="round"></path><circle cx="6" cy="8.2" r="0.7" fill="currentColor" stroke="none"></circle><circle cx="10" cy="8.2" r="0.7" fill="currentColor" stroke="none"></circle></svg> AI</button></div> <div class="editor-body svelte-1pyfjii"><div class="editor-left svelte-1pyfjii"><div class="editor-stack svelte-1pyfjii"><div class="editor-container svelte-1pyfjii"></div> <!> <!> <!></div> <div><!> <div class="log-header svelte-1pyfjii"><button class="log-toggle svelte-1pyfjii"> <!></button> <!></div> <!></div></div> <!></div></div></div>',1);function RK(o,e){Ts(e,!0);let t=P(yi([])),i=P(yi({})),n=P(null),s=P(null),r=P(null),a=P(null),d=P(yi([])),u=P(null),f=P(!1),g=P(""),p=P(!1),w=P(!0),y=P(null),x=P(!1),k=P(!1),D=P(null),M=P(yi([])),F=P(!1),K=P(30),V=P(void 0),se=null,te=null,pe=null,je=P(!1),Ke=P(""),ue=P(!1),He=P(void 0),dt=P(yi(new Set));const we=new Set;let gt=P(yi(new Set)),ot=P(yi([])),Pt=P("all"),Oe=P(""),Mt=P(!1);const et=["all","debug","info","warn","error"],ct={debug:0,info:1,warn:2,error:3};function Nt(q){if(c(Pt)!=="all"&&ct[q.level]<ct[c(Pt)])return!1;if(!c(Oe))return!0;if(c(Mt))try{return new RegExp(c(Oe),"i").test(q.msg)}catch{}return q.msg.toLowerCase().includes(c(Oe).toLowerCase())}let ti=P(null);function ri(q){const ve=q.currentTarget.getBoundingClientRect();v(ti,{x:ve.left,y:ve.top},!0)}function Vt(){v(ti,null)}let Me,jt,ft,ht=!1,he=null,Xe=null,Ut=!1,wi=!1,Ri=P(!1),ci=P(null),Bt=P(!1),Xt=P(!1),pt=P(void 0),Bi=null,Ti=null,Ni=null,Ki=P(yi(parseInt(localStorage.getItem("she-scripts-sidebar-width")??"220",10))),Ai=P(yi(parseInt(localStorage.getItem("she-scripts-log-height")??"130",10))),Di=P(yi(parseInt(localStorage.getItem("she-scripts-chat-width")??"340",10))),$i=P(yi(parseInt(localStorage.getItem("she-scripts-history-height")??"220",10))),Gi=!1,Ui=0,mn=0,rt=!1,Kt=0,_i=0,Pi=!1,Li=0,Si=0,Oi=!1,qi=0,mi=0;const Ue=Ct(()=>{var q;return c(u)&&c(ae)?{path:c(u),content:((q=c(ae).model)==null?void 0:q.getValue())??c(ae).savedContent}:null}),J=Ct(()=>{var q;return new Set(((q=c(y))==null?void 0:q.changes.map(ve=>ve.file))??[])}),Qe=Ct(()=>{const q=new Set;for(const ve of c(J)){const Ye=ve.split("/");for(let Te=1;Te<Ye.length;Te++)q.add(Ye.slice(0,Te).join("/"))}return q});let _t=P(!1),yt=P(!1),Ot=P(""),j=P(!1),ce=P(""),ke=P(yi(new Set));async function ze(){var q;if(!(!c(Ot).trim()||c(ke).size===0)){v(j,!0),v(ce,"");try{const ve=c(y).changes.filter(Ye=>c(ke).has(Ye.file)).map(Ye=>Ye.file);if(ve.length===c(y).changes.length?await zE(c(Ot).trim()):await BE(ve,c(Ot).trim()),c(k))try{await xm()}catch{}v(Ot,""),await qt(),(q=c(y))!=null&&q.changes.length?v(ke,new Set(c(y).changes.map(Ye=>Ye.file)),!0):v(_t,!1)}catch(ve){v(ce,ve.message,!0)}finally{v(j,!1)}}}let st,X,ae=Ct(()=>c(d).find(q=>q.path===c(u))??null);const me="she-tabs",Ze="she-active-tab",Zt="she-log-open",bt="she-chat-open";let We=Su(e,"active",3,!0);Vn(()=>{wi&&(localStorage.setItem(me,JSON.stringify(c(d).map(q=>q.path))),c(u)?localStorage.setItem(Ze,c(u)):localStorage.removeItem(Ze))}),Vn(()=>{wi&&localStorage.setItem(bt,String(c(Ri)))}),Vn(()=>{We()&&jt&&jt.layout()});const At=`
153
- declare const she: {
154
- log(...args: any[]): void;
155
- info(...args: any[]): void;
156
- debug(...args: any[]): void;
157
- warn(...args: any[]): void;
158
- error(...args: any[]): void;
159
- now(): number;
160
- /** Schedule with a cron string, Date, node-schedule literal, array of any of those,
161
- * or a suncalc event name ('sunrise', 'sunset', 'dawn', 'dusk', …) for solar scheduling.
162
- * opts.shift (seconds) offsets solar events; opts.random adds a random delay. */
163
- schedule(pattern: string | Date | object | (string | Date | object)[], opts?: { shift?: number; random?: number }, cb?: () => void): void;
164
- mqtt: {
165
- sub(topic: string | string[], opts?: any, cb?: (topic: string, val: any, obj: any, prev: any, msg: any) => void): void;
166
- pub(topic: string | string[], payload: any, opts?: { qos?: number; retain?: boolean }): void;
167
- get(topic: string): any;
168
- getProp(topic: string, ...prop: string[]): any;
169
- link(source: string | string[], target: string | string[], value?: any): void;
170
- age(topic: string): number;
171
- or(srcs: string[], target: string | ((topic: string | null, val: 0 | 1) => void)): void;
172
- and(srcs: string[], target: string | ((topic: string | null, val: 0 | 1) => void)): void;
173
- max(srcs: string[], target: string | ((topic: string | null, val: number) => void)): void;
174
- min(srcs: string[], target: string | ((topic: string | null, val: number) => void)): void;
175
- timer(src: string | string[], ms: number, target: string | ((topic: string | null, val: 0 | 1) => void)): void;
176
- };
177
- http: {
178
- fetch(url: string, opts?: RequestInit): Promise<any>;
179
- sub(path: string, callback: (body: any, req: { params: any; query: any; headers: any }) => any): void;
180
- };
181
- api: {
182
- get(path: string, handler: (req: any) => any): void;
183
- post(path: string, handler: (req: any, body: any) => any): void;
184
- put(path: string, handler: (req: any, body: any) => any): void;
185
- delete(path: string, handler: (req: any) => any): void;
186
- };
187
- db: {
188
- get(id: string): any;
189
- set(id: string, doc: object): void;
190
- extend(id: string, partial: object): void;
191
- delete(id: string): void;
192
- prop(id: string, method: 'set' | 'create' | 'del', prop: string, val?: any): void;
193
- sub(pattern: string, callback: (id: string, doc: any) => void): void;
194
- query(filter: string | null, mapFn: Function, reduceFn?: Function): any[];
195
- };
196
- matter: {
197
- sub(nodeId: string, endpointId: number, cluster: string, attr: string, cb: (val: any, old: any) => void): number;
198
- unsub(listenerId: number): void;
199
- get(nodeId: string, endpointId: number, cluster: string, attr: string): Promise<any>;
200
- send(nodeId: string, endpointId: number, cluster: string, command: string, args?: object): Promise<any>;
201
- on(nodeId: string, endpointId: number, cluster: string, event: string, cb: (val: any) => void): number;
202
- };
203
- influx: {
204
- query(fluxQuery: string): Promise<any[]>;
205
- write(measurement: string, fields: object, tags?: object, timestamp?: number | Date): Promise<void>;
206
- getLast(topic: string, n: number): Promise<Array<{ ts: number; val: any }>>;
207
- getRange(topic: string, from: number | string | Date, to: number | string | Date): Promise<Array<{ ts: number; val: any }>>;
208
- };
209
- elastic: {
210
- search(index: string, query: object): Promise<{ hits: any[]; total: number }>;
211
- get(index: string, id: string): Promise<object | null>;
212
- index(index: string, doc: object, id?: string): Promise<{ id: string }>;
213
- find(index: string, field: string, text: string, size?: number): Promise<any[]>;
214
- };
215
- };
216
- `;function ai(q){c(d).some(ve=>ve.dirty)&&q.preventDefault()}Bs(async()=>{var Te;window.addEventListener("beforeunload",ai),v(w,localStorage.getItem(Zt)!=="false"),v(Ri,localStorage.getItem(bt)==="true"),od.typescript.javascriptDefaults.addExtraLib(At,"she-api.d.ts"),od.typescript.javascriptDefaults.setCompilerOptions({target:od.typescript.ScriptTarget.ES2022,allowNonTsExtensions:!0,checkJs:!0}),od.typescript.javascriptDefaults.setDiagnosticsOptions({noSyntaxValidation:!1,noSemanticValidation:!0}),OG(),ft=mr.createModel("","javascript"),jt=mr.create(Me,{model:ft,theme:"vs-dark",automaticLayout:!0,minimap:{enabled:!1},fontSize:14,lineNumbers:"on",scrollBeyondLastLine:!1}),jt.onDidChangeModelContent(()=>{if(ht)return;const Rt=c(d).find(fi=>fi.path===c(u));Rt&&(Rt.dirty=jt.getValue()!==Rt.savedContent),Tt&&clearTimeout(Tt),Tt=setTimeout(it,600)}),he=Rk(Rt=>{const fi=Rt.msg.match(/^([^:\n]+\.js):\s/);if(!fi)return;const ki=fi[1];if(Rt.level==="error")we.add(ki),c(dt).has(ki)||v(dt,new Set([...c(dt),ki]),!0);else if(we.has(ki)){we.delete(ki);const en=new Set(c(dt));en.delete(ki),v(dt,en,!0)}const hn=c(d).find(en=>en.path===ki);hn&&(hn.logEntries=[...hn.logEntries.slice(-199),Rt],hn.path===c(u)&&c(w)&&c(He)&&Gg().then(()=>{c(He)&&(c(He).scrollTop=c(He).scrollHeight)}))}),Xe=cr("script:running",Rt=>{const fi=Rt.path;if(Rt.running)v(gt,new Set([...c(gt),fi]),!0);else{const ki=new Set(c(gt));ki.delete(fi),v(gt,ki,!0)}}),await zt(),qt();try{const Rt=await Pl();typeof Rt.gitAutoCommit=="boolean"&&v(x,Rt.gitAutoCommit,!0),typeof Rt.gitAutoPush=="boolean"&&v(k,Rt.gitAutoPush,!0)}catch{}try{const Rt=await getDaemonStatus();v(gt,new Set(Rt.runningScripts??[]),!0)}catch{}const q=JSON.parse(localStorage.getItem(me)??"[]"),ve=localStorage.getItem(Ze);for(const Rt of q)await $e(Rt,!1);const Ye=ve&&c(d).some(Rt=>Rt.path===ve)?ve:((Te=c(d)[0])==null?void 0:Te.path)??null;Ye&&await Ft(Ye),wi=!0}),x_(()=>{var q;window.removeEventListener("beforeunload",ai),Tt&&clearTimeout(Tt),he==null||he(),Xe==null||Xe();for(const ve of c(d))(q=ve.model)==null||q.dispose();ft==null||ft.dispose(),jt==null||jt.dispose()});async function zt(){try{if(v(t,await PU(),!0),!Ut){let ve=function(Ye){for(const Te of Ye)Te.type==="dir"&&(q[Te.path]=!0,Te.children&&ve(Te.children))};Ut=!0;const q={};ve(c(t)),v(i,q,!0)}v(g,"")}catch(q){v(g,q.message,!0)}}function vi(q){c(i)[q]=!c(i)[q]}function hi(q){switch(q){case"SH":case"BASH":return"$";case"MD":case"MARKDOWN":return"⇓";case"JSON":case"JSONC":return"{}";default:return q}}async function Ci(q,ve){try{ve?await td(`${q}/.shelib`,""):await Cm(`${q}/.shelib`),await zt(),await Qt("all",ve?`lib ${q}`:`unlib ${q}`)}catch(Ye){v(g,Ye.message,!0)}}async function zi(q,ve){const Ye=q.split("/").pop(),Te=q.includes("/")?q.slice(0,q.lastIndexOf("/")):"",Rt=Te?`${Te}/.shedisable-${Ye}`:`.shedisable-${Ye}`;try{ve?await td(Rt,""):await Cm(Rt),await zt(),await Qt("all",ve?`disable ${q}`:`enable ${q}`)}catch(fi){v(g,fi.message,!0)}}async function $e(q,ve=!0){var Ye;if(c(d).some(Te=>Te.path===q)){ve&&await Ft(q);return}try{const{content:Te}=await gS(q),Rt=y3.parse(`file:///she-scripts/${encodeURIComponent(q)}`);(Ye=mr.getModel(Rt))==null||Ye.dispose();const fi=mr.createModel(Te,qe(q),Rt);v(d,[...c(d),{path:q,dirty:!1,savedContent:Te,model:fi,logEntries:[]}],!0),ve&&await Ft(q)}catch(Te){v(g,Te.message,!0)}}async function Fe(q){await $e(q,!0)}async function Ft(q){const ve=c(d).find(Ye=>Ye.path===q);ve!=null&&ve.model&&(oe(),v(ci,null),v(u,q,!0),ht=!0,jt.setModel(ve.model),ht=!1,it())}async function Yt(q){var Te;const ve=c(d).find(Rt=>Rt.path===q);if(!ve||ve.dirty&&!await st.show(`Discard unsaved changes to ${q}?`,{confirm:"Discard"}))return;const Ye=c(d).findIndex(Rt=>Rt.path===q);if((Te=ve.model)==null||Te.dispose(),v(d,c(d).filter(Rt=>Rt.path!==q),!0),c(u)===q){const Rt=c(d)[Ye]??c(d)[Ye-1]??null;Rt?await Ft(Rt.path):(v(u,null),jt.setModel(ft))}}async function qt(){try{v(y,await RU(),!0)}catch{v(y,null)}}async function Qt(q,ve){if(c(y))try{if(q==="all"?await zE(ve):await BE(q,ve),c(k))try{await xm()}catch{}await qt()}catch{}}async function re(){if(!c(u))return;const q=c(d).find(ve=>ve.path===c(u));if(q){v(f,!0);try{const ve=jt.getValue();await td(c(u),ve),q.savedContent=ve,q.dirty=!1,v(g,""),c(x)?await Qt([c(u)],`update ${c(u)}`):qt()}catch(ve){v(g,ve.message,!0)}finally{v(f,!1)}}}async function Ge(){if(!c(u)||(await re(),c(g)))return;const q=await X.show("Commit message:",{initial:`update ${c(u)}`,placeholder:"Update script",confirm:"Commit"});if(q)try{if(await OU(c(u),q),c(k))try{await xm()}catch{}qt()}catch(ve){v(g,"Git: "+ve.message)}}async function wt(){v(p,!1);try{await xm(),await qt(),v(g,"")}catch(q){v(g,"Git push: "+q.message)}}function vt(q){const ve=Date.now()-new Date(q).getTime(),Ye=Math.floor(ve/1e3);if(Ye<60)return"just now";const Te=Math.floor(Ye/60);if(Te<60)return`${Te}m ago`;const Rt=Math.floor(Te/60);if(Rt<24)return`${Rt}h ago`;const fi=Math.floor(Rt/24);if(fi<30)return`${fi}d ago`;const ki=Math.floor(fi/30);return ki<12?`${ki}mo ago`:`${Math.floor(ki/12)}y ago`}async function di(q){ie(),v(D,q,!0),v(M,[],!0),v(K,30),await It()}async function It(){if(c(D)){v(F,!0);try{v(M,await FU(c(D).path,c(K)),!0)}catch{}finally{v(F,!1)}}}async function Ii(){v(K,c(K)+30),await It()}function W(){v(D,null),v(M,[],!0),oe()}async function Q(q){if(!c(D))return;oe(),await Fe(c(D).path);let ve;try{ve=await HU(q.hash,c(D).path)}catch{return}if(v(Ke,q.hash,!0),v(ue,ve.binary,!0),v(je,!0),ve.binary||ve.content===null)return;let Ye="";const Te=c(d).find(fi=>fi.path===c(D).path);if(Te!=null&&Te.model)Ye=Te.model.getValue();else try{Ye=(await gS(c(D).path)).content}catch{}if(await Gg(),!c(V))return;const Rt=qe(c(D).path);te=mr.createModel(ve.content,Rt),pe=mr.createModel(Ye,Rt),se=mr.createDiffEditor(c(V),{theme:"vs-dark",readOnly:!0,renderSideBySide:!0,automaticLayout:!0,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1}),se.setModel({original:te,modified:pe})}function oe(){v(je,!1),v(ue,!1),se==null||se.dispose(),se=null,te==null||te.dispose(),te=null,pe==null||pe.dispose(),pe=null}async function $(){const q=c(n)?`${c(n)}/`:"",ve=await X.show("New script name:",{placeholder:q?`${q}myscript.js`:"myscript.js",initial:q,confirm:"Create"});if(!ve)return;const Ye=ve.endsWith(".js")?`/* global she */
217
- 'use strict';
218
-
219
- `:"";await td(ve,Ye),await zt(),await $e(ve,!0)}async function A(){const q=c(n)?`${c(n)}/`:"",ve=await X.show("New folder name:",{placeholder:q?`${q}subfolder`:"myfolder",initial:q,confirm:"Create"});ve&&(await MU(ve),c(i)[ve]=!0,await zt())}function G(q,ve){q.preventDefault(),v(s,{x:q.clientX,y:q.clientY,entry:ve},!0)}function ie(){v(s,null)}async function fe(q){ie(),v(n,q,!0),c(i)[q]=!0,await $()}async function Y(q){ie(),v(n,q,!0),await A()}async function le(q){ie();const ve=q.path.includes("/")?q.path.slice(0,q.path.lastIndexOf("/")+1):"",Ye=await X.show(q.type==="dir"?"Rename folder:":"Rename script:",{initial:q.name,placeholder:q.name,confirm:"Rename"});if(!Ye||Ye===q.name)return;const Te=ve+Ye;try{await WE(q.path,Te);const Rt=c(d).find(fi=>fi.path===q.path);Rt&&(Rt.path=Te,c(u)===q.path&&v(u,Te)),await zt(),await Qt("all",`rename ${q.path} → ${Te}`)}catch(Rt){v(g,Rt.message,!0)}}function Re(q){if(!q.children)return 0;let ve=0;for(const Ye of q.children)ve++,Ye.type==="dir"&&(ve+=Re(Ye));return ve}async function _e(q){ie();let ve=`Delete ${q.type==="dir"?"folder":"file"} "${q.path}"?`;if(q.type==="dir"){const Ye=Re(q);Ye>0&&(ve+=` This will also delete ${Ye} item${Ye===1?"":"s"} inside.`)}if(await st.show(ve,{confirm:"Delete",danger:!0})){if(q.type==="dir")for(const Ye of[...c(d)])Ye.path.startsWith(q.path+"/")&&await Yt(Ye.path);else await Yt(q.path);await Cm(q.path),await zt(),await Qt("all",`delete ${q.path}`)}}async function ge(q){ie();const{content:ve}=await gS(q.path);c(ot).some(Ye=>Ye.name===q.path)||v(ot,[...c(ot),{name:q.path,content:ve}],!0),v(Ri,!0)}function tt(q,ve){var Ye;v(r,ve,!0),(Ye=q.dataTransfer)==null||Ye.setData("text/plain",ve)}function U(q,ve){if(q.preventDefault(),c(r)&&(c(r)===ve||ve.startsWith(c(r)+"/"))){q.dataTransfer&&(q.dataTransfer.dropEffect="none"),v(a,null);return}q.dataTransfer&&(q.dataTransfer.dropEffect="move"),v(a,ve,!0)}function ne(){v(a,null)}async function Le(q,ve){var ki,hn,en;q.preventDefault(),v(a,null);const Ye=Array.from(((ki=q.dataTransfer)==null?void 0:ki.items)??[]).filter(bn=>bn.kind==="file");if(Ye.length>0&&!c(r)){for(const bn of Ye){const tn=(hn=bn.webkitGetAsEntry)==null?void 0:hn.call(bn);tn&&await Ve(tn,ve,!0)}await zt();return}const Te=c(r)??((en=q.dataTransfer)==null?void 0:en.getData("text/plain"));if(v(r,null),!Te||Te===ve||ve.startsWith(Te+"/"))return;const Rt=Te.split("/").pop(),fi=ve?`${ve}/${Rt}`:Rt;if(fi!==Te)try{await WE(Te,fi);for(const bn of c(d))if(bn.path===Te)c(u)===Te&&v(u,fi,!0),bn.path=fi;else if(bn.path.startsWith(Te+"/")){const tn=fi+bn.path.slice(Te.length);c(u)===bn.path&&v(u,tn),bn.path=tn}await zt(),await Qt("all",`rename ${Te} → ${fi}`)}catch(bn){v(g,bn.message,!0)}}async function Ve(q,ve,Ye){if(q.isFile){const Rt=await(await new Promise((ki,hn)=>q.file(ki,hn))).text(),fi=ve?`${ve}/${q.name}`:q.name;await td(fi,Rt),Ye&&q.name.endsWith(".js")&&await zi(fi,!0)}else if(q.isDirectory){const Te=q.createReader();let Rt=[],fi;do fi=await new Promise((ki,hn)=>Te.readEntries(ki,hn)),Rt=[...Rt,...fi];while(fi.length>0);for(const ki of Rt)await Ve(ki,ve?`${ve}/${q.name}`:q.name,!1);if(Ye){const ki=ve?`${ve}/${q.name}`:q.name;await zi(ki,!0)}}}async function De(){if(!c(u)||!await st.show(`Delete ${c(u)}?`,{confirm:"Delete",danger:!0}))return;const q=c(u);await Yt(q),await Cm(q),await zt(),await Qt("all",`delete ${q}`)}function Ie(){c(ae)&&(c(ae).logEntries=[])}function St(){v(w,!c(w)),localStorage.setItem(Zt,String(c(w)))}function mt(q){return new Date(q).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function qe(q){var Te;const ve=((Te=q.split(".").pop())==null?void 0:Te.toLowerCase())??"";return{js:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",tsx:"typescript",json:"json",jsonc:"json",md:"markdown",markdown:"markdown",yaml:"yaml",yml:"yaml",sh:"shell",bash:"shell",css:"css",html:"html",xml:"xml",ini:"ini",toml:"ini"}[ve]??"plaintext"}let Tt=null;async function it(){const q=c(d).find(Ye=>Ye.path===c(u));if(!(q!=null&&q.model))return;const ve=q.model;try{const fi=(await(await(await od.typescript.getJavaScriptWorker())(ve.uri)).getSyntacticDiagnostics(ve.uri.toString())).map(ki=>{const hn=ve.getPositionAt(ki.start??0),en=ve.getPositionAt((ki.start??0)+(ki.length??0));return{severity:w3.Error,startLineNumber:hn.lineNumber,startColumn:hn.column,endLineNumber:en.lineNumber,endColumn:en.column,message:typeof ki.messageText=="string"?ki.messageText:JSON.stringify(ki.messageText),source:"she-syntax"}});if(mr.setModelMarkers(ve,"she-syntax",fi),c(u)){if(fi.length>0)we.add(c(u)),c(dt).has(c(u))||v(dt,new Set([...c(dt),c(u)]),!0);else if(we.has(c(u))){we.delete(c(u));const ki=new Set(c(dt));ki.delete(c(u)),v(dt,ki,!0)}}}catch{}}function ye(q){Gi=!0,Ui=q.clientX,mn=c(Ki),q.preventDefault()}function Ne(q){rt=!0,Kt=q.clientY,_i=c(Ai),q.preventDefault()}function Ee(q){Pi=!0,Li=q.clientX,Si=c(Di),q.preventDefault()}function Se(q){Oi=!0,qi=q.clientY,mi=c($i),q.preventDefault()}function nt(q){Gi&&v(Ki,Math.max(140,Math.min(500,mn+q.clientX-Ui)),!0),rt&&v(Ai,Math.max(60,Math.min(500,_i-(q.clientY-Kt))),!0),Pi&&v(Di,Math.max(200,Math.min(700,Si-(q.clientX-Li))),!0),Oi&&v($i,Math.max(80,Math.min(600,mi-(q.clientY-qi))),!0)}function de(){Gi&&(Gi=!1,localStorage.setItem("she-scripts-sidebar-width",String(c(Ki)))),rt&&(rt=!1,localStorage.setItem("she-scripts-log-height",String(c(Ai)))),Pi&&(Pi=!1,localStorage.setItem("she-scripts-chat-width",String(c(Di)))),Oi&&(Oi=!1,localStorage.setItem("she-scripts-history-height",String(c($i))))}function Pe(q){(q.ctrlKey||q.metaKey)&&q.key==="s"&&(q.preventDefault(),re()),q.key==="Escape"&&(v(p,!1),v(s,null),v(yt,!1))}async function at(q,ve){const Ye=await X.show("Save new script as:",{placeholder:"myscript.js",initial:q,confirm:"Create"});if(Ye)try{await td(Ye,ve),await zt(),await $e(Ye,!0)}catch(Te){v(g,Te.message,!0)}}async function ut(q){var Ye,Te;if(c(Bt)&&c(u)){v(ci,q,!0),await Je();return}if(v(ci,q,!0),await Gg(),!c(pt))return;Ti==null||Ti.dispose(),Ni==null||Ni.dispose(),Bi==null||Bi.dispose();const ve=((Te=(Ye=c(ae))==null?void 0:Ye.model)==null?void 0:Te.getValue())??"";Ti=mr.createModel(ve,"javascript"),Ni=mr.createModel(q,"javascript"),Bi=mr.createDiffEditor(c(pt),{theme:"vs-dark",readOnly:!0,renderSideBySide:!0,automaticLayout:!0,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1}),Bi.setModel({original:Ti,modified:Ni})}Vn(()=>{c(u),v(Bt,!1),v(Xt,!1)});async function Je(){if(c(ci)===null||!c(u))return;const q=c(ci);v(ci,null);const ve=c(d).find(Ye=>Ye.path===c(u));ve!=null&&ve.model&&(ht=!0,ve.model.setValue(q),ht=!1,ve.dirty=!1,ve.savedContent=q);try{await td(c(u),q),v(g,""),c(x)?await Qt([c(u)],`update ${c(u)}`):qt()}catch(Ye){v(g,Ye.message,!0)}Jt()}function $t(){v(ci,null),Jt()}function Jt(){Bi==null||Bi.dispose(),Bi=null,Ti==null||Ti.dispose(),Ti=null,Ni==null||Ni.dispose(),Ni=null}var Mi=MK();ds("keydown",xd,Pe),ds("mousemove",xd,nt),ds("mouseup",xd,de);var ii=xt(Mi);vs(Uc(ii,{}),q=>st=q,()=>st);var xi=m(ii,2);vs(Fq(xi,{}),q=>X=q,()=>X);var Ji=m(xi,2);{var Hi=q=>{var ve=BG(),Ye=xt(ve),Te=m(Ye,2);let Rt;var fi=b(Te);{var ki=en=>{var bn=FG(),tn=xt(bn),fn=m(tn,2),sn=m(fn,4),Bn=m(sn,2);z("click",tn,()=>fe(c(s).entry.path)),z("click",fn,()=>Y(c(s).entry.path)),z("click",sn,()=>le(c(s).entry)),z("click",Bn,()=>_e(c(s).entry)),I(en,bn)},hn=en=>{var bn=WG(),tn=xt(bn),fn=m(tn,2),sn=m(fn,2),Bn=m(sn,2);{var Xn=an=>{var gs=HG();z("click",gs,()=>di(c(s).entry)),I(an,gs)};O(Bn,an=>{c(y)&&an(Xn)})}var Gn=m(Bn,4);z("click",tn,()=>Fe(c(s).entry.path)),z("click",fn,()=>le(c(s).entry)),z("click",sn,()=>ge(c(s).entry)),z("click",Gn,()=>_e(c(s).entry)),I(en,bn)};O(fi,en=>{c(s).entry.type==="dir"?en(ki):en(hn,-1)})}H(()=>Rt=zo(Te,"",Rt,{left:`${c(s).x??""}px`,top:`${c(s).y??""}px`})),z("click",Ye,ie),z("contextmenu",Ye,en=>{en.preventDefault(),ie()}),I(q,ve)};O(Ji,q=>{c(s)&&q(Hi)})}var li=m(Ji,2);{var un=q=>{var ve=zG();let Ye;H(()=>Ye=zo(ve,"",Ye,{left:`${c(ti).x??""}px`,top:`${c(ti).y-4}px`})),I(q,ve)};O(li,q=>{c(ti)&&q(un)})}var rn=m(li,2),es=b(rn);let js;{const q=(Ye,Te=Hy,Rt)=>{let fi=E0(()=>E3(Rt==null?void 0:Rt(),!1));var ki=As(),hn=xt(ki);{var en=tn=>{var fn=jG(),sn=b(fn);let Bn;var Xn=b(sn);let Gn;var an=m(Xn,2);let gs;var $s=b(an),xs=m(an,2);{var ls=kn=>{var er=fD();I(kn,er)},ss=Ct(()=>c(J).has(Te().path)||c(Qe).has(Te().path));O(xs,kn=>{c(ss)&&kn(ls)})}var ps=m(xs,2),ks=b(ps),Us=m(ps,2),_a=b(Us),jr=m(sn,2);{var qs=kn=>{var er=VG();ni(er,21,()=>Te().children,Ns=>Ns.path,(Ns,$r)=>{q(Ns,()=>c($r),()=>Te().disabled||c(fi))}),I(kn,er)};O(jr,kn=>{c(i)[Te().path]&&Te().children&&kn(qs)})}H(()=>{Bn=kt(sn,1,"dir-row svelte-1pyfjii",null,Bn,{"dir-selected":c(n)===Te().path,"drag-target":c(a)===Te().path}),ln(sn,"aria-selected",c(n)===Te().path),Gn=kt(Xn,1,"chevron svelte-1pyfjii",null,Gn,{open:c(i)[Te().path]}),gs=kt(an,1,"dir-name svelte-1pyfjii",null,gs,{lib:Te().lib}),N($s,Te().name),hl(ks,Te().lib),hl(_a,Te().disabled)}),ds("dragstart",sn,kn=>tt(kn,Te().path)),ds("dragover",sn,kn=>U(kn,Te().path)),ds("dragleave",sn,ne),ds("drop",sn,kn=>Le(kn,Te().path)),z("contextmenu",sn,kn=>G(kn,Te())),z("click",Xn,()=>vi(Te().path)),z("click",an,()=>{v(n,Te().path,!0),c(i)[Te().path]=!0}),z("keydown",an,kn=>kn.key==="Enter"&&v(n,Te().path,!0)),ds("mouseenter",ps,ri),ds("mouseleave",ps,Vt),z("change",ks,()=>Ci(Te().path,!Te().lib)),z("change",_a,()=>zi(Te().path,!Te().disabled)),I(tn,fn)},bn=tn=>{const fn=Ct(()=>c(dt).has(Te().path)),sn=Ct(()=>c(J).has(Te().path)),Bn=Ct(()=>c(d).some(Mn=>Mn.path===Te().path&&Mn.dirty)),Xn=Ct(()=>(Te().name.split(".").pop()??"txt").toUpperCase()),Gn=Ct(()=>Te().name.endsWith(".js"));var an=ZG();let gs;var $s=b(an),xs=b($s);let ls;var ss=b(xs);let ps;var ks=b(ss),Us=m(ss,2),_a=b(Us),jr=m(Us,2);{var qs=Mn=>{var bs=fD();I(Mn,bs)};O(jr,Mn=>{c(sn)&&Mn(qs)})}var kn=m(jr);{var er=Mn=>{var bs=$G();I(Mn,bs)};O(kn,Mn=>{c(Bn)&&Mn(er)})}var Ns=m(kn,2);{var $r=Mn=>{var bs=UG();I(Mn,bs)},cg=Ct(()=>c(Gn)&&c(gt).has(Te().path)&&!c(fn));O(Ns,Mn=>{c(cg)&&Mn($r)})}var Vl=m(Ns,2);{var dg=Mn=>{var bs=qG();I(Mn,bs)};O(Vl,Mn=>{c(fn)&&Mn(dg)})}var Ur=m(xs,2);{var vw=Mn=>{var bs=GG();let Yc;var Qu=b(bs);H(()=>{Yc=kt(bs,1,"dis-label svelte-1pyfjii",null,Yc,{"dis-locked":c(fi)}),ln(bs,"title",c(fi)?"Disabled by parent directory":"Disable — this script will not be executed"),hl(Qu,Te().disabled),Qu.disabled=c(fi)}),z("change",Qu,()=>zi(Te().path,!Te().disabled)),I(Mn,bs)},Zc=Mn=>{var bs=KG();I(Mn,bs)};O(Ur,Mn=>{c(Gn)?Mn(vw):Mn(Zc,-1)})}H((Mn,bs,Yc)=>{gs=kt(an,1,"tree-file svelte-1pyfjii",null,gs,Mn),ls=kt(xs,1,"svelte-1pyfjii",null,ls,{lib:Te().lib,dis:Te().disabled,err:c(fn)}),ps=kt(ss,1,`badge badge-${bs??""}`,"svelte-1pyfjii",ps,{"badge-shelib":Te().lib}),N(ks,Yc),N(_a,Te().name)},[()=>({active:c(d).some(Mn=>Mn.path===Te().path),"active-tab":Te().path===c(u)}),()=>c(Xn).toLowerCase(),()=>hi(c(Xn))]),ds("dragstart",an,Mn=>tt(Mn,Te().path)),z("contextmenu",an,Mn=>G(Mn,Te())),z("click",xs,()=>Fe(Te().path)),I(tn,an)};O(hn,tn=>{Te().type==="dir"?tn(en):tn(bn,-1)})}I(Ye,ki)};var fo=b(es),Zo=b(fo),hr=m(Zo,2),Yn=m(hr,2),Yo=m(fo,2);{var fr=Ye=>{var Te=YG(),Rt=b(Te);H(()=>N(Rt,c(g))),I(Ye,Te)};O(Yo,Ye=>{c(g)&&Ye(fr)})}var vn=m(Yo,2),Ms=b(vn);let ve;var fs=m(Ms,2);ni(fs,17,()=>c(t),Ye=>Ye.path,(Ye,Te)=>{q(Ye,()=>c(Te))});var ns=m(vn,2);{var Rs=Ye=>{var Te=iK();let Rt;var fi=b(Te),ki=m(fi,2),hn=b(ki),en=b(hn),bn=m(hn,2),tn=m(ki,2),fn=b(tn);{var sn=Gn=>{var an=XG();I(Gn,an)},Bn=Gn=>{var an=QG();I(Gn,an)},Xn=Gn=>{var an=tK(),gs=xt(an);ni(gs,17,()=>c(M),ls=>ls.hash,(ls,ss)=>{var ps=JG(),ks=b(ps),Us=b(ks),_a=m(ks,2),jr=b(_a);H((qs,kn)=>{N(Us,c(ss).subject),N(jr,`${qs??""} · ${kn??""}`)},[()=>c(ss).hash.slice(0,7),()=>vt(c(ss).date)]),z("click",ps,()=>Q(c(ss))),I(ls,ps)});var $s=m(gs,2);{var xs=ls=>{var ss=eK(),ps=b(ss);H(()=>{ss.disabled=c(F),N(ps,c(F)?"Loading…":"Load more")}),z("click",ss,Ii),I(ls,ss)};O($s,ls=>{c(M).length>=c(K)&&ls(xs)})}I(Gn,an)};O(fn,Gn=>{c(F)&&c(M).length===0?Gn(sn):c(M).length===0?Gn(Bn,1):Gn(Xn,-1)})}H(()=>{Rt=zo(Te,"",Rt,{height:`${c($i)??""}px`}),ln(hn,"title",c(D).path),N(en,`History: ${c(D).name??""}`)}),z("mousedown",fi,Se),z("click",bn,W),I(Ye,Te)};O(ns,Ye=>{c(D)&&Ye(Rs)})}H(()=>ve=kt(Ms,1,"tree-root-drop svelte-1pyfjii",null,ve,{"drag-target":c(a)===""})),z("click",Zo,$),z("click",hr,A),z("click",Yn,zt),ds("dragover",Ms,Ye=>U(Ye,"")),ds("dragleave",Ms,ne),ds("drop",Ms,Ye=>Le(Ye,""))}var Wr=m(es,2),Za=m(Wr,2),Wl=b(Za);{var Ya=q=>{var ve=oK();ni(ve,21,()=>c(d),Ye=>Ye.path,(Ye,Te)=>{var Rt=sK();let fi;var ki=b(Rt),hn=b(ki),en=m(ki,2);{var bn=fn=>{var sn=nK();I(fn,sn)};O(en,fn=>{c(Te).dirty&&fn(bn)})}var tn=m(en,2);H(fn=>{fi=kt(Rt,1,"tab svelte-1pyfjii",null,fi,{active:c(Te).path===c(u)}),N(hn,fn)},[()=>c(Te).path.split("/").pop()]),z("click",Rt,()=>Ft(c(Te).path)),z("keydown",Rt,fn=>fn.key==="Enter"&&Ft(c(Te).path)),z("click",tn,fn=>{fn.stopPropagation(),Yt(c(Te).path)}),I(Ye,Rt)}),I(q,ve)};O(Wl,q=>{c(d).length>0&&q(Ya)})}var Xo=m(Wl,2),Br=b(Xo),zr=b(Br),F_=m(Br,2);{var gr=q=>{var ve=fK(),Ye=b(ve),Te=b(Ye),Rt=m(Ye,2);{var fi=tn=>{var fn=cK(),sn=b(fn),Bn=b(sn),Xn=m(sn,2);{var Gn=an=>{var gs=lK(),$s=xt(gs),xs=m($s,2),ls=m(b(xs),2);ni(ls,21,()=>c(y).changes,Vi,(qs,kn)=>{var er=rK(),Ns=b(er),$r=m(Ns,2),cg=b($r),Vl=m($r,2),dg=b(Vl);H(Ur=>{hl(Ns,Ur),N(cg,c(kn).status),N(dg,c(kn).file)},[()=>c(ke).has(c(kn).file)]),z("change",Ns,()=>{const Ur=new Set(c(ke));Ur.has(c(kn).file)?Ur.delete(c(kn).file):Ur.add(c(kn).file),v(ke,Ur,!0)}),I(qs,er)});var ss=m(ls,2),ps=b(ss),ks=m(ps,2),Us=b(ks),_a=m(ss,2);{var jr=qs=>{var kn=aK(),er=b(kn);H(()=>N(er,c(ce))),I(qs,kn)};O(_a,qs=>{c(ce)&&qs(jr)})}H(qs=>{var kn;ks.disabled=qs,N(Us,c(j)?"…":c(ke).size===((kn=c(y))==null?void 0:kn.changes.length)?"Commit all":`Commit ${c(ke).size}`)},[()=>!c(Ot).trim()||c(j)||c(ke).size===0]),z("click",$s,()=>v(_t,!1)),z("keydown",ps,qs=>qs.key==="Enter"&&ze()),Ht(ps,()=>c(Ot),qs=>v(Ot,qs)),z("click",ks,ze),I(an,gs)};O(Xn,an=>{c(_t)&&an(Gn)})}H(()=>{ln(sn,"title",`${c(y).changes.length??""} uncommitted change(s) — click to view`),N(Bn,`✎${c(y).changes.length??""}`)}),z("click",sn,()=>{c(_t)||v(ke,new Set(c(y).changes.map(an=>an.file)),!0),v(_t,!c(_t)),v(ce,"")}),I(tn,fn)};O(Rt,tn=>{c(y).changes.length>0&&tn(fi)})}var ki=m(Rt,2);{var hn=tn=>{var fn=uK(),sn=b(fn),Bn=b(sn),Xn=m(sn,2);{var Gn=an=>{var gs=dK(),$s=xt(gs),xs=m($s,2),ls=b(xs),ss=b(ls),ps=m(ls,2),ks=b(ps);H(()=>N(ss,`${c(y).ahead??""} unpushed commit(s)`)),z("click",$s,()=>v(yt,!1)),z("click",ks,()=>{v(yt,!1),wt()}),I(an,gs)};O(Xn,an=>{c(yt)&&an(Gn)})}H(()=>{ln(sn,"title",`${c(y).ahead??""} commit(s) ahead of upstream — click to push`),N(Bn,`↑${c(y).ahead??""}`)}),z("click",sn,()=>v(yt,!c(yt))),I(tn,fn)};O(ki,tn=>{c(y).ahead>0&&tn(hn)})}var en=m(ki,2);{var bn=tn=>{var fn=hK(),sn=b(fn);H(()=>{ln(fn,"title",`${c(y).behind??""} commit(s) behind upstream`),N(sn,`↓${c(y).behind??""}`)}),I(tn,fn)};O(en,tn=>{c(y).behind>0&&tn(bn)})}H(()=>{ln(Ye,"title",`Branch: ${c(y).branch??""}`),N(Te,`⎇ ${c(y).branch??""}`)}),I(q,ve)};O(F_,q=>{c(y)&&q(gr)})}var H_=m(F_,2),tg=b(H_),Qo=b(tg),W_=b(Qo),ig=m(Qo,2),ng=m(tg,2);{var fw=q=>{var ve=gK(),Ye=xt(ve),Te=m(Ye,2),Rt=b(Te),fi=m(Rt,2);z("click",Ye,()=>v(p,!1)),z("click",Rt,()=>{v(p,!1),re()}),z("click",fi,()=>{v(p,!1),Ge()}),I(q,ve)};O(ng,q=>{c(p)&&q(fw)})}var sg=m(H_,2);{var B_=q=>{var ve=pK();z("click",ve,De),I(q,ve)};O(sg,q=>{c(u)&&q(B_)})}var og=m(sg,2);let z_;var rg=m(Xo,2),V_=b(rg),ag=b(V_),lg=b(ag);vs(lg,q=>Me=q,()=>Me);var qc=m(lg,2);{var Xa=q=>{var ve=_K();I(q,ve)};O(qc,q=>{c(u)||q(Xa)})}var j_=m(qc,2);{var Gc=q=>{var ve=yK(),Ye=b(ve),Te=b(Ye),Rt=m(b(Te)),fi=b(Rt),ki=m(Te,2),hn=b(ki),en=b(hn),bn=b(en),tn=b(bn),fn=m(bn,2),sn=m(en,2);{var Bn=an=>{var gs=bK(),$s=xt(gs),xs=m($s,2),ls=b(xs);{var ss=ks=>{var Us=mK();z("click",Us,()=>{v(Xt,!1),v(Bt,!0),Je()}),I(ks,Us)},ps=ks=>{var Us=vK();z("click",Us,()=>{v(Xt,!1),v(Bt,!1)}),I(ks,Us)};O(ls,ks=>{c(Bt)?ks(ps,-1):ks(ss)})}z("click",$s,()=>v(Xt,!1)),I(an,gs)};O(sn,an=>{c(Xt)&&an(Bn)})}var Xn=m(hn,2),Gn=m(Ye,2);vs(Gn,an=>v(pt,an),()=>c(pt)),H(an=>{N(fi,an),N(tn,c(Bt)?"Auto-accept ✓":"Accept")},[()=>{var an;return(an=c(u))==null?void 0:an.split("/").pop()}]),z("click",bn,Je),z("click",fn,()=>v(Xt,!c(Xt))),z("click",Xn,$t),I(q,ve)};O(j_,q=>{c(ci)!==null&&q(Gc)})}var No=m(j_,2);{var $_=q=>{var ve=CK(),Ye=b(ve),Te=b(Ye),Rt=m(b(Te)),fi=b(Rt),ki=m(Rt,2),hn=b(ki),en=m(Te,2),bn=b(en),tn=m(Ye,2);{var fn=Bn=>{var Xn=wK();I(Bn,Xn)},sn=Bn=>{var Xn=SK();vs(Xn,Gn=>v(V,Gn),()=>c(V)),I(Bn,Xn)};O(tn,Bn=>{c(ue)?Bn(fn):Bn(sn,-1)})}H(Bn=>{var Xn;N(fi,Bn),N(hn,(Xn=c(D))==null?void 0:Xn.name)},[()=>c(Ke).slice(0,7)]),z("click",bn,oe),I(q,ve)};O(No,q=>{c(je)&&q($_)})}var Ku=m(ag,2);let U_,Zu;var Yu=b(Ku);{var gw=q=>{var ve=xK();z("mousedown",ve,Ne),I(q,ve)};O(Yu,q=>{c(w)&&q(gw)})}var q_=m(Yu,2),Xu=b(q_),G_=b(Xu),Jo=m(G_);{var Bl=q=>{var ve=kK(),Ye=b(ve);H(Te=>N(Ye,`— ${Te??""}`),[()=>c(u).split("/").pop()]),I(q,ve)};O(Jo,q=>{c(u)&&q(Bl)})}var pw=m(Xu,2);{var Vr=q=>{var ve=IK(),Ye=xt(ve);ni(Ye,21,()=>et,Vi,(hn,en)=>{var bn=LK(),tn=b(bn),fn={};H(()=>{N(tn,c(en)),fn!==(fn=c(en))&&(bn.value=(bn.__value=c(en))??"")}),I(hn,bn)});var Te=m(Ye,2),Rt=m(Te,2),fi=b(Rt),ki=m(Rt,2);ys(Ye,()=>c(Pt),hn=>v(Pt,hn)),Ht(Te,()=>c(Oe),hn=>v(Oe,hn)),ms(fi,()=>c(Mt),hn=>v(Mt,hn)),z("click",ki,Ie),I(q,ve)};O(pw,q=>{c(w)&&q(Vr)})}var _w=m(q_,2);{var zl=q=>{var ve=TK(),Ye=b(ve);ni(Ye,17,()=>{var fi;return(((fi=c(ae))==null?void 0:fi.logEntries)??[]).filter(Nt)},fi=>fi.ts+fi.msg,(fi,ki)=>{var hn=EK(),en=b(hn),bn=b(en),tn=m(en,2),fn=b(tn),sn=m(tn,2),Bn=b(sn);H((Xn,Gn)=>{kt(hn,1,`log-line ${c(ki).level??""}`,"svelte-1pyfjii"),N(bn,Xn),N(fn,Gn),N(Bn,c(ki).msg)},[()=>mt(c(ki).ts),()=>c(ki).level.toUpperCase()]),I(fi,hn)});var Te=m(Ye,2);{var Rt=fi=>{var ki=DK();I(fi,ki)};O(Te,fi=>{var ki;(((ki=c(ae))==null?void 0:ki.logEntries.length)??0)===0&&fi(Rt)})}vs(ve,fi=>v(He,fi),()=>c(He)),I(q,ve)};O(_w,q=>{c(w)&&q(zl)})}var mw=m(V_,2);{var Kc=q=>{var ve=PK(),Ye=xt(ve),Te=m(Ye,2);let Rt;var fi=b(Te);CG(fi,{get currentScript(){return c(Ue)},onApply:ut,onCreateFile:at,get extraFiles(){return c(ot)},set extraFiles(ki){v(ot,ki,!0)}}),H(()=>Rt=zo(Te,"",Rt,{width:`${c(Di)??""}px`})),z("mousedown",Ye,Ee),I(q,ve)};O(mw,q=>{c(Ri)&&q(Kc)})}H(()=>{var q;js=zo(es,"",js,{width:`${c(Ki)??""}px`}),N(zr,c(u)??"No file selected"),Qo.disabled=!((q=c(ae))!=null&&q.dirty)||c(f),N(W_,c(f)?"Saving…":"Save"),ig.disabled=!c(u),z_=kt(og,1,"ai-toggle svelte-1pyfjii",null,z_,{"ai-open":c(Ri)}),ln(og,"title",c(Ri)?"Close AI assistant":"Open AI assistant"),U_=kt(Ku,1,"log-panel svelte-1pyfjii",null,U_,{collapsed:!c(w)}),Zu=zo(Ku,"",Zu,{height:c(w)?`${c(Ai)}px`:"26px"}),N(G_,`${c(w)?"▾":"▸"} Script Log `)}),z("mousedown",Wr,ye),z("click",Qo,re),z("click",ig,()=>v(p,!c(p))),z("click",og,()=>v(Ri,!c(Ri))),z("click",Xu,St),I(o,Mi),Ps()}zs(["click","contextmenu","keydown","change","mousedown"]);const IA="she-theme";function NK(){return localStorage.getItem(IA)??"dark"}function AK(o){localStorage.setItem(IA,o);const e=document.documentElement;o==="system"?e.removeAttribute("data-theme"):e.setAttribute("data-theme",o)}var zg={exports:{}};/* @preserve
220
- * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
221
- * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
222
- */var OK=zg.exports,gD;function FK(){return gD||(gD=1,(function(o,e){(function(t,i){i(e)})(OK,(function(t){var i="1.9.4";function n(l){var h,_,S,E;for(_=1,S=arguments.length;_<S;_++){E=arguments[_];for(h in E)l[h]=E[h]}return l}var s=Object.create||(function(){function l(){}return function(h){return l.prototype=h,new l}})();function r(l,h){var _=Array.prototype.slice;if(l.bind)return l.bind.apply(l,_.call(arguments,1));var S=_.call(arguments,2);return function(){return l.apply(h,S.length?S.concat(_.call(arguments)):arguments)}}var a=0;function d(l){return"_leaflet_id"in l||(l._leaflet_id=++a),l._leaflet_id}function u(l,h,_){var S,E,R,ee;return ee=function(){S=!1,E&&(R.apply(_,E),E=!1)},R=function(){S?E=arguments:(l.apply(_,arguments),setTimeout(ee,h),S=!0)},R}function f(l,h,_){var S=h[1],E=h[0],R=S-E;return l===S&&_?l:((l-E)%R+R)%R+E}function g(){return!1}function p(l,h){if(h===!1)return l;var _=Math.pow(10,h===void 0?6:h);return Math.round(l*_)/_}function w(l){return l.trim?l.trim():l.replace(/^\s+|\s+$/g,"")}function y(l){return w(l).split(/\s+/)}function x(l,h){Object.prototype.hasOwnProperty.call(l,"options")||(l.options=l.options?s(l.options):{});for(var _ in h)l.options[_]=h[_];return l.options}function k(l,h,_){var S=[];for(var E in l)S.push(encodeURIComponent(_?E.toUpperCase():E)+"="+encodeURIComponent(l[E]));return(!h||h.indexOf("?")===-1?"?":"&")+S.join("&")}var D=/\{ *([\w_ -]+) *\}/g;function M(l,h){return l.replace(D,function(_,S){var E=h[S];if(E===void 0)throw new Error("No value provided for variable "+_);return typeof E=="function"&&(E=E(h)),E})}var F=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"};function K(l,h){for(var _=0;_<l.length;_++)if(l[_]===h)return _;return-1}var V="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function se(l){return window["webkit"+l]||window["moz"+l]||window["ms"+l]}var te=0;function pe(l){var h=+new Date,_=Math.max(0,16-(h-te));return te=h+_,window.setTimeout(l,_)}var je=window.requestAnimationFrame||se("RequestAnimationFrame")||pe,Ke=window.cancelAnimationFrame||se("CancelAnimationFrame")||se("CancelRequestAnimationFrame")||function(l){window.clearTimeout(l)};function ue(l,h,_){if(_&&je===pe)l.call(h);else return je.call(window,r(l,h))}function He(l){l&&Ke.call(window,l)}var dt={__proto__:null,extend:n,create:s,bind:r,get lastId(){return a},stamp:d,throttle:u,wrapNum:f,falseFn:g,formatNum:p,trim:w,splitWords:y,setOptions:x,getParamString:k,template:M,isArray:F,indexOf:K,emptyImageUrl:V,requestFn:je,cancelFn:Ke,requestAnimFrame:ue,cancelAnimFrame:He};function we(){}we.extend=function(l){var h=function(){x(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},_=h.__super__=this.prototype,S=s(_);S.constructor=h,h.prototype=S;for(var E in this)Object.prototype.hasOwnProperty.call(this,E)&&E!=="prototype"&&E!=="__super__"&&(h[E]=this[E]);return l.statics&&n(h,l.statics),l.includes&&(gt(l.includes),n.apply(null,[S].concat(l.includes))),n(S,l),delete S.statics,delete S.includes,S.options&&(S.options=_.options?s(_.options):{},n(S.options,l.options)),S._initHooks=[],S.callInitHooks=function(){if(!this._initHooksCalled){_.callInitHooks&&_.callInitHooks.call(this),this._initHooksCalled=!0;for(var R=0,ee=S._initHooks.length;R<ee;R++)S._initHooks[R].call(this)}},h},we.include=function(l){var h=this.prototype.options;return n(this.prototype,l),l.options&&(this.prototype.options=h,this.mergeOptions(l.options)),this},we.mergeOptions=function(l){return n(this.prototype.options,l),this},we.addInitHook=function(l){var h=Array.prototype.slice.call(arguments,1),_=typeof l=="function"?l:function(){this[l].apply(this,h)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(_),this};function gt(l){if(!(typeof L>"u"||!L||!L.Mixin)){l=F(l)?l:[l];for(var h=0;h<l.length;h++)l[h]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}var ot={on:function(l,h,_){if(typeof l=="object")for(var S in l)this._on(S,l[S],h);else{l=y(l);for(var E=0,R=l.length;E<R;E++)this._on(l[E],h,_)}return this},off:function(l,h,_){if(!arguments.length)delete this._events;else if(typeof l=="object")for(var S in l)this._off(S,l[S],h);else{l=y(l);for(var E=arguments.length===1,R=0,ee=l.length;R<ee;R++)E?this._off(l[R]):this._off(l[R],h,_)}return this},_on:function(l,h,_,S){if(typeof h!="function"){console.warn("wrong listener type: "+typeof h);return}if(this._listens(l,h,_)===!1){_===this&&(_=void 0);var E={fn:h,ctx:_};S&&(E.once=!0),this._events=this._events||{},this._events[l]=this._events[l]||[],this._events[l].push(E)}},_off:function(l,h,_){var S,E,R;if(this._events&&(S=this._events[l],!!S)){if(arguments.length===1){if(this._firingCount)for(E=0,R=S.length;E<R;E++)S[E].fn=g;delete this._events[l];return}if(typeof h!="function"){console.warn("wrong listener type: "+typeof h);return}var ee=this._listens(l,h,_);if(ee!==!1){var Ce=S[ee];this._firingCount&&(Ce.fn=g,this._events[l]=S=S.slice()),S.splice(ee,1)}}},fire:function(l,h,_){if(!this.listens(l,_))return this;var S=n({},h,{type:l,target:this,sourceTarget:h&&h.sourceTarget||this});if(this._events){var E=this._events[l];if(E){this._firingCount=this._firingCount+1||1;for(var R=0,ee=E.length;R<ee;R++){var Ce=E[R],Be=Ce.fn;Ce.once&&this.off(l,Be,Ce.ctx),Be.call(Ce.ctx||this,S)}this._firingCount--}}return _&&this._propagateEvent(S),this},listens:function(l,h,_,S){typeof l!="string"&&console.warn('"string" type argument expected');var E=h;typeof h!="function"&&(S=!!h,E=void 0,_=void 0);var R=this._events&&this._events[l];if(R&&R.length&&this._listens(l,E,_)!==!1)return!0;if(S){for(var ee in this._eventParents)if(this._eventParents[ee].listens(l,h,_,S))return!0}return!1},_listens:function(l,h,_){if(!this._events)return!1;var S=this._events[l]||[];if(!h)return!!S.length;_===this&&(_=void 0);for(var E=0,R=S.length;E<R;E++)if(S[E].fn===h&&S[E].ctx===_)return E;return!1},once:function(l,h,_){if(typeof l=="object")for(var S in l)this._on(S,l[S],h,!0);else{l=y(l);for(var E=0,R=l.length;E<R;E++)this._on(l[E],h,_,!0)}return this},addEventParent:function(l){return this._eventParents=this._eventParents||{},this._eventParents[d(l)]=l,this},removeEventParent:function(l){return this._eventParents&&delete this._eventParents[d(l)],this},_propagateEvent:function(l){for(var h in this._eventParents)this._eventParents[h].fire(l.type,n({layer:l.target,propagatedFrom:l.target},l),!0)}};ot.addEventListener=ot.on,ot.removeEventListener=ot.clearAllEventListeners=ot.off,ot.addOneTimeEventListener=ot.once,ot.fireEvent=ot.fire,ot.hasEventListeners=ot.listens;var Pt=we.extend(ot);function Oe(l,h,_){this.x=_?Math.round(l):l,this.y=_?Math.round(h):h}var Mt=Math.trunc||function(l){return l>0?Math.floor(l):Math.ceil(l)};Oe.prototype={clone:function(){return new Oe(this.x,this.y)},add:function(l){return this.clone()._add(et(l))},_add:function(l){return this.x+=l.x,this.y+=l.y,this},subtract:function(l){return this.clone()._subtract(et(l))},_subtract:function(l){return this.x-=l.x,this.y-=l.y,this},divideBy:function(l){return this.clone()._divideBy(l)},_divideBy:function(l){return this.x/=l,this.y/=l,this},multiplyBy:function(l){return this.clone()._multiplyBy(l)},_multiplyBy:function(l){return this.x*=l,this.y*=l,this},scaleBy:function(l){return new Oe(this.x*l.x,this.y*l.y)},unscaleBy:function(l){return new Oe(this.x/l.x,this.y/l.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=Mt(this.x),this.y=Mt(this.y),this},distanceTo:function(l){l=et(l);var h=l.x-this.x,_=l.y-this.y;return Math.sqrt(h*h+_*_)},equals:function(l){return l=et(l),l.x===this.x&&l.y===this.y},contains:function(l){return l=et(l),Math.abs(l.x)<=Math.abs(this.x)&&Math.abs(l.y)<=Math.abs(this.y)},toString:function(){return"Point("+p(this.x)+", "+p(this.y)+")"}};function et(l,h,_){return l instanceof Oe?l:F(l)?new Oe(l[0],l[1]):l==null?l:typeof l=="object"&&"x"in l&&"y"in l?new Oe(l.x,l.y):new Oe(l,h,_)}function ct(l,h){if(l)for(var _=h?[l,h]:l,S=0,E=_.length;S<E;S++)this.extend(_[S])}ct.prototype={extend:function(l){var h,_;if(!l)return this;if(l instanceof Oe||typeof l[0]=="number"||"x"in l)h=_=et(l);else if(l=Nt(l),h=l.min,_=l.max,!h||!_)return this;return!this.min&&!this.max?(this.min=h.clone(),this.max=_.clone()):(this.min.x=Math.min(h.x,this.min.x),this.max.x=Math.max(_.x,this.max.x),this.min.y=Math.min(h.y,this.min.y),this.max.y=Math.max(_.y,this.max.y)),this},getCenter:function(l){return et((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,l)},getBottomLeft:function(){return et(this.min.x,this.max.y)},getTopRight:function(){return et(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(l){var h,_;return typeof l[0]=="number"||l instanceof Oe?l=et(l):l=Nt(l),l instanceof ct?(h=l.min,_=l.max):h=_=l,h.x>=this.min.x&&_.x<=this.max.x&&h.y>=this.min.y&&_.y<=this.max.y},intersects:function(l){l=Nt(l);var h=this.min,_=this.max,S=l.min,E=l.max,R=E.x>=h.x&&S.x<=_.x,ee=E.y>=h.y&&S.y<=_.y;return R&&ee},overlaps:function(l){l=Nt(l);var h=this.min,_=this.max,S=l.min,E=l.max,R=E.x>h.x&&S.x<_.x,ee=E.y>h.y&&S.y<_.y;return R&&ee},isValid:function(){return!!(this.min&&this.max)},pad:function(l){var h=this.min,_=this.max,S=Math.abs(h.x-_.x)*l,E=Math.abs(h.y-_.y)*l;return Nt(et(h.x-S,h.y-E),et(_.x+S,_.y+E))},equals:function(l){return l?(l=Nt(l),this.min.equals(l.getTopLeft())&&this.max.equals(l.getBottomRight())):!1}};function Nt(l,h){return!l||l instanceof ct?l:new ct(l,h)}function ti(l,h){if(l)for(var _=h?[l,h]:l,S=0,E=_.length;S<E;S++)this.extend(_[S])}ti.prototype={extend:function(l){var h=this._southWest,_=this._northEast,S,E;if(l instanceof Vt)S=l,E=l;else if(l instanceof ti){if(S=l._southWest,E=l._northEast,!S||!E)return this}else return l?this.extend(Me(l)||ri(l)):this;return!h&&!_?(this._southWest=new Vt(S.lat,S.lng),this._northEast=new Vt(E.lat,E.lng)):(h.lat=Math.min(S.lat,h.lat),h.lng=Math.min(S.lng,h.lng),_.lat=Math.max(E.lat,_.lat),_.lng=Math.max(E.lng,_.lng)),this},pad:function(l){var h=this._southWest,_=this._northEast,S=Math.abs(h.lat-_.lat)*l,E=Math.abs(h.lng-_.lng)*l;return new ti(new Vt(h.lat-S,h.lng-E),new Vt(_.lat+S,_.lng+E))},getCenter:function(){return new Vt((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new Vt(this.getNorth(),this.getWest())},getSouthEast:function(){return new Vt(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(l){typeof l[0]=="number"||l instanceof Vt||"lat"in l?l=Me(l):l=ri(l);var h=this._southWest,_=this._northEast,S,E;return l instanceof ti?(S=l.getSouthWest(),E=l.getNorthEast()):S=E=l,S.lat>=h.lat&&E.lat<=_.lat&&S.lng>=h.lng&&E.lng<=_.lng},intersects:function(l){l=ri(l);var h=this._southWest,_=this._northEast,S=l.getSouthWest(),E=l.getNorthEast(),R=E.lat>=h.lat&&S.lat<=_.lat,ee=E.lng>=h.lng&&S.lng<=_.lng;return R&&ee},overlaps:function(l){l=ri(l);var h=this._southWest,_=this._northEast,S=l.getSouthWest(),E=l.getNorthEast(),R=E.lat>h.lat&&S.lat<_.lat,ee=E.lng>h.lng&&S.lng<_.lng;return R&&ee},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(l,h){return l?(l=ri(l),this._southWest.equals(l.getSouthWest(),h)&&this._northEast.equals(l.getNorthEast(),h)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function ri(l,h){return l instanceof ti?l:new ti(l,h)}function Vt(l,h,_){if(isNaN(l)||isNaN(h))throw new Error("Invalid LatLng object: ("+l+", "+h+")");this.lat=+l,this.lng=+h,_!==void 0&&(this.alt=+_)}Vt.prototype={equals:function(l,h){if(!l)return!1;l=Me(l);var _=Math.max(Math.abs(this.lat-l.lat),Math.abs(this.lng-l.lng));return _<=(h===void 0?1e-9:h)},toString:function(l){return"LatLng("+p(this.lat,l)+", "+p(this.lng,l)+")"},distanceTo:function(l){return ft.distance(this,Me(l))},wrap:function(){return ft.wrapLatLng(this)},toBounds:function(l){var h=180*l/40075017,_=h/Math.cos(Math.PI/180*this.lat);return ri([this.lat-h,this.lng-_],[this.lat+h,this.lng+_])},clone:function(){return new Vt(this.lat,this.lng,this.alt)}};function Me(l,h,_){return l instanceof Vt?l:F(l)&&typeof l[0]!="object"?l.length===3?new Vt(l[0],l[1],l[2]):l.length===2?new Vt(l[0],l[1]):null:l==null?l:typeof l=="object"&&"lat"in l?new Vt(l.lat,"lng"in l?l.lng:l.lon,l.alt):h===void 0?null:new Vt(l,h,_)}var jt={latLngToPoint:function(l,h){var _=this.projection.project(l),S=this.scale(h);return this.transformation._transform(_,S)},pointToLatLng:function(l,h){var _=this.scale(h),S=this.transformation.untransform(l,_);return this.projection.unproject(S)},project:function(l){return this.projection.project(l)},unproject:function(l){return this.projection.unproject(l)},scale:function(l){return 256*Math.pow(2,l)},zoom:function(l){return Math.log(l/256)/Math.LN2},getProjectedBounds:function(l){if(this.infinite)return null;var h=this.projection.bounds,_=this.scale(l),S=this.transformation.transform(h.min,_),E=this.transformation.transform(h.max,_);return new ct(S,E)},infinite:!1,wrapLatLng:function(l){var h=this.wrapLng?f(l.lng,this.wrapLng,!0):l.lng,_=this.wrapLat?f(l.lat,this.wrapLat,!0):l.lat,S=l.alt;return new Vt(_,h,S)},wrapLatLngBounds:function(l){var h=l.getCenter(),_=this.wrapLatLng(h),S=h.lat-_.lat,E=h.lng-_.lng;if(S===0&&E===0)return l;var R=l.getSouthWest(),ee=l.getNorthEast(),Ce=new Vt(R.lat-S,R.lng-E),Be=new Vt(ee.lat-S,ee.lng-E);return new ti(Ce,Be)}},ft=n({},jt,{wrapLng:[-180,180],R:6371e3,distance:function(l,h){var _=Math.PI/180,S=l.lat*_,E=h.lat*_,R=Math.sin((h.lat-l.lat)*_/2),ee=Math.sin((h.lng-l.lng)*_/2),Ce=R*R+Math.cos(S)*Math.cos(E)*ee*ee,Be=2*Math.atan2(Math.sqrt(Ce),Math.sqrt(1-Ce));return this.R*Be}}),ht=6378137,he={R:ht,MAX_LATITUDE:85.0511287798,project:function(l){var h=Math.PI/180,_=this.MAX_LATITUDE,S=Math.max(Math.min(_,l.lat),-_),E=Math.sin(S*h);return new Oe(this.R*l.lng*h,this.R*Math.log((1+E)/(1-E))/2)},unproject:function(l){var h=180/Math.PI;return new Vt((2*Math.atan(Math.exp(l.y/this.R))-Math.PI/2)*h,l.x*h/this.R)},bounds:(function(){var l=ht*Math.PI;return new ct([-l,-l],[l,l])})()};function Xe(l,h,_,S){if(F(l)){this._a=l[0],this._b=l[1],this._c=l[2],this._d=l[3];return}this._a=l,this._b=h,this._c=_,this._d=S}Xe.prototype={transform:function(l,h){return this._transform(l.clone(),h)},_transform:function(l,h){return h=h||1,l.x=h*(this._a*l.x+this._b),l.y=h*(this._c*l.y+this._d),l},untransform:function(l,h){return h=h||1,new Oe((l.x/h-this._b)/this._a,(l.y/h-this._d)/this._c)}};function Ut(l,h,_,S){return new Xe(l,h,_,S)}var wi=n({},ft,{code:"EPSG:3857",projection:he,transformation:(function(){var l=.5/(Math.PI*he.R);return Ut(l,.5,-l,.5)})()}),Ri=n({},wi,{code:"EPSG:900913"});function ci(l){return document.createElementNS("http://www.w3.org/2000/svg",l)}function Bt(l,h){var _="",S,E,R,ee,Ce,Be;for(S=0,R=l.length;S<R;S++){for(Ce=l[S],E=0,ee=Ce.length;E<ee;E++)Be=Ce[E],_+=(E?"L":"M")+Be.x+" "+Be.y;_+=h?We.svg?"z":"x":""}return _||"M0 0"}var Xt=document.documentElement.style,pt="ActiveXObject"in window,Bi=pt&&!document.addEventListener,Ti="msLaunchUri"in navigator&&!("documentMode"in document),Ni=bt("webkit"),Ki=bt("android"),Ai=bt("android 2")||bt("android 3"),Di=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),$i=Ki&&bt("Google")&&Di<537&&!("AudioNode"in window),Gi=!!window.opera,Ui=!Ti&&bt("chrome"),mn=bt("gecko")&&!Ni&&!Gi&&!pt,rt=!Ui&&bt("safari"),Kt=bt("phantom"),_i="OTransition"in Xt,Pi=navigator.platform.indexOf("Win")===0,Li=pt&&"transition"in Xt,Si="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!Ai,Oi="MozPerspective"in Xt,qi=!window.L_DISABLE_3D&&(Li||Si||Oi)&&!_i&&!Kt,mi=typeof orientation<"u"||bt("mobile"),Ue=mi&&Ni,J=mi&&Si,Qe=!window.PointerEvent&&window.MSPointerEvent,_t=!!(window.PointerEvent||Qe),yt="ontouchstart"in window||!!window.TouchEvent,Ot=!window.L_NO_TOUCH&&(yt||_t),j=mi&&Gi,ce=mi&&mn,ke=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,ze=(function(){var l=!1;try{var h=Object.defineProperty({},"passive",{get:function(){l=!0}});window.addEventListener("testPassiveEventSupport",g,h),window.removeEventListener("testPassiveEventSupport",g,h)}catch{}return l})(),st=(function(){return!!document.createElement("canvas").getContext})(),X=!!(document.createElementNS&&ci("svg").createSVGRect),ae=!!X&&(function(){var l=document.createElement("div");return l.innerHTML="<svg/>",(l.firstChild&&l.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"})(),me=!X&&(function(){try{var l=document.createElement("div");l.innerHTML='<v:shape adj="1"/>';var h=l.firstChild;return h.style.behavior="url(#default#VML)",h&&typeof h.adj=="object"}catch{return!1}})(),Ze=navigator.platform.indexOf("Mac")===0,Zt=navigator.platform.indexOf("Linux")===0;function bt(l){return navigator.userAgent.toLowerCase().indexOf(l)>=0}var We={ie:pt,ielt9:Bi,edge:Ti,webkit:Ni,android:Ki,android23:Ai,androidStock:$i,opera:Gi,chrome:Ui,gecko:mn,safari:rt,phantom:Kt,opera12:_i,win:Pi,ie3d:Li,webkit3d:Si,gecko3d:Oi,any3d:qi,mobile:mi,mobileWebkit:Ue,mobileWebkit3d:J,msPointer:Qe,pointer:_t,touch:Ot,touchNative:yt,mobileOpera:j,mobileGecko:ce,retina:ke,passiveEvents:ze,canvas:st,svg:X,vml:me,inlineSvg:ae,mac:Ze,linux:Zt},At=We.msPointer?"MSPointerDown":"pointerdown",ai=We.msPointer?"MSPointerMove":"pointermove",zt=We.msPointer?"MSPointerUp":"pointerup",vi=We.msPointer?"MSPointerCancel":"pointercancel",hi={touchstart:At,touchmove:ai,touchend:zt,touchcancel:vi},Ci={touchstart:wt,touchmove:Ge,touchend:Ge,touchcancel:Ge},zi={},$e=!1;function Fe(l,h,_){return h==="touchstart"&&re(),Ci[h]?(_=Ci[h].bind(this,_),l.addEventListener(hi[h],_,!1),_):(console.warn("wrong event specified:",h),g)}function Ft(l,h,_){if(!hi[h]){console.warn("wrong event specified:",h);return}l.removeEventListener(hi[h],_,!1)}function Yt(l){zi[l.pointerId]=l}function qt(l){zi[l.pointerId]&&(zi[l.pointerId]=l)}function Qt(l){delete zi[l.pointerId]}function re(){$e||(document.addEventListener(At,Yt,!0),document.addEventListener(ai,qt,!0),document.addEventListener(zt,Qt,!0),document.addEventListener(vi,Qt,!0),$e=!0)}function Ge(l,h){if(h.pointerType!==(h.MSPOINTER_TYPE_MOUSE||"mouse")){h.touches=[];for(var _ in zi)h.touches.push(zi[_]);h.changedTouches=[h],l(h)}}function wt(l,h){h.MSPOINTER_TYPE_TOUCH&&h.pointerType===h.MSPOINTER_TYPE_TOUCH&&rn(h),Ge(l,h)}function vt(l){var h={},_,S;for(S in l)_=l[S],h[S]=_&&_.bind?_.bind(l):_;return l=h,h.type="dblclick",h.detail=2,h.isTrusted=!1,h._simulated=!0,h}var di=200;function It(l,h){l.addEventListener("dblclick",h);var _=0,S;function E(R){if(R.detail!==1){S=R.detail;return}if(!(R.pointerType==="mouse"||R.sourceCapabilities&&!R.sourceCapabilities.firesTouchEvents)){var ee=js(R);if(!(ee.some(function(Be){return Be instanceof HTMLLabelElement&&Be.attributes.for})&&!ee.some(function(Be){return Be instanceof HTMLInputElement||Be instanceof HTMLSelectElement}))){var Ce=Date.now();Ce-_<=di?(S++,S===2&&h(vt(R))):S=1,_=Ce}}}return l.addEventListener("click",E),{dblclick:h,simDblclick:E}}function Ii(l,h){l.removeEventListener("dblclick",h.dblclick),l.removeEventListener("click",h.simDblclick)}var W=Ve(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Q=Ve(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),oe=Q==="webkitTransition"||Q==="OTransition"?Q+"End":"transitionend";function $(l){return typeof l=="string"?document.getElementById(l):l}function A(l,h){var _=l.style[h]||l.currentStyle&&l.currentStyle[h];if((!_||_==="auto")&&document.defaultView){var S=document.defaultView.getComputedStyle(l,null);_=S?S[h]:null}return _==="auto"?null:_}function G(l,h,_){var S=document.createElement(l);return S.className=h||"",_&&_.appendChild(S),S}function ie(l){var h=l.parentNode;h&&h.removeChild(l)}function fe(l){for(;l.firstChild;)l.removeChild(l.firstChild)}function Y(l){var h=l.parentNode;h&&h.lastChild!==l&&h.appendChild(l)}function le(l){var h=l.parentNode;h&&h.firstChild!==l&&h.insertBefore(l,h.firstChild)}function Re(l,h){if(l.classList!==void 0)return l.classList.contains(h);var _=U(l);return _.length>0&&new RegExp("(^|\\s)"+h+"(\\s|$)").test(_)}function _e(l,h){if(l.classList!==void 0)for(var _=y(h),S=0,E=_.length;S<E;S++)l.classList.add(_[S]);else if(!Re(l,h)){var R=U(l);tt(l,(R?R+" ":"")+h)}}function ge(l,h){l.classList!==void 0?l.classList.remove(h):tt(l,w((" "+U(l)+" ").replace(" "+h+" "," ")))}function tt(l,h){l.className.baseVal===void 0?l.className=h:l.className.baseVal=h}function U(l){return l.correspondingElement&&(l=l.correspondingElement),l.className.baseVal===void 0?l.className:l.className.baseVal}function ne(l,h){"opacity"in l.style?l.style.opacity=h:"filter"in l.style&&Le(l,h)}function Le(l,h){var _=!1,S="DXImageTransform.Microsoft.Alpha";try{_=l.filters.item(S)}catch{if(h===1)return}h=Math.round(h*100),_?(_.Enabled=h!==100,_.Opacity=h):l.style.filter+=" progid:"+S+"(opacity="+h+")"}function Ve(l){for(var h=document.documentElement.style,_=0;_<l.length;_++)if(l[_]in h)return l[_];return!1}function De(l,h,_){var S=h||new Oe(0,0);l.style[W]=(We.ie3d?"translate("+S.x+"px,"+S.y+"px)":"translate3d("+S.x+"px,"+S.y+"px,0)")+(_?" scale("+_+")":"")}function Ie(l,h){l._leaflet_pos=h,We.any3d?De(l,h):(l.style.left=h.x+"px",l.style.top=h.y+"px")}function St(l){return l._leaflet_pos||new Oe(0,0)}var mt,qe,Tt;if("onselectstart"in document)mt=function(){Je(window,"selectstart",rn)},qe=function(){Jt(window,"selectstart",rn)};else{var it=Ve(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);mt=function(){if(it){var l=document.documentElement.style;Tt=l[it],l[it]="none"}},qe=function(){it&&(document.documentElement.style[it]=Tt,Tt=void 0)}}function ye(){Je(window,"dragstart",rn)}function Ne(){Jt(window,"dragstart",rn)}var Ee,Se;function nt(l){for(;l.tabIndex===-1;)l=l.parentNode;l.style&&(de(),Ee=l,Se=l.style.outlineStyle,l.style.outlineStyle="none",Je(window,"keydown",de))}function de(){Ee&&(Ee.style.outlineStyle=Se,Ee=void 0,Se=void 0,Jt(window,"keydown",de))}function Pe(l){do l=l.parentNode;while((!l.offsetWidth||!l.offsetHeight)&&l!==document.body);return l}function at(l){var h=l.getBoundingClientRect();return{x:h.width/l.offsetWidth||1,y:h.height/l.offsetHeight||1,boundingClientRect:h}}var ut={__proto__:null,TRANSFORM:W,TRANSITION:Q,TRANSITION_END:oe,get:$,getStyle:A,create:G,remove:ie,empty:fe,toFront:Y,toBack:le,hasClass:Re,addClass:_e,removeClass:ge,setClass:tt,getClass:U,setOpacity:ne,testProp:Ve,setTransform:De,setPosition:Ie,getPosition:St,get disableTextSelection(){return mt},get enableTextSelection(){return qe},disableImageDrag:ye,enableImageDrag:Ne,preventOutline:nt,restoreOutline:de,getSizedParentNode:Pe,getScale:at};function Je(l,h,_,S){if(h&&typeof h=="object")for(var E in h)xi(l,E,h[E],_);else{h=y(h);for(var R=0,ee=h.length;R<ee;R++)xi(l,h[R],_,S)}return this}var $t="_leaflet_events";function Jt(l,h,_,S){if(arguments.length===1)Mi(l),delete l[$t];else if(h&&typeof h=="object")for(var E in h)Ji(l,E,h[E],_);else if(h=y(h),arguments.length===2)Mi(l,function(Ce){return K(h,Ce)!==-1});else for(var R=0,ee=h.length;R<ee;R++)Ji(l,h[R],_,S);return this}function Mi(l,h){for(var _ in l[$t]){var S=_.split(/\d/)[0];(!h||h(S))&&Ji(l,S,null,null,_)}}var ii={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function xi(l,h,_,S){var E=h+d(_)+(S?"_"+d(S):"");if(l[$t]&&l[$t][E])return this;var R=function(Ce){return _.call(S||l,Ce||window.event)},ee=R;!We.touchNative&&We.pointer&&h.indexOf("touch")===0?R=Fe(l,h,R):We.touch&&h==="dblclick"?R=It(l,R):"addEventListener"in l?h==="touchstart"||h==="touchmove"||h==="wheel"||h==="mousewheel"?l.addEventListener(ii[h]||h,R,We.passiveEvents?{passive:!1}:!1):h==="mouseenter"||h==="mouseleave"?(R=function(Ce){Ce=Ce||window.event,Yn(l,Ce)&&ee(Ce)},l.addEventListener(ii[h],R,!1)):l.addEventListener(h,ee,!1):l.attachEvent("on"+h,R),l[$t]=l[$t]||{},l[$t][E]=R}function Ji(l,h,_,S,E){E=E||h+d(_)+(S?"_"+d(S):"");var R=l[$t]&&l[$t][E];if(!R)return this;!We.touchNative&&We.pointer&&h.indexOf("touch")===0?Ft(l,h,R):We.touch&&h==="dblclick"?Ii(l,R):"removeEventListener"in l?l.removeEventListener(ii[h]||h,R,!1):l.detachEvent("on"+h,R),l[$t][E]=null}function Hi(l){return l.stopPropagation?l.stopPropagation():l.originalEvent?l.originalEvent._stopped=!0:l.cancelBubble=!0,this}function li(l){return xi(l,"wheel",Hi),this}function un(l){return Je(l,"mousedown touchstart dblclick contextmenu",Hi),l._leaflet_disable_click=!0,this}function rn(l){return l.preventDefault?l.preventDefault():l.returnValue=!1,this}function es(l){return rn(l),Hi(l),this}function js(l){if(l.composedPath)return l.composedPath();for(var h=[],_=l.target;_;)h.push(_),_=_.parentNode;return h}function fo(l,h){if(!h)return new Oe(l.clientX,l.clientY);var _=at(h),S=_.boundingClientRect;return new Oe((l.clientX-S.left)/_.x-h.clientLeft,(l.clientY-S.top)/_.y-h.clientTop)}var Zo=We.linux&&We.chrome?window.devicePixelRatio:We.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function hr(l){return We.edge?l.wheelDeltaY/2:l.deltaY&&l.deltaMode===0?-l.deltaY/Zo:l.deltaY&&l.deltaMode===1?-l.deltaY*20:l.deltaY&&l.deltaMode===2?-l.deltaY*60:l.deltaX||l.deltaZ?0:l.wheelDelta?(l.wheelDeltaY||l.wheelDelta)/2:l.detail&&Math.abs(l.detail)<32765?-l.detail*20:l.detail?l.detail/-32765*60:0}function Yn(l,h){var _=h.relatedTarget;if(!_)return!0;try{for(;_&&_!==l;)_=_.parentNode}catch{return!1}return _!==l}var Yo={__proto__:null,on:Je,off:Jt,stopPropagation:Hi,disableScrollPropagation:li,disableClickPropagation:un,preventDefault:rn,stop:es,getPropagationPath:js,getMousePosition:fo,getWheelDelta:hr,isExternalTarget:Yn,addListener:Je,removeListener:Jt},fr=Pt.extend({run:function(l,h,_,S){this.stop(),this._el=l,this._inProgress=!0,this._duration=_||.25,this._easeOutPower=1/Math.max(S||.5,.2),this._startPos=St(l),this._offset=h.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=ue(this._animate,this),this._step()},_step:function(l){var h=+new Date-this._startTime,_=this._duration*1e3;h<_?this._runFrame(this._easeOut(h/_),l):(this._runFrame(1),this._complete())},_runFrame:function(l,h){var _=this._startPos.add(this._offset.multiplyBy(l));h&&_._round(),Ie(this._el,_),this.fire("step")},_complete:function(){He(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(l){return 1-Math.pow(1-l,this._easeOutPower)}}),vn=Pt.extend({options:{crs:wi,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(l,h){h=x(this,h),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(l),this._initLayout(),this._onResize=r(this._onResize,this),this._initEvents(),h.maxBounds&&this.setMaxBounds(h.maxBounds),h.zoom!==void 0&&(this._zoom=this._limitZoom(h.zoom)),h.center&&h.zoom!==void 0&&this.setView(Me(h.center),h.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=Q&&We.any3d&&!We.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),Je(this._proxy,oe,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(l,h,_){if(h=h===void 0?this._zoom:this._limitZoom(h),l=this._limitCenter(Me(l),h,this.options.maxBounds),_=_||{},this._stop(),this._loaded&&!_.reset&&_!==!0){_.animate!==void 0&&(_.zoom=n({animate:_.animate},_.zoom),_.pan=n({animate:_.animate,duration:_.duration},_.pan));var S=this._zoom!==h?this._tryAnimatedZoom&&this._tryAnimatedZoom(l,h,_.zoom):this._tryAnimatedPan(l,_.pan);if(S)return clearTimeout(this._sizeTimer),this}return this._resetView(l,h,_.pan&&_.pan.noMoveStart),this},setZoom:function(l,h){return this._loaded?this.setView(this.getCenter(),l,{zoom:h}):(this._zoom=l,this)},zoomIn:function(l,h){return l=l||(We.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom+l,h)},zoomOut:function(l,h){return l=l||(We.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom-l,h)},setZoomAround:function(l,h,_){var S=this.getZoomScale(h),E=this.getSize().divideBy(2),R=l instanceof Oe?l:this.latLngToContainerPoint(l),ee=R.subtract(E).multiplyBy(1-1/S),Ce=this.containerPointToLatLng(E.add(ee));return this.setView(Ce,h,{zoom:_})},_getBoundsCenterZoom:function(l,h){h=h||{},l=l.getBounds?l.getBounds():ri(l);var _=et(h.paddingTopLeft||h.padding||[0,0]),S=et(h.paddingBottomRight||h.padding||[0,0]),E=this.getBoundsZoom(l,!1,_.add(S));if(E=typeof h.maxZoom=="number"?Math.min(h.maxZoom,E):E,E===1/0)return{center:l.getCenter(),zoom:E};var R=S.subtract(_).divideBy(2),ee=this.project(l.getSouthWest(),E),Ce=this.project(l.getNorthEast(),E),Be=this.unproject(ee.add(Ce).divideBy(2).add(R),E);return{center:Be,zoom:E}},fitBounds:function(l,h){if(l=ri(l),!l.isValid())throw new Error("Bounds are not valid.");var _=this._getBoundsCenterZoom(l,h);return this.setView(_.center,_.zoom,h)},fitWorld:function(l){return this.fitBounds([[-90,-180],[90,180]],l)},panTo:function(l,h){return this.setView(l,this._zoom,{pan:h})},panBy:function(l,h){if(l=et(l).round(),h=h||{},!l.x&&!l.y)return this.fire("moveend");if(h.animate!==!0&&!this.getSize().contains(l))return this._resetView(this.unproject(this.project(this.getCenter()).add(l)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new fr,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),h.noMoveStart||this.fire("movestart"),h.animate!==!1){_e(this._mapPane,"leaflet-pan-anim");var _=this._getMapPanePos().subtract(l).round();this._panAnim.run(this._mapPane,_,h.duration||.25,h.easeLinearity)}else this._rawPanBy(l),this.fire("move").fire("moveend");return this},flyTo:function(l,h,_){if(_=_||{},_.animate===!1||!We.any3d)return this.setView(l,h,_);this._stop();var S=this.project(this.getCenter()),E=this.project(l),R=this.getSize(),ee=this._zoom;l=Me(l),h=h===void 0?ee:h;var Ce=Math.max(R.x,R.y),Be=Ce*this.getZoomScale(ee,h),Et=E.distanceTo(S)||1,Ei=1.42,on=Ei*Ei;function Ln(Hs){var Z_=Hs?-1:1,FA=Hs?Be:Ce,HA=Be*Be-Ce*Ce+Z_*on*on*Et*Et,WA=2*FA*on*Et,bw=HA/WA,aL=Math.sqrt(bw*bw+1)-bw,BA=aL<1e-9?-18:Math.log(aL);return BA}function Co(Hs){return(Math.exp(Hs)-Math.exp(-Hs))/2}function Xs(Hs){return(Math.exp(Hs)+Math.exp(-Hs))/2}function pr(Hs){return Co(Hs)/Xs(Hs)}var Ao=Ln(0);function Ju(Hs){return Ce*(Xs(Ao)/Xs(Ao+Ei*Hs))}function RA(Hs){return Ce*(Xs(Ao)*pr(Ao+Ei*Hs)-Co(Ao))/on}function NA(Hs){return 1-Math.pow(1-Hs,1.5)}var AA=Date.now(),oL=(Ln(1)-Ao)/Ei,OA=_.duration?1e3*_.duration:1e3*oL*.8;function rL(){var Hs=(Date.now()-AA)/OA,Z_=NA(Hs)*oL;Hs<=1?(this._flyToFrame=ue(rL,this),this._move(this.unproject(S.add(E.subtract(S).multiplyBy(RA(Z_)/Et)),ee),this.getScaleZoom(Ce/Ju(Z_),ee),{flyTo:!0})):this._move(l,h)._moveEnd(!0)}return this._moveStart(!0,_.noMoveStart),rL.call(this),this},flyToBounds:function(l,h){var _=this._getBoundsCenterZoom(l,h);return this.flyTo(_.center,_.zoom,h)},setMaxBounds:function(l){return l=ri(l),this.listens("moveend",this._panInsideMaxBounds)&&this.off("moveend",this._panInsideMaxBounds),l.isValid()?(this.options.maxBounds=l,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(l){var h=this.options.minZoom;return this.options.minZoom=l,this._loaded&&h!==l&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(l):this},setMaxZoom:function(l){var h=this.options.maxZoom;return this.options.maxZoom=l,this._loaded&&h!==l&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(l):this},panInsideBounds:function(l,h){this._enforcingBounds=!0;var _=this.getCenter(),S=this._limitCenter(_,this._zoom,ri(l));return _.equals(S)||this.panTo(S,h),this._enforcingBounds=!1,this},panInside:function(l,h){h=h||{};var _=et(h.paddingTopLeft||h.padding||[0,0]),S=et(h.paddingBottomRight||h.padding||[0,0]),E=this.project(this.getCenter()),R=this.project(l),ee=this.getPixelBounds(),Ce=Nt([ee.min.add(_),ee.max.subtract(S)]),Be=Ce.getSize();if(!Ce.contains(R)){this._enforcingBounds=!0;var Et=R.subtract(Ce.getCenter()),Ei=Ce.extend(R).getSize().subtract(Be);E.x+=Et.x<0?-Ei.x:Ei.x,E.y+=Et.y<0?-Ei.y:Ei.y,this.panTo(this.unproject(E),h),this._enforcingBounds=!1}return this},invalidateSize:function(l){if(!this._loaded)return this;l=n({animate:!1,pan:!0},l===!0?{animate:!0}:l);var h=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var _=this.getSize(),S=h.divideBy(2).round(),E=_.divideBy(2).round(),R=S.subtract(E);return!R.x&&!R.y?this:(l.animate&&l.pan?this.panBy(R):(l.pan&&this._rawPanBy(R),this.fire("move"),l.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(r(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:h,newSize:_}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(l){if(l=this._locateOptions=n({timeout:1e4,watch:!1},l),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var h=r(this._handleGeolocationResponse,this),_=r(this._handleGeolocationError,this);return l.watch?this._locationWatchId=navigator.geolocation.watchPosition(h,_,l):navigator.geolocation.getCurrentPosition(h,_,l),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(l){if(this._container._leaflet_id){var h=l.code,_=l.message||(h===1?"permission denied":h===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:h,message:"Geolocation error: "+_+"."})}},_handleGeolocationResponse:function(l){if(this._container._leaflet_id){var h=l.coords.latitude,_=l.coords.longitude,S=new Vt(h,_),E=S.toBounds(l.coords.accuracy*2),R=this._locateOptions;if(R.setView){var ee=this.getBoundsZoom(E);this.setView(S,R.maxZoom?Math.min(ee,R.maxZoom):ee)}var Ce={latlng:S,bounds:E,timestamp:l.timestamp};for(var Be in l.coords)typeof l.coords[Be]=="number"&&(Ce[Be]=l.coords[Be]);this.fire("locationfound",Ce)}},addHandler:function(l,h){if(!h)return this;var _=this[l]=new h(this);return this._handlers.push(_),this.options[l]&&_.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),ie(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(He(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var l;for(l in this._layers)this._layers[l].remove();for(l in this._panes)ie(this._panes[l]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(l,h){var _="leaflet-pane"+(l?" leaflet-"+l.replace("Pane","")+"-pane":""),S=G("div",_,h||this._mapPane);return l&&(this._panes[l]=S),S},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var l=this.getPixelBounds(),h=this.unproject(l.getBottomLeft()),_=this.unproject(l.getTopRight());return new ti(h,_)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(l,h,_){l=ri(l),_=et(_||[0,0]);var S=this.getZoom()||0,E=this.getMinZoom(),R=this.getMaxZoom(),ee=l.getNorthWest(),Ce=l.getSouthEast(),Be=this.getSize().subtract(_),Et=Nt(this.project(Ce,S),this.project(ee,S)).getSize(),Ei=We.any3d?this.options.zoomSnap:1,on=Be.x/Et.x,Ln=Be.y/Et.y,Co=h?Math.max(on,Ln):Math.min(on,Ln);return S=this.getScaleZoom(Co,S),Ei&&(S=Math.round(S/(Ei/100))*(Ei/100),S=h?Math.ceil(S/Ei)*Ei:Math.floor(S/Ei)*Ei),Math.max(E,Math.min(R,S))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new Oe(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(l,h){var _=this._getTopLeftPoint(l,h);return new ct(_,_.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(l){return this.options.crs.getProjectedBounds(l===void 0?this.getZoom():l)},getPane:function(l){return typeof l=="string"?this._panes[l]:l},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(l,h){var _=this.options.crs;return h=h===void 0?this._zoom:h,_.scale(l)/_.scale(h)},getScaleZoom:function(l,h){var _=this.options.crs;h=h===void 0?this._zoom:h;var S=_.zoom(l*_.scale(h));return isNaN(S)?1/0:S},project:function(l,h){return h=h===void 0?this._zoom:h,this.options.crs.latLngToPoint(Me(l),h)},unproject:function(l,h){return h=h===void 0?this._zoom:h,this.options.crs.pointToLatLng(et(l),h)},layerPointToLatLng:function(l){var h=et(l).add(this.getPixelOrigin());return this.unproject(h)},latLngToLayerPoint:function(l){var h=this.project(Me(l))._round();return h._subtract(this.getPixelOrigin())},wrapLatLng:function(l){return this.options.crs.wrapLatLng(Me(l))},wrapLatLngBounds:function(l){return this.options.crs.wrapLatLngBounds(ri(l))},distance:function(l,h){return this.options.crs.distance(Me(l),Me(h))},containerPointToLayerPoint:function(l){return et(l).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(l){return et(l).add(this._getMapPanePos())},containerPointToLatLng:function(l){var h=this.containerPointToLayerPoint(et(l));return this.layerPointToLatLng(h)},latLngToContainerPoint:function(l){return this.layerPointToContainerPoint(this.latLngToLayerPoint(Me(l)))},mouseEventToContainerPoint:function(l){return fo(l,this._container)},mouseEventToLayerPoint:function(l){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(l))},mouseEventToLatLng:function(l){return this.layerPointToLatLng(this.mouseEventToLayerPoint(l))},_initContainer:function(l){var h=this._container=$(l);if(h){if(h._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");Je(h,"scroll",this._onScroll,this),this._containerId=d(h)},_initLayout:function(){var l=this._container;this._fadeAnimated=this.options.fadeAnimation&&We.any3d,_e(l,"leaflet-container"+(We.touch?" leaflet-touch":"")+(We.retina?" leaflet-retina":"")+(We.ielt9?" leaflet-oldie":"")+(We.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var h=A(l,"position");h!=="absolute"&&h!=="relative"&&h!=="fixed"&&h!=="sticky"&&(l.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var l=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Ie(this._mapPane,new Oe(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(_e(l.markerPane,"leaflet-zoom-hide"),_e(l.shadowPane,"leaflet-zoom-hide"))},_resetView:function(l,h,_){Ie(this._mapPane,new Oe(0,0));var S=!this._loaded;this._loaded=!0,h=this._limitZoom(h),this.fire("viewprereset");var E=this._zoom!==h;this._moveStart(E,_)._move(l,h)._moveEnd(E),this.fire("viewreset"),S&&this.fire("load")},_moveStart:function(l,h){return l&&this.fire("zoomstart"),h||this.fire("movestart"),this},_move:function(l,h,_,S){h===void 0&&(h=this._zoom);var E=this._zoom!==h;return this._zoom=h,this._lastCenter=l,this._pixelOrigin=this._getNewPixelOrigin(l),S?_&&_.pinch&&this.fire("zoom",_):((E||_&&_.pinch)&&this.fire("zoom",_),this.fire("move",_)),this},_moveEnd:function(l){return l&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return He(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(l){Ie(this._mapPane,this._getMapPanePos().subtract(l))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(l){this._targets={},this._targets[d(this._container)]=this;var h=l?Jt:Je;h(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&h(window,"resize",this._onResize,this),We.any3d&&this.options.transform3DLimit&&(l?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){He(this._resizeRequest),this._resizeRequest=ue(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var l=this._getMapPanePos();Math.max(Math.abs(l.x),Math.abs(l.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(l,h){for(var _=[],S,E=h==="mouseout"||h==="mouseover",R=l.target||l.srcElement,ee=!1;R;){if(S=this._targets[d(R)],S&&(h==="click"||h==="preclick")&&this._draggableMoved(S)){ee=!0;break}if(S&&S.listens(h,!0)&&(E&&!Yn(R,l)||(_.push(S),E))||R===this._container)break;R=R.parentNode}return!_.length&&!ee&&!E&&this.listens(h,!0)&&(_=[this]),_},_isClickDisabled:function(l){for(;l&&l!==this._container;){if(l._leaflet_disable_click)return!0;l=l.parentNode}},_handleDOMEvent:function(l){var h=l.target||l.srcElement;if(!(!this._loaded||h._leaflet_disable_events||l.type==="click"&&this._isClickDisabled(h))){var _=l.type;_==="mousedown"&&nt(h),this._fireDOMEvent(l,_)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(l,h,_){if(l.type==="click"){var S=n({},l);S.type="preclick",this._fireDOMEvent(S,S.type,_)}var E=this._findEventTargets(l,h);if(_){for(var R=[],ee=0;ee<_.length;ee++)_[ee].listens(h,!0)&&R.push(_[ee]);E=R.concat(E)}if(E.length){h==="contextmenu"&&rn(l);var Ce=E[0],Be={originalEvent:l};if(l.type!=="keypress"&&l.type!=="keydown"&&l.type!=="keyup"){var Et=Ce.getLatLng&&(!Ce._radius||Ce._radius<=10);Be.containerPoint=Et?this.latLngToContainerPoint(Ce.getLatLng()):this.mouseEventToContainerPoint(l),Be.layerPoint=this.containerPointToLayerPoint(Be.containerPoint),Be.latlng=Et?Ce.getLatLng():this.layerPointToLatLng(Be.layerPoint)}for(ee=0;ee<E.length;ee++)if(E[ee].fire(h,Be,!0),Be.originalEvent._stopped||E[ee].options.bubblingMouseEvents===!1&&K(this._mouseEvents,h)!==-1)return}},_draggableMoved:function(l){return l=l.dragging&&l.dragging.enabled()?l:this,l.dragging&&l.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var l=0,h=this._handlers.length;l<h;l++)this._handlers[l].disable()},whenReady:function(l,h){return this._loaded?l.call(h||this,{target:this}):this.on("load",l,h),this},_getMapPanePos:function(){return St(this._mapPane)||new Oe(0,0)},_moved:function(){var l=this._getMapPanePos();return l&&!l.equals([0,0])},_getTopLeftPoint:function(l,h){var _=l&&h!==void 0?this._getNewPixelOrigin(l,h):this.getPixelOrigin();return _.subtract(this._getMapPanePos())},_getNewPixelOrigin:function(l,h){var _=this.getSize()._divideBy(2);return this.project(l,h)._subtract(_)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(l,h,_){var S=this._getNewPixelOrigin(_,h);return this.project(l,h)._subtract(S)},_latLngBoundsToNewLayerBounds:function(l,h,_){var S=this._getNewPixelOrigin(_,h);return Nt([this.project(l.getSouthWest(),h)._subtract(S),this.project(l.getNorthWest(),h)._subtract(S),this.project(l.getSouthEast(),h)._subtract(S),this.project(l.getNorthEast(),h)._subtract(S)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(l){return this.latLngToLayerPoint(l).subtract(this._getCenterLayerPoint())},_limitCenter:function(l,h,_){if(!_)return l;var S=this.project(l,h),E=this.getSize().divideBy(2),R=new ct(S.subtract(E),S.add(E)),ee=this._getBoundsOffset(R,_,h);return Math.abs(ee.x)<=1&&Math.abs(ee.y)<=1?l:this.unproject(S.add(ee),h)},_limitOffset:function(l,h){if(!h)return l;var _=this.getPixelBounds(),S=new ct(_.min.add(l),_.max.add(l));return l.add(this._getBoundsOffset(S,h))},_getBoundsOffset:function(l,h,_){var S=Nt(this.project(h.getNorthEast(),_),this.project(h.getSouthWest(),_)),E=S.min.subtract(l.min),R=S.max.subtract(l.max),ee=this._rebound(E.x,-R.x),Ce=this._rebound(E.y,-R.y);return new Oe(ee,Ce)},_rebound:function(l,h){return l+h>0?Math.round(l-h)/2:Math.max(0,Math.ceil(l))-Math.max(0,Math.floor(h))},_limitZoom:function(l){var h=this.getMinZoom(),_=this.getMaxZoom(),S=We.any3d?this.options.zoomSnap:1;return S&&(l=Math.round(l/S)*S),Math.max(h,Math.min(_,l))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){ge(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(l,h){var _=this._getCenterOffset(l)._trunc();return(h&&h.animate)!==!0&&!this.getSize().contains(_)?!1:(this.panBy(_,h),!0)},_createAnimProxy:function(){var l=this._proxy=G("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(l),this.on("zoomanim",function(h){var _=W,S=this._proxy.style[_];De(this._proxy,this.project(h.center,h.zoom),this.getZoomScale(h.zoom,1)),S===this._proxy.style[_]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ie(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var l=this.getCenter(),h=this.getZoom();De(this._proxy,this.project(l,h),this.getZoomScale(h,1))},_catchTransitionEnd:function(l){this._animatingZoom&&l.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(l,h,_){if(this._animatingZoom)return!0;if(_=_||{},!this._zoomAnimated||_.animate===!1||this._nothingToAnimate()||Math.abs(h-this._zoom)>this.options.zoomAnimationThreshold)return!1;var S=this.getZoomScale(h),E=this._getCenterOffset(l)._divideBy(1-1/S);return _.animate!==!0&&!this.getSize().contains(E)?!1:(ue(function(){this._moveStart(!0,_.noMoveStart||!1)._animateZoom(l,h,!0)},this),!0)},_animateZoom:function(l,h,_,S){this._mapPane&&(_&&(this._animatingZoom=!0,this._animateToCenter=l,this._animateToZoom=h,_e(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:l,zoom:h,noUpdate:S}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(r(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&ge(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function Ms(l,h){return new vn(l,h)}var fs=we.extend({options:{position:"topright"},initialize:function(l){x(this,l)},getPosition:function(){return this.options.position},setPosition:function(l){var h=this._map;return h&&h.removeControl(this),this.options.position=l,h&&h.addControl(this),this},getContainer:function(){return this._container},addTo:function(l){this.remove(),this._map=l;var h=this._container=this.onAdd(l),_=this.getPosition(),S=l._controlCorners[_];return _e(h,"leaflet-control"),_.indexOf("bottom")!==-1?S.insertBefore(h,S.firstChild):S.appendChild(h),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(ie(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(l){this._map&&l&&l.screenX>0&&l.screenY>0&&this._map.getContainer().focus()}}),ns=function(l){return new fs(l)};vn.include({addControl:function(l){return l.addTo(this),this},removeControl:function(l){return l.remove(),this},_initControlPos:function(){var l=this._controlCorners={},h="leaflet-",_=this._controlContainer=G("div",h+"control-container",this._container);function S(E,R){var ee=h+E+" "+h+R;l[E+R]=G("div",ee,_)}S("top","left"),S("top","right"),S("bottom","left"),S("bottom","right")},_clearControlPos:function(){for(var l in this._controlCorners)ie(this._controlCorners[l]);ie(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Rs=fs.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(l,h,_,S){return _<S?-1:S<_?1:0}},initialize:function(l,h,_){x(this,_),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(var S in l)this._addLayer(l[S],S);for(S in h)this._addLayer(h[S],S,!0)},onAdd:function(l){this._initLayout(),this._update(),this._map=l,l.on("zoomend",this._checkDisabledLayers,this);for(var h=0;h<this._layers.length;h++)this._layers[h].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(l){return fs.prototype.addTo.call(this,l),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var l=0;l<this._layers.length;l++)this._layers[l].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(l,h){return this._addLayer(l,h),this._map?this._update():this},addOverlay:function(l,h){return this._addLayer(l,h,!0),this._map?this._update():this},removeLayer:function(l){l.off("add remove",this._onLayerChange,this);var h=this._getLayer(d(l));return h&&this._layers.splice(this._layers.indexOf(h),1),this._map?this._update():this},expand:function(){_e(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var l=this._map.getSize().y-(this._container.offsetTop+50);return l<this._section.clientHeight?(_e(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=l+"px"):ge(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return ge(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var l="leaflet-control-layers",h=this._container=G("div",l),_=this.options.collapsed;h.setAttribute("aria-haspopup",!0),un(h),li(h);var S=this._section=G("section",l+"-list");_&&(this._map.on("click",this.collapse,this),Je(h,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var E=this._layersLink=G("a",l+"-toggle",h);E.href="#",E.title="Layers",E.setAttribute("role","button"),Je(E,{keydown:function(R){R.keyCode===13&&this._expandSafely()},click:function(R){rn(R),this._expandSafely()}},this),_||this.expand(),this._baseLayersList=G("div",l+"-base",S),this._separator=G("div",l+"-separator",S),this._overlaysList=G("div",l+"-overlays",S),h.appendChild(S)},_getLayer:function(l){for(var h=0;h<this._layers.length;h++)if(this._layers[h]&&d(this._layers[h].layer)===l)return this._layers[h]},_addLayer:function(l,h,_){this._map&&l.on("add remove",this._onLayerChange,this),this._layers.push({layer:l,name:h,overlay:_}),this.options.sortLayers&&this._layers.sort(r(function(S,E){return this.options.sortFunction(S.layer,E.layer,S.name,E.name)},this)),this.options.autoZIndex&&l.setZIndex&&(this._lastZIndex++,l.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;fe(this._baseLayersList),fe(this._overlaysList),this._layerControlInputs=[];var l,h,_,S,E=0;for(_=0;_<this._layers.length;_++)S=this._layers[_],this._addItem(S),h=h||S.overlay,l=l||!S.overlay,E+=S.overlay?0:1;return this.options.hideSingleBase&&(l=l&&E>1,this._baseLayersList.style.display=l?"":"none"),this._separator.style.display=h&&l?"":"none",this},_onLayerChange:function(l){this._handlingClick||this._update();var h=this._getLayer(d(l.target)),_=h.overlay?l.type==="add"?"overlayadd":"overlayremove":l.type==="add"?"baselayerchange":null;_&&this._map.fire(_,h)},_createRadioElement:function(l,h){var _='<input type="radio" class="leaflet-control-layers-selector" name="'+l+'"'+(h?' checked="checked"':"")+"/>",S=document.createElement("div");return S.innerHTML=_,S.firstChild},_addItem:function(l){var h=document.createElement("label"),_=this._map.hasLayer(l.layer),S;l.overlay?(S=document.createElement("input"),S.type="checkbox",S.className="leaflet-control-layers-selector",S.defaultChecked=_):S=this._createRadioElement("leaflet-base-layers_"+d(this),_),this._layerControlInputs.push(S),S.layerId=d(l.layer),Je(S,"click",this._onInputClick,this);var E=document.createElement("span");E.innerHTML=" "+l.name;var R=document.createElement("span");h.appendChild(R),R.appendChild(S),R.appendChild(E);var ee=l.overlay?this._overlaysList:this._baseLayersList;return ee.appendChild(h),this._checkDisabledLayers(),h},_onInputClick:function(){if(!this._preventClick){var l=this._layerControlInputs,h,_,S=[],E=[];this._handlingClick=!0;for(var R=l.length-1;R>=0;R--)h=l[R],_=this._getLayer(h.layerId).layer,h.checked?S.push(_):h.checked||E.push(_);for(R=0;R<E.length;R++)this._map.hasLayer(E[R])&&this._map.removeLayer(E[R]);for(R=0;R<S.length;R++)this._map.hasLayer(S[R])||this._map.addLayer(S[R]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var l=this._layerControlInputs,h,_,S=this._map.getZoom(),E=l.length-1;E>=0;E--)h=l[E],_=this._getLayer(h.layerId).layer,h.disabled=_.options.minZoom!==void 0&&S<_.options.minZoom||_.options.maxZoom!==void 0&&S>_.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var l=this._section;this._preventClick=!0,Je(l,"click",rn),this.expand();var h=this;setTimeout(function(){Jt(l,"click",rn),h._preventClick=!1})}}),Wr=function(l,h,_){return new Rs(l,h,_)},Za=fs.extend({options:{position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">&#x2212;</span>',zoomOutTitle:"Zoom out"},onAdd:function(l){var h="leaflet-control-zoom",_=G("div",h+" leaflet-bar"),S=this.options;return this._zoomInButton=this._createButton(S.zoomInText,S.zoomInTitle,h+"-in",_,this._zoomIn),this._zoomOutButton=this._createButton(S.zoomOutText,S.zoomOutTitle,h+"-out",_,this._zoomOut),this._updateDisabled(),l.on("zoomend zoomlevelschange",this._updateDisabled,this),_},onRemove:function(l){l.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(l){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(l.shiftKey?3:1))},_zoomOut:function(l){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(l.shiftKey?3:1))},_createButton:function(l,h,_,S,E){var R=G("a",_,S);return R.innerHTML=l,R.href="#",R.title=h,R.setAttribute("role","button"),R.setAttribute("aria-label",h),un(R),Je(R,"click",es),Je(R,"click",E,this),Je(R,"click",this._refocusOnMap,this),R},_updateDisabled:function(){var l=this._map,h="leaflet-disabled";ge(this._zoomInButton,h),ge(this._zoomOutButton,h),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||l._zoom===l.getMinZoom())&&(_e(this._zoomOutButton,h),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||l._zoom===l.getMaxZoom())&&(_e(this._zoomInButton,h),this._zoomInButton.setAttribute("aria-disabled","true"))}});vn.mergeOptions({zoomControl:!0}),vn.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new Za,this.addControl(this.zoomControl))});var Wl=function(l){return new Za(l)},Ya=fs.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(l){var h="leaflet-control-scale",_=G("div",h),S=this.options;return this._addScales(S,h+"-line",_),l.on(S.updateWhenIdle?"moveend":"move",this._update,this),l.whenReady(this._update,this),_},onRemove:function(l){l.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(l,h,_){l.metric&&(this._mScale=G("div",h,_)),l.imperial&&(this._iScale=G("div",h,_))},_update:function(){var l=this._map,h=l.getSize().y/2,_=l.distance(l.containerPointToLatLng([0,h]),l.containerPointToLatLng([this.options.maxWidth,h]));this._updateScales(_)},_updateScales:function(l){this.options.metric&&l&&this._updateMetric(l),this.options.imperial&&l&&this._updateImperial(l)},_updateMetric:function(l){var h=this._getRoundNum(l),_=h<1e3?h+" m":h/1e3+" km";this._updateScale(this._mScale,_,h/l)},_updateImperial:function(l){var h=l*3.2808399,_,S,E;h>5280?(_=h/5280,S=this._getRoundNum(_),this._updateScale(this._iScale,S+" mi",S/_)):(E=this._getRoundNum(h),this._updateScale(this._iScale,E+" ft",E/h))},_updateScale:function(l,h,_){l.style.width=Math.round(this.options.maxWidth*_)+"px",l.innerHTML=h},_getRoundNum:function(l){var h=Math.pow(10,(Math.floor(l)+"").length-1),_=l/h;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:1,h*_}}),Xo=function(l){return new Ya(l)},Br='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="leaflet-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg>',zr=fs.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">'+(We.inlineSvg?Br+" ":"")+"Leaflet</a>"},initialize:function(l){x(this,l),this._attributions={}},onAdd:function(l){l.attributionControl=this,this._container=G("div","leaflet-control-attribution"),un(this._container);for(var h in l._layers)l._layers[h].getAttribution&&this.addAttribution(l._layers[h].getAttribution());return this._update(),l.on("layeradd",this._addAttribution,this),this._container},onRemove:function(l){l.off("layeradd",this._addAttribution,this)},_addAttribution:function(l){l.layer.getAttribution&&(this.addAttribution(l.layer.getAttribution()),l.layer.once("remove",function(){this.removeAttribution(l.layer.getAttribution())},this))},setPrefix:function(l){return this.options.prefix=l,this._update(),this},addAttribution:function(l){return l?(this._attributions[l]||(this._attributions[l]=0),this._attributions[l]++,this._update(),this):this},removeAttribution:function(l){return l?(this._attributions[l]&&(this._attributions[l]--,this._update()),this):this},_update:function(){if(this._map){var l=[];for(var h in this._attributions)this._attributions[h]&&l.push(h);var _=[];this.options.prefix&&_.push(this.options.prefix),l.length&&_.push(l.join(", ")),this._container.innerHTML=_.join(' <span aria-hidden="true">|</span> ')}}});vn.mergeOptions({attributionControl:!0}),vn.addInitHook(function(){this.options.attributionControl&&new zr().addTo(this)});var F_=function(l){return new zr(l)};fs.Layers=Rs,fs.Zoom=Za,fs.Scale=Ya,fs.Attribution=zr,ns.layers=Wr,ns.zoom=Wl,ns.scale=Xo,ns.attribution=F_;var gr=we.extend({initialize:function(l){this._map=l},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});gr.addTo=function(l,h){return l.addHandler(h,this),this};var H_={Events:ot},tg=We.touch?"touchstart mousedown":"mousedown",Qo=Pt.extend({options:{clickTolerance:3},initialize:function(l,h,_,S){x(this,S),this._element=l,this._dragStartTarget=h||l,this._preventOutline=_},enable:function(){this._enabled||(Je(this._dragStartTarget,tg,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(Qo._dragging===this&&this.finishDrag(!0),Jt(this._dragStartTarget,tg,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(l){if(this._enabled&&(this._moved=!1,!Re(this._element,"leaflet-zoom-anim"))){if(l.touches&&l.touches.length!==1){Qo._dragging===this&&this.finishDrag();return}if(!(Qo._dragging||l.shiftKey||l.which!==1&&l.button!==1&&!l.touches)&&(Qo._dragging=this,this._preventOutline&&nt(this._element),ye(),mt(),!this._moving)){this.fire("down");var h=l.touches?l.touches[0]:l,_=Pe(this._element);this._startPoint=new Oe(h.clientX,h.clientY),this._startPos=St(this._element),this._parentScale=at(_);var S=l.type==="mousedown";Je(document,S?"mousemove":"touchmove",this._onMove,this),Je(document,S?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(l){if(this._enabled){if(l.touches&&l.touches.length>1){this._moved=!0;return}var h=l.touches&&l.touches.length===1?l.touches[0]:l,_=new Oe(h.clientX,h.clientY)._subtract(this._startPoint);!_.x&&!_.y||Math.abs(_.x)+Math.abs(_.y)<this.options.clickTolerance||(_.x/=this._parentScale.x,_.y/=this._parentScale.y,rn(l),this._moved||(this.fire("dragstart"),this._moved=!0,_e(document.body,"leaflet-dragging"),this._lastTarget=l.target||l.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),_e(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(_),this._moving=!0,this._lastEvent=l,this._updatePosition())}},_updatePosition:function(){var l={originalEvent:this._lastEvent};this.fire("predrag",l),Ie(this._element,this._newPos),this.fire("drag",l)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(l){ge(document.body,"leaflet-dragging"),this._lastTarget&&(ge(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),Jt(document,"mousemove touchmove",this._onMove,this),Jt(document,"mouseup touchend touchcancel",this._onUp,this),Ne(),qe();var h=this._moved&&this._moving;this._moving=!1,Qo._dragging=!1,h&&this.fire("dragend",{noInertia:l,distance:this._newPos.distanceTo(this._startPos)})}});function W_(l,h,_){var S,E=[1,4,2,8],R,ee,Ce,Be,Et,Ei,on,Ln;for(R=0,Ei=l.length;R<Ei;R++)l[R]._code=Xa(l[R],h);for(Ce=0;Ce<4;Ce++){for(on=E[Ce],S=[],R=0,Ei=l.length,ee=Ei-1;R<Ei;ee=R++)Be=l[R],Et=l[ee],Be._code&on?Et._code&on||(Ln=qc(Et,Be,on,h,_),Ln._code=Xa(Ln,h),S.push(Ln)):(Et._code&on&&(Ln=qc(Et,Be,on,h,_),Ln._code=Xa(Ln,h),S.push(Ln)),S.push(Be));l=S}return l}function ig(l,h){var _,S,E,R,ee,Ce,Be,Et,Ei;if(!l||l.length===0)throw new Error("latlngs not passed");No(l)||(console.warn("latlngs are not flat! Only the first ring will be used"),l=l[0]);var on=Me([0,0]),Ln=ri(l),Co=Ln.getNorthWest().distanceTo(Ln.getSouthWest())*Ln.getNorthEast().distanceTo(Ln.getNorthWest());Co<1700&&(on=ng(l));var Xs=l.length,pr=[];for(_=0;_<Xs;_++){var Ao=Me(l[_]);pr.push(h.project(Me([Ao.lat-on.lat,Ao.lng-on.lng])))}for(Ce=Be=Et=0,_=0,S=Xs-1;_<Xs;S=_++)E=pr[_],R=pr[S],ee=E.y*R.x-R.y*E.x,Be+=(E.x+R.x)*ee,Et+=(E.y+R.y)*ee,Ce+=ee*3;Ce===0?Ei=pr[0]:Ei=[Be/Ce,Et/Ce];var Ju=h.unproject(et(Ei));return Me([Ju.lat+on.lat,Ju.lng+on.lng])}function ng(l){for(var h=0,_=0,S=0,E=0;E<l.length;E++){var R=Me(l[E]);h+=R.lat,_+=R.lng,S++}return Me([h/S,_/S])}var fw={__proto__:null,clipPolygon:W_,polygonCenter:ig,centroid:ng};function sg(l,h){if(!h||!l.length)return l.slice();var _=h*h;return l=V_(l,_),l=z_(l,_),l}function B_(l,h,_){return Math.sqrt(Gc(l,h,_,!0))}function og(l,h,_){return Gc(l,h,_)}function z_(l,h){var _=l.length,S=typeof Uint8Array<"u"?Uint8Array:Array,E=new S(_);E[0]=E[_-1]=1,rg(l,E,h,0,_-1);var R,ee=[];for(R=0;R<_;R++)E[R]&&ee.push(l[R]);return ee}function rg(l,h,_,S,E){var R=0,ee,Ce,Be;for(Ce=S+1;Ce<=E-1;Ce++)Be=Gc(l[Ce],l[S],l[E],!0),Be>R&&(ee=Ce,R=Be);R>_&&(h[ee]=1,rg(l,h,_,S,ee),rg(l,h,_,ee,E))}function V_(l,h){for(var _=[l[0]],S=1,E=0,R=l.length;S<R;S++)j_(l[S],l[E])>h&&(_.push(l[S]),E=S);return E<R-1&&_.push(l[R-1]),_}var ag;function lg(l,h,_,S,E){var R=S?ag:Xa(l,_),ee=Xa(h,_),Ce,Be,Et;for(ag=ee;;){if(!(R|ee))return[l,h];if(R&ee)return!1;Ce=R||ee,Be=qc(l,h,Ce,_,E),Et=Xa(Be,_),Ce===R?(l=Be,R=Et):(h=Be,ee=Et)}}function qc(l,h,_,S,E){var R=h.x-l.x,ee=h.y-l.y,Ce=S.min,Be=S.max,Et,Ei;return _&8?(Et=l.x+R*(Be.y-l.y)/ee,Ei=Be.y):_&4?(Et=l.x+R*(Ce.y-l.y)/ee,Ei=Ce.y):_&2?(Et=Be.x,Ei=l.y+ee*(Be.x-l.x)/R):_&1&&(Et=Ce.x,Ei=l.y+ee*(Ce.x-l.x)/R),new Oe(Et,Ei,E)}function Xa(l,h){var _=0;return l.x<h.min.x?_|=1:l.x>h.max.x&&(_|=2),l.y<h.min.y?_|=4:l.y>h.max.y&&(_|=8),_}function j_(l,h){var _=h.x-l.x,S=h.y-l.y;return _*_+S*S}function Gc(l,h,_,S){var E=h.x,R=h.y,ee=_.x-E,Ce=_.y-R,Be=ee*ee+Ce*Ce,Et;return Be>0&&(Et=((l.x-E)*ee+(l.y-R)*Ce)/Be,Et>1?(E=_.x,R=_.y):Et>0&&(E+=ee*Et,R+=Ce*Et)),ee=l.x-E,Ce=l.y-R,S?ee*ee+Ce*Ce:new Oe(E,R)}function No(l){return!F(l[0])||typeof l[0][0]!="object"&&typeof l[0][0]<"u"}function $_(l){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),No(l)}function Ku(l,h){var _,S,E,R,ee,Ce,Be,Et;if(!l||l.length===0)throw new Error("latlngs not passed");No(l)||(console.warn("latlngs are not flat! Only the first ring will be used"),l=l[0]);var Ei=Me([0,0]),on=ri(l),Ln=on.getNorthWest().distanceTo(on.getSouthWest())*on.getNorthEast().distanceTo(on.getNorthWest());Ln<1700&&(Ei=ng(l));var Co=l.length,Xs=[];for(_=0;_<Co;_++){var pr=Me(l[_]);Xs.push(h.project(Me([pr.lat-Ei.lat,pr.lng-Ei.lng])))}for(_=0,S=0;_<Co-1;_++)S+=Xs[_].distanceTo(Xs[_+1])/2;if(S===0)Et=Xs[0];else for(_=0,R=0;_<Co-1;_++)if(ee=Xs[_],Ce=Xs[_+1],E=ee.distanceTo(Ce),R+=E,R>S){Be=(R-S)/E,Et=[Ce.x-Be*(Ce.x-ee.x),Ce.y-Be*(Ce.y-ee.y)];break}var Ao=h.unproject(et(Et));return Me([Ao.lat+Ei.lat,Ao.lng+Ei.lng])}var U_={__proto__:null,simplify:sg,pointToSegmentDistance:B_,closestPointOnSegment:og,clipSegment:lg,_getEdgeIntersection:qc,_getBitCode:Xa,_sqClosestPointOnSegment:Gc,isFlat:No,_flat:$_,polylineCenter:Ku},Zu={project:function(l){return new Oe(l.lng,l.lat)},unproject:function(l){return new Vt(l.y,l.x)},bounds:new ct([-180,-90],[180,90])},Yu={R:6378137,R_MINOR:6356752314245179e-9,bounds:new ct([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(l){var h=Math.PI/180,_=this.R,S=l.lat*h,E=this.R_MINOR/_,R=Math.sqrt(1-E*E),ee=R*Math.sin(S),Ce=Math.tan(Math.PI/4-S/2)/Math.pow((1-ee)/(1+ee),R/2);return S=-_*Math.log(Math.max(Ce,1e-10)),new Oe(l.lng*h*_,S)},unproject:function(l){for(var h=180/Math.PI,_=this.R,S=this.R_MINOR/_,E=Math.sqrt(1-S*S),R=Math.exp(-l.y/_),ee=Math.PI/2-2*Math.atan(R),Ce=0,Be=.1,Et;Ce<15&&Math.abs(Be)>1e-7;Ce++)Et=E*Math.sin(ee),Et=Math.pow((1-Et)/(1+Et),E/2),Be=Math.PI/2-2*Math.atan(R*Et)-ee,ee+=Be;return new Vt(ee*h,l.x*h/_)}},gw={__proto__:null,LonLat:Zu,Mercator:Yu,SphericalMercator:he},q_=n({},ft,{code:"EPSG:3395",projection:Yu,transformation:(function(){var l=.5/(Math.PI*Yu.R);return Ut(l,.5,-l,.5)})()}),Xu=n({},ft,{code:"EPSG:4326",projection:Zu,transformation:Ut(1/180,1,-1/180,.5)}),G_=n({},jt,{projection:Zu,transformation:Ut(1,0,-1,0),scale:function(l){return Math.pow(2,l)},zoom:function(l){return Math.log(l)/Math.LN2},distance:function(l,h){var _=h.lng-l.lng,S=h.lat-l.lat;return Math.sqrt(_*_+S*S)},infinite:!0});jt.Earth=ft,jt.EPSG3395=q_,jt.EPSG3857=wi,jt.EPSG900913=Ri,jt.EPSG4326=Xu,jt.Simple=G_;var Jo=Pt.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(l){return l.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(l){return l&&l.removeLayer(this),this},getPane:function(l){return this._map.getPane(l?this.options[l]||l:this.options.pane)},addInteractiveTarget:function(l){return this._map._targets[d(l)]=this,this},removeInteractiveTarget:function(l){return delete this._map._targets[d(l)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(l){var h=l.target;if(h.hasLayer(this)){if(this._map=h,this._zoomAnimated=h._zoomAnimated,this.getEvents){var _=this.getEvents();h.on(_,this),this.once("remove",function(){h.off(_,this)},this)}this.onAdd(h),this.fire("add"),h.fire("layeradd",{layer:this})}}});vn.include({addLayer:function(l){if(!l._layerAdd)throw new Error("The provided object is not a Layer.");var h=d(l);return this._layers[h]?this:(this._layers[h]=l,l._mapToAdd=this,l.beforeAdd&&l.beforeAdd(this),this.whenReady(l._layerAdd,l),this)},removeLayer:function(l){var h=d(l);return this._layers[h]?(this._loaded&&l.onRemove(this),delete this._layers[h],this._loaded&&(this.fire("layerremove",{layer:l}),l.fire("remove")),l._map=l._mapToAdd=null,this):this},hasLayer:function(l){return d(l)in this._layers},eachLayer:function(l,h){for(var _ in this._layers)l.call(h,this._layers[_]);return this},_addLayers:function(l){l=l?F(l)?l:[l]:[];for(var h=0,_=l.length;h<_;h++)this.addLayer(l[h])},_addZoomLimit:function(l){(!isNaN(l.options.maxZoom)||!isNaN(l.options.minZoom))&&(this._zoomBoundLayers[d(l)]=l,this._updateZoomLevels())},_removeZoomLimit:function(l){var h=d(l);this._zoomBoundLayers[h]&&(delete this._zoomBoundLayers[h],this._updateZoomLevels())},_updateZoomLevels:function(){var l=1/0,h=-1/0,_=this._getZoomSpan();for(var S in this._zoomBoundLayers){var E=this._zoomBoundLayers[S].options;l=E.minZoom===void 0?l:Math.min(l,E.minZoom),h=E.maxZoom===void 0?h:Math.max(h,E.maxZoom)}this._layersMaxZoom=h===-1/0?void 0:h,this._layersMinZoom=l===1/0?void 0:l,_!==this._getZoomSpan()&&this.fire("zoomlevelschange"),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var Bl=Jo.extend({initialize:function(l,h){x(this,h),this._layers={};var _,S;if(l)for(_=0,S=l.length;_<S;_++)this.addLayer(l[_])},addLayer:function(l){var h=this.getLayerId(l);return this._layers[h]=l,this._map&&this._map.addLayer(l),this},removeLayer:function(l){var h=l in this._layers?l:this.getLayerId(l);return this._map&&this._layers[h]&&this._map.removeLayer(this._layers[h]),delete this._layers[h],this},hasLayer:function(l){var h=typeof l=="number"?l:this.getLayerId(l);return h in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(l){var h=Array.prototype.slice.call(arguments,1),_,S;for(_ in this._layers)S=this._layers[_],S[l]&&S[l].apply(S,h);return this},onAdd:function(l){this.eachLayer(l.addLayer,l)},onRemove:function(l){this.eachLayer(l.removeLayer,l)},eachLayer:function(l,h){for(var _ in this._layers)l.call(h,this._layers[_]);return this},getLayer:function(l){return this._layers[l]},getLayers:function(){var l=[];return this.eachLayer(l.push,l),l},setZIndex:function(l){return this.invoke("setZIndex",l)},getLayerId:function(l){return d(l)}}),pw=function(l,h){return new Bl(l,h)},Vr=Bl.extend({addLayer:function(l){return this.hasLayer(l)?this:(l.addEventParent(this),Bl.prototype.addLayer.call(this,l),this.fire("layeradd",{layer:l}))},removeLayer:function(l){return this.hasLayer(l)?(l in this._layers&&(l=this._layers[l]),l.removeEventParent(this),Bl.prototype.removeLayer.call(this,l),this.fire("layerremove",{layer:l})):this},setStyle:function(l){return this.invoke("setStyle",l)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var l=new ti;for(var h in this._layers){var _=this._layers[h];l.extend(_.getBounds?_.getBounds():_.getLatLng())}return l}}),_w=function(l,h){return new Vr(l,h)},zl=we.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(l){x(this,l)},createIcon:function(l){return this._createIcon("icon",l)},createShadow:function(l){return this._createIcon("shadow",l)},_createIcon:function(l,h){var _=this._getIconUrl(l);if(!_){if(l==="icon")throw new Error("iconUrl not set in Icon options (see the docs).");return null}var S=this._createImg(_,h&&h.tagName==="IMG"?h:null);return this._setIconStyles(S,l),(this.options.crossOrigin||this.options.crossOrigin==="")&&(S.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),S},_setIconStyles:function(l,h){var _=this.options,S=_[h+"Size"];typeof S=="number"&&(S=[S,S]);var E=et(S),R=et(h==="shadow"&&_.shadowAnchor||_.iconAnchor||E&&E.divideBy(2,!0));l.className="leaflet-marker-"+h+" "+(_.className||""),R&&(l.style.marginLeft=-R.x+"px",l.style.marginTop=-R.y+"px"),E&&(l.style.width=E.x+"px",l.style.height=E.y+"px")},_createImg:function(l,h){return h=h||document.createElement("img"),h.src=l,h},_getIconUrl:function(l){return We.retina&&this.options[l+"RetinaUrl"]||this.options[l+"Url"]}});function mw(l){return new zl(l)}var Kc=zl.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(l){return typeof Kc.imagePath!="string"&&(Kc.imagePath=this._detectIconPath()),(this.options.imagePath||Kc.imagePath)+zl.prototype._getIconUrl.call(this,l)},_stripUrl:function(l){var h=function(_,S,E){var R=S.exec(_);return R&&R[E]};return l=h(l,/^url\((['"])?(.+)\1\)$/,2),l&&h(l,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var l=G("div","leaflet-default-icon-path",document.body),h=A(l,"background-image")||A(l,"backgroundImage");if(document.body.removeChild(l),h=this._stripUrl(h),h)return h;var _=document.querySelector('link[href$="leaflet.css"]');return _?_.href.substring(0,_.href.length-11-1):""}}),q=gr.extend({initialize:function(l){this._marker=l},addHooks:function(){var l=this._marker._icon;this._draggable||(this._draggable=new Qo(l,l,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),_e(l,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&ge(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(l){var h=this._marker,_=h._map,S=this._marker.options.autoPanSpeed,E=this._marker.options.autoPanPadding,R=St(h._icon),ee=_.getPixelBounds(),Ce=_.getPixelOrigin(),Be=Nt(ee.min._subtract(Ce).add(E),ee.max._subtract(Ce).subtract(E));if(!Be.contains(R)){var Et=et((Math.max(Be.max.x,R.x)-Be.max.x)/(ee.max.x-Be.max.x)-(Math.min(Be.min.x,R.x)-Be.min.x)/(ee.min.x-Be.min.x),(Math.max(Be.max.y,R.y)-Be.max.y)/(ee.max.y-Be.max.y)-(Math.min(Be.min.y,R.y)-Be.min.y)/(ee.min.y-Be.min.y)).multiplyBy(S);_.panBy(Et,{animate:!1}),this._draggable._newPos._add(Et),this._draggable._startPos._add(Et),Ie(h._icon,this._draggable._newPos),this._onDrag(l),this._panRequest=ue(this._adjustPan.bind(this,l))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(l){this._marker.options.autoPan&&(He(this._panRequest),this._panRequest=ue(this._adjustPan.bind(this,l)))},_onDrag:function(l){var h=this._marker,_=h._shadow,S=St(h._icon),E=h._map.layerPointToLatLng(S);_&&Ie(_,S),h._latlng=E,l.latlng=E,l.oldLatLng=this._oldLatLng,h.fire("move",l).fire("drag",l)},_onDragEnd:function(l){He(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",l)}}),ve=Jo.extend({options:{icon:new Kc,interactive:!0,keyboard:!0,title:"",alt:"Marker",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingMouseEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(l,h){x(this,h),this._latlng=Me(l)},onAdd:function(l){this._zoomAnimated=this._zoomAnimated&&l.options.markerZoomAnimation,this._zoomAnimated&&l.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(l){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&l.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(l){var h=this._latlng;return this._latlng=Me(l),this.update(),this.fire("move",{oldLatLng:h,latlng:this._latlng})},setZIndexOffset:function(l){return this.options.zIndexOffset=l,this.update()},getIcon:function(){return this.options.icon},setIcon:function(l){return this.options.icon=l,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var l=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(l)}return this},_initIcon:function(){var l=this.options,h="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),_=l.icon.createIcon(this._icon),S=!1;_!==this._icon&&(this._icon&&this._removeIcon(),S=!0,l.title&&(_.title=l.title),_.tagName==="IMG"&&(_.alt=l.alt||"")),_e(_,h),l.keyboard&&(_.tabIndex="0",_.setAttribute("role","button")),this._icon=_,l.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Je(_,"focus",this._panOnFocus,this);var E=l.icon.createShadow(this._shadow),R=!1;E!==this._shadow&&(this._removeShadow(),R=!0),E&&(_e(E,h),E.alt=""),this._shadow=E,l.opacity<1&&this._updateOpacity(),S&&this.getPane().appendChild(this._icon),this._initInteraction(),E&&R&&this.getPane(l.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&Jt(this._icon,"focus",this._panOnFocus,this),ie(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&ie(this._shadow),this._shadow=null},_setPos:function(l){this._icon&&Ie(this._icon,l),this._shadow&&Ie(this._shadow,l),this._zIndex=l.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(l){this._icon&&(this._icon.style.zIndex=this._zIndex+l)},_animateZoom:function(l){var h=this._map._latLngToNewLayerPoint(this._latlng,l.zoom,l.center).round();this._setPos(h)},_initInteraction:function(){if(this.options.interactive&&(_e(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),q)){var l=this.options.draggable;this.dragging&&(l=this.dragging.enabled(),this.dragging.disable()),this.dragging=new q(this),l&&this.dragging.enable()}},setOpacity:function(l){return this.options.opacity=l,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var l=this.options.opacity;this._icon&&ne(this._icon,l),this._shadow&&ne(this._shadow,l)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var l=this._map;if(l){var h=this.options.icon.options,_=h.iconSize?et(h.iconSize):et(0,0),S=h.iconAnchor?et(h.iconAnchor):et(0,0);l.panInside(this._latlng,{paddingTopLeft:S,paddingBottomRight:_.subtract(S)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function Ye(l,h){return new ve(l,h)}var Te=Jo.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(l){this._renderer=l.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(l){return x(this,l),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&l&&Object.prototype.hasOwnProperty.call(l,"weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}}),Rt=Te.extend({options:{fill:!0,radius:10},initialize:function(l,h){x(this,h),this._latlng=Me(l),this._radius=this.options.radius},setLatLng:function(l){var h=this._latlng;return this._latlng=Me(l),this.redraw(),this.fire("move",{oldLatLng:h,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(l){return this.options.radius=this._radius=l,this.redraw()},getRadius:function(){return this._radius},setStyle:function(l){var h=l&&l.radius||this._radius;return Te.prototype.setStyle.call(this,l),this.setRadius(h),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var l=this._radius,h=this._radiusY||l,_=this._clickTolerance(),S=[l+_,h+_];this._pxBounds=new ct(this._point.subtract(S),this._point.add(S))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(l){return l.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function fi(l,h){return new Rt(l,h)}var ki=Rt.extend({initialize:function(l,h,_){if(typeof h=="number"&&(h=n({},_,{radius:h})),x(this,h),this._latlng=Me(l),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(l){return this._mRadius=l,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var l=[this._radius,this._radiusY||this._radius];return new ti(this._map.layerPointToLatLng(this._point.subtract(l)),this._map.layerPointToLatLng(this._point.add(l)))},setStyle:Te.prototype.setStyle,_project:function(){var l=this._latlng.lng,h=this._latlng.lat,_=this._map,S=_.options.crs;if(S.distance===ft.distance){var E=Math.PI/180,R=this._mRadius/ft.R/E,ee=_.project([h+R,l]),Ce=_.project([h-R,l]),Be=ee.add(Ce).divideBy(2),Et=_.unproject(Be).lat,Ei=Math.acos((Math.cos(R*E)-Math.sin(h*E)*Math.sin(Et*E))/(Math.cos(h*E)*Math.cos(Et*E)))/E;(isNaN(Ei)||Ei===0)&&(Ei=R/Math.cos(Math.PI/180*h)),this._point=Be.subtract(_.getPixelOrigin()),this._radius=isNaN(Ei)?0:Be.x-_.project([Et,l-Ei]).x,this._radiusY=Be.y-ee.y}else{var on=S.unproject(S.project(this._latlng).subtract([this._mRadius,0]));this._point=_.latLngToLayerPoint(this._latlng),this._radius=this._point.x-_.latLngToLayerPoint(on).x}this._updateBounds()}});function hn(l,h,_){return new ki(l,h,_)}var en=Te.extend({options:{smoothFactor:1,noClip:!1},initialize:function(l,h){x(this,h),this._setLatLngs(l)},getLatLngs:function(){return this._latlngs},setLatLngs:function(l){return this._setLatLngs(l),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(l){for(var h=1/0,_=null,S=Gc,E,R,ee=0,Ce=this._parts.length;ee<Ce;ee++)for(var Be=this._parts[ee],Et=1,Ei=Be.length;Et<Ei;Et++){E=Be[Et-1],R=Be[Et];var on=S(l,E,R,!0);on<h&&(h=on,_=S(l,E,R))}return _&&(_.distance=Math.sqrt(h)),_},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return Ku(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(l,h){return h=h||this._defaultShape(),l=Me(l),h.push(l),this._bounds.extend(l),this.redraw()},_setLatLngs:function(l){this._bounds=new ti,this._latlngs=this._convertLatLngs(l)},_defaultShape:function(){return No(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(l){for(var h=[],_=No(l),S=0,E=l.length;S<E;S++)_?(h[S]=Me(l[S]),this._bounds.extend(h[S])):h[S]=this._convertLatLngs(l[S]);return h},_project:function(){var l=new ct;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,l),this._bounds.isValid()&&l.isValid()&&(this._rawPxBounds=l,this._updateBounds())},_updateBounds:function(){var l=this._clickTolerance(),h=new Oe(l,l);this._rawPxBounds&&(this._pxBounds=new ct([this._rawPxBounds.min.subtract(h),this._rawPxBounds.max.add(h)]))},_projectLatlngs:function(l,h,_){var S=l[0]instanceof Vt,E=l.length,R,ee;if(S){for(ee=[],R=0;R<E;R++)ee[R]=this._map.latLngToLayerPoint(l[R]),_.extend(ee[R]);h.push(ee)}else for(R=0;R<E;R++)this._projectLatlngs(l[R],h,_)},_clipPoints:function(){var l=this._renderer._bounds;if(this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(l))){if(this.options.noClip){this._parts=this._rings;return}var h=this._parts,_,S,E,R,ee,Ce,Be;for(_=0,E=0,R=this._rings.length;_<R;_++)for(Be=this._rings[_],S=0,ee=Be.length;S<ee-1;S++)Ce=lg(Be[S],Be[S+1],l,S,!0),Ce&&(h[E]=h[E]||[],h[E].push(Ce[0]),(Ce[1]!==Be[S+1]||S===ee-2)&&(h[E].push(Ce[1]),E++))}},_simplifyPoints:function(){for(var l=this._parts,h=this.options.smoothFactor,_=0,S=l.length;_<S;_++)l[_]=sg(l[_],h)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(l,h){var _,S,E,R,ee,Ce,Be=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(l))return!1;for(_=0,R=this._parts.length;_<R;_++)for(Ce=this._parts[_],S=0,ee=Ce.length,E=ee-1;S<ee;E=S++)if(!(!h&&S===0)&&B_(l,Ce[E],Ce[S])<=Be)return!0;return!1}});function bn(l,h){return new en(l,h)}en._flat=$_;var tn=en.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return ig(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(l){var h=en.prototype._convertLatLngs.call(this,l),_=h.length;return _>=2&&h[0]instanceof Vt&&h[0].equals(h[_-1])&&h.pop(),h},_setLatLngs:function(l){en.prototype._setLatLngs.call(this,l),No(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return No(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var l=this._renderer._bounds,h=this.options.weight,_=new Oe(h,h);if(l=new ct(l.min.subtract(_),l.max.add(_)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(l))){if(this.options.noClip){this._parts=this._rings;return}for(var S=0,E=this._rings.length,R;S<E;S++)R=W_(this._rings[S],l,!0),R.length&&this._parts.push(R)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(l){var h=!1,_,S,E,R,ee,Ce,Be,Et;if(!this._pxBounds||!this._pxBounds.contains(l))return!1;for(R=0,Be=this._parts.length;R<Be;R++)for(_=this._parts[R],ee=0,Et=_.length,Ce=Et-1;ee<Et;Ce=ee++)S=_[ee],E=_[Ce],S.y>l.y!=E.y>l.y&&l.x<(E.x-S.x)*(l.y-S.y)/(E.y-S.y)+S.x&&(h=!h);return h||en.prototype._containsPoint.call(this,l,!0)}});function fn(l,h){return new tn(l,h)}var sn=Vr.extend({initialize:function(l,h){x(this,h),this._layers={},l&&this.addData(l)},addData:function(l){var h=F(l)?l:l.features,_,S,E;if(h){for(_=0,S=h.length;_<S;_++)E=h[_],(E.geometries||E.geometry||E.features||E.coordinates)&&this.addData(E);return this}var R=this.options;if(R.filter&&!R.filter(l))return this;var ee=Bn(l,R);return ee?(ee.feature=ls(l),ee.defaultOptions=ee.options,this.resetStyle(ee),R.onEachFeature&&R.onEachFeature(l,ee),this.addLayer(ee)):this},resetStyle:function(l){return l===void 0?this.eachLayer(this.resetStyle,this):(l.options=n({},l.defaultOptions),this._setLayerStyle(l,this.options.style),this)},setStyle:function(l){return this.eachLayer(function(h){this._setLayerStyle(h,l)},this)},_setLayerStyle:function(l,h){l.setStyle&&(typeof h=="function"&&(h=h(l.feature)),l.setStyle(h))}});function Bn(l,h){var _=l.type==="Feature"?l.geometry:l,S=_?_.coordinates:null,E=[],R=h&&h.pointToLayer,ee=h&&h.coordsToLatLng||Gn,Ce,Be,Et,Ei;if(!S&&!_)return null;switch(_.type){case"Point":return Ce=ee(S),Xn(R,l,Ce,h);case"MultiPoint":for(Et=0,Ei=S.length;Et<Ei;Et++)Ce=ee(S[Et]),E.push(Xn(R,l,Ce,h));return new Vr(E);case"LineString":case"MultiLineString":return Be=an(S,_.type==="LineString"?0:1,ee),new en(Be,h);case"Polygon":case"MultiPolygon":return Be=an(S,_.type==="Polygon"?1:2,ee),new tn(Be,h);case"GeometryCollection":for(Et=0,Ei=_.geometries.length;Et<Ei;Et++){var on=Bn({geometry:_.geometries[Et],type:"Feature",properties:l.properties},h);on&&E.push(on)}return new Vr(E);case"FeatureCollection":for(Et=0,Ei=_.features.length;Et<Ei;Et++){var Ln=Bn(_.features[Et],h);Ln&&E.push(Ln)}return new Vr(E);default:throw new Error("Invalid GeoJSON object.")}}function Xn(l,h,_,S){return l?l(h,_):new ve(_,S&&S.markersInheritOptions&&S)}function Gn(l){return new Vt(l[1],l[0],l[2])}function an(l,h,_){for(var S=[],E=0,R=l.length,ee;E<R;E++)ee=h?an(l[E],h-1,_):(_||Gn)(l[E]),S.push(ee);return S}function gs(l,h){return l=Me(l),l.alt!==void 0?[p(l.lng,h),p(l.lat,h),p(l.alt,h)]:[p(l.lng,h),p(l.lat,h)]}function $s(l,h,_,S){for(var E=[],R=0,ee=l.length;R<ee;R++)E.push(h?$s(l[R],No(l[R])?0:h-1,_,S):gs(l[R],S));return!h&&_&&E.length>0&&E.push(E[0].slice()),E}function xs(l,h){return l.feature?n({},l.feature,{geometry:h}):ls(h)}function ls(l){return l.type==="Feature"||l.type==="FeatureCollection"?l:{type:"Feature",properties:{},geometry:l}}var ss={toGeoJSON:function(l){return xs(this,{type:"Point",coordinates:gs(this.getLatLng(),l)})}};ve.include(ss),ki.include(ss),Rt.include(ss),en.include({toGeoJSON:function(l){var h=!No(this._latlngs),_=$s(this._latlngs,h?1:0,!1,l);return xs(this,{type:(h?"Multi":"")+"LineString",coordinates:_})}}),tn.include({toGeoJSON:function(l){var h=!No(this._latlngs),_=h&&!No(this._latlngs[0]),S=$s(this._latlngs,_?2:h?1:0,!0,l);return h||(S=[S]),xs(this,{type:(_?"Multi":"")+"Polygon",coordinates:S})}}),Bl.include({toMultiPoint:function(l){var h=[];return this.eachLayer(function(_){h.push(_.toGeoJSON(l).geometry.coordinates)}),xs(this,{type:"MultiPoint",coordinates:h})},toGeoJSON:function(l){var h=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(h==="MultiPoint")return this.toMultiPoint(l);var _=h==="GeometryCollection",S=[];return this.eachLayer(function(E){if(E.toGeoJSON){var R=E.toGeoJSON(l);if(_)S.push(R.geometry);else{var ee=ls(R);ee.type==="FeatureCollection"?S.push.apply(S,ee.features):S.push(ee)}}}),_?xs(this,{geometries:S,type:"GeometryCollection"}):{type:"FeatureCollection",features:S}}});function ps(l,h){return new sn(l,h)}var ks=ps,Us=Jo.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(l,h,_){this._url=l,this._bounds=ri(h),x(this,_)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(_e(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){ie(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(l){return this.options.opacity=l,this._image&&this._updateOpacity(),this},setStyle:function(l){return l.opacity&&this.setOpacity(l.opacity),this},bringToFront:function(){return this._map&&Y(this._image),this},bringToBack:function(){return this._map&&le(this._image),this},setUrl:function(l){return this._url=l,this._image&&(this._image.src=l),this},setBounds:function(l){return this._bounds=ri(l),this._map&&this._reset(),this},getEvents:function(){var l={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(l.zoomanim=this._animateZoom),l},setZIndex:function(l){return this.options.zIndex=l,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var l=this._url.tagName==="IMG",h=this._image=l?this._url:G("img");if(_e(h,"leaflet-image-layer"),this._zoomAnimated&&_e(h,"leaflet-zoom-animated"),this.options.className&&_e(h,this.options.className),h.onselectstart=g,h.onmousemove=g,h.onload=r(this.fire,this,"load"),h.onerror=r(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(h.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),l){this._url=h.src;return}h.src=this._url,h.alt=this.options.alt},_animateZoom:function(l){var h=this._map.getZoomScale(l.zoom),_=this._map._latLngBoundsToNewLayerBounds(this._bounds,l.zoom,l.center).min;De(this._image,_,h)},_reset:function(){var l=this._image,h=new ct(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),_=h.getSize();Ie(l,h.min),l.style.width=_.x+"px",l.style.height=_.y+"px"},_updateOpacity:function(){ne(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var l=this.options.errorOverlayUrl;l&&this._url!==l&&(this._url=l,this._image.src=l)},getCenter:function(){return this._bounds.getCenter()}}),_a=function(l,h,_){return new Us(l,h,_)},jr=Us.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var l=this._url.tagName==="VIDEO",h=this._image=l?this._url:G("video");if(_e(h,"leaflet-image-layer"),this._zoomAnimated&&_e(h,"leaflet-zoom-animated"),this.options.className&&_e(h,this.options.className),h.onselectstart=g,h.onmousemove=g,h.onloadeddata=r(this.fire,this,"load"),l){for(var _=h.getElementsByTagName("source"),S=[],E=0;E<_.length;E++)S.push(_[E].src);this._url=_.length>0?S:[h.src];return}F(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(h.style,"objectFit")&&(h.style.objectFit="fill"),h.autoplay=!!this.options.autoplay,h.loop=!!this.options.loop,h.muted=!!this.options.muted,h.playsInline=!!this.options.playsInline;for(var R=0;R<this._url.length;R++){var ee=G("source");ee.src=this._url[R],h.appendChild(ee)}}});function qs(l,h,_){return new jr(l,h,_)}var kn=Us.extend({_initImage:function(){var l=this._image=this._url;_e(l,"leaflet-image-layer"),this._zoomAnimated&&_e(l,"leaflet-zoom-animated"),this.options.className&&_e(l,this.options.className),l.onselectstart=g,l.onmousemove=g}});function er(l,h,_){return new kn(l,h,_)}var Ns=Jo.extend({options:{interactive:!1,offset:[0,0],className:"",pane:void 0,content:""},initialize:function(l,h){l&&(l instanceof Vt||F(l))?(this._latlng=Me(l),x(this,h)):(x(this,l),this._source=h),this.options.content&&(this._content=this.options.content)},openOn:function(l){return l=arguments.length?l:this._source._map,l.hasLayer(this)||l.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(l){return this._map?this.close():(arguments.length?this._source=l:l=this._source,this._prepareOpen(),this.openOn(l._map)),this},onAdd:function(l){this._zoomAnimated=l._zoomAnimated,this._container||this._initLayout(),l._fadeAnimated&&ne(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),l._fadeAnimated&&ne(this._container,1),this.bringToFront(),this.options.interactive&&(_e(this._container,"leaflet-interactive"),this.addInteractiveTarget(this._container))},onRemove:function(l){l._fadeAnimated?(ne(this._container,0),this._removeTimeout=setTimeout(r(ie,void 0,this._container),200)):ie(this._container),this.options.interactive&&(ge(this._container,"leaflet-interactive"),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(l){return this._latlng=Me(l),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(l){return this._content=l,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var l={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(l.zoomanim=this._animateZoom),l},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&Y(this._container),this},bringToBack:function(){return this._map&&le(this._container),this},_prepareOpen:function(l){var h=this._source;if(!h._map)return!1;if(h instanceof Vr){h=null;var _=this._source._layers;for(var S in _)if(_[S]._map){h=_[S];break}if(!h)return!1;this._source=h}if(!l)if(h.getCenter)l=h.getCenter();else if(h.getLatLng)l=h.getLatLng();else if(h.getBounds)l=h.getBounds().getCenter();else throw new Error("Unable to get source layer LatLng.");return this.setLatLng(l),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var l=this._contentNode,h=typeof this._content=="function"?this._content(this._source||this):this._content;if(typeof h=="string")l.innerHTML=h;else{for(;l.hasChildNodes();)l.removeChild(l.firstChild);l.appendChild(h)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var l=this._map.latLngToLayerPoint(this._latlng),h=et(this.options.offset),_=this._getAnchor();this._zoomAnimated?Ie(this._container,l.add(_)):h=h.add(l).add(_);var S=this._containerBottom=-h.y,E=this._containerLeft=-Math.round(this._containerWidth/2)+h.x;this._container.style.bottom=S+"px",this._container.style.left=E+"px"}},_getAnchor:function(){return[0,0]}});vn.include({_initOverlay:function(l,h,_,S){var E=h;return E instanceof l||(E=new l(S).setContent(h)),_&&E.setLatLng(_),E}}),Jo.include({_initOverlay:function(l,h,_,S){var E=_;return E instanceof l?(x(E,S),E._source=this):(E=h&&!S?h:new l(S,this),E.setContent(_)),E}});var $r=Ns.extend({options:{pane:"popupPane",offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:""},openOn:function(l){return l=arguments.length?l:this._source._map,!l.hasLayer(this)&&l._popup&&l._popup.options.autoClose&&l.removeLayer(l._popup),l._popup=this,Ns.prototype.openOn.call(this,l)},onAdd:function(l){Ns.prototype.onAdd.call(this,l),l.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof Te||this._source.on("preclick",Hi))},onRemove:function(l){Ns.prototype.onRemove.call(this,l),l.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof Te||this._source.off("preclick",Hi))},getEvents:function(){var l=Ns.prototype.getEvents.call(this);return(this.options.closeOnClick!==void 0?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(l.preclick=this.close),this.options.keepInView&&(l.moveend=this._adjustPan),l},_initLayout:function(){var l="leaflet-popup",h=this._container=G("div",l+" "+(this.options.className||"")+" leaflet-zoom-animated"),_=this._wrapper=G("div",l+"-content-wrapper",h);if(this._contentNode=G("div",l+"-content",_),un(h),li(this._contentNode),Je(h,"contextmenu",Hi),this._tipContainer=G("div",l+"-tip-container",h),this._tip=G("div",l+"-tip",this._tipContainer),this.options.closeButton){var S=this._closeButton=G("a",l+"-close-button",h);S.setAttribute("role","button"),S.setAttribute("aria-label","Close popup"),S.href="#close",S.innerHTML='<span aria-hidden="true">&#215;</span>',Je(S,"click",function(E){rn(E),this.close()},this)}},_updateLayout:function(){var l=this._contentNode,h=l.style;h.width="",h.whiteSpace="nowrap";var _=l.offsetWidth;_=Math.min(_,this.options.maxWidth),_=Math.max(_,this.options.minWidth),h.width=_+1+"px",h.whiteSpace="",h.height="";var S=l.offsetHeight,E=this.options.maxHeight,R="leaflet-popup-scrolled";E&&S>E?(h.height=E+"px",_e(l,R)):ge(l,R),this._containerWidth=this._container.offsetWidth},_animateZoom:function(l){var h=this._map._latLngToNewLayerPoint(this._latlng,l.zoom,l.center),_=this._getAnchor();Ie(this._container,h.add(_))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var l=this._map,h=parseInt(A(this._container,"marginBottom"),10)||0,_=this._container.offsetHeight+h,S=this._containerWidth,E=new Oe(this._containerLeft,-_-this._containerBottom);E._add(St(this._container));var R=l.layerPointToContainerPoint(E),ee=et(this.options.autoPanPadding),Ce=et(this.options.autoPanPaddingTopLeft||ee),Be=et(this.options.autoPanPaddingBottomRight||ee),Et=l.getSize(),Ei=0,on=0;R.x+S+Be.x>Et.x&&(Ei=R.x+S-Et.x+Be.x),R.x-Ei-Ce.x<0&&(Ei=R.x-Ce.x),R.y+_+Be.y>Et.y&&(on=R.y+_-Et.y+Be.y),R.y-on-Ce.y<0&&(on=R.y-Ce.y),(Ei||on)&&(this.options.keepInView&&(this._autopanning=!0),l.fire("autopanstart").panBy([Ei,on]))}},_getAnchor:function(){return et(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),cg=function(l,h){return new $r(l,h)};vn.mergeOptions({closePopupOnClick:!0}),vn.include({openPopup:function(l,h,_){return this._initOverlay($r,l,h,_).openOn(this),this},closePopup:function(l){return l=arguments.length?l:this._popup,l&&l.close(),this}}),Jo.include({bindPopup:function(l,h){return this._popup=this._initOverlay($r,this._popup,l,h),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(l){return this._popup&&(this instanceof Vr||(this._popup._source=this),this._popup._prepareOpen(l||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(l){return this._popup&&this._popup.setContent(l),this},getPopup:function(){return this._popup},_openPopup:function(l){if(!(!this._popup||!this._map)){es(l);var h=l.layer||l.target;if(this._popup._source===h&&!(h instanceof Te)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(l.latlng);return}this._popup._source=h,this.openPopup(l.latlng)}},_movePopup:function(l){this._popup.setLatLng(l.latlng)},_onKeyPress:function(l){l.originalEvent.keyCode===13&&this._openPopup(l)}});var Vl=Ns.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(l){Ns.prototype.onAdd.call(this,l),this.setOpacity(this.options.opacity),l.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(l){Ns.prototype.onRemove.call(this,l),l.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var l=Ns.prototype.getEvents.call(this);return this.options.permanent||(l.preclick=this.close),l},_initLayout:function(){var l="leaflet-tooltip",h=l+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=G("div",h),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+d(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(l){var h,_,S=this._map,E=this._container,R=S.latLngToContainerPoint(S.getCenter()),ee=S.layerPointToContainerPoint(l),Ce=this.options.direction,Be=E.offsetWidth,Et=E.offsetHeight,Ei=et(this.options.offset),on=this._getAnchor();Ce==="top"?(h=Be/2,_=Et):Ce==="bottom"?(h=Be/2,_=0):Ce==="center"?(h=Be/2,_=Et/2):Ce==="right"?(h=0,_=Et/2):Ce==="left"?(h=Be,_=Et/2):ee.x<R.x?(Ce="right",h=0,_=Et/2):(Ce="left",h=Be+(Ei.x+on.x)*2,_=Et/2),l=l.subtract(et(h,_,!0)).add(Ei).add(on),ge(E,"leaflet-tooltip-right"),ge(E,"leaflet-tooltip-left"),ge(E,"leaflet-tooltip-top"),ge(E,"leaflet-tooltip-bottom"),_e(E,"leaflet-tooltip-"+Ce),Ie(E,l)},_updatePosition:function(){var l=this._map.latLngToLayerPoint(this._latlng);this._setPosition(l)},setOpacity:function(l){this.options.opacity=l,this._container&&ne(this._container,l)},_animateZoom:function(l){var h=this._map._latLngToNewLayerPoint(this._latlng,l.zoom,l.center);this._setPosition(h)},_getAnchor:function(){return et(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),dg=function(l,h){return new Vl(l,h)};vn.include({openTooltip:function(l,h,_){return this._initOverlay(Vl,l,h,_).openOn(this),this},closeTooltip:function(l){return l.close(),this}}),Jo.include({bindTooltip:function(l,h){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(Vl,this._tooltip,l,h),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(l){if(!(!l&&this._tooltipHandlersAdded)){var h=l?"off":"on",_={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?_.add=this._openTooltip:(_.mouseover=this._openTooltip,_.mouseout=this.closeTooltip,_.click=this._openTooltip,this._map?this._addFocusListeners():_.add=this._addFocusListeners),this._tooltip.options.sticky&&(_.mousemove=this._moveTooltip),this[h](_),this._tooltipHandlersAdded=!l}},openTooltip:function(l){return this._tooltip&&(this instanceof Vr||(this._tooltip._source=this),this._tooltip._prepareOpen(l)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip:function(){if(this._tooltip)return this._tooltip.close()},toggleTooltip:function(){return this._tooltip&&this._tooltip.toggle(this),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(l){return this._tooltip&&this._tooltip.setContent(l),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(l){var h=typeof l.getElement=="function"&&l.getElement();h&&(Je(h,"focus",function(){this._tooltip._source=l,this.openTooltip()},this),Je(h,"blur",this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(l){var h=typeof l.getElement=="function"&&l.getElement();h&&h.setAttribute("aria-describedby",this._tooltip._container.id)},_openTooltip:function(l){if(!(!this._tooltip||!this._map)){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var h=this;this._map.once("moveend",function(){h._openOnceFlag=!1,h._openTooltip(l)});return}this._tooltip._source=l.layer||l.target,this.openTooltip(this._tooltip.options.sticky?l.latlng:void 0)}},_moveTooltip:function(l){var h=l.latlng,_,S;this._tooltip.options.sticky&&l.originalEvent&&(_=this._map.mouseEventToContainerPoint(l.originalEvent),S=this._map.containerPointToLayerPoint(_),h=this._map.layerPointToLatLng(S)),this._tooltip.setLatLng(h)}});var Ur=zl.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(l){var h=l&&l.tagName==="DIV"?l:document.createElement("div"),_=this.options;if(_.html instanceof Element?(fe(h),h.appendChild(_.html)):h.innerHTML=_.html!==!1?_.html:"",_.bgPos){var S=et(_.bgPos);h.style.backgroundPosition=-S.x+"px "+-S.y+"px"}return this._setIconStyles(h,"icon"),h},createShadow:function(){return null}});function vw(l){return new Ur(l)}zl.Default=Kc;var Zc=Jo.extend({options:{tileSize:256,opacity:1,updateWhenIdle:We.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(l){x(this,l)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(l){l._addZoomLimit(this)},onRemove:function(l){this._removeAllTiles(),ie(this._container),l._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(Y(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(le(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(l){return this.options.opacity=l,this._updateOpacity(),this},setZIndex:function(l){return this.options.zIndex=l,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var l=this._clampZoom(this._map.getZoom());l!==this._tileZoom&&(this._tileZoom=l,this._updateLevels()),this._update()}return this},getEvents:function(){var l={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=u(this._onMoveEnd,this.options.updateInterval,this)),l.move=this._onMove),this._zoomAnimated&&(l.zoomanim=this._animateZoom),l},createTile:function(){return document.createElement("div")},getTileSize:function(){var l=this.options.tileSize;return l instanceof Oe?l:new Oe(l,l)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(l){for(var h=this.getPane().children,_=-l(-1/0,1/0),S=0,E=h.length,R;S<E;S++)R=h[S].style.zIndex,h[S]!==this._container&&R&&(_=l(_,+R));isFinite(_)&&(this.options.zIndex=_+l(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!We.ielt9){ne(this._container,this.options.opacity);var l=+new Date,h=!1,_=!1;for(var S in this._tiles){var E=this._tiles[S];if(!(!E.current||!E.loaded)){var R=Math.min(1,(l-E.loaded)/200);ne(E.el,R),R<1?h=!0:(E.active?_=!0:this._onOpaqueTile(E),E.active=!0)}}_&&!this._noPrune&&this._pruneTiles(),h&&(He(this._fadeFrame),this._fadeFrame=ue(this._updateOpacity,this))}},_onOpaqueTile:g,_initContainer:function(){this._container||(this._container=G("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var l=this._tileZoom,h=this.options.maxZoom;if(l!==void 0){for(var _ in this._levels)_=Number(_),this._levels[_].el.children.length||_===l?(this._levels[_].el.style.zIndex=h-Math.abs(l-_),this._onUpdateLevel(_)):(ie(this._levels[_].el),this._removeTilesAtZoom(_),this._onRemoveLevel(_),delete this._levels[_]);var S=this._levels[l],E=this._map;return S||(S=this._levels[l]={},S.el=G("div","leaflet-tile-container leaflet-zoom-animated",this._container),S.el.style.zIndex=h,S.origin=E.project(E.unproject(E.getPixelOrigin()),l).round(),S.zoom=l,this._setZoomTransform(S,E.getCenter(),E.getZoom()),g(S.el.offsetWidth),this._onCreateLevel(S)),this._level=S,S}},_onUpdateLevel:g,_onRemoveLevel:g,_onCreateLevel:g,_pruneTiles:function(){if(this._map){var l,h,_=this._map.getZoom();if(_>this.options.maxZoom||_<this.options.minZoom){this._removeAllTiles();return}for(l in this._tiles)h=this._tiles[l],h.retain=h.current;for(l in this._tiles)if(h=this._tiles[l],h.current&&!h.active){var S=h.coords;this._retainParent(S.x,S.y,S.z,S.z-5)||this._retainChildren(S.x,S.y,S.z,S.z+2)}for(l in this._tiles)this._tiles[l].retain||this._removeTile(l)}},_removeTilesAtZoom:function(l){for(var h in this._tiles)this._tiles[h].coords.z===l&&this._removeTile(h)},_removeAllTiles:function(){for(var l in this._tiles)this._removeTile(l)},_invalidateAll:function(){for(var l in this._levels)ie(this._levels[l].el),this._onRemoveLevel(Number(l)),delete this._levels[l];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(l,h,_,S){var E=Math.floor(l/2),R=Math.floor(h/2),ee=_-1,Ce=new Oe(+E,+R);Ce.z=+ee;var Be=this._tileCoordsToKey(Ce),Et=this._tiles[Be];return Et&&Et.active?(Et.retain=!0,!0):(Et&&Et.loaded&&(Et.retain=!0),ee>S?this._retainParent(E,R,ee,S):!1)},_retainChildren:function(l,h,_,S){for(var E=2*l;E<2*l+2;E++)for(var R=2*h;R<2*h+2;R++){var ee=new Oe(E,R);ee.z=_+1;var Ce=this._tileCoordsToKey(ee),Be=this._tiles[Ce];if(Be&&Be.active){Be.retain=!0;continue}else Be&&Be.loaded&&(Be.retain=!0);_+1<S&&this._retainChildren(E,R,_+1,S)}},_resetView:function(l){var h=l&&(l.pinch||l.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),h,h)},_animateZoom:function(l){this._setView(l.center,l.zoom,!0,l.noUpdate)},_clampZoom:function(l){var h=this.options;return h.minNativeZoom!==void 0&&l<h.minNativeZoom?h.minNativeZoom:h.maxNativeZoom!==void 0&&h.maxNativeZoom<l?h.maxNativeZoom:l},_setView:function(l,h,_,S){var E=Math.round(h);this.options.maxZoom!==void 0&&E>this.options.maxZoom||this.options.minZoom!==void 0&&E<this.options.minZoom?E=void 0:E=this._clampZoom(E);var R=this.options.updateWhenZooming&&E!==this._tileZoom;(!S||R)&&(this._tileZoom=E,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),E!==void 0&&this._update(l),_||this._pruneTiles(),this._noPrune=!!_),this._setZoomTransforms(l,h)},_setZoomTransforms:function(l,h){for(var _ in this._levels)this._setZoomTransform(this._levels[_],l,h)},_setZoomTransform:function(l,h,_){var S=this._map.getZoomScale(_,l.zoom),E=l.origin.multiplyBy(S).subtract(this._map._getNewPixelOrigin(h,_)).round();We.any3d?De(l.el,E,S):Ie(l.el,E)},_resetGrid:function(){var l=this._map,h=l.options.crs,_=this._tileSize=this.getTileSize(),S=this._tileZoom,E=this._map.getPixelWorldBounds(this._tileZoom);E&&(this._globalTileRange=this._pxBoundsToTileRange(E)),this._wrapX=h.wrapLng&&!this.options.noWrap&&[Math.floor(l.project([0,h.wrapLng[0]],S).x/_.x),Math.ceil(l.project([0,h.wrapLng[1]],S).x/_.y)],this._wrapY=h.wrapLat&&!this.options.noWrap&&[Math.floor(l.project([h.wrapLat[0],0],S).y/_.x),Math.ceil(l.project([h.wrapLat[1],0],S).y/_.y)]},_onMoveEnd:function(){!this._map||this._map._animatingZoom||this._update()},_getTiledPixelBounds:function(l){var h=this._map,_=h._animatingZoom?Math.max(h._animateToZoom,h.getZoom()):h.getZoom(),S=h.getZoomScale(_,this._tileZoom),E=h.project(l,this._tileZoom).floor(),R=h.getSize().divideBy(S*2);return new ct(E.subtract(R),E.add(R))},_update:function(l){var h=this._map;if(h){var _=this._clampZoom(h.getZoom());if(l===void 0&&(l=h.getCenter()),this._tileZoom!==void 0){var S=this._getTiledPixelBounds(l),E=this._pxBoundsToTileRange(S),R=E.getCenter(),ee=[],Ce=this.options.keepBuffer,Be=new ct(E.getBottomLeft().subtract([Ce,-Ce]),E.getTopRight().add([Ce,-Ce]));if(!(isFinite(E.min.x)&&isFinite(E.min.y)&&isFinite(E.max.x)&&isFinite(E.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var Et in this._tiles){var Ei=this._tiles[Et].coords;(Ei.z!==this._tileZoom||!Be.contains(new Oe(Ei.x,Ei.y)))&&(this._tiles[Et].current=!1)}if(Math.abs(_-this._tileZoom)>1){this._setView(l,_);return}for(var on=E.min.y;on<=E.max.y;on++)for(var Ln=E.min.x;Ln<=E.max.x;Ln++){var Co=new Oe(Ln,on);if(Co.z=this._tileZoom,!!this._isValidTile(Co)){var Xs=this._tiles[this._tileCoordsToKey(Co)];Xs?Xs.current=!0:ee.push(Co)}}if(ee.sort(function(Ao,Ju){return Ao.distanceTo(R)-Ju.distanceTo(R)}),ee.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var pr=document.createDocumentFragment();for(Ln=0;Ln<ee.length;Ln++)this._addTile(ee[Ln],pr);this._level.el.appendChild(pr)}}}},_isValidTile:function(l){var h=this._map.options.crs;if(!h.infinite){var _=this._globalTileRange;if(!h.wrapLng&&(l.x<_.min.x||l.x>_.max.x)||!h.wrapLat&&(l.y<_.min.y||l.y>_.max.y))return!1}if(!this.options.bounds)return!0;var S=this._tileCoordsToBounds(l);return ri(this.options.bounds).overlaps(S)},_keyToBounds:function(l){return this._tileCoordsToBounds(this._keyToTileCoords(l))},_tileCoordsToNwSe:function(l){var h=this._map,_=this.getTileSize(),S=l.scaleBy(_),E=S.add(_),R=h.unproject(S,l.z),ee=h.unproject(E,l.z);return[R,ee]},_tileCoordsToBounds:function(l){var h=this._tileCoordsToNwSe(l),_=new ti(h[0],h[1]);return this.options.noWrap||(_=this._map.wrapLatLngBounds(_)),_},_tileCoordsToKey:function(l){return l.x+":"+l.y+":"+l.z},_keyToTileCoords:function(l){var h=l.split(":"),_=new Oe(+h[0],+h[1]);return _.z=+h[2],_},_removeTile:function(l){var h=this._tiles[l];h&&(ie(h.el),delete this._tiles[l],this.fire("tileunload",{tile:h.el,coords:this._keyToTileCoords(l)}))},_initTile:function(l){_e(l,"leaflet-tile");var h=this.getTileSize();l.style.width=h.x+"px",l.style.height=h.y+"px",l.onselectstart=g,l.onmousemove=g,We.ielt9&&this.options.opacity<1&&ne(l,this.options.opacity)},_addTile:function(l,h){var _=this._getTilePos(l),S=this._tileCoordsToKey(l),E=this.createTile(this._wrapCoords(l),r(this._tileReady,this,l));this._initTile(E),this.createTile.length<2&&ue(r(this._tileReady,this,l,null,E)),Ie(E,_),this._tiles[S]={el:E,coords:l,current:!0},h.appendChild(E),this.fire("tileloadstart",{tile:E,coords:l})},_tileReady:function(l,h,_){h&&this.fire("tileerror",{error:h,tile:_,coords:l});var S=this._tileCoordsToKey(l);_=this._tiles[S],_&&(_.loaded=+new Date,this._map._fadeAnimated?(ne(_.el,0),He(this._fadeFrame),this._fadeFrame=ue(this._updateOpacity,this)):(_.active=!0,this._pruneTiles()),h||(_e(_.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:_.el,coords:l})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),We.ielt9||!this._map._fadeAnimated?ue(this._pruneTiles,this):setTimeout(r(this._pruneTiles,this),250)))},_getTilePos:function(l){return l.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(l){var h=new Oe(this._wrapX?f(l.x,this._wrapX):l.x,this._wrapY?f(l.y,this._wrapY):l.y);return h.z=l.z,h},_pxBoundsToTileRange:function(l){var h=this.getTileSize();return new ct(l.min.unscaleBy(h).floor(),l.max.unscaleBy(h).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var l in this._tiles)if(!this._tiles[l].loaded)return!1;return!0}});function Mn(l){return new Zc(l)}var bs=Zc.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(l,h){this._url=l,h=x(this,h),h.detectRetina&&We.retina&&h.maxZoom>0?(h.tileSize=Math.floor(h.tileSize/2),h.zoomReverse?(h.zoomOffset--,h.minZoom=Math.min(h.maxZoom,h.minZoom+1)):(h.zoomOffset++,h.maxZoom=Math.max(h.minZoom,h.maxZoom-1)),h.minZoom=Math.max(0,h.minZoom)):h.zoomReverse?h.minZoom=Math.min(h.maxZoom,h.minZoom):h.maxZoom=Math.max(h.minZoom,h.maxZoom),typeof h.subdomains=="string"&&(h.subdomains=h.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(l,h){return this._url===l&&h===void 0&&(h=!0),this._url=l,h||this.redraw(),this},createTile:function(l,h){var _=document.createElement("img");return Je(_,"load",r(this._tileOnLoad,this,h,_)),Je(_,"error",r(this._tileOnError,this,h,_)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(_.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(_.referrerPolicy=this.options.referrerPolicy),_.alt="",_.src=this.getTileUrl(l),_},getTileUrl:function(l){var h={r:We.retina?"@2x":"",s:this._getSubdomain(l),x:l.x,y:l.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var _=this._globalTileRange.max.y-l.y;this.options.tms&&(h.y=_),h["-y"]=_}return M(this._url,n(h,this.options))},_tileOnLoad:function(l,h){We.ielt9?setTimeout(r(l,this,null,h),0):l(null,h)},_tileOnError:function(l,h,_){var S=this.options.errorTileUrl;S&&h.getAttribute("src")!==S&&(h.src=S),l(_,h)},_onTileRemove:function(l){l.tile.onload=null},_getZoomForUrl:function(){var l=this._tileZoom,h=this.options.maxZoom,_=this.options.zoomReverse,S=this.options.zoomOffset;return _&&(l=h-l),l+S},_getSubdomain:function(l){var h=Math.abs(l.x+l.y)%this.options.subdomains.length;return this.options.subdomains[h]},_abortLoading:function(){var l,h;for(l in this._tiles)if(this._tiles[l].coords.z!==this._tileZoom&&(h=this._tiles[l].el,h.onload=g,h.onerror=g,!h.complete)){h.src=V;var _=this._tiles[l].coords;ie(h),delete this._tiles[l],this.fire("tileabort",{tile:h,coords:_})}},_removeTile:function(l){var h=this._tiles[l];if(h)return h.el.setAttribute("src",V),Zc.prototype._removeTile.call(this,l)},_tileReady:function(l,h,_){if(!(!this._map||_&&_.getAttribute("src")===V))return Zc.prototype._tileReady.call(this,l,h,_)}});function Yc(l,h){return new bs(l,h)}var Qu=bs.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(l,h){this._url=l;var _=n({},this.defaultWmsParams);for(var S in h)S in this.options||(_[S]=h[S]);h=x(this,h);var E=h.detectRetina&&We.retina?2:1,R=this.getTileSize();_.width=R.x*E,_.height=R.y*E,this.wmsParams=_},onAdd:function(l){this._crs=this.options.crs||l.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var h=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[h]=this._crs.code,bs.prototype.onAdd.call(this,l)},getTileUrl:function(l){var h=this._tileCoordsToNwSe(l),_=this._crs,S=Nt(_.project(h[0]),_.project(h[1])),E=S.min,R=S.max,ee=(this._wmsVersion>=1.3&&this._crs===Xu?[E.y,E.x,R.y,R.x]:[E.x,E.y,R.x,R.y]).join(","),Ce=bs.prototype.getTileUrl.call(this,l);return Ce+k(this.wmsParams,Ce,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+ee},setParams:function(l,h){return n(this.wmsParams,l),h||this.redraw(),this}});function EA(l,h){return new Qu(l,h)}bs.WMS=Qu,Yc.wms=EA;var Qa=Jo.extend({options:{padding:.1},initialize:function(l){x(this,l),d(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),_e(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var l={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(l.zoomanim=this._onAnimZoom),l},_onAnimZoom:function(l){this._updateTransform(l.center,l.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(l,h){var _=this._map.getZoomScale(h,this._zoom),S=this._map.getSize().multiplyBy(.5+this.options.padding),E=this._map.project(this._center,h),R=S.multiplyBy(-_).add(E).subtract(this._map._getNewPixelOrigin(l,h));We.any3d?De(this._container,R,_):Ie(this._container,R)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var l in this._layers)this._layers[l]._reset()},_onZoomEnd:function(){for(var l in this._layers)this._layers[l]._project()},_updatePaths:function(){for(var l in this._layers)this._layers[l]._update()},_update:function(){var l=this.options.padding,h=this._map.getSize(),_=this._map.containerPointToLayerPoint(h.multiplyBy(-l)).round();this._bounds=new ct(_,_.add(h.multiplyBy(1+l*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Kk=Qa.extend({options:{tolerance:0},getEvents:function(){var l=Qa.prototype.getEvents.call(this);return l.viewprereset=this._onViewPreReset,l},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Qa.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var l=this._container=document.createElement("canvas");Je(l,"mousemove",this._onMouseMove,this),Je(l,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Je(l,"mouseout",this._handleMouseOut,this),l._leaflet_disable_events=!0,this._ctx=l.getContext("2d")},_destroyContainer:function(){He(this._redrawRequest),delete this._ctx,ie(this._container),Jt(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var l;this._redrawBounds=null;for(var h in this._layers)l=this._layers[h],l._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Qa.prototype._update.call(this);var l=this._bounds,h=this._container,_=l.getSize(),S=We.retina?2:1;Ie(h,l.min),h.width=S*_.x,h.height=S*_.y,h.style.width=_.x+"px",h.style.height=_.y+"px",We.retina&&this._ctx.scale(2,2),this._ctx.translate(-l.min.x,-l.min.y),this.fire("update")}},_reset:function(){Qa.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(l){this._updateDashArray(l),this._layers[d(l)]=l;var h=l._order={layer:l,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=h),this._drawLast=h,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(l){this._requestRedraw(l)},_removePath:function(l){var h=l._order,_=h.next,S=h.prev;_?_.prev=S:this._drawLast=S,S?S.next=_:this._drawFirst=_,delete l._order,delete this._layers[d(l)],this._requestRedraw(l)},_updatePath:function(l){this._extendRedrawBounds(l),l._project(),l._update(),this._requestRedraw(l)},_updateStyle:function(l){this._updateDashArray(l),this._requestRedraw(l)},_updateDashArray:function(l){if(typeof l.options.dashArray=="string"){var h=l.options.dashArray.split(/[, ]+/),_=[],S,E;for(E=0;E<h.length;E++){if(S=Number(h[E]),isNaN(S))return;_.push(S)}l.options._dashArray=_}else l.options._dashArray=l.options.dashArray},_requestRedraw:function(l){this._map&&(this._extendRedrawBounds(l),this._redrawRequest=this._redrawRequest||ue(this._redraw,this))},_extendRedrawBounds:function(l){if(l._pxBounds){var h=(l.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new ct,this._redrawBounds.extend(l._pxBounds.min.subtract([h,h])),this._redrawBounds.extend(l._pxBounds.max.add([h,h]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var l=this._redrawBounds;if(l){var h=l.getSize();this._ctx.clearRect(l.min.x,l.min.y,h.x,h.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()},_draw:function(){var l,h=this._redrawBounds;if(this._ctx.save(),h){var _=h.getSize();this._ctx.beginPath(),this._ctx.rect(h.min.x,h.min.y,_.x,_.y),this._ctx.clip()}this._drawing=!0;for(var S=this._drawFirst;S;S=S.next)l=S.layer,(!h||l._pxBounds&&l._pxBounds.intersects(h))&&l._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(l,h){if(this._drawing){var _,S,E,R,ee=l._parts,Ce=ee.length,Be=this._ctx;if(Ce){for(Be.beginPath(),_=0;_<Ce;_++){for(S=0,E=ee[_].length;S<E;S++)R=ee[_][S],Be[S?"lineTo":"moveTo"](R.x,R.y);h&&Be.closePath()}this._fillStroke(Be,l)}}},_updateCircle:function(l){if(!(!this._drawing||l._empty())){var h=l._point,_=this._ctx,S=Math.max(Math.round(l._radius),1),E=(Math.max(Math.round(l._radiusY),1)||S)/S;E!==1&&(_.save(),_.scale(1,E)),_.beginPath(),_.arc(h.x,h.y/E,S,0,Math.PI*2,!1),E!==1&&_.restore(),this._fillStroke(_,l)}},_fillStroke:function(l,h){var _=h.options;_.fill&&(l.globalAlpha=_.fillOpacity,l.fillStyle=_.fillColor||_.color,l.fill(_.fillRule||"evenodd")),_.stroke&&_.weight!==0&&(l.setLineDash&&l.setLineDash(h.options&&h.options._dashArray||[]),l.globalAlpha=_.opacity,l.lineWidth=_.weight,l.strokeStyle=_.color,l.lineCap=_.lineCap,l.lineJoin=_.lineJoin,l.stroke())},_onClick:function(l){for(var h=this._map.mouseEventToLayerPoint(l),_,S,E=this._drawFirst;E;E=E.next)_=E.layer,_.options.interactive&&_._containsPoint(h)&&(!(l.type==="click"||l.type==="preclick")||!this._map._draggableMoved(_))&&(S=_);this._fireEvent(S?[S]:!1,l)},_onMouseMove:function(l){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var h=this._map.mouseEventToLayerPoint(l);this._handleMouseHover(l,h)}},_handleMouseOut:function(l){var h=this._hoveredLayer;h&&(ge(this._container,"leaflet-interactive"),this._fireEvent([h],l,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(l,h){if(!this._mouseHoverThrottled){for(var _,S,E=this._drawFirst;E;E=E.next)_=E.layer,_.options.interactive&&_._containsPoint(h)&&(S=_);S!==this._hoveredLayer&&(this._handleMouseOut(l),S&&(_e(this._container,"leaflet-interactive"),this._fireEvent([S],l,"mouseover"),this._hoveredLayer=S)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,l),this._mouseHoverThrottled=!0,setTimeout(r(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(l,h,_){this._map._fireDOMEvent(h,_||h.type,l)},_bringToFront:function(l){var h=l._order;if(h){var _=h.next,S=h.prev;if(_)_.prev=S;else return;S?S.next=_:_&&(this._drawFirst=_),h.prev=this._drawLast,this._drawLast.next=h,h.next=null,this._drawLast=h,this._requestRedraw(l)}},_bringToBack:function(l){var h=l._order;if(h){var _=h.next,S=h.prev;if(S)S.next=_;else return;_?_.prev=S:S&&(this._drawLast=S),h.prev=null,h.next=this._drawFirst,this._drawFirst.prev=h,this._drawFirst=h,this._requestRedraw(l)}}});function Zk(l){return We.canvas?new Kk(l):null}var ug=(function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(l){return document.createElement("<lvml:"+l+' class="lvml">')}}catch{}return function(l){return document.createElement("<"+l+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}})(),DA={_initContainer:function(){this._container=G("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Qa.prototype._update.call(this),this.fire("update"))},_initPath:function(l){var h=l._container=ug("shape");_e(h,"leaflet-vml-shape "+(this.options.className||"")),h.coordsize="1 1",l._path=ug("path"),h.appendChild(l._path),this._updateStyle(l),this._layers[d(l)]=l},_addPath:function(l){var h=l._container;this._container.appendChild(h),l.options.interactive&&l.addInteractiveTarget(h)},_removePath:function(l){var h=l._container;ie(h),l.removeInteractiveTarget(h),delete this._layers[d(l)]},_updateStyle:function(l){var h=l._stroke,_=l._fill,S=l.options,E=l._container;E.stroked=!!S.stroke,E.filled=!!S.fill,S.stroke?(h||(h=l._stroke=ug("stroke")),E.appendChild(h),h.weight=S.weight+"px",h.color=S.color,h.opacity=S.opacity,S.dashArray?h.dashStyle=F(S.dashArray)?S.dashArray.join(" "):S.dashArray.replace(/( *, *)/g," "):h.dashStyle="",h.endcap=S.lineCap.replace("butt","flat"),h.joinstyle=S.lineJoin):h&&(E.removeChild(h),l._stroke=null),S.fill?(_||(_=l._fill=ug("fill")),E.appendChild(_),_.color=S.fillColor||S.color,_.opacity=S.fillOpacity):_&&(E.removeChild(_),l._fill=null)},_updateCircle:function(l){var h=l._point.round(),_=Math.round(l._radius),S=Math.round(l._radiusY||_);this._setPath(l,l._empty()?"M0 0":"AL "+h.x+","+h.y+" "+_+","+S+" 0,"+65535*360)},_setPath:function(l,h){l._path.v=h},_bringToFront:function(l){Y(l._container)},_bringToBack:function(l){le(l._container)}},K_=We.vml?ug:ci,hg=Qa.extend({_initContainer:function(){this._container=K_("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=K_("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ie(this._container),Jt(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Qa.prototype._update.call(this);var l=this._bounds,h=l.getSize(),_=this._container;(!this._svgSize||!this._svgSize.equals(h))&&(this._svgSize=h,_.setAttribute("width",h.x),_.setAttribute("height",h.y)),Ie(_,l.min),_.setAttribute("viewBox",[l.min.x,l.min.y,h.x,h.y].join(" ")),this.fire("update")}},_initPath:function(l){var h=l._path=K_("path");l.options.className&&_e(h,l.options.className),l.options.interactive&&_e(h,"leaflet-interactive"),this._updateStyle(l),this._layers[d(l)]=l},_addPath:function(l){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(l._path),l.addInteractiveTarget(l._path)},_removePath:function(l){ie(l._path),l.removeInteractiveTarget(l._path),delete this._layers[d(l)]},_updatePath:function(l){l._project(),l._update()},_updateStyle:function(l){var h=l._path,_=l.options;h&&(_.stroke?(h.setAttribute("stroke",_.color),h.setAttribute("stroke-opacity",_.opacity),h.setAttribute("stroke-width",_.weight),h.setAttribute("stroke-linecap",_.lineCap),h.setAttribute("stroke-linejoin",_.lineJoin),_.dashArray?h.setAttribute("stroke-dasharray",_.dashArray):h.removeAttribute("stroke-dasharray"),_.dashOffset?h.setAttribute("stroke-dashoffset",_.dashOffset):h.removeAttribute("stroke-dashoffset")):h.setAttribute("stroke","none"),_.fill?(h.setAttribute("fill",_.fillColor||_.color),h.setAttribute("fill-opacity",_.fillOpacity),h.setAttribute("fill-rule",_.fillRule||"evenodd")):h.setAttribute("fill","none"))},_updatePoly:function(l,h){this._setPath(l,Bt(l._parts,h))},_updateCircle:function(l){var h=l._point,_=Math.max(Math.round(l._radius),1),S=Math.max(Math.round(l._radiusY),1)||_,E="a"+_+","+S+" 0 1,0 ",R=l._empty()?"M0 0":"M"+(h.x-_)+","+h.y+E+_*2+",0 "+E+-_*2+",0 ";this._setPath(l,R)},_setPath:function(l,h){l._path.setAttribute("d",h)},_bringToFront:function(l){Y(l._path)},_bringToBack:function(l){le(l._path)}});We.vml&&hg.include(DA);function Yk(l){return We.svg||We.vml?new hg(l):null}vn.include({getRenderer:function(l){var h=l.options.renderer||this._getPaneRenderer(l.options.pane)||this.options.renderer||this._renderer;return h||(h=this._renderer=this._createRenderer()),this.hasLayer(h)||this.addLayer(h),h},_getPaneRenderer:function(l){if(l==="overlayPane"||l===void 0)return!1;var h=this._paneRenderers[l];return h===void 0&&(h=this._createRenderer({pane:l}),this._paneRenderers[l]=h),h},_createRenderer:function(l){return this.options.preferCanvas&&Zk(l)||Yk(l)}});var Xk=tn.extend({initialize:function(l,h){tn.prototype.initialize.call(this,this._boundsToLatLngs(l),h)},setBounds:function(l){return this.setLatLngs(this._boundsToLatLngs(l))},_boundsToLatLngs:function(l){return l=ri(l),[l.getSouthWest(),l.getNorthWest(),l.getNorthEast(),l.getSouthEast()]}});function TA(l,h){return new Xk(l,h)}hg.create=K_,hg.pointsToPath=Bt,sn.geometryToLayer=Bn,sn.coordsToLatLng=Gn,sn.coordsToLatLngs=an,sn.latLngToCoords=gs,sn.latLngsToCoords=$s,sn.getFeature=xs,sn.asFeature=ls,vn.mergeOptions({boxZoom:!0});var Qk=gr.extend({initialize:function(l){this._map=l,this._container=l._container,this._pane=l._panes.overlayPane,this._resetStateTimeout=0,l.on("unload",this._destroy,this)},addHooks:function(){Je(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Jt(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ie(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(l){if(!l.shiftKey||l.which!==1&&l.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),mt(),ye(),this._startPoint=this._map.mouseEventToContainerPoint(l),Je(document,{contextmenu:es,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(l){this._moved||(this._moved=!0,this._box=G("div","leaflet-zoom-box",this._container),_e(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(l);var h=new ct(this._point,this._startPoint),_=h.getSize();Ie(this._box,h.min),this._box.style.width=_.x+"px",this._box.style.height=_.y+"px"},_finish:function(){this._moved&&(ie(this._box),ge(this._container,"leaflet-crosshair")),qe(),Ne(),Jt(document,{contextmenu:es,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(l){if(!(l.which!==1&&l.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(r(this._resetState,this),0);var h=new ti(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(h).fire("boxzoomend",{boxZoomBounds:h})}},_onKeyDown:function(l){l.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});vn.addInitHook("addHandler","boxZoom",Qk),vn.mergeOptions({doubleClickZoom:!0});var Jk=gr.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(l){var h=this._map,_=h.getZoom(),S=h.options.zoomDelta,E=l.originalEvent.shiftKey?_-S:_+S;h.options.doubleClickZoom==="center"?h.setZoom(E):h.setZoomAround(l.containerPoint,E)}});vn.addInitHook("addHandler","doubleClickZoom",Jk),vn.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var eL=gr.extend({addHooks:function(){if(!this._draggable){var l=this._map;this._draggable=new Qo(l._mapPane,l._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),l.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),l.on("zoomend",this._onZoomEnd,this),l.whenReady(this._onZoomEnd,this))}_e(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){ge(this._map._container,"leaflet-grab"),ge(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var l=this._map;if(l._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var h=ri(this._map.options.maxBounds);this._offsetLimit=Nt(this._map.latLngToContainerPoint(h.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(h.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;l.fire("movestart").fire("dragstart"),l.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(l){if(this._map.options.inertia){var h=this._lastTime=+new Date,_=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(_),this._times.push(h),this._prunePositions(h)}this._map.fire("move",l).fire("drag",l)},_prunePositions:function(l){for(;this._positions.length>1&&l-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var l=this._map.getSize().divideBy(2),h=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=h.subtract(l).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(l,h){return l-(l-h)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var l=this._draggable._newPos.subtract(this._draggable._startPos),h=this._offsetLimit;l.x<h.min.x&&(l.x=this._viscousLimit(l.x,h.min.x)),l.y<h.min.y&&(l.y=this._viscousLimit(l.y,h.min.y)),l.x>h.max.x&&(l.x=this._viscousLimit(l.x,h.max.x)),l.y>h.max.y&&(l.y=this._viscousLimit(l.y,h.max.y)),this._draggable._newPos=this._draggable._startPos.add(l)}},_onPreDragWrap:function(){var l=this._worldWidth,h=Math.round(l/2),_=this._initialWorldOffset,S=this._draggable._newPos.x,E=(S-h+_)%l+h-_,R=(S+h+_)%l-h-_,ee=Math.abs(E+_)<Math.abs(R+_)?E:R;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=ee},_onDragEnd:function(l){var h=this._map,_=h.options,S=!_.inertia||l.noInertia||this._times.length<2;if(h.fire("dragend",l),S)h.fire("moveend");else{this._prunePositions(+new Date);var E=this._lastPos.subtract(this._positions[0]),R=(this._lastTime-this._times[0])/1e3,ee=_.easeLinearity,Ce=E.multiplyBy(ee/R),Be=Ce.distanceTo([0,0]),Et=Math.min(_.inertiaMaxSpeed,Be),Ei=Ce.multiplyBy(Et/Be),on=Et/(_.inertiaDeceleration*ee),Ln=Ei.multiplyBy(-on/2).round();!Ln.x&&!Ln.y?h.fire("moveend"):(Ln=h._limitOffset(Ln,h.options.maxBounds),ue(function(){h.panBy(Ln,{duration:on,easeLinearity:ee,noMoveStart:!0,animate:!0})}))}}});vn.addInitHook("addHandler","dragging",eL),vn.mergeOptions({keyboard:!0,keyboardPanDelta:80});var tL=gr.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(l){this._map=l,this._setPanDelta(l.options.keyboardPanDelta),this._setZoomDelta(l.options.zoomDelta)},addHooks:function(){var l=this._map._container;l.tabIndex<=0&&(l.tabIndex="0"),Je(l,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),Jt(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var l=document.body,h=document.documentElement,_=l.scrollTop||h.scrollTop,S=l.scrollLeft||h.scrollLeft;this._map._container.focus(),window.scrollTo(S,_)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(l){var h=this._panKeys={},_=this.keyCodes,S,E;for(S=0,E=_.left.length;S<E;S++)h[_.left[S]]=[-1*l,0];for(S=0,E=_.right.length;S<E;S++)h[_.right[S]]=[l,0];for(S=0,E=_.down.length;S<E;S++)h[_.down[S]]=[0,l];for(S=0,E=_.up.length;S<E;S++)h[_.up[S]]=[0,-1*l]},_setZoomDelta:function(l){var h=this._zoomKeys={},_=this.keyCodes,S,E;for(S=0,E=_.zoomIn.length;S<E;S++)h[_.zoomIn[S]]=l;for(S=0,E=_.zoomOut.length;S<E;S++)h[_.zoomOut[S]]=-l},_addHooks:function(){Je(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){Jt(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(l){if(!(l.altKey||l.ctrlKey||l.metaKey)){var h=l.keyCode,_=this._map,S;if(h in this._panKeys){if(!_._panAnim||!_._panAnim._inProgress)if(S=this._panKeys[h],l.shiftKey&&(S=et(S).multiplyBy(3)),_.options.maxBounds&&(S=_._limitOffset(et(S),_.options.maxBounds)),_.options.worldCopyJump){var E=_.wrapLatLng(_.unproject(_.project(_.getCenter()).add(S)));_.panTo(E)}else _.panBy(S)}else if(h in this._zoomKeys)_.setZoom(_.getZoom()+(l.shiftKey?3:1)*this._zoomKeys[h]);else if(h===27&&_._popup&&_._popup.options.closeOnEscapeKey)_.closePopup();else return;es(l)}}});vn.addInitHook("addHandler","keyboard",tL),vn.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var iL=gr.extend({addHooks:function(){Je(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){Jt(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(l){var h=hr(l),_=this._map.options.wheelDebounceTime;this._delta+=h,this._lastMousePos=this._map.mouseEventToContainerPoint(l),this._startTime||(this._startTime=+new Date);var S=Math.max(_-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(r(this._performZoom,this),S),es(l)},_performZoom:function(){var l=this._map,h=l.getZoom(),_=this._map.options.zoomSnap||0;l._stop();var S=this._delta/(this._map.options.wheelPxPerZoomLevel*4),E=4*Math.log(2/(1+Math.exp(-Math.abs(S))))/Math.LN2,R=_?Math.ceil(E/_)*_:E,ee=l._limitZoom(h+(this._delta>0?R:-R))-h;this._delta=0,this._startTime=null,ee&&(l.options.scrollWheelZoom==="center"?l.setZoom(h+ee):l.setZoomAround(this._lastMousePos,h+ee))}});vn.addInitHook("addHandler","scrollWheelZoom",iL);var PA=600;vn.mergeOptions({tapHold:We.touchNative&&We.safari&&We.mobile,tapTolerance:15});var nL=gr.extend({addHooks:function(){Je(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Jt(this._map._container,"touchstart",this._onDown,this)},_onDown:function(l){if(clearTimeout(this._holdTimeout),l.touches.length===1){var h=l.touches[0];this._startPos=this._newPos=new Oe(h.clientX,h.clientY),this._holdTimeout=setTimeout(r(function(){this._cancel(),this._isTapValid()&&(Je(document,"touchend",rn),Je(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",h))},this),PA),Je(document,"touchend touchcancel contextmenu",this._cancel,this),Je(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function l(){Jt(document,"touchend",rn),Jt(document,"touchend touchcancel",l)},_cancel:function(){clearTimeout(this._holdTimeout),Jt(document,"touchend touchcancel contextmenu",this._cancel,this),Jt(document,"touchmove",this._onMove,this)},_onMove:function(l){var h=l.touches[0];this._newPos=new Oe(h.clientX,h.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(l,h){var _=new MouseEvent(l,{bubbles:!0,cancelable:!0,view:window,screenX:h.screenX,screenY:h.screenY,clientX:h.clientX,clientY:h.clientY});_._simulated=!0,h.target.dispatchEvent(_)}});vn.addInitHook("addHandler","tapHold",nL),vn.mergeOptions({touchZoom:We.touch,bounceAtZoomLimits:!0});var sL=gr.extend({addHooks:function(){_e(this._map._container,"leaflet-touch-zoom"),Je(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){ge(this._map._container,"leaflet-touch-zoom"),Jt(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(l){var h=this._map;if(!(!l.touches||l.touches.length!==2||h._animatingZoom||this._zooming)){var _=h.mouseEventToContainerPoint(l.touches[0]),S=h.mouseEventToContainerPoint(l.touches[1]);this._centerPoint=h.getSize()._divideBy(2),this._startLatLng=h.containerPointToLatLng(this._centerPoint),h.options.touchZoom!=="center"&&(this._pinchStartLatLng=h.containerPointToLatLng(_.add(S)._divideBy(2))),this._startDist=_.distanceTo(S),this._startZoom=h.getZoom(),this._moved=!1,this._zooming=!0,h._stop(),Je(document,"touchmove",this._onTouchMove,this),Je(document,"touchend touchcancel",this._onTouchEnd,this),rn(l)}},_onTouchMove:function(l){if(!(!l.touches||l.touches.length!==2||!this._zooming)){var h=this._map,_=h.mouseEventToContainerPoint(l.touches[0]),S=h.mouseEventToContainerPoint(l.touches[1]),E=_.distanceTo(S)/this._startDist;if(this._zoom=h.getScaleZoom(E,this._startZoom),!h.options.bounceAtZoomLimits&&(this._zoom<h.getMinZoom()&&E<1||this._zoom>h.getMaxZoom()&&E>1)&&(this._zoom=h._limitZoom(this._zoom)),h.options.touchZoom==="center"){if(this._center=this._startLatLng,E===1)return}else{var R=_._add(S)._divideBy(2)._subtract(this._centerPoint);if(E===1&&R.x===0&&R.y===0)return;this._center=h.unproject(h.project(this._pinchStartLatLng,this._zoom).subtract(R),this._zoom)}this._moved||(h._moveStart(!0,!1),this._moved=!0),He(this._animRequest);var ee=r(h._move,h,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=ue(ee,this,!0),rn(l)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,He(this._animRequest),Jt(document,"touchmove",this._onTouchMove,this),Jt(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});vn.addInitHook("addHandler","touchZoom",sL),vn.BoxZoom=Qk,vn.DoubleClickZoom=Jk,vn.Drag=eL,vn.Keyboard=tL,vn.ScrollWheelZoom=iL,vn.TapHold=nL,vn.TouchZoom=sL,t.Bounds=ct,t.Browser=We,t.CRS=jt,t.Canvas=Kk,t.Circle=ki,t.CircleMarker=Rt,t.Class=we,t.Control=fs,t.DivIcon=Ur,t.DivOverlay=Ns,t.DomEvent=Yo,t.DomUtil=ut,t.Draggable=Qo,t.Evented=Pt,t.FeatureGroup=Vr,t.GeoJSON=sn,t.GridLayer=Zc,t.Handler=gr,t.Icon=zl,t.ImageOverlay=Us,t.LatLng=Vt,t.LatLngBounds=ti,t.Layer=Jo,t.LayerGroup=Bl,t.LineUtil=U_,t.Map=vn,t.Marker=ve,t.Mixin=H_,t.Path=Te,t.Point=Oe,t.PolyUtil=fw,t.Polygon=tn,t.Polyline=en,t.Popup=$r,t.PosAnimation=fr,t.Projection=gw,t.Rectangle=Xk,t.Renderer=Qa,t.SVG=hg,t.SVGOverlay=kn,t.TileLayer=bs,t.Tooltip=Vl,t.Transformation=Xe,t.Util=dt,t.VideoOverlay=jr,t.bind=r,t.bounds=Nt,t.canvas=Zk,t.circle=hn,t.circleMarker=fi,t.control=ns,t.divIcon=vw,t.extend=n,t.featureGroup=_w,t.geoJSON=ps,t.geoJson=ks,t.gridLayer=Mn,t.icon=mw,t.imageOverlay=_a,t.latLng=Me,t.latLngBounds=ri,t.layerGroup=pw,t.map=Ms,t.marker=Ye,t.point=et,t.polygon=fn,t.polyline=bn,t.popup=cg,t.rectangle=TA,t.setOptions=x,t.stamp=d,t.svg=Yk,t.svgOverlay=er,t.tileLayer=Yc,t.tooltip=dg,t.transformation=Ut,t.version=i,t.videoOverlay=qs;var MA=window.L;t.noConflict=function(){return window.L=MA,this},window.L=t}))})(zg,zg.exports)),zg.exports}var HK=FK();const Cg=cA(HK),WK="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",BK="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==",zK="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",An=(o,e=Hy)=>{var t=VK(),i=m(b(t),2),n=b(i);H(()=>N(n,e())),I(o,t)};var VK=T('<span class="tip svelte-767znw"><span class="tip-icon svelte-767znw">ℹ</span> <span class="tip-box svelte-767znw"> </span></span>'),jK=T("<button> </button>"),$K=T('<span class="err svelte-767znw"> </span>'),UK=T('<span class="ok svelte-767znw"> </span>'),qK=T('<div class="loading svelte-767znw">Loading…</div>'),GK=T('<section id="sec-appearance" class="svelte-767znw"><h3 class="svelte-767znw">Appearance</h3> <div class="field svelte-767znw"><label for="theme-select" class="svelte-767znw">Color theme</label> <select id="theme-select" class="svelte-767znw"><option>Dark</option><option>Light</option><option>System (OS preference)</option></select></div></section>'),KK=T('<div class="field svelte-767znw"><label class="svelte-767znw">CA certificate <!></label> <textarea rows="4" placeholder="-----BEGIN CERTIFICATE----- … -----END CERTIFICATE-----" spellcheck="false" class="svelte-767znw"></textarea></div> <div class="field svelte-767znw"><label class="svelte-767znw">Client certificate <!></label> <textarea rows="4" placeholder="-----BEGIN CERTIFICATE----- … -----END CERTIFICATE-----" spellcheck="false" class="svelte-767znw"></textarea></div> <div class="field svelte-767znw"><label class="svelte-767znw">Client private key <!></label> <textarea rows="4" placeholder="-----BEGIN PRIVATE KEY----- … -----END PRIVATE KEY-----" spellcheck="false" class="svelte-767znw"></textarea></div>',1),ZK=T('<section id="sec-mqtt" class="svelte-767znw"><h3 class="svelte-767znw">MQTT</h3> <div class="field svelte-767znw"><label class="svelte-767znw">Protocol <!></label> <select class="svelte-767znw"><option>mqtt (plain TCP)</option><option>mqtts (TLS)</option><option>ws (WebSocket)</option><option>wss (WebSocket + TLS)</option></select></div> <div class="field svelte-767znw"><label class="svelte-767znw">Broker address <!></label> <input type="text" placeholder="localhost:1883" class="svelte-767znw"/></div> <div class="field svelte-767znw"><label class="svelte-767znw">Username <!></label> <input type="text" placeholder="(optional)" autocomplete="off" class="svelte-767znw"/></div> <div class="field svelte-767znw"><label class="svelte-767znw">Password <!></label> <input type="password" placeholder="(optional)" autocomplete="new-password" class="svelte-767znw"/></div> <!> <div class="field svelte-767znw"><label class="svelte-767znw">MQTT protocol version <!></label> <select class="svelte-767znw"><option>3.1.1 (default)</option><option>5.0</option></select></div> <div class="field svelte-767znw"><label class="svelte-767znw">Client name <!></label> <input type="text" placeholder="she" class="svelte-767znw"/></div> <div class="field svelte-767znw"><label class="svelte-767znw">Variable prefix <!></label> <input type="text" placeholder="var" class="svelte-767znw"/></div> <div class="field field--check svelte-767znw"><span></span> <label class="check-label svelte-767znw"><input type="checkbox" class="svelte-767znw"/> <span class="checkmark svelte-767znw"></span> Disable variable system <!></label></div></section>'),YK=T('<div class="field svelte-767znw"><label class="svelte-767znw"> <!></label> <input type="password" placeholder="Enter new password" autocomplete="new-password" class="svelte-767znw"/></div>'),XK=T('<div class="field svelte-767znw"><label class="svelte-767znw">Proxy user header <!></label> <input type="text" placeholder="X-Remote-User" class="svelte-767znw"/></div> <div class="field svelte-767znw"><label class="svelte-767znw">Logout URL <!></label> <input type="text" placeholder="https://auth.example.com/…/end-session/" class="svelte-767znw"/></div>',1),QK=T('<div class="field-error svelte-767znw"> </div>'),JK=T('<div class="field-ok svelte-767znw"> </div>'),eZ=T('<section id="sec-auth" class="svelte-767znw"><h3 class="svelte-767znw">Authentication</h3> <div class="field svelte-767znw"><label class="svelte-767znw">Mode <!></label> <select class="svelte-767znw"><option>None (open)</option><option>Password</option><option>Proxy header (nginx / authentik)</option></select></div> <!> <!> <!> <!> <div class="field svelte-767znw"><span></span> <button class="save-auth-btn svelte-767znw"> </button></div></section>'),tZ=T('<section id="sec-webserver" class="svelte-767znw"><h3 class="svelte-767znw">Web server</h3> <div class="field svelte-767znw"><label class="svelte-767znw">Port <!></label> <input type="number" min="0" max="65535" placeholder="8080" class="svelte-767znw"/></div> <div class="field svelte-767znw"><label class="svelte-767znw">Bind address <!></label> <input type="text" placeholder="0.0.0.0 (default)" class="svelte-767znw"/></div></section>'),iZ=T('<section id="sec-scripts" class="svelte-767znw"><h3 class="svelte-767znw">Scripts</h3> <div class="field svelte-767znw"><label class="svelte-767znw">Scripts directory <!></label> <input type="text" class="svelte-767znw"/></div> <div class="field field--check svelte-767znw"><span></span> <label class="check-label svelte-767znw"><input type="checkbox" class="svelte-767znw"/> <span class="checkmark svelte-767znw"></span> Disable file watching <!></label></div></section>'),nZ=T('<section id="sec-git" class="svelte-767znw"><h3 class="svelte-767znw">Git</h3> <div class="field field--check svelte-767znw"><span></span> <label class="check-label svelte-767znw"><input type="checkbox" class="svelte-767znw"/> <span class="checkmark svelte-767znw"></span> Auto-commit on save <!></label></div> <div class="field field--check svelte-767znw"><span></span> <label class="check-label svelte-767znw"><input type="checkbox" class="svelte-767znw"/> <span class="checkmark svelte-767znw"></span> Auto-push after commit <!></label></div></section>'),pD=T("<option> </option>"),sZ=T('<div class="field svelte-767znw"><div class="map-label svelte-767znw">Map <span class="map-note svelte-767znw">(click or drag marker to set location — requires internet for tiles)</span></div> <div class="map-container svelte-767znw"></div></div>'),oZ=T('<section id="sec-solar" class="svelte-767znw"><h3 class="svelte-767znw">Location</h3> <div class="field svelte-767znw"><label class="svelte-767znw">Timezone <!></label> <input type="text" list="tz-list" placeholder="(system default)" autocomplete="off" spellcheck="false" class="svelte-767znw"/> <datalist id="tz-list"></datalist></div> <div class="field svelte-767znw"><label class="svelte-767znw">Latitude <!></label> <input type="number" step="0.0001" placeholder="48.7408" class="svelte-767znw"/></div> <div class="field svelte-767znw"><label class="svelte-767znw">Longitude <!></label> <input type="number" step="0.0001" placeholder="9.1778" class="svelte-767znw"/></div> <div class="field geo-actions svelte-767znw"><span></span> <div class="geo-btns svelte-767znw"><button class="geo-btn svelte-767znw"><!></button> <button class="geo-btn svelte-767znw"> </button></div></div> <!></section>'),rZ=T('<section id="sec-logging" class="svelte-767znw"><h3 class="svelte-767znw">Logging</h3> <div class="field svelte-767znw"><label class="svelte-767znw">Verbosity <!></label> <select class="svelte-767znw"><option>debug</option><option>info</option><option>warn</option><option>error</option></select></div></section>'),aZ=T('<div class="field field--check svelte-767znw"><span></span> <label><input type="checkbox" class="svelte-767znw"/> <span class="checkmark svelte-767znw"></span> Retain document messages <!></label></div>'),lZ=T('<section id="sec-shedb" class="svelte-767znw"><h3 class="svelte-767znw">sheDB</h3> <div class="field svelte-767znw"><label class="svelte-767znw">Database path <!></label> <input type="text" class="svelte-767znw"/></div> <div class="field svelte-767znw"><label class="svelte-767znw">MQTT topic prefix <!></label> <input type="text" placeholder="she/db/ (default)" class="svelte-767znw"/></div> <div class="field field--check svelte-767znw"><span></span> <label><input type="checkbox" class="svelte-767znw"/> <span class="checkmark svelte-767znw"></span> Publish documents to MQTT <!></label></div> <!></section>'),cZ=T('<section id="sec-redis" class="svelte-767znw"><h3 class="svelte-767znw">Redis</h3> <div class="field svelte-767znw"><label class="svelte-767znw">Redis URL <!></label> <input type="text" placeholder="leave empty to disable" class="svelte-767znw"/></div></section>'),dZ=T('<span class="free-badge svelte-767znw">FREE</span> ',1),uZ=T('&nbsp;— <a target="_blank" rel="noreferrer" class="svelte-767znw">Get API key ↗</a>',1),hZ=T("<div><!> <!></div>"),fZ=T('<div class="field svelte-767znw"><label class="svelte-767znw">Base URL <!></label> <input type="text" class="svelte-767znw"/></div>'),gZ=T('<div class="field svelte-767znw"><label class="svelte-767znw">API key <!></label> <input type="password" placeholder="sk-…" autocomplete="off" class="svelte-767znw"/></div>'),pZ=T('<section id="sec-ai" class="svelte-767znw"><h3 class="svelte-767znw">AI Assistant</h3> <div class="field svelte-767znw"><label class="svelte-767znw">Provider <!></label> <select class="svelte-767znw"></select></div> <!> <!> <div class="field svelte-767znw"><label class="svelte-767znw">Model <!></label> <input type="text" class="svelte-767znw"/></div> <!></section>'),_Z=T('<div class="config-form svelte-767znw"><!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!></div>'),mZ=T('<!> <div class="config-root svelte-767znw"><aside class="config-sidebar svelte-767znw"><div class="sidebar-search svelte-767znw"><svg class="search-icon svelte-767znw" width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><circle cx="6.5" cy="6.5" r="4.5"></circle><line x1="10" y1="10" x2="14" y2="14"></line></svg> <input class="search-input svelte-767znw" type="search" placeholder="Filter settings…" autocomplete="off" spellcheck="false"/></div> <nav class="section-nav svelte-767znw"></nav></aside> <div class="config-main svelte-767znw"><div class="config-topbar svelte-767znw"><span class="topbar-title svelte-767znw">Settings</span> <!> <!> <button class="save-btn svelte-767znw"> </button></div> <!></div></div>',1);function vZ(o,e){Ts(e,!0),delete Cg.Icon.Default.prototype._getIconUrl,Cg.Icon.Default.mergeOptions({iconUrl:WK,iconRetinaUrl:BK,shadowUrl:zK});let t=P(yi(NK())),i=P("~/.she"),n=P("mqtt"),s=P(""),r=P(""),a=P(""),d=P(""),u=P(""),f=P(""),g=P("logic"),p=P("var"),w=P(""),y=P(!1),x=P(8080),k=P(""),D=P("none"),M=P(""),F=P("X-Remote-User"),K=P(""),V=P(!1),se=P(""),te=P(""),pe=P(""),je=P(!1),Ke=P(!1),ue=P(!1),He=P(""),dt=P(48.7408),we=P(9.1778),gt=P(!1),ot=P(void 0),Pt=P(!1),Oe=P(null),Mt=P("info"),et=P(""),ct=P(""),Nt=P(!1),ti=P(!1),ri=P("");const Vt=[{id:"ollama",label:"Ollama (local)",provider:"ollama",baseUrl:"",defaultModel:"",freeNote:"",apiKeyUrl:""},{id:"lmstudio",label:"LM Studio (local)",provider:"openai",baseUrl:"http://localhost:1234",defaultModel:"",freeNote:"",apiKeyUrl:""},{id:"groq",label:"Groq — Qwen 2.5 Coder 32B (free)",provider:"openai",baseUrl:"https://api.groq.com/openai/v1",defaultModel:"qwen-2.5-coder-32b",freeNote:"14 400 req/day · no credit card needed",apiKeyUrl:"https://console.groq.com/keys"},{id:"gemini",label:"Google Gemini 2.0 Flash (free)",provider:"openai",baseUrl:"https://generativelanguage.googleapis.com/v1beta/openai",defaultModel:"gemini-2.0-flash",freeNote:"15 RPM · 1 000 000 tokens/day · no credit card",apiKeyUrl:"https://aistudio.google.com/apikey"},{id:"openai",label:"OpenAI (paid)",provider:"openai",baseUrl:"",defaultModel:"gpt-4o-mini",freeNote:"",apiKeyUrl:"https://platform.openai.com/api-keys"},{id:"anthropic",label:"Anthropic (paid)",provider:"anthropic",baseUrl:"",defaultModel:"claude-3-5-haiku-20241022",freeNote:"",apiKeyUrl:"https://console.anthropic.com/settings/keys"}];let Me=P("ollama"),jt=P("ollama"),ft=P(""),ht=P(""),he=P("");const Xe={};let Ut="ollama";function wi(X,ae){return X==="anthropic"?"anthropic":X==="ollama"?"ollama":ae?ae.includes("localhost:1234")?"lmstudio":ae.includes("groq.com")?"groq":ae.includes("googleapis.com")?"gemini":"openai":"openai"}function Ri(){Xe[Ut]={baseUrl:c(ft),model:c(ht),apiKey:c(he)};const X=Vt.find(me=>me.id===c(Me));if(!X)return;v(jt,X.provider,!0);const ae=Xe[c(Me)];v(ft,(ae==null?void 0:ae.baseUrl)??X.baseUrl,!0),v(ht,(ae==null?void 0:ae.model)??X.defaultModel,!0),v(he,(ae==null?void 0:ae.apiKey)??"",!0),Ut=c(Me)}const ci=Ct(()=>Vt.find(X=>X.id===c(Me)));let Bt=P(yi({}));const Xt=new Set(["url","name","variablePrefix","disableVariables","mqttUsername","mqttPassword","mqttCa","mqttCert","mqttKey","mqttVersion","port","bindAddress","auth","password","proxyHeader","proxyLogoutUrl","dir","disableWatch","gitAutoCommit","gitAutoPush","latitude","longitude","timezone","verbosity","dbPath","dbPrefix","dbPublish","dbRetain","redis","ai"]);Vn(()=>{if(!c(ot))return;const X=typeof c(dt)=="number"?c(dt):48.7408,ae=typeof c(we)=="number"?c(we):9.1778,me=Cg.map(c(ot)).setView([X,ae],10);Cg.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'}).addTo(me);const Ze=Cg.marker([X,ae],{draggable:!0}).addTo(me);v(Oe,Ze,!0);const Zt=bt=>{v(dt,+bt.lat.toFixed(6)),v(we,+bt.lng.toFixed(6))};return Ze.on("dragend",()=>Zt(Ze.getLatLng())),me.on("click",bt=>{Ze.setLatLng(bt.latlng),Zt(bt.latlng)}),()=>{v(Oe,null),me.remove()}}),Vn(()=>{!c(Oe)||c(dt)===""||c(we)===""||c(Oe).setLatLng([Number(c(dt)),Number(c(we))])});let pt;function Bi(){if(!navigator.geolocation){pt.show("Geolocation is not supported by this browser.",{alert:!0});return}v(Pt,!0),navigator.geolocation.getCurrentPosition(X=>{v(dt,+X.coords.latitude.toFixed(6)),v(we,+X.coords.longitude.toFixed(6)),v(Pt,!1)},()=>{v(Pt,!1)})}let Ti=P(!0),Ni=P(!1),Ki=P(""),Ai=P(""),Di=P(""),$i=P("appearance");const Gi=[{id:"appearance",label:"Appearance",terms:["theme","color","dark","light"]},{id:"auth",label:"Authentication",terms:["auth","password","login","proxy","header","nginx","authentik","secure"]},{id:"mqtt",label:"MQTT",terms:["broker","url","client","name","variable","prefix","protocol","version","mqtt5"]},{id:"webserver",label:"Web server",terms:["port","http","server","bind","address"]},{id:"scripts",label:"Scripts",terms:["directory","watch","hot reload","dir"]},{id:"git",label:"Git",terms:["git","auto commit","auto push","commit","push","repository"]},{id:"solar",label:"Location",terms:["latitude","longitude","sunrise","sunset","geo","timezone","time zone","iana","schedule"]},{id:"logging",label:"Logging",terms:["verbosity","debug","info","warn","error"]},{id:"shedb",label:"sheDB",terms:["database","db","path","retain"]},{id:"redis",label:"Redis",terms:["redis","cache"]},{id:"ai",label:"AI Assistant",terms:["llm","ollama","openai","anthropic","model","provider","base url"]}];let Ui=Ct(()=>Gi.filter(X=>{const ae=c(Di).trim().toLowerCase();return!ae||X.label.toLowerCase().includes(ae)||X.terms.some(me=>me.includes(ae))}));function mn(X){var ae;v($i,X,!0),(ae=document.getElementById("sec-"+X))==null||ae.scrollIntoView({behavior:"smooth",block:"start"})}Bs(async()=>{try{const X=await Wg();X.dataDir&&v(i,X.dataDir,!0)}catch{}try{const X=await Pl();if(typeof X.url=="string"&&X.url)try{const Ze=new URL(X.url);v(n,Ze.protocol.replace(":",""),!0),v(s,Ze.host,!0)}catch{v(s,X.url,!0)}typeof X.mqttUsername=="string"&&v(r,X.mqttUsername,!0),typeof X.mqttPassword=="string"&&v(a,X.mqttPassword,!0),typeof X.mqttCa=="string"&&v(d,X.mqttCa,!0),typeof X.mqttCert=="string"&&v(u,X.mqttCert,!0),typeof X.mqttKey=="string"&&v(f,X.mqttKey,!0),typeof X.mqttVersion=="string"&&v(w,X.mqttVersion,!0),typeof X.name=="string"&&v(g,X.name,!0),typeof X.variablePrefix=="string"&&v(p,X.variablePrefix,!0),typeof X.disableVariables=="boolean"&&v(y,X.disableVariables,!0),typeof X.port=="number"&&v(x,X.port,!0),typeof X.bindAddress=="string"&&v(k,X.bindAddress,!0),typeof X.auth=="string"&&v(D,X.auth,!0),typeof X.proxyHeader=="string"&&v(F,X.proxyHeader,!0),typeof X.proxyLogoutUrl=="string"&&v(K,X.proxyLogoutUrl,!0),typeof X.dir=="string"&&v(pe,X.dir,!0),typeof X.disableWatch=="boolean"&&v(je,X.disableWatch,!0),typeof X.gitAutoCommit=="boolean"&&v(Ke,X.gitAutoCommit,!0),typeof X.gitAutoPush=="boolean"&&v(ue,X.gitAutoPush,!0),typeof X.latitude=="number"&&v(dt,X.latitude,!0),typeof X.longitude=="number"&&v(we,X.longitude,!0),typeof X.timezone=="string"&&v(He,X.timezone,!0),typeof X.verbosity=="string"&&v(Mt,X.verbosity,!0),typeof X.dbPath=="string"&&v(et,X.dbPath,!0),typeof X.dbPrefix=="string"&&v(ct,X.dbPrefix,!0),typeof X.dbPublish=="boolean"&&v(Nt,X.dbPublish,!0),typeof X.dbRetain=="boolean"&&v(ti,X.dbRetain,!0);const ae=X.redis;ae!=null&&ae.url&&v(ri,ae.url,!0);const me=X.ai;me!=null&&me.provider&&v(jt,me.provider,!0),me!=null&&me.baseUrl&&v(ft,me.baseUrl,!0),me!=null&&me.model&&v(ht,me.model,!0),me!=null&&me.apiKey&&v(he,me.apiKey,!0),v(Me,wi(c(jt),c(ft)),!0),Ut=c(Me),v(Bt,Object.fromEntries(Object.entries(X).filter(([Ze])=>!Xt.has(Ze))),!0)}catch(X){v(Ai,X.message,!0)}finally{v(Ti,!1)}});async function rt(){if(v(te,""),v(se,""),c(D)==="password"&&!c(M)){v(te,"A password is required to enable password authentication.");return}v(V,!0);try{await TU(c(D),c(D)==="password"?c(M):void 0,c(D)==="proxy"?c(F):void 0,c(D)==="proxy"?c(K):void 0),v(M,""),v(se,"Authentication settings saved.")}catch(X){v(te,X.message,!0)}finally{v(V,!1)}}async function Kt(){v(Ai,""),v(Ki,"");const X={...c(Bt)};c(s)&&(X.url=`${c(n)}://${c(s)}`),X.name=c(g),X.variablePrefix=c(p),c(w)&&(X.mqttVersion=c(w)),c(y)&&(X.disableVariables=!0),c(r)&&(X.mqttUsername=c(r)),c(a)&&(X.mqttPassword=c(a)),c(d)&&(X.mqttCa=c(d)),c(u)&&(X.mqttCert=c(u)),c(f)&&(X.mqttKey=c(f)),c(x)!==""&&(X.port=Number(c(x))),c(k)&&(X.bindAddress=c(k)),c(pe)&&(X.dir=c(pe)),c(je)&&(X.disableWatch=!0),c(Ke)&&(X.gitAutoCommit=!0),c(ue)&&(X.gitAutoPush=!0),c(dt)!==""&&(X.latitude=Number(c(dt))),c(we)!==""&&(X.longitude=Number(c(we))),c(He)&&(X.timezone=c(He)),X.verbosity=c(Mt),c(et)&&(X.dbPath=c(et),c(ct)&&(X.dbPrefix=c(ct)),c(Nt)&&(X.dbPublish=!0,c(ti)&&(X.dbRetain=!0))),c(ri)&&(X.redis={url:c(ri)}),c(jt)&&(X.ai={provider:c(jt),...c(ft)?{baseUrl:c(ft)}:{},...c(ht)?{model:c(ht)}:{},...c(he)?{apiKey:c(he)}:{}}),v(Ni,!0);try{const ae=await Xp(X);window.dispatchEvent(new CustomEvent("she:config-changed")),v(Ki,ae.restartRequired?"Saved — restart required to apply changes.":"Saved.",!0)}catch(ae){v(Ai,ae.message,!0)}finally{v(Ni,!1)}}var _i=mZ(),Pi=xt(_i);vs(Uc(Pi,{}),X=>pt=X,()=>pt);var Li=m(Pi,2),Si=b(Li),Oi=b(Si),qi=m(b(Oi),2),mi=m(Oi,2);ni(mi,21,()=>Gi,X=>X.id,(X,ae)=>{var me=As(),Ze=xt(me);{var Zt=We=>{var At=jK();let ai;var zt=b(At);H(()=>{ai=kt(At,1,"section-link svelte-767znw",null,ai,{active:c($i)===c(ae).id}),N(zt,c(ae).label)}),z("click",At,()=>mn(c(ae).id)),I(We,At)},bt=Ct(()=>c(Ui).some(We=>We.id===c(ae).id));O(Ze,We=>{c(bt)&&We(Zt)})}I(X,me)});var Ue=m(Si,2),J=b(Ue),Qe=m(b(J),2);{var _t=X=>{var ae=$K(),me=b(ae);H(()=>N(me,c(Ai))),I(X,ae)};O(Qe,X=>{c(Ai)&&X(_t)})}var yt=m(Qe,2);{var Ot=X=>{var ae=UK(),me=b(ae);H(()=>N(me,c(Ki))),I(X,ae)};O(yt,X=>{c(Ki)&&X(Ot)})}var j=m(yt,2),ce=b(j),ke=m(J,2);{var ze=X=>{var ae=qK();I(X,ae)},st=X=>{var ae=_Z(),me=b(ae);{var Ze=Y=>{var le=GK(),Re=m(b(le),2),_e=m(b(Re),2),ge=b(_e);ge.value=ge.__value="dark";var tt=m(ge);tt.value=tt.__value="light";var U=m(tt);U.value=U.__value="system",z("change",_e,()=>AK(c(t))),ys(_e,()=>c(t),ne=>v(t,ne)),I(Y,le)},Zt=Ct(()=>c(Ui).some(Y=>Y.id==="appearance"));O(me,Y=>{c(Zt)&&Y(Ze)})}var bt=m(me,2);{var We=Y=>{var le=ZK(),Re=m(b(le),2),_e=b(Re),ge=m(b(_e));An(ge,()=>"Transport protocol. Use mqtts or wss for TLS encryption.");var tt=m(_e,2),U=b(tt);U.value=U.__value="mqtt";var ne=m(U);ne.value=ne.__value="mqtts";var Le=m(ne);Le.value=Le.__value="ws";var Ve=m(Le);Ve.value=Ve.__value="wss";var De=m(Re,2),Ie=b(De),St=m(b(Ie));An(St,()=>"Hostname and optional port of the MQTT broker. Example: 192.168.1.1:1883. Leave empty to run without MQTT.");var mt=m(Ie,2),qe=m(De,2),Tt=b(qe),it=m(b(Tt));An(it,()=>"MQTT broker username. Leave empty if the broker does not require authentication.");var ye=m(Tt,2),Ne=m(qe,2),Ee=b(Ne),Se=m(b(Ee));An(Se,()=>"MQTT broker password. Stored in plain text in config.json.");var nt=m(Ee,2),de=m(Ne,2);{var Pe=Yn=>{var Yo=KK(),fr=xt(Yo),vn=b(fr),Ms=m(b(vn));An(Ms,()=>"PEM-encoded CA certificate to verify the broker's TLS certificate. Leave empty to use the system's default CA store.");var fs=m(vn,2),ns=m(fr,2),Rs=b(ns),Wr=m(b(Rs));An(Wr,()=>"PEM-encoded client certificate for mutual TLS authentication.");var Za=m(Rs,2),Wl=m(ns,2),Ya=b(Wl),Xo=m(b(Ya));An(Xo,()=>"PEM-encoded private key matching the client certificate.");var Br=m(Ya,2);Ht(fs,()=>c(d),zr=>v(d,zr)),Ht(Za,()=>c(u),zr=>v(u,zr)),Ht(Br,()=>c(f),zr=>v(f,zr)),I(Yn,Yo)};O(de,Yn=>{(c(n)==="mqtts"||c(n)==="wss")&&Yn(Pe)})}var at=m(de,2),ut=b(at),Je=m(b(ut));An(Je,()=>"MQTT protocol version used when connecting to the broker. Choose 5 only if your broker supports MQTT 5.0. Default: 3.1.1 (mqtt.js default).");var $t=m(ut,2),Jt=b($t);Jt.value=Jt.__value="";var Mi=m(Jt);Mi.value=Mi.__value="5";var ii=m(at,2),xi=b(ii),Ji=m(b(xi));An(Ji,()=>'MQTT client ID and topic prefix used for the "connected" status message. Default: she');var Hi=m(xi,2),li=m(ii,2),un=b(li),rn=m(b(un));An(rn,()=>"Topic prefix for the variable system (var/set/name → var/status/name). Default: var");var es=m(un,2),js=m(li,2),fo=m(b(js),2),Zo=b(fo),hr=m(Zo,4);An(hr,()=>"When enabled, var/set/… messages are not processed and no var/status/… retained messages are published."),ys(tt,()=>c(n),Yn=>v(n,Yn)),Ht(mt,()=>c(s),Yn=>v(s,Yn)),Ht(ye,()=>c(r),Yn=>v(r,Yn)),Ht(nt,()=>c(a),Yn=>v(a,Yn)),ys($t,()=>c(w),Yn=>v(w,Yn)),Ht(Hi,()=>c(g),Yn=>v(g,Yn)),Ht(es,()=>c(p),Yn=>v(p,Yn)),ms(Zo,()=>c(y),Yn=>v(y,Yn)),I(Y,le)},At=Ct(()=>c(Ui).some(Y=>Y.id==="mqtt"));O(bt,Y=>{c(At)&&Y(We)})}var ai=m(bt,2);{var zt=Y=>{var le=eZ(),Re=m(b(le),2),_e=b(Re),ge=m(b(_e));An(ge,()=>"none: no authentication required. password: single-user password login. proxy: trust a header set by nginx/authentik.");var tt=m(_e,2),U=b(tt);U.value=U.__value="none";var ne=m(U);ne.value=ne.__value="password";var Le=m(ne);Le.value=Le.__value="proxy";var Ve=m(Re,2);{var De=Se=>{var nt=YK(),de=b(nt),Pe=b(de),at=m(Pe);An(at,()=>"Set a new password. Leave empty to keep the current password (if already set).");var ut=m(de,2);H(()=>N(Pe,`${c(M)?"New password":"Password"} `)),Ht(ut,()=>c(M),Je=>v(M,Je)),I(Se,nt)};O(Ve,Se=>{c(D)==="password"&&Se(De)})}var Ie=m(Ve,2);{var St=Se=>{var nt=XK(),de=xt(nt),Pe=b(de),at=m(b(Pe));An(at,()=>"The HTTP header that nginx/authentik sets after successful authentication. Default: X-Remote-User");var ut=m(Pe,2),Je=m(de,2),$t=b(Je),Jt=m(b($t));An(Jt,()=>"URL to redirect to when the user clicks Logout (e.g. https://auth.example.com/application/o/she/end-session/ for Authentik). Leave empty to do nothing on logout.");var Mi=m($t,2);Ht(ut,()=>c(F),ii=>v(F,ii)),Ht(Mi,()=>c(K),ii=>v(K,ii)),I(Se,nt)};O(Ie,Se=>{c(D)==="proxy"&&Se(St)})}var mt=m(Ie,2);{var qe=Se=>{var nt=QK(),de=b(nt);H(()=>N(de,c(te))),I(Se,nt)};O(mt,Se=>{c(te)&&Se(qe)})}var Tt=m(mt,2);{var it=Se=>{var nt=JK(),de=b(nt);H(()=>N(de,c(se))),I(Se,nt)};O(Tt,Se=>{c(se)&&Se(it)})}var ye=m(Tt,2),Ne=m(b(ye),2),Ee=b(Ne);H(()=>{Ne.disabled=c(V)||c(D)==="password"&&!c(M),N(Ee,c(V)?"Saving…":"Apply authentication settings")}),ys(tt,()=>c(D),Se=>v(D,Se)),z("click",Ne,rt),I(Y,le)},vi=Ct(()=>c(Ui).some(Y=>Y.id==="auth"));O(ai,Y=>{c(vi)&&Y(zt)})}var hi=m(ai,2);{var Ci=Y=>{var le=tZ(),Re=m(b(le),2),_e=b(Re),ge=m(b(_e));An(ge,()=>"HTTP server port. Use 0 to let the OS pick a free port. Default: 8080");var tt=m(_e,2),U=m(Re,2),ne=b(U),Le=m(b(ne));An(Le,()=>"Interface she listens on. Use 127.0.0.1 when running behind nginx (recommended with proxy auth). Default: 0.0.0.0");var Ve=m(ne,2);Ht(tt,()=>c(x),De=>v(x,De)),Ht(Ve,()=>c(k),De=>v(k,De)),I(Y,le)},zi=Ct(()=>c(Ui).some(Y=>Y.id==="webserver"));O(hi,Y=>{c(zi)&&Y(Ci)})}var $e=m(hi,2);{var Fe=Y=>{var le=iZ(),Re=m(b(le),2),_e=b(Re),ge=m(b(_e));An(ge,()=>"Directory that is watched for .js script files. Defaults to {dataDir}/scripts");var tt=m(_e,2),U=m(Re,2),ne=m(b(U),2),Le=b(ne),Ve=m(Le,4);An(Ve,()=>"When enabled the daemon will not watch for file changes and will not hot-reload scripts."),H(()=>ln(tt,"placeholder",`${c(i)??""}/scripts (default)`)),Ht(tt,()=>c(pe),De=>v(pe,De)),ms(Le,()=>c(je),De=>v(je,De)),I(Y,le)},Ft=Ct(()=>c(Ui).some(Y=>Y.id==="scripts"));O($e,Y=>{c(Ft)&&Y(Fe)})}var Yt=m($e,2);{var qt=Y=>{var le=nZ(),Re=m(b(le),2),_e=m(b(Re),2),ge=b(_e),tt=m(ge,4);An(tt,()=>"When enabled, saving or renaming/deleting a script automatically creates a git commit. Only effective when the scripts directory is inside a git repository.");var U=m(Re,2),ne=m(b(U),2),Le=b(ne),Ve=m(Le,4);An(Ve,()=>"When enabled, every commit (manual or automatic) is immediately pushed to the remote."),ms(ge,()=>c(Ke),De=>v(Ke,De)),ms(Le,()=>c(ue),De=>v(ue,De)),I(Y,le)},Qt=Ct(()=>c(Ui).some(Y=>Y.id==="git"));O(Yt,Y=>{c(Qt)&&Y(qt)})}var re=m(Yt,2);{var Ge=Y=>{var le=oZ(),Re=m(b(le),2),_e=b(Re),ge=m(b(_e));An(ge,()=>"IANA timezone for cron scheduling (e.g. Europe/Berlin). Leave empty to use the system timezone. Requires daemon restart.");var tt=m(_e,2),U=m(tt,2);ni(U,20,()=>{var ut;return((ut=Intl.supportedValuesOf)==null?void 0:ut.call(Intl,"timeZone"))??[]},Vi,(ut,Je)=>{var $t=pD(),Jt=b($t),Mi={};H(()=>{N(Jt,Je),Mi!==(Mi=Je)&&($t.value=($t.__value=Je)??"")}),I(ut,$t)});var ne=m(Re,2),Le=b(ne),Ve=m(b(Le));An(Ve,()=>"Geographic latitude used for sunrise/sunset calculations. Default: 48.7408 (Stuttgart)");var De=m(Le,2),Ie=m(ne,2),St=b(Ie),mt=m(b(St));An(mt,()=>"Geographic longitude used for sunrise/sunset calculations. Default: 9.1778 (Stuttgart)");var qe=m(St,2),Tt=m(Ie,2),it=m(b(Tt),2),ye=b(it),Ne=b(ye);{var Ee=ut=>{var Je=po("…");I(ut,Je)},Se=ut=>{var Je=po("📍 Use my location");I(ut,Je)};O(Ne,ut=>{c(Pt)?ut(Ee):ut(Se,-1)})}var nt=m(ye,2),de=b(nt),Pe=m(Tt,2);{var at=ut=>{var Je=sZ(),$t=m(b(Je),2);vs($t,Jt=>v(ot,Jt),()=>c(ot)),I(ut,Je)};O(Pe,ut=>{c(gt)&&ut(at)})}H(()=>{ye.disabled=c(Pt),N(de,c(gt)?"Hide map":"Pick on map")}),Ht(tt,()=>c(He),ut=>v(He,ut)),Ht(De,()=>c(dt),ut=>v(dt,ut)),Ht(qe,()=>c(we),ut=>v(we,ut)),z("click",ye,Bi),z("click",nt,()=>v(gt,!c(gt))),I(Y,le)},wt=Ct(()=>c(Ui).some(Y=>Y.id==="solar"));O(re,Y=>{c(wt)&&Y(Ge)})}var vt=m(re,2);{var di=Y=>{var le=rZ(),Re=m(b(le),2),_e=b(Re),ge=m(b(_e));An(ge,()=>"Minimum log level. debug shows all messages including MQTT traffic details.");var tt=m(_e,2),U=b(tt);U.value=U.__value="debug";var ne=m(U);ne.value=ne.__value="info";var Le=m(ne);Le.value=Le.__value="warn";var Ve=m(Le);Ve.value=Ve.__value="error",ys(tt,()=>c(Mt),De=>v(Mt,De)),I(Y,le)},It=Ct(()=>c(Ui).some(Y=>Y.id==="logging"));O(vt,Y=>{c(It)&&Y(di)})}var Ii=m(vt,2);{var W=Y=>{var le=lZ(),Re=m(b(le),2),_e=b(Re),ge=m(b(_e));An(ge,()=>"Path to the sheDB data directory. Defaults to {dataDir}/db. Leave empty to disable sheDB.");var tt=m(_e,2),U=m(Re,2),ne=b(U),Le=m(b(ne));An(Le,()=>"Prefix for all sheDB MQTT topics. Defaults to she/db/ — documents publish to {prefix}doc/{id}, views to {prefix}view/{id}, commands use {prefix}set/{id} etc.");var Ve=m(ne,2),De=m(U,2),Ie=m(b(De),2);let St;var mt=b(Ie),qe=m(mt,4);An(qe,()=>'When enabled, every document change is published to {dbPrefix}doc/{id}. Individual views can publish independently via their own "mqttpub" setting.');var Tt=m(De,2);{var it=ye=>{var Ne=aZ(),Ee=m(b(Ne),2);let Se;var nt=b(Ee),de=m(nt,4);An(de,()=>"When enabled, MQTT messages for document changes are published as retained messages."),H(()=>{Se=kt(Ee,1,"check-label svelte-767znw",null,Se,{muted:!c(et)}),nt.disabled=!c(et)}),ms(nt,()=>c(ti),Pe=>v(ti,Pe)),I(ye,Ne)};O(Tt,ye=>{c(Nt)&&ye(it)})}H(()=>{ln(tt,"placeholder",`defaults to ${c(i)??""}/db`),Ve.disabled=!c(et),St=kt(Ie,1,"check-label svelte-767znw",null,St,{muted:!c(et)}),mt.disabled=!c(et)}),Ht(tt,()=>c(et),ye=>v(et,ye)),Ht(Ve,()=>c(ct),ye=>v(ct,ye)),ms(mt,()=>c(Nt),ye=>v(Nt,ye)),I(Y,le)},Q=Ct(()=>c(Ui).some(Y=>Y.id==="shedb"));O(Ii,Y=>{c(Q)&&Y(W)})}var oe=m(Ii,2);{var $=Y=>{var le=cZ(),Re=m(b(le),2),_e=b(Re),ge=m(b(_e));An(ge,()=>"redis:// URL for the optional Redis write-through cache. All state store changes are written to the she:state hash. Leave empty to disable.");var tt=m(_e,2);Ht(tt,()=>c(ri),U=>v(ri,U)),I(Y,le)},A=Ct(()=>c(Ui).some(Y=>Y.id==="redis"));O(oe,Y=>{c(A)&&Y($)})}var G=m(oe,2);{var ie=Y=>{var le=pZ(),Re=m(b(le),2),_e=b(Re),ge=m(b(_e));An(ge,()=>"Choose a provider. Free options need a free API key from the provider's website — no credit card required.");var tt=m(_e,2);ni(tt,21,()=>Vt,Vi,(it,ye)=>{var Ne=pD(),Ee=b(Ne),Se={};H(()=>{N(Ee,c(ye).label),Se!==(Se=c(ye).id)&&(Ne.value=(Ne.__value=c(ye).id)??"")}),I(it,Ne)});var U=m(Re,2);{var ne=it=>{var ye=hZ();let Ne;var Ee=b(ye);{var Se=Pe=>{var at=dZ(),ut=m(xt(at));H(()=>N(ut,` ${c(ci).freeNote??""}`)),I(Pe,at)};O(Ee,Pe=>{c(ci).freeNote&&Pe(Se)})}var nt=m(Ee,2);{var de=Pe=>{var at=uZ(),ut=m(xt(at));H(()=>ln(ut,"href",c(ci).apiKeyUrl)),I(Pe,at)};O(nt,Pe=>{c(ci).apiKeyUrl&&Pe(de)})}H(()=>Ne=kt(ye,1,"preset-note svelte-767znw",null,Ne,{free:!!c(ci).freeNote})),I(it,ye)};O(U,it=>{var ye,Ne;((ye=c(ci))!=null&&ye.freeNote||(Ne=c(ci))!=null&&Ne.apiKeyUrl)&&it(ne)})}var Le=m(U,2);{var Ve=it=>{var ye=fZ(),Ne=b(ye),Ee=m(b(Ne));An(Ee,()=>"Base URL of the LLM API. Auto-filled for cloud presets. For Ollama: http://localhost:11434.");var Se=m(Ne,2);H(()=>{var nt;return ln(Se,"placeholder",c(Me)==="ollama"?"http://localhost:11434":c(Me)==="lmstudio"?"http://localhost:1234":((nt=c(ci))==null?void 0:nt.baseUrl)??"")}),Ht(Se,()=>c(ft),nt=>v(ft,nt)),I(it,ye)};O(Le,it=>{c(Me)!=="anthropic"&&it(Ve)})}var De=m(Le,2),Ie=b(De),St=m(b(Ie));An(St,()=>"Model identifier. Suggested default is filled in when you choose a preset.");var mt=m(Ie,2),qe=m(De,2);{var Tt=it=>{var ye=gZ(),Ne=b(ye),Ee=m(b(Ne));An(Ee,()=>"Stored in config.json. Not needed for local providers.");var Se=m(Ne,2);Ht(Se,()=>c(he),nt=>v(he,nt)),I(it,ye)};O(qe,it=>{c(Me)!=="ollama"&&c(Me)!=="lmstudio"&&it(Tt)})}H(()=>{var it;return ln(mt,"placeholder",((it=c(ci))==null?void 0:it.defaultModel)||"e.g. llama3.2")}),z("change",tt,Ri),ys(tt,()=>c(Me),it=>v(Me,it)),Ht(mt,()=>c(ht),it=>v(ht,it)),I(Y,le)},fe=Ct(()=>c(Ui).some(Y=>Y.id==="ai"));O(G,Y=>{c(fe)&&Y(ie)})}I(X,ae)};O(ke,X=>{c(Ti)?X(ze):X(st,-1)})}H(()=>{j.disabled=c(Ni),N(ce,c(Ni)?"Saving…":"Save")}),Ht(qi,()=>c(Di),X=>v(Di,X)),z("click",j,Kt),I(o,_i),Ps()}zs(["click","change"]);var bZ=T("<option> </option>"),yZ=T('<div><span class="ts svelte-18loop9"> </span> <span class="lvl svelte-18loop9"> </span> <span class="msg svelte-18loop9"> </span></div>'),wZ=T('<div class="page svelte-18loop9"><div class="toolbar svelte-18loop9"><h2 class="svelte-18loop9">Logs</h2> <select class="svelte-18loop9"></select> <input class="filter-in svelte-18loop9" type="search" placeholder="Filter messages…"/> <label class="check-label svelte-18loop9" title="Interpret filter as a regular expression"><input type="checkbox" class="svelte-18loop9"/> <span class="checkmark svelte-18loop9"></span> Regex</label> <label class="check-label svelte-18loop9"><input type="checkbox" class="svelte-18loop9"/> <span class="checkmark svelte-18loop9"></span> Auto-scroll</label> <button class="svelte-18loop9">Clear</button></div> <div class="log svelte-18loop9"></div></div>');function SZ(o,e){Ts(e,!0);let t=P(yi(aA())),i,n=P(!0),s=P("all"),r=P(""),a=P(!1);const d=["all","debug","info","warn","error"],u={debug:0,info:1,warn:2,error:3};Rk(te=>{v(t,[...c(t).slice(-1999),te],!0)}),Bs(()=>{i&&(i.scrollTop=i.scrollHeight)}),Vn(()=>{c(t).length,c(n)&&i&&(i.scrollTop=i.scrollHeight)});function f(){v(t,[],!0)}function g(te){if(c(s)!=="all"&&u[te.level]<u[c(s)])return!1;if(!c(r))return!0;if(c(a))try{return new RegExp(c(r),"i").test(te.msg)}catch{}return te.msg.toLowerCase().includes(c(r).toLowerCase())}function p(te){return new Date(te).toLocaleTimeString()}var w=wZ(),y=b(w),x=m(b(y),2);ni(x,21,()=>d,Vi,(te,pe)=>{var je=bZ(),Ke=b(je),ue={};H(()=>{N(Ke,c(pe)),ue!==(ue=c(pe))&&(je.value=(je.__value=c(pe))??"")}),I(te,je)});var k=m(x,2),D=m(k,2),M=b(D),F=m(D,2),K=b(F),V=m(F,2),se=m(y,2);ni(se,21,()=>c(t).filter(g),te=>te.ts+te.msg,(te,pe)=>{var je=yZ(),Ke=b(je),ue=b(Ke),He=m(Ke,2),dt=b(He),we=m(He,2),gt=b(we);H((ot,Pt)=>{kt(je,1,`line ${c(pe).level??""}`,"svelte-18loop9"),N(ue,ot),N(dt,Pt),N(gt,c(pe).msg)},[()=>p(c(pe).ts),()=>c(pe).level.toUpperCase()]),I(te,je)}),vs(se,te=>i=te,()=>i),ys(x,()=>c(s),te=>v(s,te)),Ht(k,()=>c(r),te=>v(r,te)),ms(M,()=>c(a),te=>v(a,te)),ms(K,()=>c(n),te=>v(n,te)),z("click",V,f),I(o,w),Ps()}zs(["click"]);var CZ=T('<span class="chat-model svelte-1twuiul"><!></span>'),xZ=T('<button class="clear-btn svelte-1twuiul" title="Clear conversation">✕</button>'),kZ=T('<div class="unconfigured svelte-1twuiul">Configure an AI provider in the <strong class="svelte-1twuiul">Config</strong> tab to use the AI assistant.</div>'),LZ=T('Working on view <code class="svelte-1twuiul"> </code>',1),IZ=T('<button class="chip svelte-1twuiul"> </button>'),EZ=T('<div class="suggestions svelte-1twuiul"><p class="suggestions-hint svelte-1twuiul"><!></p> <!></div>'),DZ=T('<div class="msg-content user-text svelte-1twuiul"> </div>'),_D=T('<div class="tool-event tool-call svelte-1twuiul"><span class="tool-icon svelte-1twuiul">🔧</span><span class="tool-name svelte-1twuiul"> </span></div>'),mD=T('<div class="tool-event tool-result svelte-1twuiul"><span class="tool-icon svelte-1twuiul">✓</span><span class="tool-name svelte-1twuiul"> </span></div>'),vD=T('<div class="tool-events svelte-1twuiul"></div>'),bD=T('<div class="text-block svelte-1twuiul"></div>'),TZ=T('<button class="expand-btn svelte-1twuiul"> </button>'),PZ=T('<div class="code-block svelte-1twuiul"><div class="code-header svelte-1twuiul"><span class="code-lang svelte-1twuiul"> </span> <div class="code-actions svelte-1twuiul"><button class="svelte-1twuiul">Copy</button></div></div> <div><pre class="svelte-1twuiul"><code class="hljs svelte-1twuiul"></code></pre> <!></div></div>'),MZ=T('<div class="apply-view-row svelte-1twuiul"><button class="apply-view-btn svelte-1twuiul"> </button></div>'),RZ=T('<!> <div class="msg-content svelte-1twuiul"><!> <!></div>',1),NZ=T("<div><!></div>"),AZ=T('<div class="message assistant svelte-1twuiul"><div class="msg-content svelte-1twuiul"><span class="status-shimmer svelte-1twuiul"> </span></div></div>'),OZ=T('<div class="code-block svelte-1twuiul"><div class="code-header svelte-1twuiul"><span class="code-lang svelte-1twuiul"> </span></div> <pre class="svelte-1twuiul"><code class="hljs svelte-1twuiul"></code></pre></div>'),FZ=T('<div class="message assistant streaming svelte-1twuiul"><div class="msg-content svelte-1twuiul"></div></div>'),HZ=T('<div class="chat-error svelte-1twuiul"> </div>'),WZ=T('<span><span class="badge badge-db svelte-1twuiul">db</span> <span class="chip-name svelte-1twuiul"> </span> <button class="chip-remove svelte-1twuiul"> </button></span>'),BZ=T('<span class="file-chip svelte-1twuiul"><span> </span> <span class="chip-name svelte-1twuiul"> </span> <button class="chip-remove svelte-1twuiul" title="Remove from context">×</button></span>'),zZ=T('<button class="stop-btn svelte-1twuiul" title="Stop generation">■</button>'),VZ=T('<button class="send-btn svelte-1twuiul">↑</button>'),jZ=T('<option class="svelte-1twuiul"> </option>'),$Z=T('<select class="model-select svelte-1twuiul"></select>'),UZ=T('<span class="model-name svelte-1twuiul"> </span>'),qZ=T('<button class="info-btn svelte-1twuiul" title="Model info">ℹ</button>'),GZ=T('<div class="model-bar svelte-1twuiul"><span class="model-provider svelte-1twuiul"> </span> <!> <!></div>'),KZ=T('<p class="info-status svelte-1twuiul">Loading…</p>'),ZZ=T('<p class="info-status info-err svelte-1twuiul"> </p>'),YZ=T('<dt class="svelte-1twuiul">Ollama version</dt><dd class="svelte-1twuiul"> </dd>',1),XZ=T('<dt class="svelte-1twuiul">Family</dt><dd class="svelte-1twuiul"> </dd>',1),QZ=T('<dt class="svelte-1twuiul">Parameters</dt><dd class="svelte-1twuiul"> </dd>',1),JZ=T('<dt class="svelte-1twuiul">Quantization</dt><dd class="svelte-1twuiul"> </dd>',1),eY=T('<div class="running-model svelte-1twuiul"> </div>'),tY=T('<dt class="svelte-1twuiul">Loaded</dt> <dd class="svelte-1twuiul"></dd>',1),iY=T('<dt class="svelte-1twuiul">Loaded</dt><dd class="dim svelte-1twuiul">Not in memory</dd>',1),nY=T('<dl class="svelte-1twuiul"><!> <!> <!> <!> <!></dl>'),sY=T('<div class="info-overlay svelte-1twuiul"><div class="info-popup svelte-1twuiul"><div class="info-popup-header svelte-1twuiul"><span class="svelte-1twuiul"> </span> <button title="Close" class="svelte-1twuiul">✕</button></div> <div class="info-popup-body svelte-1twuiul"><!></div></div></div>'),oY=T('<div class="chat-panel svelte-1twuiul"><div class="chat-header svelte-1twuiul"><span class="chat-title svelte-1twuiul">AI — View assistant</span> <!> <!></div> <div class="messages svelte-1twuiul"><!> <!> <!> <!> <!></div> <!> <div class="context-row svelte-1twuiul"><label title="Include sheDB document IDs in context" class="svelte-1twuiul"><input type="checkbox" class="svelte-1twuiul"/><span class="checkmark svelte-1twuiul"></span> Doc IDs</label> <label title="Include sample document content in context (first 10 docs)" class="svelte-1twuiul"><input type="checkbox" class="svelte-1twuiul"/><span class="checkmark svelte-1twuiul"></span> Sample docs</label> <label title="Let the AI query sheDB documents on demand. Disables real-time streaming." class="svelte-1twuiul"><input type="checkbox" class="svelte-1twuiul"/><span class="checkmark svelte-1twuiul"></span> 😎 Agent</label> <span class="req-size svelte-1twuiul"> </span></div> <div class="files-row svelte-1twuiul"><!> <!> <button class="add-file-btn svelte-1twuiul" title="Attach file to context">+</button> <input type="file" multiple="" class="file-input-hidden svelte-1twuiul"/></div> <div><div><textarea rows="3" class="svelte-1twuiul"></textarea></div> <!></div> <!></div> <!>',1);function rY(o,e){Ts(e,!0),bb.registerLanguage("javascript",fA),qn.use({breaks:!0,gfm:!0});let t=Su(e,"currentView",3,null);const i="she:viewchat:messages";let n=P(yi(JSON.parse(localStorage.getItem(i)??"[]"))),s=P(null),r=P(""),a=P(!1),d=P(""),u=P(null),f=P(yi([])),g=P(yi(localStorage.getItem("she:selectedModel")??""));Vn(()=>{localStorage.setItem(i,JSON.stringify(c(n)))});let p=P(yi(new Set)),w=P(!1),y=P(null),x=P(!1),k=P(""),D=null,M=P(0);const F=["[core] reticulating splines…","[io] calibrating the flux capacitor…","[net] pinging the oracle (no response)…","[gpu] overclocking the neurons…","[fs] loading sarcasm module v4.2…","[mem] defragmenting the embedding space…","[sched] running gradient descent into madness…","[net] synchronizing with the hive mind…","[model] tickling the transformer…","[io] consulting rubber duck debugger…"];let K=P(!0),V=P(!0),se=P(!0),te=P(yi([])),pe=P(!0),je=P(!1),Ke,ue=P(yi([])),He=P(0),dt,we;const gt=Ct(()=>({apiref:!1,shedb:c(K),sampleDocs:c(V),tools:c(se)})),ot=Ct(()=>{var W;return((W=c(u))==null?void 0:W.configured)??!1}),Pt=Ct(()=>c(He)+new TextEncoder().encode(c(r)).length),Oe=Ct(()=>c(pe)?t():null);async function Mt(){try{const W=await XN();v(u,W,!0),W.configured&&!c(g)&&v(g,W.model,!0)}catch{}}Vn(()=>(window.addEventListener("she:config-changed",Mt),()=>window.removeEventListener("she:config-changed",Mt))),Bs(()=>{Mt()}),Vn(()=>{c(g)&&localStorage.setItem("she:selectedModel",c(g))}),Vn(()=>{var W;(W=c(u))!=null&&W.provider&&QN().then(Q=>{v(f,Q.models,!0),!c(g)&&Q.models.length>0&&v(g,Q.models[0],!0)}).catch(()=>{})}),Vn(()=>{c(g),v(y,null),v(k,"")}),Vn(()=>{const W=c(gt),Q=c(Oe),oe=c(te);c(ot)&&JN({context:W,currentView:Q??null,extraFiles:oe.length>0?oe:void 0}).then($=>{v(He,new TextEncoder().encode($.prompt).length,!0)}).catch(()=>{})}),Vn(()=>{if(!c(a))return;v(M,Math.floor(Math.random()*F.length),!0);const W=setInterval(()=>{v(M,(c(M)+1)%F.length)},1e4);return()=>clearInterval(W)}),Vn(()=>{var W;we&&(c(n).length+(((W=c(s))==null?void 0:W.length)??0),requestAnimationFrame(()=>{we&&(we.scrollTop=we.scrollHeight)}))});function et(W){const Q=[],oe=/```(\w*)\n([\s\S]*?)```/g;let $=0,A;for(;(A=oe.exec(W))!==null;)A.index>$&&Q.push({type:"text",text:W.slice($,A.index)}),Q.push({type:"code",lang:A[1]||"text",text:A[2].trimEnd()}),$=A.index+A[0].length;return $<W.length&&Q.push({type:"text",text:W.slice($)}),Q}function ct(W){const Q=[],oe=/```(\w*)\n([\s\S]*?)```/g;let $=0,A;for(;(A=oe.exec(W))!==null;)A.index>$&&Q.push({type:"text",text:W.slice($,A.index)}),Q.push({type:"code",lang:A[1]||"text",text:A[2].trimEnd()}),$=A.index+A[0].length;const G=W.slice($),ie=G.match(/```(\w*)\n([\s\S]*)$/);return ie?(ie.index>0&&Q.push({type:"text",text:G.slice(0,ie.index)}),Q.push({type:"code",lang:ie[1]||"text",text:ie[2]})):G&&Q.push({type:"text",text:G}),Q}function Nt(W){const Q={};for(const oe of W)if(oe.type==="code"){if(oe.lang==="filter")Q.filter=oe.text.trim();else if(he(oe.lang)){const $=oe.text.split(`
223
- `)[0].trim();$==="// @view-map"?Q.map=oe.text.split(`
224
- `).slice(1).join(`
225
- `).trim():$==="// @view-reduce"&&(Q.reduce=oe.text.split(`
226
- `).slice(1).join(`
227
- `).trim())}}return Q}function ti(W){return W.filter!==void 0||W.map!==void 0||W.reduce!==void 0}function ri(W){const Q=[];return W.filter!==void 0&&Q.push("filter"),W.map!==void 0&&Q.push("map"),W.reduce!==void 0&&Q.push("reduce"),`Apply ${Q.join(" + ")}`}const Vt=15;function Me(W){return W.split(`
228
- `).length>Vt}function jt(W){const Q=new Set(c(p));Q.has(W)?Q.delete(W):Q.add(W),v(p,Q,!0)}function ft(W,Q){if(he(Q))try{return bb.highlight(W,{language:"javascript"}).value}catch{}return W.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ht(W){return qn.parse(W)}function he(W){return!W||W==="js"||W==="javascript"}function Xe(W){navigator.clipboard.writeText(W).catch(()=>{})}async function Ut(){if(v(w,!0),!(c(y)||c(x))){v(x,!0),v(k,"");try{v(y,await Hx(c(g)||c(u).model),!0)}catch(W){v(k,W.message,!0)}v(x,!1)}}function wi(W){return W>=1e9?`${(W/1e9).toFixed(1)} GB`:W>=1e6?`${(W/1e6).toFixed(0)} MB`:`${W} B`}function Ri(W){const Q=W.match(/\.([^.]+)$/);return Q?Q[1].toUpperCase():"?"}function ci(W){switch(W){case"SH":case"BASH":return"$";case"MD":case"MARKDOWN":return"↓";case"JSON":case"JSONC":return"{}";default:return W}}function Bt(W){v(te,c(te).filter((Q,oe)=>oe!==W),!0)}function Xt(){Ke.click()}async function pt(W){if(!(!W||W.length===0))for(const Q of Array.from(W)){const oe=await Q.text();v(te,[...c(te),{name:Q.name,content:oe}],!0)}}function Bi(W){const Q=W.target;pt(Q.files),Q.value=""}function Ti(W){var Q;W.preventDefault(),v(je,!1),pt(((Q=W.dataTransfer)==null?void 0:Q.files)??null)}function Ni(W){var Q;(Q=W.dataTransfer)!=null&&Q.types.includes("Files")&&(W.preventDefault(),v(je,!0))}function Ki(){v(je,!1)}async function Ai(){const W=c(r).trim();if(!(!W||c(a))){v(r,""),v(d,""),v(a,!0),v(n,[...c(n),{role:"user",content:W}],!0),D=new AbortController,v(ue,[],!0);try{await eA({messages:c(n),currentView:c(Oe),context:c(gt),modelOverride:c(g)||void 0,extraFiles:c(te).length>0?c(te):void 0},Q=>{v(s,(c(s)??"")+Q)},D.signal,Q=>{v(ue,[...c(ue),Q],!0)}),v(n,[...c(n),{role:"assistant",content:c(s)??"",toolEvents:c(ue).length>0?[...c(ue)]:void 0}],!0),v(ue,[],!0)}catch(Q){if(Q.name==="AbortError"){const oe=c(s);oe!=null&&oe.trim()&&v(n,[...c(n),{role:"assistant",content:oe+`
229
-
230
- *[stopped]*`,toolEvents:c(ue).length>0?[...c(ue)]:void 0}],!0)}else v(d,Q.message,!0)}finally{D=null,v(s,null),v(ue,[],!0),v(a,!1)}}}function Di(){D==null||D.abort()}function $i(W){W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),Ai())}function Gi(){v(n,[],!0),v(d,"")}const Ui=["Write a view to list all document IDs","Write a view to sum a numeric property across all documents","Write a view that filters to a specific prefix and emits a field","Write a reduce that returns the maximum value","Explain how the current view works"];function mn(W){v(r,W,!0),dt==null||dt.focus()}var rt=oY(),Kt=xt(rt),_i=b(Kt),Pi=m(b(_i),2);{var Li=W=>{var Q=CZ(),oe=b(Q);{var $=G=>{var ie=po();H(()=>N(ie,`${c(u).provider??""} · ${(c(g)||c(u).model)??""}`)),I(G,ie)},A=G=>{var ie=po("Not configured");I(G,ie)};O(oe,G=>{c(ot)?G($):G(A,-1)})}H(()=>ln(Q,"title",`Provider: ${c(u).provider??""}`)),I(W,Q)};O(Pi,W=>{c(u)&&W(Li)})}var Si=m(Pi,2);{var Oi=W=>{var Q=xZ();z("click",Q,Gi),I(W,Q)};O(Si,W=>{c(n).length>0&&W(Oi)})}var qi=m(_i,2),mi=b(qi);{var Ue=W=>{var Q=kZ();I(W,Q)},J=W=>{var Q=EZ(),oe=b(Q),$=b(oe);{var A=fe=>{var Y=LZ(),le=m(xt(Y)),Re=b(le);H(()=>N(Re,t().id)),I(fe,Y)},G=fe=>{var Y=po("No view selected. Ask a general sheDB view question.");I(fe,Y)};O($,fe=>{t()?fe(A):fe(G,-1)})}var ie=m(oe,2);ni(ie,17,()=>Ui,Vi,(fe,Y)=>{var le=IZ(),Re=b(le);H(()=>N(Re,c(Y))),z("click",le,()=>mn(c(Y))),I(fe,le)}),I(W,Q)};O(mi,W=>{c(ot)?c(n).length===0&&c(s)===null&&W(J,1):W(Ue)})}var Qe=m(mi,2);ni(Qe,17,()=>c(n),Vi,(W,Q,oe)=>{var $=NZ(),A=b($);{var G=fe=>{var Y=DZ(),le=b(Y);H(()=>N(le,c(Q).content)),I(fe,Y)},ie=fe=>{const Y=Ct(()=>et(c(Q).content)),le=Ct(()=>Nt(c(Y)));var Re=RZ(),_e=xt(Re);{var ge=De=>{var Ie=vD();ni(Ie,21,()=>c(Q).toolEvents,Vi,(St,mt)=>{var qe=As(),Tt=xt(qe);{var it=Ne=>{var Ee=_D(),Se=m(b(Ee)),nt=b(Se);H(de=>N(nt,de),[()=>c(mt).name.replace(/_/g," ")]),I(Ne,Ee)},ye=Ne=>{var Ee=mD(),Se=m(b(Ee)),nt=b(Se);H(de=>N(nt,de),[()=>c(mt).name.replace(/_/g," ")]),I(Ne,Ee)};O(Tt,Ne=>{c(mt).type==="tool_call"?Ne(it):Ne(ye,-1)})}I(St,qe)}),I(De,Ie)};O(_e,De=>{var Ie;(Ie=c(Q).toolEvents)!=null&&Ie.length&&De(ge)})}var tt=m(_e,2),U=b(tt);ni(U,17,()=>c(Y),Vi,(De,Ie,St)=>{var mt=As(),qe=xt(mt);{var Tt=ye=>{var Ne=bD();rc(Ne,()=>ht(c(Ie).text),!0),I(ye,Ne)},it=ye=>{const Ne=Ct(()=>`${oe}:${St}`),Ee=Ct(()=>Me(c(Ie).text)),Se=Ct(()=>c(p).has(c(Ne))),nt=Ct(()=>c(Ie).lang==="filter");var de=PZ(),Pe=b(de),at=b(Pe),ut=b(at),Je=m(at,2),$t=b(Je),Jt=m(Pe,2);let Mi;var ii=b(Jt),xi=b(ii);rc(xi,()=>ft(c(Ie).text,c(Ie).lang??""),!0);var Ji=m(ii,2);{var Hi=li=>{var un=TZ(),rn=b(un);H(()=>N(rn,c(Se)?"▲ collapse":"▼ expand")),z("click",un,()=>jt(c(Ne))),I(li,un)};O(Ji,li=>{c(Ee)&&li(Hi)})}H(()=>{N(ut,c(nt)?"filter":c(Ie).lang),Mi=kt(Jt,1,"code-body svelte-1twuiul",null,Mi,{collapsed:c(Ee)&&!c(Se)})}),z("click",$t,()=>Xe(c(Ie).text)),I(ye,de)};O(qe,ye=>{c(Ie).type==="text"?ye(Tt):ye(it,-1)})}I(De,mt)});var ne=m(U,2);{var Le=De=>{var Ie=MZ(),St=b(Ie),mt=b(St);H(qe=>N(mt,qe),[()=>ri(c(le))]),z("click",St,()=>e.onApplyView(c(le))),I(De,Ie)},Ve=Ct(()=>ti(c(le))&&e.onApplyView);O(ne,De=>{c(Ve)&&De(Le)})}I(fe,Re)};O(A,fe=>{c(Q).role==="user"?fe(G):fe(ie,-1)})}H(()=>kt($,1,`message ${c(Q).role??""}`,"svelte-1twuiul")),I(W,$)});var _t=m(Qe,2);{var yt=W=>{var Q=vD();ni(Q,21,()=>c(ue),Vi,(oe,$)=>{var A=As(),G=xt(A);{var ie=Y=>{var le=_D(),Re=m(b(le)),_e=b(Re);H(ge=>N(_e,ge),[()=>c($).name.replace(/_/g," ")]),I(Y,le)},fe=Y=>{var le=mD(),Re=m(b(le)),_e=b(Re);H(ge=>N(_e,ge),[()=>c($).name.replace(/_/g," ")]),I(Y,le)};O(G,Y=>{c($).type==="tool_call"?Y(ie):Y(fe,-1)})}I(oe,A)}),I(W,Q)};O(_t,W=>{c(ue).length>0&&W(yt)})}var Ot=m(_t,2);{var j=W=>{var Q=AZ(),oe=b(Q),$=b(oe),A=b($);H(()=>N(A,F[c(M)])),I(W,Q)};O(Ot,W=>{c(a)&&c(s)===null&&c(ue).length===0&&W(j)})}var ce=m(Ot,2);{var ke=W=>{var Q=FZ(),oe=b(Q);ni(oe,21,()=>ct(c(s)),Vi,($,A)=>{var G=As(),ie=xt(G);{var fe=le=>{var Re=bD();rc(Re,()=>ht(c(A).text),!0),I(le,Re)},Y=le=>{var Re=OZ(),_e=b(Re),ge=b(_e),tt=b(ge),U=m(_e,2),ne=b(U);rc(ne,()=>ft(c(A).text,c(A).lang??""),!0),H(()=>N(tt,c(A).lang)),I(le,Re)};O(ie,le=>{c(A).type==="text"?le(fe):le(Y,-1)})}I($,G)}),I(W,Q)};O(ce,W=>{c(s)!==null&&W(ke)})}vs(qi,W=>we=W,()=>we);var ze=m(qi,2);{var st=W=>{var Q=HZ(),oe=b(Q);H(()=>N(oe,c(d))),I(W,Q)};O(ze,W=>{c(d)&&W(st)})}var X=m(ze,2),ae=b(X),me=b(ae),Ze=m(ae,2),Zt=b(Ze),bt=m(Ze,2),We=b(bt),At=m(bt,2),ai=b(At),zt=m(X,2),vi=b(zt);{var hi=W=>{var Q=WZ();let oe;var $=m(b(Q),2),A=b($),G=m($,2),ie=b(G);H(()=>{oe=kt(Q,1,"file-chip svelte-1twuiul",null,oe,{inactive:!c(pe)}),N(A,t().id),ln(G,"title",c(pe)?"Remove from context":"Re-add to context"),N(ie,c(pe)?"×":"+")}),z("click",G,()=>v(pe,!c(pe))),I(W,Q)};O(vi,W=>{t()&&W(hi)})}var Ci=m(vi,2);ni(Ci,17,()=>c(te),Vi,(W,Q,oe)=>{const $=Ct(()=>Ri(c(Q).name));var A=BZ(),G=b(A),ie=b(G),fe=m(G,2),Y=b(fe),le=m(fe,2);H((Re,_e)=>{kt(G,1,`badge badge-${Re??""}`,"svelte-1twuiul"),N(ie,_e),N(Y,c(Q).name)},[()=>c($).toLowerCase(),()=>ci(c($))]),z("click",le,()=>Bt(oe)),I(W,A)});var zi=m(Ci,2),$e=m(zi,2);vs($e,W=>Ke=W,()=>Ke);var Fe=m(zt,2);let Ft;var Yt=b(Fe);let qt;var Qt=b(Yt);vs(Qt,W=>dt=W,()=>dt);var re=m(Yt,2);{var Ge=W=>{var Q=zZ();z("click",Q,Di),I(W,Q)},wt=W=>{var Q=VZ();H(oe=>Q.disabled=oe,[()=>!c(r).trim()||!c(ot)]),z("click",Q,Ai),I(W,Q)};O(re,W=>{c(a)?W(Ge):W(wt,-1)})}var vt=m(Fe,2);{var di=W=>{var Q=GZ(),oe=b(Q),$=b(oe),A=m(oe,2);{var G=le=>{var Re=$Z();ni(Re,21,()=>c(f),Vi,(_e,ge)=>{var tt=jZ(),U=b(tt),ne={};H(()=>{N(U,c(ge)),ne!==(ne=c(ge))&&(tt.value=(tt.__value=c(ge))??"")}),I(_e,tt)}),H(()=>Re.disabled=c(a)),ys(Re,()=>c(g),_e=>v(g,_e)),I(le,Re)},ie=le=>{var Re=UZ(),_e=b(Re);H(()=>N(_e,c(g)||c(u).model)),I(le,Re)};O(A,le=>{c(f).length>0?le(G):le(ie,-1)})}var fe=m(A,2);{var Y=le=>{var Re=qZ();z("click",Re,Ut),I(le,Re)};O(fe,le=>{c(u).provider==="ollama"&&le(Y)})}H(()=>N($,c(u).provider)),I(W,Q)};O(vt,W=>{c(ot)&&c(u)&&W(di)})}var It=m(Kt,2);{var Ii=W=>{var Q=sY(),oe=b(Q),$=b(oe),A=b($),G=b(A),ie=m(A,2),fe=m($,2),Y=b(fe);{var le=ge=>{var tt=KZ();I(ge,tt)},Re=ge=>{var tt=ZZ(),U=b(tt);H(()=>N(U,c(k))),I(ge,tt)},_e=ge=>{var tt=nY(),U=b(tt);{var ne=ye=>{var Ne=YZ(),Ee=m(xt(Ne)),Se=b(Ee);H(()=>N(Se,c(y).version)),I(ye,Ne)};O(U,ye=>{c(y).version&&ye(ne)})}var Le=m(U,2);{var Ve=ye=>{var Ne=XZ(),Ee=m(xt(Ne)),Se=b(Ee);H(()=>N(Se,c(y).details.family)),I(ye,Ne)};O(Le,ye=>{var Ne;(Ne=c(y).details)!=null&&Ne.family&&ye(Ve)})}var De=m(Le,2);{var Ie=ye=>{var Ne=QZ(),Ee=m(xt(Ne)),Se=b(Ee);H(()=>N(Se,c(y).details.parameter_size)),I(ye,Ne)};O(De,ye=>{var Ne;(Ne=c(y).details)!=null&&Ne.parameter_size&&ye(Ie)})}var St=m(De,2);{var mt=ye=>{var Ne=JZ(),Ee=m(xt(Ne)),Se=b(Ee);H(()=>N(Se,c(y).details.quantization_level)),I(ye,Ne)};O(St,ye=>{var Ne;(Ne=c(y).details)!=null&&Ne.quantization_level&&ye(mt)})}var qe=m(St,2);{var Tt=ye=>{var Ne=tY(),Ee=m(xt(Ne),2);ni(Ee,21,()=>c(y).running,Vi,(Se,nt)=>{var de=eY(),Pe=b(de);H(at=>N(Pe,`${c(nt).name??""} · ${at??""} VRAM`),[()=>wi(c(nt).size_vram)]),I(Se,de)}),I(ye,Ne)},it=ye=>{var Ne=iY();I(ye,Ne)};O(qe,ye=>{c(y).running&&c(y).running.length>0?ye(Tt):c(y).running!==null&&ye(it,1)})}I(ge,tt)};O(Y,ge=>{c(x)?ge(le):c(k)?ge(Re,1):c(y)&&ge(_e,2)})}H(()=>{var ge;return N(G,`Ollama · ${(c(g)||((ge=c(u))==null?void 0:ge.model))??""}`)}),z("click",Q,()=>v(w,!1)),z("click",oe,ge=>ge.stopPropagation()),z("click",ie,()=>v(w,!1)),I(W,Q)};O(It,W=>{c(w)&&W(Ii)})}H(W=>{N(ai,W),Ft=kt(Fe,1,"input-row svelte-1twuiul",null,Ft,{"drag-over":c(je)}),qt=kt(Yt,1,"textarea-wrap svelte-1twuiul",null,qt,{loading:c(a)}),ln(Qt,"placeholder",c(ot)?"Ask anything… (Enter to send, Shift+Enter for newline, drag & drop files to add context)":"AI not configured"),Qt.disabled=c(a)||!c(ot)},[()=>wi(c(Pt))]),ms(me,()=>c(K),W=>v(K,W)),ms(Zt,()=>c(V),W=>v(V,W)),ms(We,()=>c(se),W=>v(se,W)),z("click",zi,Xt),z("change",$e,Bi),ds("dragover",Fe,Ni),ds("dragleave",Fe,Ki),ds("drop",Fe,Ti),z("keydown",Qt,$i),Ht(Qt,()=>c(r),W=>v(r,W)),I(o,rt),Ps()}zs(["click","change","keydown"]);var aY=T('<div class="me svelte-1pxdb1"></div>');function vS(o,e){Ts(e,!0);let t=Su(e,"value",15,""),i=Su(e,"language",3,"javascript"),n,s,r=!1;Bs(()=>{const d=i()==="json"?{formatOnPaste:!0,autoIndent:"full"}:{};s=mr.create(n,{value:t(),language:i(),theme:"vs-dark",minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,fontFamily:"'Cascadia Code', 'Fira Code', monospace",automaticLayout:!0,wordWrap:"on",lineNumbers:"on",renderLineHighlight:"none",overviewRulerLanes:0,scrollbar:{verticalScrollbarSize:6,horizontalScrollbarSize:6},...d}),s.onDidChangeModelContent(()=>{r||t(s.getValue())})}),x_(()=>s==null?void 0:s.dispose()),Vn(()=>{!s||s.getValue()===t()||(r=!0,s.setValue(t()),r=!1)});var a=aY();vs(a,d=>n=d,()=>n),I(o,a),Ps()}var lY=T('<!> <div class="welcome svelte-rrt0o"><div class="welcome-inner svelte-rrt0o"><div class="welcome-logo svelte-rrt0o">db</div> <p class="welcome-sub svelte-rrt0o">sheDB — embedded JSON document store with MapReduce views</p> <div class="welcome-hint svelte-rrt0o"><strong>In scripts:</strong> use <code class="svelte-rrt0o">she.db.get(id)</code>, <code class="svelte-rrt0o">she.db.set(id, doc)</code>, <code class="svelte-rrt0o">she.db.extend(id, partial)</code>, <code class="svelte-rrt0o">she.db.sub(pattern, cb)</code>.<br/> <strong>Views:</strong> <code class="svelte-rrt0o">this</code> = current document &mdash; call <code class="svelte-rrt0o">emit(value)</code> to add to result.</div> <div class="welcome-links svelte-rrt0o"><a href="https://github.com/hobbyquaker/she/blob/main/doc/db/README.md" target="_blank" rel="noopener" class="svelte-rrt0o">sheDB docs</a> <span class="svelte-rrt0o">·</span> <a href="https://github.com/hobbyquaker/she/blob/main/doc/db/view-examples.md" target="_blank" rel="noopener" class="svelte-rrt0o">View examples</a> <span class="svelte-rrt0o">·</span> <a href="https://github.com/hobbyquaker/she" target="_blank" rel="noopener" class="svelte-rrt0o">GitHub</a></div></div></div>',1),cY=T('<button><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"><line x1="5.5" y1="5" x2="4" y2="2.5"></line><line x1="10.5" y1="5" x2="12" y2="2.5"></line><path d="M3 11 V7 A5 3.5 0 0 0 13 7 V11 Z" stroke-linejoin="round"></path><circle cx="6" cy="8.2" r="0.7" fill="currentColor" stroke="none"></circle><circle cx="10" cy="8.2" r="0.7" fill="currentColor" stroke="none"></circle></svg> AI</button>'),yD=T('<div class="form-error svelte-rrt0o"> </div>'),dY=T('<div class="new-item-form svelte-rrt0o"><input placeholder="device/lamp1" class="svelte-rrt0o"/> <button class="svelte-rrt0o">Create</button></div> <!>',1),wD=T("<li> </li>"),SD=T('<div class="error-bar svelte-rrt0o"> </div>'),CD=T('<div class="loading svelte-rrt0o">Loading…</div>'),uY=T('<div class="monaco-doc-wrap svelte-rrt0o"><!></div>'),hY=T('<div class="editor-toolbar svelte-rrt0o"><span class="editor-title svelte-rrt0o"> </span> <button class="svelte-rrt0o">Save</button> <button class="btn-danger svelte-rrt0o">Delete</button></div> <!> <!>',1),fY=T('<div class="panel svelte-rrt0o"><aside class="sidebar svelte-rrt0o"><div class="toolbar svelte-rrt0o"><button class="svelte-rrt0o">+ Doc</button></div> <!> <div class="sidebar-search svelte-rrt0o"><input type="search" placeholder="Filter…" class="svelte-rrt0o"/></div> <ul class="flat-list svelte-rrt0o"></ul></aside> <div class="resize-handle svelte-rrt0o" role="separator"></div> <main class="editor-area svelte-rrt0o"><!></main></div>'),gY=T('<div class="new-item-form svelte-rrt0o"><input placeholder="myView" class="svelte-rrt0o"/> <button class="svelte-rrt0o">Create</button></div> <!>',1),pY=T('<label class="opt-check svelte-rrt0o"><input type="checkbox" class="svelte-rrt0o"/> <span class="checkmark svelte-rrt0o"></span> Retain <span class="section-hint svelte-rrt0o">— send as retained MQTT message</span></label>'),_Y=T('<span class="badge-error svelte-rrt0o">error</span>'),mY=T('<span class="badge-ok svelte-rrt0o"> </span>'),vY=T('<pre class="result-error svelte-rrt0o"> </pre>'),bY=T('<pre class="result-json svelte-rrt0o"> </pre>'),yY=T('<div class="view-result svelte-rrt0o"><div class="result-header svelte-rrt0o">Result <!></div> <!></div>'),wY=T('<div class="view-sections svelte-rrt0o"><div class="view-section svelte-rrt0o"><div class="section-title svelte-rrt0o">Description <span class="section-hint svelte-rrt0o">— optional, shown in sidebar</span></div> <div class="section-body svelte-rrt0o"><input class="filter-input svelte-rrt0o" placeholder="(optional description)"/></div></div> <div class="view-section svelte-rrt0o"><div class="section-title svelte-rrt0o">Filter <span class="section-hint svelte-rrt0o">— MQTT wildcard, optional</span></div> <div class="section-body svelte-rrt0o"><input class="filter-input svelte-rrt0o" placeholder="#"/></div></div> <div class="view-section svelte-rrt0o"><div class="section-title svelte-rrt0o">Map <span class="section-hint svelte-rrt0o">— <code>this</code> = document &nbsp;·&nbsp; call <code>emit(this)</code> to include in result</span></div> <div class="monaco-view-wrap monaco-view-wrap--map svelte-rrt0o"><!></div></div> <div class="view-section svelte-rrt0o"><div class="section-title svelte-rrt0o">Reduce <span class="section-hint svelte-rrt0o">— receives <code>result</code> array, must <code>return</code> new value (optional)</span></div> <div class="monaco-view-wrap monaco-view-wrap--reduce svelte-rrt0o"><!></div></div> <div class="view-section view-section--options svelte-rrt0o"><label class="opt-check svelte-rrt0o"><input type="checkbox" class="svelte-rrt0o"/> <span class="checkmark svelte-rrt0o"></span> Publish to MQTT <span class="section-hint svelte-rrt0o">— publish view to MQTT topic <code> </code></span></label> <!></div> <!></div>'),SY=T('<div class="editor-toolbar svelte-rrt0o"><span class="editor-title svelte-rrt0o"> </span> <button class="svelte-rrt0o">Save</button> <button title="Re-run view" class="svelte-rrt0o">Refresh</button> <button class="btn-danger svelte-rrt0o">Delete</button></div> <!> <!>',1),CY=T('<div class="chat-resize-handle svelte-rrt0o" role="separator"></div> <div class="chat-pane svelte-rrt0o"><!></div>',1),xY=T('<div class="panel svelte-rrt0o"><aside class="sidebar svelte-rrt0o"><div class="toolbar svelte-rrt0o"><button class="svelte-rrt0o">+ View</button></div> <!> <div class="sidebar-search svelte-rrt0o"><input type="search" placeholder="Filter…" class="svelte-rrt0o"/></div> <ul class="flat-list svelte-rrt0o"></ul></aside> <div class="resize-handle svelte-rrt0o" role="separator"></div> <main class="editor-area svelte-rrt0o"><!></main> <!></div>'),kY=T('<div class="db-root svelte-rrt0o" role="presentation"><div class="panel-tabs svelte-rrt0o"><button>Documents</button> <button>Views</button> <!></div> <!></div>');function LY(o,e){Ts(e,!0);const t=Ue=>{var J=lY(),Qe=xt(J);vs(Uc(Qe,{}),_t=>ci=_t,()=>ci),I(Ue,J)};let i=P(yi([])),n=P(null),s=P("{}"),r=P(!1),a=P(null);const d="she-db-selected-view";let u=P(yi([])),f=P(yi(localStorage.getItem(d))),g=P("#"),p=P("// emit(this.someProperty)"),w=P(""),y=P(""),x=P(!1),k=P(!1),D=P(null),M=P(!1),F=P(null),K=P("she/db/view/");const V="she-db-panel";let se=P(yi(localStorage.getItem(V)??"docs")),te=P(""),pe=P(!1),je=P(null),Ke=P(""),ue=P(!1),He=P(null);const dt="she-db-sidebar-width";let we=P(yi(parseInt(localStorage.getItem(dt)??"220",10))),gt=!1,ot=0,Pt=0;const Oe="she-db-chat-width",Mt="she-db-chat-open";let et=P(localStorage.getItem(Mt)==="true"),ct=P(yi(parseInt(localStorage.getItem(Oe)??"320",10))),Nt=!1,ti=0,ri=0;const Vt=Ct(()=>c(f)?{id:c(f),filter:c(g),map:c(p),reduce:c(w)}:null);function Me(Ue){Ue.filter!==void 0&&v(g,Ue.filter,!0),Ue.map!==void 0&&v(p,Ue.map,!0),Ue.reduce!==void 0&&v(w,Ue.reduce,!0)}Vn(()=>{localStorage.setItem(Mt,String(c(et)))}),Vn(()=>{localStorage.setItem(V,c(se))}),Vn(()=>{c(f)?localStorage.setItem(d,c(f)):localStorage.removeItem(d)});function jt(Ue){gt=!0,ot=Ue.clientX,Pt=c(we),Ue.preventDefault()}function ft(Ue){gt&&v(we,Math.max(140,Math.min(500,Pt+Ue.clientX-ot)),!0),Nt&&v(ct,Math.max(240,Math.min(600,ri-(Ue.clientX-ti))),!0)}function ht(){gt&&(gt=!1,localStorage.setItem(dt,String(c(we)))),Nt&&(Nt=!1,localStorage.setItem(Oe,String(c(ct))))}function he(Ue){Nt=!0,ti=Ue.clientX,ri=c(ct),Ue.preventDefault()}async function Xe(){try{v(i,await qN(),!0)}catch{}}async function Ut(){try{v(u,await GN(),!0)}catch{}}async function wi(Ue){v(n,Ue,!0),v(a,null),v(r,!0);try{const J=await WU(Ue);v(s,JSON.stringify(J,null,2),!0)}catch(J){v(a,J instanceof Error?J.message:String(J),!0)}finally{v(r,!1)}}async function Ri(){if(c(n)){v(a,null);try{const Ue=JSON.parse(c(s));await VE(c(n),Ue)}catch(Ue){v(a,Ue instanceof Error?Ue.message:String(Ue),!0)}}}let ci;async function Bt(){if(c(n)&&await ci.show(`Delete document "${c(n)}"?`,{confirm:"Delete",danger:!0}))try{await BU(c(n)),v(n,null),v(s,"{}")}catch(Ue){v(a,Ue instanceof Error?Ue.message:String(Ue),!0)}}async function Xt(){const Ue=c(te).trim();if(Ue){v(je,null);try{await VE(Ue,{}),v(pe,!1),v(te,""),await wi(Ue)}catch(J){v(je,J instanceof Error?J.message:String(J),!0)}}}async function pt(Ue){v(f,Ue,!0),v(F,null),v(M,!0),v(D,null);try{const J=await zU(Ue);v(g,J.filter??"",!0),v(p,J.map,!0),v(w,J.reduce??"",!0),v(y,J.description??"",!0),v(x,J.mqttpub??!1,!0),v(k,J.retain??!1,!0),v(D,await pS(Ue).catch(()=>null),!0)}catch(J){v(F,J instanceof Error?J.message:String(J),!0)}finally{v(M,!1)}}async function Bi(){if(c(f)){v(F,null);try{const Ue={map:c(p)};c(g).trim()&&(Ue.filter=c(g).trim()),c(w).trim()&&(Ue.reduce=c(w).trim()),c(y).trim()&&(Ue.description=c(y).trim()),c(x)&&(Ue.mqttpub=!0),c(k)&&(Ue.retain=!0),await jE(c(f),Ue)}catch(Ue){v(F,Ue instanceof Error?Ue.message:String(Ue),!0)}}}async function Ti(){if(c(f))try{v(D,await pS(c(f)),!0)}catch(Ue){v(F,Ue instanceof Error?Ue.message:String(Ue),!0)}}async function Ni(){if(c(f)&&await ci.show(`Delete view "${c(f)}"?`,{confirm:"Delete",danger:!0}))try{await VU(c(f)),v(f,null),v(g,""),v(p,"// emit(this.someProperty)"),v(w,""),v(y,""),v(x,!1),v(k,!1),v(D,null)}catch(Ue){v(F,Ue instanceof Error?Ue.message:String(Ue),!0)}}async function Ki(){if(!c(Ke).trim())return;const Ue=c(Ke).trim();v(He,null);try{await jE(Ue,{map:"// emit(this.someProperty)"}),v(ue,!1),v(Ke,""),await Ut(),await pt(Ue)}catch(J){v(He,J instanceof Error?J.message:String(J),!0)}}let Ai=P(""),Di=P(""),$i=Ct(()=>[...c(i)].filter(Ue=>!c(Ai)||Ue.toLowerCase().includes(c(Ai).toLowerCase())).sort()),Gi=Ct(()=>[...c(u)].filter(Ue=>!c(Di)||Ue.toLowerCase().includes(c(Di).toLowerCase())).sort());Bs(()=>{Xe(),Ut().then(()=>{c(f)&&c(u).includes(c(f))?pt(c(f)):v(f,null)}),Pl().then(yt=>{const Ot=yt.dbPrefix||"she/db/",j=Ot.endsWith("/")?Ot:Ot+"/";v(K,j+"view/")}).catch(()=>{});const Ue=cr("db:ids",yt=>{v(i,yt.ids??[],!0)}),J=cr("db:viewIds",yt=>{v(u,yt.ids??[],!0)}),Qe=cr("db:change",async yt=>{const Ot=yt.id;c(n)===Ot&&(yt.doc===null?(v(n,null),v(s,"{}")):v(s,JSON.stringify(yt.doc,null,2),!0))}),_t=cr("db:viewUpdate",async yt=>{const Ot=yt.id;c(f)===Ot&&v(D,await pS(Ot).catch(()=>null),!0)});return()=>{Ue(),J(),Qe(),_t()}});var Ui=kY(),mn=b(Ui),rt=b(mn);let Kt;var _i=m(rt,2);let Pi;var Li=m(_i,2);{var Si=Ue=>{var J=cY();let Qe;H(()=>{Qe=kt(J,1,"ai-toggle svelte-rrt0o",null,Qe,{"ai-open":c(et)}),ln(J,"title",c(et)?"Close AI assistant":"Open AI assistant")}),z("click",J,()=>v(et,!c(et))),I(Ue,J)};O(Li,Ue=>{c(se)==="views"&&Ue(Si)})}var Oi=m(mn,2);{var qi=Ue=>{var J=fY(),Qe=b(J);let _t;var yt=b(Qe),Ot=b(yt),j=m(yt,2);{var ce=bt=>{var We=dY(),At=xt(We),ai=b(At),zt=m(ai,2),vi=m(At,2);{var hi=Ci=>{var zi=yD(),$e=b(zi);H(()=>N($e,c(je))),I(Ci,zi)};O(vi,Ci=>{c(je)&&Ci(hi)})}z("keydown",ai,Ci=>Ci.key==="Enter"&&Xt()),Ht(ai,()=>c(te),Ci=>v(te,Ci)),z("click",zt,Xt),I(bt,We)};O(j,bt=>{c(pe)&&bt(ce)})}var ke=m(j,2),ze=b(ke),st=m(ke,2);ni(st,20,()=>c($i),bt=>bt,(bt,We)=>{var At=wD();let ai;var zt=b(At);H(()=>{ai=kt(At,1,"flat-item svelte-rrt0o",null,ai,{"active-item":c(n)===We}),N(zt,We)}),z("click",At,()=>wi(We)),I(bt,At)});var X=m(Qe,2),ae=m(X,2),me=b(ae);{var Ze=bt=>{var We=hY(),At=xt(We),ai=b(At),zt=b(ai),vi=m(ai,2),hi=m(vi,2),Ci=m(At,2);{var zi=Yt=>{var qt=SD(),Qt=b(qt);H(()=>N(Qt,c(a))),I(Yt,qt)};O(Ci,Yt=>{c(a)&&Yt(zi)})}var $e=m(Ci,2);{var Fe=Yt=>{var qt=CD();I(Yt,qt)},Ft=Yt=>{var qt=uY(),Qt=b(qt);vS(Qt,{language:"json",get value(){return c(s)},set value(re){v(s,re,!0)}}),I(Yt,qt)};O($e,Yt=>{c(r)?Yt(Fe):Yt(Ft,-1)})}H(()=>N(zt,c(n))),z("click",vi,Ri),z("click",hi,Bt),I(bt,We)},Zt=bt=>{t(bt)};O(me,bt=>{c(n)?bt(Ze):bt(Zt,-1)})}H(()=>_t=zo(Qe,"",_t,{width:`${c(we)??""}px`})),z("click",Ot,()=>{v(pe,!c(pe)),v(je,null)}),Ht(ze,()=>c(Ai),bt=>v(Ai,bt)),z("mousedown",X,jt),I(Ue,J)},mi=Ue=>{var J=xY(),Qe=b(J);let _t;var yt=b(Qe),Ot=b(yt),j=m(yt,2);{var ce=At=>{var ai=gY(),zt=xt(ai),vi=b(zt),hi=m(vi,2),Ci=m(zt,2);{var zi=$e=>{var Fe=yD(),Ft=b(Fe);H(()=>N(Ft,c(He))),I($e,Fe)};O(Ci,$e=>{c(He)&&$e(zi)})}z("keydown",vi,$e=>$e.key==="Enter"&&Ki()),Ht(vi,()=>c(Ke),$e=>v(Ke,$e)),z("click",hi,Ki),I(At,ai)};O(j,At=>{c(ue)&&At(ce)})}var ke=m(j,2),ze=b(ke),st=m(ke,2);ni(st,20,()=>c(Gi),At=>At,(At,ai)=>{var zt=wD();let vi;var hi=b(zt);H(()=>{vi=kt(zt,1,"flat-item svelte-rrt0o",null,vi,{"active-item":c(f)===ai}),N(hi,ai)}),z("click",zt,()=>pt(ai)),I(At,zt)});var X=m(Qe,2),ae=m(X,2),me=b(ae);{var Ze=At=>{var ai=SY(),zt=xt(ai),vi=b(zt),hi=b(vi),Ci=m(vi,2),zi=m(Ci,2),$e=m(zi,2),Fe=m(zt,2);{var Ft=re=>{var Ge=SD(),wt=b(Ge);H(()=>N(wt,c(F))),I(re,Ge)};O(Fe,re=>{c(F)&&re(Ft)})}var Yt=m(Fe,2);{var qt=re=>{var Ge=CD();I(re,Ge)},Qt=re=>{var Ge=wY(),wt=b(Ge),vt=m(b(wt),2),di=b(vt),It=m(wt,2),Ii=m(b(It),2),W=b(Ii),Q=m(It,2),oe=m(b(Q),2),$=b(oe);vS($,{language:"javascript",get value(){return c(p)},set value(Ve){v(p,Ve,!0)}});var A=m(Q,2),G=m(b(A),2),ie=b(G);vS(ie,{language:"javascript",get value(){return c(w)},set value(Ve){v(w,Ve,!0)}});var fe=m(A,2),Y=b(fe),le=b(Y),Re=m(le,4),_e=m(b(Re)),ge=b(_e),tt=m(Y,2);{var U=Ve=>{var De=pY(),Ie=b(De);ms(Ie,()=>c(k),St=>v(k,St)),I(Ve,De)};O(tt,Ve=>{c(x)&&Ve(U)})}var ne=m(fe,2);{var Le=Ve=>{var De=yY(),Ie=b(De),St=m(b(Ie));{var mt=Ne=>{var Ee=_Y();I(Ne,Ee)},qe=Ne=>{var Ee=mY(),Se=b(Ee);H(()=>N(Se,`${c(D).length??0??""} items · rev ${c(D)._rev??""}`)),I(Ne,Ee)};O(St,Ne=>{c(D).error?Ne(mt):Ne(qe,-1)})}var Tt=m(Ie,2);{var it=Ne=>{var Ee=vY(),Se=b(Ee);H(()=>N(Se,c(D).error)),I(Ne,Ee)},ye=Ne=>{var Ee=bY(),Se=b(Ee);H(nt=>N(Se,nt),[()=>JSON.stringify(c(D).result,null,2)]),I(Ne,Ee)};O(Tt,Ne=>{c(D).error?Ne(it):Ne(ye,-1)})}I(Ve,De)};O(ne,Ve=>{c(D)&&Ve(Le)})}H(()=>N(ge,`${c(K)??""}${c(f)??""} on every update`)),Ht(di,()=>c(y),Ve=>v(y,Ve)),Ht(W,()=>c(g),Ve=>v(g,Ve)),ms(le,()=>c(x),Ve=>v(x,Ve)),I(re,Ge)};O(Yt,re=>{c(M)?re(qt):re(Qt,-1)})}H(()=>N(hi,c(f))),z("click",Ci,Bi),z("click",zi,Ti),z("click",$e,Ni),I(At,ai)},Zt=At=>{t(At)};O(me,At=>{c(f)?At(Ze):At(Zt,-1)})}var bt=m(ae,2);{var We=At=>{var ai=CY(),zt=xt(ai),vi=m(zt,2);let hi;var Ci=b(vi);rY(Ci,{get currentView(){return c(Vt)},onApplyView:Me}),H(()=>hi=zo(vi,"",hi,{width:`${c(ct)??""}px`})),z("mousedown",zt,he),I(At,ai)};O(bt,At=>{c(et)&&At(We)})}H(()=>_t=zo(Qe,"",_t,{width:`${c(we)??""}px`})),z("click",Ot,()=>{v(ue,!c(ue)),v(He,null)}),Ht(ze,()=>c(Di),At=>v(Di,At)),z("mousedown",X,jt),I(Ue,J)};O(Oi,Ue=>{c(se)==="docs"?Ue(qi):Ue(mi,-1)})}H(()=>{Kt=kt(rt,1,"svelte-rrt0o",null,Kt,{active:c(se)==="docs"}),Pi=kt(_i,1,"svelte-rrt0o",null,Pi,{active:c(se)==="views"})}),z("mousemove",Ui,ft),z("mouseup",Ui,ht),ds("mouseleave",Ui,ht),z("click",rt,()=>v(se,"docs")),z("click",_i,()=>v(se,"views")),I(o,Ui),Ps()}zs(["mousemove","mouseup","click","keydown","mousedown"]);var IY=T('<label class="svelte-1ua3isv">Passcode <input type="number" placeholder="20202021" class="svelte-1ua3isv"/></label> <label class="svelte-1ua3isv">Discriminator (optional) <input type="number" placeholder="3840" class="svelte-1ua3isv"/></label>',1),EY=T('<label class="svelte-1ua3isv">Pairing Code / QR <input type="text" placeholder="MT:..." class="svelte-1ua3isv"/></label>'),xD=T('<p class="err svelte-1ua3isv"> </p>'),DY=T('<div class="wizard svelte-1ua3isv"><div class="wizard-tabs svelte-1ua3isv"><button>Passcode</button> <button>QR / Code</button></div> <!> <label class="svelte-1ua3isv">IP Address (optional, bypasses mDNS) <input type="text" placeholder="192.168.1.100 or 192.168.1.100:5540" class="svelte-1ua3isv"/></label> <!> <button class="commission-btn svelte-1ua3isv"> </button></div>'),TY=T('<span class="device-name svelte-1ua3isv"> </span> <span class="device-nodeid svelte-1ua3isv"> </span>',1),PY=T('<span class="device-name svelte-1ua3isv"> </span>'),MY=T('<li><button class="device-select-btn svelte-1ua3isv"><span></span> <span class="device-label svelte-1ua3isv"><!></span></button> <button class="unpair-btn svelte-1ua3isv" title="Unpair">✕</button></li>'),RY=T('<li class="empty svelte-1ua3isv">No paired devices</li>'),NY=T('<p class="info svelte-1ua3isv">Loading…</p>'),AY=T('<p class="device-subtitle svelte-1ua3isv"> </p>'),OY=T('<span class="ep-chip svelte-1ua3isv"> </span>'),FY=T('<span class="attr-id svelte-1ua3isv"> </span>'),HY=T('<button class="attr-action-btn svelte-1ua3isv"> </button>'),WY=T('<div class="attr-actions svelte-1ua3isv"></div>'),BY=T('<span class="cmd-sep svelte-1ua3isv">,</span>'),zY=T('<span class="cmd-name svelte-1ua3isv"> </span><span class="cmd-id svelte-1ua3isv"> </span>',1),VY=T('<span class="cmd-id svelte-1ua3isv"> </span>'),jY=T("<!> <!>",1),$Y=T('<span class="cmd-list svelte-1ua3isv"></span>'),UY=T(' <span class="cmd-id svelte-1ua3isv"> </span>',1),qY=T('<tr class="svelte-1ua3isv"><td class="svelte-1ua3isv"><!></td><td class="svelte-1ua3isv"> </td></tr>'),GY=T('<table class="attr-arr-table svelte-1ua3isv"><thead class="svelte-1ua3isv"><tr class="svelte-1ua3isv"><th class="svelte-1ua3isv">deviceType</th><th class="svelte-1ua3isv">revision</th></tr></thead><tbody class="svelte-1ua3isv"></tbody></table>'),KY=T('<th class="svelte-1ua3isv"> </th>'),ZY=T('<td class="svelte-1ua3isv"> </td>'),YY=T('<tr class="svelte-1ua3isv"></tr>'),XY=T('<table class="attr-arr-table svelte-1ua3isv"><thead class="svelte-1ua3isv"><tr class="svelte-1ua3isv"></tr></thead><tbody class="svelte-1ua3isv"></tbody></table>'),QY=T('<tr class="svelte-1ua3isv"><td class="attr-obj-key svelte-1ua3isv"> </td><td class="attr-obj-val svelte-1ua3isv"> </td></tr>'),JY=T('<table class="attr-obj-table svelte-1ua3isv"><tbody class="svelte-1ua3isv"></tbody></table>'),eX=T('<a class="attr-link svelte-1ua3isv" target="_blank" rel="noopener noreferrer"> </a>'),tX=T('<span class="attr-val svelte-1ua3isv"> </span>'),iX=T('<tr class="svelte-1ua3isv"><td class="attr-name-cell svelte-1ua3isv"><span class="attr-key svelte-1ua3isv"> </span><!></td><td class="attr-actions-cell svelte-1ua3isv"><!></td><td class="attr-val-cell svelte-1ua3isv"><!></td></tr>'),nX=T('<tr class="cluster-hdr-row svelte-1ua3isv"><td colspan="3" class="cluster-hdr-cell svelte-1ua3isv"> </td></tr> <!>',1),sX=T('<table class="cluster-table svelte-1ua3isv"><colgroup><col class="col-attr-name svelte-1ua3isv"/><col class="col-attr-actions svelte-1ua3isv"/><col class="col-attr-val"/></colgroup><tbody class="svelte-1ua3isv"></tbody></table>'),oX=T('<p class="no-clusters svelte-1ua3isv">No clusters</p>'),rX=T('<details class="svelte-1ua3isv"><summary class="svelte-1ua3isv"> <span class="ep-id svelte-1ua3isv"> </span> <span class="ep-chips svelte-1ua3isv"></span></summary> <!></details>'),aX=T('<div class="detail-hdr svelte-1ua3isv"><h2 class="svelte-1ua3isv"> </h2> <!> <p class="detail-nodeid svelte-1ua3isv"> </p></div> <!>',1),lX=T('<p class="info svelte-1ua3isv">Select a device to view its endpoints.</p>'),cX=T('<span class="stream-badge svelte-1ua3isv"> </span>'),dX=T('<span class="stream-empty svelte-1ua3isv">Waiting for events…</span>'),bS=T('&nbsp;<span class="e-sub svelte-1ua3isv"> </span>',1),uX=T('<span class="e-badge e-badge-status svelte-1ua3isv">status</span> <span class="e-node svelte-1ua3isv"> <!></span> <span> </span>',1),hX=T('<span class="e-badge e-badge-attr svelte-1ua3isv">attr</span> <span class="e-node svelte-1ua3isv"> <!></span> <span class="e-ep svelte-1ua3isv"> <!></span> <span class="e-cluster svelte-1ua3isv"> </span> <span class="e-attr svelte-1ua3isv"> </span> <span class="e-val svelte-1ua3isv"> </span>',1),fX=T('<div class="er svelte-1ua3isv"><span class="e-ts svelte-1ua3isv"> </span> <!></div>'),gX=T('<div class="stream-body svelte-1ua3isv"><!></div>'),pX=T('<!> <div class="matter-page svelte-1ua3isv"><div class="matter-main svelte-1ua3isv"><div class="sidebar svelte-1ua3isv"><div class="sidebar-header svelte-1ua3isv"><span class="sidebar-title svelte-1ua3isv">Matter Devices</span> <button class="add-btn svelte-1ua3isv" title="Commission new device">+</button></div> <!> <ul class="device-list svelte-1ua3isv"><!> <!></ul></div> <div class="detail svelte-1ua3isv"><!></div></div> <div class="stream-panel svelte-1ua3isv"><div class="stream-resize svelte-1ua3isv"></div> <div class="stream-hdr-row svelte-1ua3isv"><span class="stream-title svelte-1ua3isv">Matter Events</span> <!> <button class="stream-toggle svelte-1ua3isv" title="Toggle event feed"> </button></div> <!></div></div>',1);function _X(o,e){Ts(e,!0);const t={onOff:{onOff:[{label:"On",command:"on"},{label:"Off",command:"off"},{label:"Toggle",command:"toggle"}]},levelControl:{currentLevel:[{label:"Step ▲",command:"stepWithOnOff",args:{stepMode:0,stepSize:25,transitionTime:5}},{label:"Step ▼",command:"stepWithOnOff",args:{stepMode:1,stepSize:25,transitionTime:5}}]},windowCovering:{currentPositionLiftPercent100ths:[{label:"Open",command:"upOrOpen"},{label:"Close",command:"downOrClose"},{label:"Stop",command:"stopMotion"}],currentPositionTiltPercent100ths:[{label:"Open",command:"upOrOpen"},{label:"Close",command:"downOrClose"},{label:"Stop",command:"stopMotion"}]}};async function i(J,Qe,_t,yt,Ot){try{await eq(J,Qe,_t,yt,Ot)}catch(j){console.error("matter command failed",j)}}const n={identify:{0:"identify",1:"triggerEffect"},groups:{0:"addGroup",1:"viewGroup",2:"getGroupMembership",3:"removeGroup",4:"removeAllGroups",5:"addGroupIfIdentifying"},scenes:{0:"addScene",1:"viewScene",2:"removeScene",3:"removeAllScenes",4:"storeScene",5:"recallScene",6:"getSceneMembership",64:"enhancedAddScene",65:"enhancedViewScene",66:"copyScene"},onOff:{0:"off",1:"on",2:"toggle",64:"offWithEffect",65:"onWithRecallGlobalScene",66:"onWithTimedOff"},levelControl:{0:"moveToLevel",1:"move",2:"step",3:"stop",4:"moveToLevelWithOnOff",5:"moveWithOnOff",6:"stepWithOnOff",7:"stopWithOnOff",8:"moveToClosestFrequency"},colorControl:{0:"moveToHue",1:"moveHue",2:"stepHue",3:"moveToSaturation",4:"moveSaturation",5:"stepSaturation",6:"moveToHueAndSaturation",7:"moveToColor",8:"moveColor",9:"stepColor",10:"moveToColorTemperature",64:"enhancedMoveToHue",65:"enhancedMoveHue",66:"enhancedStepHue",67:"enhancedMoveToHueAndSaturation",68:"colorLoopSet",71:"stopMoveStep",75:"moveColorTemperature",76:"stepColorTemperature"},thermostat:{0:"setpointRaiseLower",1:"setWeeklySchedule",2:"getWeeklySchedule",3:"clearWeeklySchedule"},doorLock:{0:"lockDoor",1:"unlockDoor",3:"unlockWithTimeout",11:"setWeekDaySchedule",12:"getWeekDaySchedule",13:"clearWeekDaySchedule",14:"setYearDaySchedule",15:"getYearDaySchedule",16:"clearYearDaySchedule",17:"setHolidaySchedule",18:"getHolidaySchedule",19:"clearHolidaySchedule",26:"setUser",27:"getUser",28:"clearUser",34:"setCredential",36:"getCredential",38:"clearCredential"},windowCovering:{0:"upOrOpen",1:"downOrClose",2:"stopMotion",4:"goToLiftValue",5:"goToLiftPercentage",7:"goToTiltValue",8:"goToTiltPercentage"},fanControl:{0:"step"}};function s(J,Qe){const _t=n[J];return Qe.map(yt=>{const Ot=typeof yt=="number"?yt:Number(yt);return{id:Ot,name:(_t==null?void 0:_t[Ot])??null}})}const r={10:"Door Lock",11:"Door Lock Controller",14:"Aggregator",15:"Generic Switch",17:"On/Off Plug-In Unit",18:"Dimmable Plug-In Unit",19:"Pump",20:"On/Off Light Switch",21:"Dimmer Switch",22:"Color Dimmer Switch",23:"Control Bridge",24:"Pump Controller",256:"On/Off Light",257:"Dimmable Light",268:"Extended Color Light",269:"Color Temperature Light",262:"Light Sensor",263:"Occupancy Sensor",514:"Window Covering",515:"Window Covering Controller",768:"Heating/Cooling Unit",769:"Thermostat",770:"Temperature Sensor",771:"Pressure Sensor",772:"Flow Sensor",773:"Humidity Sensor",774:"On/Off Sensor",2112:"Air Quality Sensor"},a={generatedCommandList:65528,acceptedCommandList:65529,eventList:65530,attributeList:65531,featureMap:65532,clusterRevision:65533},d={descriptor:{deviceTypeList:0,serverList:1,clientList:2,partsList:3,tagList:4},basicInformation:{dataModelRevision:0,vendorName:1,vendorID:2,vendorId:2,productName:3,productID:4,productId:4,nodeLabel:5,location:6,hardwareVersion:7,hardwareVersionString:8,softwareVersion:9,softwareVersionString:10,manufacturingDate:11,partNumber:12,productURL:13,productUrl:13,productLabel:14,serialNumber:15,localConfigDisabled:16,reachable:17,uniqueID:18,uniqueId:18,capabilityMinima:19,productAppearance:20,specificationVersion:21,maxPathsPerInvoke:22},bridgedDeviceBasicInformation:{vendorName:1,vendorID:2,vendorId:2,productName:3,productId:4,nodeLabel:5,hardwareVersion:7,hardwareVersionString:8,softwareVersion:9,softwareVersionString:10,manufacturingDate:11,partNumber:12,productURL:13,productUrl:13,productLabel:14,serialNumber:15,reachable:17,uniqueID:18,uniqueId:18,productAppearance:20},identify:{identifyTime:0,identifyType:1},groups:{nameSupport:0},onOff:{onOff:0,globalSceneControl:16384,onTime:16385,offWaitTime:16386,startUpOnOff:16387},levelControl:{currentLevel:0,remainingTime:1,minLevel:2,maxLevel:3,currentFrequency:4,minFrequency:5,maxFrequency:6,options:15,onOffTransitionTime:16,onLevel:17,onTransitionTime:18,offTransitionTime:19,defaultMoveRate:20,startUpCurrentLevel:16384},colorControl:{currentHue:0,currentSaturation:1,remainingTime:2,currentX:3,currentY:4,colorTemperatureMireds:7,colorMode:8,options:15,enhancedCurrentHue:16384,enhancedColorMode:16385,colorLoopActive:16386,colorLoopDirection:16387,colorLoopTime:16388,colorCapabilities:16394,colorTempPhysicalMinMireds:16395,colorTempPhysicalMaxMireds:16396,coupleColorTempToLevelMinMireds:16397,startUpColorTemperatureMireds:16400},thermostat:{localTemperature:0,outdoorTemperature:1,occupancy:2,absMinHeatSetpointLimit:3,absMaxHeatSetpointLimit:4,absMinCoolSetpointLimit:5,absMaxCoolSetpointLimit:6,piCoolingDemand:7,piHeatingDemand:8,localTemperatureCalibration:16,occupiedCoolingSetpoint:17,occupiedHeatingSetpoint:18,unoccupiedCoolingSetpoint:19,unoccupiedHeatingSetpoint:20,minHeatSetpointLimit:21,maxHeatSetpointLimit:22,minCoolSetpointLimit:23,maxCoolSetpointLimit:24,minSetpointDeadBand:25,remoteSensing:26,controlSequenceOfOperation:27,systemMode:28,thermostatRunningMode:30,startOfWeek:32,numberOfWeeklyTransitions:33,numberOfDailyTransitions:34,temperatureSetpointHold:35,temperatureSetpointHoldDuration:36,thermostatProgrammingOperationMode:37,thermostatRunningState:41,setpointChangeSource:48,setpointChangeAmount:49,setpointChangeSourceTimestamp:50,occupiedSetback:52,unoccupiedSetback:55,emergencyHeatDelta:58},windowCovering:{type:0,physicalClosedLimitLift:1,physicalClosedLimitTilt:2,currentPositionLift:3,currentPositionTilt:4,numberOfActuationsLift:5,numberOfActuationsTilt:6,configStatus:7,currentPositionLiftPercentage:8,currentPositionTiltPercentage:9,operationalStatus:10,targetPositionLiftPercent100ths:11,targetPositionTiltPercent100ths:12,endProductType:13,currentPositionLiftPercent100ths:14,currentPositionTiltPercent100ths:15,installedOpenLimitLift:16,installedClosedLimitLift:17,installedOpenLimitTilt:18,installedClosedLimitTilt:19,mode:23,safetyStatus:26},doorLock:{lockState:0,lockType:1,actuatorEnabled:2,doorState:3,numberOfTotalUsersSupported:17,numberOfPINUsersSupported:18,maxPINCodeLength:23,minPINCodeLength:24,language:33,autoRelockTime:35,soundVolume:36,operatingMode:37,supportedOperatingModes:38,wrongCodeEntryLimit:48},fanControl:{fanMode:0,fanModeSequence:1,percentSetting:2,percentCurrent:3,speedMax:4,speedSetting:5,speedCurrent:6,rockSupport:7,rockSetting:8,windSupport:9,windSetting:10,airflowDirectionSupport:11,airflowDirection:12},occupancySensing:{occupancy:0,occupancySensorType:1,occupancySensorTypeBitmap:2,holdTime:3,pirOccupiedToUnoccupiedDelay:16,pirUnoccupiedToOccupiedDelay:17},illuminanceMeasurement:{measuredValue:0,minMeasuredValue:1,maxMeasuredValue:2,tolerance:3,lightSensorType:4},temperatureMeasurement:{measuredValue:0,minMeasuredValue:1,maxMeasuredValue:2,tolerance:3},pressureMeasurement:{measuredValue:0,minMeasuredValue:1,maxMeasuredValue:2,tolerance:3,scaledValue:16,minScaledValue:17,maxScaledValue:18,scale:20},flowMeasurement:{measuredValue:0,minMeasuredValue:1,maxMeasuredValue:2,tolerance:3},relativeHumidityMeasurement:{measuredValue:0,minMeasuredValue:1,maxMeasuredValue:2,tolerance:3},powerSource:{status:0,order:1,description:2,batVoltage:11,batPercentRemaining:12,batTimeRemaining:13,batChargeLevel:14,batReplacementNeeded:15,batReplaceability:16,batPresent:17,activeBatFaults:18,batChargeState:26}};function u(J){return"0x"+J.toString(16).toUpperCase().padStart(4,"0")}let f=P(yi([])),g=yi(new Map);function p(J){if(J==null)return"—";if(typeof J=="boolean"||typeof J=="number")return String(J);if(typeof J=="string")return J.length>50?J.slice(0,47)+"…":J;const Qe=JSON.stringify(J);return Qe.length>60?Qe.slice(0,57)+"…":Qe}function w(J){return J==null?"—":typeof J=="boolean"||typeof J=="number"?String(J):typeof J=="string"?J:JSON.stringify(J)}function y(J){return J!==null&&typeof J=="object"&&!Array.isArray(J)}function x(J){return Array.isArray(J)&&J.length>0&&J.every(y)}function k(J,Qe){return!!(Qe==="attributeList"||Array.isArray(J)&&J.length===0||y(J)&&Object.keys(J).length===0)}function D(J){return new Date(J).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}const M=500,F=20,K=32;let V=0,se=P(yi([])),te=P(!0),pe=P(180),je=Ct(()=>{const J=Math.max(1,Math.floor((c(pe)-K)/F)+1);return c(se).slice(0,J)});function Ke(J){J.preventDefault();const Qe=J.clientY,_t=c(pe);function yt(j){v(pe,Math.max(60,Math.min(600,_t+Qe-j.clientY)),!0)}function Ot(){document.removeEventListener("mousemove",yt),document.removeEventListener("mouseup",Ot)}document.addEventListener("mousemove",yt),document.addEventListener("mouseup",Ot)}let ue=P(null),He=P(!1),dt=P(null),we=P(!1),gt=P("passcode"),ot=P(""),Pt=P(""),Oe=P(""),Mt=P(!1),et=P(null),ct=P("");const Nt="she:matter:selectedNodeId";async function ti(){try{v(f,await ZN(),!0);for(const J of c(f))Jm(J.nodeId).then(Qe=>{g.set(J.nodeId,Qe)}).catch(()=>{});if(c(f).length>0&&!c(ue)){const J=localStorage.getItem(Nt),Qe=J&&c(f).find(_t=>_t.nodeId===J)?J:c(f)[0].nodeId;ri(Qe)}}catch{v(f,[],!0)}}async function ri(J){v(He,!0),v(dt,null);try{v(ue,await Jm(J),!0),g.set(J,c(ue)),localStorage.setItem(Nt,J)}catch(Qe){v(dt,Qe instanceof Error?Qe.message:String(Qe),!0)}finally{v(He,!1)}}let Vt;async function Me(J){var Qe;if(await Vt.show(`Unpair device ${J}?`,{confirm:"Unpair",danger:!0}))try{await JU(J),((Qe=c(ue))==null?void 0:Qe.nodeId)===J&&v(ue,null),await ti()}catch(_t){v(dt,_t instanceof Error?_t.message:String(_t),!0)}}async function jt(){v(Mt,!0),v(et,null);try{let J;c(gt)==="passcode"?(J={passcode:Number(c(ot))},c(Pt)&&(J={...J,discriminator:Number(c(Pt))})):J={pairingCode:c(Oe).trim()},c(ct).trim()&&(J={...J,discoveryAddress:c(ct).trim()}),await QU(J),v(we,!1),v(ot,""),v(Pt,""),v(Oe,""),v(ct,""),await ti()}catch(J){v(et,J instanceof Error?J.message:String(J),!0)}finally{v(Mt,!1)}}Bs(()=>{ti()});const ft=cr("matter:deviceList",J=>{if(!Array.isArray(J.devices))return;const Qe=J.devices;for(const _t of Qe)g.has(_t.nodeId)||Jm(_t.nodeId).then(yt=>{g.set(_t.nodeId,yt)}).catch(()=>{});v(f,Qe,!0)}),ht=cr("matter:deviceStatus",J=>{if(J.nodeId===void 0)return;const Qe=String(J.nodeId),_t=!!J.online;v(f,c(f).map(yt=>yt.nodeId===Qe?{...yt,online:_t}:yt),!0),v(se,[{id:V++,kind:"status",nodeId:Qe,online:_t,ts:Date.now()},...c(se).slice(0,M-1)],!0)}),he=cr("matter:attr",J=>{const Qe=String(J.nodeId),_t=J.endpointId,yt=String(J.clusterName),Ot=String(J.attrName),j=J.value;if(c(ue)&&c(ue).nodeId===Qe){const ke=c(ue).endpoints.find(st=>st.endpointId===_t),ze=ke==null?void 0:ke.clusters.find(st=>st.name===yt);ze&&(ze.attrs[Ot]=j)}const ce=g.get(Qe);if(ce){const ke=ce.endpoints.find(st=>st.endpointId===_t),ze=ke==null?void 0:ke.clusters.find(st=>st.name===yt);ze&&(ze.attrs[Ot]=j)}v(se,[{id:V++,kind:"attr",nodeId:Qe,endpointId:_t,clusterName:yt,attrName:Ot,value:j,ts:J.ts??Date.now()},...c(se).slice(0,M-1)],!0)});x_(()=>{ft(),ht(),he()});var Xe=pX(),Ut=xt(Xe);vs(Uc(Ut,{}),J=>Vt=J,()=>Vt);var wi=m(Ut,2),Ri=b(wi),ci=b(Ri),Bt=b(ci),Xt=m(b(Bt),2),pt=m(Bt,2);{var Bi=J=>{var Qe=DY(),_t=b(Qe),yt=b(_t);let Ot;var j=m(yt,2);let ce;var ke=m(_t,2);{var ze=We=>{var At=IY(),ai=xt(At),zt=m(b(ai)),vi=m(ai,2),hi=m(b(vi));Ht(zt,()=>c(ot),Ci=>v(ot,Ci)),Ht(hi,()=>c(Pt),Ci=>v(Pt,Ci)),I(We,At)},st=We=>{var At=EY(),ai=m(b(At));Ht(ai,()=>c(Oe),zt=>v(Oe,zt)),I(We,At)};O(ke,We=>{c(gt)==="passcode"?We(ze):We(st,-1)})}var X=m(ke,2),ae=m(b(X)),me=m(X,2);{var Ze=We=>{var At=xD(),ai=b(At);H(()=>N(ai,c(et))),I(We,At)};O(me,We=>{c(et)&&We(Ze)})}var Zt=m(me,2),bt=b(Zt);H(()=>{Ot=kt(yt,1,"svelte-1ua3isv",null,Ot,{active:c(gt)==="passcode"}),ce=kt(j,1,"svelte-1ua3isv",null,ce,{active:c(gt)==="pairingCode"}),Zt.disabled=c(Mt),N(bt,c(Mt)?"Commissioning…":"Commission")}),z("click",yt,()=>v(gt,"passcode")),z("click",j,()=>v(gt,"pairingCode")),Ht(ae,()=>c(ct),We=>v(ct,We)),z("click",Zt,jt),I(J,Qe)};O(pt,J=>{c(we)&&J(Bi)})}var Ti=m(pt,2),Ni=b(Ti);ni(Ni,17,()=>c(f),J=>J.nodeId,(J,Qe)=>{var _t=MY();let yt;var Ot=b(_t),j=b(Ot);let ce;var ke=m(j,2),ze=b(ke);{var st=me=>{var Ze=TY(),Zt=xt(Ze),bt=b(Zt),We=m(Zt,2),At=b(We);H(()=>{N(bt,c(Qe).name),N(At,`#${c(Qe).nodeId??""}`)}),I(me,Ze)},X=me=>{var Ze=PY(),Zt=b(Ze);H(()=>N(Zt,`Node ${c(Qe).nodeId??""}`)),I(me,Ze)};O(ze,me=>{c(Qe).name?me(st):me(X,-1)})}var ae=m(Ot,2);H(()=>{var me;yt=kt(_t,1,"svelte-1ua3isv",null,yt,{selected:((me=c(ue))==null?void 0:me.nodeId)===c(Qe).nodeId}),ce=kt(j,1,"status-dot svelte-1ua3isv",null,ce,{online:c(Qe).online})}),z("click",Ot,()=>ri(c(Qe).nodeId)),z("click",ae,()=>Me(c(Qe).nodeId)),I(J,_t)});var Ki=m(Ni,2);{var Ai=J=>{var Qe=RY();I(J,Qe)};O(Ki,J=>{c(f).length===0&&J(Ai)})}var Di=m(ci,2),$i=b(Di);{var Gi=J=>{var Qe=NY();I(J,Qe)},Ui=J=>{var Qe=xD(),_t=b(Qe);H(()=>N(_t,c(dt))),I(J,Qe)},mn=J=>{var Qe=aX(),_t=xt(Qe),yt=b(_t),Ot=b(yt),j=m(yt,2);{var ce=X=>{var ae=AY(),me=b(ae);H(()=>N(me,c(ue).subtitle)),I(X,ae)};O(j,X=>{c(ue).subtitle&&X(ce)})}var ke=m(j,2),ze=b(ke),st=m(_t,2);ni(st,17,()=>c(ue).endpoints,X=>X.endpointId,(X,ae)=>{var me=rX(),Ze=b(me),Zt=b(Ze),bt=m(Zt),We=b(bt),At=m(bt,2);ni(At,21,()=>c(ae).clusters,Vi,(hi,Ci)=>{var zi=OY(),$e=b(zi);H(()=>N($e,c(Ci).name)),I(hi,zi)});var ai=m(Ze,2);{var zt=hi=>{var Ci=sX(),zi=m(b(Ci));ni(zi,21,()=>c(ae).clusters,Vi,($e,Fe)=>{var Ft=nX(),Yt=xt(Ft),qt=b(Yt),Qt=b(qt),re=m(Yt,2);ni(re,17,()=>Object.entries(c(Fe).attrs),Vi,(Ge,wt)=>{var vt=Ct(()=>zL(c(wt),2));let di=()=>c(vt)[0],It=()=>c(vt)[1];var Ii=As(),W=xt(Ii);{var Q=$=>{const A=Ct(()=>{var Ee;return(Ee=t[c(Fe).name])==null?void 0:Ee[di()]}),G=Ct(()=>(di()==="acceptedCommandList"||di()==="generatedCommandList")&&Array.isArray(It())),ie=Ct(()=>{var Ee;return((Ee=d[c(Fe).name])==null?void 0:Ee[di()])??a[di()]});var fe=iX(),Y=b(fe),le=b(Y),Re=b(le),_e=m(le);{var ge=Ee=>{var Se=FY(),nt=b(Se);H(de=>N(nt,`(${de??""})`),[()=>u(c(ie))]),I(Ee,Se)};O(_e,Ee=>{c(ie)!==void 0&&Ee(ge)})}var tt=m(Y),U=b(tt);{var ne=Ee=>{var Se=WY();ni(Se,21,()=>c(A),Vi,(nt,de)=>{var Pe=HY(),at=b(Pe);H(()=>N(at,c(de).label)),z("click",Pe,()=>i(c(ue).nodeId,c(ae).endpointId,c(Fe).name,c(de).command,c(de).args)),I(nt,Pe)}),I(Ee,Se)};O(U,Ee=>{c(A)&&Ee(ne)})}var Le=m(tt),Ve=b(Le);{var De=Ee=>{var Se=$Y();ni(Se,21,()=>s(c(Fe).name,It()),Vi,(nt,de,Pe)=>{var at=jY(),ut=xt(at);{var Je=ii=>{var xi=BY();I(ii,xi)};O(ut,ii=>{Pe>0&&ii(Je)})}var $t=m(ut,2);{var Jt=ii=>{var xi=zY(),Ji=xt(xi),Hi=b(Ji),li=m(Ji),un=b(li);H(()=>{N(Hi,c(de).name),N(un,`(${c(de).id??""})`)}),I(ii,xi)},Mi=ii=>{var xi=VY(),Ji=b(xi);H(()=>N(Ji,c(de).id)),I(ii,xi)};O($t,ii=>{c(de).name?ii(Jt):ii(Mi,-1)})}I(nt,at)}),I(Ee,Se)},Ie=Ee=>{var Se=GY(),nt=m(b(Se));ni(nt,21,It,Vi,(de,Pe)=>{const at=Ct(()=>c(Pe)),ut=Ct(()=>c(at).deviceType),Je=Ct(()=>r[c(ut)]);var $t=qY(),Jt=b($t),Mi=b(Jt);{var ii=li=>{var un=UY(),rn=xt(un),es=m(rn),js=b(es);H(fo=>{N(rn,`${c(Je)??""} `),N(js,`(${fo??""})`)},[()=>u(c(ut))]),I(li,un)},xi=li=>{var un=po();H(rn=>N(un,rn),[()=>u(c(ut))]),I(li,un)};O(Mi,li=>{c(Je)?li(ii):li(xi,-1)})}var Ji=m(Jt),Hi=b(Ji);H(li=>N(Hi,li),[()=>w(c(at).revision)]),I(de,$t)}),I(Ee,Se)},St=Ct(()=>di()==="deviceTypeList"&&Array.isArray(It())),mt=Ee=>{const Se=Ct(()=>[...new Set(It().flatMap(ut=>Object.keys(ut)))]);var nt=XY(),de=b(nt),Pe=b(de);ni(Pe,21,()=>c(Se),Vi,(ut,Je)=>{var $t=KY(),Jt=b($t);H(()=>N(Jt,c(Je))),I(ut,$t)});var at=m(de);ni(at,21,It,Vi,(ut,Je)=>{var $t=YY();ni($t,21,()=>c(Se),Vi,(Jt,Mi)=>{var ii=ZY(),xi=b(ii);H(Ji=>N(xi,Ji),[()=>w(c(Je)[c(Mi)])]),I(Jt,ii)}),I(ut,$t)}),I(Ee,nt)},qe=Ct(()=>x(It())),Tt=Ee=>{var Se=JY(),nt=b(Se);ni(nt,21,()=>Object.entries(It()),Vi,(de,Pe)=>{var at=Ct(()=>zL(c(Pe),2));let ut=()=>c(at)[0],Je=()=>c(at)[1];var $t=QY(),Jt=b($t),Mi=b(Jt),ii=m(Jt),xi=b(ii);H(Ji=>{N(Mi,ut()),N(xi,Ji)},[()=>w(Je())]),I(de,$t)}),I(Ee,Se)},it=Ct(()=>y(It())),ye=Ee=>{var Se=eX(),nt=b(Se);H(()=>{ln(Se,"href",It()),N(nt,It())}),I(Ee,Se)},Ne=Ee=>{var Se=tX(),nt=b(Se);H(de=>N(nt,de),[()=>w(It())]),I(Ee,Se)};O(Ve,Ee=>{c(G)?Ee(De):c(St)?Ee(Ie,1):c(qe)?Ee(mt,2):c(it)?Ee(Tt,3):(di()==="productUrl"||di()==="productURL")&&typeof It()=="string"?Ee(ye,4):Ee(Ne,-1)})}H(()=>{ln(Y,"title",di()),N(Re,di())}),I($,fe)},oe=Ct(()=>!k(It(),di()));O(W,$=>{c(oe)&&$(Q)})}I(Ge,Ii)}),H(()=>N(Qt,c(Fe).name)),I($e,Ft)}),I(hi,Ci)},vi=hi=>{var Ci=oX();I(hi,Ci)};O(ai,hi=>{c(ae).clusters.length>0?hi(zt):hi(vi,-1)})}H(()=>{N(Zt,`${c(ae).name??`Endpoint ${c(ae).endpointId}`??""} `),N(We,`ep${c(ae).endpointId??""}`)}),I(X,me)}),H(()=>{N(Ot,c(ue).name??`Node ${c(ue).nodeId}`),N(ze,`Node ID: ${c(ue).nodeId??""}`)}),I(J,Qe)},rt=J=>{var Qe=lX();I(J,Qe)};O($i,J=>{c(He)?J(Gi):c(dt)?J(Ui,1):c(ue)?J(mn,2):J(rt,-1)})}var Kt=m(Ri,2),_i=b(Kt),Pi=m(_i,2),Li=m(b(Pi),2);{var Si=J=>{var Qe=cX(),_t=b(Qe);H(()=>N(_t,c(se).length)),I(J,Qe)};O(Li,J=>{!c(te)&&c(se).length>0&&J(Si)})}var Oi=m(Li,2),qi=b(Oi),mi=m(Pi,2);{var Ue=J=>{var Qe=gX(),_t=b(Qe);{var yt=j=>{var ce=dX();I(j,ce)},Ot=j=>{var ce=As(),ke=xt(ce);ni(ke,17,()=>c(je),ze=>ze.id,(ze,st)=>{const X=Ct(()=>{var zt,vi;return((zt=g.get(c(st).nodeId))==null?void 0:zt.name)??((vi=c(f).find(hi=>hi.nodeId===c(st).nodeId))==null?void 0:vi.name)??null}),ae=Ct(()=>{var zt,vi;return c(st).endpointId!==void 0?((vi=(zt=g.get(c(st).nodeId))==null?void 0:zt.endpoints.find(hi=>hi.endpointId===c(st).endpointId))==null?void 0:vi.name)??null:null}),me=Ct(()=>c(st).attrName??c(st).clusterName);var Ze=fX(),Zt=b(Ze),bt=b(Zt),We=m(Zt,2);{var At=zt=>{var vi=uX(),hi=m(xt(vi),2),Ci=b(hi),zi=m(Ci);{var $e=qt=>{var Qt=bS(),re=m(xt(Qt)),Ge=b(re);H(()=>N(Ge,`(#${c(st).nodeId??""})`)),I(qt,Qt)};O(zi,qt=>{c(X)&&qt($e)})}var Fe=m(hi,2);let Ft;var Yt=b(Fe);H(()=>{N(Ci,c(X)??`#${c(st).nodeId}`),Ft=kt(Fe,1,"e-val svelte-1ua3isv",null,Ft,{"e-online":c(st).online,"e-offline":!c(st).online}),N(Yt,c(st).online?"online":"offline")}),I(zt,vi)},ai=zt=>{var vi=hX(),hi=m(xt(vi),2),Ci=b(hi),zi=m(Ci);{var $e=It=>{var Ii=bS(),W=m(xt(Ii)),Q=b(W);H(()=>N(Q,`(#${c(st).nodeId??""})`)),I(It,Ii)};O(zi,It=>{c(X)&&It($e)})}var Fe=m(hi,2),Ft=b(Fe),Yt=m(Ft);{var qt=It=>{var Ii=bS(),W=m(xt(Ii)),Q=b(W);H(()=>N(Q,`(ep ${c(st).endpointId??""})`)),I(It,Ii)};O(Yt,It=>{c(ae)&&It(qt)})}var Qt=m(Fe,2),re=b(Qt),Ge=m(Qt,2),wt=b(Ge),vt=m(Ge,2),di=b(vt);H(It=>{N(Ci,c(X)??`#${c(st).nodeId}`),N(Ft,c(ae)??`ep${c(st).endpointId}`),N(re,c(st).clusterName),N(wt,c(me)),N(di,It)},[()=>p(c(st).value)]),I(zt,vi)};O(We,zt=>{c(st).kind==="status"?zt(At):zt(ai,-1)})}H(zt=>N(bt,zt),[()=>D(c(st).ts)]),I(ze,Ze)}),I(j,ce)};O(_t,j=>{c(je).length===0?j(yt):j(Ot,-1)})}I(J,Qe)};O(mi,J=>{c(te)&&J(Ue)})}H(()=>{zo(Kt,c(te)?`height: ${c(pe)}px;`:""),N(qi,c(te)?"▾":"▸")}),z("click",Xt,()=>v(we,!c(we))),z("mousedown",_i,Ke),z("click",Oi,()=>{v(te,!c(te))}),I(o,Xe),Ps()}zs(["click","mousedown"]);var mX=T("<button>›</button>"),vX=T('<span class="chev-ph svelte-1vejtrc"></span>'),bX=T('<span class="tv svelte-1vejtrc"> </span> <span class="tt svelte-1vejtrc"> </span>',1),yX=T("<button>🔒</button>"),wX=T("<span> </span>"),SX=T('<span class="acl-dyn svelte-1vejtrc" title="per-user/client pattern — cannot evaluate statically">⚠%u/%c</span>'),CX=T('<span class="acl-members svelte-1vejtrc"> </span>'),xX=T('<span class="acl-group svelte-1vejtrc"> </span>'),kX=T('<span> <strong class="svelte-1vejtrc"> </strong> <!> <!> <!></span>'),LX=T('<div class="acl-sec svelte-1vejtrc"><span class="acl-sec-hdr svelte-1vejtrc"> </span> <!></div>'),IX=T('<div class="acl-panel svelte-1vejtrc"></div>'),EX=T('<div class="tc svelte-1vejtrc"></div>'),DX=T('<div class="tn svelte-1vejtrc"><div><!> <span class="seg svelte-1vejtrc"> </span> <!> <!></div> <!> <!></div>'),TX=T('<button class="acl-refresh svelte-1vejtrc" title="Refresh ACL data">↺</button>'),PX=T('<button title="Show ACL coverage for topics"><svg width="11" height="11" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><rect x="3" y="7" width="10" height="8" rx="1.5"></rect><path d="M5 7V5a3 3 0 0 1 6 0v2" fill="none" stroke="currentColor" stroke-width="1.8"></path></svg> ACL<!></button> <!>',1),MX=T("<option></option>"),RX=T('<span class="pub-ok svelte-1vejtrc">✓</span>'),NX=T('<span class="pub-err svelte-1vejtrc"> </span>'),AX=T('<div class="info svelte-1vejtrc">Loading…</div>'),OX=T('<div class="info err svelte-1vejtrc"> </div>'),FX=T('<div class="info svelte-1vejtrc">No topics match.</div>'),HX=T('<div class="vr svelte-1vejtrc"><span class="v-topic svelte-1vejtrc"> </span> <span class="v-val svelte-1vejtrc"> </span> <span class="v-ts svelte-1vejtrc"> </span></div>'),WX=T('<div class="vs svelte-1vejtrc"><div><div class="vrows-abs svelte-1vejtrc"></div></div></div>'),BX=T('<div class="info svelte-1vejtrc">No topics yet.</div>'),zX=T('<div class="tree-wrap svelte-1vejtrc"><!></div>'),VX=T('<span class="stream-badge"> </span>'),jX=T('<span class="stream-empty svelte-1vejtrc">Waiting for messages…</span>'),$X=T('<span class="s-ret svelte-1vejtrc" title="retained snapshot">&#x229B;</span>'),UX=T('<div><span class="s-ts svelte-1vejtrc"> </span> <!> <span class="s-topic svelte-1vejtrc"> </span> <span class="s-val svelte-1vejtrc"> </span></div>'),qX=T('<div class="stream-body svelte-1vejtrc"><!></div>'),GX=T('<div class="ctx-bd svelte-1vejtrc"></div> <div class="ctx-menu svelte-1vejtrc"><button class="svelte-1vejtrc">Copy topic</button> <button class="svelte-1vejtrc">Clear retained</button></div>',1),KX=T('<label class="modal-check svelte-1vejtrc"><input type="checkbox" class="svelte-1vejtrc"/> <span class="checkmark svelte-1vejtrc"></span> Recursive — also clear all child topics</label>'),ZX=T('<div class="modal-bd svelte-1vejtrc"></div> <div class="modal svelte-1vejtrc"><div class="modal-title svelte-1vejtrc">Clear retained</div> <div class="modal-body svelte-1vejtrc"><p class="svelte-1vejtrc">Clear retained value for <code class="svelte-1vejtrc"> </code>?</p> <!></div> <div class="modal-footer svelte-1vejtrc"><button class="btn-cancel svelte-1vejtrc">Cancel</button> <button class="btn-confirm svelte-1vejtrc">Clear</button></div></div>',1),YX=T('<div class="page svelte-1vejtrc"><div class="toolbar svelte-1vejtrc"><h2 class="svelte-1vejtrc">MQTT</h2> <!></div> <div class="main-group svelte-1vejtrc"><div class="pub-bar svelte-1vejtrc"><input class="pt svelte-1vejtrc" type="text" placeholder="topic" list="pub-topic-list" autocomplete="off"/> <datalist id="pub-topic-list"></datalist> <input class="pp svelte-1vejtrc" type="text" placeholder="payload"/> <label class="rl svelte-1vejtrc"><input type="checkbox" class="svelte-1vejtrc"/> <span class="checkmark svelte-1vejtrc"></span> retain</label> <select class="svelte-1vejtrc"><option>QoS 0</option><option>QoS 1</option><option>QoS 2</option></select> <button class="svelte-1vejtrc">Publish</button> <!> <!></div> <div class="tree-filter-bar svelte-1vejtrc"><input class="filter-in svelte-1vejtrc" type="search" placeholder="Filter topics…"/> <span class="count svelte-1vejtrc"><!> </span></div> <!></div> <div class="stream-panel svelte-1vejtrc"><div class="stream-resize svelte-1vejtrc"></div> <div class="stream-hdr-row svelte-1vejtrc"><input class="filter-in stream-filter-in svelte-1vejtrc" type="search" placeholder="Live stream filter (MQTT wildcard, default: #)"/> <!> <button class="stream-toggle svelte-1vejtrc" title="Toggle live stream"> </button></div> <!></div> <!> <!></div>');function XX(o,e){Ts(e,!0);const t=($,A=Hy)=>{const G=Ct(()=>c(g).has(A().path)),ie=Ct(()=>c(a)>=0&&A().children.size>0),fe=Ct(()=>c(a)>=0&&A().isLeaf&&!n.has(A().path));var Y=DX(),le=b(Y);let Re;var _e=b(le);{var ge=ye=>{var Ne=mX();let Ee;H(()=>{Ee=kt(Ne,1,"chev svelte-1vejtrc",null,Ee,{open:c(G)}),ln(Ne,"aria-label",c(G)?"Collapse":"Expand")}),z("click",Ne,()=>p(A().path)),I(ye,Ne)},tt=ye=>{var Ne=vX();I(ye,Ne)};O(_e,ye=>{c(ie)?ye(ge):ye(tt,-1)})}var U=m(_e,2),ne=b(U),Le=m(U,2);{var Ve=ye=>{var Ne=bX(),Ee=xt(Ne),Se=b(Ee),nt=m(Ee,2),de=b(nt);H((Pe,at,ut)=>{ln(Ee,"title",Pe),N(Se,at),N(de,ut)},[()=>{var Pe;return wi((Pe=Bt(A().path))==null?void 0:Pe.val)},()=>{var Pe;return wi((Pe=Bt(A().path))==null?void 0:Pe.val)},()=>{var Pe;return((Pe=Bt(A().path))==null?void 0:Pe.ts)!=null?Ri(Bt(A().path).ts):""}]),I(ye,Ne)},De=Ct(()=>A().isLeaf&&i.has(A().path));O(Le,ye=>{c(De)&&ye(Ve)})}var Ie=m(Le,2);{var St=ye=>{const Ne=Ct(()=>!!c($i)&&mn(A().path));var Ee=yX();let Se;H(()=>{Se=kt(Ee,1,"acl-badge svelte-1vejtrc",null,Se,{matched:c(Ne)}),ln(Ee,"title",c(Ne)?"Has explicit ACL — click to inspect":"No explicit ACL — uses defaults")}),z("click",Ee,nt=>{nt.stopPropagation(),v(Gi,c(Gi)===A().path?null:A().path,!0)}),I(ye,Ee)};O(Ie,ye=>{c(Ai)&&A().isLeaf&&ye(St)})}var mt=m(le,2);{var qe=ye=>{const Ne=Ct(()=>rt(A().path,Bi)),Ee=Ct(()=>rt(A().path,Ti)),Se=Ct(()=>rt(A().path,Ni));var nt=IX();ni(nt,21,()=>[{label:"Send",roles:c(Ne),defType:"publishClientSend"},{label:"Subscribe",roles:c(Ee),defType:"subscribePattern"},{label:"Receive",roles:c(Se),defType:"publishClientReceive"}],Vi,(de,Pe)=>{var at=LX(),ut=b(at),Je=b(ut),$t=m(ut,2);{var Jt=ii=>{var xi=wX();let Ji;var Hi=b(xi);H((li,un)=>{Ji=kt(xi,1,"acl-def svelte-1vejtrc",null,Ji,li),N(Hi,`${un??""} (default)`)},[()=>({allow:_i(c(Pe).defType),deny:!_i(c(Pe).defType)}),()=>_i(c(Pe).defType)?"allow":"deny"]),I(ii,xi)},Mi=ii=>{var xi=As(),Ji=xt(xi);ni(Ji,17,()=>c(Pe).roles,Vi,(Hi,li)=>{const un=Ct(()=>Kt(c(li).rolename));var rn=kX();let es;var js=b(rn),fo=m(js),Zo=b(fo),hr=m(fo,2);{var Yn=Ms=>{var fs=SX();I(Ms,fs)};O(hr,Ms=>{c(li).dynamic&&Ms(Yn)})}var Yo=m(hr,2);{var fr=Ms=>{var fs=CX(),ns=b(fs);H(Rs=>N(ns,Rs),[()=>c(un).direct.join(", ")]),I(Ms,fs)};O(Yo,Ms=>{c(un).direct.length>0&&Ms(fr)})}var vn=m(Yo,2);ni(vn,17,()=>c(un).viaGroup,Vi,(Ms,fs)=>{var ns=xX(),Rs=b(ns);H(()=>N(Rs,c(fs).groupname)),I(Ms,ns)}),H(()=>{es=kt(rn,1,"acl-role svelte-1vejtrc",null,es,{allow:c(li).allow,deny:!c(li).allow}),N(js,`${c(li).allow?"✓":"✗"} `),N(Zo,c(li).rolename)}),I(Hi,rn)}),I(ii,xi)};O($t,ii=>{c(Pe).roles.length===0?ii(Jt):ii(Mi,-1)})}H(()=>N(Je,c(Pe).label)),I(de,at)}),I(ye,nt)};O(mt,ye=>{c(Ai)&&A().isLeaf&&c(Gi)===A().path&&c($i)&&ye(qe)})}var Tt=m(mt,2);{var it=ye=>{var Ne=EX();ni(Ne,21,()=>[...A().children.values()].sort((Ee,Se)=>Ee.seg.localeCompare(Se.seg)),Ee=>Ee.path,(Ee,Se)=>{t(Ee,()=>c(Se))}),I(ye,Ne)};O(Tt,ye=>{c(ie)&&c(G)&&ye(it)})}H(()=>{Re=kt(le,1,"tr svelte-1vejtrc",null,Re,{stale:c(fe)}),N(ne,A().seg)}),z("click",le,()=>{v(He,A().path+"/#")}),z("contextmenu",le,ye=>{ye.preventDefault(),v(ct,{x:ye.clientX,y:ye.clientY,topic:A().path},!0)}),I($,Y)},i=new Map,n=new Set,s=new Set;let r=null,a=P(0);function d(){r===null&&(r=requestAnimationFrame(()=>{r=null;for(const $ of s)f($);s.clear(),$L(a)}))}const u=new Map;function f($){const A=$.split("/");let G=u,ie="";for(let fe=0;fe<A.length;fe++){const Y=A[fe];ie=fe===0?Y:`${ie}/${Y}`,G.has(Y)||G.set(Y,{seg:Y,path:ie,children:new Map,isLeaf:!1});const le=G.get(Y);fe===A.length-1&&(le.isLeaf=!0),G=le.children}}let g=P(yi(new Set));function p($){const A=new Set(c(g));A.has($)?A.delete($):A.add($),v(g,A,!0)}let w=P("");const y=24,x=5;let k=P(0),D=P(300),M=Ct(()=>{if(c(a),!c(w))return[];const $=c(w).toLowerCase().split(/\s+/).filter(Boolean),A=[];for(const[G,ie]of i){const fe=G.toLowerCase();$.every(Y=>fe.includes(Y))&&A.push({topic:G,...ie})}return A.sort((G,ie)=>G.topic.localeCompare(ie.topic))}),F=Ct(()=>{const $=c(M).length,A=Math.max(0,Math.floor(c(k)/y)-x),G=Math.min($,Math.ceil((c(k)+c(D))/y)+x);return{start:A,end:G,totalH:$*y,top:A*y}});const K=1e3,V=200,se=20,te=36;let pe=0,je=P(yi([])),Ke=P(yi([])),ue=P(!0),He=P("#"),dt=P(200);Vn(()=>{const $=c(He).trim(),A=Fl(()=>c(je)),G=!$||$==="#"?A.slice(0,V):A.filter(ie=>we($,ie.topic)).slice(0,V);if($&&$!=="#"){const ie=new Set(G.map(Y=>Y.topic)),fe=[];for(const[Y,le]of i)ie.has(Y)||we($,Y)&&fe.push({id:-(fe.length+1),topic:Y,val:le.val,ts:le.ts,retained:!0});fe.sort((Y,le)=>Y.topic.localeCompare(le.topic)),v(Ke,[...G,...fe],!0)}else v(Ke,G,!0)});function we($,A){if($==="#")return!0;const G=$.split("/"),ie=A.split("/");for(let fe=0;fe<G.length;fe++){if(G[fe]==="#")return!0;if(fe>=ie.length||G[fe]!=="+"&&G[fe]!==ie[fe])return!1}return G.length===ie.length}function gt($){$.preventDefault();const A=$.clientY,G=c(dt);function ie(Y){v(dt,Math.max(60,Math.min(800,G+A-Y.clientY)),!0)}function fe(){document.removeEventListener("mousemove",ie),document.removeEventListener("mouseup",fe)}document.addEventListener("mousemove",ie),document.addEventListener("mouseup",fe)}let ot=Ct(()=>{const $=Math.max(1,Math.floor((c(dt)-te)/se)+1);return c(Ke).slice(0,$)}),Pt=P(!0),Oe=P(null);async function Mt(){v(Pt,!0),v(Oe,null);try{const $=await YN();for(const A of $)i.set(A.topic,{val:A.val,ts:A.ts}),f(A.topic)}catch($){v(Oe,$ instanceof Error?$.message:String($),!0)}finally{v(Pt,!1),$L(a)}}const et=cr("mqtt",$=>{const{topic:A,val:G,ts:ie}=$;i.set(A,{val:G,ts:ie}),n.add(A),s.add(A),d();const fe={id:pe++,topic:A,val:G,ts:ie};v(je,[fe,...c(je).slice(0,K-1)],!0);const Y=c(He).trim();(!Y||Y==="#"||we(Y,A))&&v(Ke,[fe,...c(Ke).filter(le=>!(le.retained&&le.topic===A)).slice(0,V-1)],!0)});let ct=P(null),Nt=P(null);async function ti($,A){const G=[$];if(A){const ie=$+"/";for(const fe of i.keys())fe.startsWith(ie)&&G.push(fe)}for(const ie of G)await UE(ie,"",!0,0)}let ri=Ct(()=>(c(a),[...i.keys()].sort())),Vt=P(""),Me=P(""),jt=P(!1),ft=P(0),ht=P(!1),he=P(null),Xe=P(!1);async function Ut(){if(c(Vt)){v(ht,!0),v(he,null),v(Xe,!1);try{await UE(c(Vt),c(Me),c(jt),c(ft)),v(Xe,!0),setTimeout(()=>{v(Xe,!1)},2e3)}catch($){v(he,$ instanceof Error?$.message:String($),!0)}finally{v(ht,!1)}}}function wi($){return $==null?"":typeof $=="object"?JSON.stringify($):String($)}function Ri($){return new Date($).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function ci($){return new Date($).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function Bt($){return c(a),i.get($)}let Xt=Ct(()=>(c(a),[...u.values()].sort(($,A)=>$.seg.localeCompare(A.seg)))),pt=Ct(()=>(c(a),i.size));const Bi=new Set(["publishClientSend"]),Ti=new Set(["subscribePattern","subscribeLiteral"]),Ni=new Set(["publishClientReceive"]);let Ki=P(!1),Ai=P(!1),Di=P(!1),$i=P(null),Gi=P(null);function Ui($,A,G){return A.includes("%u")||A.includes("%c")?"dynamic":$==="subscribeLiteral"||$==="unsubscribeLiteral"?A===G?"match":"no-match":we(A,G)?"match":"no-match"}function mn($){if(!c($i))return!1;for(const A of c($i).roles)if(A.acls){for(const G of A.acls)if(Ui(G.acltype,G.topic,$)!=="no-match")return!0}return!1}function rt($,A){if(!c($i))return[];const G=[];for(const ie of c($i).roles)if(ie.acls)for(const fe of ie.acls){if(!A.has(fe.acltype))continue;const Y=Ui(fe.acltype,fe.topic,$);if(Y!=="no-match"){G.push({rolename:ie.rolename,allow:fe.allow,dynamic:Y==="dynamic"});break}}return G}function Kt($){if(!c($i))return{direct:[],viaGroup:[]};const A=c($i).users.filter(ie=>{var fe;return(fe=ie.roles)==null?void 0:fe.some(Y=>Y.rolename===$)}).map(ie=>ie.username),G=c($i).groups.filter(ie=>{var fe;return(fe=ie.roles)==null?void 0:fe.some(Y=>Y.rolename===$)}).map(ie=>({groupname:ie.groupname,members:(ie.clients??[]).map(fe=>fe.username)}));return{direct:A,viaGroup:G}}function _i($){if(!c($i))return!1;const A=c($i).defaults.find(G=>G.acltype===$);return(A==null?void 0:A.allow)??!1}async function Pi(){v(Di,!0);try{const[$,A,G,ie]=await Promise.all([sA(),nA(),oA(),rA()]);v($i,{roles:$.roles,users:A.users,groups:G.groups,defaults:ie.acls},!0)}catch{v($i,null),v(Ai,!1)}finally{v(Di,!1)}}async function Li(){c(Ai)?(v(Ai,!1),v(Gi,null)):(v(Ai,!0),v(Gi,null),c($i)||await Pi())}Bs(Mt),Bs(async()=>{var $;try{const A=await Tk();v(Ki,!!(($=A.dynsec)!=null&&$.dynsecReady),!0)}catch{v(Ki,!1)}}),x_(()=>{et(),r!==null&&cancelAnimationFrame(r)});var Si=YX(),Oi=b(Si),qi=m(b(Oi),2);{var mi=$=>{var A=PX(),G=xt(A);let ie;var fe=m(b(G),2);{var Y=_e=>{var ge=po("…");I(_e,ge)};O(fe,_e=>{c(Di)&&_e(Y)})}var le=m(G,2);{var Re=_e=>{var ge=TX();H(()=>ge.disabled=c(Di)),z("click",ge,Pi),I(_e,ge)};O(le,_e=>{c(Ai)&&_e(Re)})}H(()=>{ie=kt(G,1,"acl-btn svelte-1vejtrc",null,ie,{active:c(Ai)}),G.disabled=c(Di)}),z("click",G,Li),I($,A)};O(qi,$=>{c(Ki)&&$(mi)})}var Ue=m(Oi,2),J=b(Ue),Qe=b(J),_t=m(Qe,2);ni(_t,20,()=>c(ri),$=>$,($,A)=>{var G=MX(),ie={};H(()=>{ie!==(ie=A)&&(G.value=(G.__value=A)??"")}),I($,G)});var yt=m(_t,2),Ot=m(yt,2),j=b(Ot),ce=m(Ot,2),ke=b(ce);ke.value=ke.__value=0;var ze=m(ke);ze.value=ze.__value=1;var st=m(ze);st.value=st.__value=2;var X=m(ce,2),ae=m(X,2);{var me=$=>{var A=RX();I($,A)};O(ae,$=>{c(Xe)&&$(me)})}var Ze=m(ae,2);{var Zt=$=>{var A=NX(),G=b(A);H(()=>N(G,c(he))),I($,A)};O(Ze,$=>{c(he)&&$(Zt)})}var bt=m(J,2),We=b(bt),At=m(We,2),ai=b(At);{var zt=$=>{var A=po();H(()=>N(A,`${c(M).length??""} /`)),I($,A)};O(ai,$=>{c(w)&&$(zt)})}var vi=m(ai),hi=m(bt,2);{var Ci=$=>{var A=AX();I($,A)},zi=$=>{var A=OX(),G=b(A);H(()=>N(G,c(Oe))),I($,A)},$e=$=>{var A=As(),G=xt(A);{var ie=Y=>{var le=FX();I(Y,le)},fe=Y=>{var le=WX(),Re=b(le),_e=b(Re);ni(_e,21,()=>c(M).slice(c(F).start,c(F).end),ge=>ge.topic,(ge,tt)=>{var U=HX(),ne=b(U),Le=b(ne),Ve=m(ne,2),De=b(Ve),Ie=m(Ve,2),St=b(Ie);H((mt,qe,Tt)=>{N(Le,c(tt).topic),ln(Ve,"title",mt),N(De,qe),N(St,Tt)},[()=>wi(c(tt).val),()=>wi(c(tt).val),()=>Ri(c(tt).ts)]),I(ge,U)}),H(()=>{zo(Re,`height: ${c(F).totalH??""}px; position: relative;`),zo(_e,`top: ${c(F).top??""}px;`)}),ds("scroll",le,ge=>{v(k,ge.currentTarget.scrollTop,!0)}),rW(le,"clientHeight",ge=>v(D,ge)),I(Y,le)};O(G,Y=>{c(M).length===0?Y(ie):Y(fe,-1)})}I($,A)},Fe=$=>{var A=zX(),G=b(A);{var ie=Y=>{var le=BX();I(Y,le)},fe=Y=>{var le=As(),Re=xt(le);ni(Re,17,()=>c(Xt),_e=>_e.path,(_e,ge)=>{t(_e,()=>c(ge))}),I(Y,le)};O(G,Y=>{c(Xt).length===0?Y(ie):Y(fe,-1)})}I($,A)};O(hi,$=>{c(Pt)?$(Ci):c(Oe)?$(zi,1):c(w)?$($e,2):$(Fe,-1)})}var Ft=m(Ue,2),Yt=b(Ft),qt=m(Yt,2),Qt=b(qt),re=m(Qt,2);{var Ge=$=>{var A=VX(),G=b(A);H(()=>N(G,c(Ke).length)),I($,A)};O(re,$=>{!c(ue)&&c(Ke).length>0&&$(Ge)})}var wt=m(re,2),vt=b(wt),di=m(qt,2);{var It=$=>{var A=qX(),G=b(A);{var ie=Y=>{var le=jX();I(Y,le)},fe=Y=>{var le=As(),Re=xt(le);ni(Re,17,()=>c(ot),_e=>_e.id,(_e,ge)=>{var tt=UX();let U;var ne=b(tt),Le=b(ne),Ve=m(ne,2);{var De=Tt=>{var it=$X();I(Tt,it)};O(Ve,Tt=>{c(ge).retained&&Tt(De)})}var Ie=m(Ve,2),St=b(Ie),mt=m(Ie,2),qe=b(mt);H((Tt,it,ye)=>{U=kt(tt,1,"sr svelte-1vejtrc",null,U,{retained:c(ge).retained}),N(Le,Tt),N(St,c(ge).topic),ln(mt,"title",it),N(qe,ye)},[()=>ci(c(ge).ts),()=>wi(c(ge).val),()=>wi(c(ge).val)]),I(_e,tt)}),I(Y,le)};O(G,Y=>{c(ot).length===0?Y(ie):Y(fe,-1)})}I($,A)};O(di,$=>{c(ue)&&$(It)})}var Ii=m(Ft,2);{var W=$=>{var A=GX(),G=xt(A),ie=m(G,2);let fe;var Y=b(ie),le=m(Y,2);H(()=>fe=zo(ie,"",fe,{left:`${c(ct).x??""}px`,top:`${c(ct).y??""}px`})),z("click",G,()=>v(ct,null)),z("contextmenu",G,Re=>{Re.preventDefault(),v(ct,null)}),z("click",Y,()=>{navigator.clipboard.writeText(c(ct).topic),v(ct,null)}),z("click",le,()=>{const Re=c(ct).topic,_e=Re+"/",ge=[...i.keys()].some(tt=>tt.startsWith(_e));v(Nt,{topic:Re,hasChildren:ge,recursive:!1},!0),v(ct,null)}),I($,A)};O(Ii,$=>{c(ct)&&$(W)})}var Q=m(Ii,2);{var oe=$=>{var A=ZX(),G=xt(A),ie=m(G,2),fe=m(b(ie),2),Y=b(fe),le=m(b(Y)),Re=b(le),_e=m(Y,2);{var ge=Le=>{var Ve=KX(),De=b(Ve);ms(De,()=>c(Nt).recursive,Ie=>c(Nt).recursive=Ie),I(Le,Ve)};O(_e,Le=>{c(Nt).hasChildren&&Le(ge)})}var tt=m(fe,2),U=b(tt),ne=m(U,2);H(()=>N(Re,c(Nt).topic)),z("click",G,()=>v(Nt,null)),z("click",U,()=>v(Nt,null)),z("click",ne,()=>{const{topic:Le,recursive:Ve}=c(Nt);v(Nt,null),ti(Le,Ve)}),I($,A)};O(Q,$=>{c(Nt)&&$(oe)})}H(()=>{X.disabled=c(ht)||!c(Vt),N(vi,` ${c(pt)??""}`),zo(Ft,c(ue)?`height: ${c(dt)}px;`:""),N(vt,c(ue)?"▾":"▸")}),Ht(Qe,()=>c(Vt),$=>v(Vt,$)),Ht(yt,()=>c(Me),$=>v(Me,$)),ms(j,()=>c(jt),$=>v(jt,$)),ys(ce,()=>c(ft),$=>v(ft,$)),z("click",X,Ut),Ht(We,()=>c(w),$=>v(w,$)),z("mousedown",Yt,gt),Ht(Qt,()=>c(He),$=>v(He,$)),z("click",wt,()=>{v(ue,!c(ue))}),I(o,Si),Ps()}zs(["click","contextmenu","mousedown"]);var QX=T('<div class="restart-banner restart-banner--restarting svelte-twakcj">Restarting daemon…</div>'),JX=T('<div class="restart-banner svelte-twakcj">⚠ Package changes require a daemon restart to take effect. <button class="restart-btn svelte-twakcj">Restart now</button></div>'),eQ=T('<div class="err svelte-twakcj"> </div>'),tQ=T('<span class="pane-count pane-count--warn svelte-twakcj"> </span>'),iQ=T('<p class="empty svelte-twakcj">No packages installed.</p>'),nQ=T('<p class="empty svelte-twakcj">No match.</p>'),sQ=T("<span> </span>"),oQ=tM('<svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><circle cx="8" cy="8" r="6" stroke-dasharray="18" stroke-dashoffset="4"></circle></svg>'),rQ=tM('<svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M13 8A5 5 0 1 1 10.5 3.67"></path><polyline points="10.5,1.5 10.5,4 13,4"></polyline></svg>'),aQ=T('<div><div class="dep-info svelte-twakcj"><a class="dep-name svelte-twakcj" target="_blank" rel="noopener noreferrer"> </a> <span class="dep-ver svelte-twakcj"> </span> <!></div> <div class="dep-btns svelte-twakcj"><button><svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4"></path><line x1="9" y1="15" x2="4.5" y2="19.5"></line><line x1="14.5" y1="4" x2="20" y2="9.5"></line></svg></button> <button><!></button> <button class="icon-btn icon-btn--danger svelte-twakcj" title="Uninstall"><svg width="11" height="11" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="2" y1="2" x2="14" y2="14"></line><line x1="14" y1="2" x2="2" y2="14"></line></svg></button></div></div>'),lQ=T('<span class="result-author svelte-twakcj"> </span>'),cQ=T('<span class="result-date svelte-twakcj"> </span>'),dQ=T('<span class="result-desc svelte-twakcj"> </span>'),uQ=T('<div class="result-row svelte-twakcj"><div class="result-info svelte-twakcj"><a class="result-name svelte-twakcj" target="_blank" rel="noopener noreferrer"> </a> <span class="result-ver svelte-twakcj"> </span> <!> <!> <!></div> <button class="install-btn svelte-twakcj"> </button></div>'),hQ=T('<div class="results-list svelte-twakcj"></div>'),fQ=T('<pre class="npm-output svelte-twakcj"> </pre>'),gQ=T(`<p class="hint svelte-twakcj">Install npm packages into <code class="svelte-twakcj">~/.she/</code>. Scripts can then <code class="svelte-twakcj">require('package-name')</code> directly.</p>`),pQ=T('<!> <div class="pkg-shell svelte-twakcj"><!> <!> <div class="pkg-body svelte-twakcj"><div class="pkg-left svelte-twakcj"><div class="pane-hdr svelte-twakcj"><span class="pane-title svelte-twakcj">Installed</span> <span class="pane-count svelte-twakcj"> </span> <!> <button class="icon-btn check-outdated-btn svelte-twakcj" title="Check for package updates"><svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M13 8A5 5 0 1 1 10.5 3.67"></path><polyline points="10.5,1.5 10.5,4 13,4"></polyline></svg></button></div> <div class="filter-row svelte-twakcj"><input class="filter-in svelte-twakcj" type="search" placeholder="Filter…"/></div> <div class="installed-list svelte-twakcj"><!></div></div> <div class="pkg-right svelte-twakcj"><div class="pane-hdr svelte-twakcj"><span class="pane-title svelte-twakcj">Search npm</span></div> <div class="search-row svelte-twakcj"><input class="search-in svelte-twakcj" type="text" placeholder="Package name, e.g. axios, lodash…"/> <button class="search-btn svelte-twakcj"> </button></div> <!> <!> <!></div></div></div>',1);function _Q(o,e){Ts(e,!0);let t=P(yi([])),i=P(""),n=P(yi({})),s=P(yi([])),r=P(!1),a=P(""),d=P(yi([])),u=P(!1),f=P(!1),g=P(!1),p=P(""),w=P(""),y=yi({});const x=Ct(()=>c(i).trim()?c(t).filter(rt=>rt.name.toLowerCase().includes(c(i).toLowerCase())):c(t)),k=Ct(()=>Object.keys(c(n)).filter(rt=>!c(s).includes(rt)).length);Bs(async()=>{await Promise.all([D(),M(),F()])});async function D(){try{v(t,await jU(),!0),v(p,"")}catch(rt){v(p,rt.message,!0)}}async function M(){try{v(n,await KN(),!0)}catch{}}async function F(){try{const rt=await Pl();v(s,Array.isArray(rt.pinnedPackages)?rt.pinnedPackages:[],!0)}catch{}}async function K(rt){const Kt=c(s).includes(rt)?c(s).filter(_i=>_i!==rt):[...c(s),rt];v(s,Kt,!0);try{const _i=await Pl();await Xp({..._i,pinnedPackages:Kt})}catch{}}async function V(){v(r,!0);try{v(n,await KU(),!0)}catch{}finally{v(r,!1)}}async function se(){const rt=c(a).trim();if(!rt){v(d,[],!0);return}v(g,!0),v(p,"");try{v(d,await $U(rt),!0)}catch(Kt){v(p,Kt.message,!0)}finally{v(g,!1)}}function te(rt){if(!rt)return"";try{return new Date(rt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}async function pe(rt,Kt){y[rt]=!0,v(p,""),v(w,"");try{const _i=await UU(rt,Kt);v(w,_i.stdout||_i.stderr||"Done.",!0),v(u,!0),await D()}catch(_i){v(p,_i.message,!0)}finally{y[rt]=!1}}async function je(rt){y[rt]=!0,v(p,""),v(w,"");try{const Kt=await qU(rt);v(w,Kt.stdout||Kt.stderr||"Done.",!0),v(u,!0);const _i={...c(n)};delete _i[rt],v(n,_i,!0),await D()}catch(Kt){v(p,Kt.message,!0)}finally{y[rt]=!1}}async function Ke(rt){y[rt]=!0,v(p,""),v(w,"");try{const Kt=await GU(rt);v(w,Kt.stdout||Kt.stderr||"Done.",!0),v(u,!0);const _i={...c(n)};delete _i[rt],v(n,_i,!0),await D()}catch(Kt){v(p,Kt.message,!0)}finally{y[rt]=!1}}let ue;async function He(){if(await ue.show("Restart the she daemon? The page will reload after a moment.",{confirm:"Restart"})){v(f,!0);try{await UN()}catch{}setTimeout(()=>{window.location.reload()},3e3)}}var dt=pQ(),we=xt(dt);vs(Uc(we,{}),rt=>ue=rt,()=>ue);var gt=m(we,2),ot=b(gt);{var Pt=rt=>{var Kt=QX();I(rt,Kt)},Oe=rt=>{var Kt=JX(),_i=m(b(Kt));z("click",_i,He),I(rt,Kt)};O(ot,rt=>{c(f)?rt(Pt):c(u)&&rt(Oe,1)})}var Mt=m(ot,2);{var et=rt=>{var Kt=eQ(),_i=b(Kt);H(()=>N(_i,c(p))),I(rt,Kt)};O(Mt,rt=>{c(p)&&rt(et)})}var ct=m(Mt,2),Nt=b(ct),ti=b(Nt),ri=m(b(ti),2),Vt=b(ri),Me=m(ri,2);{var jt=rt=>{var Kt=tQ(),_i=b(Kt);H(()=>N(_i,`${c(k)??""} outdated`)),I(rt,Kt)};O(Me,rt=>{c(k)>0&&rt(jt)})}var ft=m(Me,2),ht=b(ft);let he;var Xe=m(ti,2),Ut=b(Xe),wi=m(Xe,2),Ri=b(wi);{var ci=rt=>{var Kt=iQ();I(rt,Kt)},Bt=rt=>{var Kt=nQ();I(rt,Kt)},Xt=rt=>{var Kt=As(),_i=xt(Kt);ni(_i,17,()=>c(x),Pi=>Pi.name,(Pi,Li)=>{var Si=aQ();let Oi;var qi=b(Si),mi=b(qi),Ue=b(mi),J=m(mi,2),Qe=b(J),_t=m(J,2);{var yt=Ze=>{var Zt=sQ();let bt;var We=b(Zt);H(At=>{bt=kt(Zt,1,"dep-latest svelte-twakcj",null,bt,At),N(We,`→ v${c(n)[c(Li).name].latest??""}`)},[()=>({"dep-latest--pinned":c(s).includes(c(Li).name)})]),I(Ze,Zt)};O(_t,Ze=>{c(n)[c(Li).name]&&Ze(yt)})}var Ot=m(qi,2),j=b(Ot);let ce;var ke=m(j,2);let ze;var st=b(ke);{var X=Ze=>{var Zt=oQ();I(Ze,Zt)},ae=Ze=>{var Zt=rQ();I(Ze,Zt)};O(st,Ze=>{y[c(Li).name]?Ze(X):Ze(ae,-1)})}var me=m(ke,2);H((Ze,Zt,bt)=>{Oi=kt(Si,1,"dep-row svelte-twakcj",null,Oi,{"dep-busy":!!y[c(Li).name]}),ln(mi,"href",c(Li).url??`https://www.npmjs.com/package/${c(Li).name}`),N(Ue,c(Li).name),N(Qe,c(Li).installedVersion??c(Li).version),ce=kt(j,1,"icon-btn svelte-twakcj",null,ce,Ze),ln(j,"title",Zt),ze=kt(ke,1,"icon-btn svelte-twakcj",null,ze,bt),ke.disabled=!!y[c(Li).name],ln(ke,"title",c(n)[c(Li).name]?`Update to v${c(n)[c(Li).name].latest}`:"Update to latest"),me.disabled=!!y[c(Li).name]},[()=>({"icon-btn--pinned":c(s).includes(c(Li).name)}),()=>c(s).includes(c(Li).name)?"Unpin package":"Pin package (suppress update dot)",()=>({"icon-btn--update":!!c(n)[c(Li).name]&&!c(s).includes(c(Li).name)})]),z("click",j,()=>K(c(Li).name)),z("click",ke,()=>Ke(c(Li).name)),z("click",me,()=>je(c(Li).name)),I(Pi,Si)}),I(rt,Kt)};O(Ri,rt=>{c(t).length===0?rt(ci):c(x).length===0?rt(Bt,1):rt(Xt,-1)})}var pt=m(Nt,2),Bi=m(b(pt),2),Ti=b(Bi),Ni=m(Ti,2),Ki=b(Ni),Ai=m(Bi,2);{var Di=rt=>{var Kt=hQ();ni(Kt,21,()=>c(d),_i=>_i.name,(_i,Pi)=>{var Li=uQ(),Si=b(Li),Oi=b(Si),qi=b(Oi),mi=m(Oi,2),Ue=b(mi),J=m(mi,2);{var Qe=ze=>{var st=lQ(),X=b(st);H(()=>N(X,c(Pi).author)),I(ze,st)};O(J,ze=>{c(Pi).author&&ze(Qe)})}var _t=m(J,2);{var yt=ze=>{var st=cQ(),X=b(st);H(ae=>{ln(st,"title",c(Pi).date),N(X,ae)},[()=>te(c(Pi).date)]),I(ze,st)};O(_t,ze=>{c(Pi).date&&ze(yt)})}var Ot=m(_t,2);{var j=ze=>{var st=dQ(),X=b(st);H(()=>N(X,c(Pi).description)),I(ze,st)};O(Ot,ze=>{c(Pi).description&&ze(j)})}var ce=m(Si,2),ke=b(ce);H(()=>{ln(Oi,"href",c(Pi).url??`https://www.npmjs.com/package/${c(Pi).name}`),N(qi,c(Pi).name),N(Ue,c(Pi).version),ce.disabled=!!y[c(Pi).name],N(ke,y[c(Pi).name]?"Installing…":"Install")}),z("click",ce,()=>pe(c(Pi).name)),I(_i,Li)}),I(rt,Kt)};O(Ai,rt=>{c(d).length>0&&rt(Di)})}var $i=m(Ai,2);{var Gi=rt=>{var Kt=fQ(),_i=b(Kt);H(()=>N(_i,c(w))),I(rt,Kt)};O($i,rt=>{c(w)&&rt(Gi)})}var Ui=m($i,2);{var mn=rt=>{var Kt=gQ();I(rt,Kt)};O(Ui,rt=>{!c(d).length&&!c(w)&&rt(mn)})}H(()=>{N(Vt,c(t).length),ft.disabled=c(r),he=kt(ht,0,"svelte-twakcj",null,he,{spinning:c(r)}),Ni.disabled=c(g),N(Ki,c(g)?"Searching…":"Search")}),z("click",ft,V),Ht(Ut,()=>c(i),rt=>v(i,rt)),z("keydown",Ti,rt=>rt.key==="Enter"&&se()),Ht(Ti,()=>c(a),rt=>v(a,rt)),z("click",Ni,se),I(o,dt),Ps()}zs(["click","keydown"]);var mQ=T('<div class="plugin-warning svelte-3itf14">⚠ The dynamic-security plugin is not responding. Add <code class="svelte-3itf14">plugin …/mosquitto_dynamic_security.so</code> and <code class="svelte-3itf14">plugin_opt_config_file …/dynamic-security.json</code> to your mosquitto.conf and restart mosquitto. Operations below will time out until the plugin is active.</div>'),ya=T('<div class="err svelte-3itf14"> </div>'),vQ=T('<div class="empty svelte-3itf14">No users found.</div>'),bQ=T('<span class="tag svelte-3itf14"> <button class="tag-x svelte-3itf14" title="Remove role">×</button></span>'),_h=T("<option> </option>"),Lm=T('<div class="inline-err svelte-3itf14"> </div>'),kD=T('<div class="inline-add svelte-3itf14"><select class="svelte-3itf14"><option>— role —</option><!></select> <button class="inline-confirm svelte-3itf14">Add</button> <button class="inline-cancel svelte-3itf14">×</button></div> <!>',1),yQ=T('<span class="tag tag--group svelte-3itf14"> <button class="tag-x svelte-3itf14" title="Remove from group">×</button></span>'),wQ=T('<div class="inline-add svelte-3itf14"><select class="svelte-3itf14"><option>— group —</option><!></select> <button class="inline-confirm svelte-3itf14">Add</button> <button class="inline-cancel svelte-3itf14">×</button></div> <!>',1),SQ=T('<tr class="svelte-3itf14"><td class="mono svelte-3itf14"> </td><td class="svelte-3itf14"><div class="tags-cell svelte-3itf14"><div class="tags svelte-3itf14"><!> <button class="tag-plus svelte-3itf14" title="Add role">+</button></div> <!></div></td><td class="svelte-3itf14"><div class="tags-cell svelte-3itf14"><div class="tags svelte-3itf14"><!> <button class="tag-plus tag-plus--group svelte-3itf14" title="Add to group">+</button></div> <!></div></td><td class="cell-actions svelte-3itf14"><div class="actions svelte-3itf14"><button title="Set password" class="svelte-3itf14">🔑</button> <button class="danger svelte-3itf14" title="Delete">✕</button></div></td></tr>'),CQ=T('<table class="svelte-3itf14"><thead><tr><th class="svelte-3itf14">Username</th><th class="svelte-3itf14">Roles</th><th class="svelte-3itf14">Groups</th><th class="svelte-3itf14"></th></tr></thead><tbody></tbody></table>'),xQ=T('<div class="panel svelte-3itf14"><div class="panel-header svelte-3itf14"><h3 class="svelte-3itf14">Users</h3> <button class="btn-add svelte-3itf14">+ Add user</button></div> <!> <!></div>'),kQ=T('<div class="empty svelte-3itf14">No roles found.</div>'),LQ=T('<tr class="svelte-3itf14"><td class="mono svelte-3itf14"> </td><td class="svelte-3itf14"> </td><td class="cell-actions svelte-3itf14"><div class="actions svelte-3itf14"><button title="Edit ACLs" class="svelte-3itf14">Edit ACLs</button> <button class="danger svelte-3itf14" title="Delete">✕</button></div></td></tr>'),IQ=T('<table class="svelte-3itf14"><thead><tr><th class="svelte-3itf14">Role</th><th class="svelte-3itf14">ACLs</th><th class="svelte-3itf14"></th></tr></thead><tbody></tbody></table>'),EQ=T('<div class="panel svelte-3itf14"><div class="panel-header svelte-3itf14"><h3 class="svelte-3itf14">Roles</h3> <button class="btn-add svelte-3itf14">+ Add role</button></div> <!> <!></div>'),DQ=T('<div class="empty svelte-3itf14">No groups found.</div>'),TQ=T('<span class="tag svelte-3itf14"> <button class="tag-x svelte-3itf14" title="Remove member">×</button></span>'),PQ=T('<div class="inline-add svelte-3itf14"><select class="svelte-3itf14"><option>— user —</option><!></select> <button class="inline-confirm svelte-3itf14">Add</button> <button class="inline-cancel svelte-3itf14">×</button></div> <!>',1),MQ=T('<span class="tag tag--group svelte-3itf14"> <button class="tag-x svelte-3itf14" title="Remove role">×</button></span>'),RQ=T('<tr class="svelte-3itf14"><td class="mono svelte-3itf14"> </td><td class="svelte-3itf14"><div class="tags-cell svelte-3itf14"><div class="tags svelte-3itf14"><!> <button class="tag-plus svelte-3itf14" title="Add member">+</button></div> <!></div></td><td class="svelte-3itf14"><div class="tags-cell svelte-3itf14"><div class="tags svelte-3itf14"><!> <button class="tag-plus tag-plus--group svelte-3itf14" title="Add role">+</button></div> <!></div></td><td class="cell-actions svelte-3itf14"><div class="actions svelte-3itf14"><button class="danger svelte-3itf14" title="Delete">✕</button></div></td></tr>'),NQ=T('<table class="svelte-3itf14"><thead><tr><th class="svelte-3itf14">Group</th><th class="svelte-3itf14">Members</th><th class="svelte-3itf14">Roles</th><th class="svelte-3itf14"></th></tr></thead><tbody></tbody></table>'),AQ=T('<div class="panel svelte-3itf14"><div class="panel-header svelte-3itf14"><h3 class="svelte-3itf14">Groups</h3> <button class="btn-add svelte-3itf14">+ Add group</button></div> <!> <!></div>'),LD=T('<div class="empty svelte-3itf14">Loading…</div>'),OQ=T('<tr><td class="mono small svelte-3itf14"> </td><td class="acl-radio svelte-3itf14"><input type="radio" value="allow"/></td><td class="acl-radio svelte-3itf14"><input type="radio" value="deny"/></td></tr>'),FQ=T('<table class="acl-defaults-table svelte-3itf14"><thead><tr><th class="svelte-3itf14">Operation</th><th class="svelte-3itf14">Allow</th><th class="svelte-3itf14">Deny</th></tr></thead><tbody></tbody></table>'),HQ=T('<div class="anon-current svelte-3itf14">Current: <span class="mono svelte-3itf14"> </span></div>'),WQ=T('<div class="anon-current muted svelte-3itf14">No anonymous group configured.</div>'),BQ=T('<div class="anon-row svelte-3itf14"><select class="svelte-3itf14"><option>— none —</option><!></select> <button class="svelte-3itf14"> </button></div> <!>',1),zQ=T('<div class="panel svelte-3itf14"><div class="settings-section svelte-3itf14"><h3 class="settings-heading svelte-3itf14">Default ACL Access</h3> <p class="settings-hint svelte-3itf14">Broker-wide defaults applied when no role ACL matches. Role ACLs always take precedence over these defaults.</p> <!> <!></div> <div class="settings-section svelte-3itf14"><h3 class="settings-heading svelte-3itf14">Anonymous Group</h3> <p class="settings-hint svelte-3itf14">Clients connecting without credentials are treated as members of this group. Requires <code class="svelte-3itf14">allow_anonymous true</code> in mosquitto.conf.</p> <!> <!></div></div>'),VQ=T('<div class="modal-backdrop svelte-3itf14" role="dialog" aria-modal="true"><div class="modal svelte-3itf14"><h3 class="svelte-3itf14">Add user</h3> <label class="svelte-3itf14">Username<input autocomplete="off" class="svelte-3itf14"/></label> <label class="svelte-3itf14">Password <div class="pw-row svelte-3itf14"><input autocomplete="new-password" class="svelte-3itf14"/> <button class="toggle-pw svelte-3itf14"> </button></div></label> <!> <div class="modal-actions svelte-3itf14"><button class="svelte-3itf14">Cancel</button> <button class="btn-primary svelte-3itf14"> </button></div></div></div>'),jQ=T('<div class="modal-backdrop svelte-3itf14" role="dialog" aria-modal="true"><div class="modal svelte-3itf14"><h3 class="svelte-3itf14">Set password for <em class="svelte-3itf14"> </em></h3> <label class="svelte-3itf14">New password <input type="password" autocomplete="new-password" class="svelte-3itf14"/></label> <!> <div class="modal-actions svelte-3itf14"><button class="svelte-3itf14">Cancel</button> <button class="btn-primary svelte-3itf14"> </button></div></div></div>'),$Q=T('<div class="modal-backdrop svelte-3itf14" role="dialog" aria-modal="true"><div class="modal svelte-3itf14"><h3 class="svelte-3itf14">Add role</h3> <label class="svelte-3itf14">Role name<input autocomplete="off" class="svelte-3itf14"/></label> <!> <div class="modal-actions svelte-3itf14"><button class="svelte-3itf14">Cancel</button> <button class="btn-primary svelte-3itf14"> </button></div></div></div>'),UQ=T('<tr class="svelte-3itf14"><td class="mono small svelte-3itf14"> </td><td class="mono svelte-3itf14"> </td><td class="svelte-3itf14"> </td><td class="svelte-3itf14"><button class="danger">✕</button></td></tr>'),qQ=T('<table class="acl-table svelte-3itf14"><thead><tr><th class="svelte-3itf14">Type</th><th class="svelte-3itf14">Topic</th><th class="svelte-3itf14">Allow</th><th class="svelte-3itf14"></th></tr></thead><tbody></tbody></table>'),GQ=T('<div class="empty svelte-3itf14">No ACL rules yet.</div>'),KQ=T('<div class="modal-backdrop svelte-3itf14" role="dialog" aria-modal="true"><div class="modal modal--wide svelte-3itf14"><h3 class="svelte-3itf14">ACLs for role <em class="svelte-3itf14"> </em></h3> <!> <div class="acl-add-row svelte-3itf14"><select class="svelte-3itf14"></select> <input placeholder="topic or pattern" class="svelte-3itf14"/> <label class="allow-toggle svelte-3itf14"><input type="checkbox" class="svelte-3itf14"/> Allow</label> <button class="svelte-3itf14">Add</button></div> <!> <div class="modal-actions svelte-3itf14"><button class="svelte-3itf14">Close</button></div></div></div>'),ZQ=T('<div class="modal-backdrop svelte-3itf14" role="dialog" aria-modal="true"><div class="modal svelte-3itf14"><h3 class="svelte-3itf14">Add group</h3> <label class="svelte-3itf14">Group name<input autocomplete="off" class="svelte-3itf14"/></label> <!> <div class="modal-actions svelte-3itf14"><button class="svelte-3itf14">Cancel</button> <button class="btn-primary svelte-3itf14"> </button></div></div></div>'),YQ=T('<div class="users-page svelte-3itf14"><!> <div class="panel-tabs svelte-3itf14"><button>Users</button> <button>Roles</button> <button>Groups</button> <button>Settings</button> <button class="reload-btn svelte-3itf14" title="Refresh">↺</button></div> <!> <!> <!> <!></div> <!> <!> <!> <!> <!> <!>',1);function XQ(o,e){Ts(e,!0);let t=Su(e,"dynsecReady",3,!1),i,n=P(yi([])),s=P(yi([])),r=P(yi([])),a=P(""),d=P(""),u=P(""),f=P("users"),g=P(null),p=P(""),w=P(""),y=P(!1);const x=Ct(()=>c(g)?c(g).kind==="user-roles"?c(s).map(re=>re.rolename).filter(re=>{var Ge,wt;return!((wt=(Ge=c(n).find(vt=>vt.username===c(g).target))==null?void 0:Ge.roles)!=null&&wt.some(vt=>vt.rolename===re))}):c(g).kind==="user-groups"?c(r).map(re=>re.groupname).filter(re=>{var Ge,wt;return!((wt=(Ge=c(n).find(vt=>vt.username===c(g).target))==null?void 0:Ge.groups)!=null&&wt.some(vt=>vt.groupname===re))}):c(g).kind==="group-members"?c(n).map(re=>re.username).filter(re=>{var Ge,wt;return!((wt=(Ge=c(r).find(vt=>vt.groupname===c(g).target))==null?void 0:Ge.clients)!=null&&wt.some(vt=>vt.username===re))}):c(s).map(re=>re.rolename).filter(re=>{var Ge,wt;return!((wt=(Ge=c(r).find(vt=>vt.groupname===c(g).target))==null?void 0:Ge.roles)!=null&&wt.some(vt=>vt.rolename===re))}):[]);function k(re,Ge){v(g,{kind:re,target:Ge},!0),v(p,""),v(w,"")}async function D(){if(!(!c(g)||!c(p))){v(y,!0),v(w,"");try{const{kind:re,target:Ge}=c(g);re==="user-roles"?await dq(Ge,c(p)):re==="user-groups"?await qE(c(p),Ge):re==="group-members"?await qE(Ge,c(p)):await vq(Ge,c(p)),v(g,null),v(p,""),await Di()}catch(re){v(w,re.message,!0)}finally{v(y,!1)}}}async function M(re,Ge){try{await uq(re,Ge),await Di()}catch(wt){v(a,wt.message,!0)}}async function F(re,Ge){try{await GE(Ge,re),await Di()}catch(wt){v(a,wt.message,!0)}}async function K(re,Ge){try{await GE(re,Ge),await Di()}catch(wt){v(u,wt.message,!0)}}async function V(re,Ge){try{await bq(re,Ge),await Di()}catch(wt){v(u,wt.message,!0)}}let se=P(!1),te=P(""),pe=P(""),je=P(!1),Ke=P(""),ue=P(!1),He=P(!1),dt=P(""),we=P(""),gt=P(""),ot=P(!1),Pt=P(!1),Oe=P(""),Mt=P(""),et=P(!1),ct=P(null),Nt=P(!1),ti=P("publishClientSend"),ri=P(""),Vt=P(!0),Me=P(""),jt=P(!1),ft=P(""),ht=P(""),he=P(!1),Xe=P(yi([])),Ut=P(""),wi=P(!1),Ri=P(null),ci=P(""),Bt=P(""),Xt=P(!1),pt=P(!1);const Bi=[{acltype:"publishClientSend",label:"Publish (send)"},{acltype:"publishClientReceive",label:"Publish (receive)"},{acltype:"subscribe",label:"Subscribe"},{acltype:"unsubscribe",label:"Unsubscribe"}];async function Ti(){var re,Ge;v(pt,!1),v(Ut,""),v(Bt,"");try{const[wt,vt]=await Promise.allSettled([rA(),wq()]);if(wt.status==="fulfilled"){const di=Object.fromEntries(wt.value.acls.map(It=>[It.acltype,It.allow]));v(Xe,Bi.map(({acltype:It})=>({acltype:It,allow:di[It]??(It==="publishClientReceive"||It==="unsubscribe")})),!0)}else v(Ut,((re=wt.reason)==null?void 0:re.message)??"Failed to load default ACLs",!0);vt.status==="fulfilled"?(v(Ri,vt.value.group,!0),v(ci,vt.value.group??"",!0)):v(Bt,((Ge=vt.reason)==null?void 0:Ge.message)??"Failed to load anonymous group",!0)}finally{v(pt,!0)}}async function Ni(re,Ge){v(Xe,c(Xe).map(wt=>wt.acltype===re?{...wt,allow:Ge}:wt),!0),v(wi,!0),v(Ut,"");try{await yq(c(Xe))}catch(wt){v(Ut,wt.message,!0)}finally{v(wi,!1)}}async function Ki(){v(Xt,!0),v(Bt,"");try{await Sq(c(ci)||null),v(Ri,c(ci)||null,!0)}catch(re){v(Bt,re.message,!0)}finally{v(Xt,!1)}}const Ai=["publishClientSend","publishClientReceive","subscribeLiteral","subscribePattern","unsubscribeLiteral","unsubscribePattern"];async function Di(){var re,Ge,wt;try{const[vt,di,It]=await Promise.allSettled([nA(),sA(),oA()]);vt.status==="fulfilled"?(v(n,vt.value.users,!0),v(a,"")):v(a,((re=vt.reason)==null?void 0:re.message)??"Failed to load users",!0),di.status==="fulfilled"?(v(s,di.value.roles,!0),v(d,"")):v(d,((Ge=di.reason)==null?void 0:Ge.message)??"Failed to load roles",!0),It.status==="fulfilled"?(v(r,It.value.groups,!0),v(u,"")):v(u,((wt=It.reason)==null?void 0:wt.message)??"Failed to load groups",!0)}catch{}}Bs(()=>{Di()});async function $i(){v(Ke,""),v(ue,!0);try{await aq(c(te),c(pe)),v(te,""),v(pe,""),v(se,!1),await Di()}catch(re){v(Ke,re.message??"Failed to create user",!0)}finally{v(ue,!1)}}async function Gi(re){if(await i.show(`Delete user “${re}”?`,{confirm:"Delete",danger:!0}))try{await lq(re),await Di()}catch(Ge){v(a,Ge.message,!0)}}async function Ui(re){v(dt,re,!0),v(we,""),v(gt,""),v(He,!0)}async function mn(){v(gt,""),v(ot,!0);try{await cq(c(dt),c(we)),v(He,!1)}catch(re){v(gt,re.message,!0)}finally{v(ot,!1)}}async function rt(){v(Mt,""),v(et,!0);try{await hq(c(Oe)),v(Oe,""),v(Pt,!1),await Di()}catch(re){v(Mt,re.message??"Failed to create role",!0)}finally{v(et,!1)}}async function Kt(re){var Ge;if(await i.show(`Delete role “${re}”?`,{confirm:"Delete",danger:!0}))try{await fq(re),((Ge=c(ct))==null?void 0:Ge.rolename)===re&&(v(ct,null),v(Nt,!1)),await Di()}catch(wt){v(d,wt.message,!0)}}function _i(re){v(ct,re,!0),v(Nt,!0),v(ti,"publishClientSend"),v(ri,""),v(Vt,!0),v(Me,"")}async function Pi(){if(c(ct)){v(Me,"");try{await gq(c(ct).rolename,{acltype:c(ti),topic:c(ri),allow:c(Vt)}),v(ri,""),await Di(),v(ct,c(s).find(re=>re.rolename===c(ct).rolename)??c(ct),!0)}catch(re){v(Me,re.message,!0)}}}async function Li(re,Ge,wt){try{await pq(re,Ge,wt),await Di(),v(ct,c(s).find(vt=>vt.rolename===re)??c(ct),!0)}catch(vt){v(Me,vt.message,!0)}}async function Si(){v(ht,""),v(he,!0);try{await _q(c(ft)),v(ft,""),v(jt,!1),await Di()}catch(re){v(ht,re.message??"Failed to create group",!0)}finally{v(he,!1)}}async function Oi(re){if(await i.show(`Delete group “${re}”?`,{confirm:"Delete",danger:!0}))try{await mq(re),await Di()}catch(Ge){v(u,Ge.message,!0)}}var qi=YQ(),mi=xt(qi),Ue=b(mi);{var J=re=>{var Ge=mQ();I(re,Ge)};O(Ue,re=>{t()||re(J)})}var Qe=m(Ue,2),_t=b(Qe);let yt;var Ot=m(_t,2);let j;var ce=m(Ot,2);let ke;var ze=m(ce,2);let st;var X=m(ze,2),ae=m(Qe,2);{var me=re=>{var Ge=xQ(),wt=b(Ge),vt=m(b(wt),2),di=m(wt,2);{var It=oe=>{var $=ya(),A=b($);H(()=>N(A,c(a))),I(oe,$)};O(di,oe=>{c(a)&&oe(It)})}var Ii=m(di,2);{var W=oe=>{var $=vQ();I(oe,$)},Q=oe=>{var $=CQ(),A=m(b($));ni(A,21,()=>c(n),Vi,(G,ie)=>{var fe=SQ(),Y=b(fe),le=b(Y),Re=m(Y),_e=b(Re),ge=b(_e),tt=b(ge);ni(tt,17,()=>c(ie).roles??[],Vi,(Se,nt)=>{var de=bQ(),Pe=b(de),at=m(Pe);H(()=>N(Pe,c(nt).rolename)),z("click",at,()=>M(c(ie).username,c(nt).rolename)),I(Se,de)});var U=m(tt,2),ne=m(ge,2);{var Le=Se=>{var nt=kD(),de=xt(nt),Pe=b(de),at=b(Pe);at.value=at.__value="";var ut=m(at);ni(ut,17,()=>c(x),Vi,(ii,xi)=>{var Ji=_h(),Hi=b(Ji),li={};H(()=>{N(Hi,c(xi)),li!==(li=c(xi))&&(Ji.value=(Ji.__value=c(xi))??"")}),I(ii,Ji)});var Je=m(Pe,2),$t=m(Je,2),Jt=m(de,2);{var Mi=ii=>{var xi=Lm(),Ji=b(xi);H(()=>N(Ji,c(w))),I(ii,xi)};O(Jt,ii=>{c(w)&&ii(Mi)})}H(()=>Je.disabled=!c(p)||c(y)),ys(Pe,()=>c(p),ii=>v(p,ii)),z("click",Je,D),z("click",$t,()=>v(g,null)),I(Se,nt)};O(ne,Se=>{var nt;((nt=c(g))==null?void 0:nt.kind)==="user-roles"&&c(g).target===c(ie).username&&Se(Le)})}var Ve=m(Re),De=b(Ve),Ie=b(De),St=b(Ie);ni(St,17,()=>c(ie).groups??[],Vi,(Se,nt)=>{var de=yQ(),Pe=b(de),at=m(Pe);H(()=>N(Pe,c(nt).groupname)),z("click",at,()=>F(c(ie).username,c(nt).groupname)),I(Se,de)});var mt=m(St,2),qe=m(Ie,2);{var Tt=Se=>{var nt=wQ(),de=xt(nt),Pe=b(de),at=b(Pe);at.value=at.__value="";var ut=m(at);ni(ut,17,()=>c(x),Vi,(ii,xi)=>{var Ji=_h(),Hi=b(Ji),li={};H(()=>{N(Hi,c(xi)),li!==(li=c(xi))&&(Ji.value=(Ji.__value=c(xi))??"")}),I(ii,Ji)});var Je=m(Pe,2),$t=m(Je,2),Jt=m(de,2);{var Mi=ii=>{var xi=Lm(),Ji=b(xi);H(()=>N(Ji,c(w))),I(ii,xi)};O(Jt,ii=>{c(w)&&ii(Mi)})}H(()=>Je.disabled=!c(p)||c(y)),ys(Pe,()=>c(p),ii=>v(p,ii)),z("click",Je,D),z("click",$t,()=>v(g,null)),I(Se,nt)};O(qe,Se=>{var nt;((nt=c(g))==null?void 0:nt.kind)==="user-groups"&&c(g).target===c(ie).username&&Se(Tt)})}var it=m(Ve),ye=b(it),Ne=b(ye),Ee=m(Ne,2);H(()=>N(le,c(ie).username)),z("click",U,()=>k("user-roles",c(ie).username)),z("click",mt,()=>k("user-groups",c(ie).username)),z("click",Ne,()=>Ui(c(ie).username)),z("click",Ee,()=>Gi(c(ie).username)),I(G,fe)}),I(oe,$)};O(Ii,oe=>{c(n).length===0?oe(W):oe(Q,-1)})}z("click",vt,()=>{v(se,!0),v(Ke,"")}),I(re,Ge)};O(ae,re=>{c(f)==="users"&&re(me)})}var Ze=m(ae,2);{var Zt=re=>{var Ge=EQ(),wt=b(Ge),vt=m(b(wt),2),di=m(wt,2);{var It=oe=>{var $=ya(),A=b($);H(()=>N(A,c(d))),I(oe,$)};O(di,oe=>{c(d)&&oe(It)})}var Ii=m(di,2);{var W=oe=>{var $=kQ();I(oe,$)},Q=oe=>{var $=IQ(),A=m(b($));ni(A,21,()=>c(s),Vi,(G,ie)=>{var fe=LQ(),Y=b(fe),le=b(Y),Re=m(Y),_e=b(Re),ge=m(Re),tt=b(ge),U=b(tt),ne=m(U,2);H(()=>{var Le;N(le,c(ie).rolename),N(_e,((Le=c(ie).acls)==null?void 0:Le.length)??0)}),z("click",U,()=>_i(c(ie))),z("click",ne,()=>Kt(c(ie).rolename)),I(G,fe)}),I(oe,$)};O(Ii,oe=>{c(s).length===0?oe(W):oe(Q,-1)})}z("click",vt,()=>{v(Pt,!0),v(Mt,""),v(Oe,"")}),I(re,Ge)};O(Ze,re=>{c(f)==="roles"&&re(Zt)})}var bt=m(Ze,2);{var We=re=>{var Ge=AQ(),wt=b(Ge),vt=m(b(wt),2),di=m(wt,2);{var It=oe=>{var $=ya(),A=b($);H(()=>N(A,c(u))),I(oe,$)};O(di,oe=>{c(u)&&oe(It)})}var Ii=m(di,2);{var W=oe=>{var $=DQ();I(oe,$)},Q=oe=>{var $=NQ(),A=m(b($));ni(A,21,()=>c(r),Vi,(G,ie)=>{var fe=RQ(),Y=b(fe),le=b(Y),Re=m(Y),_e=b(Re),ge=b(_e),tt=b(ge);ni(tt,17,()=>c(ie).clients??[],Vi,(Ee,Se)=>{var nt=TQ(),de=b(nt),Pe=m(de);H(()=>N(de,c(Se).username)),z("click",Pe,()=>K(c(ie).groupname,c(Se).username)),I(Ee,nt)});var U=m(tt,2),ne=m(ge,2);{var Le=Ee=>{var Se=PQ(),nt=xt(Se),de=b(nt),Pe=b(de);Pe.value=Pe.__value="";var at=m(Pe);ni(at,17,()=>c(x),Vi,(Mi,ii)=>{var xi=_h(),Ji=b(xi),Hi={};H(()=>{N(Ji,c(ii)),Hi!==(Hi=c(ii))&&(xi.value=(xi.__value=c(ii))??"")}),I(Mi,xi)});var ut=m(de,2),Je=m(ut,2),$t=m(nt,2);{var Jt=Mi=>{var ii=Lm(),xi=b(ii);H(()=>N(xi,c(w))),I(Mi,ii)};O($t,Mi=>{c(w)&&Mi(Jt)})}H(()=>ut.disabled=!c(p)||c(y)),ys(de,()=>c(p),Mi=>v(p,Mi)),z("click",ut,D),z("click",Je,()=>v(g,null)),I(Ee,Se)};O(ne,Ee=>{var Se;((Se=c(g))==null?void 0:Se.kind)==="group-members"&&c(g).target===c(ie).groupname&&Ee(Le)})}var Ve=m(Re),De=b(Ve),Ie=b(De),St=b(Ie);ni(St,17,()=>c(ie).roles??[],Vi,(Ee,Se)=>{var nt=MQ(),de=b(nt),Pe=m(de);H(()=>N(de,c(Se).rolename)),z("click",Pe,()=>V(c(ie).groupname,c(Se).rolename)),I(Ee,nt)});var mt=m(St,2),qe=m(Ie,2);{var Tt=Ee=>{var Se=kD(),nt=xt(Se),de=b(nt),Pe=b(de);Pe.value=Pe.__value="";var at=m(Pe);ni(at,17,()=>c(x),Vi,(Mi,ii)=>{var xi=_h(),Ji=b(xi),Hi={};H(()=>{N(Ji,c(ii)),Hi!==(Hi=c(ii))&&(xi.value=(xi.__value=c(ii))??"")}),I(Mi,xi)});var ut=m(de,2),Je=m(ut,2),$t=m(nt,2);{var Jt=Mi=>{var ii=Lm(),xi=b(ii);H(()=>N(xi,c(w))),I(Mi,ii)};O($t,Mi=>{c(w)&&Mi(Jt)})}H(()=>ut.disabled=!c(p)||c(y)),ys(de,()=>c(p),Mi=>v(p,Mi)),z("click",ut,D),z("click",Je,()=>v(g,null)),I(Ee,Se)};O(qe,Ee=>{var Se;((Se=c(g))==null?void 0:Se.kind)==="group-roles"&&c(g).target===c(ie).groupname&&Ee(Tt)})}var it=m(Ve),ye=b(it),Ne=b(ye);H(()=>N(le,c(ie).groupname)),z("click",U,()=>k("group-members",c(ie).groupname)),z("click",mt,()=>k("group-roles",c(ie).groupname)),z("click",Ne,()=>Oi(c(ie).groupname)),I(G,fe)}),I(oe,$)};O(Ii,oe=>{c(r).length===0?oe(W):oe(Q,-1)})}z("click",vt,()=>{v(jt,!0),v(ht,""),v(ft,"")}),I(re,Ge)};O(bt,re=>{c(f)==="groups"&&re(We)})}var At=m(bt,2);{var ai=re=>{var Ge=zQ(),wt=b(Ge),vt=m(b(wt),4);{var di=fe=>{var Y=ya(),le=b(Y);H(()=>N(le,c(Ut))),I(fe,Y)};O(vt,fe=>{c(Ut)&&fe(di)})}var It=m(vt,2);{var Ii=fe=>{var Y=LD();I(fe,Y)},W=fe=>{var Y=FQ(),le=m(b(Y));ni(le,21,()=>Bi,Vi,(Re,_e)=>{let ge=()=>c(_e).acltype,tt=()=>c(_e).label;const U=Ct(()=>c(Xe).find(Tt=>Tt.acltype===ge()));var ne=OQ();let Le;var Ve=b(ne),De=b(Ve),Ie=m(Ve),St=b(Ie),mt=m(Ie),qe=b(mt);H(()=>{var Tt,it;Le=kt(ne,1,"svelte-3itf14",null,Le,{saving:c(wi)}),N(De,tt()),ln(St,"name",ge()),hl(St,((Tt=c(U))==null?void 0:Tt.allow)===!0),ln(qe,"name",ge()),hl(qe,((it=c(U))==null?void 0:it.allow)===!1)}),z("change",St,()=>Ni(ge(),!0)),z("change",qe,()=>Ni(ge(),!1)),I(Re,ne)}),I(fe,Y)};O(It,fe=>{c(pt)?fe(W,-1):fe(Ii)})}var Q=m(wt,2),oe=m(b(Q),4);{var $=fe=>{var Y=ya(),le=b(Y);H(()=>N(le,c(Bt))),I(fe,Y)};O(oe,fe=>{c(Bt)&&fe($)})}var A=m(oe,2);{var G=fe=>{var Y=LD();I(fe,Y)},ie=fe=>{var Y=BQ(),le=xt(Y),Re=b(le),_e=b(Re);_e.value=_e.__value="";var ge=m(_e);ni(ge,17,()=>c(r),Vi,(De,Ie)=>{var St=_h(),mt=b(St),qe={};H(()=>{N(mt,c(Ie).groupname),qe!==(qe=c(Ie).groupname)&&(St.value=(St.__value=c(Ie).groupname)??"")}),I(De,St)});var tt=m(Re,2),U=b(tt),ne=m(le,2);{var Le=De=>{var Ie=HQ(),St=m(b(Ie)),mt=b(St);H(()=>N(mt,c(Ri))),I(De,Ie)},Ve=De=>{var Ie=WQ();I(De,Ie)};O(ne,De=>{c(Ri)?De(Le):De(Ve,-1)})}H(()=>{tt.disabled=c(Xt)||c(ci)===(c(Ri)??""),N(U,c(Xt)?"Saving…":"Save")}),ys(Re,()=>c(ci),De=>v(ci,De)),z("click",tt,Ki),I(fe,Y)};O(A,fe=>{c(pt)?fe(ie,-1):fe(G)})}I(re,Ge)};O(At,re=>{c(f)==="settings"&&re(ai)})}var zt=m(mi,2);{var vi=re=>{var Ge=VQ(),wt=b(Ge),vt=m(b(wt),2),di=m(b(vt)),It=m(vt,2),Ii=m(b(It)),W=b(Ii),Q=m(W,2),oe=b(Q),$=m(It,2);{var A=le=>{var Re=ya(),_e=b(Re);H(()=>N(_e,c(Ke))),I(le,Re)};O($,le=>{c(Ke)&&le(A)})}var G=m($,2),ie=b(G),fe=m(ie,2),Y=b(fe);H(()=>{ln(W,"type",c(je)?"text":"password"),N(oe,c(je)?"Hide":"Show"),fe.disabled=c(ue)||!c(te)||!c(pe),N(Y,c(ue)?"Creating…":"Create")}),Ht(di,()=>c(te),le=>v(te,le)),Ht(W,()=>c(pe),le=>v(pe,le)),z("click",Q,()=>v(je,!c(je))),z("click",ie,()=>v(se,!1)),z("click",fe,$i),I(re,Ge)};O(zt,re=>{c(se)&&re(vi)})}var hi=m(zt,2);{var Ci=re=>{var Ge=jQ(),wt=b(Ge),vt=b(wt),di=m(b(vt)),It=b(di),Ii=m(vt,2),W=m(b(Ii)),Q=m(Ii,2);{var oe=fe=>{var Y=ya(),le=b(Y);H(()=>N(le,c(gt))),I(fe,Y)};O(Q,fe=>{c(gt)&&fe(oe)})}var $=m(Q,2),A=b($),G=m(A,2),ie=b(G);H(()=>{N(It,c(dt)),G.disabled=c(ot)||!c(we),N(ie,c(ot)?"Saving…":"Set password")}),Ht(W,()=>c(we),fe=>v(we,fe)),z("click",A,()=>v(He,!1)),z("click",G,mn),I(re,Ge)};O(hi,re=>{c(He)&&re(Ci)})}var zi=m(hi,2);{var $e=re=>{var Ge=$Q(),wt=b(Ge),vt=m(b(wt),2),di=m(b(vt)),It=m(vt,2);{var Ii=A=>{var G=ya(),ie=b(G);H(()=>N(ie,c(Mt))),I(A,G)};O(It,A=>{c(Mt)&&A(Ii)})}var W=m(It,2),Q=b(W),oe=m(Q,2),$=b(oe);H(()=>{oe.disabled=c(et)||!c(Oe),N($,c(et)?"Creating…":"Create")}),Ht(di,()=>c(Oe),A=>v(Oe,A)),z("click",Q,()=>v(Pt,!1)),z("click",oe,rt),I(re,Ge)};O(zi,re=>{c(Pt)&&re($e)})}var Fe=m(zi,2);{var Ft=re=>{var Ge=KQ(),wt=b(Ge),vt=b(wt),di=m(b(vt)),It=b(di),Ii=m(vt,2);{var W=ge=>{var tt=qQ(),U=m(b(tt));ni(U,21,()=>c(ct).acls??[],Vi,(ne,Le)=>{var Ve=UQ(),De=b(Ve),Ie=b(De),St=m(De),mt=b(St),qe=m(St),Tt=b(qe),it=m(qe),ye=b(it);H(()=>{N(Ie,c(Le).acltype),N(mt,c(Le).topic),N(Tt,c(Le).allow?"✓":"✗")}),z("click",ye,()=>Li(c(ct).rolename,c(Le).acltype,c(Le).topic)),I(ne,Ve)}),I(ge,tt)},Q=ge=>{var tt=GQ();I(ge,tt)};O(Ii,ge=>{var tt;(((tt=c(ct).acls)==null?void 0:tt.length)??0)>0?ge(W):ge(Q,-1)})}var oe=m(Ii,2),$=b(oe);ni($,21,()=>Ai,Vi,(ge,tt)=>{var U=_h(),ne=b(U),Le={};H(()=>{N(ne,c(tt)),Le!==(Le=c(tt))&&(U.value=(U.__value=c(tt))??"")}),I(ge,U)});var A=m($,2),G=m(A,2),ie=b(G),fe=m(G,2),Y=m(oe,2);{var le=ge=>{var tt=ya(),U=b(tt);H(()=>N(U,c(Me))),I(ge,tt)};O(Y,ge=>{c(Me)&&ge(le)})}var Re=m(Y,2),_e=b(Re);H(()=>{N(It,c(ct).rolename),fe.disabled=!c(ri)}),ys($,()=>c(ti),ge=>v(ti,ge)),Ht(A,()=>c(ri),ge=>v(ri,ge)),ms(ie,()=>c(Vt),ge=>v(Vt,ge)),z("click",fe,Pi),z("click",_e,()=>v(Nt,!1)),I(re,Ge)};O(Fe,re=>{c(Nt)&&c(ct)&&re(Ft)})}var Yt=m(Fe,2);{var qt=re=>{var Ge=ZQ(),wt=b(Ge),vt=m(b(wt),2),di=m(b(vt)),It=m(vt,2);{var Ii=A=>{var G=ya(),ie=b(G);H(()=>N(ie,c(ht))),I(A,G)};O(It,A=>{c(ht)&&A(Ii)})}var W=m(It,2),Q=b(W),oe=m(Q,2),$=b(oe);H(()=>{oe.disabled=c(he)||!c(ft),N($,c(he)?"Creating…":"Create")}),Ht(di,()=>c(ft),A=>v(ft,A)),z("click",Q,()=>v(jt,!1)),z("click",oe,Si),I(re,Ge)};O(Yt,re=>{c(jt)&&re(qt)})}var Qt=m(Yt,2);vs(Uc(Qt,{}),re=>i=re,()=>i),H(()=>{yt=kt(_t,1,"svelte-3itf14",null,yt,{active:c(f)==="users"}),j=kt(Ot,1,"svelte-3itf14",null,j,{active:c(f)==="roles"}),ke=kt(ce,1,"svelte-3itf14",null,ke,{active:c(f)==="groups"}),st=kt(ze,1,"svelte-3itf14",null,st,{active:c(f)==="settings"})}),z("click",_t,()=>v(f,"users")),z("click",Ot,()=>v(f,"roles")),z("click",ce,()=>v(f,"groups")),z("click",ze,()=>{v(f,"settings"),c(pt)||Ti()}),z("click",X,Di),I(o,qi),Ps()}zs(["click","change"]);var ID=T('<div class="err svelte-9i68x"> </div>'),QQ=T('<div class="ok svelte-9i68x">Saved.</div>'),JQ=T('<div class="reload-msg svelte-9i68x"> </div>'),eJ=T('<div class="loading svelte-9i68x">Loading…</div>'),tJ=T('<div class="anon-row svelte-9i68x"><span class="field-label svelte-9i68x"><code class="svelte-9i68x">allow_anonymous</code></span> <select class="svelte-9i68x"><option>auto (broker default)</option><option>true — allow unauthenticated clients</option><option>false — require authentication</option></select></div>'),iJ=T("<option></option>"),nJ=T('<div class="tls-section svelte-9i68x"><div class="field-row svelte-9i68x"><label class="svelte-9i68x">Certificate file (certfile) <input placeholder="/etc/mosquitto/certs/server.crt" class="svelte-9i68x"/></label> <label class="svelte-9i68x">Key file (keyfile) <input placeholder="/etc/mosquitto/certs/server.key" class="svelte-9i68x"/></label></div> <div class="field-row svelte-9i68x"><label class="svelte-9i68x">CA file (cafile) — single CA cert <input placeholder="/etc/mosquitto/ca.crt" class="svelte-9i68x"/></label> <label class="svelte-9i68x">CA path (capath) — CA cert directory <input placeholder="/etc/mosquitto/ca-certs/" class="svelte-9i68x"/></label></div> <div class="field-row svelte-9i68x"><label class="svelte-9i68x">CRL file (crlfile) <input placeholder="/etc/mosquitto/crl.pem" class="svelte-9i68x"/></label> <label class="svelte-9i68x">TLS version <select class="svelte-9i68x"><option>Default</option><option>tlsv1.3</option><option>tlsv1.2</option></select></label></div> <div class="field-row svelte-9i68x"><label class="toggle-label svelte-9i68x"><input type="checkbox" class="svelte-9i68x"/> Require client certificate (require_certificate)</label> <label class="toggle-label svelte-9i68x"><input type="checkbox" class="svelte-9i68x"/> Use cert CN as username (use_identity_as_username)</label></div></div>'),sJ=T('<div class="field-row svelte-9i68x"><label class="toggle-label svelte-9i68x"><input type="checkbox" class="svelte-9i68x"/> Use cert Subject as username (use_subject_as_username)</label></div>'),oJ=T('<div class="advanced-section svelte-9i68x"><div class="field-row svelte-9i68x"><label class="svelte-9i68x">Mount point <input placeholder="(none)" class="svelte-9i68x"/></label> <label class="svelte-9i68x">Max connections <input type="number" min="-1" placeholder="-1 (unlimited)" class="svelte-9i68x"/></label> <label class="svelte-9i68x">Max QoS <select class="svelte-9i68x"><option>default</option><option>0 — fire and forget</option><option>1 — at least once</option><option>2 — exactly once</option></select></label></div> <!></div>'),rJ=T('<div class="auth-section svelte-9i68x"><div class="auth-section-title svelte-9i68x">Authentication</div> <div class="field-row svelte-9i68x"><label class="svelte-9i68x">allow_anonymous <select class="svelte-9i68x"><option>auto (broker default)</option><option>true — allow unauthenticated</option><option>false — require auth</option></select></label> <label class="svelte-9i68x">password_file <input placeholder="/etc/mosquitto/passwd" class="svelte-9i68x"/></label> <label class="svelte-9i68x">acl_file <input placeholder="/etc/mosquitto/acl" class="svelte-9i68x"/></label></div></div>'),aJ=T('<div class="listener-card svelte-9i68x"><div class="card-title svelte-9i68x"><span> </span> <button class="remove-btn svelte-9i68x" title="Remove listener">✕</button></div> <div class="field-row svelte-9i68x"><label class="svelte-9i68x">Port <input type="number" min="1" max="65535" class="svelte-9i68x"/></label> <label class="svelte-9i68x">Protocol <select class="svelte-9i68x"><option>mqtt</option><option>websockets</option></select></label> <label class="svelte-9i68x">Bind address <input placeholder="(all interfaces)" class="svelte-9i68x"/></label> <label class="toggle-label tls-inline svelte-9i68x"><input type="checkbox" class="svelte-9i68x"/> TLS</label></div> <datalist></datalist> <!> <button class="advanced-btn svelte-9i68x"> </button> <!> <!></div>'),lJ=T('<div class="empty svelte-9i68x">No listeners configured. Click "+ Add listener" to create one.</div>'),cJ=T('<div class="global-settings svelte-9i68x"><label class="toggle-label svelte-9i68x"><input type="checkbox"/> <span><code>per_listener_settings</code> — independent auth per listener</span> <span class="info-icon svelte-9i68x" title="Not recommended when using the dynamic-security plugin — dynsec credentials only apply to the default listener. See mosquitto documentation.">ℹ</span></label> <!></div> <div class="cards svelte-9i68x"><!> <!></div>',1),dJ=T('<div class="listeners-page svelte-9i68x"><div class="page-header svelte-9i68x"><h3 class="svelte-9i68x">Listeners</h3> <div class="header-actions svelte-9i68x"><button class="svelte-9i68x">+ Add listener</button> <button class="btn-save svelte-9i68x"> </button> <button class="btn-reload svelte-9i68x" title="Apply &amp; Reload mosquitto"> </button></div></div> <!> <!> <!> <!> <!></div>');function uJ(o,e){Ts(e,!0);let t=P(null),i=P(""),n=P(!1),s=P(""),r=P(!1),a=P(!1),d=P(""),u=P(yi([])),f=P(null),g=P(!1),p=P(""),w=P(yi([])),y=P(yi(new Set));Bs(()=>{x(),iq().then(Me=>{v(w,Me.addresses,!0)}).catch(()=>{})});async function x(){try{v(t,await Pk(),!0),v(u,JSON.parse(JSON.stringify(c(t).listeners)),!0),v(f,c(t).checksum,!0);const Me=c(t).managed.allow_anonymous;v(p,Me==="true"||Me==="false"?Me:"",!0),v(g,c(t).managed.per_listener_settings==="true"),v(i,"")}catch(Me){v(i,Me.message??"Failed to load broker config",!0)}}function k(){v(u,[...c(u),{port:1883,bindAddress:"",protocol:"mqtt",tls:{}}],!0),v(y,new Set(c(y)),!0)}function D(Me){const jt=new Set(c(y));jt.has(Me)?jt.delete(Me):jt.add(Me),v(y,jt,!0)}function M(Me){v(u,c(u).filter((jt,ft)=>ft!==Me),!0)}async function F(){if(c(t)){v(n,!0),v(s,""),v(r,!1);try{const Me={...c(t).managed};c(g)?(Me.per_listener_settings="true",delete Me.allow_anonymous):(delete Me.per_listener_settings,c(p)?Me.allow_anonymous=c(p):delete Me.allow_anonymous),await tA({listeners:c(u),managed:Me,passthrough:c(t).passthrough,checksum:c(f)}),v(r,!0),setTimeout(()=>v(r,!1),3e3),await x()}catch(Me){v(s,Me.message??"Save failed",!0)}finally{v(n,!1)}}}async function K(){v(a,!0),v(d,"");try{const Me=await iA();v(d,Me.stderr||Me.stdout||"Reloaded",!0)}catch(Me){v(d,"Error: "+(Me.message??"reload failed"))}finally{v(a,!1)}}function V(Me){var jt,ft,ht,he;return!!((jt=Me.tls)!=null&&jt.certfile||(ft=Me.tls)!=null&&ft.keyfile||(ht=Me.tls)!=null&&ht.capath||(he=Me.tls)!=null&&he.cafile)}function se(Me,jt){jt||(Me.tls={}),v(u,[...c(u)],!0)}var te=dJ(),pe=b(te),je=m(b(pe),2),Ke=b(je),ue=m(Ke,2),He=b(ue),dt=m(ue,2),we=b(dt),gt=m(pe,2);{var ot=Me=>{var jt=ID(),ft=b(jt);H(()=>N(ft,c(i))),I(Me,jt)};O(gt,Me=>{c(i)&&Me(ot)})}var Pt=m(gt,2);{var Oe=Me=>{var jt=ID(),ft=b(jt);H(()=>N(ft,c(s))),I(Me,jt)};O(Pt,Me=>{c(s)&&Me(Oe)})}var Mt=m(Pt,2);{var et=Me=>{var jt=QQ();I(Me,jt)};O(Mt,Me=>{c(r)&&Me(et)})}var ct=m(Mt,2);{var Nt=Me=>{var jt=JQ(),ft=b(jt);H(()=>N(ft,c(d))),I(Me,jt)};O(ct,Me=>{c(d)&&Me(Nt)})}var ti=m(ct,2);{var ri=Me=>{var jt=eJ();I(Me,jt)},Vt=Me=>{var jt=cJ(),ft=xt(jt),ht=b(ft),he=b(ht),Xe=m(ht,2);{var Ut=Xt=>{var pt=tJ(),Bi=m(b(pt),2),Ti=b(Bi);Ti.value=Ti.__value="";var Ni=m(Ti);Ni.value=Ni.__value="true";var Ki=m(Ni);Ki.value=Ki.__value="false",ys(Bi,()=>c(p),Ai=>v(p,Ai)),I(Xt,pt)};O(Xe,Xt=>{c(g)||Xt(Ut)})}var wi=m(ft,2),Ri=b(wi);ni(Ri,17,()=>c(u),Vi,(Xt,pt,Bi)=>{var Ti=aJ(),Ni=b(Ti),Ki=b(Ni),Ai=b(Ki),Di=m(Ki,2),$i=m(Ni,2),Gi=b($i),Ui=m(b(Gi)),mn=m(Gi,2),rt=m(b(mn)),Kt=b(rt);Kt.value=Kt.__value="mqtt";var _i=m(Kt);_i.value=_i.__value="websockets";var Pi=m(mn,2),Li=m(b(Pi));ln(Li,"list",`bind-addr-list-${Bi}`);var Si=m(Pi,2),Oi=b(Si),qi=m($i,2);ln(qi,"id",`bind-addr-list-${Bi}`),ni(qi,21,()=>c(w),Vi,(ze,st)=>{var X=iJ(),ae={};H(()=>{ae!==(ae=c(st))&&(X.value=(X.__value=c(st))??"")}),I(ze,X)});var mi=m(qi,2);{var Ue=ze=>{var st=nJ(),X=b(st),ae=b(X),me=m(b(ae)),Ze=m(ae,2),Zt=m(b(Ze)),bt=m(X,2),We=b(bt),At=m(b(We)),ai=m(We,2),zt=m(b(ai)),vi=m(bt,2),hi=b(vi),Ci=m(b(hi)),zi=m(hi,2),$e=m(b(zi)),Fe=b($e);Fe.value=Fe.__value="";var Ft=m(Fe);Ft.value=Ft.__value="tlsv1.3";var Yt=m(Ft);Yt.value=Yt.__value="tlsv1.2";var qt=m(vi,2),Qt=b(qt),re=b(Qt),Ge=m(Qt,2),wt=b(Ge);Ht(me,()=>c(pt).tls.certfile,vt=>c(pt).tls.certfile=vt),Ht(Zt,()=>c(pt).tls.keyfile,vt=>c(pt).tls.keyfile=vt),Ht(At,()=>c(pt).tls.cafile,vt=>c(pt).tls.cafile=vt),Ht(zt,()=>c(pt).tls.capath,vt=>c(pt).tls.capath=vt),Ht(Ci,()=>c(pt).tls.crlfile,vt=>c(pt).tls.crlfile=vt),ys($e,()=>c(pt).tls.tls_version,vt=>c(pt).tls.tls_version=vt),ms(re,()=>c(pt).tls.require_certificate,vt=>c(pt).tls.require_certificate=vt),ms(wt,()=>c(pt).tls.use_identity_as_username,vt=>c(pt).tls.use_identity_as_username=vt),I(ze,st)},J=Ct(()=>V(c(pt)));O(mi,ze=>{c(J)&&ze(Ue)})}var Qe=m(mi,2),_t=b(Qe),yt=m(Qe,2);{var Ot=ze=>{var st=oJ(),X=b(st),ae=b(X),me=m(b(ae)),Ze=m(ae,2),Zt=m(b(Ze)),bt=m(Ze,2),We=m(b(bt)),At=b(We);At.value=At.__value="";var ai=m(At);ai.value=ai.__value="0";var zt=m(ai);zt.value=zt.__value="1";var vi=m(zt);vi.value=vi.__value="2";var hi;ZS(We);var Ci=m(X,2);{var zi=Fe=>{var Ft=sJ(),Yt=b(Ft),qt=b(Yt);ms(qt,()=>c(pt).tls.use_subject_as_username,Qt=>c(pt).tls.use_subject_as_username=Qt),I(Fe,Ft)},$e=Ct(()=>V(c(pt)));O(Ci,Fe=>{c($e)&&Fe(zi)})}H(Fe=>{hi!==(hi=Fe)&&(We.value=(We.__value=Fe)??"",mv(We,Fe))},[()=>c(pt).max_qos!==void 0?String(c(pt).max_qos):""]),Ht(me,()=>c(pt).mount_point,Fe=>c(pt).mount_point=Fe),Ht(Zt,()=>c(pt).max_connections,Fe=>c(pt).max_connections=Fe),z("change",We,Fe=>{const Ft=Fe.target.value;c(pt).max_qos=Ft===""?void 0:Number(Ft),v(u,[...c(u)],!0)}),I(ze,st)},j=Ct(()=>c(y).has(Bi));O(yt,ze=>{c(j)&&ze(Ot)})}var ce=m(yt,2);{var ke=ze=>{var st=rJ(),X=m(b(st),2),ae=b(X),me=m(b(ae)),Ze=b(me);Ze.value=Ze.__value="";var Zt=m(Ze);Zt.value=Zt.__value="true";var bt=m(Zt);bt.value=bt.__value="false";var We;ZS(me);var At=m(ae,2),ai=m(b(At)),zt=m(At,2),vi=m(b(zt));H(()=>{We!==(We=c(pt).allow_anonymous===void 0?"":c(pt).allow_anonymous?"true":"false")&&(me.value=me.__value=c(pt).allow_anonymous===void 0?"":c(pt).allow_anonymous?"true":"false",mv(me,c(pt).allow_anonymous===void 0?"":c(pt).allow_anonymous?"true":"false"))}),z("change",me,hi=>{const Ci=hi.target.value;c(pt).allow_anonymous=Ci===""?void 0:Ci==="true",v(u,[...c(u)],!0)}),Ht(ai,()=>c(pt).password_file,hi=>c(pt).password_file=hi),Ht(vi,()=>c(pt).acl_file,hi=>c(pt).acl_file=hi),I(ze,st)};O(ce,ze=>{c(g)&&ze(ke)})}H((ze,st)=>{N(Ai,`Port ${c(pt).port??""}`),hl(Oi,ze),N(_t,`${st??""} Advanced`)},[()=>V(c(pt)),()=>c(y).has(Bi)?"▾":"▸"]),z("click",Di,()=>M(Bi)),Ht(Ui,()=>c(pt).port,ze=>c(pt).port=ze),ys(rt,()=>c(pt).protocol,ze=>c(pt).protocol=ze),Ht(Li,()=>c(pt).bindAddress,ze=>c(pt).bindAddress=ze),z("change",Oi,ze=>se(c(pt),ze.target.checked)),z("click",Qe,()=>D(Bi)),I(Xt,Ti)});var ci=m(Ri,2);{var Bt=Xt=>{var pt=lJ();I(Xt,pt)};O(ci,Xt=>{c(u).length===0&&Xt(Bt)})}ms(he,()=>c(g),Xt=>v(g,Xt)),I(Me,jt)};O(ti,Me=>{c(t)===null&&!c(i)?Me(ri):Me(Vt,-1)})}H(()=>{ue.disabled=c(n),N(He,c(n)?"Saving…":"Save"),dt.disabled=c(a),N(we,c(a)?"Reloading…":"Apply & Reload")}),z("click",Ke,k),z("click",ue,F),z("click",dt,K),I(o,te),Ps()}zs(["click","change"]);var ED=T('<div class="err svelte-1by6o5t"> </div>'),hJ=T('<div class="ok svelte-1by6o5t">Saved.</div>'),fJ=T('<div class="reload-msg svelte-1by6o5t"> </div>'),DD=T('<label class="check-label svelte-1by6o5t"><input type="checkbox" class="svelte-1by6o5t"/> </label>'),gJ=T(`<div class="section svelte-1by6o5t"><h4 class="svelte-1by6o5t">Connection limits</h4> <div class="field-grid svelte-1by6o5t"><div class="field svelte-1by6o5t"><label class="svelte-1by6o5t"><span class="svelte-1by6o5t">max_connections</span> <input placeholder="−1 (unlimited)" class="svelte-1by6o5t"/></label> <p class="hint svelte-1by6o5t">Maximum simultaneous client connections. <code class="svelte-1by6o5t">-1</code> = unlimited.</p></div> <div class="field svelte-1by6o5t"><label class="svelte-1by6o5t"><span class="svelte-1by6o5t">max_keepalive</span> <input placeholder="65535" class="svelte-1by6o5t"/></label> <p class="hint svelte-1by6o5t">Maximum keepalive value (seconds) a client may request. <code class="svelte-1by6o5t">0</code> = unlimited.</p></div> <div class="field svelte-1by6o5t"><label class="svelte-1by6o5t"><span class="svelte-1by6o5t">max_inflight_messages</span> <input placeholder="20" class="svelte-1by6o5t"/></label> <p class="hint svelte-1by6o5t">Max simultaneous unacknowledged QoS 1/2 messages per client.</p></div> <div class="field svelte-1by6o5t"><label class="svelte-1by6o5t"><span class="svelte-1by6o5t">max_queued_messages</span> <input placeholder="100" class="svelte-1by6o5t"/></label> <p class="hint svelte-1by6o5t">Max messages queued for a disconnected persistent client.</p></div></div></div> <div class="section svelte-1by6o5t"><h4 class="svelte-1by6o5t">Packet &amp; payload size</h4> <div class="field-grid svelte-1by6o5t"><div class="field svelte-1by6o5t"><label class="svelte-1by6o5t"><span class="svelte-1by6o5t">max_packet_size</span> <input placeholder="0 (no limit)" class="svelte-1by6o5t"/></label> <p class="hint svelte-1by6o5t">Maximum MQTT packet size in bytes (MQTT v5 only). <code class="svelte-1by6o5t">0</code> = no limit.</p></div> <div class="field svelte-1by6o5t"><label class="svelte-1by6o5t"><span class="svelte-1by6o5t">message_size_limit</span> <input placeholder="0 (no limit)" class="svelte-1by6o5t"/></label> <p class="hint svelte-1by6o5t">Maximum payload size in bytes for published messages. <code class="svelte-1by6o5t">0</code> = no limit.</p></div></div></div> <div class="section svelte-1by6o5t"><h4 class="svelte-1by6o5t">Sessions &amp; persistence</h4> <div class="field-grid svelte-1by6o5t"><div class="field svelte-1by6o5t"><label class="svelte-1by6o5t"><span class="svelte-1by6o5t">persistent_client_expiration</span> <input placeholder="e.g. 7d, 2h, 30m" class="svelte-1by6o5t"/></label> <p class="hint svelte-1by6o5t">Expire persistent sessions after this duration. Suffix: <code class="svelte-1by6o5t">d</code>/<code class="svelte-1by6o5t">h</code>/<code class="svelte-1by6o5t">m</code>/<code class="svelte-1by6o5t">s</code>. Empty = never expire.</p></div> <div class="field svelte-1by6o5t"><label class="svelte-1by6o5t"><span class="svelte-1by6o5t">retain_available</span> <select class="svelte-1by6o5t"><option>auto (broker default)</option><option>true — allow retained messages</option><option>false — disable retained messages globally</option></select></label> <p class="hint svelte-1by6o5t">Disable retained messages broker-wide.</p></div></div></div> <div class="section svelte-1by6o5t"><h4 class="svelte-1by6o5t">Logging</h4> <div class="field svelte-1by6o5t"><span class="field-key svelte-1by6o5t">log_dest</span> <div class="checkbox-group svelte-1by6o5t"></div> <p class="hint svelte-1by6o5t">Log destinations. Enable <code class="svelte-1by6o5t">topic</code> to stream logs to <code class="svelte-1by6o5t">$SYS/broker/log/*</code> and view them in the Logs tab.</p></div> <div class="field svelte-1by6o5t"><span class="field-key svelte-1by6o5t">log_type</span> <div class="checkbox-group svelte-1by6o5t"></div> <p class="hint svelte-1by6o5t">Types of messages to log. Leave empty to use the broker default.</p></div></div> <div class="section svelte-1by6o5t"><h4 class="svelte-1by6o5t">Performance</h4> <div class="field-grid svelte-1by6o5t"><div class="field svelte-1by6o5t"><label class="svelte-1by6o5t"><span class="svelte-1by6o5t">set_tcp_nodelay</span> <select class="svelte-1by6o5t"><option>auto (broker default)</option><option>true — disable Nagle (lower latency)</option><option>false — enable Nagle</option></select></label> <p class="hint svelte-1by6o5t">Disable Nagle's algorithm to reduce latency at the cost of slightly more packets.</p></div> <div class="field svelte-1by6o5t"><label class="svelte-1by6o5t"><span class="svelte-1by6o5t">connection_messages</span> <select class="svelte-1by6o5t"><option>auto (broker default)</option><option>true — log connect/disconnect</option><option>false — suppress</option></select></label> <p class="hint svelte-1by6o5t">Log a message on every client connect and disconnect.</p></div></div></div>`,1),pJ=T('<div class="config-page svelte-1by6o5t"><div class="page-header svelte-1by6o5t"><h3 class="svelte-1by6o5t">Global config</h3> <div class="header-actions svelte-1by6o5t"><button class="btn-save svelte-1by6o5t"> </button> <button class="btn-reload svelte-1by6o5t"> </button></div></div> <!> <!> <!> <!> <!></div>');function _J(o,e){Ts(e,!0);let t=P(null),i=P(""),n=P(!1),s=P(""),r=P(!1),a=P(!1),d=P(""),u=P(null),f=P(""),g=P(""),p=P(""),w=P(""),y=P(""),x=P(""),k=P(""),D=P(""),M=P(""),F=P("");const K=["file","stdout","stderr","syslog","topic","none"],V=["debug","error","warning","notice","information","subscribe","unsubscribe","websockets","connect","disconnect","publish","receive","all"];let se=P(yi(new Set)),te=P(yi(new Set));function pe(he){if(!c(t))return"";const Xe=c(t).managed[he];return Array.isArray(Xe)?Xe[0]:Xe??""}function je(he){if(!c(t))return new Set;const Xe=c(t).managed[he];return Xe?new Set(Array.isArray(Xe)?Xe:[Xe]):new Set}Bs(()=>Ke());async function Ke(){try{v(t,await Pk(),!0),v(u,c(t).checksum,!0),v(f,pe("max_connections"),!0),v(g,pe("max_inflight_messages"),!0),v(p,pe("max_queued_messages"),!0),v(w,pe("max_packet_size"),!0),v(y,pe("message_size_limit"),!0),v(x,pe("max_keepalive"),!0),v(k,pe("persistent_client_expiration"),!0),v(D,pe("retain_available"),!0),v(M,pe("set_tcp_nodelay"),!0),v(F,pe("connection_messages"),!0),v(se,je("log_dest"),!0),v(te,je("log_type"),!0),v(i,"")}catch(he){v(i,he.message??"Failed to load config",!0)}}async function ue(){if(c(t)){v(n,!0),v(s,""),v(r,!1);try{let Xe=function(Ut,wi){wi!==""?he[Ut]=wi:delete he[Ut]};const he={...c(t).managed};Xe("max_connections",c(f)),Xe("max_inflight_messages",c(g)),Xe("max_queued_messages",c(p)),Xe("max_packet_size",c(w)),Xe("message_size_limit",c(y)),Xe("max_keepalive",c(x)),Xe("persistent_client_expiration",c(k)),Xe("retain_available",c(D)),Xe("set_tcp_nodelay",c(M)),Xe("connection_messages",c(F)),c(se).size>0?he.log_dest=c(se).size===1?[...c(se)][0]:[...c(se)]:delete he.log_dest,c(te).size>0?he.log_type=c(te).size===1?[...c(te)][0]:[...c(te)]:delete he.log_type,await tA({listeners:c(t).listeners,managed:he,passthrough:c(t).passthrough,checksum:c(u)}),v(r,!0),setTimeout(()=>v(r,!1),3e3),await Ke()}catch(he){v(s,he.message??"Save failed",!0)}finally{v(n,!1)}}}async function He(){v(a,!0),v(d,"");try{const he=await iA();v(d,he.stderr||he.stdout||"Reloaded",!0)}catch(he){v(d,"Error: "+(he.message??"reload failed"))}finally{v(a,!1)}}var dt=pJ(),we=b(dt),gt=m(b(we),2),ot=b(gt),Pt=b(ot),Oe=m(ot,2),Mt=b(Oe),et=m(we,2);{var ct=he=>{var Xe=ED(),Ut=b(Xe);H(()=>N(Ut,c(i))),I(he,Xe)};O(et,he=>{c(i)&&he(ct)})}var Nt=m(et,2);{var ti=he=>{var Xe=ED(),Ut=b(Xe);H(()=>N(Ut,c(s))),I(he,Xe)};O(Nt,he=>{c(s)&&he(ti)})}var ri=m(Nt,2);{var Vt=he=>{var Xe=hJ();I(he,Xe)};O(ri,he=>{c(r)&&he(Vt)})}var Me=m(ri,2);{var jt=he=>{var Xe=fJ(),Ut=b(Xe);H(()=>N(Ut,c(d))),I(he,Xe)};O(Me,he=>{c(d)&&he(jt)})}var ft=m(Me,2);{var ht=he=>{var Xe=gJ(),Ut=xt(Xe),wi=m(b(Ut),2),Ri=b(wi),ci=b(Ri),Bt=m(b(ci),2),Xt=m(Ri,2),pt=b(Xt),Bi=m(b(pt),2),Ti=m(Xt,2),Ni=b(Ti),Ki=m(b(Ni),2),Ai=m(Ti,2),Di=b(Ai),$i=m(b(Di),2),Gi=m(Ut,2),Ui=m(b(Gi),2),mn=b(Ui),rt=b(mn),Kt=m(b(rt),2),_i=m(mn,2),Pi=b(_i),Li=m(b(Pi),2),Si=m(Gi,2),Oi=m(b(Si),2),qi=b(Oi),mi=b(qi),Ue=m(b(mi),2),J=m(qi,2),Qe=b(J),_t=m(b(Qe),2),yt=b(_t);yt.value=yt.__value="";var Ot=m(yt);Ot.value=Ot.__value="true";var j=m(Ot);j.value=j.__value="false";var ce=m(Si,2),ke=m(b(ce),2),ze=m(b(ke),2);ni(ze,21,()=>K,Vi,(Fe,Ft)=>{var Yt=DD(),qt=b(Yt),Qt=m(qt);H(re=>{hl(qt,re),N(Qt,` ${c(Ft)??""}`)},[()=>c(se).has(c(Ft))]),z("change",qt,()=>{const re=new Set(c(se));re.has(c(Ft))?re.delete(c(Ft)):re.add(c(Ft)),v(se,re,!0)}),I(Fe,Yt)});var st=m(ke,2),X=m(b(st),2);ni(X,21,()=>V,Vi,(Fe,Ft)=>{var Yt=DD(),qt=b(Yt),Qt=m(qt);H(re=>{hl(qt,re),N(Qt,` ${c(Ft)??""}`)},[()=>c(te).has(c(Ft))]),z("change",qt,()=>{const re=new Set(c(te));re.has(c(Ft))?re.delete(c(Ft)):re.add(c(Ft)),v(te,re,!0)}),I(Fe,Yt)});var ae=m(ce,2),me=m(b(ae),2),Ze=b(me),Zt=b(Ze),bt=m(b(Zt),2),We=b(bt);We.value=We.__value="";var At=m(We);At.value=At.__value="true";var ai=m(At);ai.value=ai.__value="false";var zt=m(Ze,2),vi=b(zt),hi=m(b(vi),2),Ci=b(hi);Ci.value=Ci.__value="";var zi=m(Ci);zi.value=zi.__value="true";var $e=m(zi);$e.value=$e.__value="false",Ht(Bt,()=>c(f),Fe=>v(f,Fe)),Ht(Bi,()=>c(x),Fe=>v(x,Fe)),Ht(Ki,()=>c(g),Fe=>v(g,Fe)),Ht($i,()=>c(p),Fe=>v(p,Fe)),Ht(Kt,()=>c(w),Fe=>v(w,Fe)),Ht(Li,()=>c(y),Fe=>v(y,Fe)),Ht(Ue,()=>c(k),Fe=>v(k,Fe)),ys(_t,()=>c(D),Fe=>v(D,Fe)),ys(bt,()=>c(M),Fe=>v(M,Fe)),ys(hi,()=>c(F),Fe=>v(F,Fe)),I(he,Xe)};O(ft,he=>{c(t)&&he(ht)})}H(()=>{ot.disabled=c(n),N(Pt,c(n)?"Saving…":"Save"),Oe.disabled=c(a),N(Mt,c(a)?"Reloading…":"Apply & Reload")}),z("click",ot,ue),z("click",Oe,He),I(o,dt),Ps()}zs(["click","change"]);var tl=T('<div class="err svelte-9auejo"> </div>'),mJ=T('<div class="info-card svelte-9auejo"><dl class="svelte-9auejo"><dt class="svelte-9auejo">CN</dt><dd class="svelte-9auejo"> </dd> <dt class="svelte-9auejo">Fingerprint (SHA-256)</dt><dd class="mono small svelte-9auejo"> </dd> <dt class="svelte-9auejo">Expires</dt><dd> </dd></dl></div>'),vJ=T('<div class="empty svelte-9auejo">No managed server certificate. Use one of the options above, or configure <code>certfile</code>/<code>keyfile</code> manually in the Listeners tab.</div>'),bJ=T('<div class="empty svelte-9auejo">No trusted CA certs. Add one to enable client certificate authentication.</div>'),yJ=T('<tr><td class="mono svelte-9auejo"> </td><td class="mono small svelte-9auejo"> </td><td> </td><td class="actions svelte-9auejo"><button class="danger svelte-9auejo">✕</button></td></tr>'),wJ=T('<table class="svelte-9auejo"><thead><tr><th class="svelte-9auejo">CN</th><th class="svelte-9auejo">Fingerprint</th><th class="svelte-9auejo">Expires</th><th class="svelte-9auejo"></th></tr></thead><tbody></tbody></table>'),SJ=T('<div class="result-box svelte-9auejo"><p class="svelte-9auejo">✓ Certificate installed.</p> <dl class="svelte-9auejo"><dt class="svelte-9auejo">Fingerprint</dt><dd class="mono small svelte-9auejo"> </dd><dt class="svelte-9auejo">Expires</dt><dd class="svelte-9auejo"> </dd></dl></div>'),TD=T('<button class="btn-primary svelte-9auejo"> </button>'),CJ=T('<div class="modal-backdrop svelte-9auejo" role="dialog" aria-modal="true"><div class="modal svelte-9auejo"><h3 class="svelte-9auejo">Generate self-signed server certificate</h3> <label class="svelte-9auejo">Common Name (hostname / IP)<input placeholder="e.g. mqtt.home.arpa" class="svelte-9auejo"/></label> <label class="svelte-9auejo">Subject Alternative Names (comma-separated, optional)<input placeholder="192.168.1.10, mqtt.local" class="svelte-9auejo"/></label> <label class="svelte-9auejo">Validity (days)<input type="number" min="1" max="3650" class="svelte-9auejo"/></label> <!> <!> <div class="modal-actions svelte-9auejo"><button class="svelte-9auejo">Close</button> <!></div></div></div>'),xJ=T('<label class="svelte-9auejo">Common Name (hostname / IP)<input placeholder="e.g. mqtt.home.arpa" class="svelte-9auejo"/></label> <label class="svelte-9auejo">Subject Alternative Names (comma-separated, optional)<input placeholder="192.168.1.10, mqtt.local" class="svelte-9auejo"/></label> <p class="hint svelte-9auejo">A private key and CSR are generated on the server. Copy the CSR, have it signed by your CA, then paste the signed cert below.</p> <!> <div class="modal-actions svelte-9auejo"><button class="svelte-9auejo">Cancel</button> <button class="btn-primary svelte-9auejo"> </button></div>',1),kJ=T('<div class="ok svelte-9auejo">✓ Certificate installed.</div>'),LJ=T('<p class="hint svelte-9auejo">Key stored on server. Copy the CSR, get it signed, then paste the signed certificate to complete installation.</p> <label class="svelte-9auejo">Certificate Signing Request<textarea readonly="" rows="8" class="svelte-9auejo"></textarea></label> <div class="csr-actions svelte-9auejo"><button class="svelte-9auejo">Copy CSR</button> <a class="btn-download svelte-9auejo" download="server.csr">Download .csr</a></div> <hr class="svelte-9auejo"/> <label class="svelte-9auejo">Upload signed certificate (PEM)<textarea rows="6" placeholder="-----BEGIN CERTIFICATE----- … -----END CERTIFICATE-----" class="svelte-9auejo"></textarea></label> <!> <!> <div class="modal-actions svelte-9auejo"><button class="svelte-9auejo">Close</button> <!></div>',1),IJ=T('<div class="modal-backdrop svelte-9auejo" role="dialog" aria-modal="true"><div class="modal modal--wide svelte-9auejo"><h3 class="svelte-9auejo">Generate key + CSR for server certificate</h3> <!></div></div>'),EJ=T('<label class="svelte-9auejo">Certificate (PEM)<textarea rows="5" placeholder="-----BEGIN CERTIFICATE----- … -----END CERTIFICATE-----" class="svelte-9auejo"></textarea></label> <label class="svelte-9auejo">Private key (PEM — leave blank if key is already on disk from a prior CSR)<textarea rows="4" placeholder="-----BEGIN PRIVATE KEY----- … -----END PRIVATE KEY-----" class="svelte-9auejo"></textarea></label>',1),DJ=T('<span class="file-name mono small svelte-9auejo"> </span>'),TJ=T('<label class="svelte-9auejo">PKCS#12 file <div class="file-row svelte-9auejo"><input type="file" accept=".p12,.pfx" class="svelte-9auejo"/> <!></div></label> <label class="svelte-9auejo">Passphrase <div class="pw-row svelte-9auejo"><input autocomplete="off" class="svelte-9auejo"/> <button class="toggle-pw svelte-9auejo"> </button></div></label>',1),PJ=T('<div class="modal-backdrop svelte-9auejo" role="dialog" aria-modal="true"><div class="modal modal--wide svelte-9auejo"><h3 class="svelte-9auejo">Import server certificate</h3> <div class="import-mode-tabs svelte-9auejo"><button>PEM files</button> <button>PKCS#12 (.p12 / .pfx)</button></div> <!> <!> <div class="modal-actions svelte-9auejo"><button class="svelte-9auejo">Cancel</button> <button class="btn-primary svelte-9auejo"> </button></div></div></div>'),yS=T("<option></option>"),MJ=T('<div class="modal-backdrop svelte-9auejo" role="dialog" aria-modal="true"><div class="modal modal--wide svelte-9auejo"><h3 class="svelte-9auejo">Use existing certificate files</h3> <p class="hint svelte-9auejo">Enter absolute paths on the broker host. Tab-completion is available for paths starting with /.</p> <label class="svelte-9auejo">Certificate file path <input list="set-cert-path-list" placeholder="/etc/letsencrypt/live/mqtt.example.com/fullchain.pem" class="svelte-9auejo"/> <datalist id="set-cert-path-list"></datalist></label> <label class="svelte-9auejo">Private key file path <input list="set-key-path-list" placeholder="/etc/letsencrypt/live/mqtt.example.com/privkey.pem" class="svelte-9auejo"/> <datalist id="set-key-path-list"></datalist></label> <!> <div class="modal-actions svelte-9auejo"><button class="svelte-9auejo">Cancel</button> <button class="btn-primary svelte-9auejo"> </button></div></div></div>'),RJ=T('<label class="svelte-9auejo">CA certificate (PEM)<textarea rows="8" placeholder="-----BEGIN CERTIFICATE----- … -----END CERTIFICATE-----" class="svelte-9auejo"></textarea></label> <!> <div class="modal-actions svelte-9auejo"><button class="svelte-9auejo">Cancel</button> <button class="btn-primary svelte-9auejo"> </button></div>',1),NJ=T('<p class="hint svelte-9auejo">Enter the absolute path to the CA certificate file on the broker host.</p> <label class="svelte-9auejo">CA certificate path <input list="trusted-path-list" placeholder="/etc/ssl/certs/my-ca.pem" class="svelte-9auejo"/> <datalist id="trusted-path-list"></datalist></label> <!> <div class="modal-actions svelte-9auejo"><button class="svelte-9auejo">Cancel</button> <button class="btn-primary svelte-9auejo"> </button></div>',1),AJ=T('<div class="modal-backdrop svelte-9auejo" role="dialog" aria-modal="true"><div class="modal modal--wide svelte-9auejo"><h3 class="svelte-9auejo">Add trusted CA certificate</h3> <div class="import-mode-tabs svelte-9auejo"><button>Paste PEM</button> <button>From path</button></div> <!></div></div>'),OJ=T('<div class="certs-page svelte-9auejo"><div class="page-toolbar svelte-9auejo"><button class="reload-btn svelte-9auejo" title="Refresh">↺</button></div> <!> <!> <div class="section svelte-9auejo"><div class="section-header svelte-9auejo"><h3 class="svelte-9auejo">Server Certificate</h3> <button class="svelte-9auejo">Self-signed</button> <button class="svelte-9auejo">Generate CSR</button> <button class="svelte-9auejo">Import cert</button> <button class="svelte-9auejo">Use path</button></div> <!></div> <div class="section svelte-9auejo"><div class="section-header svelte-9auejo"><h3 class="svelte-9auejo">Trusted CA Certificates</h3> <button class="svelte-9auejo">+ Add CA cert</button></div> <!></div></div> <!> <!> <!> <!> <!>',1);function FJ(o,e){Ts(e,!0);let t=P(null),i=P(yi([])),n=P(""),s=P(""),r=P(!1),a=P(""),d=P(""),u=P(365),f=P(!1),g=P(""),p=P(null),w=P(!1),y=P(""),x=P(""),k=P(!1),D=P(""),M=P(""),F=P(""),K=P(!1),V=P(""),se=P(!1),te=P(!1),pe=P("pem"),je=P(""),Ke=P(""),ue=P(""),He=P(""),dt=P(""),we=P(!1),gt=P(!1),ot=P(""),Pt=P(!1),Oe=P(""),Mt=P(""),et=P(!1),ct=P(""),Nt=P(yi([])),ti=P(yi([])),ri=P(!1),Vt=P("pem"),Me=P(""),jt=P(!1),ft=P(""),ht=P(""),he=P(yi([])),Xe=P(!1),Ut=P("");async function wi(){try{const[$e,Fe]=await Promise.allSettled([Cq(),Lq()]);$e.status==="fulfilled"&&v(t,$e.value.server,!0),Fe.status==="fulfilled"&&v(i,Fe.value.certs,!0),v(n,"")}catch($e){v(n,$e.message,!0)}}Bs(()=>{wi()});async function Ri(){v(g,""),v(f,!0),v(p,null);try{const $e=c(d).split(",").map(Ft=>Ft.trim()).filter(Boolean),Fe=await xq({cn:c(a),san:$e,days:c(u)});v(p,{fingerprint:Fe.fingerprint,expires:Fe.expires},!0),await wi()}catch($e){v(g,$e.message,!0)}finally{v(f,!1)}}async function ci(){v(D,""),v(k,!0),v(M,"");try{const $e=c(x).split(",").map(Ft=>Ft.trim()).filter(Boolean),Fe=await kq({cn:c(y),san:$e});v(M,Fe.csrPem,!0)}catch($e){v(D,$e.message,!0)}finally{v(k,!1)}}async function Bt(){v(V,""),v(K,!0),v(se,!1);try{if(!c(F).trim())throw new Error("Paste the signed certificate PEM");await _S({cert:c(F)}),v(se,!0),await wi()}catch($e){v(V,$e.message,!0)}finally{v(K,!1)}}function Xt(){navigator.clipboard.writeText(c(M)).catch(()=>{})}function pt($e){var Yt;const Fe=(Yt=$e.target.files)==null?void 0:Yt[0];if(!Fe)return;v(He,Fe.name,!0);const Ft=new FileReader;Ft.onload=()=>{const qt=Ft.result;v(ue,btoa(String.fromCharCode(...new Uint8Array(qt))),!0)},Ft.readAsArrayBuffer(Fe)}async function Bi(){v(ot,""),v(gt,!0);try{if(c(pe)==="p12"){if(!c(ue))throw new Error("Select a .p12 / .pfx file");await _S({p12base64:c(ue),passphrase:c(dt)})}else{if(!c(je).trim())throw new Error("Certificate PEM is required");await _S({cert:c(je),key:c(Ke)||void 0})}v(te,!1),await wi()}catch($e){v(ot,$e.message,!0)}finally{v(gt,!1)}}function Ti($e){let Fe;return Ft=>{const Yt=Ft.target.value;clearTimeout(Fe),Fe=setTimeout(async()=>{if(!Yt.startsWith("/")||Yt.length<2){$e([]);return}try{$e((await Dq(Yt)).suggestions)}catch{$e([])}},280)}}const Ni=Ti($e=>{v(Nt,$e,!0)}),Ki=Ti($e=>{v(ti,$e,!0)}),Ai=Ti($e=>{v(he,$e,!0)});async function Di(){v(ct,""),v(et,!0);try{await Tq({certPath:c(Oe),keyPath:c(Mt)}),v(Pt,!1),await wi()}catch($e){v(ct,$e.message,!0)}finally{v(et,!1)}}async function $i(){v(ft,""),v(jt,!0);try{await Iq(c(Me)),v(Me,""),v(ri,!1),await wi()}catch($e){v(ft,$e.message,!0)}finally{v(jt,!1)}}async function Gi(){v(Ut,""),v(Xe,!0);try{await Pq(c(ht)),v(ht,""),v(ri,!1),await wi()}catch($e){v(Ut,$e.message,!0)}finally{v(Xe,!1)}}async function Ui($e){if(confirm("Remove this trusted CA cert?"))try{await Eq($e),await wi()}catch(Fe){v(s,Fe.message,!0)}}function mn($e){const Fe=new Date($e).getTime()-Date.now();return Fe<0?"expired":Fe<30*864e5?"expiring":""}function rt($e){return new Date($e).toLocaleDateString()}var Kt=OJ(),_i=xt(Kt),Pi=b(_i),Li=b(Pi),Si=m(Pi,2);{var Oi=$e=>{var Fe=tl(),Ft=b(Fe);H(()=>N(Ft,c(n))),I($e,Fe)};O(Si,$e=>{c(n)&&$e(Oi)})}var qi=m(Si,2);{var mi=$e=>{var Fe=tl(),Ft=b(Fe);H(()=>N(Ft,c(s))),I($e,Fe)};O(qi,$e=>{c(s)&&$e(mi)})}var Ue=m(qi,2),J=b(Ue),Qe=m(b(J),2),_t=m(Qe,2),yt=m(_t,2),Ot=m(yt,2),j=m(J,2);{var ce=$e=>{var Fe=mJ(),Ft=b(Fe),Yt=m(b(Ft)),qt=b(Yt),Qt=m(Yt,3),re=b(Qt),Ge=m(Qt,3),wt=b(Ge);H((vt,di)=>{N(qt,c(t).cn),N(re,c(t).fingerprint),kt(Ge,1,vt,"svelte-9auejo"),N(wt,di)},[()=>Kg(mn(c(t).expires)),()=>rt(c(t).expires)]),I($e,Fe)},ke=$e=>{var Fe=vJ();I($e,Fe)};O(j,$e=>{c(t)?$e(ce):$e(ke,-1)})}var ze=m(Ue,2),st=b(ze),X=m(b(st),2),ae=m(st,2);{var me=$e=>{var Fe=bJ();I($e,Fe)},Ze=$e=>{var Fe=wJ(),Ft=m(b(Fe));ni(Ft,21,()=>c(i),Vi,(Yt,qt)=>{var Qt=yJ(),re=b(Qt),Ge=b(re),wt=m(re),vt=b(wt),di=m(wt),It=b(di),Ii=m(di),W=b(Ii);H((Q,oe,$)=>{N(Ge,c(qt).cn),N(vt,`${Q??""}…`),kt(di,1,oe,"svelte-9auejo"),N(It,$)},[()=>c(qt).fingerprint.slice(0,29),()=>Kg(mn(c(qt).expires)),()=>rt(c(qt).expires)]),z("click",W,()=>Ui(c(qt).fingerprint)),I(Yt,Qt)}),I($e,Fe)};O(ae,$e=>{c(i).length===0?$e(me):$e(Ze,-1)})}var Zt=m(_i,2);{var bt=$e=>{var Fe=CJ(),Ft=b(Fe),Yt=m(b(Ft),2),qt=m(b(Yt)),Qt=m(Yt,2),re=m(b(Qt)),Ge=m(Qt,2),wt=m(b(Ge)),vt=m(Ge,2);{var di=A=>{var G=tl(),ie=b(G);H(()=>N(ie,c(g))),I(A,G)};O(vt,A=>{c(g)&&A(di)})}var It=m(vt,2);{var Ii=A=>{var G=SJ(),ie=m(b(G),2),fe=m(b(ie)),Y=b(fe),le=m(fe,2),Re=b(le);H(_e=>{N(Y,c(p).fingerprint),N(Re,_e)},[()=>rt(c(p).expires)]),I(A,G)};O(It,A=>{c(p)&&A(Ii)})}var W=m(It,2),Q=b(W),oe=m(Q,2);{var $=A=>{var G=TD(),ie=b(G);H(()=>{G.disabled=c(f),N(ie,c(f)?"Generating…":"Generate")}),z("click",G,Ri),I(A,G)};O(oe,A=>{c(p)||A($)})}Ht(qt,()=>c(a),A=>v(a,A)),Ht(re,()=>c(d),A=>v(d,A)),Ht(wt,()=>c(u),A=>v(u,A)),z("click",Q,()=>v(r,!1)),I($e,Fe)};O(Zt,$e=>{c(r)&&$e(bt)})}var We=m(Zt,2);{var At=$e=>{var Fe=IJ(),Ft=b(Fe),Yt=m(b(Ft),2);{var qt=re=>{var Ge=xJ(),wt=xt(Ge),vt=m(b(wt)),di=m(wt,2),It=m(b(di)),Ii=m(di,4);{var W=G=>{var ie=tl(),fe=b(ie);H(()=>N(fe,c(D))),I(G,ie)};O(Ii,G=>{c(D)&&G(W)})}var Q=m(Ii,2),oe=b(Q),$=m(oe,2),A=b($);H(()=>{$.disabled=c(k),N(A,c(k)?"Generating…":"Generate key + CSR")}),Ht(vt,()=>c(y),G=>v(y,G)),Ht(It,()=>c(x),G=>v(x,G)),z("click",oe,()=>v(w,!1)),z("click",$,ci),I(re,Ge)},Qt=re=>{var Ge=LJ(),wt=m(xt(Ge),2),vt=m(b(wt)),di=m(wt,2),It=b(di),Ii=m(It,2),W=m(di,4),Q=m(b(W)),oe=m(W,2);{var $=Re=>{var _e=tl(),ge=b(_e);H(()=>N(ge,c(V))),I(Re,_e)};O(oe,Re=>{c(V)&&Re($)})}var A=m(oe,2);{var G=Re=>{var _e=kJ();I(Re,_e)};O(A,Re=>{c(se)&&Re(G)})}var ie=m(A,2),fe=b(ie),Y=m(fe,2);{var le=Re=>{var _e=TD(),ge=b(_e);H(tt=>{_e.disabled=tt,N(ge,c(K)?"Uploading…":"Upload signed cert")},[()=>c(K)||!c(F).trim()]),z("click",_e,Bt),I(Re,_e)};O(Y,Re=>{c(se)||Re(le)})}H(Re=>{YS(vt,c(M)),ln(Ii,"href",`data:application/pkcs10;charset=utf-8,${Re??""}`)},[()=>encodeURIComponent(c(M))]),z("click",It,Xt),Ht(Q,()=>c(F),Re=>v(F,Re)),z("click",fe,()=>v(w,!1)),I(re,Ge)};O(Yt,re=>{c(M)?re(Qt,-1):re(qt)})}I($e,Fe)};O(We,$e=>{c(w)&&$e(At)})}var ai=m(We,2);{var zt=$e=>{var Fe=PJ(),Ft=b(Fe),Yt=m(b(Ft),2),qt=b(Yt);let Qt;var re=m(qt,2);let Ge;var wt=m(Yt,2);{var vt=A=>{var G=EJ(),ie=xt(G),fe=m(b(ie)),Y=m(ie,2),le=m(b(Y));Ht(fe,()=>c(je),Re=>v(je,Re)),Ht(le,()=>c(Ke),Re=>v(Ke,Re)),I(A,G)},di=A=>{var G=TJ(),ie=xt(G),fe=m(b(ie)),Y=b(fe),le=m(Y,2);{var Re=Le=>{var Ve=DJ(),De=b(Ve);H(()=>N(De,c(He))),I(Le,Ve)};O(le,Le=>{c(He)&&Le(Re)})}var _e=m(ie,2),ge=m(b(_e)),tt=b(ge),U=m(tt,2),ne=b(U);H(()=>{ln(tt,"type",c(we)?"text":"password"),N(ne,c(we)?"Hide":"Show")}),z("change",Y,pt),Ht(tt,()=>c(dt),Le=>v(dt,Le)),z("click",U,()=>v(we,!c(we))),I(A,G)};O(wt,A=>{c(pe)==="pem"?A(vt):A(di,-1)})}var It=m(wt,2);{var Ii=A=>{var G=tl(),ie=b(G);H(()=>N(ie,c(ot))),I(A,G)};O(It,A=>{c(ot)&&A(Ii)})}var W=m(It,2),Q=b(W),oe=m(Q,2),$=b(oe);H(()=>{Qt=kt(qt,1,"svelte-9auejo",null,Qt,{active:c(pe)==="pem"}),Ge=kt(re,1,"svelte-9auejo",null,Ge,{active:c(pe)==="p12"}),oe.disabled=c(gt),N($,c(gt)?"Importing…":"Import")}),z("click",qt,()=>v(pe,"pem")),z("click",re,()=>v(pe,"p12")),z("click",Q,()=>v(te,!1)),z("click",oe,Bi),I($e,Fe)};O(ai,$e=>{c(te)&&$e(zt)})}var vi=m(ai,2);{var hi=$e=>{var Fe=MJ(),Ft=b(Fe),Yt=m(b(Ft),4),qt=m(b(Yt)),Qt=m(qt,2);ni(Qt,21,()=>c(Nt),Vi,(oe,$)=>{var A=yS(),G={};H(()=>{G!==(G=c($))&&(A.value=(A.__value=c($))??"")}),I(oe,A)});var re=m(Yt,2),Ge=m(b(re)),wt=m(Ge,2);ni(wt,21,()=>c(ti),Vi,(oe,$)=>{var A=yS(),G={};H(()=>{G!==(G=c($))&&(A.value=(A.__value=c($))??"")}),I(oe,A)});var vt=m(re,2);{var di=oe=>{var $=tl(),A=b($);H(()=>N(A,c(ct))),I(oe,$)};O(vt,oe=>{c(ct)&&oe(di)})}var It=m(vt,2),Ii=b(It),W=m(Ii,2),Q=b(W);H(oe=>{W.disabled=oe,N(Q,c(et)?"Installing…":"Install")},[()=>c(et)||!c(Oe).trim()||!c(Mt).trim()]),z("input",qt,Ni),Ht(qt,()=>c(Oe),oe=>v(Oe,oe)),z("input",Ge,Ki),Ht(Ge,()=>c(Mt),oe=>v(Mt,oe)),z("click",Ii,()=>v(Pt,!1)),z("click",W,Di),I($e,Fe)};O(vi,$e=>{c(Pt)&&$e(hi)})}var Ci=m(vi,2);{var zi=$e=>{var Fe=AJ(),Ft=b(Fe),Yt=m(b(Ft),2),qt=b(Yt);let Qt;var re=m(qt,2);let Ge;var wt=m(Yt,2);{var vt=It=>{var Ii=RJ(),W=xt(Ii),Q=m(b(W)),oe=m(W,2);{var $=Y=>{var le=tl(),Re=b(le);H(()=>N(Re,c(ft))),I(Y,le)};O(oe,Y=>{c(ft)&&Y($)})}var A=m(oe,2),G=b(A),ie=m(G,2),fe=b(ie);H(Y=>{ie.disabled=Y,N(fe,c(jt)?"Adding…":"Add CA cert")},[()=>c(jt)||!c(Me).trim()]),Ht(Q,()=>c(Me),Y=>v(Me,Y)),z("click",G,()=>v(ri,!1)),z("click",ie,$i),I(It,Ii)},di=It=>{var Ii=NJ(),W=m(xt(Ii),2),Q=m(b(W)),oe=m(Q,2);ni(oe,21,()=>c(he),Vi,(le,Re)=>{var _e=yS(),ge={};H(()=>{ge!==(ge=c(Re))&&(_e.value=(_e.__value=c(Re))??"")}),I(le,_e)});var $=m(W,2);{var A=le=>{var Re=tl(),_e=b(Re);H(()=>N(_e,c(Ut))),I(le,Re)};O($,le=>{c(Ut)&&le(A)})}var G=m($,2),ie=b(G),fe=m(ie,2),Y=b(fe);H(le=>{fe.disabled=le,N(Y,c(Xe)?"Adding…":"Add CA cert")},[()=>c(Xe)||!c(ht).trim()]),z("input",Q,Ai),Ht(Q,()=>c(ht),le=>v(ht,le)),z("click",ie,()=>v(ri,!1)),z("click",fe,Gi),I(It,Ii)};O(wt,It=>{c(Vt)==="pem"?It(vt):It(di,-1)})}H(()=>{Qt=kt(qt,1,"svelte-9auejo",null,Qt,{active:c(Vt)==="pem"}),Ge=kt(re,1,"svelte-9auejo",null,Ge,{active:c(Vt)==="path"})}),z("click",qt,()=>v(Vt,"pem")),z("click",re,()=>v(Vt,"path")),I($e,Fe)};O(Ci,$e=>{c(ri)&&$e(zi)})}z("click",Li,wi),z("click",Qe,()=>{v(r,!0),v(g,""),v(p,null)}),z("click",_t,()=>{v(w,!0),v(D,""),v(M,""),v(F,""),v(se,!1),v(V,"")}),z("click",yt,()=>{v(te,!0),v(ot,""),v(pe,"pem"),v(je,""),v(Ke,""),v(ue,""),v(He,""),v(dt,""),v(we,!1)}),z("click",Ot,()=>{v(Pt,!0),v(ct,""),v(Oe,""),v(Mt,""),v(Nt,[],!0),v(ti,[],!0)}),z("click",X,()=>{v(ri,!0),v(ft,""),v(Me,""),v(Vt,"pem"),v(Ut,""),v(ht,""),v(he,[],!0)}),I(o,Kt),Ps()}zs(["click","change","input"]);var Im=T('<div class="err svelte-17yczfe"> </div>'),HJ=T('<div class="check-list svelte-17yczfe"><div class="check-row svelte-17yczfe"><span> </span> <code class="svelte-17yczfe">mosquitto_ctrl</code> <span> </span></div> <div class="check-row svelte-17yczfe"><span> </span> <code class="svelte-17yczfe">mosquitto</code> <span> </span></div></div>'),WJ=T('<div class="checking svelte-17yczfe">Checking…</div>'),BJ=T('<div class="section svelte-17yczfe"><h3 class="svelte-17yczfe">Tool availability</h3> <p class="hint svelte-17yczfe">These tools must be installed and in the PATH of the she process. They are used by the Setup Wizard and cert installation.</p> <!> <!> <div class="row svelte-17yczfe"><button class="svelte-17yczfe"> </button></div></div>'),zJ=T('<label class="svelte-17yczfe">Install command (run locally) <div class="pubkey-row svelte-17yczfe"><input readonly="" class="svelte-17yczfe"/> <button class="copy-btn svelte-17yczfe">Copy</button></div></label>'),VJ=T('<label class="svelte-17yczfe">Public key <div class="pubkey-row svelte-17yczfe"><textarea readonly="" rows="3" class="svelte-17yczfe"></textarea> <button class="copy-btn svelte-17yczfe">Copy</button></div></label> <!> <div class="row svelte-17yczfe"><button class="svelte-17yczfe"> </button></div>',1),jJ=T('<div class="row svelte-17yczfe"><button class="svelte-17yczfe"> </button></div>'),$J=T("<span> </span>"),UJ=T('<div class="section svelte-17yczfe"><h3 class="svelte-17yczfe">SSH connection</h3> <p class="hint svelte-17yczfe">Used for file operations: reading/writing mosquitto.conf and installing certificates on the broker host. User/ACL management always uses the MQTT port directly.</p> <div class="fields svelte-17yczfe"><label class="svelte-17yczfe">Host<input placeholder="192.168.1.10 or broker.local" class="svelte-17yczfe"/></label> <label class="svelte-17yczfe">Port<input type="number" min="1" max="65535" class="svelte-17yczfe"/></label> <label class="svelte-17yczfe">SSH user<input placeholder="root" class="svelte-17yczfe"/></label> <label class="svelte-17yczfe">Identity file (private key)<input class="svelte-17yczfe"/></label></div></div> <div class="section svelte-17yczfe"><h3 class="svelte-17yczfe">SSH keypair</h3> <p class="hint svelte-17yczfe">Dedicated Ed25519 keypair for she to authenticate to the broker host. Private key stored at <code class="svelte-17yczfe"> </code>.</p> <!> <!></div> <div class="section svelte-17yczfe"><h3 class="svelte-17yczfe">Test connection</h3> <div class="row svelte-17yczfe"><button class="svelte-17yczfe"> </button> <!></div></div>',1),qJ=T('<div class="ok svelte-17yczfe">Saved.</div>'),GJ=T('<div class="mosquitto-page svelte-17yczfe"><!> <div class="mode-bar svelte-17yczfe"><span class="mode-label svelte-17yczfe">Connection mode</span> <div class="mode-toggle svelte-17yczfe"><button>Local</button> <button>SSH / Remote</button></div> <span class="mode-desc svelte-17yczfe"> </span></div> <!> <!> <!> <!> <div class="row svelte-17yczfe"><button class="btn-primary svelte-17yczfe"> </button></div></div>');function KJ(o,e){Ts(e,!0);let t=P(yi({})),i=P(""),n=P(!1),s=P(!1),r=P(""),a=P("~/.she/ssh/broker_id_ed25519"),d=P("local"),u=P(null),f=P(!1),g=P(""),p=P(""),w=P(!1),y=P(""),x=P(!1),k=P(""),D=P(yi({}));Bs(async()=>{try{const[he,Xe,Ut]=await Promise.all([Pl(),Tk(),fetch("/she/broker/ssh/pubkey").then(Ri=>Ri.json()).catch(()=>({publicKey:null}))]);v(D,he,!0),Xe.sshKeyDefault&&v(a,Xe.sshKeyDefault,!0);const wi=c(D).broker??{};v(t,wi.ssh??{},!0),c(t).port||(c(t).port=22),c(t).identityFile||(c(t).identityFile=c(a)),Ut.publicKey&&v(p,Ut.publicKey,!0),v(d,c(t).host?"ssh":"local",!0),c(d)==="local"&&M()}catch(he){v(i,he.message,!0)}});async function M(){v(f,!0),v(g,"");try{v(u,await tq(),!0)}catch(he){v(g,he.message??"Check failed",!0)}finally{v(f,!1)}}async function F(){v(n,!0),v(r,""),v(s,!1);try{const he=c(D).broker??{},Xe=c(d)==="local"?{...c(t),host:""}:c(t),Ut={...c(D),broker:{...he,ssh:Xe}};await Xp(Ut),v(s,!0),setTimeout(()=>v(s,!1),3e3)}catch(he){v(r,he.message,!0)}finally{v(n,!1)}}async function K(){v(w,!0),v(y,"");try{const he=await fetch("/she/broker/ssh/keygen",{method:"POST",headers:{"Content-Type":"application/json"}}),Xe=await he.json();if(!he.ok)throw new Error(Xe.error??he.statusText);v(p,Xe.publicKey,!0)}catch(he){v(y,he.message,!0)}finally{v(w,!1)}}async function V(){v(x,!0),v(k,"");try{const he=await fetch("/she/broker/ssh/test",{method:"POST",headers:{"Content-Type":"application/json"}}),Xe=await he.json();if(!he.ok)throw new Error(Xe.error??he.statusText);v(k,Xe.ok?"✓ Connection successful":"✗ "+(Xe.error??"Failed"),!0)}catch(he){v(k,"✗ "+he.message)}finally{v(x,!1)}}function se(he){navigator.clipboard.writeText(he).catch(()=>{})}const te=Ct(()=>c(t).identityFile&&c(t).user&&c(t).host?`ssh-copy-id -i ${c(t).identityFile}.pub ${c(t).user}@${c(t).host}`:"");var pe=GJ(),je=b(pe);{var Ke=he=>{var Xe=Im(),Ut=b(Xe);H(()=>N(Ut,c(i))),I(he,Xe)};O(je,he=>{c(i)&&he(Ke)})}var ue=m(je,2),He=m(b(ue),2),dt=b(He);let we;var gt=m(dt,2);let ot;var Pt=m(He,2),Oe=b(Pt),Mt=m(ue,2);{var et=he=>{var Xe=BJ(),Ut=m(b(Xe),4);{var wi=Ti=>{var Ni=Im(),Ki=b(Ni);H(()=>N(Ki,c(g))),I(Ti,Ni)};O(Ut,Ti=>{c(g)&&Ti(wi)})}var Ri=m(Ut,2);{var ci=Ti=>{var Ni=HJ(),Ki=b(Ni),Ai=b(Ki);let Di;var $i=b(Ai),Gi=m(Ai,4);let Ui;var mn=b(Gi),rt=m(Ki,2),Kt=b(rt);let _i;var Pi=b(Kt),Li=m(Kt,4);let Si;var Oi=b(Li);H(()=>{Di=kt(Ai,1,"check-icon svelte-17yczfe",null,Di,{ok:c(u).mosquittoCtrl,fail:!c(u).mosquittoCtrl}),N($i,c(u).mosquittoCtrl?"✓":"✗"),Ui=kt(Gi,1,"check-note svelte-17yczfe",null,Ui,{ok:c(u).mosquittoCtrl,fail:!c(u).mosquittoCtrl}),N(mn,c(u).mosquittoCtrl?"found in PATH":"not found — install the mosquitto or mosquitto-clients package"),_i=kt(Kt,1,"check-icon svelte-17yczfe",null,_i,{ok:c(u).mosquitto,fail:!c(u).mosquitto}),N(Pi,c(u).mosquitto?"✓":"✗"),Si=kt(Li,1,"check-note svelte-17yczfe",null,Si,{ok:c(u).mosquitto,fail:!c(u).mosquitto}),N(Oi,c(u).mosquitto?"found in PATH":"not found — install the mosquitto package")}),I(Ti,Ni)},Bt=Ti=>{var Ni=WJ();I(Ti,Ni)};O(Ri,Ti=>{c(u)?Ti(ci):c(f)&&Ti(Bt,1)})}var Xt=m(Ri,2),pt=b(Xt),Bi=b(pt);H(()=>{pt.disabled=c(f),N(Bi,c(f)?"Checking…":c(u)?"Re-check":"Check tools")}),z("click",pt,M),I(he,Xe)};O(Mt,he=>{c(d)==="local"&&he(et)})}var ct=m(Mt,2);{var Nt=he=>{var Xe=UJ(),Ut=xt(Xe),wi=m(b(Ut),4),Ri=b(wi),ci=m(b(Ri)),Bt=m(Ri,2),Xt=m(b(Bt)),pt=m(Bt,2),Bi=m(b(pt)),Ti=m(pt,2),Ni=m(b(Ti)),Ki=m(Ut,2),Ai=m(b(Ki),2),Di=m(b(Ai)),$i=b(Di),Gi=m(Ai,2);{var Ui=mi=>{var Ue=VJ(),J=xt(Ue),Qe=m(b(J)),_t=b(Qe),yt=m(_t,2),Ot=m(J,2);{var j=st=>{var X=zJ(),ae=m(b(X)),me=b(ae),Ze=m(me,2);H(()=>YS(me,c(te))),z("click",Ze,()=>se(c(te))),I(st,X)};O(Ot,st=>{c(te)&&st(j)})}var ce=m(Ot,2),ke=b(ce),ze=b(ke);H(()=>{YS(_t,c(p)),ke.disabled=c(w),N(ze,c(w)?"Generating…":"Regenerate keypair")}),z("click",yt,()=>se(c(p))),z("click",ke,K),I(mi,Ue)},mn=mi=>{var Ue=jJ(),J=b(Ue),Qe=b(J);H(()=>{J.disabled=c(w),N(Qe,c(w)?"Generating…":"Generate keypair")}),z("click",J,K),I(mi,Ue)};O(Gi,mi=>{c(p)?mi(Ui):mi(mn,-1)})}var rt=m(Gi,2);{var Kt=mi=>{var Ue=Im(),J=b(Ue);H(()=>N(J,c(y))),I(mi,Ue)};O(rt,mi=>{c(y)&&mi(Kt)})}var _i=m(Ki,2),Pi=m(b(_i),2),Li=b(Pi),Si=b(Li),Oi=m(Li,2);{var qi=mi=>{var Ue=$J();let J;var Qe=b(Ue);H(_t=>{J=kt(Ue,1,"test-result svelte-17yczfe",null,J,_t),N(Qe,c(k))},[()=>({ok:c(k).startsWith("✓"),fail:c(k).startsWith("✗")})]),I(mi,Ue)};O(Oi,mi=>{c(k)&&mi(qi)})}H(()=>{ln(Ni,"placeholder",c(a)),N($i,c(t).identityFile||c(a)),Li.disabled=c(x)||!c(t).host,N(Si,c(x)?"Testing…":"Test SSH connection")}),Ht(ci,()=>c(t).host,mi=>c(t).host=mi),Ht(Xt,()=>c(t).port,mi=>c(t).port=mi),Ht(Bi,()=>c(t).user,mi=>c(t).user=mi),Ht(Ni,()=>c(t).identityFile,mi=>c(t).identityFile=mi),z("click",Li,V),I(he,Xe)};O(ct,he=>{c(d)==="ssh"&&he(Nt)})}var ti=m(ct,2);{var ri=he=>{var Xe=Im(),Ut=b(Xe);H(()=>N(Ut,c(r))),I(he,Xe)};O(ti,he=>{c(r)&&he(ri)})}var Vt=m(ti,2);{var Me=he=>{var Xe=qJ();I(he,Xe)};O(Vt,he=>{c(s)&&he(Me)})}var jt=m(Vt,2),ft=b(jt),ht=b(ft);H(()=>{we=kt(dt,1,"svelte-17yczfe",null,we,{active:c(d)==="local"}),ot=kt(gt,1,"svelte-17yczfe",null,ot,{active:c(d)==="ssh"}),N(Oe,c(d)==="local"?"she and mosquitto run on the same machine — local filesystem access":"mosquitto runs on a remote host — file operations go through SSH"),ft.disabled=c(n),N(ht,c(n)?"Saving…":"Save")}),z("click",dt,()=>{v(d,"local"),c(u)||M()}),z("click",gt,()=>v(d,"ssh")),z("click",ft,F),I(o,pe),Ps()}zs(["click"]);var ZJ=T("<button> </button>"),YJ=T('<code>log_dest topic</code> is not enabled in mosquitto.conf.<br/> <span class="hint svelte-1yc29ow">Enable it in the <strong>Config</strong> tab, then click <em>Apply &amp; Reload</em>.</span>',1),XJ=T('<code>log_dest topic</code> is configured — waiting for messages&hellip;<br/> <span class="hint svelte-1yc29ow">If nothing appears, mosquitto may need a full restart for the change to take effect.</span>',1),QJ=T('Waiting for log messages&hellip;<br/> <span class="hint svelte-1yc29ow">Make sure <code class="svelte-1yc29ow">log_dest topic</code> is set in mosquitto.conf.</span>',1),JJ=T('<div class="empty svelte-1yc29ow"><!></div>'),eee=T('<div class="entry svelte-1yc29ow"><span class="ts svelte-1yc29ow"> </span> <span> </span> <span class="msg svelte-1yc29ow"> </span></div>'),tee=T('<div class="logs-page svelte-1yc29ow"><div class="toolbar svelte-1yc29ow"><div class="level-filters svelte-1yc29ow"></div> <div class="spacer svelte-1yc29ow"></div> <label class="autoscroll-label svelte-1yc29ow"><input type="checkbox"/> Auto-scroll</label> <button class="btn-clear svelte-1yc29ow">Clear</button></div> <div class="log-container svelte-1yc29ow"><!></div></div>');function iee(o,e){Ts(e,!0);const t={D:"DBG",I:"INF",N:"NTC",W:"WRN",E:"ERR"},i={D:"lvl-d",I:"lvl-i",N:"lvl-n",W:"lvl-w",E:"lvl-e"};function n(ue){const He=ue.slice(16);return He==="D"?"D":He==="I"?"I":He==="N"?"N":He==="W"?"W":He==="E"?"E":null}let s=P(yi([])),r=P(!0),a=P(yi(new Set(["D","I","N","W","E"]))),d=P(void 0),u=P(!1),f=P(null),g=null;Bs(()=>{g=cr("mqtt",ue=>{if(!ue.topic.startsWith("$SYS/broker/log/"))return;const He=n(ue.topic);He&&(v(u,!0),v(s,[...c(s).slice(-499),{ts:ue.ts,level:He,msg:ue.val}],!0),c(r)&&Gg().then(p))}),Pk().then(ue=>{const He=ue.managed.log_dest,dt=Array.isArray(He)?He:He?[He]:[];v(f,dt.includes("topic"),!0)}).catch(()=>{v(f,null)})}),x_(()=>{g==null||g()});function p(){c(d)&&(c(d).scrollTop=c(d).scrollHeight)}function w(ue){const He=new Set(c(a));He.has(ue)?He.delete(ue):He.add(ue),v(a,He,!0)}function y(){v(s,[],!0),v(u,!1)}let x=Ct(()=>c(s).filter(ue=>c(a).has(ue.level)));function k(ue){const He=new Date(ue);return He.toTimeString().slice(0,8)+"."+String(He.getMilliseconds()).padStart(3,"0")}var D=tee(),M=b(D),F=b(M);ni(F,20,()=>["D","I","N","W","E"],Vi,(ue,He)=>{var dt=ZJ();let we;var gt=b(dt);H(ot=>{we=kt(dt,1,`lvl-btn ${i[He]??""}`,"svelte-1yc29ow",we,ot),ln(dt,"title",`Toggle ${He??""} messages`),N(gt,t[He])},[()=>({active:c(a).has(He)})]),z("click",dt,()=>w(He)),I(ue,dt)});var K=m(F,4),V=b(K),se=m(K,2),te=m(M,2),pe=b(te);{var je=ue=>{var He=JJ(),dt=b(He);{var we=ot=>{var Pt=As(),Oe=xt(Pt);{var Mt=Nt=>{var ti=YJ();I(Nt,ti)},et=Nt=>{var ti=XJ();I(Nt,ti)},ct=Nt=>{var ti=QJ();I(Nt,ti)};O(Oe,Nt=>{c(f)===!1?Nt(Mt):c(f)===!0?Nt(et,1):Nt(ct,-1)})}I(ot,Pt)},gt=ot=>{var Pt=po("No messages match the current filter.");I(ot,Pt)};O(dt,ot=>{c(u)?ot(gt,-1):ot(we)})}I(ue,He)},Ke=ue=>{var He=As(),dt=xt(He);ni(dt,17,()=>c(x),we=>we.ts+we.msg,(we,gt)=>{var ot=eee(),Pt=b(ot),Oe=b(Pt),Mt=m(Pt,2),et=b(Mt),ct=m(Mt,2),Nt=b(ct);H(ti=>{N(Oe,ti),kt(Mt,1,`badge ${i[c(gt).level]??""}`,"svelte-1yc29ow"),N(et,t[c(gt).level]),N(Nt,c(gt).msg)},[()=>k(c(gt).ts)]),I(we,ot)}),I(ue,He)};O(pe,ue=>{c(x).length===0?ue(je):ue(Ke,-1)})}vs(te,ue=>v(d,ue),()=>c(d)),ms(V,()=>c(r),ue=>v(r,ue)),z("click",se,y),I(o,D),Ps()}zs(["click"]);var nee=T('<div class="err svelte-d31be1"> </div>'),see=T('<div class="step svelte-d31be1"><p class="svelte-d31be1">This wizard will configure the <strong>Mosquitto Dynamic Security plugin</strong> for use with she. It will:</p> <ul class="svelte-d31be1"><li>Create a <code class="svelte-d31be1">she-admin</code> service account with a random strong password.</li> <li>Write <code class="svelte-d31be1">dynamic-security.json</code> to your mosquitto config directory.</li> <li>Add the <code class="svelte-d31be1">plugin</code> line to <code class="svelte-d31be1">mosquitto.conf</code>.</li> <li>Ask you to restart mosquitto to activate the plugin.</li></ul> <p class="hint svelte-d31be1">In <strong>remote mode</strong> (SSH host configured), <code class="svelte-d31be1">mosquitto_ctrl</code> is invoked on the broker host via SSH. In local mode, it must be installed on this machine. <code class="svelte-d31be1">mosquitto_ctrl</code> is part of the <code class="svelte-d31be1">mosquitto</code> package.</p> <div class="actions svelte-d31be1"><button class="svelte-d31be1">Start</button></div></div>'),oee=T('<div class="step svelte-d31be1"><p class="svelte-d31be1"> </p></div>'),ree=T('<div class="step svelte-d31be1"><p class="svelte-d31be1">dynsec is not yet active. Configure bootstrap settings:</p> <label class="svelte-d31be1">Admin username<input class="svelte-d31be1"/></label> <label class="svelte-d31be1">Admin password<input type="password" placeholder="(leave blank to auto-generate)" class="svelte-d31be1"/></label> <label class="svelte-d31be1">Mosquitto config directory<input class="svelte-d31be1"/></label> <div class="actions svelte-d31be1"><button class="svelte-d31be1"> </button></div></div>'),aee=T('<p class="hint svelte-d31be1">Restarting mosquitto… this may take a few seconds.</p>'),lee=T(`<div class="step svelte-d31be1"><div class="ok-banner svelte-d31be1">✓ dynsec files written and credentials saved.</div> <p class="svelte-d31be1">The <code class="svelte-d31be1">plugin</code> line has been added to <code class="svelte-d31be1"> </code>.</p> <p class="svelte-d31be1">Enabling a new plugin requires a <strong>full mosquitto restart</strong> (not just SIGHUP):</p> <div class="actions svelte-d31be1"><button class="btn-warn svelte-d31be1"> </button> <button class="skip-step svelte-d31be1">Skip (I'll restart manually)</button></div> <!></div>`),cee=T('<div class="step svelte-d31be1"><div class="ok-banner svelte-d31be1">✓ dynsec is configured and connected.</div> <p class="svelte-d31be1">she is now managing broker users and ACLs via the Dynamic Security plugin. You can use the <strong>Users & Roles</strong> tab to add users, create roles, and define ACL rules.</p> <div class="actions svelte-d31be1"><button class="btn-primary svelte-d31be1">Done</button></div></div>'),dee=T('<div class="step svelte-d31be1"><p class="svelte-d31be1">Enter the credentials of an existing dynsec admin account:</p> <label class="svelte-d31be1">Admin username<input class="svelte-d31be1"/></label> <label class="svelte-d31be1">Admin password<input type="password" class="svelte-d31be1"/></label> <div class="actions svelte-d31be1"><button class="svelte-d31be1">Back</button> <button class="btn-primary svelte-d31be1"> </button></div></div>'),uee=T('<div class="wizard svelte-d31be1"><div class="wizard-header svelte-d31be1"><h3 class="svelte-d31be1">dynsec Setup Wizard</h3> <button class="skip-btn svelte-d31be1">Manual setup instead</button></div> <!> <!></div>');function hee(o,e){Ts(e,!0);let t=P("intro"),i=P(""),n=P(!1),s=P("she-admin"),r=P(""),a=P("/etc/mosquitto"),d=P(null),u=P(!1),f=P(!1),g=P("she-admin"),p=P(""),w=P(!1);async function y(){v(n,!0),v(i,"");try{(await(await fetch("/she/broker/wizard/probe",{method:"POST",headers:{"Content-Type":"application/json"}})).json()).active?v(t,"done"):v(t,"config")}catch(we){v(i,we.message,!0)}finally{v(n,!1)}}async function x(){v(n,!0),v(i,"");try{const we=await fetch("/she/broker/wizard/bootstrap",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({adminUsername:c(s),adminPassword:c(r)||void 0,configDir:c(a)})}),gt=await we.json();if(!we.ok||!gt.ok)throw new Error(gt.error??"Bootstrap failed");v(d,gt,!0);const ot=await Pl(),Pt=ot.broker??{};await Xp({...ot,broker:{...Pt,dynsec:{adminUsername:gt.adminUsername,adminPassword:gt.adminPassword}}}),await oq().catch(()=>{}),v(t,"restart")}catch(we){v(i,we.message,!0)}finally{v(n,!1)}}async function k(){v(f,!0),v(i,"");try{await nq(),await new Promise(we=>setTimeout(we,2e3)),v(u,!0),v(t,"done")}catch(we){v(i,we.message,!0)}finally{v(f,!1)}}async function D(){v(w,!0),v(i,"");try{const we=await Pl(),gt=we.broker??{};await Xp({...we,broker:{...gt,dynsec:{adminUsername:c(g),adminPassword:c(p)}}}),v(t,"done")}catch(we){v(i,we.message,!0)}finally{v(w,!1)}}var M=uee(),F=b(M),K=m(b(F),2),V=m(F,2);{var se=we=>{var gt=nee(),ot=b(gt);H(()=>N(ot,c(i))),I(we,gt)};O(V,we=>{c(i)&&we(se)})}var te=m(V,2);{var pe=we=>{var gt=see(),ot=m(b(gt),6),Pt=b(ot);H(()=>Pt.disabled=c(n)),z("click",Pt,()=>{v(t,"probe"),y()}),I(we,gt)},je=we=>{var gt=oee(),ot=b(gt),Pt=b(ot);H(()=>N(Pt,c(n)?"Probing dynsec…":"Checking dynsec status…")),I(we,gt)},Ke=we=>{var gt=ree(),ot=m(b(gt),2),Pt=m(b(ot)),Oe=m(ot,2),Mt=m(b(Oe)),et=m(Oe,2),ct=m(b(et)),Nt=m(et,2),ti=b(Nt),ri=b(ti);H(()=>{ti.disabled=c(n)||!c(s),N(ri,c(n)?"Bootstrapping…":"Bootstrap dynsec")}),Ht(Pt,()=>c(s),Vt=>v(s,Vt)),Ht(Mt,()=>c(r),Vt=>v(r,Vt)),Ht(ct,()=>c(a),Vt=>v(a,Vt)),z("click",ti,x),I(we,gt)},ue=we=>{var gt=lee(),ot=m(b(gt),2),Pt=m(b(ot),3),Oe=b(Pt),Mt=m(ot,4),et=b(Mt),ct=b(et),Nt=m(et,2),ti=m(Mt,2);{var ri=Vt=>{var Me=aee();I(Vt,Me)};O(ti,Vt=>{c(f)&&Vt(ri)})}H(()=>{N(Oe,c(d).confFilePath),et.disabled=c(f),N(ct,c(f)?"Restarting…":"Restart mosquitto now")}),z("click",et,k),z("click",Nt,()=>{v(t,"done")}),I(we,gt)},He=we=>{var gt=cee(),ot=m(b(gt),4),Pt=b(ot);z("click",Pt,function(...Oe){var Mt;(Mt=e.onDone)==null||Mt.apply(this,Oe)}),I(we,gt)},dt=we=>{var gt=dee(),ot=m(b(gt),2),Pt=m(b(ot)),Oe=m(ot,2),Mt=m(b(Oe)),et=m(Oe,2),ct=b(et),Nt=m(ct,2),ti=b(Nt);H(()=>{Nt.disabled=c(w)||!c(g)||!c(p),N(ti,c(w)?"Saving…":"Save credentials")}),Ht(Pt,()=>c(g),ri=>v(g,ri)),Ht(Mt,()=>c(p),ri=>v(p,ri)),z("click",ct,()=>v(t,"intro")),z("click",Nt,D),I(we,gt)};O(te,we=>{c(t)==="intro"?we(pe):c(t)==="probe"?we(je,1):c(t)==="config"?we(Ke,2):c(t)==="restart"&&c(d)?we(ue,3):c(t)==="done"?we(He,4):c(t)==="manual"&&we(dt,5)})}z("click",K,()=>v(t,"manual")),I(o,M),Ps()}zs(["click"]);var fee=T('<div class="loading svelte-zuhcpo">Loading…</div>'),gee=T('<div class="error-banner svelte-zuhcpo"> </div>'),pee=T('<div class="conn-row svelte-zuhcpo"><span></span> <span class="conn-name svelte-zuhcpo">dynamic security</span> <span><!></span> <button class="btn-deactivate svelte-zuhcpo"> </button></div>'),_ee=T('<button class="btn-wizard-inline svelte-zuhcpo">Setup Wizard ↗</button>'),mee=T('<div class="conn-row svelte-zuhcpo"><span class="dot dot-off svelte-zuhcpo"></span> <span class="conn-name svelte-zuhcpo">dynamic security</span> <span class="conn-detail muted svelte-zuhcpo">not configured</span> <!></div>'),vee=T('<div class="error-inline svelte-zuhcpo"> </div>'),bee=T('<button class="diag-btn svelte-zuhcpo"> </button>'),PD=T('<p class="diag-issue svelte-zuhcpo"> </p>'),yee=T('<p class="diag-ok-msg svelte-zuhcpo">✓ dynamic-security.json looks correct. Verify mosquitto restarted with the plugin loaded.</p>'),wee=T('<p class="diag-row svelte-zuhcpo"><span class="svelte-zuhcpo">File</span><code class="svelte-zuhcpo"> </code></p> <p class="diag-row svelte-zuhcpo"><span class="svelte-zuhcpo">Admin user exists</span><span> </span></p> <p class="diag-row svelte-zuhcpo"><span class="svelte-zuhcpo">Has admin role</span><span> </span></p> <p class="diag-row svelte-zuhcpo"><span class="svelte-zuhcpo">$CONTROL publish ACL</span><span> </span></p> <!> <!>',1),See=T('<div><!></div> <button class="diag-btn svelte-zuhcpo" style="margin-top:6px"> </button>',1),Cee=T('<button class="wizard-btn svelte-zuhcpo">Run Setup Wizard</button>'),xee=T('<div class="diag-area svelte-zuhcpo"><!> <!></div>'),kee=T('<div class="stats-block svelte-zuhcpo"><dl class="svelte-zuhcpo"><dt class="svelte-zuhcpo">Version</dt><dd class="svelte-zuhcpo"> </dd> <dt class="svelte-zuhcpo">Uptime</dt><dd class="svelte-zuhcpo"> </dd> <dt class="svelte-zuhcpo">Clients</dt><dd class="svelte-zuhcpo"> </dd> <dt class="svelte-zuhcpo">Messages</dt><dd class="svelte-zuhcpo"> </dd> <dt class="svelte-zuhcpo">Topics</dt><dd class="svelte-zuhcpo"> </dd> <dt class="svelte-zuhcpo">Traffic</dt><dd class="svelte-zuhcpo"> </dd></dl></div>'),Lee=T('<div style="margin-top: 20px;"><!></div>'),Iee=T('<div class="status-layout svelte-zuhcpo"><div class="conn-block svelte-zuhcpo"><div class="conn-row svelte-zuhcpo"><span class="dot ok svelte-zuhcpo"></span> <span class="conn-name svelte-zuhcpo">mosquitto</span> <span class="conn-detail svelte-zuhcpo"> </span></div> <!> <!></div> <!> <!></div> <!>',1),Eee=T('<div class="tab-content svelte-zuhcpo"><!></div>'),Dee=T('<div class="broker-page svelte-zuhcpo"><div class="sub-nav svelte-zuhcpo"><button>Status</button> <button>Directory</button> <button>Config</button> <button>Listeners</button> <button>Certificates</button> <button>Connection</button> <button>Logs</button></div> <!></div> <!>',1);function Tee(o,e){Ts(e,!0);let t=P(!1),i,n=P(!1),s=P(""),r=P(!1),a=P(null);const d="she-broker-tab";let u=P(yi(localStorage.getItem(d)??"status"));Vn(()=>{localStorage.setItem(d,c(u))});let f=P(null),g=P(""),p=P(!0);async function w(){try{v(f,await Tk(),!0),v(g,"")}catch(ht){v(g,ht.message??"Failed to load broker status",!0)}finally{v(p,!1)}}Bs(()=>{w();const ht=setInterval(w,1e4);return()=>clearInterval(ht)});async function y(){v(r,!0),v(a,null);try{v(a,await rq(),!0)}catch(ht){v(a,{ok:!1,dynSecPath:"",issues:[ht.message??"Diagnose request failed"]},!0)}finally{v(r,!1)}}async function x(){if(await i.show("Remove dynsec plugin lines from mosquitto.conf and clear credentials? You will need to restart mosquitto afterwards.",{confirm:"Deactivate",danger:!0})){v(n,!0),v(s,"");try{await sq(),await w()}catch(ht){v(s,ht.message??"Deactivate failed",!0)}finally{v(n,!1)}}}function k(ht){var Xe;if(!((Xe=c(f))!=null&&Xe.sys))return"—";const he=c(f).sys[ht];return he?String(he.val??"—"):"—"}function D(ht){if(ht==="—")return ht;const he=ht.match(/^(\d+)/),Xe=he?parseInt(he[1]):NaN;if(isNaN(Xe))return ht;const Ut=Math.floor(Xe/86400),wi=Math.floor(Xe%86400/3600),Ri=Math.floor(Xe%3600/60),ci=Xe%60,Bt=Xt=>String(Xt).padStart(2,"0");return Ut>0?`${Ut}d ${Bt(wi)}:${Bt(Ri)}:${Bt(ci)}`:`${Bt(wi)}:${Bt(Ri)}:${Bt(ci)}`}function M(ht){if(ht==="—")return ht;const he=parseInt(ht);return isNaN(he)?ht:he<1024?`${he} B`:he<1048576?`${(he/1024).toFixed(1)} KB`:he<1073741824?`${(he/1048576).toFixed(1)} MB`:`${(he/1073741824).toFixed(1)} GB`}var F=Dee(),K=xt(F),V=b(K),se=b(V);let te;var pe=m(se,2);let je;var Ke=m(pe,2);let ue;var He=m(Ke,2);let dt;var we=m(He,2);let gt;var ot=m(we,2);let Pt;var Oe=m(ot,2);let Mt;var et=m(V,2);{var ct=ht=>{var he=Eee(),Xe=b(he);{var Ut=ci=>{var Bt=fee();I(ci,Bt)},wi=ci=>{var Bt=gee(),Xt=b(Bt);H(()=>N(Xt,c(g))),I(ci,Bt)},Ri=ci=>{var Bt=Iee(),Xt=xt(Bt),pt=b(Xt),Bi=b(pt),Ti=m(b(Bi),4),Ni=b(Ti),Ki=m(Bi,2);{var Ai=Si=>{var Oi=pee(),qi=b(Oi);let mi;var Ue=m(qi,4);let J;var Qe=b(Ue);{var _t=ke=>{var ze=po("plugin active");I(ke,ze)},yt=ke=>{var ze=po("connected — plugin not responding");I(ke,ze)},Ot=ke=>{var ze=po("disconnected");I(ke,ze)};O(Qe,ke=>{c(f).dynsec.dynsecReady?ke(_t):c(f).dynsec.connected?ke(yt,1):ke(Ot,-1)})}var j=m(Ue,2),ce=b(j);H(()=>{mi=kt(qi,1,"dot svelte-zuhcpo",null,mi,{ok:c(f).dynsec.dynsecReady,warn:c(f).dynsec.connected&&!c(f).dynsec.dynsecReady,"dot-err":!c(f).dynsec.connected}),J=kt(Ue,1,"conn-detail svelte-zuhcpo",null,J,{ok:c(f).dynsec.dynsecReady,warn:c(f).dynsec.connected&&!c(f).dynsec.dynsecReady,err:!c(f).dynsec.connected}),j.disabled=c(n),N(ce,c(n)?"…":"deactivate")}),z("click",j,x),I(Si,Oi)},Di=Si=>{var Oi=mee(),qi=m(b(Oi),6);{var mi=Ue=>{var J=_ee();z("click",J,()=>v(t,!0)),I(Ue,J)};O(qi,Ue=>{c(t)||Ue(mi)})}I(Si,Oi)};O(Ki,Si=>{c(f).dynsec.configured?Si(Ai):Si(Di,-1)})}var $i=m(Ki,2);{var Gi=Si=>{var Oi=vee(),qi=b(Oi);H(()=>N(qi,c(s))),I(Si,Oi)};O($i,Si=>{c(s)&&Si(Gi)})}var Ui=m(pt,2);{var mn=Si=>{var Oi=xee(),qi=b(Oi);{var mi=_t=>{var yt=bee(),Ot=b(yt);H(()=>{yt.disabled=c(r),N(Ot,c(r)?"Running diagnostics…":"Run diagnostics")}),z("click",yt,y),I(_t,yt)},Ue=_t=>{var yt=See(),Ot=xt(yt);let j;var ce=b(Ot);{var ke=ae=>{var me=PD(),Ze=b(me);H(()=>N(Ze,`⚠ ${c(a).error??""}`)),I(ae,me)},ze=ae=>{var me=wee(),Ze=xt(me),Zt=m(b(Ze)),bt=b(Zt),We=m(Ze,2),At=m(b(We)),ai=b(At),zt=m(We,2),vi=m(b(zt)),hi=b(vi),Ci=m(zt,2),zi=m(b(Ci)),$e=b(zi),Fe=m(Ci,2);ni(Fe,17,()=>c(a).issues,Vi,(qt,Qt)=>{var re=PD(),Ge=b(re);H(()=>N(Ge,`⚠ ${c(Qt)??""}`)),I(qt,re)});var Ft=m(Fe,2);{var Yt=qt=>{var Qt=yee();I(qt,Qt)};O(Ft,qt=>{c(a).ok&&qt(Yt)})}H(()=>{N(bt,c(a).dynSecPath),kt(At,1,Kg(c(a).adminClientExists?"ok":"fail"),"svelte-zuhcpo"),N(ai,c(a).adminClientExists?"✓ yes":"✗ no"),kt(vi,1,Kg(c(a).hasAdminRole?"ok":"fail"),"svelte-zuhcpo"),N(hi,c(a).hasAdminRole?"✓ yes":"✗ no"),kt(zi,1,Kg(c(a).hasControlSendAcl?"ok":"fail"),"svelte-zuhcpo"),N($e,c(a).hasControlSendAcl?"✓ present":"✗ missing")}),I(ae,me)};O(ce,ae=>{c(a).error?ae(ke):ae(ze,-1)})}var st=m(Ot,2),X=b(st);H(()=>{j=kt(Ot,1,"diag-card svelte-zuhcpo",null,j,{"diag-ok":c(a).ok,"diag-fail":!c(a).ok}),st.disabled=c(r),N(X,c(r)?"Running…":"Re-run")}),z("click",st,y),I(_t,yt)};O(qi,_t=>{c(a)?_t(Ue,-1):_t(mi)})}var J=m(qi,2);{var Qe=_t=>{var yt=Cee();z("click",yt,()=>v(t,!0)),I(_t,yt)};O(J,_t=>{c(t)||_t(Qe)})}I(Si,Oi)};O(Ui,Si=>{c(f).dynsec.configured&&c(f).dynsec.connected&&!c(f).dynsec.dynsecReady&&Si(mn)})}var rt=m(Ui,2);{var Kt=Si=>{var Oi=kee(),qi=b(Oi),mi=m(b(qi)),Ue=b(mi),J=m(mi,3),Qe=b(J),_t=m(J,3),yt=b(_t),Ot=m(_t,3),j=b(Ot),ce=m(Ot,3),ke=b(ce),ze=m(ce,3),st=b(ze);H((X,ae,me,Ze,Zt,bt,We,At,ai,zt,vi,hi)=>{N(Ue,X),N(Qe,ae),N(yt,`${me??""} connected · ${Ze??""} max · ${Zt??""} total`),N(j,`${bt??""} rcv · ${We??""} sent · ${At??""} stored`),N(ke,`${ai??""} retained · ${zt??""} subscriptions`),N(st,`${vi??""} in · ${hi??""} out`)},[()=>k("$SYS/broker/version"),()=>D(k("$SYS/broker/uptime")),()=>k("$SYS/broker/clients/connected"),()=>k("$SYS/broker/clients/maximum"),()=>k("$SYS/broker/clients/total"),()=>k("$SYS/broker/messages/received"),()=>k("$SYS/broker/messages/sent"),()=>k("$SYS/broker/messages/stored"),()=>k("$SYS/broker/retained messages/count"),()=>k("$SYS/broker/subscriptions/count"),()=>M(k("$SYS/broker/bytes/received")),()=>M(k("$SYS/broker/bytes/sent"))]),I(Si,Oi)},_i=Ct(()=>Object.keys(c(f).sys).length>0);O(rt,Si=>{c(_i)&&Si(Kt)})}var Pi=m(Xt,2);{var Li=Si=>{var Oi=Lee(),qi=b(Oi);hee(qi,{onDone:()=>{v(t,!1),w()}}),I(Si,Oi)};O(Pi,Si=>{c(t)&&(!c(f).dynsec.configured||!c(f).dynsec.dynsecReady)&&Si(Li)})}H(()=>N(Ni,c(f).sshConfigured?`ssh — ${c(f).sshHost}`:"local")),I(ci,Bt)};O(Xe,ci=>{c(p)?ci(Ut):c(g)?ci(wi,1):c(f)&&ci(Ri,2)})}I(ht,he)},Nt=ht=>{{let he=Ct(()=>{var Xe;return((Xe=c(f))==null?void 0:Xe.dynsec.dynsecReady)??!1});XQ(ht,{get dynsecReady(){return c(he)}})}},ti=ht=>{_J(ht,{})},ri=ht=>{uJ(ht,{})},Vt=ht=>{FJ(ht,{})},Me=ht=>{KJ(ht,{})},jt=ht=>{iee(ht,{})};O(et,ht=>{c(u)==="status"?ht(ct):c(u)==="users"?ht(Nt,1):c(u)==="brokerconfig"?ht(ti,2):c(u)==="listeners"?ht(ri,3):c(u)==="certs"?ht(Vt,4):c(u)==="ssh"?ht(Me,5):c(u)==="logs"&&ht(jt,6)})}var ft=m(K,2);vs(Uc(ft,{}),ht=>i=ht,()=>i),H(()=>{te=kt(se,1,"svelte-zuhcpo",null,te,{active:c(u)==="status"}),je=kt(pe,1,"svelte-zuhcpo",null,je,{active:c(u)==="users"}),ue=kt(Ke,1,"svelte-zuhcpo",null,ue,{active:c(u)==="brokerconfig"}),dt=kt(He,1,"svelte-zuhcpo",null,dt,{active:c(u)==="listeners"}),gt=kt(we,1,"svelte-zuhcpo",null,gt,{active:c(u)==="certs"}),Pt=kt(ot,1,"svelte-zuhcpo",null,Pt,{active:c(u)==="ssh"}),Mt=kt(Oe,1,"svelte-zuhcpo",null,Mt,{active:c(u)==="logs"})}),z("click",se,()=>v(u,"status")),z("click",pe,()=>v(u,"users")),z("click",Ke,()=>v(u,"brokerconfig")),z("click",He,()=>v(u,"listeners")),z("click",we,()=>v(u,"certs")),z("click",ot,()=>v(u,"ssh")),z("click",Oe,()=>v(u,"logs")),I(o,F),Ps()}zs(["click"]);var Pee=T('<span class="nav-dot nav-dot--warn svelte-1n46o8q"></span>'),Mee=T('<span class="nav-dot nav-dot--err svelte-1n46o8q" title="MQTT broker not connected"></span>'),Ree=T('<span class="nav-dot nav-dot--warn nav-dot--blink svelte-1n46o8q" title="Waiting for retained MQTT state"></span>'),Nee=T('<span class="nav-dot nav-dot--ok svelte-1n46o8q" title="MQTT connected"></span>'),Aee=T('<span class="nav-dot nav-dot--ok svelte-1n46o8q" title="All Matter devices online"></span>'),Oee=T('<span class="nav-dot nav-dot--warn svelte-1n46o8q" title="Some Matter devices offline"></span>'),Fee=T('<span class="nav-dot nav-dot--err svelte-1n46o8q" title="No Matter devices online"></span>'),Hee=T('<span class="nav-dot nav-dot--err svelte-1n46o8q" title="Errors in recent logs"></span>'),Wee=T('<span class="nav-dot nav-dot--warn svelte-1n46o8q" title="Warnings in recent logs"></span>'),Bee=T('<span class="update-dot svelte-1n46o8q" title="Update available"></span>'),zee=T('<dt class="svelte-1n46o8q">Latest</dt><dd style="color: #f90" class="svelte-1n46o8q"> </dd>',1),Vee=T('<dt class="svelte-1n46o8q">Latest</dt><dd class="svelte-1n46o8q">up to date</dd>',1),jee=T('<button class="svelte-1n46o8q"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><polyline points="4 4 4 10 10 10" class="svelte-1n46o8q"></polyline><path d="M4 10A9 9 0 1 0 6.5 5" class="svelte-1n46o8q"></path></svg> </button>'),$ee=T('<div class="version-popup svelte-1n46o8q"><dl class="svelte-1n46o8q"><dt class="svelte-1n46o8q">Installed</dt><dd class="svelte-1n46o8q"></dd> <!></dl> <div class="version-actions svelte-1n46o8q"><!> <button class="check-btn svelte-1n46o8q" title="Check for updates now"><svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 4 4 10 10 10" class="svelte-1n46o8q"></polyline><path d="M4 10A9 9 0 1 0 6.5 5" class="svelte-1n46o8q"></path></svg> </button></div></div>'),Uee=T('<dt class="svelte-1n46o8q">Uptime</dt><dd class="svelte-1n46o8q"> </dd>',1),qee=T('<dt class="svelte-1n46o8q">Matter nodes</dt><dd class="svelte-1n46o8q"> </dd> <dt class="svelte-1n46o8q">Matter endpoints</dt><dd class="svelte-1n46o8q"> </dd>',1),Gee=T('<dt class="svelte-1n46o8q">DB docs</dt><dd class="svelte-1n46o8q"> </dd> <dt class="svelte-1n46o8q">DB views</dt><dd class="svelte-1n46o8q"> </dd>',1),Kee=T('<dl class="svelte-1n46o8q"><!> <dt class="svelte-1n46o8q">Scripts</dt><dd class="svelte-1n46o8q"> </dd> <dt class="svelte-1n46o8q">MQTT topics</dt><dd class="svelte-1n46o8q"> </dd> <dt class="svelte-1n46o8q">MQTT msg/s</dt><dd class="svelte-1n46o8q"> </dd> <!> <!> <dt class="svelte-1n46o8q">Handlers</dt><dd class="svelte-1n46o8q"> </dd> <dt class="svelte-1n46o8q">Memory</dt><dd class="svelte-1n46o8q"> </dd> <dt class="svelte-1n46o8q">CPU</dt><dd class="svelte-1n46o8q"> </dd></dl>'),Zee=T('<span class="stats-empty svelte-1n46o8q">Loading…</span>'),Yee=T('<button class="svelte-1n46o8q"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><path d="M18.36 6.64a9 9 0 1 1-12.73 0" class="svelte-1n46o8q"></path><line x1="12" y1="2" x2="12" y2="12" class="svelte-1n46o8q"></line></svg> Restart daemon</button>'),Xee=T('<div class="stats-popup svelte-1n46o8q"><!> <div class="stats-actions svelte-1n46o8q"><!></div></div>'),Qee=T('<button class="nav-logout svelte-1n46o8q" title="Logout"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" class="svelte-1n46o8q"></path><polyline points="16 17 21 12 16 7" class="svelte-1n46o8q"></polyline><line x1="21" y1="12" x2="9" y2="12" class="svelte-1n46o8q"></line></svg></button>'),Jee=T('<div class="shell svelte-1n46o8q"><nav class="svelte-1n46o8q"><span class="brand svelte-1n46o8q">she</span> <button><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><polyline points="5,3 1,8 5,13" class="svelte-1n46o8q"></polyline><polyline points="11,3 15,8 11,13" class="svelte-1n46o8q"></polyline></svg> Scripts</button> <button><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square" stroke-linejoin="miter" class="svelte-1n46o8q"><rect x="0.75" y="0.75" width="14.5" height="14.5" rx="1" class="svelte-1n46o8q"></rect><path d="M2,11 V5 H5 V11" class="svelte-1n46o8q"></path><path d="M6,12 V5 H9 V8 H6" class="svelte-1n46o8q"></path><path d="M10,11 V5 H15 V11" class="svelte-1n46o8q"></path><line x1="12.5" y1="5" x2="12.5" y2="11" class="svelte-1n46o8q"></line></svg> Packages <!></button> <button><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" stroke="none" style="vertical-align: middle" class="svelte-1n46o8q"><path fill-rule="evenodd" d="M2,0 H14 A2,2 0 0,1 16,2 V14 A2,2 0 0,1 14,16 H0 V2 A2,2 0 0,1 2,0 Z M0,16 L0,12 A4,4 0 0,1 4,16 Z M0,10.5 A5.5,5.5 0 0,1 5.5,16 L9,16 A9,9 0 0,0 0,7 Z M0,5.5 A10.5,10.5 0 0,1 10.5,16 L13.5,16 A13.5,13.5 0 0,0 0,2.5 Z" class="svelte-1n46o8q"></path></svg> MQTT <!></button> <button><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><circle cx="8" cy="10" r="2" class="svelte-1n46o8q"></circle><path d="M5,7 A4,4 0,0,1 11,7" class="svelte-1n46o8q"></path><path d="M3,5 A6.5,6.5 0,0,1 13,5" class="svelte-1n46o8q"></path><line x1="8" y1="12" x2="8" y2="15" class="svelte-1n46o8q"></line></svg> Broker</button> <button><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><path d="M8,2 L8,7" class="svelte-1n46o8q"></path><path d="M6,5 L8,7.5 L10,5" class="svelte-1n46o8q"></path><path d="M2.5,14 L6,10" class="svelte-1n46o8q"></path><path d="M6.2,12.8 L6,10 L3.2,10.2" class="svelte-1n46o8q"></path><path d="M13.5,14 L10,10" class="svelte-1n46o8q"></path><path d="M9.8,12.8 L10,10 L12.8,10.2" class="svelte-1n46o8q"></path></svg> Matter <!></button> <button><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><ellipse cx="8" cy="4.5" rx="5" ry="1.8" class="svelte-1n46o8q"></ellipse><path d="M3,4.5 v7 a5,1.8 0,0,0 10,0 v-7" class="svelte-1n46o8q"></path><path d="M3,8 a5,1.8 0,0,0 10,0" class="svelte-1n46o8q"></path></svg> DB</button> <button><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" class="svelte-1n46o8q"><line x1="2" y1="5" x2="14" y2="5" class="svelte-1n46o8q"></line><line x1="2" y1="8" x2="14" y2="8" class="svelte-1n46o8q"></line><line x1="2" y1="11" x2="9" y2="11" class="svelte-1n46o8q"></line></svg> Logs <!></button> <div class="nav-spacer svelte-1n46o8q"></div> <div class="nav-right svelte-1n46o8q"><a class="nav-icon svelte-1n46o8q" href="https://github.com/hobbyquaker/she" target="_blank" rel="noopener" title="GitHub"><svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" class="svelte-1n46o8q"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" class="svelte-1n46o8q"></path></svg></a> <div class="version-wrap svelte-1n46o8q"><button class="version svelte-1n46o8q"> <!></button> <!></div> <div class="stats-wrap svelte-1n46o8q"><button class="nav-icon svelte-1n46o8q" title="Daemon status"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><line x1="18" y1="20" x2="18" y2="10" class="svelte-1n46o8q"></line><line x1="12" y1="20" x2="12" y2="4" class="svelte-1n46o8q"></line><line x1="6" y1="20" x2="6" y2="14" class="svelte-1n46o8q"></line></svg></button> <!></div> <button title="Settings"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" class="svelte-1n46o8q"></path><circle cx="12" cy="12" r="3" class="svelte-1n46o8q"></circle></svg></button> <!></div></nav> <main class="svelte-1n46o8q"><!> <div><!></div> <div><!></div> <div><!></div> <div><!></div> <div><!></div> <div><!></div> <div><!></div> <div><!></div></main></div>'),ete=T('<div class="login-error svelte-1n46o8q"> </div>'),tte=T('<div class="login-overlay svelte-1n46o8q"><form class="login-box svelte-1n46o8q"><div class="login-brand svelte-1n46o8q">she</div> <h2 class="svelte-1n46o8q">Sign in</h2> <div class="login-field svelte-1n46o8q"><label for="she-password" class="svelte-1n46o8q">Password</label> <input id="she-password" type="password" placeholder="Enter password" autocomplete="current-password" class="svelte-1n46o8q"/></div> <!> <button type="submit" class="login-btn svelte-1n46o8q"> </button></form></div>'),ite=T('<div class="updating-overlay svelte-1n46o8q"><div class="updating-box svelte-1n46o8q"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><polyline points="4 4 4 10 10 10" class="svelte-1n46o8q"></polyline><path d="M4 10A9 9 0 1 0 6.5 5" class="svelte-1n46o8q"></path></svg> Restarting smart-home-engine…</div></div>'),nte=T('<div class="updating-overlay svelte-1n46o8q"><div class="updating-box svelte-1n46o8q"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-1n46o8q"><polyline points="4 4 4 10 10 10" class="svelte-1n46o8q"></polyline><path d="M4 10A9 9 0 1 0 6.5 5" class="svelte-1n46o8q"></path></svg> Updating smart-home-engine…</div></div>'),ste=T("<!> <!> <!> <!>",1);function ote(o,e){Ts(e,!0);const t=["scripts","mqtt","matter","security","db","logs","config","packages"];function i(){const ft=location.hash.slice(1);return t.includes(ft)?ft:"scripts"}let n=P(yi(i())),s=P(null),r=P(!1),a=P(!1),d=P(!1),u=P(!1),f=P("none"),g=P(""),p=P(!1),w=P(""),y=P(""),x=P(!1),k=P(!1);kU(()=>{v(p,!0)});async function D(){v(y,""),v(x,!0);try{await EU(c(w)),v(w,""),v(p,!1)}catch(ft){v(y,ft.message??"Login failed",!0)}finally{v(x,!1)}}async function M(){if(c(f)==="proxy"&&c(g)){window.location.href=c(g);return}await DU(),v(p,!0)}let F=P(null),K=P(!1),V=P(!1),se=P(!1),te=P(!1),pe=P(yi([])),je=P(0),Ke=P(yi([]));const ue=Ct(()=>c(Ke).filter(ft=>ft.online).length),He=Ct(()=>c(Ke).length===0?"none":c(ue)===c(Ke).length?"all":c(ue)>0?"some":"offline");let dt=P(!1),we=P(!1);async function gt(){if(!await c(F).show("Restart the she daemon? The page will reload after a moment.",{confirm:"Restart"}))return;v(K,!0);let ft;try{ft=(await Wg()).startedAt}catch{}try{await UN()}catch{}const ht=Date.now()+6e4;for(;Date.now()<ht;){await new Promise(he=>setTimeout(he,250));try{const he=await Wg();if(ft===void 0||he.startedAt!==ft){location.reload();return}}catch{}}location.reload()}async function ot(){v(d,!0);try{const ft=await AU();c(s)&&v(s,{...c(s),latestVersion:ft.latestVersion??void 0},!0)}catch{}finally{v(d,!1)}}async function Pt(){var he,Xe;if(!await c(F).show(`Update to v${(he=c(s))==null?void 0:he.latestVersion}? The daemon will restart after the update completes.`,{confirm:"Update"}))return;v(a,!1),v(u,!0);const ft=(Xe=c(s))==null?void 0:Xe.startedAt;try{await NU()}catch{}const ht=Date.now()+18e4;for(;Date.now()<ht;){await new Promise(Ut=>setTimeout(Ut,1e3));try{const Ut=await Wg();if(ft===void 0||Ut.startedAt!==ft){location.reload();return}}catch{v(u,!1),v(K,!0)}}location.reload()}function Oe(ft){v(n,ft,!0),location.hash=ft}Bs(async()=>{location.hash||(location.hash=c(n));const ft=()=>{v(n,i(),!0)};window.addEventListener("hashchange",ft);try{const Bt=await IU();v(f,Bt.mode,!0),v(g,Bt.proxyLogoutUrl??"",!0),c(f)==="password"&&(await fetch("/she/scripts")).status===401&&v(p,!0)}catch{}v(k,!0);async function ht(){try{v(s,await Wg(),!0)}catch{}try{const[Bt,Xt]=await Promise.all([KN(),Pl()]);v(pe,Array.isArray(Xt.pinnedPackages)?Xt.pinnedPackages:[],!0),v(je,Object.keys(Bt).filter(pt=>!c(pe).includes(pt)).length,!0)}catch{}}ht();const he=setInterval(ht,5e3),Xe=cr("mqtt:status",Bt=>{Bt.connected===!1?(v(te,!0),v(V,!1),v(se,!1)):(v(te,!1),v(V,Bt.ready===!1),v(se,Bt.ready===!0))}),Ut=cr("matter:deviceList",Bt=>{Array.isArray(Bt.devices)&&v(Ke,Bt.devices.map(Xt=>({nodeId:String(Xt.nodeId),online:!!Xt.online})),!0)}),wi=cr("matter:deviceStatus",Bt=>{if(Bt.nodeId===void 0)return;const Xt=String(Bt.nodeId),pt=!!Bt.online;v(Ke,c(Ke).map(Bi=>Bi.nodeId===Xt?{...Bi,online:pt}:Bi),!0)}),Ri=aA();v(dt,Ri.some(Bt=>Bt.level==="error"),!0),v(we,!c(dt)&&Ri.some(Bt=>Bt.level==="warn"),!0);const ci=Rk(Bt=>{Bt.level==="error"?(v(dt,!0),v(we,!1)):Bt.level==="warn"&&!c(dt)&&v(we,!0)});return()=>{window.removeEventListener("hashchange",ft),clearInterval(he),Xe(),Ut(),wi(),ci()}});var Mt=ste();ds("click",NP,()=>{c(r)&&v(r,!1),c(a)&&v(a,!1)});var et=xt(Mt);{var ct=ft=>{var ht=Jee(),he=b(ht),Xe=m(b(he),2);let Ut;var wi=m(Xe,2);let Ri;var ci=m(b(wi),2);{var Bt=A=>{var G=Pee();H(()=>ln(G,"title",`${c(je)??""} package update${c(je)===1?"":"s"} available`)),I(A,G)};O(ci,A=>{c(je)>0&&A(Bt)})}var Xt=m(wi,2);let pt;var Bi=m(b(Xt),2);{var Ti=A=>{var G=Mee();I(A,G)},Ni=A=>{var G=Ree();I(A,G)},Ki=A=>{var G=Nee();I(A,G)};O(Bi,A=>{c(te)?A(Ti):c(V)?A(Ni,1):c(se)&&A(Ki,2)})}var Ai=m(Xt,2);let Di;var $i=m(Ai,2);let Gi;var Ui=m(b($i),2);{var mn=A=>{var G=Aee();I(A,G)},rt=A=>{var G=Oee();I(A,G)},Kt=A=>{var G=Fee();I(A,G)};O(Ui,A=>{c(He)==="all"?A(mn):c(He)==="some"?A(rt,1):c(He)==="offline"&&A(Kt,2)})}var _i=m($i,2);let Pi;var Li=m(_i,2);let Si;var Oi=m(b(Li),2);{var qi=A=>{var G=Hee();I(A,G)},mi=A=>{var G=Wee();I(A,G)};O(Oi,A=>{c(dt)?A(qi):c(we)&&A(mi,1)})}var Ue=m(Li,4),J=m(b(Ue),2),Qe=b(J),_t=b(Qe);_t.nodeValue="v1.8.1 ";var yt=m(_t);{var Ot=A=>{var G=Bee();I(A,G)};O(yt,A=>{var G,ie;(G=c(s))!=null&&G.latestVersion&&!((ie=c(s))!=null&&ie.docker)&&A(Ot)})}var j=m(Qe,2);{var ce=A=>{var G=$ee(),ie=b(G),fe=m(b(ie));fe.textContent="v1.8.1";var Y=m(fe,2);{var le=De=>{var Ie=zee(),St=m(xt(Ie)),mt=b(St);H(()=>N(mt,`v${c(s).latestVersion??""}`)),I(De,Ie)},Re=De=>{var Ie=Vee();I(De,Ie)};O(Y,De=>{var Ie;(Ie=c(s))!=null&&Ie.latestVersion?De(le):De(Re,-1)})}var _e=m(ie,2),ge=b(_e);{var tt=De=>{var Ie=jee(),St=m(b(Ie));H(()=>N(St,` Update to v${c(s).latestVersion??""}`)),z("click",Ie,Pt),I(De,Ie)};O(ge,De=>{var Ie;(Ie=c(s))!=null&&Ie.latestVersion&&De(tt)})}var U=m(ge,2),ne=b(U);let Le;var Ve=m(ne);H(()=>{U.disabled=c(d),Le=kt(ne,0,"svelte-1n46o8q",null,Le,{spinning:c(d)}),N(Ve,` ${c(d)?"Checking…":"Check for updates"}`)}),z("click",G,De=>De.stopPropagation()),z("click",U,ot),I(A,G)};O(j,A=>{var G;c(a)&&!((G=c(s))!=null&&G.docker)&&A(ce)})}var ke=m(J,2),ze=b(ke),st=m(ze,2);{var X=A=>{var G=Xee(),ie=b(G);{var fe=ge=>{var tt=Kee(),U=b(tt);{var ne=at=>{const ut=Ct(()=>Math.floor((Date.now()-c(s).startedAt)/1e3)),Je=Ct(()=>Math.floor(c(ut)/86400)),$t=Ct(()=>Math.floor(c(ut)%86400/3600)),Jt=Ct(()=>Math.floor(c(ut)%3600/60));var Mi=Uee(),ii=m(xt(Mi)),xi=b(ii);H(()=>N(xi,`${c(Je)>0?c(Je)+"d ":""}${c($t)>0||c(Je)>0?c($t)+"h ":""}${c(Jt)??""}m`)),I(at,Mi)};O(U,at=>{c(s).startedAt&&at(ne)})}var Le=m(U,3),Ve=b(Le),De=m(Le,3),Ie=b(De),St=m(De,3),mt=b(St),qe=m(St,2);{var Tt=at=>{var ut=qee(),Je=m(xt(ut)),$t=b(Je),Jt=m(Je,3),Mi=b(Jt);H(()=>{N($t,c(s).matterNodes??0),N(Mi,c(s).matterEndpoints??0)}),I(at,ut)};O(qe,at=>{c(s).matterEnabled&&at(Tt)})}var it=m(qe,2);{var ye=at=>{var ut=Gee(),Je=m(xt(ut)),$t=b(Je),Jt=m(Je,3),Mi=b(Jt);H(()=>{N($t,c(s).dbDocs??"—"),N(Mi,c(s).dbViews??"—")}),I(at,ut)};O(it,at=>{c(s).dbEnabled&&at(ye)})}var Ne=m(it,3),Ee=b(Ne),Se=m(Ne,3),nt=b(Se),de=m(Se,3),Pe=b(de);H(()=>{N(Ve,c(s).scripts),N(Ie,c(s).topics),N(mt,c(s).mqttMsgPerSec??"—"),N(Ee,c(s).handlers??"—"),N(nt,c(s).memMb!=null?c(s).memMb+" MB":"—"),N(Pe,c(s).cpuPercent!=null?c(s).cpuPercent+" %":"—")}),I(ge,tt)},Y=ge=>{var tt=Zee();I(ge,tt)};O(ie,ge=>{c(s)?ge(fe):ge(Y,-1)})}var le=m(ie,2),Re=b(le);{var _e=ge=>{var tt=Yee();z("click",tt,()=>{v(r,!1),gt()}),I(ge,tt)};O(Re,ge=>{var tt;(tt=c(s))!=null&&tt.docker||ge(_e)})}z("click",G,ge=>ge.stopPropagation()),I(A,G)};O(st,A=>{c(r)&&A(X)})}var ae=m(ke,2);let me;var Ze=m(ae,2);{var Zt=A=>{var G=Qee();z("click",G,M),I(A,G)};O(Ze,A=>{c(f)==="password"&&A(Zt)})}var bt=m(he,2),We=b(bt);vs(Uc(We,{}),A=>v(F,A,!0),()=>c(F));var At=m(We,2);let ai;var zt=b(At);{let A=Ct(()=>c(n)==="scripts");RK(zt,{get active(){return c(A)}})}var vi=m(At,2);let hi;var Ci=b(vi);_Q(Ci,{});var zi=m(vi,2);let $e;var Fe=b(zi);XX(Fe,{});var Ft=m(zi,2);let Yt;var qt=b(Ft);_X(qt,{});var Qt=m(Ft,2);let re;var Ge=b(Qt);Tee(Ge,{});var wt=m(Qt,2);let vt;var di=b(wt);LY(di,{});var It=m(wt,2);let Ii;var W=b(It);vZ(W,{});var Q=m(It,2);let oe;var $=b(Q);SZ($,{}),H(()=>{Ut=kt(Xe,1,"svelte-1n46o8q",null,Ut,{active:c(n)==="scripts"}),Ri=kt(wi,1,"svelte-1n46o8q",null,Ri,{active:c(n)==="packages"}),pt=kt(Xt,1,"svelte-1n46o8q",null,pt,{active:c(n)==="mqtt"}),Di=kt(Ai,1,"svelte-1n46o8q",null,Di,{active:c(n)==="security"}),Gi=kt($i,1,"svelte-1n46o8q",null,Gi,{active:c(n)==="matter"}),Pi=kt(_i,1,"svelte-1n46o8q",null,Pi,{active:c(n)==="db"}),Si=kt(Li,1,"svelte-1n46o8q",null,Si,{active:c(n)==="logs"}),me=kt(ae,1,"nav-settings svelte-1n46o8q",null,me,{active:c(n)==="config"}),ai=kt(At,1,"page-wrap svelte-1n46o8q",null,ai,{hidden:c(n)!=="scripts"}),hi=kt(vi,1,"page-wrap svelte-1n46o8q",null,hi,{hidden:c(n)!=="packages"}),$e=kt(zi,1,"page-wrap svelte-1n46o8q",null,$e,{hidden:c(n)!=="mqtt"}),Yt=kt(Ft,1,"page-wrap svelte-1n46o8q",null,Yt,{hidden:c(n)!=="matter"}),re=kt(Qt,1,"page-wrap svelte-1n46o8q",null,re,{hidden:c(n)!=="security"}),vt=kt(wt,1,"page-wrap svelte-1n46o8q",null,vt,{hidden:c(n)!=="db"}),Ii=kt(It,1,"page-wrap svelte-1n46o8q",null,Ii,{hidden:c(n)!=="config"}),oe=kt(Q,1,"page-wrap svelte-1n46o8q",null,oe,{hidden:c(n)!=="logs"})}),z("click",Xe,()=>Oe("scripts")),z("click",wi,()=>Oe("packages")),z("click",Xt,()=>Oe("mqtt")),z("click",Ai,()=>Oe("security")),z("click",$i,()=>Oe("matter")),z("click",_i,()=>Oe("db")),z("click",Li,()=>{Oe("logs"),v(dt,!1),v(we,!1)}),z("click",Qe,A=>{A.stopPropagation(),v(a,!c(a)),v(r,!1)}),z("click",ze,A=>{A.stopPropagation(),v(r,!c(r)),v(a,!1)}),z("click",ae,()=>Oe("config")),I(ft,ht)};O(et,ft=>{c(k)&&!c(p)&&ft(ct)})}var Nt=m(et,2);{var ti=ft=>{var ht=tte(),he=b(ht),Xe=m(b(he),4),Ut=m(b(Xe),2),wi=m(Xe,2);{var Ri=Xt=>{var pt=ete(),Bi=b(pt);H(()=>N(Bi,c(y))),I(Xt,pt)};O(wi,Xt=>{c(y)&&Xt(Ri)})}var ci=m(wi,2),Bt=b(ci);H(()=>{Ut.disabled=c(x),ci.disabled=c(x)||!c(w),N(Bt,c(x)?"Signing in…":"Sign in")}),ds("submit",he,Xt=>{Xt.preventDefault(),D()}),Ht(Ut,()=>c(w),Xt=>v(w,Xt)),I(ft,ht)};O(Nt,ft=>{c(p)&&ft(ti)})}var ri=m(Nt,2);{var Vt=ft=>{var ht=ite();I(ft,ht)};O(ri,ft=>{c(K)&&ft(Vt)})}var Me=m(ri,2);{var jt=ft=>{var ht=nte();I(ft,ht)};O(Me,ft=>{c(u)&&ft(jt)})}I(o,Mt),Ps()}zs(["click"]);UH(ote,{target:document.getElementById("app")});export{fM as t};