///|
pub fn ColorToken::hex(
  name : String,
  value : String,
  role~ : String,
) -> ColorToken {
  { name, value, role }
}

///|
pub fn ColorToken::css_var(self : ColorToken) -> String {
  "--brand-\{self.name}: \{self.value};"
}

///|
pub fn Space::describe(self : Space) -> String {
  match self {
    Pixels(px) => "\{px}px"
    Multiplier(x) => "\{x}x logo height"
  }
}

///|
pub fn BackgroundRule::describe(self : BackgroundRule) -> String {
  match self {
    LightOnly => "light backgrounds only"
    DarkOnly => "dark backgrounds only"
    LightOrDark => "light or dark backgrounds"
    Monochrome => "single-color applications"
  }
}

///|
pub fn Severity::label(self : Severity) -> String {
  match self {
    Info => "info"
    Warning => "warning"
    Error => "error"
  }
}

///|
pub fn Finding::info(path : String, message : String) -> Finding {
  Finding::{ severity: Info, path, message }
}

///|
pub fn AuditReport::from_findings(findings : Array[Finding]) -> AuditReport {
  AuditReport::{ findings, }
}

///|
pub fn AuditReport::has_errors(self : AuditReport) -> Bool {
  self.findings.any(fn(f) { f.severity == Error })
}

///|
pub fn AuditReport::summary(self : AuditReport) -> String {
  let mut errors = 0
  let mut warnings = 0
  let mut infos = 0
  for finding in self.findings {
    match finding.severity {
      Error => errors += 1
      Warning => warnings += 1
      Info => infos += 1
    }
  }
  "\{errors} errors, \{warnings} warnings, \{infos} notes"
}