#import "@preview/t4t:0.3.2": is
#import "../utils/style.typ": 字号, 字体
#import "../utils/indent.typ": fake-par
#import "../utils/double-underline.typ": double-underline
#import "../utils/invisible-heading.typ": invisible-heading

// 本科生英文摘要页
#let bachelor-abstract-en(
  // documentclass 传入的参数
  anonymous: false,
  twoside: false,
  fonts: (:),
  info: (:),
  // 其他参数
  keywords: (),
  outline-title: "ABSTRACT",
  outlined: true,
  anonymous-info-keys: ("author-en", "supervisor-en"),
  leading: 1.28em,
  spacing: 1.28em,
  body,
) = {
  // 1.  默认参数
  fonts = 字体 + fonts
  info = (
    title-en: "non-Bullsh*t generatoe with ChatGPT",
    author-en: "<NAME>",
    department-en: "XX Department",
    major-en: "XX Major",
    supervisor-en: "Professor <NAME>",
  ) + info

  // 2.  对参数进行处理
  // 2.1 如果是字符串，则使用换行符将标题分隔为列表
  if (is.str(info.title-en)) {
    info.title-en = info.title-en.split("\n")
  }

  // 3.  内置辅助函数
  let info-value(key, body) = {
    if (not anonymous or (key not in anonymous-info-keys)) {
      body
    }
  }

  // 4.  正式渲染
  [

    #set text(font: "Times New Roman", size: 字号.五号)
    #set par(leading: leading, justify: true)
    #show par: set block(spacing: spacing)

    #align(center)[
      #set text(font: "Times New Roman", size: 字号.三号, weight: "bold")  
      #(("",)+ info.title-en).sum()

    ]
    #v(2em)

    #text(font: "Times New Roman", size: 字号.小四, weight: "bold")[Abstract:]
    #[
      #body
    ]

    #v(1em)

    #text(font: "Times New Roman", size: 字号.小四, weight: "bold")[Key words:]
    #(("",)+ keywords.intersperse("; ")).sum()
  ]
}
