from pathlib import Path

root = Path(__file__).resolve().parents[2]
checks = {
    "factory carousel": (root / "MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Navigation.vb", "Public Function AddContentCarousel"),
    "factory palette": (root / "MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Navigation.vb", "Public Function AddCommandPalette"),
    "carousel default looping": (root / "Component/Navigation/ContentCarousel/MASContentCarousel.vb", "Private _isLooping As Boolean = True"),
    "carousel max": (root / "Component/Tokens/Component/ContentCarouselTokens.vb", "Friend Const MaxItems As Integer = 64"),
    "carousel default title": (root / "Component/Tokens/Component/ContentCarouselTokens.vb", 'Friend Const DefaultTitle As String = "Content carousel"'),
    "carousel duplicate case-insensitive": (root / "Component/Navigation/ContentCarousel/MASContentCarousel.ItemModel.vb", "StringComparison.OrdinalIgnoreCase"),
    "carousel events": (root / "Component/Navigation/ContentCarousel/MASContentCarousel.vb", "Public Event SelectedItemChanged As EventHandler"),
    "palette stable index": (root / "docs/reference/api/all-public-types-index.md", "`MASCommandPalette` | Class | Stable | V1Stable"),
    "palette defaults": (root / "Component/Navigation/CommandPalette/MASCommandPalette.vb", 'Private _title As String = "Command Palette"'),
    "palette add": (root / "Component/Navigation/CommandPalette/MASCommandPalette.vb", "Public Function AddCommand(commandId As String"),
    "palette execute": (root / "Component/Navigation/CommandPalette/MASCommandPalette.vb", "Public Function ExecuteSelectedCommand() As Boolean"),
    "palette keyboard": (root / "Component/Navigation/CommandPalette/MASCommandPalette.vb", "Case Keys.PageDown"),
    "palette recents": (root / "Component/Navigation/CommandPalette/MASCommandPalette.vb", "If _recentCommandIds.Count > 8"),
    "documentation": (root / "docs/reference/controls/content-carousel-and-command-palette.md", "# Content Carousel and Command Palette"),
}
failed = []
for name, (path, needle) in checks.items():
    text = path.read_text(encoding="utf-8-sig")
    if needle not in text:
        failed.append(f"{name}: {path} missing {needle!r}")
if failed:
    print("Assertions failed:")
    print("\n".join(failed))
    raise SystemExit(1)
print(f"Assertions: {len(checks)} passed, 0 failed")
