import React from "react"; import { Stack, Box, Typography, Tabs, Tab, CircularProgress, Button, IconButton, Tooltip, alpha } from "@mui/material"; import { Person as PersonIcon, Info as InfoIcon, CheckCircle as CheckCircleIcon, Refresh as RefreshIcon, Collections as CollectionsIcon, Delete as DeleteIcon, AutoAwesome as AutoAwesomeIcon, CloudUpload as CloudUploadIcon, PhotoCamera as PhotoCameraIcon, } from "@mui/icons-material"; import { AvatarAssetBrowser } from "../AvatarAssetBrowser"; import { CameraSelfie } from "../CameraSelfie"; import { SecondaryButton } from "../ui"; interface AvatarSelectorProps { avatarTab: number; setAvatarTab: (event: React.SyntheticEvent, newValue: number) => void; avatarFile: File | null; avatarPreview: string | null; avatarUrl: string | null; loadingBrandAvatar: boolean; handleUseBrandAvatar: () => void; handleAvatarSelectFromLibrary: (url: string) => void; handleAvatarChange: (e: React.ChangeEvent) => void; handleCameraSelfie: (imageDataUrl: string) => void; handleRemoveAvatar: () => void; handleMakePresentable: () => void; makingPresentable: boolean; avatarPreviewBlobUrl: string | null; brandAvatarFromDb?: string | null; brandAvatarBlobUrl?: string | null; cameraSelfieOpen: boolean; setCameraSelfieOpen: (open: boolean) => void; } export const AvatarSelector: React.FC = ({ avatarTab, setAvatarTab, avatarFile, avatarPreview, avatarUrl, loadingBrandAvatar, handleUseBrandAvatar, handleAvatarSelectFromLibrary, handleAvatarChange, handleCameraSelfie, handleRemoveAvatar, handleMakePresentable, makingPresentable, avatarPreviewBlobUrl, brandAvatarFromDb, brandAvatarBlobUrl, cameraSelfieOpen, setCameraSelfieOpen, }) => { return ( Podcast Presenter Avatar Avatar Options: Brand Avatar: Use your configured brand avatar for consistency.

Asset Library: Choose from your previously uploaded images.

Take a Selfie: Use your camera to capture a photo instantly for your podcast presenter.

Upload your photo: We'll enhance it into a professional podcast presenter using AI.
} arrow placement="top" > {/* Left Side: Tabs & Content */} {avatarTab === 0 && ( {loadingBrandAvatar ? ( ) : avatarPreview && avatarPreview === brandAvatarFromDb ? ( Active Presenter ) : brandAvatarFromDb ? ( ) : ( No brand avatar found. )} Brand Avatar Select your pre-configured brand avatar to maintain consistency. If not selected, a new AI presenter will be generated. )} {avatarTab === 1 && ( {avatarPreview && !avatarFile && ( )} handleAvatarSelectFromLibrary(url)} /> Asset Library Select from your previously uploaded images. Filter by favorites or search to find the perfect presenter. )} {avatarTab === 2 && ( {avatarFile && avatarPreview ? ( {avatarUrl && ( )} ) : ( setCameraSelfieOpen(true)} sx={{ display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", width: "100%", minHeight: 200, border: "2px dashed #cbd5e1", borderRadius: 2.5, bgcolor: "#f8fafc", cursor: "pointer", transition: "all 0.2s", "&:hover": { borderColor: "#667eea", bgcolor: "#f1f5f9", borderWidth: "2.5px", boxShadow: "0 0 0 3px rgba(102, 126, 234, 0.08)", }, }} > Take a Selfie Use your camera to capture a photo instantly )} Take a Selfie Capture a photo using your device camera and use "Make Presentable" to enhance it into a professional presenter using AI. Camera access required for selfie capture )} {avatarTab === 3 && ( {avatarFile && avatarPreview ? ( {avatarUrl && ( : undefined} sx={{ width: "100%" }} > {makingPresentable ? "Transforming..." : "Make Presentable"} )} ) : ( Upload Your Photo JPG, PNG, WebP (max 5MB) )} Upload Your Photo Upload a new photo and use "Make Presentable" to enhance it into a professional presenter using AI. Supported formats: JPG, PNG, WebP (max 5MB) )} {/* Camera Selfie Dialog */} setCameraSelfieOpen(false)} onCapture={handleCameraSelfie} /> ); };