import type { SidebarsConfig } from '@docusaurus/plugin-content-docs';

// NOTE: Guide ordering is controlled entirely by the explicit items below.
// sidebar_position frontmatter in guide files has been removed and is not used.

const sidebars: SidebarsConfig = {
  // ── Documentation sidebar ──
  docsSidebar: [
    'intro',

    // ── Getting Started ──
    {
      type: 'category',
      label: 'Getting Started',
      collapsed: false,
      items: [
        'guides/getting-started',
        'guides/authentication',
        'guides/agent-setup',
        'guides/running-your-agent',
        'guides/playwright-primer',
        {
          type: 'category',
          label: 'Your Background',
          items: [
            'guides/migration-from-playwright',
            'guides/migration-from-selenium',
            'guides/migration-from-wdi5',
            'guides/migration-from-tosca',
            'guides/sap-business-analyst-guide',
          ],
        },
      ],
    },

    // ── AI-Powered Testing ──
    {
      type: 'category',
      label: 'AI-Powered Testing',
      items: [
        'guides/ai-integration',
        'guides/intent-api',
        'guides/vocabulary-system',
        'guides/capabilities-recipes',
        'guides/agent-framework-integrations',
        {
          type: 'category',
          label: 'Playwright CLI',
          link: { type: 'doc', id: 'guides/playwright-cli-overview' },
          items: [
            'guides/playwright-cli-setup',
            'guides/playwright-cli-discovery',
            'guides/playwright-cli-iframes',
            'guides/playwright-cli-agents',
            'guides/browser-bind',
            'guides/mcp-vs-cli',
            'guides/playwright-cli-reference',
          ],
        },
      ],
    },

    // ── Claude Code Plugin ──
    {
      type: 'category',
      label: 'Claude Code Plugin',
      items: [
        'guides/claude-code-plugin-overview',
        'guides/claude-code-plugin-installation',
        'guides/claude-code-plugin-commands',
        'guides/claude-code-plugin-agents-skills',
        'guides/claude-code-plugin-mandatory-rules',
        'guides/claude-code-plugin-forbidden-patterns',
        'guides/claude-code-plugin-walkthrough',
        'guides/claude-code-plugin-troubleshooting',
        'guides/claude-cowork-plugin',
      ],
    },

    // ── Writing Tests ──
    {
      type: 'category',
      label: 'Writing Tests',
      items: [
        'guides/control-interactions',
        'guides/selectors',
        'guides/locator-selector-syntax',
        'guides/navigation',
        'guides/typed-controls',
        'guides/discovery-and-interaction',
        'guides/custom-matchers',
        'guides/gold-standard-test',
        'guides/business-process-examples',
      ],
    },

    // ── SAP Testing Patterns ──
    {
      type: 'category',
      label: 'SAP Testing Patterns',
      items: [
        'guides/fiori-elements',
        'guides/sap-control-cookbook',
        'guides/transaction-mapping',
        'guides/odata-operations',
        'guides/odata-mocking',
        'guides/upgrade-testing',
      ],
    },

    // ── Debugging & Monitoring ──
    {
      type: 'category',
      label: 'Debugging & Monitoring',
      items: [
        'guides/inspect-command',
        'guides/debugging',
        'guides/errors',
        'guides/troubleshooting',
        'guides/debugging-agent-failures',
        'guides/reporters',
        'guides/telemetry',
        'guides/performance-benchmarks',
        {
          type: 'doc',
          id: 'guides/example-reports',
          label: 'Report Architecture',
        },
      ],
    },

    // ── Test Strategies ──
    {
      type: 'category',
      label: 'Test Strategies',
      items: [
        'guides/accessibility-testing',
        'guides/component-testing',
        'guides/cross-browser',
        'guides/visual-regression',
        'guides/test-data-management',
        'guides/i18n-testing',
        'guides/security-testing',
        'guides/websocket-testing',
      ],
    },

    // ── Deploying & Scaling ──
    {
      type: 'category',
      label: 'Deploying & Scaling',
      items: ['guides/docker-cicd', 'guides/parallel-execution'],
    },

    // ── Integrations ──
    {
      type: 'category',
      label: 'Integrations',
      items: [
        'guides/multi-tool-integration',
        'guides/cloud-alm-integration',
        'guides/sap-activate-alignment',
        'guides/azure-playwright-workspaces',
      ],
    },

    // ── Reference ──
    {
      type: 'category',
      label: 'Reference',
      items: [
        'guides/quick-reference',
        'guides/configuration',
        'guides/compatibility',
        'guides/stability-timing',
        'guides/fixtures',
        'guides/fixture-composition',
        {
          type: 'doc',
          id: 'guides/capabilities',
          label: 'Feature Inventory',
        },
        'reference/capability-registry',
        'guides/glossary',
      ],
    },

    // ── Architecture (collapsed by default — most users don't need internals) ──
    {
      type: 'category',
      label: 'Architecture',
      collapsed: true,
      items: [
        'guides/architecture-overview',
        'guides/control-proxy',
        'guides/bridge-internals',
        'guides/behavioral-equivalence',
        'guides/lifecycle-extensibility',
        'guides/custom-controls',
      ],
    },

    // ── Examples (autogenerated from docs/examples/) ──
    {
      type: 'category',
      label: 'Examples',
      items: [{ type: 'autogenerated', dirName: 'examples' }],
    },

    'release-notes',
    'changelog',
    'security',
  ],

  // ── API Reference sidebar — auto-generated by docusaurus-plugin-typedoc ──
  apiSidebar: [
    {
      type: 'autogenerated',
      dirName: 'api',
    },
  ],
};

export default sidebars;
