from pathlib import Path
import sys

root = Path(__file__).resolve().parents[2]
checks = {
    "checkbox factory": ("MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Buttons.vb", "Public Function AddCheckBox"),
    "radio factory": ("MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Buttons.vb", "Public Function AddRadioButton"),
    "toggle factory": ("MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Buttons.vb", "Public Function AddToggleSwitch"),
    "status factory": ("MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Feedback.vb", "Public Function AddStatusBanner"),
    "validation factory": ("MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Feedback.vb", "Public Function AddValidationMessage"),
    "progress factory": ("MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Feedback.vb", "Public Function AddProgressBar"),
    "checkbox event": ("Component/Inputs/CheckBox/MASCheckBox.vb", "Public Event CheckedChanged As EventHandler"),
    "checkbox guard": ("Component/Inputs/CheckBox/MASCheckBox.vb", "CanInteract(Enabled, Visible)"),
    "radio group": ("Component/Inputs/RadioButton/MASRadioButton.vb", "Public Property GroupName As String"),
    "radio selection": ("Component/Inputs/RadioButton/MASRadioButton.vb", "Public Sub SelectThis()"),
    "toggle guard": ("Component/Inputs/ToggleSwitch/MASToggleSwitch.vb", "CanInteract(Enabled, Visible)"),
    "status tone": ("Component/Feedback/StatusBanner/MASStatusBanner.vb", "Public Property Tone As MASToastTone"),
    "validation state": ("Component/Feedback/ValidationMessage/MASValidationMessage.vb", "Public Property State As MASTextValidationState"),
    "progress event": ("Component/Feedback/ProgressBar/MASProgressBar.vb", "Public Event ValueChanged As EventHandler"),
    "progress range": ("Component/Feedback/ProgressBar/MASProgressBar.Api.vb", "Public Sub SetRange(min As Double, max As Double)"),
    "progress fraction": ("Component/Feedback/ProgressBar/MASProgressBar.Api.vb", "Public ReadOnly Property ProgressFraction As Single"),
    "range swap": ("Component/Feedback/ProgressBar/MASProgressBarValuePolicy.vb", "If maxValue < minValue Then"),
    "percent clamp": ("Component/Feedback/ProgressBar/MASProgressBarValuePolicy.vb", "Return Clamp(value, 0.0R, 100.0R)"),
    "reference doc": ("docs/reference/controls/selection-and-feedback.md", "# Selection and Feedback Controls — Source-Verified Reference"),
    "recipe link": ("docs/recipes/feedback.md", "../reference/controls/selection-and-feedback.md"),
}
failed=[]
for name,(rel,needle) in checks.items():
    p=root/rel
    text=p.read_text(encoding="utf-8-sig") if p.exists() else ""
    if needle not in text: failed.append(f"{name}: {rel} missing {needle!r}")
print(f"Assertions: {len(checks)-len(failed)} passed, {len(failed)} failed")
for item in failed: print("FAIL", item)
sys.exit(1 if failed else 0)
