import type { BusinessProfile, OnboardingInput } from "@/lib/types";

export function buildBusinessProfile(input: OnboardingInput): BusinessProfile {
  const competitors = (input.mainCompetitors ?? "")
    .split(",")
    .map((c) => c.trim())
    .filter(Boolean);

  return {
    companySummary: `${input.businessName} is a ${input.businessType.toLowerCase()} in ${input.industryCategory ?? input.industry}, based in ${input.location}. Current revenue range: ${input.monthlyRevenueRange}. Primary focus: ${input.productsServices}.`,
    brandPositioning: `${input.businessName} helps ${input.targetCustomer.toLowerCase()} solve ${input.biggestChallenge.toLowerCase()} through ${input.productsServices.toLowerCase()}.`,
    targetAudience: input.targetCustomer,
    productsServices: input.productsServices,
    strengths: [
      `Clear offer: ${input.productsServices}`,
      `Defined revenue goal: ${input.revenueGoal}`,
      input.websiteUrl ? "Digital presence established" : "Opportunity to launch strong digital presence",
    ],
    weaknesses: [
      input.biggestChallenge,
      competitors.length > 0 ? "Competitive pressure in local/market category" : "Competitive landscape not yet mapped",
      input.monthlyRevenueRange === "Pre-revenue" ? "Limited revenue proof for scaling" : "Growth execution bandwidth",
    ],
    marketOpportunities: [
      `Capture demand from ${input.targetCustomer.toLowerCase()} searching for ${input.productsServices.toLowerCase()}`,
      "Content-led authority in your category",
      competitors.length > 0 ? `Win share from ${competitors[0]}` : "Define and monitor top local competitors",
    ],
    suggestedCompetitors:
      competitors.length > 0
        ? competitors
        : [`Leading ${input.industry} provider`, `Local ${input.industry} alternative`],
    brandImprovements: [
      "Sharpen homepage positioning around outcomes, not features",
      "Add social proof near primary conversion points",
      "Launch weekly content tied to buyer questions",
      "Build a simple referral offer for existing customers",
    ],
  };
}
