import { setCredentialFeature } from './NDUVZQ7S.js';
import { parseKnownFiles, getProfileName } from './ELFNCT57.js';
import './OH4A2VLX.js';
import { CredentialsProviderError, chain } from './TTKDG2NN.js';
import { init_esm_shims, __name } from './4RNWLMHM.js';

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/index.js
init_esm_shims();

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/fromIni.js
init_esm_shims();

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProfileData.js
init_esm_shims();

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveAssumeRoleCredentials.js
init_esm_shims();

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveCredentialSource.js
init_esm_shims();
var resolveCredentialSource = /* @__PURE__ */ __name((credentialSource, profileName, logger) => {
  const sourceProvidersMap = {
    EcsContainer: /* @__PURE__ */ __name(async (options) => {
      const { fromHttp } = await import('./7R7EZF6Z.js');
      const { fromContainerMetadata } = await import('./RH2W4KPM.js');
      logger?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
      return async () => chain(fromHttp(options ?? {}), fromContainerMetadata(options))().then(setNamedProvider);
    }, "EcsContainer"),
    Ec2InstanceMetadata: /* @__PURE__ */ __name(async (options) => {
      logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
      const { fromInstanceMetadata } = await import('./RH2W4KPM.js');
      return async () => fromInstanceMetadata(options)().then(setNamedProvider);
    }, "Ec2InstanceMetadata"),
    Environment: /* @__PURE__ */ __name(async (options) => {
      logger?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
      const { fromEnv } = await import('./L3JULKNZ.js');
      return async () => fromEnv(options)().then(setNamedProvider);
    }, "Environment")
  };
  if (credentialSource in sourceProvidersMap) {
    return sourceProvidersMap[credentialSource];
  } else {
    throw new CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, {
      logger
    });
  }
}, "resolveCredentialSource");
var setNamedProvider = /* @__PURE__ */ __name((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p"), "setNamedProvider");

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveAssumeRoleCredentials.js
var isAssumeRoleProfile = /* @__PURE__ */ __name((arg, { profile = "default", logger } = {}) => {
  return Boolean(arg) && typeof arg === "object" && typeof arg.role_arn === "string" && [
    "undefined",
    "string"
  ].indexOf(typeof arg.role_session_name) > -1 && [
    "undefined",
    "string"
  ].indexOf(typeof arg.external_id) > -1 && [
    "undefined",
    "string"
  ].indexOf(typeof arg.mfa_serial) > -1 && (isAssumeRoleWithSourceProfile(arg, {
    profile,
    logger
  }) || isCredentialSourceProfile(arg, {
    profile,
    logger
  }));
}, "isAssumeRoleProfile");
var isAssumeRoleWithSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger }) => {
  const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
  if (withSourceProfile) {
    logger?.debug?.(`    ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
  }
  return withSourceProfile;
}, "isAssumeRoleWithSourceProfile");
var isCredentialSourceProfile = /* @__PURE__ */ __name((arg, { profile, logger }) => {
  const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
  if (withProviderProfile) {
    logger?.debug?.(`    ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
  }
  return withProviderProfile;
}, "isCredentialSourceProfile");
var resolveAssumeRoleCredentials = /* @__PURE__ */ __name(async (profileName, profiles, options, visitedProfiles = {}) => {
  options.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");
  const profileData = profiles[profileName];
  const { source_profile, region } = profileData;
  if (!options.roleAssumer) {
    const { getDefaultRoleAssumer } = await import('./35BIBLTE.js');
    options.roleAssumer = getDefaultRoleAssumer({
      ...options.clientConfig,
      credentialProviderLogger: options.logger,
      parentClientConfig: {
        ...options?.parentClientConfig,
        region: region ?? options?.parentClientConfig?.region
      }
    }, options.clientPlugins);
  }
  if (source_profile && source_profile in visitedProfiles) {
    throw new CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${getProfileName(options)}. Profiles visited: ` + Object.keys(visitedProfiles).join(", "), {
      logger: options.logger
    });
  }
  options.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${source_profile ? `source_profile=[${source_profile}]` : `profile=[${profileName}]`}`);
  const sourceCredsProvider = source_profile ? resolveProfileData(source_profile, profiles, options, {
    ...visitedProfiles,
    [source_profile]: true
  }, isCredentialSourceWithoutRoleArn(profiles[source_profile] ?? {})) : (await resolveCredentialSource(profileData.credential_source, profileName, options.logger)(options))();
  if (isCredentialSourceWithoutRoleArn(profileData)) {
    return sourceCredsProvider.then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
  } else {
    const params = {
      RoleArn: profileData.role_arn,
      RoleSessionName: profileData.role_session_name || `aws-sdk-js-${Date.now()}`,
      ExternalId: profileData.external_id,
      DurationSeconds: parseInt(profileData.duration_seconds || "3600", 10)
    };
    const { mfa_serial } = profileData;
    if (mfa_serial) {
      if (!options.mfaCodeProvider) {
        throw new CredentialsProviderError(`Profile ${profileName} requires multi-factor authentication, but no MFA code callback was provided.`, {
          logger: options.logger,
          tryNextLink: false
        });
      }
      params.SerialNumber = mfa_serial;
      params.TokenCode = await options.mfaCodeProvider(mfa_serial);
    }
    const sourceCreds = await sourceCredsProvider;
    return options.roleAssumer(sourceCreds, params).then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_SOURCE_PROFILE", "o"));
  }
}, "resolveAssumeRoleCredentials");
var isCredentialSourceWithoutRoleArn = /* @__PURE__ */ __name((section) => {
  return !section.role_arn && !!section.credential_source;
}, "isCredentialSourceWithoutRoleArn");

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProcessCredentials.js
init_esm_shims();
var isProcessProfile = /* @__PURE__ */ __name((arg) => Boolean(arg) && typeof arg === "object" && typeof arg.credential_process === "string", "isProcessProfile");
var resolveProcessCredentials = /* @__PURE__ */ __name(async (options, profile) => import('./EDWLY6YP.js').then(({ fromProcess }) => fromProcess({
  ...options,
  profile
})().then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_PROCESS", "v"))), "resolveProcessCredentials");

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveSsoCredentials.js
init_esm_shims();
var resolveSsoCredentials = /* @__PURE__ */ __name(async (profile, profileData, options = {}) => {
  const { fromSSO } = await import('./S37YVMJL.js');
  return fromSSO({
    profile,
    logger: options.logger,
    parentClientConfig: options.parentClientConfig,
    clientConfig: options.clientConfig
  })().then((creds) => {
    if (profileData.sso_session) {
      return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO", "r");
    } else {
      return setCredentialFeature(creds, "CREDENTIALS_PROFILE_SSO_LEGACY", "t");
    }
  });
}, "resolveSsoCredentials");
var isSsoProfile = /* @__PURE__ */ __name((arg) => arg && (typeof arg.sso_start_url === "string" || typeof arg.sso_account_id === "string" || typeof arg.sso_session === "string" || typeof arg.sso_region === "string" || typeof arg.sso_role_name === "string"), "isSsoProfile");

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveStaticCredentials.js
init_esm_shims();
var isStaticCredsProfile = /* @__PURE__ */ __name((arg) => Boolean(arg) && typeof arg === "object" && typeof arg.aws_access_key_id === "string" && typeof arg.aws_secret_access_key === "string" && [
  "undefined",
  "string"
].indexOf(typeof arg.aws_session_token) > -1 && [
  "undefined",
  "string"
].indexOf(typeof arg.aws_account_id) > -1, "isStaticCredsProfile");
var resolveStaticCredentials = /* @__PURE__ */ __name(async (profile, options) => {
  options?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");
  const credentials = {
    accessKeyId: profile.aws_access_key_id,
    secretAccessKey: profile.aws_secret_access_key,
    sessionToken: profile.aws_session_token,
    ...profile.aws_credential_scope && {
      credentialScope: profile.aws_credential_scope
    },
    ...profile.aws_account_id && {
      accountId: profile.aws_account_id
    }
  };
  return setCredentialFeature(credentials, "CREDENTIALS_PROFILE", "n");
}, "resolveStaticCredentials");

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveWebIdentityCredentials.js
init_esm_shims();
var isWebIdentityProfile = /* @__PURE__ */ __name((arg) => Boolean(arg) && typeof arg === "object" && typeof arg.web_identity_token_file === "string" && typeof arg.role_arn === "string" && [
  "undefined",
  "string"
].indexOf(typeof arg.role_session_name) > -1, "isWebIdentityProfile");
var resolveWebIdentityCredentials = /* @__PURE__ */ __name(async (profile, options) => import('./LF6BYBZY.js').then(({ fromTokenFile }) => fromTokenFile({
  webIdentityTokenFile: profile.web_identity_token_file,
  roleArn: profile.role_arn,
  roleSessionName: profile.role_session_name,
  roleAssumerWithWebIdentity: options.roleAssumerWithWebIdentity,
  logger: options.logger,
  parentClientConfig: options.parentClientConfig
})().then((creds) => setCredentialFeature(creds, "CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN", "q"))), "resolveWebIdentityCredentials");

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProfileData.js
var resolveProfileData = /* @__PURE__ */ __name(async (profileName, profiles, options, visitedProfiles = {}, isAssumeRoleRecursiveCall = false) => {
  const data = profiles[profileName];
  if (Object.keys(visitedProfiles).length > 0 && isStaticCredsProfile(data)) {
    return resolveStaticCredentials(data, options);
  }
  if (isAssumeRoleRecursiveCall || isAssumeRoleProfile(data, {
    profile: profileName,
    logger: options.logger
  })) {
    return resolveAssumeRoleCredentials(profileName, profiles, options, visitedProfiles);
  }
  if (isStaticCredsProfile(data)) {
    return resolveStaticCredentials(data, options);
  }
  if (isWebIdentityProfile(data)) {
    return resolveWebIdentityCredentials(data, options);
  }
  if (isProcessProfile(data)) {
    return resolveProcessCredentials(options, profileName);
  }
  if (isSsoProfile(data)) {
    return await resolveSsoCredentials(profileName, data, options);
  }
  throw new CredentialsProviderError(`Could not resolve credentials using profile: [${profileName}] in configuration/credentials file(s).`, {
    logger: options.logger
  });
}, "resolveProfileData");

// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.879.0/node_modules/@aws-sdk/credential-provider-ini/dist-es/fromIni.js
var fromIni = /* @__PURE__ */ __name((_init = {}) => async ({ callerClientConfig } = {}) => {
  const init = {
    ..._init,
    parentClientConfig: {
      ...callerClientConfig,
      ..._init.parentClientConfig
    }
  };
  init.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");
  const profiles = await parseKnownFiles(init);
  return resolveProfileData(getProfileName({
    profile: _init.profile ?? callerClientConfig?.profile
  }), profiles, init);
}, "fromIni");

export { fromIni };
//# sourceMappingURL=OANFSFAO.js.map
//# sourceMappingURL=OANFSFAO.js.map