/**
 * General options
 */
interface Options {
    loose?: boolean | undefined;
}
/**
 * Options for `coerce()`
 */
interface CoerceOptions extends Options {
    includePrerelease?: boolean | undefined;
    /**
     * Used by `coerce()` to coerce from right to left.
     *
     * @default false
     *
     * @example
     * ```js
     * coerce('1.2.3.4', { rtl: true }) // { version: '2.3.4', ... }
     * ```
     */
    rtl?: boolean | undefined;
}

/**
 * Returns cleaned (removed leading/trailing whitespace, remove '=', 'v' prefixes) and parsed version, or `null` if version is invalid.
 *
 * @param version version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns cleaned version string or `null` if version is invalid
 *
 * @example
 * ```js
 * clean('  =v1.2.3  ') // '1.2.3'
 * ```
 */
declare const clean: (version: string, optionsOrLoose?: boolean | Options) => string | null;

/**
 * Operator string for `cmp()` (could be "===", "!==", "", "=", "==", "!=", ">", ">=", "<", "<=")
 */
type Operator = '===' | '!==' | '' | '=' | '==' | '!=' | '>' | '>=' | '<' | '<=';
/**
 * Pass in a comparison string, and it'll call the corresponding semver comparison function.
 *
 * Throws if an invalid comparison string is provided.
 *
 * @param v1 first version string
 * @param operator operator string (could be "===", "!==", "", "=", "==", "!=", ">", ">=", "<", "<=")
 * @param v2 second version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns `true` if the comparison is true, `false` otherwise
 *
 * @example
 * ```js
 * cmp('1.2.3', '>', '1.2.2') // true
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is not taken into account in all operations but "===" and "!==" which do simple comparison of the whole strings
 */
declare const cmp: (v1: string, operator: Operator, v2: string, optionsOrLoose?: boolean | Options) => boolean;

/**
 * Coerces a string if possible
 *
 * @param version string to coerce
 * @param options options object
 * @returns version string (including build identifier if it exists) or null if the version string is invalid
 *
 * @example
 * ```js
 * coerce('1.2.3.4') // '1.2.3'
 * coerce('1.2.3.4', { rtl: true }) // '2.3.4'
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is taken into account
 */
declare const coerce: (version: string | number | null | undefined, options?: CoerceOptions) => string | null;

/**
 * Compares two versions excluding build identifiers (the bit after `+` in the semantic version string).
 *
 * @param v1 first version string
 * @param v2 second version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns
 * - `0` if `v1` == `v2`
 * - `1` if `v1` > `v2`
 * - `-1` if `v1` < `v2`
 *
 * @example
 * ```js
 * compare('1.2.3', '1.2.2') // 1
 * ```
 *
 * @remarks `versionArray.sort(compare)` can sort in ascending order for `MAJOR.MINOR.PATCH[-PRERELEASE]`, excluding build identifier (`[+BUILD]`). This is different from `sort()`, which also sorts in ascending order but for the whole `MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]`
 */
declare const compare: (v1: string, v2: string, optionsOrLoose?: boolean | Options) => 0 | 1 | -1;

/**
 * Compares two versions including build identifiers (the bit after `+` in the semantic version string).
 *
 * @param v1 first version string
 * @param v2 second version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns
 * - `0` if `v1` == `v2`
 * - `1` if `v1` > `v2`
 * - `-1` if `v1` < `v2`
 *
 * @example
 * ```js
 * compareBuild('1.2.3foo', '1.2.3-foo') // 0
 * ```
 */
declare const compareBuild: (v1: string, v2: string, optionsOrLoose?: boolean | Options) => 0 | 1 | -1;

/**
 * Compare two identifiers.
 *
 * @param a first identifier
 * @param b second identifier
 *
 * @returns
 * - `0` if `v1` == `v2`
 * - `1` if `v1` > `v2`
 * - `-1` if `v1` < `v2`
 *
 * @example
 * ```js
 * compareIdentifiers('3', '6') // -1
 * compareIdentifiers('s6g1', '6df4') // 1
 * ```
 */
declare const compareIdentifiers: (a: string | number, b: string | number) => 1 | 0 | -1;

