import { slugify } from '@rareindex/shared'; /** URL slug for an auction house name (`/auctions/house/`). Deterministic; no DB round-trip. */ export function houseSlug(name: string): string { return slugify(name.replace(/[’']/g, '')) || 'house'; } /** Resolve a URL slug back to the house name known by the registry; null when nothing matches. */ export function resolveHouse(slug: string, houses: readonly T[]): T | null { const s = slug.trim().toLowerCase(); return houses.find((h) => houseSlug(h.house) === s) ?? null; } /** Ending-within presets exposed on /auctions (hours). */ export const ENDING_WINDOWS = [ { id: '24h', label: '24 h', hours: 24 }, { id: '72h', label: '72 h', hours: 72 }, { id: '7d', label: '7 days', hours: 168 }, ] as const; export type EndingWindow = (typeof ENDING_WINDOWS)[number]['id']; export function endingHours(id: string | null | undefined): number | null { return ENDING_WINDOWS.find((w) => w.id === id)?.hours ?? null; }