var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellEmail/utils/emailValidator.ts
var emailValidator_exports = {};
__export(emailValidator_exports, {
  validateEmail: () => validateEmail,
  validateEmailDomain: () => validateEmailDomain,
  validateEmailParts: () => validateEmailParts,
  validateEmailStrict: () => validateEmailStrict
});
module.exports = __toCommonJS(emailValidator_exports);
var import_emailRegex = require("../constants/emailRegex");
var import_emailHelper = require("./emailHelper");
function validateEmail(email) {
  if (!email) return true;
  return import_emailRegex.EMAIL_REGEX.test(email);
}
function validateEmailStrict(email) {
  if (!email) return true;
  return import_emailRegex.STRICT_EMAIL_REGEX.test(email);
}
function validateEmailParts(email) {
  const errors = [];
  if (!email.includes("@")) {
    errors.push("邮箱地址必须包含 @ 符号");
    return { isValid: false, errors };
  }
  const [localPart, domainPart] = email.split("@");
  if (!localPart || localPart.length === 0) {
    errors.push("@ 符号前不能为空");
  }
  if (localPart.length > 64) {
    errors.push("@ 符号前最多 64 个字符");
  }
  if (!domainPart || domainPart.length === 0) {
    errors.push("@ 符号后不能为空");
  }
  if (!domainPart.includes(".")) {
    errors.push("域名必须包含 . 符号");
  }
  if (domainPart.endsWith(".")) {
    errors.push("域名不能以 . 结尾");
  }
  const parts = domainPart.split(".");
  const tld = parts[parts.length - 1];
  if (tld && tld.length < 2) {
    errors.push("顶级域名至少 2 个字符");
  }
  return {
    isValid: errors.length === 0,
    errors
  };
}
function validateEmailDomain(email, allowedDomains, blockedDomains) {
  const errors = [];
  const domain = (0, import_emailHelper.extractEmailDomain)(email);
  if (!domain) {
    return { isValid: true, errors };
  }
  if (allowedDomains && allowedDomains.length > 0) {
    if (!allowedDomains.includes(domain)) {
      errors.push(`只允许以下域名：${allowedDomains.join(", ")}`);
    }
  }
  if (blockedDomains && blockedDomains.length > 0) {
    if (blockedDomains.includes(domain)) {
      errors.push("该邮箱域名不可用");
    }
  }
  return {
    isValid: errors.length === 0,
    errors
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  validateEmail,
  validateEmailDomain,
  validateEmailParts,
  validateEmailStrict
});
