import { motion } from 'framer-motion';
import { useFlowStore } from '../../store/useFlowStore';
import { Icon } from '../shared/Icon';
function formatTime(seconds: number): string {
const mins = Math.floor(seconds / 60);
const secs = Math.floor(seconds % 60);
const cs = Math.floor((seconds % 1) * 100);
return `${String(mins).padStart(2, '0')}:${String(secs).padStart(2, '0')}.${String(cs).padStart(2, '0')}`;
}
export const PlaybackBar = () => {
const {
playbackState,
speed,
activeStepIndex,
elapsedTime,
play,
pause,
stop,
nextStep,
prevStep,
setSpeed,
setActiveStep,
getTotalSteps,
getCurrentStep,
getCurrentSteps,
toggleLogsPanel,
replayStep,
addLog,
} = useFlowStore();
const totalSteps = getTotalSteps();
const currentStep = getCurrentStep();
const steps = getCurrentSteps();
const progress = totalSteps > 0 ? ((activeStepIndex + 1) / totalSteps) * 100 : 0;
const estimatedTotal = totalSteps * 8;
const handleFlagIssue = () => {
if (currentStep) {
addLog({
level: 'warn',
source: 'USER',
message: `Flagged step ${activeStepIndex + 1}: ${currentStep.title}`,
});
}
};
return (
{/* Ambient glow */}
{/* Header: label + timer */}
Booking Flow Progress
{formatTime(elapsedTime)}
{' / '}
{formatTime(estimatedTotal)}
{/* Step title */}
{currentStep
? `Step ${activeStepIndex + 1}: ${currentStep.title}`
: 'Select a path to begin'}
{/* Step markers + progress bar */}
{/* Markers row */}
{steps.map((step, i) => {
const isCompleted = i < activeStepIndex;
const isActive = i === activeStepIndex;
const shortLabel = step.title.split(' ')[0];
return (
);
})}
{/* Progress bar */}
{/* Controls row */}
{/* Skip Prev */}
{/* Play / Pause */}
{/* Skip Next */}
{/* Stop */}
{/* Divider */}
{/* Speed control */}
{[1, 2, 3].map((s) => (
))}
{/* Divider */}
{/* Replay Step */}
{/* Flag Issue */}
{/* Divider */}
{/* Logs toggle */}
);
};