import { __exports as path } from '../../../../../../../_virtual/path.mjs';
import require$$0 from 'node:os';
import path__default from 'node:path';

var hasRequiredPath;
function requirePath() {
  if (hasRequiredPath) return path;
  hasRequiredPath = 1;
  Object.defineProperty(path, "__esModule", {
    value: true
  });
  path.convertPosixPathToPattern = path.convertWindowsPathToPattern = path.convertPathToPattern = path.escapePosixPath = path.escapeWindowsPath = path.escape = path.removeLeadingDotSegment = path.makeAbsolute = path.unixify = void 0;
  const os = require$$0;
  const path$1 = path__default;
  const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
  const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
  /**
   * All non-escaped special characters.
   * Posix: ()*?[]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
   * Windows: (){}[], !+@ before (, ! at the beginning.
   */
  const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
  const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
  /**
   * The device path (\\.\ or \\?\).
   * https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
   */
  const DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
  /**
   * All backslashes except those escaping special characters.
   * Windows: !()+@{}
   * https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
   */
  const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g;
  /**
   * Designed to work only with simple paths: `dir\\file`.
   */
  function unixify(filepath) {
    return filepath.replace(/\\/g, '/');
  }
  path.unixify = unixify;
  function makeAbsolute(cwd, filepath) {
    return path$1.resolve(cwd, filepath);
  }
  path.makeAbsolute = makeAbsolute;
  function removeLeadingDotSegment(entry) {
    // We do not use `startsWith` because this is 10x slower than current implementation for some cases.
    // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
    if (entry.charAt(0) === '.') {
      const secondCharactery = entry.charAt(1);
      if (secondCharactery === '/' || secondCharactery === '\\') {
        return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
      }
    }
    return entry;
  }
  path.removeLeadingDotSegment = removeLeadingDotSegment;
  path.escape = IS_WINDOWS_PLATFORM ? escapeWindowsPath : escapePosixPath;
  function escapeWindowsPath(pattern) {
    return pattern.replace(WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
  }
  path.escapeWindowsPath = escapeWindowsPath;
  function escapePosixPath(pattern) {
    return pattern.replace(POSIX_UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
  }
  path.escapePosixPath = escapePosixPath;
  path.convertPathToPattern = IS_WINDOWS_PLATFORM ? convertWindowsPathToPattern : convertPosixPathToPattern;
  function convertWindowsPathToPattern(filepath) {
    return escapeWindowsPath(filepath).replace(DOS_DEVICE_PATH_RE, '//$1').replace(WINDOWS_BACKSLASHES_RE, '/');
  }
  path.convertWindowsPathToPattern = convertWindowsPathToPattern;
  function convertPosixPathToPattern(filepath) {
    return escapePosixPath(filepath);
  }
  path.convertPosixPathToPattern = convertPosixPathToPattern;
  return path;
}

export { requirePath as __require };
