package com.example.support;

/**
 * One accessibility violation surfaced by axe-core: the rule id, its impact, a short help string
 * with a docs URL, how many DOM nodes failed the rule, and one sample node (CSS target + HTML) as
 * concrete evidence. Mirrors {@link SecurityFinding} - a small, printable value object. Generated /
 * shipped by L3git.
 */
public class A11yViolation {

    public final String id;         // axe rule id, e.g. "color-contrast"
    public final String impact;     // minor | moderate | serious | critical (null -> "minor")
    public final String help;       // one-line description of the rule
    public final String helpUrl;    // link to the rule's documentation
    public final int nodeCount;     // how many elements failed this rule
    public final String sampleTarget; // CSS selector of the first failing element
    public final String sampleHtml;   // outerHTML (trimmed) of the first failing element

    public A11yViolation(String id, String impact, String help, String helpUrl,
                         int nodeCount, String sampleTarget, String sampleHtml) {
        this.id = id;
        this.impact = (impact == null || impact.isEmpty()) ? "minor" : impact;
        this.help = help;
        this.helpUrl = helpUrl;
        this.nodeCount = nodeCount;
        this.sampleTarget = sampleTarget;
        this.sampleHtml = sampleHtml;
    }

    @Override
    public String toString() {
        return "[" + impact.toUpperCase() + "] " + id + " - " + help
                + " (" + nodeCount + (nodeCount == 1 ? " node" : " nodes") + ")";
    }
}
