/**
 * Constructs the correct client-side redirect path for an audit result page,
 * accounting for the audit.meseoapp.com subdomain rewrite.
 *
 * On audit.meseoapp.com the middleware rewrites:
 *   /{id}        → /audit/{id}   (internal Next.js route, correct)
 *   /audit/{id}  → /audit/audit/{id}  (double-prefix, 404)
 *
 * So on the audit subdomain we navigate to /{id}, not /audit/{id}.
 * On app.meseoapp.com (no rewrite) we navigate to /audit/{id} as normal.
 *
 * Must only be called in client components (reads window.location).
 */
export function getAuditResultPath(auditId: string): string {
  if (typeof window === "undefined") return `/audit/${auditId}`;
  const isAuditSubdomain =
    window.location.hostname === "audit.meseoapp.com" ||
    window.location.hostname === "audit.localhost";
  return isAuditSubdomain ? `/${auditId}` : `/audit/${auditId}`;
}