/**
 * Compare with loose mode enabled
 *
 * @param v1 first version string
 * @param v2 second version string
 *
 * @returns
 * - `0` if `v1` == `v2`
 * - `1` if `v1` > `v2`
 * - `-1` if `v1` < `v2`
 *
 * @example
 * ```js
 * compareLoose('1.2.3', '1.2.3') // 0
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is not taken into account
 */
declare const compareLoose: (v1: string, v2: string) => 0 | 1 | -1;

/**
 * The release type, could be "major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease". This type does not include 'release'
 */
type ReleaseType = 'major' | 'premajor' | 'minor' | 'preminor' | 'patch' | 'prepatch' | 'prerelease';

/**
 * Get difference between two versions by the release type
 *
 * @param version1 first version string
 * @param version2 second version string
 * @returns difference between two versions by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease), or null if the versions are the same.
 *
 * @example
 * ```js
 * diff('1.2.3', '1.2.3') // null
 * diff('1.2.3', '1.2.4') // 'patch'
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is not taken into account
 */
declare const diff: (version1: string, version2: string) => ReleaseType | null;

/**
 * v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.
 *
 * @param v1 first version string
 * @param v2 second version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns `true` if v1 == v2, `false` if v1 != v2
 *
 * @example
 * ```js
 * eq('1.2.3', '1.2.3') // true
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is not taken into account
 */
declare const eq: (v1: string, v2: string, optionsOrLoose?: boolean | Options) => boolean;

/**
 * v1 > v2 This is true if v1 is greater than v2.
 *
 * @param v1 first version string
 * @param v2 second version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns `true` if v1 > v2, `false` if v1 <= v2
 *
 * @example
 * ```js
 * gt('1.2.3', '1.2.3') // false
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is not taken into account
 */
declare const gt: (v1: string, v2: string, optionsOrLoose?: boolean | Options) => boolean;

/**
 * v1 >= v2 This is true if v1 is greater than or equivalent to v2.
 *
 * @param v1 first version string
 * @param v2 second version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns `true` if v1 >= v2, `false` if v1 < v2
 *
 * @example
 * ```js
 * gte('1.2.3', '1.2.3') // true
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is not taken into account
 */
declare const gte: (v1: string, v2: string, optionsOrLoose?: boolean | Options) => boolean;

/**
 * The base to use for the identifier in `inc()`, could be '0' or '1'
 */
type IdentifierBase = '0' | '1';
/**
 * Return the version incremented by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease), or null if it's not valid.
 *
 * @param version - The version to increment
 * @param release - The release type to use, could be "major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease", 'release'
 * @param optionsOrLoose - An options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings **this param can be omitted, making `identifier` and `identifierBase` the third and the fourth params respectively**
 * @param identifier - The identifier to use for prerelease versions
 * @param identifierBase - The base to use for the identifier, could be '0' or '1'
 *
 * @returns The incremented version, or null if it's not valid
 *
 * @example
 * ```js
 * inc('1.2.3', 'minor') // '1.3.0'
 * inc('1.2.3', 'prerelease') // '1.2.4-0'
 * inc('1.2', 'minor') // null
 * ```
 */
declare function inc(version: string, release: ReleaseType | 'release', optionsOrLoose?: boolean | Options, identifier?: string, identifierBase?: IdentifierBase | false): string | null;
declare function inc(version: string, release: ReleaseType | 'release', identifier?: string, identifierBase?: IdentifierBase | false): string | null;
/**
 * Return the version incremented by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease)
 *
 * @param version - The version to increment
 * @param release - The release type to use, could be "major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease", 'release'
 * @param identifier - The identifier to use for prerelease versions
 * @param identifierBase - The base to use for the identifier, could be '0' or '1'
 * @param optionsOrLoose - An options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns The incremented version
 *
 * @throws TypeError if the version string is invalid or if there are other errors
 *
 * @example
 * ```js
 * incThrow('1.2.3', 'minor') // '1.3.0'
 * incThrow('1.2', 'minor') // throws TypeError: Invalid Version: 1.2
 * ```
 *
 * @remarks unlike `inc()` which returns `null` if error occurs, this function could throw error
 */
