const allowedPasswordCharactersString = "~@#%^*_+=-?:{}[]\\/";
const allPasswordCharacters = `$&+,:;=?@#|'<>.^*()%!-`;
const escapeForRegex = (str) => str.replace(/[-\\[\]^]/g, "\\$&");
const requirements = [{
  re: /^.{8,}$/,
  label: "Содержит не менее 8 символов"
}, {
  re: /^[a-zA-Z0-9$&+,:;=?@#|'<>.^*()%!/-]*$/,
  label: "Содержит только латинские символы"
}, {
  re: /[0-9]/,
  label: "добавьте число"
}, {
  re: /[a-z]/,
  label: "добавьте строчную букву"
}, {
  re: /[A-Z]/,
  label: "добавьте заглавную букву"
}, {
  re: /[$&+,:;=?@#|'<>.^*()%!-]/,
  label: "добавьте специальные символы (! “ # $ % ‘ () *)"
}];
const getPasswordStrength = (strength, t) => {
  if (strength < 50) {
    return {
      color: "#FF6B6B",
      strengthString: t("passwordReset.reliability.unreliable")
    };
  } else if (strength >= 50 && strength < 100) {
    return {
      color: "#FCC419",
      strengthString: t("passwordReset.reliability.quite_reliable")
    };
  } else if (strength === 100) {
    return {
      color: "#51CF66",
      strengthString: t("passwordReset.reliability.reliable")
    };
  } else {
    return {
      color: "",
      strengthString: ""
    };
  }
};
new RegExp(requirements.map(({
  re
}) => `(${re.source})`).join("|"));
const generatePassword = (regex, minLength) => {
  const characters = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789${allPasswordCharacters}`;
  let password = "";
  const minimumLength = minLength || 8;
  while (!regex.test(password)) {
    password = "";
    for (let i = 0; i <= minimumLength; i++) {
      password += characters.charAt(Math.floor(Math.random() * characters.length));
    }
  }
  return password;
};
function generatePasswordRegExp({
  options = {},
  maxLengthPassword = 30
}) {
  const characterClasses = [];
  characterClasses.push("(?!.*\\s)");
  if (options.UseLowLetter) {
    characterClasses.push("(?=.*[a-z])");
  }
  if (options.UseCapitalLetters) {
    characterClasses.push("(?=.*[A-Z])");
  }
  if (options.UseDigital) {
    characterClasses.push("(?=.*[0-9])");
  }
  let allowedCharacters = "";
  if (options.UseSpecialCharacters) {
    if (options.UseAllowedSpecialCharacters) {
      const escapedAllowed = escapeForRegex(allowedPasswordCharactersString);
      characterClasses.push(`(?=.*[${escapedAllowed}])`);
      allowedCharacters = `a-zA-Z0-9${escapedAllowed}`;
    } else {
      characterClasses.push(`(?=.*[^a-zA-Z0-9])`);
      allowedCharacters = `\\x21-\\x7E`;
    }
  } else {
    allowedCharacters = "a-zA-Z0-9";
  }
  const minLength = options.MinLength && options.MinLength >= 8 && options.MinLength <= 30 ? options.MinLength : 8;
  const pattern = `^${characterClasses.join("")}(?!.*[^${allowedCharacters}])[${allowedCharacters}]{${minLength},${maxLengthPassword}}$`;
  return new RegExp(pattern);
}
export {
  generatePassword as a,
  generatePasswordRegExp as b,
  allowedPasswordCharactersString as c,
  getPasswordStrength as g
};
//# sourceMappingURL=passwordUtils-B3CN2t6O.js.map
