// Our explanation for every axe-core rule. A test checks that every rule of the pinned axe-core release has one,
// so an upgrade that adds a rule fails until its text is written.
import { RULE_TEXTS_A } from "./rule-texts-a.js";
import { RULE_TEXTS_B } from "./rule-texts-b.js";
import type { AxeRule, RuleText } from "./types.js";

export const RULE_TEXTS: Readonly<Record<string, RuleText>> = { ...RULE_TEXTS_A, ...RULE_TEXTS_B };

/** Our text for a rule; for a rule we have no text for, a plain text built from axe's own help and description. */
export function ruleText(rule: Pick<AxeRule, "id" | "help" | "description" | "helpUrl">): RuleText {
  return (
    RULE_TEXTS[rule.id] ?? {
      title: rule.help,
      whatIsWrong: rule.description,
      whoIsAffected: "People who use assistive technology, such as a screen reader, may not be able to use this element.",
      fixSteps: [`Read the rule documentation at ${rule.helpUrl} and change the element it names.`],
    }
  );
}
