import { ViewSettings } from 'ontime-types'; import { FitText } from '../../../common/components/fit-text/FitText'; import MultiPartProgressBar from '../../../common/components/multi-part-progress-bar/MultiPartProgressBar'; import { useTimerSocket } from '../../../common/hooks/useSocket'; import { cx } from '../../../common/utils/styleUtils'; import { getFormattedTimer, getTimerByType } from '../../../features/viewers/common/viewUtils'; import { getEstimatedFontSize, getIsPlaying, getSecondaryDisplay, getShowMessage, getShowModifiers, getShowProgressBar, getTotalTime, } from '../../timer/timer.utils'; import { getTimerColour } from '../../utils/presentation.utils'; import './PipTimer.scss'; interface PipTimerProps { viewSettings: ViewSettings; } export function PipTimer({ viewSettings }: PipTimerProps) { const { eventNow, message, time, clock, timerTypeNow, countToEndNow, auxTimer } = useTimerSocket(); // gather modifiers const showOverlay = getShowMessage(message.timer); const { showFinished, showWarning, showDanger } = getShowModifiers( timerTypeNow, countToEndNow, time.phase, false, '', false, ); const isPlaying = getIsPlaying(time.playback); const showProgressBar = getShowProgressBar(timerTypeNow); // gather timer data const totalTime = getTotalTime(time.duration, time.addedTime); const stageTimer = getTimerByType(false, timerTypeNow, clock, time, timerTypeNow); const display = getFormattedTimer(stageTimer, timerTypeNow, 'min', { removeSeconds: false, removeLeadingZero: false, }); const currentAux = (() => { if (message.timer.secondarySource === 'aux1') { return auxTimer.aux1; } if (message.timer.secondarySource === 'aux2') { return auxTimer.aux2; } if (message.timer.secondarySource === 'aux3') { return auxTimer.aux3; } return null; })(); const secondaryContent = getSecondaryDisplay(message, currentAux, 'min', false, true, false); // gather presentation styles const resolvedTimerColour = getTimerColour(viewSettings, undefined, showWarning, showDanger); const timerFontSize = getEstimatedFontSize(display, secondaryContent); const userStyles = { ...(resolvedTimerColour && { '--timer-colour': resolvedTimerColour }), }; return (