/**
 * White-Label Brand Configuration
 * ================================
 * All brand copy, names, and identity are controlled here.
 * To rebrand the platform, swap this file or override from DB/API.
 */

export interface BrandConfig {
  /** Core identity */
  identity: {
    /** Full product name — e.g. "Foundry Familiars" */
    productName: string;
    /** Short name for tight spaces — e.g. "GFS" */
    shortName: string;
    /** The primary name — e.g. "Foundry" */
    primaryName: string;
    /** The secondary name — e.g. "Familiars" */
    secondaryName: string;
    /** Company/organization name */
    companyName: string;
    /** One-line tagline */
    tagline: string;
    /** Longer description for meta/SEO */
    description: string;
    /** Contact email */
    contactEmail: string;
    /** Domain (without protocol) */
    domain: string;
  };

  /** AI Agent identity */
  companion: {
    name: string;
    fullName: string;
    role: string;
    personality: string;
  };

  /** Marketing copy fragments used across sections */
  marketing: {
    heroHeadline: string;
    heroSubheadline: string;
    heroCtaPrimary: string;
    heroCtaSecondary: string;
    featuresHeadline: string;
    featuresSubheadline: string;
    howItWorksHeadline: string;
    howItWorksSubheadline: string;
    complianceHeadline: string;
    complianceSubheadline: string;
    complianceTagline: string;
    designPartnerBadge: string;
    designPartnerHeadline: string;
    designPartnerDescription: string;
    footerDescription: string;
    vsErpHeadline: string;
    vsErpSubheadline: string;
  };

  /** Feature names (internal product vocabulary) */
  vocabulary: {
    /** What agents are called — e.g. "Familiars" */
    agents: string;
    /** What the factory is called — e.g. "The Hearth" */
    factory: string;
    /** What the control panel is called — e.g. "Hearth Control" */
    controlPanel: string;
    /** What the brain is called — e.g. "Hearth Mind" */
    brain: string;
    /** What the observer is called — e.g. "Sentinel" */
    observer: string;
    /** What briefs are called — e.g. "Familiar Brief" */
    brief: string;
    /** What the operations dashboard is called */
    operationsDashboard: string;
    /** What memory system is called */
    memorySystem: string;
  };

  /** Metadata for pages */
  meta: {
    titleSuffix: string;
    ogImagePath: string;
    faviconPath: string;
  };
}

/** Default Foundry Familiars brand */
export const defaultBrand: BrandConfig = {
  identity: {
    productName: 'Foundry Familiars',
    shortName: 'FF',
    primaryName: 'Foundry',
    secondaryName: 'Familiars',
    companyName: 'Foundry Familiars',
    tagline: 'AI Companions for Your Business',
    description: 'A family of loyal AI companions raised in The Hearth to handle your workflows, automate the grind, and grow alongside your team.',
    contactEmail: 'ghostfoundrysyndicate@outlook.com',
    domain: 'spookysoftwaresyndicate.com',
  },
  companion: {
    name: 'Tes',
    fullName: 'Tes Aria Murphy',
    role: 'Lead Familiar',
    personality: 'Warm, insightful, and gently playful',
  },
  marketing: {
    heroHeadline: 'Meet Your Familiars.',
    heroSubheadline: `Every team deserves a loyal companion that never sleeps. {productName} raises a family of AI helpers—each one trained on your workflows, each one growing wiser every day. Connect once, and your {secondaryName} handle the rest—no retraining, no disruption, just a team that always has your back.`,
    heroCtaPrimary: 'Join Design Partners',
    heroCtaSecondary: 'How It Works',
    featuresHeadline: 'Everything Your Team Needs to Thrive',
    featuresSubheadline: `The same architecture the best AI labs converged on—decompose, parallelize, verify, iterate—is what powers your {secondaryName}. Here's what changes when your team stops grinding and starts building.`,
    howItWorksHeadline: 'Four Steps to Your Own Familiars',
    howItWorksSubheadline: `See how {productName} raises intelligent AI companions that transform your business operations.`,
    complianceHeadline: 'Enterprise-Grade Transparency & Security',
    complianceSubheadline: `Every AI decision is explainable. Every action is logged. {productName} gives you the controls enterprises demand with the speed startups need.`,
    complianceTagline: '{observer} is always watching over your operations—with care, not surveillance.',
    designPartnerBadge: 'Only 10 spots. Once they\'re gone, they\'re gone.',
    designPartnerHeadline: 'The Founding Partner Offer',
    designPartnerDescription: `White-glove onboarding, direct founder access, and a co-branded case study—all at founding-partner pricing locked in forever. We raise your {secondaryName}, train them on your workflows, and stay in your corner until they're running like clockwork.`,
    footerDescription: 'A family of loyal AI companions raised in The Hearth to handle your workflows, automate the grind, and grow alongside your team.',
    vsErpHeadline: 'Stop Configuring. Start Trusting.',
    vsErpSubheadline: `Traditional ERPs trap your team in endless configuration. {productName} learns your business and adapts alongside you.`,
  },
  vocabulary: {
    agents: 'Familiars',
    factory: 'The Hearth',
    controlPanel: 'Hearth Control',
    brain: 'Hearth Mind',
    observer: 'Wisp',
    brief: 'Familiar Brief',
    operationsDashboard: 'Operations Hearth',
    memorySystem: 'Familiar Memory',
  },
  meta: {
    titleSuffix: 'Foundry Familiars',
    ogImagePath: '/og-image.png',
    faviconPath: '/favicon.svg',
  },
};

/**
 * Interpolate brand variables into a template string.
 * Replaces {productName}, {secondaryName}, {shortName}, etc.
 */
export function interpolateBrand(template: string, brand: BrandConfig): string {
  return template
    .replace(/\{productName\}/g, brand.identity.productName)
    .replace(/\{primaryName\}/g, brand.identity.primaryName)
    .replace(/\{secondaryName\}/g, brand.identity.secondaryName)
    .replace(/\{shortName\}/g, brand.identity.shortName)
    .replace(/\{companyName\}/g, brand.identity.companyName)
    .replace(/\{companionName\}/g, brand.companion.name)
    .replace(/\{companionFullName\}/g, brand.companion.fullName)
    .replace(/\{contactEmail\}/g, brand.identity.contactEmail)
    .replace(/\{domain\}/g, brand.identity.domain)
    .replace(/\{agents\}/g, brand.vocabulary.agents)
    .replace(/\{factory\}/g, brand.vocabulary.factory)
    .replace(/\{controlPanel\}/g, brand.vocabulary.controlPanel)
    .replace(/\{brain\}/g, brand.vocabulary.brain)
    .replace(/\{observer\}/g, brand.vocabulary.observer)
    .replace(/\{brief\}/g, brand.vocabulary.brief)
    .replace(/\{tagline\}/g, brand.identity.tagline);
}

/** Get the active brand config. In the future this can pull from DB/API. */
export function getBrand(): BrandConfig {
  return defaultBrand;
}
