const EMPTY_FIELD_PLACEHOLDER_PATTERNS = [
  /^(待确认|未知|通用|待识别|待识别文件|暂无|无|空|未填写|未提供|n\/?a|na|none|null)$/i,
  /^(?:Excel原始文件|PDF原始文件|Word原始文件|图片原始文件|原始文件)[，,]待识别$/,
  /^需人工核对原始文件$/,
  /^Excel 字段导入，如有缺漏请人工补充$/,
];

export function isEmptyFieldPlaceholder(value: unknown): boolean {
  if (value == null) {
    return true;
  }

  const text = String(value).trim();
  if (!text) {
    return true;
  }

  return EMPTY_FIELD_PLACEHOLDER_PATTERNS.some((pattern) => pattern.test(text));
}

export function normalizeEmptyFieldText(value: unknown): string {
  if (value == null) {
    return "";
  }

  const text = String(value).trim();
  return isEmptyFieldPlaceholder(text) ? "" : text;
}