'use strict';

var fs = require('node:fs');
var Module = require('node:module');
var os = require('node:os');
var path = require('node:path');
var require$$0 = require('node:url');
var registryConstants = require('../external/@socketsecurity/registry/lib/constants');

var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
const require$1 =Module.createRequire(require$$0.pathToFileURL(__filename).href)
const __filename$1 = require$$0.fileURLToPath((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('constants.js', document.baseURI).href)));
const __dirname$1 = path.dirname(__filename$1);
const {
  kInternalsSymbol,
  [kInternalsSymbol]: {
    attributes: registryConstantsAttribs,
    createConstantsObject,
    getIpc
  }
} = registryConstants;
const ALERT_TYPE_CRITICAL_CVE = 'criticalCVE';
const ALERT_TYPE_CVE = 'cve';
const ALERT_TYPE_MEDIUM_CVE = 'mediumCVE';
const ALERT_TYPE_MILD_CVE = 'mildCVE';
const API_V0_URL = 'https://api.socket.dev/v0/';
const BINARY_LOCK_EXT = '.lockb';
const BUN = 'bun';
const DRY_RUN_LABEL = '[DryRun]';
const DRY_RUN_BAILING_NOW = `${DRY_RUN_LABEL}: Bailing now`;
const DRY_RUN_NOT_SAVING = `${DRY_RUN_LABEL}: Not saving`;
const LOCALAPPDATA = 'LOCALAPPDATA';
const LOCK_EXT = '.lock';
const NPM_BUGGY_OVERRIDES_PATCHED_VERSION = '11.2.0';
const NPM_REGISTRY_URL = 'https://registry.npmjs.org';
const PNPM = 'pnpm';
const REDACTED = '<redacted>';
const SHADOW_BIN = 'shadow-bin';
const SHADOW_INJECT = 'shadow-inject';
const SOCKET = 'socket';
const SOCKET_CLI_ACCEPT_RISKS = 'SOCKET_CLI_ACCEPT_RISKS';
const SOCKET_CLI_BIN_NAME = 'socket';
const SOCKET_CLI_BIN_NAME_ALIAS = 'cli';
const SOCKET_CLI_FIX = 'SOCKET_CLI_FIX';
const SOCKET_CLI_ISSUES_URL = 'https://github.com/SocketDev/socket-cli/issues';
const SOCKET_CLI_LEGACY_PACKAGE_NAME = '@socketsecurity/cli';
const SOCKET_CLI_OPTIMIZE = 'SOCKET_CLI_OPTIMIZE';
const SOCKET_CLI_NPM_BIN_NAME = 'socket-npm';
const SOCKET_CLI_NPX_BIN_NAME = 'socket-npx';
const SOCKET_CLI_PACKAGE_NAME = 'socket';
const SOCKET_CLI_SAFE_BIN = 'SOCKET_CLI_SAFE_BIN';
const SOCKET_CLI_SAFE_PROGRESS = 'SOCKET_CLI_SAFE_PROGRESS';
const SOCKET_CLI_SENTRY_BIN_NAME = 'socket-with-sentry';
const SOCKET_CLI_SENTRY_BIN_NAME_ALIAS = 'cli-with-sentry';
const SOCKET_CLI_SENTRY_NPM_BIN_NAME = 'socket-npm-with-sentry';
const SOCKET_CLI_SENTRY_NPX_BIN_NAME = 'socket-npx-with-sentry';
const SOCKET_CLI_SENTRY_PACKAGE_NAME = '@socketsecurity/cli-with-sentry';
const SOCKET_CLI_VIEW_ALL_RISKS = 'SOCKET_CLI_VIEW_ALL_RISKS';
const SOCKET_WEBSITE_URL = 'https://socket.dev';
const VLT = 'vlt';
const WITH_SENTRY = 'with-sentry';
const YARN = 'yarn';
const YARN_BERRY = 'yarn/berry';
const YARN_CLASSIC = 'yarn/classic';
const YARN_LOCK = 'yarn.lock';
let _Sentry;
const LAZY_ENV = () => {
  const {
    envAsBoolean,
    envAsString
  } = require$1('../external/@socketsecurity/registry/lib/env');
  const {
    env
  } = process;
  const GITHUB_TOKEN = envAsString(env['GITHUB_TOKEN']);
  // We inline some environment values so that they CANNOT be influenced by user
  // provided environment variables.
  return Object.freeze({
    __proto__: null,
    // Lazily access registryConstants.ENV.
    ...registryConstants.ENV,
    // Flag to disable using GitHub's workflow actions/cache.
    // https://github.com/actions/cache
    DISABLE_GITHUB_CACHE: envAsBoolean(env['DISABLE_GITHUB_CACHE']),
    // Always set to true when GitHub Actions is running the workflow. This variable
    // can be used to differentiate when tests are being run locally or by GitHub Actions.
    // https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
    GITHUB_ACTIONS: envAsBoolean(env['GITHUB_ACTIONS']),
    // The short ref name of the branch or tag that triggered the GitHub workflow
    // run. This value matches the branch or tag name shown on GitHub. For example,
    // feature-branch-1. For pull requests, the format is <pr_number>/merge.
    // https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
    GITHUB_REF_NAME: envAsString(env['GITHUB_REF_NAME']),
    // The type of ref that triggered the workflow run. Valid values are branch or tag.
    // https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
    GITHUB_REF_TYPE: envAsString(env['GITHUB_REF_TYPE']),
    // The owner and repository name. For example, octocat/Hello-World.
    // https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
    GITHUB_REPOSITORY: envAsString(env['GITHUB_REPOSITORY']),
    // The GITHUB_TOKEN secret is a GitHub App installation access token.
    // The token's permissions are limited to the repository that contains the
    // workflow.
    // https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#about-the-github_token-secret
    GITHUB_TOKEN,
    // Comp-time inlined @cyclonedx/cdxgen package version.
    // The '@rollup/plugin-replace' will replace "process.env['INLINED_CYCLONEDX_CDXGEN_VERSION']".
    INLINED_CYCLONEDX_CDXGEN_VERSION: envAsString("11.3.2"),
    // Comp-time inlined Socket package homepage.
    // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_HOMEPAGE']".
    INLINED_SOCKET_CLI_HOMEPAGE: envAsString("https://github.com/SocketDev/socket-cli"),
    // Comp-time inlined flag to determine if this is the Legacy build.
    // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_LEGACY_BUILD']".
    INLINED_SOCKET_CLI_LEGACY_BUILD: envAsBoolean(true),
    // Comp-time inlined Socket package name.
    // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_NAME']".
    INLINED_SOCKET_CLI_NAME: envAsString("socket"),
    // Comp-time inlined flag to determine if this is a published build.
    // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_PUBLISHED_BUILD']".
    INLINED_SOCKET_CLI_PUBLISHED_BUILD: envAsBoolean(true),
    // Comp-time inlined flag to determine if this is the Sentry build.
    // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_SENTRY_BUILD']".
    INLINED_SOCKET_CLI_SENTRY_BUILD: envAsBoolean(false),
    // Comp-time inlined Socket package version.
    // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
    INLINED_SOCKET_CLI_VERSION: envAsString("0.15.36"),
    // Comp-time inlined Socket package version hash.
    // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
    INLINED_SOCKET_CLI_VERSION_HASH: envAsString("0.15.36:e863b30:478ef7e9:pub"),
    // Comp-time inlined synp package version.
    // The '@rollup/plugin-replace' will replace "process.env['INLINED_SYNP_VERSION']".
    INLINED_SYNP_VERSION: envAsString("1.9.14"),
    // The location of the %localappdata% folder on Windows used to store user-specific,
    // non-roaming application data, like temporary files, cached data, and program
    // settings, that are specific to the current machine and user.
    LOCALAPPDATA: envAsString(env[LOCALAPPDATA]),
    // Flag to enable the module compile cache for the Node.js instance.
    // https://nodejs.org/api/cli.html#node_compile_cachedir
    NODE_COMPILE_CACHE:
    // Lazily access constants.SUPPORTS_NODE_COMPILE_CACHE_ENV_VAR.
    constants.SUPPORTS_NODE_COMPILE_CACHE_ENV_VAR ?
    // Lazily access constants.socketCachePath.
    constants.socketCachePath : '',
    // PATH is an environment variable that lists directories where executable
    // programs are located. When a command is run, the system searches these
    // directories to find the executable.
    PATH: envAsString(env['PATH']),
    // Flag to accepts risks of safe-npm and safe-npx run.
    SOCKET_CLI_ACCEPT_RISKS: envAsBoolean(env[SOCKET_CLI_ACCEPT_RISKS]),
    // Flag to change the base URL for all API-calls.
    // https://github.com/SocketDev/socket-cli?tab=readme-ov-file#environment-variables-for-development
    SOCKET_CLI_API_BASE_URL: envAsString(env['SOCKET_CLI_API_BASE_URL']) || envAsString(env['SOCKET_SECURITY_API_BASE_URL']),
    // Flag to set the proxy all requests are routed through.
    // https://github.com/SocketDev/socket-cli?tab=readme-ov-file#environment-variables-for-development
    SOCKET_CLI_API_PROXY: envAsString(env['SOCKET_CLI_API_PROXY']) || envAsString(env['SOCKET_SECURITY_API_PROXY']),
    // Flag to set the API token.
    // https://github.com/SocketDev/socket-cli?tab=readme-ov-file#environment-variables
    SOCKET_CLI_API_TOKEN: envAsString(env['SOCKET_CLI_API_TOKEN']) || envAsString(env['SOCKET_CLI_API_KEY']) || envAsString(env['SOCKET_SECURITY_API_TOKEN']) || envAsString(env['SOCKET_SECURITY_API_KEY']),
    // Flag containing a JSON stringified Socket configuration object.
    SOCKET_CLI_CONFIG: envAsString(env['SOCKET_CLI_CONFIG']),
    // Flag to help debug Socket CLI.
    SOCKET_CLI_DEBUG: envAsBoolean(env['SOCKET_CLI_DEBUG']),
    // The git config user.email used by Socket CLI.
    SOCKET_CLI_GIT_USER_EMAIL: envAsString(env['SOCKET_CLI_GIT_USER_EMAIL']) || `github-actions[bot]@users.noreply.github.com`,
    // The git config user.name used by Socket CLI.
    SOCKET_CLI_GIT_USER_NAME: envAsString(env['SOCKET_CLI_GIT_USER_NAME']) || envAsString(env['SOCKET_CLI_GIT_USERNAME']) || 'github-actions[bot]',
    // A classic GitHub personal access token with the "repo" scope or a
    // fine-grained access token with at least read/write permissions set for
    // "Contents" and "Pull Request".
    // https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
    SOCKET_CLI_GITHUB_TOKEN: envAsString(env['SOCKET_CLI_GITHUB_TOKEN']) || envAsString(env['SOCKET_SECURITY_GITHUB_PAT']) || GITHUB_TOKEN,
    // Flag to make the default API token `undefined`.
    SOCKET_CLI_NO_API_TOKEN: envAsBoolean(env['SOCKET_CLI_NO_API_TOKEN']),
    // Flag to view all risks of safe-npm and safe-npx run.
    SOCKET_CLI_VIEW_ALL_RISKS: envAsBoolean(env[SOCKET_CLI_VIEW_ALL_RISKS]),
    // Specifies the type of terminal or terminal emulator being used by the process.
    TERM: envAsString(env['TERM']),
    // The location of the base directory on Linux and MacOS used to store
    // user-specific data files, defaulting to $HOME/.local/share if not set or empty.
    XDG_DATA_HOME: envAsString(env['XDG_DATA_HOME'])
  });
};
const lazyBashRcPath = () =>
// Lazily access constants.homePath.
path.join(constants.homePath, '.bashrc');
const lazyBinPath = () =>
// Lazily access constants.rootPath.
path.join(constants.rootPath, 'bin');
const lazyBinCliPath = () =>
// Lazily access constants.binPath.
path.join(constants.binPath, 'cli.js');
const lazyBlessedOptions = () => Object.freeze({
  smartCSR: true,
  // Lazily access constants.WIN32.
  term: constants.WIN32 ? 'windows-ansi' : 'xterm',
  useBCE: true
});
const lazyDistPath = () =>
// Lazily access constants.rootPath.
path.join(constants.rootPath, 'dist');
const lazyDistCliPath = () =>
// Lazily access constants.distPath.
path.join(constants.distPath, 'cli.js');
const lazyDistInstrumentWithSentryPath = () =>
// Lazily access constants.distPath.
path.join(constants.distPath, 'instrument-with-sentry.js');
const lazyDistShadowBinPath = () =>
// Lazily access constants.distPath.
path.join(constants.distPath, `${SHADOW_BIN}.js`);
const lazyDistShadowInjectPath = () =>
// Lazily access constants.distPath.
path.join(constants.distPath, `${SHADOW_INJECT}.js`);
const lazyGithubCachePath = () =>
// Lazily access constants.socketCachePath.
path.join(constants.socketCachePath, 'github');
const lazyHomePath = () => os.homedir();
const lazyMinimumVersionByAgent = () => new Map([
// Bun >=1.1.39 supports the text-based lockfile.
// https://bun.sh/blog/bun-lock-text-lockfile
[BUN, '1.1.39'],
// The npm version bundled with Node 18.
// https://nodejs.org/en/about/previous-releases#looking-for-the-latest-release-of-a-version-branch
['npm', '10.8.2'],
// 8.x is the earliest version to support Node 18.
// https://pnpm.io/installation#compatibility
// https://www.npmjs.com/package/pnpm?activeTab=versions
[PNPM, '8.15.7'],
// 4.x supports >= Node 18.12.0
// https://github.com/yarnpkg/berry/blob/%40yarnpkg/core/4.1.0/CHANGELOG.md#400
[YARN_BERRY, '4.0.0'],
// Latest 1.x.
// https://www.npmjs.com/package/yarn?activeTab=versions
[YARN_CLASSIC, '1.22.22'],
// vlt does not support overrides so we don't gate on it.
[VLT, '*']]);
const lazyNmBinPath = () =>
// Lazily access constants.rootPath.
path.join(constants.rootPath, 'node_modules/.bin');