declare const incThrow: (version: string, release: ReleaseType | "release", identifier?: string, identifierBase?: IdentifierBase | false, optionsOrLoose?: boolean | Options) => string;

/**
 * v1 < v2 This is true if v1 is less than v2.
 *
 * @param v1 first version string
 * @param v2 second version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns `true` if v1 < v2, `false` if v1 >= v2
 *
 * @example
 * ```js
 * lt('1.2.3', '2.0.2') // true
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is not taken into account
 **/
declare const lt: (v1: string, v2: string, optionsOrLoose?: boolean | Options) => boolean;

/**
 * v1 <= v2 This is true if v1 is less than or equivalent to v2.
 *
 * @param v1 first version string
 * @param v2 second version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns `true` if v1 <= v2, `false` if v1 > v2
 *
 * @example
 * ```js
 * lte('1.2.3', '1.2.3') // true
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is not taken into account
 **/
declare const lte: (v1: string, v2: string, optionsOrLoose?: boolean | Options) => boolean;

/**
 * Return the major version number.
 *
 * @param version version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns the major version number
 *
 * @example
 * ```js
 * major('1.2.3') // 1
 * ```
 */
declare const major: (version: string, optionsOrLoose?: boolean | Options) => number;

/**
 * Return the minor version number.
 *
 * @param version version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns the minor version number
 *
 * @example
 * ```js
 * minor('1.2.3') // 2
 * ```
 */
declare const minor: (version: string, optionsOrLoose?: boolean | Options) => number;

/**
 * v1 != v2 The opposite of eq.
 *
 * @param v1 first version string
 * @param v2 second version string
 *
 * @returns `true` if v1 != v2, `false` if v1 == v2
 *
 * @example
 * ```js
 * neq('1.2.3', '2.0.2') // true
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is not taken into account
 */
declare const neq: (v1: string, v2: string, optionsOrLoose?: boolean | Options) => boolean;

/**
 * A parsed version object as returned by `parse()`
 *
 * @example
 * ```js
 * // return value of `parse('1.2.3-foo.bar+build.123')`:
 * {
 *   version: '1.2.3-foo.bar',
 *   fullVersion: '1.2.3-foo.bar+build.123',
 *   major: 1,
 *   minor: 2,
 *   patch: 3,
 *   prerelease: ['foo', 'bar'],
 *   build: ['build', '123']
 * }
 * ```
 */
interface ParsedVersion {
    /**
     * The parsed version string with prerelease version if it exists, but without build identifier (the bit after `+` in the version string)
     */
    version: string;
    /**
     * The parsed version string with prerelease version and build identifier (the bit after `+` in the version string) if they exists
     */
    fullVersion: string;
    /**
     * The major version number
     */
    major: number;
    /**
     * The minor version number
     */
    minor: number;
    /**
     * The patch version number
     */
    patch: number;
    /**
     * The prerelease version number as an array of strings and/or numbers, or an empty array if it doesn't exist
     */
    prerelease: ReadonlyArray<string | number>;
    /**
     * The build identifier (the bit after `+` in the semantic version string) as an array of strings, or an empty array if it doesn't exist
     */
    build: ReadonlyArray<string>;
}

/**
 * Return the parsed version of a semver string, if the semver string is not valid, it returns `null` or throws an error depending on the value of `throwErrors`
 *
 * @param ver version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 * @param throwErrors whether to throw an error if the version string is invalid or if there are other errors. Defaults to `false`
 *
 * @returns parsed version object, or `null` if the version string is invalid or if there are other errors (if `throwErrors` is truthy, an error will be thrown instead of returning `null`)
 *
 * @throws TypeError if the version string is invalid or if there are other errors (if `throwErrors` is falsy, it will return `null` instead of throwing an error)
 *
 * @example
 * ```js
 * parse('1.2.3') // { version: '1.2.3', fullVersion: "1.2.3", major: 1, minor: 2, patch: 3, prerelease: [], build: [] }
 * parse('1.2.3-foo.bar+build.123') // { version: '1.2.3-foo.bar', fullVersion: "1.2.3-foo.bar+build.123", major: 1, minor: 2, patch: 3, prerelease: ['foo', 'bar'], build: ['build', '123'] }
 * parse('1.2') // null
 * parse('1.2', { loose: true }, true) // throws TypeError: Invalid Version: 1.2
 * ```
 *
 * @remarks build identifier (`[+BUILD]`) is taken into account
 */
