import type { TourStepProps } from 'antd';
import type { TourStepContext } from '../types';
import { domTarget } from '../types';

export function gettingStartedSteps(ctx: TourStepContext): TourStepProps[] {
  const steps: TourStepProps[] = [];

  // Step 1 (conditional): Change Password — only when org name is still default
  if (ctx.settings.organizationName === 'Changemaker Lite') {
    steps.push({
      title: 'Change Your Password',
      description:
        'Welcome! Your first step should be to change your default admin password. Click your user menu, then go to Users to update it.',
      target: domTarget('[data-tour="user-menu"]'),
      placement: 'bottomRight',
    });
  }

  // Step 2: Welcome & Dashboard (centered, no target)
  steps.push({
    title: 'Welcome to Your Dashboard',
    description:
      'This is your Dashboard — it shows key metrics about your organization: active campaigns, map locations, volunteers, and system health.',
    target: null,
  });

  // Step 3: Sidebar Navigation
  if (!ctx.isMobile) {
    steps.push({
      title: 'Sidebar Navigation',
      description:
        'The sidebar is your main navigation. Sections expand to reveal sub-pages. You can collapse it with the toggle button.',
      target: domTarget('[data-tour="sidebar"]'),
      placement: 'right',
    });
  }

  // Step 4: Settings
  steps.push({
    title: 'Settings',
    description:
      'Settings is where you configure your organization name, domain, email, theme, and feature modules. Visit this first after setup.',
    target: ctx.isMobile ? null : domTarget('[data-menu-id*="/app/settings"]'),
    placement: 'right',
  });

  // Step 5 (conditional): Campaigns
  if (ctx.settings.enableInfluence !== false) {
    steps.push({
      title: 'Advocacy Campaigns',
      description:
        'Advocacy Campaigns let you organize letter-writing and email campaigns to elected representatives.',
      target: ctx.isMobile ? null : domTarget('[data-menu-id*="influence"]'),
      placement: 'right',
    });
  }

  // Step 6 (conditional): Map & Canvassing
  if (ctx.settings.enableMap !== false) {
    steps.push({
      title: 'Map & Canvassing',
      description:
        'The Map module manages geographic locations, canvassing areas, and volunteer shifts for field operations.',
      target: ctx.isMobile ? null : domTarget('[data-menu-id*="map"]'),
      placement: 'right',
    });
  }

  // Step 7: Getting Help
  steps.push({
    title: 'Getting Help',
    description:
      'Use the search shortcut (Ctrl+K) to quickly find any page. Click the floating help button to explore more tutorials for each section.',
    target: domTarget('[data-tour="search-button"]'),
    placement: 'bottom',
  });

  return steps;
}
