import type { SponsorDashboardDTO } from '@/lib/types/generated/SponsorDashboardDTO';
import type { SponsorDashboardViewData } from '@/lib/view-data/SponsorDashboardViewData';
import { CurrencyDisplay } from '@/lib/display-objects/CurrencyDisplay';
import { NumberDisplay } from '@/lib/display-objects/NumberDisplay';

/**
 * Sponsor Dashboard ViewData Builder
 *
 * Transforms SponsorDashboardDTO into ViewData for templates.
 * Deterministic and side-effect free.
 */
export class SponsorDashboardViewDataBuilder {
  static build(apiDto: SponsorDashboardDTO): SponsorDashboardViewData {
    const totalInvestmentValue = apiDto.investment.activeSponsorships * 1000;

    return {
      sponsorName: apiDto.sponsorName,
      totalImpressions: NumberDisplay.format(apiDto.metrics.impressions),
      totalInvestment: CurrencyDisplay.format(totalInvestmentValue),
      metrics: {
        impressionsChange: apiDto.metrics.impressions > 1000 ? 15 : -5,
        viewersChange: 8,
        exposureChange: 12,
      },
      categoryData: {
        leagues: { count: 2, countLabel: '2 active', impressions: 1500, impressionsLabel: '1,500' },
        teams: { count: 1, countLabel: '1 active', impressions: 800, impressionsLabel: '800' },
        drivers: { count: 3, countLabel: '3 active', impressions: 2200, impressionsLabel: '2,200' },
        races: { count: 1, countLabel: '1 active', impressions: 500, impressionsLabel: '500' },
        platform: { count: 0, countLabel: '0 active', impressions: 0, impressionsLabel: '0' },
      },
      sponsorships: apiDto.sponsorships,
      activeSponsorships: apiDto.investment.activeSponsorships,
      formattedTotalInvestment: CurrencyDisplay.format(totalInvestmentValue),
      costPerThousandViews: CurrencyDisplay.format(50),
      upcomingRenewals: [], // Mock empty for now
      recentActivity: [], // Mock empty for now
    };
  }
}