export type BillingPeriod = "monthly" | "annual";

export interface PricingFeature {
  label: string;
  info?: boolean;
}

export interface PricingTier {
  id: "lite" | "pro" | "business";
  name: string;
  description: string;
  monthlyPrice: number;
  /** Per-month price when yearly billing is selected */
  annualMonthlyPrice: number;
  compareAtAnnualPrice?: number;
  promoLabel?: string;
  featuresHeading?: string;
  features: PricingFeature[];
  cta: string;
  highlighted?: boolean;
}

export const ANNUAL_SAVINGS_PERCENT = 20;

export const PRICING_TIERS: PricingTier[] = [
  {
    id: "lite",
    name: "Lite",
    description: "Gain access to premium features for personal use.",
    monthlyPrice: 8,
    annualMonthlyPrice: 8,
    features: [
      { label: "400 AI credits / month", info: true },
      { label: "5 HD720 template exports" },
      { label: "Access to Premium AI models" },
      { label: "Limited catalog of 1M+ stock footage, music, and photos" },
      { label: "1 premium website on your own domain" },
      { label: "10 GB cloud storage" },
    ],
    cta: "Subscribe",
  },
  {
    id: "pro",
    name: "Pro",
    description:
      "Become a pro and unlock more powerful video, design and website editing tools for commercial use.",
    monthlyPrice: 29,
    annualMonthlyPrice: 14.5,
    compareAtAnnualPrice: 29,
    promoLabel: "First year 50% OFF",
    featuresHeading: "All Lite features, with",
    highlighted: true,
    features: [
      { label: "1600 AI credits / month" },
      { label: "Unlimited HD720 AI video creations" },
      { label: "Unlimited AI image processing" },
      { label: "Unlimited Full HD1080 template exports" },
      { label: "Full catalog of 5M+ stock footage, music, and photos" },
    ],
    cta: "Subscribe",
  },
  {
    id: "business",
    name: "Business",
    description:
      "Advanced level solution for teams and businesses. Includes reseller license.",
    monthlyPrice: 49,
    annualMonthlyPrice: 34.3,
    compareAtAnnualPrice: 49,
    promoLabel: "First year 30% OFF",
    featuresHeading: "All Pro features, with",
    features: [
      { label: "3000 AI credits / month" },
      { label: "Unlimited HD1080 AI video creations" },
      { label: "Unlimited Ultra HD 4K template exports" },
      { label: "Reseller license & Team management" },
      { label: "Team members", info: true },
      { label: "100 GB cloud storage" },
    ],
    cta: "Subscribe",
  },
];

export function getDisplayPrice(
  tier: PricingTier,
  billing: BillingPeriod
): number {
  if (billing === "annual") return tier.annualMonthlyPrice;
  return tier.monthlyPrice;
}

export function getCompareAtPrice(
  tier: PricingTier,
  billing: BillingPeriod
): number | null {
  if (billing === "annual" && tier.compareAtAnnualPrice != null) {
    return tier.compareAtAnnualPrice;
  }
  return null;
}

export type CompareValue = true | false | string;

export interface CompareRow {
  feature: string;
  tooltip?: string;
  lite: CompareValue;
  pro: CompareValue;
  business: CompareValue;
}

export interface CompareSection {
  title: string;
  rows: CompareRow[];
}

export const COMPARE_ANNUAL_SAVINGS_BADGE = 40;

export const COMPARE_SECTIONS: CompareSection[] = [
  {
    title: "Video",
    rows: [
      {
        feature: "Projects",
        lite: "Unlimited",
        pro: "Unlimited",
        business: "Unlimited",
      },
      {
        feature: "Duration",
        lite: "Unlimited",
        pro: "Unlimited",
        business: "Unlimited",
      },
      {
        feature: "Export Quality",
        lite: "HD 720",
        pro: "HD 1080",
        business: "UHD 4K",
      },
      {
        feature: "Stock footage",
        lite: "1M+ clips",
        pro: "5M+ clips",
        business: "5M+ clips",
      },
      {
        feature: "No watermarks",
        lite: "5 / month",
        pro: true,
        business: true,
      },
      {
        feature: "Text to speech",
        lite: "50 mins / month",
        pro: "100 mins / month",
        business: "300 mins / month",
      },
      {
        feature: "Unlimited color palettes",
        lite: true,
        pro: true,
        business: true,
      },
      {
        feature: "Upload custom fonts",
        lite: true,
        pro: true,
        business: true,
      },
      {
        feature: "1M+ premium templates",
        lite: true,
        pro: true,
        business: true,
      },
      {
        feature: "Custom watermark",
        lite: false,
        pro: false,
        business: true,
      },
      {
        feature: "Reseller license",
        lite: false,
        pro: false,
        business: "Up to 10 clients",
      },
      {
        feature: "Team management",
        lite: false,
        pro: false,
        business: true,
      },
    ],
  },
  {
    title: "AI Credits",
    rows: [
      {
        feature: "Generate AI videos & images",
        lite: "400 / month",
        pro: "1,600 / month",
        business: "3,000 / month",
      },
    ],
  },
  {
    title: "AI Video Generation",
    rows: [
      {
        feature: "Quick AI videos (5 sec)",
        lite: "40 videos",
        pro: "Unlimited",
        business: "Unlimited",
      },
      {
        feature: "AI Image generation",
        lite: "50 / month",
        pro: "Unlimited",
        business: "Unlimited",
      },
    ],
  },
  {
    title: "Image Tools",
    rows: [
      {
        feature: "Background removal",
        lite: "10 / month",
        pro: "Unlimited",
        business: "Unlimited",
      },
      {
        feature: "Image export quality",
        lite: "HD",
        pro: "Full HD",
        business: "4K",
      },
    ],
  },
  {
    title: "Storage & Export",
    rows: [
      {
        feature: "Cloud storage",
        lite: "10 GB",
        pro: "50 GB",
        business: "100 GB",
      },
      {
        feature: "Download formats",
        lite: "MP4",
        pro: "MP4, GIF",
        business: "MP4, GIF, WebM",
      },
    ],
  },
];
