import { Playback, TimerPhase, ViewSettings } from 'ontime-types'; import { millisToString } from 'ontime-utils'; import { useAuxTimersName, useAuxTimersTime, useStudioTimersSocket } from '../../common/hooks/useSocket'; import { getAuxTimerLabel } from '../../common/utils/auxTimerUtils'; import { getOffsetState } from '../../common/utils/offset'; import { cx } from '../../common/utils/styleUtils'; import { useTranslation } from '../../translation/TranslationProvider'; import { getPropertyValue } from '../common/viewUtils'; import { getTimerColour } from '../utils/presentation.utils'; import { useStudioOptions } from './studio.options'; import { getFormattedEventData, getFormattedScheduleTimes } from './studioTimers.utils'; import './StudioTimers.scss'; interface StudioTimersProps { viewSettings: ViewSettings; } export default function StudioTimers({ viewSettings }: StudioTimersProps) { const { getLocalizedString } = useTranslation(); const { mainSource } = useStudioOptions(); const { eventNow, eventNext, message, time, offset, rundown, expectedRundownEnd } = useStudioTimersSocket(); const schedule = getFormattedScheduleTimes({ offset: offset, actualStart: rundown.actualStart, expectedEnd: expectedRundownEnd, }); const event = getFormattedEventData(eventNow, time, mainSource); const eventNextTitle = getPropertyValue(eventNext, mainSource ?? 'title') || '-'; const formattedTimerMessage = (message.timer.visible && message.timer.text) || '-'; const formattedSecondaryMessage = message.timer.secondarySource === 'secondary' ? message.secondary || '-' : '-'; // gather presentation styles const timerColour = getTimerColour( viewSettings, undefined, time.phase === TimerPhase.Warning, time.phase === TimerPhase.Danger, ); const offsetState = getOffsetState(offset); return (