import{kc as Z,lc as _,mc as $,pc as O}from"./cli-0.5.3-7mzx7yy1.mjs";import{Gc as Y,Lc as x}from"./cli-0.5.3-jxz68zfe.mjs";import{VH as U,_H as W,dI as S,eI as X,oI as V}from"./cli-0.5.3-jbzr8k4s.mjs";import{Nfa as R,Qfa as K}from"./cli-0.5.3-n3cxyxpg.mjs";import{Ega as Q,Lga as C}from"./cli-0.5.3-c8bcrqa4.mjs";x();K();C();V();S();O();function b(G,J,L){let H=new Set(J.plugins.map((z)=>z.name)),A=`@${L}`,q=[];for(let z of Object.keys(G.plugins)){if(!z.endsWith(A))continue;let h=z.slice(0,-A.length);if(!H.has(h))q.push(z)}return q}async function F(){await Z();let G=X(),J=_(),L=await U(),H=[];for(let A of Object.keys(L))try{let q=await W(A);if(!q.forceRemoveDeletedPlugins)continue;let z=b(G,q,A);for(let h of z){if(h in J)continue;let T=G.plugins[h]??[];if(!T.some((B)=>B.scope==="user"||B.scope==="project"||B.scope==="local"))continue;for(let B of T){let{scope:E}=B;if(E!=="user"&&E!=="project"&&E!=="local")continue;try{await Y(h,E)}catch(v){R(`Failed to auto-uninstall delisted plugin ${h} from ${E}: ${Q(v)}`,{level:"error"})}}await $(h),H.push(h)}}catch(q){R(`Failed to check for delisted plugins in "${A}": ${Q(q)}`,{level:"warn"})}return H}
export{F as jb};
