import{vb as m}from"./chunk-2wrs9p57.js";var U="AWS_PROFILE";var X=(o)=>o.profile||process.env.AWS_PROFILE||"default";import{join as H}from"path";import{homedir as D}from"os";import{sep as T}from"path";var h={},A=()=>{if(process&&process.geteuid)return`${process.geteuid()}`;return"DEFAULT"},f=()=>{let{HOME:o,USERPROFILE:e,HOMEPATH:t,HOMEDRIVE:r=`C:${T}`}=process.env;if(o)return o;if(e)return e;if(t)return`${r}${t}`;let i=A();if(!h[i])h[i]=D();return h[i]};var N="AWS_CONFIG_FILE",u=()=>process.env[N]||H(f(),".aws","config");import{join as O}from"path";var S=(o)=>Object.entries(o).filter(([e])=>{let t=e.indexOf(c);if(t===-1)return!1;return Object.values(m).includes(e.substring(0,t))}).reduce((e,[t,r])=>{let i=t.indexOf(c),s=t.substring(0,i)===m.PROFILE?t.substring(i+1):t;return e[s]=r,e},{...o.default&&{default:o.default}});import{join as L}from"path";var w="AWS_SHARED_CREDENTIALS_FILE",E=()=>process.env[w]||L(f(),".aws","credentials");var b=/^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/,v=["__proto__","profile __proto__"],l=(o)=>{let e={},t,r;for(let i of o.split(/\r?\n/)){let s=i.split(/(^|\s)[;#]/)[0].trim();if(s[0]==="["&&s[s.length-1]==="]"){t=void 0,r=void 0;let n=s.substring(1,s.length-1),p=b.exec(n);if(p){let[,a,,d]=p;if(Object.values(m).includes(a))t=[a,d].join(c)}else t=n;if(v.includes(n))throw new Error(`Found invalid profile name "${n}"`)}else if(t){let n=s.indexOf("=");if(![0,-1].includes(n)){let[p,a]=[s.substring(0,n).trim(),s.substring(n+1).trim()];if(a==="")r=p;else{if(r&&i.trimStart()===i)r=void 0;e[t]=e[t]||{};let d=r?[r,p].join(c):p;e[t][d]=a}}}}return e};import{promises as j}from"fs";var{readFile:y}=j,x={},g=(o,e)=>{if(!x[o]||e?.ignoreCache)x[o]=y(o,"utf8");return x[o]};var _=()=>({}),c=".",C=async(o={})=>{let{filepath:e=E(),configFilepath:t=u()}=o,r=f(),i="~/",s=e;if(e.startsWith("~/"))s=O(r,e.slice(2));let F=t;if(t.startsWith("~/"))F=O(r,t.slice(2));let n=await Promise.all([g(F,{ignoreCache:o.ignoreCache}).then(l).then(S).catch(_),g(s,{ignoreCache:o.ignoreCache}).then(l).catch(_)]);return{configFile:n[0],credentialsFile:n[1]}};var I=(o)=>Object.entries(o).filter(([e])=>e.startsWith(m.SSO_SESSION+c)).reduce((e,[t,r])=>({...e,[t.substring(t.indexOf(c)+1)]:r}),{});var $=()=>({}),Ie=async(o={})=>g(o.configFilepath??u()).then(l).then(I).catch($);var P=(...o)=>{let e={};for(let t of o)for(let[r,i]of Object.entries(t))if(e[r]!==void 0)Object.assign(e[r],i);else e[r]=i;return e};var Ae=async(o)=>{let e=await C(o);return P(e.configFile,e.credentialsFile)};import{createHash as G}from"crypto";import{join as W}from"path";var R=(o)=>{let t=G("sha1").update(o).digest("hex");return W(f(),".aws","sso","cache",`${t}.json`)};import{promises as K}from"fs";var{readFile:V}=K,ye=async(o)=>{let e=R(o),t=await V(e,"utf8");return JSON.parse(t)};export{U as kb,X as lb,R as mb,ye as nb,c as ob,C as pb,Ie as qb,Ae as rb};
