import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { WhepPlayer } from '../../lib/whepPlayer.js'; import { useTelemetrySelector } from '../../context/TelemetryContext.jsx'; import { mainBrushAudioTelemetryEqual, selectMainBrushAudioTelemetry, } from '../../context/telemetryViews.js'; import { useSessionSelector } from '../../context/SessionContext.jsx'; import { useVideoRequests } from '../../hooks/useVideoRequests.js'; import { useRoverSnapshots } from '../../hooks/useRoverSnapshots.js'; import { useSettingsNamespace } from '../../settings/index.js'; import { AUDIO_SETTINGS_DEFAULTS, VIDEO_SETTINGS_DEFAULTS } from '../../settings/namespaces.js'; import { trackAnalyticsEventThrottled } from '../../analytics/index.js'; import { RESTART_DELAY_MS, UNMUTE_RETRY_MS, AUDIO_RETRY_MS, BRUSH_CURRENT_THRESHOLD_MA, DUCK_RELEASE_FADE_MS, } from './constants.js'; const VIDEO_FILTER_STYLES = { // The empty filter keeps the browser's native video presentation untouched when the user // wants normal color or when a rover's camera color is already useful. none: '', // Grayscale is the most reliable way to remove the pink cast from a no-IR-filter camera // because it depends on luminance instead of trying to guess the original scene colors. grayscale: 'grayscale(1) contrast(1.08)', // Greenscale is intentionally implemented as a CSS tint over grayscale rather than canvas // processing. That keeps latency low, works for both