/** * Centralized Habbo avatar imager utility. * Points to the self-hosted imager API (`/api/imaging/avatar`) which handles * disk + memory caching and (Phase 2) local rendering from .nitro bundles. * Override with NEXT_PUBLIC_IMAGER_URL when needed (e.g. CDN in front). */ const IMAGER_URL = process.env.NEXT_PUBLIC_IMAGER_URL || "/api/imaging/avatar"; export type { AvatarOptions } from "@/types/admin"; import type { AvatarOptions } from "@/types/admin"; /** * Build an avatar image URL served by the self-hosted imager. * * @example * getAvatarUrl('hr-893-45.hd-180-1.ch-210-66.lg-270-82') * getAvatarUrl(look, { size: 'l', headOnly: true }) * getAvatarUrl(look, { size: 'm', gesture: 'sml', direction: 2 }) */ export function getAvatarUrl(figure: string, options: AvatarOptions = {}): string { const { size = "m", direction = 2, headDirection = 3, headOnly = false, gesture, action } = options; const params = new URLSearchParams({ figure, direction: String(direction), head_direction: String(headDirection), size, }); if (headOnly) params.set("headonly", "1"); if (gesture) params.set("gesture", gesture); if (action) params.set("action", action); return `${IMAGER_URL}?${params.toString()}`; }