'use strict';

var P5BPMTGP_cjs = require('./P5BPMTGP.cjs');
var JGLHYXTW_cjs = require('./JGLHYXTW.cjs');
var U7VZULNU_cjs = require('./U7VZULNU.cjs');

// ../../node_modules/.pnpm/@smithy+url-parser@4.0.5/node_modules/@smithy/url-parser/dist-es/index.js
U7VZULNU_cjs.init_cjs_shims();

// ../../node_modules/.pnpm/@smithy+querystring-parser@4.0.5/node_modules/@smithy/querystring-parser/dist-es/index.js
U7VZULNU_cjs.init_cjs_shims();
function parseQueryString(querystring) {
  const query = {};
  querystring = querystring.replace(/^\?/, "");
  if (querystring) {
    for (const pair of querystring.split("&")) {
      let [key, value = null] = pair.split("=");
      key = decodeURIComponent(key);
      if (value) {
        value = decodeURIComponent(value);
      }
      if (!(key in query)) {
        query[key] = value;
      } else if (Array.isArray(query[key])) {
        query[key].push(value);
      } else {
        query[key] = [
          query[key],
          value
        ];
      }
    }
  }
  return query;
}
U7VZULNU_cjs.__name(parseQueryString, "parseQueryString");

// ../../node_modules/.pnpm/@smithy+url-parser@4.0.5/node_modules/@smithy/url-parser/dist-es/index.js
var parseUrl = /* @__PURE__ */ U7VZULNU_cjs.__name((url) => {
  if (typeof url === "string") {
    return parseUrl(new URL(url));
  }
  const { hostname, pathname, port, protocol, search } = url;
  let query;
  if (search) {
    query = parseQueryString(search);
  }
  return {
    hostname,
    port: port ? parseInt(port) : void 0,
    protocol,
    path: pathname,
    query
  };
}, "parseUrl");

// ../../node_modules/.pnpm/@smithy+node-config-provider@4.1.4/node_modules/@smithy/node-config-provider/dist-es/configLoader.js
U7VZULNU_cjs.init_cjs_shims();

// ../../node_modules/.pnpm/@smithy+node-config-provider@4.1.4/node_modules/@smithy/node-config-provider/dist-es/fromEnv.js
U7VZULNU_cjs.init_cjs_shims();

// ../../node_modules/.pnpm/@smithy+node-config-provider@4.1.4/node_modules/@smithy/node-config-provider/dist-es/getSelectorName.js
U7VZULNU_cjs.init_cjs_shims();
function getSelectorName(functionString) {
  try {
    const constants = new Set(Array.from(functionString.match(/([A-Z_]){3,}/g) ?? []));
    constants.delete("CONFIG");
    constants.delete("CONFIG_PREFIX_SEPARATOR");
    constants.delete("ENV");
    return [
      ...constants
    ].join(", ");
  } catch (e) {
    return functionString;
  }
}
U7VZULNU_cjs.__name(getSelectorName, "getSelectorName");

// ../../node_modules/.pnpm/@smithy+node-config-provider@4.1.4/node_modules/@smithy/node-config-provider/dist-es/fromEnv.js
var fromEnv = /* @__PURE__ */ U7VZULNU_cjs.__name((envVarSelector, options) => async () => {
  try {
    const config = envVarSelector(process.env, options);
    if (config === void 0) {
      throw new Error();
    }
    return config;
  } catch (e) {
    throw new JGLHYXTW_cjs.CredentialsProviderError(e.message || `Not found in ENV: ${getSelectorName(envVarSelector.toString())}`, {
      logger: options?.logger
    });
  }
}, "fromEnv");

// ../../node_modules/.pnpm/@smithy+node-config-provider@4.1.4/node_modules/@smithy/node-config-provider/dist-es/fromSharedConfigFiles.js
U7VZULNU_cjs.init_cjs_shims();
var fromSharedConfigFiles = /* @__PURE__ */ U7VZULNU_cjs.__name((configSelector, { preferredFile = "config", ...init } = {}) => async () => {
  const profile = P5BPMTGP_cjs.getProfileName(init);
  const { configFile, credentialsFile } = await P5BPMTGP_cjs.loadSharedConfigFiles(init);
  const profileFromCredentials = credentialsFile[profile] || {};
  const profileFromConfig = configFile[profile] || {};
  const mergedProfile = preferredFile === "config" ? {
    ...profileFromCredentials,
    ...profileFromConfig
  } : {
    ...profileFromConfig,
    ...profileFromCredentials
  };
  try {
    const cfgFile = preferredFile === "config" ? configFile : credentialsFile;
    const configValue = configSelector(mergedProfile, cfgFile);
    if (configValue === void 0) {
      throw new Error();
    }
    return configValue;
  } catch (e) {
    throw new JGLHYXTW_cjs.CredentialsProviderError(e.message || `Not found in config files w/ profile [${profile}]: ${getSelectorName(configSelector.toString())}`, {
      logger: init.logger
    });
  }
}, "fromSharedConfigFiles");

// ../../node_modules/.pnpm/@smithy+node-config-provider@4.1.4/node_modules/@smithy/node-config-provider/dist-es/fromStatic.js
U7VZULNU_cjs.init_cjs_shims();
var isFunction = /* @__PURE__ */ U7VZULNU_cjs.__name((func) => typeof func === "function", "isFunction");
var fromStatic2 = /* @__PURE__ */ U7VZULNU_cjs.__name((defaultValue) => isFunction(defaultValue) ? async () => await defaultValue() : JGLHYXTW_cjs.fromStatic(defaultValue), "fromStatic");

// ../../node_modules/.pnpm/@smithy+node-config-provider@4.1.4/node_modules/@smithy/node-config-provider/dist-es/configLoader.js
var loadConfig = /* @__PURE__ */ U7VZULNU_cjs.__name(({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => {
  const { signingName, logger } = configuration;
  const envOptions = {
    signingName,
    logger
  };
  return JGLHYXTW_cjs.memoize(JGLHYXTW_cjs.chain(fromEnv(environmentVariableSelector, envOptions), fromSharedConfigFiles(configFileSelector, configuration), fromStatic2(defaultValue)));
}, "loadConfig");

// ../../node_modules/.pnpm/@smithy+node-config-provider@4.1.4/node_modules/@smithy/node-config-provider/dist-es/index.js
U7VZULNU_cjs.init_cjs_shims();

exports.loadConfig = loadConfig;
exports.parseUrl = parseUrl;
//# sourceMappingURL=F7OAIAEX.cjs.map
//# sourceMappingURL=F7OAIAEX.cjs.map