// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
import type { Comparator, SemVer } from "./types.ts";

/**
 * MAX is a sentinel value used by some range calculations.
 * It is equivalent to `∞.∞.∞`.
 */
export const MAX: SemVer = {
  major: Number.POSITIVE_INFINITY,
  minor: Number.POSITIVE_INFINITY,
  patch: Number.POSITIVE_INFINITY,
  prerelease: [],
  build: [],
};

/**
 * The minimum valid SemVer object. Equivalent to `0.0.0`.
 */
export const MIN: SemVer = {
  major: 0,
  minor: 0,
  patch: 0,
  prerelease: [],
  build: [],
};

/**
 * A sentinel value used to denote an invalid SemVer object
 * which may be the result of impossible ranges or comparator operations.
 * @example
 * ```ts
 * import { equals } from "@std/semver/equals";
 * import { parse } from "@std/semver/parse";
 * import { INVALID } from "@std/semver/constants"
 * equals(parse("1.2.3"), INVALID);
 * ```
 */
export const INVALID: SemVer = {
  major: Number.NEGATIVE_INFINITY,
  minor: Number.POSITIVE_INFINITY,
  patch: Number.POSITIVE_INFINITY,
  prerelease: [],
  build: [],
};

/**
 * ANY is a sentinel value used by some range calculations. It is not a valid
 * SemVer object and should not be used directly.
 * @example
 * ```ts
 * import { equals } from "@std/semver/equals";
 * import { parse } from "@std/semver/parse";
 * import { ANY } from "@std/semver/constants"
 * equals(parse("1.2.3"), ANY); // false
 * ```
 */
export const ANY: SemVer = {
  major: Number.NaN,
  minor: Number.NaN,
  patch: Number.NaN,
  prerelease: [],
  build: [],
};

/**
 * A comparator which will span all valid semantic versions
 */
export const ALL: Comparator = {
  operator: undefined,
  ...ANY,
};

/**
 * A comparator which will not span any semantic versions
 */
export const NONE: Comparator = {
  operator: "<",
  ...MIN,
};

// denoCacheMetadata={"headers":{"cf-ray":"a223e657ba537db6-LAX","etag":"\"737513b0898610164cf853090f0ee4c0\"","cross-origin-resource-policy":"cross-origin","x-content-type-options":"nosniff","content-security-policy":"default-src 'none'; script-src 'none'; style-src 'none'; img-src 'none'; font-src 'none'; connect-src 'none'; frame-src 'none'; object-src 'none'; frame-ancestors 'none'; sandbox; form-action 'none';","x-robots-tag":"noindex","alt-svc":"h3=\":443\"; ma=86400","set-cookie":"__cf_bm=pbicKIduxPgiPOGKHfb3kGsjaKVXzoyO_CQ9qptEhAk-1785241875.1541257-1.0.1.1-fcjKXVAylf4fYMNvamhoNofBVtZuFLBdCfbpxZ8uTKkzvWVWVnVTLXfuZdniEYaH.rJGDTy21bk5qbJrlueZtoHaekCn7KBwbOLBUtUyPKA2LkyoBkTPyeqqIwa2EEuz; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","date":"Tue, 28 Jul 2026 12:31:15 GMT","accept-ranges":"bytes","access-control-allow-origin":"*","age":"36703","content-type":"text/typescript","access-control-expose-headers":"*","server":"cloudflare","cf-cache-status":"HIT","cache-control":"public, max-age=31536000, immutable","content-length":"1875","vary":"Origin","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=Q2XFC6Z40GRE5AeTOo01DV952fzM8RhxTciQEKy0ogLYh4gBtoTcQiqHwNzfIHSBoKGhoxqLSLsTF9mnxyxk5NwQwsrFgiKJ4a0hQ0RamUSBQShvmiuIE2U%3D\"}]}","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","x-jsr-backend":"modules"},"url":"https://jsr.io/@std/semver/0.224.3/constants.ts","time":1785241875}