import { NextResponse } from "next/server";
import { analyzeWebsiteAesthetics } from "@/lib/website-aesthetic-analysis";
import type { Business } from "@/lib/types";

export async function POST(request: Request) {
  try {
    const body = (await request.json()) as { business: Business };
    if (!body.business?.input) {
      return NextResponse.json({ error: "Missing business payload" }, { status: 400 });
    }

    const analysis = analyzeWebsiteAesthetics(body.business);
    return NextResponse.json({ analysis });
  } catch {
    return NextResponse.json({ error: "Analysis failed" }, { status: 500 });
  }
}
