import{ho as e}from"./app-server-manager-signals-Yn0WSnoY.js";import{lt as t,o as n}from"./vscode-api-DjORcpSo.js";import{n as r}from"./react-0SBwfqBm.js";import{t as i}from"./persisted-atom-D9Fx3rWR.js";import{n as a}from"./local-environments-D9wWZVb1.js";var o=t(),s=i(`local-env-selections-by-workspace`,{});function c(t){let n=a(t),r=n?.configPath??null,i=r?e(r):null;return{defaultEnvironment:n,defaultEnvironmentNormalized:i,availableEnvironments:i?t.filter(t=>e(t.configPath)!==i):t}}function l(t,n){return!t||t===`/`?null:`${n}:${e(t)}`}function u({canValidateSelection:t,environments:n,hostId:r,selectionsByWorkspace:i,workspaceRoot:a}){let o=l(a,r),{defaultEnvironment:s,defaultEnvironmentNormalized:u,availableEnvironments:d}=c(n),f=s?.configPath??null,p=o!=null&&Object.prototype.hasOwnProperty.call(i,o),m=null;o&&p&&(m=i[o]??null);let h=m?e(m):null,g=t&&h!=null&&n.some(t=>e(t.configPath)===h),_=p?m:null;t&&p&&m!=null&&!g&&(_=f);let v=_?e(_):null;return{workspaceKey:o,defaultEnvironment:s,defaultEnvironmentNormalized:u,availableEnvironments:d,resolvedConfigPath:_,normalizedResolvedConfigPath:v}}function d({selectionsByWorkspace:e,setSelectionsByWorkspace:t,hostId:n,workspaceRoot:r,configPath:i}){let a=l(r,n);a&&t({...e,[a]:i})}function f(e){let t=(0,o.c)(37),{hostId:i,workspaceRoot:a}=e,[c,f]=r(s),m;t[0]!==i||t[1]!==a?(m=l(a,i),t[0]=i,t[1]=a,t[2]=m):m=t[2];let h=m,g=a??``,_;t[3]!==i||t[4]!==g?(_={hostId:i,workspaceRoot:g},t[3]=i,t[4]=g,t[5]=_):_=t[5];let v=h!=null,y;t[6]===v?y=t[7]:(y={enabled:v},t[6]=v,t[7]=y);let b;t[8]!==_||t[9]!==y?(b={params:_,queryConfig:y,select:p},t[8]=_,t[9]=y,t[10]=b):b=t[10];let{data:x,isLoading:S,isFetching:C,error:w}=n(`local-environments`,b),T,E;t[11]!==w||t[12]!==i||t[13]!==C||t[14]!==S||t[15]!==x||t[16]!==c||t[17]!==a?(T=x??[],E=u({canValidateSelection:!S&&!C&&w==null,environments:T,hostId:i,selectionsByWorkspace:c,workspaceRoot:a}),t[11]=w,t[12]=i,t[13]=C,t[14]=S,t[15]=x,t[16]=c,t[17]=a,t[18]=T,t[19]=E):(T=t[18],E=t[19]);let{workspaceKey:D,defaultEnvironment:O,defaultEnvironmentNormalized:k,availableEnvironments:A,resolvedConfigPath:j,normalizedResolvedConfigPath:M}=E,N;t[20]!==i||t[21]!==c||t[22]!==f||t[23]!==a?(N=e=>{d({selectionsByWorkspace:c,setSelectionsByWorkspace:f,hostId:i,workspaceRoot:a,configPath:e})},t[20]=i,t[21]=c,t[22]=f,t[23]=a,t[24]=N):N=t[24];let P=N,F;return t[25]!==A||t[26]!==O||t[27]!==k||t[28]!==T||t[29]!==w||t[30]!==C||t[31]!==S||t[32]!==M||t[33]!==j||t[34]!==D||t[35]!==P?(F={workspaceKey:D,environments:T,isLoading:S,isFetching:C,error:w,defaultEnvironment:O,defaultEnvironmentNormalized:k,availableEnvironments:A,resolvedConfigPath:j,normalizedResolvedConfigPath:M,updateSelection:P},t[25]=A,t[26]=O,t[27]=k,t[28]=T,t[29]=w,t[30]=C,t[31]=S,t[32]=M,t[33]=j,t[34]=D,t[35]=P,t[36]=F):F=t[36],F}function p(e){return e.environments}export{u as n,f as r,s as t};
//# sourceMappingURL=local-environment-selection-LAZtypYc.js.map