import type { OoMoment } from "@rakazo/core"; import { ACTIVE_RUN_STATUSES, DEFAULT_OO_AVATAR, decodeOoAvatar, ooIdentityShapeIndex, ooMomentForStatus, resolveOoColor, } from "@rakazo/core"; import { memo, useMemo } from "react"; import { Image, View } from "react-native"; import { useI18n } from "../lib/i18n"; import { NativeSymbol } from "./native-symbol"; import { OoFigure } from "./oo-figure"; export const BotAvatar = memo(function BotAvatar({ color, size = 54, status, identity, moment, still, muted = false, }: { color: string; size?: number; status?: string; identity?: string; /** Explicit moment; wins over `status`. */ moment?: OoMoment; still?: boolean; muted?: boolean; }) { const { t } = useI18n(); const isWorking = ACTIVE_RUN_STATUSES.some((activeStatus) => activeStatus === status); const picture = color.startsWith("data:image/") ? color : null; const look = useMemo(() => decodeOoAvatar(color) ?? DEFAULT_OO_AVATAR, [color]); const seed = identity || (picture ? "agent" : color) || "agent"; const body = resolveOoColor(seed, look.color).hex; return ( {picture ? ( ) : ( )} {isWorking ? ( ) : null} {muted ? ( ) : null} ); });