from pathlib import Path
import sys

root = Path(__file__).resolve().parents[2]
checks = {
    "stepper default orientation": ("Component/Navigation/Stepper/MASStepper.vb", "Private _orientation As MASStepperOrientation = MASStepperOrientation.Horizontal"),
    "stepper initial index": ("Component/Navigation/Stepper/MASStepper.vb", "Private _currentIndex As Integer = -1"),
    "first step current": ("Component/Navigation/Stepper/MASStepper.vb", "If _currentIndex < 0 Then _currentIndex = 0"),
    "disabled step rejected": ("Component/Navigation/Stepper/MASStepper.vb", "If _steps(index).State = MASStepperStepState.Disabled Then Return"),
    "stepper next enabled": ("Component/Navigation/Stepper/MASStepper.vb", "ResolveNextEnabledIndex"),
    "wizard internal stepper": ("Component/Navigation/Stepper/MASWizard.vb", "Private ReadOnly _stepper As MASStepper"),
    "wizard content list": ("Component/Navigation/Stepper/MASWizard.vb", "Private ReadOnly _contents As New List(Of MASControlBase)()"),
    "wizard content attach": ("Component/Navigation/Stepper/MASWizard.vb", "ChildLayerInternal.Add(content)"),
    "wizard next delegation": ("Component/Navigation/Stepper/MASWizard.vb", "_stepper.MoveNext()"),
    "segmented defaults": ("Component/Selectors/SegmentedControl/MASSegmentedControl.vb", 'New MASSegmentEntry("built-in", "Built-in")'),
    "segmented minimum count": ("Component/Selectors/SegmentedControl/MASSegmentedControl.vb", "requires at least two segments"),
    "segmented unique ids": ("Component/Selectors/SegmentedControl/MASSegmentedControl.vb", "ValidateUniqueSegmentIds(nextItems)"),
    "segment id validation": ("Component/Selectors/SegmentedControl/MASSegmentEntry.vb", "Segment id cannot be empty."),
    "segment label validation": ("Component/Selectors/SegmentedControl/MASSegmentEntry.vb", "Segment label cannot be empty."),
    "factory stepper": ("MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Containers.vb", "Public Function AddStepper"),
    "factory wizard": ("MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Containers.vb", "Public Function AddWizard"),
    "factory segmented": ("MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Buttons.vb", "Public Function AddSegmentedControl"),
}
failed=[]
for name,(rel,needle) in checks.items():
    text=(root/rel).read_text(encoding='utf-8-sig')
    if needle not in text:
        failed.append(f"{name}: missing {needle!r} in {rel}")

doc=root/'docs/reference/controls/steppers-wizards-and-segmented-selection.md'
if not doc.exists(): failed.append('documentation file missing')
for rel in ['docs/reference-guide.md','docs/user/controls.md']:
    text=(root/rel).read_text(encoding='utf-8-sig')
    if 'steppers-wizards-and-segmented-selection.md' not in text:
        failed.append(f'link missing in {rel}')

if failed:
    print('\n'.join(failed))
    sys.exit(1)
print(f"Assertions: {len(checks)} passed, 0 failed")
