/**
 * Centralized pricing configuration constants
 *
 * All magic numbers and hardcoded values for pricing should be defined here
 * to ensure consistency across the pricing page and related components.
 */

export const PRICING_CONFIG = {
  /**
   * Yearly discount percentage applied to monthly prices
   * Applied in: PricingClient, BillingToggle badge
   */
  YEARLY_DISCOUNT_PERCENT: 7,

  /**
   * Free trial duration in days
   * Displayed in: PricingClient banner, PricingFAQ
   */
  FREE_TRIAL_DAYS: 14,

  /**
   * Default setup price in GBP
   * Can be overridden per tier in pricing-tiers.ts
   */
  DEFAULT_SETUP_PRICE_GBP: 199,

  /**
   * Maximum number of features shown on pricing cards
   * Prevents card overflow with too many features
   */
  FEATURES_SHOWN_PER_CARD: 6,

  /**
   * ISR revalidation time for pricing page (in seconds)
   * 3600 = 1 hour cache duration
   */
  ISR_REVALIDATE_SECONDS: 3600,

  /**
   * Stripe configuration
   */
  STRIPE: {
    /**
     * Required metadata field on Stripe products to map to tier IDs
     */
    TIER_ID_METADATA_KEY: "tier_id" as const,

    /**
     * Required metadata field for feature list
     */
    FEATURES_METADATA_KEY: "features" as const,
  },
} as const;

/**
 * Calculate yearly discount multiplier from percentage
 * @returns multiplier to apply to base price (e.g., 0.93 for 7% discount)
 */
export function getYearlyDiscountMultiplier(): number {
  return 1 - PRICING_CONFIG.YEARLY_DISCOUNT_PERCENT / 100;
}

/**
 * Get the yearly discount percentage for display
 */
export function getYearlyDiscountText(isAr: boolean): string {
  const percent = PRICING_CONFIG.YEARLY_DISCOUNT_PERCENT;
  return isAr ? `وفّر ${percent}%` : `Save ${percent}%`;
}

/**
 * Get free trial text for display
 */
export function getFreeTrialText(isAr: boolean): string {
  const days = PRICING_CONFIG.FREE_TRIAL_DAYS;
  return isAr ? `تجربة مجانية لمدة ${days} يوماً` : `${days}-Day Free Trial`;
}
