export interface ProfileRecord { id: string display_name: string description: string avatar_path: string | null created_at: string updated_at: string } export function profileAvatarUrl(profile: Pick, supabaseUrl: string): string | null { if (!profile.avatar_path) return null const encodedPath = profile.avatar_path.split('/').map(encodeURIComponent).join('/') const version = encodeURIComponent(profile.updated_at) return `${supabaseUrl.replace(/\/$/, '')}/storage/v1/object/public/profile-avatars/${encodedPath}?v=${version}` } export function visibleProfile(profile: ProfileRecord, supabaseUrl: string) { return { id: profile.id, display_name: profile.display_name, description: profile.description, avatar_url: profileAvatarUrl(profile, supabaseUrl), created_at: profile.created_at, updated_at: profile.updated_at, } }