import{lb as d,pb as g}from"./chunk-cs5k02gt.js";import{Bb as s,Db as y,Eb as u,Fb as C}from"./chunk-3wpw5xgd.js";function c(o){try{let r=new Set(Array.from(o.match(/([A-Z_]){3,}/g)??[]));return r.delete("CONFIG"),r.delete("CONFIG_PREFIX_SEPARATOR"),r.delete("ENV"),[...r].join(", ")}catch(r){return o}}var l=(o,r)=>async()=>{try{let t=o(process.env);if(t===void 0)throw new Error;return t}catch(t){throw new s(t.message||`Not found in ENV: ${c(o.toString())}`,{logger:r})}};var h=(o,{preferredFile:r="config",...t}={})=>async()=>{let e=d(t),{configFile:n,credentialsFile:i}=await g(t),f=i[e]||{},m=n[e]||{},S=r==="config"?{...f,...m}:{...m,...f};try{let p=o(S,r==="config"?n:i);if(p===void 0)throw new Error;return p}catch(a){throw new s(a.message||`Not found in config files w/ profile [${e}]: ${c(o.toString())}`,{logger:t.logger})}};var E=(o)=>typeof o==="function",w=(o)=>E(o)?async()=>await o():u(o);var k=({environmentVariableSelector:o,configFileSelector:r,default:t},e={})=>C(y(l(o),h(r,e),w(t)));function F(o){let r={};if(o=o.replace(/^\?/,""),o)for(let t of o.split("&")){let[e,n=null]=t.split("=");if(e=decodeURIComponent(e),n)n=decodeURIComponent(n);if(!(e in r))r[e]=n;else if(Array.isArray(r[e]))r[e].push(n);else r[e]=[r[e],n]}return r}var N=(o)=>{if(typeof o==="string")return N(new URL(o));let{hostname:r,pathname:t,port:e,protocol:n,search:i}=o,f;if(i)f=F(i);return{hostname:r,port:e?parseInt(e):void 0,protocol:n,path:t,query:f}};
export{k as wa,N as xa};
