/**
 * Converts a string theme version to the object with numbers
 * @param str A string with version (e.g. "1.0")
 * @param [separator="."] Optional major and minor string separator. By default is "."
 * @returns An object of type { major: number; minor: number } or null, if the given string is invalid
 */
export var parseThemeVersion = function parseThemeVersion(str, separator) {
  if (separator === void 0) {
    separator = '\\.';
  }
  var match = str.match(new RegExp("(\\d+)" + separator + "(\\d+)"));
  var major = match == null ? void 0 : match[1];
  var minor = match == null ? void 0 : match[2];
  if (!major || !minor) {
    return null;
  }
  return {
    major: Number(major),
    minor: Number(minor)
  };
};

/**
 * Extracts a version from a theme name
 * @param name A string theme name (e.g. "LIGHT_THEME_1_0")
 * @returns An object of type { major: number; minor: number } or null, if the given string is invalid or contains no version
 */
export var parseVersionFromThemeName = function parseVersionFromThemeName(name) {
  return parseThemeVersion(name, '_');
};

/**
 * Checks if one string theme version is "greater or equal" than another one
 * @param v1 The version being compared (e.g. "1.0")
 * @param v2 The version being compared to (e.g. "2.0")
 * @returns Boolean result
 */
export var isThemeVersionGTE = function isThemeVersionGTE(v1, v2) {
  var parsedV1 = parseThemeVersion(v1);
  var parsedV2 = parseThemeVersion(v2);
  if (!parsedV1 || !parsedV2) {
    return false;
  }
  if (parsedV1.major > parsedV2.major) {
    return true;
  } else if (parsedV1.major === parsedV2.major) {
    return parsedV1.minor >= parsedV2.minor;
  }
  return false;
};