// Redefine registryConstants.nodeHardenFlags to account for the
// INLINED_SOCKET_CLI_SENTRY_BUILD environment variable.
const lazyNodeHardenFlags = () => Object.freeze(
// Lazily access constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD.
constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD ||
// Lazily access constants.WIN32.
constants.WIN32 ? [] :
// Harden Node security.
// https://nodejs.org/en/learn/getting-started/security-best-practices
['--disable-proto', 'throw',
// We have contributed the following patches to our dependencies to make
// Node's --frozen-intrinsics workable.
// √ https://github.com/SBoudrias/Inquirer.js/pull/1683
// √ https://github.com/pnpm/components/pull/23
'--frozen-intrinsics', '--no-deprecation']);
const lazyRootPath = () => path.join(fs.realpathSync.native(__dirname$1), '..');
const lazySocketAppDataPath = () => {
  // Get the OS app data folder:
  // - Win: %LOCALAPPDATA% or fail?
  // - Mac: %XDG_DATA_HOME% or fallback to "~/Library/Application Support/"
  // - Linux: %XDG_DATA_HOME% or fallback to "~/.local/share/"
  // Note: LOCALAPPDATA is typically: C:\Users\USERNAME\AppData
  // Note: XDG stands for "X Desktop Group", nowadays "freedesktop.org"
  //       On most systems that path is: $HOME/.local/share
  // Then append `socket/settings`, so:
  // - Win: %LOCALAPPDATA%\socket\settings or return undefined
  // - Mac: %XDG_DATA_HOME%/socket/settings or "~/Library/Application Support/socket/settings"
  // - Linux: %XDG_DATA_HOME%/socket/settings or "~/.local/share/socket/settings"

  // Lazily access constants.WIN32.
  const {
    WIN32
  } = constants;
  let dataHome = WIN32 ?
  // Lazily access constants.ENV.LOCALAPPDATA
  constants.ENV.LOCALAPPDATA :
  // Lazily access constants.ENV.XDG_DATA_HOME
  constants.ENV.XDG_DATA_HOME;
  if (!dataHome) {
    if (WIN32) {
      const logger = require$1('../external/@socketsecurity/registry/lib/logger');
      logger.warn(`Missing %${LOCALAPPDATA}%`);
    } else {
      dataHome = path.join(
      // Lazily access constants.homePath.
      constants.homePath,
      // Lazily access constants.DARWIN.
      constants.DARWIN ? 'Library/Application Support' : '.local/share');
    }
  }
  return dataHome ? path.join(dataHome, 'socket/settings') : undefined;
};
const lazySocketCachePath = () =>
// Lazily access constants.rootPath.
path.join(constants.rootPath, '.cache');
const lazyShadowBinPath = () =>
// Lazily access constants.rootPath.
path.join(constants.rootPath, SHADOW_BIN);
const lazyZshRcPath = () =>
// Lazily access constants.homePath.
path.join(constants.homePath, '.zshrc');
const constants = createConstantsObject({
  ...registryConstantsAttribs.props,
  ALERT_TYPE_CRITICAL_CVE,
  ALERT_TYPE_CVE,
  ALERT_TYPE_MEDIUM_CVE,
  ALERT_TYPE_MILD_CVE,
  API_V0_URL,
  BINARY_LOCK_EXT,
  BUN,
  DRY_RUN_LABEL,
  DRY_RUN_BAILING_NOW,
  DRY_RUN_NOT_SAVING,
  ENV: undefined,
  LOCK_EXT,
  NPM_BUGGY_OVERRIDES_PATCHED_VERSION,
  NPM_REGISTRY_URL,
  PNPM,
  REDACTED,
  SHADOW_BIN,
  SHADOW_INJECT,
  SOCKET,
  SOCKET_CLI_ACCEPT_RISKS,
  SOCKET_CLI_BIN_NAME,
  SOCKET_CLI_BIN_NAME_ALIAS,
  SOCKET_CLI_FIX,
  SOCKET_CLI_ISSUES_URL,
  SOCKET_CLI_SENTRY_BIN_NAME_ALIAS,
  SOCKET_CLI_LEGACY_PACKAGE_NAME,
  SOCKET_CLI_NPM_BIN_NAME,
  SOCKET_CLI_NPX_BIN_NAME,
  SOCKET_CLI_OPTIMIZE,
  SOCKET_CLI_PACKAGE_NAME,
  SOCKET_CLI_SAFE_BIN,
  SOCKET_CLI_SAFE_PROGRESS,
  SOCKET_CLI_SENTRY_BIN_NAME,
  SOCKET_CLI_SENTRY_NPM_BIN_NAME,
  SOCKET_CLI_SENTRY_NPX_BIN_NAME,
  SOCKET_CLI_SENTRY_PACKAGE_NAME,
  SOCKET_CLI_VIEW_ALL_RISKS,
  SOCKET_WEBSITE_URL,
  VLT,
  WITH_SENTRY,
  YARN,
  YARN_BERRY,
  YARN_CLASSIC,
  YARN_LOCK,
  bashRcPath: undefined,
  binPath: undefined,
  binCliPath: undefined,
  blessedOptions: undefined,
  distCliPath: undefined,
  distInstrumentWithSentryPath: undefined,
  distPath: undefined,
  distShadowBinPath: undefined,
  distShadowInjectPath: undefined,
  githubCachePath: undefined,
  homePath: undefined,
  minimumVersionByAgent: undefined,
  nmBinPath: undefined,
  nodeHardenFlags: undefined,
  rootPath: undefined,
  shadowBinPath: undefined,
  socketAppDataPath: undefined,
  socketCachePath: undefined,
  zshRcPath: undefined
}, {
  getters: {
    ...registryConstantsAttribs.getters,
    ENV: LAZY_ENV,
    bashRcPath: lazyBashRcPath,
    binCliPath: lazyBinCliPath,
    binPath: lazyBinPath,
    blessedOptions: lazyBlessedOptions,
    distCliPath: lazyDistCliPath,
    distInstrumentWithSentryPath: lazyDistInstrumentWithSentryPath,
    distPath: lazyDistPath,
    distShadowBinPath: lazyDistShadowBinPath,
    distShadowInjectPath: lazyDistShadowInjectPath,
    githubCachePath: lazyGithubCachePath,
    homePath: lazyHomePath,
    minimumVersionByAgent: lazyMinimumVersionByAgent,
    nmBinPath: lazyNmBinPath,
    nodeHardenFlags: lazyNodeHardenFlags,
    rootPath: lazyRootPath,
    shadowBinPath: lazyShadowBinPath,
    socketAppDataPath: lazySocketAppDataPath,
    socketCachePath: lazySocketCachePath,
    zshRcPath: lazyZshRcPath
  },
  internals: {
    ...registryConstantsAttribs.internals,
    getIpc,
    getSentry() {
      return _Sentry;
    },
    setSentry(Sentry) {
      if (_Sentry === undefined) {
        _Sentry = Sentry;
        return true;
      }
      return false;
    }
  }
});

module.exports = constants;
//# debugId=409ec535-3198-4e28-be41-22c7e523e9f8
//# sourceMappingURL=constants.js.map
