import { PropsWithChildren } from 'react'; import { MaybeNumber, Playback, TimerPhase } from 'ontime-types'; import { dayInMs, millisToString } from 'ontime-utils'; import AppLink from '../../../../common/components/link/app-link/AppLink'; import Tooltip from '../../../../common/components/tooltip/Tooltip'; import { useTimer } from '../../../../common/hooks/useSocket'; import useReport from '../../../../common/hooks-query/useReport'; import { formatDuration } from '../../../../common/utils/time'; import TimerDisplay from '../timer-display/TimerDisplay'; import style from './PlaybackTimer.module.scss'; function resolveAddedTimeLabel(addedTime: number) { if (addedTime > 0) { return `Added ${formatDuration(addedTime, false)}`; } if (addedTime < 0) { return `Removed ${formatDuration(Math.abs(addedTime), false)}`; } return ''; } export default function PlaybackTimer({ children }: PropsWithChildren) { const timer = useTimer(); const isRolling = timer.playback === Playback.Roll; const isWaiting = timer.phase === TimerPhase.Pending; const isOvertime = timer.phase === TimerPhase.Overtime; const hasAddedTime = Boolean(timer.addedTime); const rollLabel = isRolling ? 'Roll mode active' : ''; const addedTimeLabel = resolveAddedTimeLabel(timer.addedTime); return (