import{s as e}from"./chunk-Bj-mKKzh.js";import{fs as t,qo as n,v as r}from"./app-server-manager-signals-Yn0WSnoY.js";import{n as i}from"./jsx-runtime-CiQ1k8xo.js";import{A as a,I as o,lt as s,u as c,v as l}from"./vscode-api-DjORcpSo.js";import{d as u}from"./thread-context-inputs-C9hcxtXy.js";import{t as d}from"./use-register-command-yA_5KLgb.js";var f=s(),p=e(i(),1),m=[`skills`];function h(e,i,s){let h=(0,f.c)(40),_=o(r),v=i??_,y=a(),[b]=n(`skills_refresh_nonce`),x=o(u),S=e===void 0;x.data?.roots;let C;bb0:{if(Array.isArray(e)){C=e;break bb0}if(typeof e==`string`){let t;h[0]===e?t=h[1]:(t=[e],h[0]=e,h[1]=t),C=t;break bb0}let t;h[2]===x.data?.roots?t=h[3]:(t=x.data?.roots??[],h[2]=x.data?.roots,h[3]=t),C=t}let w=C,T=(s?.enabled??!0)&&(e!==void 0||x.isFetched),E;h[4]!==v||h[5]!==w?(E=[...m,v,w],h[4]=v,h[5]=w,h[6]=E):E=h[6];let D=E,O;h[7]!==v||h[8]!==w?(O=()=>t(`list-skills-for-host`,{hostId:v,cwds:w}),h[7]=v,h[8]=w,h[9]=O):O=h[9];let k;h[10]!==T||h[11]!==D||h[12]!==O?(k={queryKey:D,queryFn:O,enabled:T,staleTime:c.FIVE_MINUTES,gcTime:1/0},h[10]=T,h[11]=D,h[12]=O,h[13]=k):k=h[13];let A=l(k);A.data?.data;let j;h[14]===A.data?.data?j=h[15]:(j=A.data?.data??[],h[14]=A.data?.data,h[15]=j);let M=j,N;h[16]===M?N=h[17]:(N=M.flatMap(g),h[16]=M,h[17]=N);let P=N,F,I;h[18]!==y||h[19]!==b?(F=()=>{b!=null&&y.invalidateQueries({queryKey:m})},I=[b,y],h[18]=y,h[19]=b,h[20]=F,h[21]=I):(F=h[20],I=h[21]),(0,p.useEffect)(F,I);let L;h[22]!==v||h[23]!==y||h[24]!==w||h[25]!==D?(L=async function(){let e=await t(`list-skills-for-host`,{hostId:v,cwds:w,forceReload:!0});y.setQueryData(D,e)},h[22]=v,h[23]=y,h[24]=w,h[25]=D,h[26]=L):L=h[26];let R=L,z;h[27]===R?z=h[28]:(z=()=>{R()},h[27]=R,h[28]=z),d(`forceReloadSkills`,z);let B;h[29]===P?B=h[30]:(B=e=>{let t=e.toLowerCase();return P.find(e=>e.name.toLowerCase()===t)??null},h[29]=P,h[30]=B);let V=B,H=S&&x.isLoading||A.isLoading,U=S&&x.isFetching||A.isFetching,W;h[31]===A?W=h[32]:(W=()=>A.refetch(),h[31]=A,h[32]=W);let G;return h[33]!==V||h[34]!==R||h[35]!==P||h[36]!==H||h[37]!==U||h[38]!==W?(G={skills:P,isLoading:H,isFetching:U,refetch:W,forceReload:R,findSkillByName:V},h[33]=V,h[34]=R,h[35]=P,h[36]=H,h[37]=U,h[38]=W,h[39]=G):G=h[39],G}function g(e){return e.skills}export{h as n,m as t};
//# sourceMappingURL=use-skills-BVPQeZVw.js.map