/** * AvatarDisplay * * Deterministic mapping of avatar-related data to display formats. */ export class AvatarDisplay { /** * Converts binary buffer to base64 string for display. */ static bufferToBase64(buffer: ArrayBuffer): string { const bytes = new Uint8Array(buffer); let binary = ''; for (let i = 0; i < bytes.byteLength; i++) { binary += String.fromCharCode(bytes[i]); } return btoa(binary); } /** * Determines if avatar data is valid for display. * Accepts base64-encoded string buffer. */ static hasValidData(buffer: string, contentType: string): boolean { return buffer.length > 0 && contentType.length > 0; } /** * Formats content type for display (e.g., "image/png" → "PNG"). */ static formatContentType(contentType: string): string { const parts = contentType.split('/'); if (parts.length === 2) { return parts[1].toUpperCase(); } return contentType; } }