declare const parse: <T extends boolean>(ver: string, optionsOrLoose?: boolean | Options, throwErrors?: T) => T extends true ? ParsedVersion : ParsedVersion | null;

/**
 * Return the patch version number.
 *
 * @param version version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns the patch version number
 *
 * @example
 * ```js
 * patch('1.2.3') // 3
 * ```
 */
declare const patch: (version: string, optionsOrLoose?: boolean | Options) => number;

/**
 * Returns an array of prerelease components, or `null` if none exist.
 *
 * @param version version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns an array of prerelease components, or `null` if none exist
 *
 * @example
 * ```js
 * prerelease('1.2.3-foo.bar+build.123') // ['foo', 'bar']
 * ```
 */
declare const prerelease: (version: string, optionsOrLoose?: boolean | Options) => readonly (string | number)[] | null;

/**
 * The reverse of compare.
 *
 * @param v1 first version string
 * @param v2 second version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @remarks `versionArray.sort(rcompare)` can sort in descending order for `MAJOR.MINOR.PATCH[-PRERELEASE]`, excluding build identifier (`[+BUILD]`). This is different from `rsort()`, which also sorts in descending order but for the whole `MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]`
 *
 * @returns
 * - `0` if `v1` == `v2`
 * - `-1` if `v1` > `v2`
 * - `1` if `v1` < `v2`
 *
 * @example
 * ```js
 * rcompare('1.2.3', '1.2.4') // 1
 * ```
 */
declare const rcompare: (v1: string, v2: string, optionsOrLoose?: boolean | Options) => 0 | 1 | -1;

/**
 * Regular expression to match semver strings in the form `major.minor.patch-prerelease+build`
 */
declare const FULL: RegExp;

/**
 * Sorts an array of version strings in descending order using `compareBuild()` (the whole version including build identifier (`[+BUILD]`) taken into account).
 *
 * @param list array of version strings
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns the sorted array
 *
 * @example
 * ```js
 * rsort(['2.0.2', '1.2.3', '1.2.4', '1.2.4-foo.bar+build.123', '1.2.4-foo.bar+build.1234']) // [ "2.0.2", "1.2.4", "1.2.4-foo.bar+build.1234", "1.2.4-foo.bar+build.123", "1.2.3" ]
 * ```
 */
declare const rsort: (list: string[], optionsOrLoose?: boolean | Options) => string[];

/**
 * Sorts an array of version strings in ascending order using `compareBuild()` (the whole version including build identifier (`[+BUILD]`) taken into account).
 *
 * @param list array of version strings
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns the sorted array
 *
 * @example
 * ```js
 * sort(['2.0.2', '1.2.3', '1.2.4', '1.2.4-foo.bar+build.123', '1.2.4-foo.bar+build.1234']) // [ "1.2.3", "1.2.4-foo.bar+build.123", "1.2.4-foo.bar+build.1234", "1.2.4", "2.0.2" ]
 * ```
 */
declare const sort: (list: string[], optionsOrLoose?: boolean | Options) => string[];

/**
 * Return the parsed version as a string, or `null` if it's not valid.
 *
 * @param version version string
 * @param optionsOrLoose an options object `{ loose }` (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings
 *
 * @returns the parsed version as a string, or `null` if it's not valid
 *
 * @example
 * ```js
 * valid('1.2.3') // '1.2.3'
 * valid('1.2.3-foo.bar+build.12345') // 1.2.3-foo.bar
 * valid('1.2') // null
 * ```
 */
declare const valid: (version: string, optionsOrLoose?: boolean | Options) => string | null;

export { type CoerceOptions, type IdentifierBase, type Operator, type Options, type ParsedVersion, type ReleaseType, clean, cmp, coerce, compare, compareBuild, compareIdentifiers, compareLoose, diff, eq, gt, gte, inc, incThrow, lt, lte, major, minor, neq, parse, patch, prerelease, rcompare, rsort, FULL as semverRegex, sort, valid };
