import{A as e,lt as t,n,o as r,r as i,s as a,u as o}from"./vscode-api-DjORcpSo.js";import{n as s,t as c}from"./recommended-skill-statsig-overrides-BAP3bvNU.js";var l=t();function u(t){let u=(0,l.c)(29),{hostId:f,loadOnMount:p}=t,m=p===void 0?!0:p,h=e(),g=s(),_;u[0]===f?_=u[1]:(_=i(`recommended-skills`,{hostId:f,refresh:!1}),u[0]=f,u[1]=_);let v=_,y;u[2]===f?y=u[3]:(y={hostId:f,refresh:!1},u[2]=f,u[3]=y);let b;u[4]===m?b=u[5]:(b={enabled:m,staleTime:o.FIVE_MINUTES},u[4]=m,u[5]=b);let x;u[6]!==y||u[7]!==b?(x={params:y,queryConfig:b},u[6]=y,u[7]=b,u[8]=x):x=u[8];let S=r(`recommended-skills`,x),C=S.data?.error??(S.error?String(S.error.message??S.error):null),w=a(`install-recommended-skill`),T;u[9]!==f||u[10]!==h||u[11]!==v?(T=async()=>{let e=await n(`recommended-skills`,{params:{hostId:f,refresh:!0}});h.setQueryData(v,e)},u[9]=f,u[10]=h,u[11]=v,u[12]=T):T=u[12];let E=T,D=d,O;u[13]!==f||u[14]!==S.data?.skills||u[15]!==h||u[16]!==v?(O=async e=>{let t=D(S.data?.skills??[],e);if(t)return t;let r=await n(`recommended-skills`,{params:{hostId:f,refresh:!1}});return h.setQueryData(v,r),D(r.skills,e)},u[13]=f,u[14]=S.data?.skills,u[15]=h,u[16]=v,u[17]=O):O=u[17];let k=O,A;u[18]!==f||u[19]!==w||u[20]!==g?(A=async e=>{let{skill:t,installRoot:n}=e,r=n===void 0?null:n;return w.mutateAsync({hostId:f,skillId:t.id,repoPath:t.repoPath,installRoot:r,skillStatsigOverride:c(g,t.id)})},u[18]=f,u[19]=w,u[20]=g,u[21]=A):A=u[21];let j=A,M;return u[22]!==k||u[23]!==C||u[24]!==j||u[25]!==S.data||u[26]!==S.isLoading||u[27]!==E?(M={data:S.data,errorMessage:C,isLoading:S.isLoading,refresh:E,ensureSkillByName:k,installSkill:j},u[22]=k,u[23]=C,u[24]=j,u[25]=S.data,u[26]=S.isLoading,u[27]=E,u[28]=M):M=u[28],M}function d(e,t){let n=t.toLowerCase();return e.find(e=>{let t=e.name.toLowerCase(),r=e.id.toLowerCase();return t===n||r===n})??null}export{u as t};
//# sourceMappingURL=use-recommended-skills-Bl4XVaOp.js.map