import{kc as Z,lc as _,mc as $,pc as O}from"./cli-0.5.4-5j99cwqy.mjs";import{Gc as Y,Lc as x}from"./cli-0.5.4-q7qfy21z.mjs";import{XH as U,aI as W,fI as S,gI as X,qI as V}from"./cli-0.5.4-k5fz4zd3.mjs";import{Pfa as R,Sfa as K}from"./cli-0.5.4-end8wj9r.mjs";import{Gga as Q,Nga as C}from"./cli-0.5.4-sgcaw17t.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};
