/**
 * Host routing for the check-in lane. The lane is served on a dedicated
 * subdomain (`checkin.alqove.com`, D18) for edge-cache + cookie/storage
 * isolation from the main app. These pure helpers drive the middleware.
 */

export const CHECKIN_HOST =
  process.env.NEXT_PUBLIC_CHECKIN_HOST || "checkin.alqove.com";

/** True when the request's Host header is the check-in subdomain. */
export function isCheckinHost(host: string | null | undefined): boolean {
  if (!host) return false;
  const hostname = host.split(":")[0].toLowerCase();
  return hostname === CHECKIN_HOST.toLowerCase();
}

/**
 * On the check-in subdomain, only the public lane (`/c/...`) is served — every
 * other app path 404s so the main marketplace isn't reachable there. On any
 * other host (incl. localhost in dev), nothing is restricted.
 */
export function isPathAllowedOnCheckinHost(pathname: string): boolean {
  return pathname === "/c" || pathname.startsWith("/c/");
}
