markdown-flow-ui 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index.cjs8.js +1 -1
- package/dist/_virtual/index.cjs9.js +1 -1
- package/dist/_virtual/index.es8.js +2 -2
- package/dist/_virtual/index.es9.js +2 -2
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/Slide/Slide.cjs.js +1 -1
- package/dist/components/Slide/Slide.cjs.js.map +1 -1
- package/dist/components/Slide/Slide.es.js +833 -728
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/Slide.stories.d.ts +2 -0
- package/dist/components/Slide/utils/interactionPlayback.cjs.js +1 -1
- package/dist/components/Slide/utils/interactionPlayback.cjs.js.map +1 -1
- package/dist/components/Slide/utils/interactionPlayback.d.ts +12 -5
- package/dist/components/Slide/utils/interactionPlayback.es.js +16 -16
- package/dist/components/Slide/utils/interactionPlayback.es.js.map +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/node_modules/classnames/index.cjs.js +1 -1
- package/dist/node_modules/classnames/index.es.js +1 -1
- package/dist/node_modules/lucide-react/dist/esm/icons/grip-horizontal.cjs.js +7 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/grip-horizontal.cjs.js.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/grip-horizontal.es.js +20 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/grip-horizontal.es.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slide.cjs.js","sources":["../../../src/components/Slide/Slide.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronLeft } from \"lucide-react\";\n\nimport { isSandboxInteractionMessage } from \"../../lib/sandboxInteraction\";\nimport { cn } from \"../../lib/utils\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\nimport ContentRender from \"../ContentRender\";\nimport type { ContentRenderProps } from \"../ContentRender/ContentRender\";\nimport IframeSandbox from \"../ContentRender/IframeSandbox\";\nimport type { OnSendContentParams } from \"../types\";\nimport type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport {\n isLandscapeViewport as getIsFullscreenPreferredViewport,\n isMobileDevice as getIsMobileDevice,\n subscribeMobileDeviceChange,\n} from \"../../lib/mobileDevice\";\nimport Player from \"./Player\";\nimport MarkdownSlideScaling from \"./MarkdownSlideScaling\";\nimport SubtitleOverlay from \"./SubtitleOverlay\";\nimport type {\n PlayerProps,\n SlidePlayerNavigationContext,\n SlidePlayerSubtitleJumpTarget,\n SlidePlayerSubtitleSeekRequest,\n SlidePlayerTexts,\n} from \"./Player\";\nimport type { SlidePlayerLoadingReason } from \"./Player\";\nimport type { Element } from \"./types\";\nimport useSlide from \"./useSlide\";\nimport useWakePlayerFromIframe from \"./useWakePlayerFromIframe\";\nimport { PlayerKeyboardShortcutContext } from \"./utils/playerKeyboardShortcutContext\";\nimport { activatePlayerKeyboardShortcutOwner } from \"./utils/playerKeyboardShortcuts\";\nimport {\n DEFAULT_MOBILE_VIEW_MODE,\n resolveMobileViewModeState,\n type MobileViewMode,\n} from \"./utils/mobileScreenMode\";\nimport {\n shouldPresentInteractionOverlay,\n shouldRenderInteractionOverlay,\n} from \"./utils/interactionPlayback\";\nimport { resolveMarkdownScalingMode } from \"./utils/markdownScaling\";\nimport { shouldWakePlayerControlsAfterNavigation } from \"./utils/playerNavigationContext\";\nimport { shouldAutoAdvanceIntoAppendedMarker } from \"./utils/appendedMarkerAdvance\";\nimport {\n getPlaybackSequenceTransition,\n shouldStartDefaultAudioSequence,\n} from \"./utils/playbackSequence\";\nimport {\n canReachSubtitleJumpTarget,\n hasResolvedInteractionElement,\n} from \"./utils/subtitleJumpNavigation\";\nimport {\n getPlayerCustomActionCount,\n resolvePlayerCustomActionElement,\n} from \"./utils/playerCustomActions\";\nimport { createPlaybackTimeStore } from \"./utils/playbackTimeStore\";\nimport { resolveSlideInteractionState } from \"./utils/interactionResolution\";\nimport { shouldUseAutoAdvanceToggle } from \"./utils/playerToggleMode\";\nimport {\n areImageOnlyStepIframeVisualsReady,\n DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS,\n} from \"./utils/imageOnlyStepVisualReady\";\nimport { resolveSilentStepAutoAdvanceBehavior } from \"./utils/silentStepAutoAdvance\";\nimport {\n resolveSlidePlayerVisibility,\n type SlidePlayerControlsVisibility,\n} from \"./utils/playerVisibility\";\nimport {\n DEFAULT_SLIDE_BUFFERING_TEXTS,\n getSlideLocaleTexts,\n type SlideBufferingReason,\n} from \"./slideI18n\";\nimport \"./slide.css\";\nexport type {\n Element,\n ElementAudioSegment,\n ElementSubtitleCue,\n SlidePlayerCustomActionContext,\n SlidePlayerCustomActions,\n} from \"./types\";\nexport type { SlidePlayerControlsVisibility } from \"./utils/playerVisibility\";\n\nconst DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS = 2000;\nconst DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS = 300;\nconst DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX = 160;\nconst DEFAULT_INTERACTION_SUBTITLE_GAP_PX = 16;\nconst DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS = 3000;\nconst INTERACTION_ACTIVITY_SELECTOR = [\n \"button\",\n \"input\",\n \"textarea\",\n '[contenteditable=\"\"]',\n '[contenteditable=\"true\"]',\n '[contenteditable=\"plaintext-only\"]',\n].join(\", \");\nconst DEFAULT_BUFFERING_REASON: SlideBufferingReason = \"waitingForAudio\";\n\nexport type { SlideBufferingReason } from \"./slideI18n\";\n\nexport type SlideBufferingTextConfig =\n | string\n | Partial<Record<SlideBufferingReason, string>>;\n\nconst resolveBufferingTextByReason = (\n bufferingText: SlideBufferingTextConfig,\n reason: SlideBufferingReason\n) => {\n if (typeof bufferingText === \"string\") {\n return bufferingText;\n }\n\n return (\n bufferingText[reason] ??\n bufferingText[DEFAULT_BUFFERING_REASON] ??\n DEFAULT_SLIDE_BUFFERING_TEXTS[reason]\n );\n};\n\nconst mergeBufferingTextWithLocaleDefaults = (\n bufferingText: SlideBufferingTextConfig | undefined,\n localeBufferingText: Record<string, string>\n): SlideBufferingTextConfig => {\n if (typeof bufferingText === \"string\") {\n return bufferingText;\n }\n\n return {\n ...localeBufferingText,\n ...bufferingText,\n };\n};\n\nconst shouldShowBufferingOverlay = (\n reason: SlideBufferingReason | null,\n loading: boolean\n) => {\n if (!loading) {\n return false;\n }\n\n // Keep the silent preload/loading phase invisible until audio is actually playable.\n return reason !== \"loadingAudio\";\n};\n\ntype RenderSlideElementOptions = {\n replaceRootScreenHeightWithFull?: boolean;\n};\n\ninterface InteractionOverlayCardProps {\n content: string;\n title: string;\n locale?: MarkdownFlowLocale;\n defaultButtonText?: string;\n defaultInputText?: string;\n defaultSelectedValues?: string[];\n confirmButtonText?: string;\n copyButtonText?: string;\n copiedButtonText?: string;\n onSend?: (content: OnSendContentParams) => void;\n readonly?: boolean;\n}\n\nexport interface SlideInteractionTexts\n extends Pick<\n ContentRenderProps,\n \"confirmButtonText\" | \"copyButtonText\" | \"copiedButtonText\"\n > {\n title?: string;\n}\n\nexport type SlideFullscreenHeader = {\n content?: React.ReactNode;\n backAriaLabel?: string;\n onBack?: () => void;\n};\n\nconst InteractionOverlayCard = memo(\n ({\n content,\n title,\n locale,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n onSend,\n readonly = false,\n }: InteractionOverlayCardProps) => (\n <div className=\"slide-player__interaction-card\">\n <div className=\"slide-player__interaction-header\">\n <p className=\"slide-player__interaction-title\">{title}</p>\n </div>\n <div className=\"slide-player__interaction-body\">\n <ContentRender\n content={content}\n locale={locale}\n defaultButtonText={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n onSend={onSend}\n readonly={readonly}\n sandboxMode=\"content\"\n />\n </div>\n </div>\n )\n);\n\nInteractionOverlayCard.displayName = \"InteractionOverlayCard\";\n\nconst areStepElementListsEqual = (\n prevElementList: Element[],\n nextElementList: Element[]\n) =>\n prevElementList.length === nextElementList.length &&\n prevElementList.every((element, index) => {\n const nextElement = nextElementList[index];\n\n return (\n element.sequence_number === nextElement?.sequence_number &&\n element.type === nextElement?.type &&\n element.content === nextElement?.content\n );\n });\n\nconst isInteractionActivityTarget = (\n target: EventTarget | null\n): target is HTMLElement =>\n target instanceof HTMLElement &&\n target.matches(INTERACTION_ACTIVITY_SELECTOR);\nconst TEXT_ENTRY_SELECTOR = [\n 'input:not([type=\"button\"]):not([type=\"checkbox\"]):not([type=\"radio\"]):not([type=\"submit\"])',\n \"textarea\",\n '[contenteditable=\"\"]',\n '[contenteditable=\"true\"]',\n '[contenteditable=\"plaintext-only\"]',\n].join(\", \");\n\nconst isTextEntryTarget = (target: EventTarget | null): target is HTMLElement =>\n target instanceof HTMLElement && target.matches(TEXT_ENTRY_SELECTOR);\n\nexport interface SlideProps extends React.ComponentProps<\"section\"> {\n elementList?: Element[];\n /** Locale used for built-in UI text when a more specific text prop is not provided. */\n locale?: MarkdownFlowLocale;\n /** Enables the player runtime, including audio playback and keyboard shortcuts. */\n playerEnabled?: boolean;\n /**\n * Controls whether the player controls are always visible, always hidden, or auto-hidden.\n *\n * Use `\"hidden\"` to keep audio playback and keyboard shortcuts active while\n * hiding the visual controls.\n *\n * @example\n * ```tsx\n * <Slide playerControlsVisibility=\"hidden\" enableKeyboardShortcuts />\n * ```\n */\n playerControlsVisibility?: SlidePlayerControlsVisibility;\n playerClassName?: string;\n fullscreenHeader?: SlideFullscreenHeader;\n playerCustomActions?: PlayerProps[\"customActions\"];\n playerCustomActionPauseOnActive?: boolean;\n bufferingText?: SlideBufferingTextConfig;\n interactionTitle?: string;\n interactionTexts?: SlideInteractionTexts;\n playerTexts?: SlidePlayerTexts;\n playerAutoHideDelay?: number;\n markerAutoAdvanceDelay?: number;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n onSend?: (content: OnSendContentParams, element?: Element) => void;\n onPlayerVisibilityChange?: (visible: boolean) => void;\n onMobileViewModeChange?: (viewMode: MobileViewMode) => void;\n onStepChange?: (element: Element | undefined, index: number) => void;\n /**\n * Enables keyboard shortcuts for existing player actions.\n *\n * Defaults to `true`. The active slide responds after users click, touch, or\n * focus the slide/player surface; ignored targets include form controls and\n * interaction overlays.\n *\n * @example\n * ```tsx\n * <Slide elementList={slides} enableKeyboardShortcuts={false} />\n * ```\n */\n enableKeyboardShortcuts?: boolean;\n enableIframeScaling?: boolean;\n /**\n * Fits Markdown-only slides to the available presentation viewport.\n *\n * Defaults to `true`. Disable this to preserve the fixed 16px article\n * typography used by standalone ContentRender.\n */\n enableMarkdownScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n locale,\n playerEnabled,\n playerControlsVisibility,\n playerClassName,\n fullscreenHeader,\n playerCustomActions,\n playerCustomActionPauseOnActive = true,\n bufferingText,\n interactionTitle,\n interactionTexts,\n playerTexts,\n playerAutoHideDelay = 3000,\n markerAutoAdvanceDelay = DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS,\n interactionDefaultValueOptions,\n onSend,\n onPlayerVisibilityChange,\n onMobileViewModeChange,\n onStepChange,\n enableKeyboardShortcuts = true,\n enableIframeScaling = true,\n enableMarkdownScaling = true,\n disableLoadingOverlay = false,\n className,\n onPointerDown,\n onFocusCapture,\n ...props\n}) => {\n const localeTexts = useMemo(() => getSlideLocaleTexts(locale), [locale]);\n const resolvedBufferingText = useMemo(\n () =>\n mergeBufferingTextWithLocaleDefaults(\n bufferingText,\n localeTexts.bufferingText\n ),\n [bufferingText, localeTexts.bufferingText]\n );\n const {\n playerEnabled: resolvedPlayerEnabled,\n playerControlsVisibility: resolvedPlayerControlsVisibility,\n } = resolveSlidePlayerVisibility({\n playerEnabled,\n playerControlsVisibility,\n });\n const keyboardShortcutOwnerId = useId();\n const sectionRef = useRef<HTMLElement | null>(null);\n const viewportRef = useRef<HTMLDivElement | null>(null);\n const stageLayerRef = useRef<HTMLDivElement | null>(null);\n const lastElementRef = useRef<HTMLDivElement | null>(null);\n const playerHideTimerRef = useRef<number | null>(null);\n const isPointerInsidePlayerControlsRef = useRef(false);\n const autoAdvanceTimerRef = useRef<number | null>(null);\n const imageOnlyStepReadyTimeoutRef = useRef<number | null>(null);\n const interactionAutoCloseTimerRef = useRef<number | null>(null);\n const interactionOverlayOpenTimerRef = useRef<number | null>(null);\n const interactionOverlayRef = useRef<HTMLDivElement | null>(null);\n const prevRenderElementKeysRef = useRef<string[]>([]);\n const shouldScrollToBottomRef = useRef(false);\n const pendingInteractionOverlayStepIndexRef = useRef<number | null>(null);\n const pendingSubtitleJumpRef = useRef<{\n audioIndex: number;\n audioKey: string;\n slideIndex: number;\n timeMs: number;\n } | null>(null);\n const subtitleSeekRequestIdRef = useRef(0);\n const playbackResetKeyRef = useRef<string | null>(null);\n const appendedMarkerAdvanceStateRef = useRef({\n markerCount: 0,\n currentIndex: -1,\n canGoNext: false,\n });\n const shouldSkipDefaultAudioStartForSubtitleJumpRef = useRef(false);\n const {\n currentElementList,\n stepElementLists,\n slideElementList,\n currentIndex,\n audioList,\n audioSlideIndexes,\n currentAudioSequenceIndexes,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n canGoPrev,\n canGoNext,\n handlePrev: goPrev,\n handleNext: goNext,\n handleGoTo: goTo,\n } = useSlide(elementList);\n const currentStepElement = useMemo(() => {\n if (currentIndex < 0) {\n return undefined;\n }\n\n return slideElementList[currentIndex];\n }, [currentIndex, slideElementList]);\n const currentRenderElementKeys = useMemo(\n () =>\n currentElementList.map(\n (element, index) =>\n `${element.sequence_number ?? `${element.type}-${index}`}:${String(element.is_new ?? \"\")}`\n ),\n [currentElementList]\n );\n const visibleMarkerCount = slideElementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const isSingleSlide = visibleMarkerCount === 1;\n const shouldMountPlayer =\n resolvedPlayerEnabled &&\n (slideElementList.length > 0 ||\n audioList.length > 0 ||\n Boolean(currentInteractionElement));\n const keyboardShortcutContextValue = useMemo(\n () => ({\n enabled: enableKeyboardShortcuts,\n ownerId: keyboardShortcutOwnerId,\n }),\n [enableKeyboardShortcuts, keyboardShortcutOwnerId]\n );\n const activateKeyboardShortcutOwner = useCallback(() => {\n if (!enableKeyboardShortcuts || !shouldMountPlayer) {\n return;\n }\n\n activatePlayerKeyboardShortcutOwner(keyboardShortcutOwnerId);\n }, [enableKeyboardShortcuts, keyboardShortcutOwnerId, shouldMountPlayer]);\n const currentAudioSequenceKeys = useMemo(\n () =>\n currentAudioSequenceIndexes\n .map((audioIndex) => audioList[audioIndex]?.audioKey)\n .filter((audioKey): audioKey is string => Boolean(audioKey)),\n [audioList, currentAudioSequenceIndexes]\n );\n const [isPlayerVisible, setIsPlayerVisible] = useState(true);\n const [hasPlayerInteracted, setHasPlayerInteracted] = useState(false);\n const [isPlaybackRequested, setIsPlaybackRequested] = useState(true);\n const [isAutoAdvanceEnabled, setIsAutoAdvanceEnabled] = useState(true);\n const [currentAudioKey, setCurrentAudioKey] = useState<string | null>(null);\n const [subtitleSeekRequest, setSubtitleSeekRequest] =\n useState<SlidePlayerSubtitleSeekRequest | null>(null);\n const [isAudioLoadingVisible, setIsAudioLoadingVisible] = useState(false);\n const [audioLoadingReason, setAudioLoadingReason] =\n useState<SlideBufferingReason>(DEFAULT_BUFFERING_REASON);\n const [hasCompletedCurrentStepAudio, setHasCompletedCurrentStepAudio] =\n useState(false);\n const [hasCurrentAudioPlaybackStarted, setHasCurrentAudioPlaybackStarted] =\n useState(false);\n const [isSubtitleEnabled, setIsSubtitleEnabled] = useState(true);\n const [isPlayerCustomActionActive, setIsPlayerCustomActionActive] =\n useState(false);\n const [activeInteractionElement, setActiveInteractionElement] = useState<\n Element | undefined\n >();\n const [isInteractionOverlayOpen, setIsInteractionOverlayOpen] =\n useState(false);\n const [hasInteractionOverlayActivity, setHasInteractionOverlayActivity] =\n useState(false);\n const [hasFocusedInteractionTextInput, setHasFocusedInteractionTextInput] =\n useState(false);\n const [\n interactionOverlaySubtitleOffset,\n setInteractionOverlaySubtitleOffset,\n ] = useState(0);\n const [isBrowserFullscreen, setIsBrowserFullscreen] = useState(false);\n const isMobileDevice = useMemo(() => getIsMobileDevice(), []);\n const [mobileViewMode, setMobileViewMode] = useState<MobileViewMode>(\n DEFAULT_MOBILE_VIEW_MODE\n );\n const [hasManualMobileViewMode, setHasManualMobileViewMode] = useState(false);\n const [isViewportFullscreenPreferred, setIsViewportFullscreenPreferred] =\n useState(() =>\n isMobileDevice ? getIsFullscreenPreferredViewport() : false\n );\n const playbackTimeStore = useMemo(() => createPlaybackTimeStore(), []);\n const {\n effectiveMobileViewMode,\n isImmersiveMobileFullscreen,\n isNativeMobileFullscreen,\n shouldRotateFullscreenViewport,\n } = useMemo(\n () =>\n resolveMobileViewModeState({\n hasManualMobileViewMode,\n isMobileDevice,\n isViewportFullscreenPreferred,\n mobileViewMode,\n }),\n [\n hasManualMobileViewMode,\n isMobileDevice,\n isViewportFullscreenPreferred,\n mobileViewMode,\n ]\n );\n const previousEffectiveMobileViewModeRef = useRef(effectiveMobileViewMode);\n const playerControlsVisible =\n shouldMountPlayer &&\n resolvedPlayerControlsVisibility !== \"hidden\" &&\n (resolvedPlayerControlsVisibility === \"visible\" || isPlayerVisible);\n const shouldShowFullscreenHeader =\n isImmersiveMobileFullscreen && playerControlsVisible;\n const shouldApplyFullscreenViewportPadding =\n isImmersiveMobileFullscreen && playerControlsVisible;\n const shouldShowMobileFullscreenMask =\n isImmersiveMobileFullscreen || isNativeMobileFullscreen;\n const isDesktopBrowserFullscreen = isBrowserFullscreen && !isMobileDevice;\n const handleMobileViewModeSelect = useCallback(\n (nextViewMode: MobileViewMode) => {\n setHasManualMobileViewMode(true);\n setMobileViewMode(nextViewMode);\n },\n []\n );\n const handleMobileViewModeReset = useCallback(() => {\n // Clear manual override so the effective mode returns to the default non-fullscreen state.\n setHasManualMobileViewMode(false);\n setMobileViewMode(DEFAULT_MOBILE_VIEW_MODE);\n }, []);\n const handleFullscreenHeaderBack = useCallback(() => {\n handleMobileViewModeReset();\n fullscreenHeader?.onBack?.();\n }, [fullscreenHeader, handleMobileViewModeReset]);\n const setPlayerCustomActionActive = useCallback((active: boolean) => {\n setIsPlayerCustomActionActive(active);\n }, []);\n const togglePlayerCustomActionActive = useCallback(() => {\n setIsPlayerCustomActionActive((previous) => !previous);\n }, []);\n const { mountedStepStates, currentMountedStateIndex } = useMemo(() => {\n const nextMountedStepStates: Array<{\n elementList: Element[];\n sourceStepIndexes: number[];\n }> = [];\n const mountedStateIndexByStep = new Map<number, number>();\n\n stepElementLists.forEach((stepElementList, stepIndex) => {\n const existingMountedStateIndex = nextMountedStepStates.findIndex(\n (mountedStepState) =>\n areStepElementListsEqual(\n mountedStepState.elementList,\n stepElementList\n )\n );\n\n if (existingMountedStateIndex >= 0) {\n nextMountedStepStates[\n existingMountedStateIndex\n ]?.sourceStepIndexes.push(stepIndex);\n mountedStateIndexByStep.set(stepIndex, existingMountedStateIndex);\n return;\n }\n\n nextMountedStepStates.push({\n elementList: stepElementList,\n sourceStepIndexes: [stepIndex],\n });\n mountedStateIndexByStep.set(stepIndex, nextMountedStepStates.length - 1);\n });\n\n return {\n mountedStepStates: nextMountedStepStates,\n currentMountedStateIndex:\n currentIndex >= 0\n ? (mountedStateIndexByStep.get(currentIndex) ?? -1)\n : -1,\n };\n }, [currentIndex, stepElementLists]);\n const currentStepKey = useMemo(() => String(currentIndex), [currentIndex]);\n const currentAudioIndex = useMemo(() => {\n if (!currentAudioKey) {\n return -1;\n }\n\n return audioList.findIndex(\n (audioItem) => (audioItem.audioKey ?? \"\") === currentAudioKey\n );\n }, [audioList, currentAudioKey]);\n const currentAudioItem = useMemo(\n () => (currentAudioIndex >= 0 ? audioList[currentAudioIndex] : undefined),\n [audioList, currentAudioIndex]\n );\n const currentSubtitleCues = currentAudioItem?.element?.subtitle_cues ?? [];\n const currentAudioSequenceStartKey = useMemo(\n () => currentAudioSequenceKeys[0] ?? \"none\",\n [currentAudioSequenceKeys]\n );\n const playerCustomActionContext = useMemo(\n () => ({\n currentElement: resolvePlayerCustomActionElement({\n currentAudioIndex,\n currentAudioSequenceIndexes,\n audioList,\n currentInteractionElement: activeInteractionElement,\n currentStepElement,\n }),\n currentIndex,\n currentStepElement,\n isActive: isPlayerCustomActionActive,\n setActive: setPlayerCustomActionActive,\n toggleActive: togglePlayerCustomActionActive,\n }),\n [\n activeInteractionElement,\n audioList,\n currentAudioIndex,\n currentAudioSequenceIndexes,\n currentIndex,\n currentStepElement,\n isPlayerCustomActionActive,\n setPlayerCustomActionActive,\n togglePlayerCustomActionActive,\n ]\n );\n const playerCustomActionCount = useMemo(\n () =>\n getPlayerCustomActionCount(\n playerCustomActions,\n playerCustomActionContext\n ),\n [playerCustomActionContext, playerCustomActions]\n );\n const interactionOverlayStyle = useMemo(\n () =>\n ({\n \"--slide-player-custom-action-count\": String(playerCustomActionCount),\n \"--slide-player-mobile-control-count\": String(\n playerCustomActionCount + 4\n ),\n }) as React.CSSProperties,\n [playerCustomActionCount]\n );\n const hasAvailableStepAudio = currentAudioSequenceKeys.length > 0;\n const currentInteractionResetKey = useMemo(() => {\n if (!currentInteractionElement) {\n return \"none\";\n }\n\n return `${currentInteractionElement.sequence_number ?? \"none\"}:${String(\n currentInteractionElement.content ?? \"\"\n )}`;\n }, [currentInteractionElement]);\n const currentPlaybackResetKey = useMemo(\n () => [currentStepKey, currentInteractionResetKey].join(\"|\"),\n [currentInteractionResetKey, currentStepKey]\n );\n const currentPlaybackStartedResetKey = useMemo(\n () =>\n [\n currentPlaybackResetKey,\n currentAudioItem?.audioKey ?? \"none\",\n String(currentAudioIndex),\n ].join(\"|\"),\n [currentAudioIndex, currentAudioItem?.audioKey, currentPlaybackResetKey]\n );\n const currentStepAudioUrl = useMemo(() => {\n if (\n !currentAudioSequenceStartKey ||\n currentAudioSequenceStartKey === \"none\"\n ) {\n return \"\";\n }\n\n const currentStepAudioItem = audioList.find(\n (audioItem) => audioItem.audioKey === currentAudioSequenceStartKey\n );\n\n return currentStepAudioItem?.audioUrl?.trim() ?? \"\";\n }, [audioList, currentAudioSequenceStartKey]);\n const hasCurrentStepAudioUrl = Boolean(currentStepAudioUrl);\n const shouldPausePlaybackForCustomAction =\n playerCustomActionPauseOnActive &&\n Boolean(playerCustomActions) &&\n isPlayerCustomActionActive;\n const shouldUseSilentStepAutoAdvanceToggle = useMemo(\n () =>\n shouldUseAutoAdvanceToggle({\n canGoNext,\n currentAudioIndex,\n currentStepHasSpeakableElement,\n hasInteraction: Boolean(currentInteractionElement),\n }),\n [\n canGoNext,\n currentAudioIndex,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n ]\n );\n const silentStepAutoAdvanceBehavior = useMemo(\n () =>\n resolveSilentStepAutoAdvanceBehavior({\n currentElementList,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n markerAutoAdvanceDelay,\n }),\n [\n currentElementList,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n markerAutoAdvanceDelay,\n ]\n );\n const silentStepAutoAdvanceDelay = silentStepAutoAdvanceBehavior.delayMs;\n const isImageOnlySilentStep =\n silentStepAutoAdvanceBehavior.usesImageOnlyDelay;\n const imageOnlyStepVisualReadyKey = useMemo(\n () => `${currentIndex}:${currentRenderElementKeys.join(\"|\")}`,\n [currentIndex, currentRenderElementKeys]\n );\n const [readyImageOnlyStepKey, setReadyImageOnlyStepKey] = useState<\n string | null\n >(null);\n const isImageOnlyStepVisualReady =\n !isImageOnlySilentStep ||\n readyImageOnlyStepKey === imageOnlyStepVisualReadyKey;\n\n const clearPlayerHideTimer = useCallback(() => {\n if (playerHideTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(playerHideTimerRef.current);\n playerHideTimerRef.current = null;\n }, []);\n\n const clearInteractionAutoCloseTimer = useCallback(() => {\n if (interactionAutoCloseTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(interactionAutoCloseTimerRef.current);\n interactionAutoCloseTimerRef.current = null;\n }, []);\n\n const clearInteractionOverlayOpenTimer = useCallback(() => {\n if (interactionOverlayOpenTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(interactionOverlayOpenTimerRef.current);\n interactionOverlayOpenTimerRef.current = null;\n }, []);\n\n const clearAutoAdvanceTimer = useCallback(() => {\n if (autoAdvanceTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(autoAdvanceTimerRef.current);\n autoAdvanceTimerRef.current = null;\n }, []);\n\n const clearImageOnlyStepReadyTimeout = useCallback(() => {\n if (imageOnlyStepReadyTimeoutRef.current === null) {\n return;\n }\n\n window.clearTimeout(imageOnlyStepReadyTimeoutRef.current);\n imageOnlyStepReadyTimeoutRef.current = null;\n }, []);\n\n const resetAudioSequence = useCallback(\n (\n options: {\n preservePendingSubtitleJump?: boolean;\n } = {}\n ) => {\n clearAutoAdvanceTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n clearImageOnlyStepReadyTimeout();\n setCurrentAudioKey(null);\n playbackTimeStore.reset();\n setIsAudioLoadingVisible(false);\n setAudioLoadingReason(DEFAULT_BUFFERING_REASON);\n setHasCompletedCurrentStepAudio(false);\n setHasCurrentAudioPlaybackStarted(false);\n setSubtitleSeekRequest(null);\n if (!options.preservePendingSubtitleJump) {\n pendingSubtitleJumpRef.current = null;\n }\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n },\n [\n clearAutoAdvanceTimer,\n clearImageOnlyStepReadyTimeout,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n playbackTimeStore,\n ]\n );\n\n const requestSubtitleCueSeek = useCallback(\n (target: SlidePlayerSubtitleJumpTarget) => {\n subtitleSeekRequestIdRef.current += 1;\n setSubtitleSeekRequest({\n ...target,\n id: subtitleSeekRequestIdRef.current,\n });\n },\n []\n );\n\n const startCurrentAudioSequence = useCallback(() => {\n const nextAudioKey = currentAudioSequenceKeys[0];\n\n if (!nextAudioKey) {\n return false;\n }\n\n // Start the first audio segment for the current step immediately.\n setCurrentAudioKey(nextAudioKey);\n return true;\n }, [currentAudioSequenceKeys]);\n\n const continueAfterInteraction = useCallback(() => {\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (canGoNext) {\n goNext();\n }\n }, [\n canGoNext,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n goNext,\n startCurrentAudioSequence,\n ]);\n\n const scheduleInteractionOverlayOpen = useCallback(\n (interactionElement?: Element) => {\n clearInteractionOverlayOpenTimer();\n\n if (!interactionElement) {\n return;\n }\n\n const openOverlay = () => {\n interactionOverlayOpenTimerRef.current = null;\n setInteractionOverlaySubtitleOffset(\n DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX\n );\n setIsInteractionOverlayOpen(true);\n pendingInteractionOverlayStepIndexRef.current = null;\n };\n\n interactionOverlayOpenTimerRef.current = window.setTimeout(\n openOverlay,\n DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS\n );\n },\n [clearInteractionOverlayOpenTimer]\n );\n\n const isPlayerControlsHovered = useCallback(\n () =>\n isPointerInsidePlayerControlsRef.current ||\n Boolean(\n sectionRef.current?.querySelector(\".slide-player__controls:hover\")\n ),\n []\n );\n\n const revealPlayerControls = useCallback(\n (enableAutoHide = hasPlayerInteracted) => {\n if (!shouldMountPlayer || resolvedPlayerControlsVisibility === \"hidden\") {\n return;\n }\n\n setIsPlayerVisible(true);\n clearPlayerHideTimer();\n\n if (\n resolvedPlayerControlsVisibility === \"visible\" ||\n !enableAutoHide ||\n playerAutoHideDelay <= 0 ||\n isPlayerControlsHovered()\n ) {\n return;\n }\n\n playerHideTimerRef.current = window.setTimeout(() => {\n if (isPlayerControlsHovered()) {\n playerHideTimerRef.current = null;\n return;\n }\n\n setIsPlayerVisible(false);\n playerHideTimerRef.current = null;\n }, playerAutoHideDelay);\n },\n [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n isPlayerControlsHovered,\n playerAutoHideDelay,\n resolvedPlayerControlsVisibility,\n shouldMountPlayer,\n ]\n );\n\n const hasResolvedCurrentInteraction = Boolean(\n hasResolvedInteractionElement(currentInteractionElement)\n );\n\n const shouldBlockPlaybackForInteraction =\n Boolean(currentInteractionElement) && !hasResolvedCurrentInteraction;\n\n const handlePlaybackPreferenceChange = useCallback((playing: boolean) => {\n setIsPlaybackRequested(playing);\n }, []);\n\n const syncPlaybackPreferenceBeforeNavigation = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n if (context) {\n setIsPlaybackRequested(context.shouldContinuePlayback);\n }\n },\n []\n );\n\n useEffect(() => {\n // Keep silent-step autoplay aligned with the same play/pause preference as audio.\n setIsAutoAdvanceEnabled(isPlaybackRequested);\n }, [currentIndex, isPlaybackRequested, playerCustomActionPauseOnActive]);\n\n useEffect(() => {\n if (playerCustomActionPauseOnActive) {\n setIsPlayerCustomActionActive(false);\n }\n }, [currentIndex, playerCustomActionPauseOnActive]);\n\n useEffect(() => {\n return () => {\n clearAutoAdvanceTimer();\n clearImageOnlyStepReadyTimeout();\n clearPlayerHideTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n };\n }, [\n clearAutoAdvanceTimer,\n clearImageOnlyStepReadyTimeout,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n clearPlayerHideTimer,\n ]);\n\n useEffect(() => {\n if (!isImageOnlySilentStep) {\n clearImageOnlyStepReadyTimeout();\n return;\n }\n\n let cancelled = false;\n let rafId: number | null = null;\n let cleanupListeners: (() => void) | null = null;\n\n const detachListeners = () => {\n cleanupListeners?.();\n cleanupListeners = null;\n };\n\n const finishVisualReady = () => {\n if (cancelled) {\n return;\n }\n\n detachListeners();\n clearImageOnlyStepReadyTimeout();\n setReadyImageOnlyStepKey(imageOnlyStepVisualReadyKey);\n };\n\n const evaluateVisualReady = () => {\n if (cancelled) {\n return;\n }\n\n detachListeners();\n\n const activeStepContainer = stageLayerRef.current?.querySelector(\n '[data-active-step=\"true\"]'\n ) as HTMLElement | null;\n\n if (!activeStepContainer) {\n return;\n }\n\n const iframeElements = Array.from(\n activeStepContainer.querySelectorAll(\"iframe\")\n ) as HTMLIFrameElement[];\n\n if (\n iframeElements.length === 0 ||\n areImageOnlyStepIframeVisualsReady(iframeElements)\n ) {\n finishVisualReady();\n return;\n }\n\n const cleanupCallbacks: Array<() => void> = [];\n const queueRecheck = () => {\n if (cancelled) {\n return;\n }\n\n if (rafId !== null) {\n window.cancelAnimationFrame(rafId);\n }\n\n rafId = window.requestAnimationFrame(() => {\n rafId = null;\n evaluateVisualReady();\n });\n };\n const registerEvent = (\n target: EventTarget,\n eventName: string,\n listener: EventListener\n ) => {\n target.addEventListener(eventName, listener, { once: true });\n cleanupCallbacks.push(() =>\n target.removeEventListener(eventName, listener)\n );\n };\n\n iframeElements.forEach((iframeElement) => {\n const iframeDocument = iframeElement.contentDocument;\n\n if (!iframeDocument || iframeDocument.readyState !== \"complete\") {\n registerEvent(iframeElement, \"load\", queueRecheck);\n return;\n }\n\n Array.from(iframeDocument.images)\n .filter((image) => !image.complete)\n .forEach((image) => {\n registerEvent(image, \"load\", queueRecheck);\n registerEvent(image, \"error\", queueRecheck);\n });\n });\n\n cleanupListeners = () => {\n cleanupCallbacks.forEach((cleanup) => cleanup());\n };\n };\n\n rafId = window.requestAnimationFrame(() => {\n rafId = null;\n evaluateVisualReady();\n });\n\n imageOnlyStepReadyTimeoutRef.current = window.setTimeout(() => {\n finishVisualReady();\n }, DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS);\n\n return () => {\n cancelled = true;\n detachListeners();\n clearImageOnlyStepReadyTimeout();\n if (rafId !== null) {\n window.cancelAnimationFrame(rafId);\n }\n };\n }, [\n clearImageOnlyStepReadyTimeout,\n currentElementList,\n currentIndex,\n imageOnlyStepVisualReadyKey,\n isImageOnlySilentStep,\n ]);\n\n useEffect(() => {\n onPlayerVisibilityChange?.(playerControlsVisible);\n\n return () => {\n onPlayerVisibilityChange?.(false);\n };\n }, [onPlayerVisibilityChange, playerControlsVisible]);\n\n useEffect(() => {\n if (playerControlsVisible) {\n return;\n }\n\n isPointerInsidePlayerControlsRef.current = false;\n }, [playerControlsVisible]);\n\n useEffect(() => {\n if (isMobileDevice || mobileViewMode === DEFAULT_MOBILE_VIEW_MODE) {\n return;\n }\n\n setHasManualMobileViewMode(false);\n setMobileViewMode(DEFAULT_MOBILE_VIEW_MODE);\n }, [isMobileDevice, mobileViewMode]);\n\n useEffect(() => {\n if (!isMobileDevice) {\n setIsViewportFullscreenPreferred(false);\n return;\n }\n\n const syncViewportFullscreenPreference = () => {\n setIsViewportFullscreenPreferred(getIsFullscreenPreferredViewport());\n };\n\n syncViewportFullscreenPreference();\n\n return subscribeMobileDeviceChange(syncViewportFullscreenPreference);\n }, [isMobileDevice]);\n\n useEffect(() => {\n onMobileViewModeChange?.(effectiveMobileViewMode);\n }, [effectiveMobileViewMode, onMobileViewModeChange]);\n\n useEffect(() => {\n previousEffectiveMobileViewModeRef.current = effectiveMobileViewMode;\n }, [effectiveMobileViewMode]);\n\n useEffect(() => {\n onStepChange?.(currentStepElement, currentIndex);\n }, [currentIndex, currentStepElement, onStepChange]);\n\n useEffect(() => {\n const previousState = appendedMarkerAdvanceStateRef.current;\n const shouldAdvanceIntoAppendedMarker = shouldAutoAdvanceIntoAppendedMarker(\n {\n previousMarkerCount: previousState.markerCount,\n nextMarkerCount: slideElementList.length,\n previousIndex: previousState.currentIndex,\n previousCanGoNext: previousState.canGoNext,\n nextCanGoNext: canGoNext,\n currentAudioKey,\n hasCompletedCurrentStepAudio,\n hasResolvedCurrentInteraction,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n isAutoAdvanceEnabled,\n shouldUseSilentStepAutoAdvanceToggle,\n }\n );\n\n appendedMarkerAdvanceStateRef.current = {\n markerCount: slideElementList.length,\n currentIndex,\n canGoNext,\n };\n\n if (!shouldAdvanceIntoAppendedMarker) {\n return;\n }\n\n goNext();\n }, [\n canGoNext,\n currentAudioKey,\n currentIndex,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n goNext,\n hasCompletedCurrentStepAudio,\n hasResolvedCurrentInteraction,\n isAutoAdvanceEnabled,\n shouldUseSilentStepAutoAdvanceToggle,\n slideElementList.length,\n ]);\n\n useEffect(() => {\n if (!shouldMountPlayer || resolvedPlayerControlsVisibility === \"hidden\") {\n clearPlayerHideTimer();\n setIsPlayerVisible(false);\n return;\n }\n\n if (resolvedPlayerControlsVisibility === \"visible\") {\n clearPlayerHideTimer();\n setIsPlayerVisible(true);\n return;\n }\n\n if (!hasPlayerInteracted) {\n // Keep the initial player visible briefly, then hide it automatically.\n revealPlayerControls(true);\n }\n }, [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n resolvedPlayerControlsVisibility,\n shouldMountPlayer,\n revealPlayerControls,\n ]);\n\n useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const handleSandboxInteraction = (event: MessageEvent) => {\n if (event.origin !== window.location.origin) {\n return;\n }\n\n if (!isSandboxInteractionMessage(event.data)) {\n return;\n }\n\n if (event.data.eventType !== \"click\") {\n return;\n }\n\n if (!shouldMountPlayer) {\n return;\n }\n\n // Restore player controls on explicit click/tap without waking on scroll start.\n activateKeyboardShortcutOwner();\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n };\n\n window.addEventListener(\"message\", handleSandboxInteraction);\n\n return () => {\n window.removeEventListener(\"message\", handleSandboxInteraction);\n };\n }, [activateKeyboardShortcutOwner, shouldMountPlayer, revealPlayerControls]);\n\n useWakePlayerFromIframe({\n sectionRef,\n enabled: shouldMountPlayer,\n keyboardShortcutsEnabled: enableKeyboardShortcuts,\n onKeyboardShortcut: activateKeyboardShortcutOwner,\n onWake: () => {\n activateKeyboardShortcutOwner();\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n },\n });\n\n useEffect(() => {\n if (!shouldMountPlayer) {\n resetAudioSequence();\n return;\n }\n\n const { hasPlaybackContextChanged, shouldInitializeAudioSequence } =\n getPlaybackSequenceTransition({\n previousResetKey: playbackResetKeyRef.current,\n nextResetKey: currentPlaybackResetKey,\n currentAudioKey,\n hasCompletedCurrentStepAudio,\n });\n\n playbackResetKeyRef.current = currentPlaybackResetKey;\n\n const shouldOpenInteractionOverlayAfterAudio =\n pendingInteractionOverlayStepIndexRef.current === currentIndex &&\n Boolean(currentInteractionElement);\n const shouldPresentOverlay = shouldPresentInteractionOverlay({\n hasInteraction: Boolean(currentInteractionElement),\n shouldBlockPlaybackForInteraction,\n shouldOpenInteractionOverlayAfterAudio,\n hasPlaybackContextChanged,\n hasResolvedCurrentInteraction,\n currentStepHasSpeakableElement,\n });\n\n const pendingSubtitleJump = pendingSubtitleJumpRef.current;\n const shouldPreservePendingSubtitleJump =\n pendingSubtitleJump?.slideIndex === currentIndex;\n\n if (hasPlaybackContextChanged) {\n resetAudioSequence({\n preservePendingSubtitleJump: shouldPreservePendingSubtitleJump,\n });\n }\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldPausePlaybackForCustomAction) {\n return;\n }\n\n if (pendingSubtitleJump?.slideIndex === currentIndex) {\n if (\n !canReachSubtitleJumpTarget({\n currentIndex,\n resolvedCurrentInteractionElement: activeInteractionElement,\n slideElementList,\n targetSlideIndex: pendingSubtitleJump.slideIndex,\n })\n ) {\n // Keep the pending seek queued while the interaction overlay gates playback.\n } else {\n pendingSubtitleJumpRef.current = null;\n // The default audio-start effect still sees the pre-seek render state.\n // Skip it once so it does not replace the subtitle target audio.\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current = true;\n setCurrentAudioKey(pendingSubtitleJump.audioKey);\n requestSubtitleCueSeek({\n audioIndex: pendingSubtitleJump.audioIndex,\n timeMs: pendingSubtitleJump.timeMs,\n });\n return;\n }\n }\n\n if (currentInteractionElement) {\n setActiveInteractionElement(currentInteractionElement);\n }\n\n if (shouldPresentOverlay) {\n // Delay auto-presenting the overlay so subtitles can settle above it.\n scheduleInteractionOverlayOpen(currentInteractionElement);\n return;\n }\n\n clearInteractionOverlayOpenTimer();\n pendingInteractionOverlayStepIndexRef.current = null;\n\n if (!shouldInitializeAudioSequence) {\n return;\n }\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (currentStepHasSpeakableElement) {\n if (disableLoadingOverlay) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(true);\n return;\n }\n\n if (!canGoNext) {\n return;\n }\n\n if (shouldUseSilentStepAutoAdvanceToggle && !isAutoAdvanceEnabled) {\n return;\n }\n\n if (isImageOnlySilentStep && !isImageOnlyStepVisualReady) {\n return;\n }\n\n // Auto-advance silent marker-only steps so playback flow does not stall.\n autoAdvanceTimerRef.current = window.setTimeout(() => {\n autoAdvanceTimerRef.current = null;\n goNext();\n }, silentStepAutoAdvanceDelay);\n\n return () => {\n clearAutoAdvanceTimer();\n };\n }, [\n activeInteractionElement,\n canGoNext,\n clearAutoAdvanceTimer,\n currentElementList.length,\n currentIndex,\n currentInteractionElement,\n currentAudioKey,\n currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n isImageOnlySilentStep,\n isImageOnlyStepVisualReady,\n silentStepAutoAdvanceDelay,\n goNext,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n isAutoAdvanceEnabled,\n hasResolvedCurrentInteraction,\n shouldBlockPlaybackForInteraction,\n clearInteractionOverlayOpenTimer,\n resetAudioSequence,\n requestSubtitleCueSeek,\n scheduleInteractionOverlayOpen,\n shouldMountPlayer,\n slideElementList,\n startCurrentAudioSequence,\n shouldPausePlaybackForCustomAction,\n shouldUseSilentStepAutoAdvanceToggle,\n ]);\n\n useEffect(() => {\n if (\n disableLoadingOverlay ||\n shouldPausePlaybackForCustomAction ||\n !currentStepHasSpeakableElement ||\n shouldBlockPlaybackForInteraction\n ) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (hasAvailableStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setAudioLoadingReason(\"waitingForAudio\");\n setIsAudioLoadingVisible(true);\n }, [\n hasAvailableStepAudio,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n ]);\n\n useEffect(() => {\n const shouldSkipDefaultAudioStart =\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current;\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current = false;\n\n if (\n !shouldStartDefaultAudioSequence({\n currentAudioKey,\n currentAudioSequenceLength: currentAudioSequenceKeys.length,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldBlockPlaybackForInteraction,\n shouldPausePlaybackForCustomAction,\n shouldSkipDefaultAudioStart,\n })\n ) {\n return;\n }\n\n startCurrentAudioSequence();\n }, [\n currentAudioKey,\n currentAudioSequenceKeys,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n startCurrentAudioSequence,\n ]);\n\n useEffect(() => {\n if (!currentAudioKey || currentAudioIndex >= 0) {\n return;\n }\n\n setCurrentAudioKey(null);\n }, [currentAudioIndex, currentAudioKey]);\n\n useEffect(() => {\n if (currentAudioIndex >= 0) {\n return;\n }\n\n playbackTimeStore.reset();\n }, [currentAudioIndex, playbackTimeStore]);\n\n useEffect(() => {\n setHasCurrentAudioPlaybackStarted(false);\n }, [currentPlaybackStartedResetKey]);\n\n const {\n interactionDefaults,\n interactionDefaultSelectedValues,\n hasResolvedInteractionInput,\n isInteractionReadonly: resolvedInteractionReadonly,\n shouldAutoContinueInteraction,\n } = useMemo(\n () =>\n resolveSlideInteractionState(activeInteractionElement, {\n interactionDefaultValueOptions,\n }),\n [activeInteractionElement, interactionDefaultValueOptions]\n );\n\n const isInteractionReadonly =\n Boolean(activeInteractionElement?.readonly) || resolvedInteractionReadonly;\n const shouldShowInteractionOverlay = shouldRenderInteractionOverlay({\n hasActiveInteraction: Boolean(activeInteractionElement),\n isInteractionOverlayOpen,\n shouldBlockPlaybackForInteraction:\n shouldBlockPlaybackForInteraction &&\n !isInteractionReadonly &&\n !hasResolvedInteractionInput,\n playerControlsVisible,\n shouldMountPlayer,\n hasFocusedTextInput: hasFocusedInteractionTextInput,\n });\n\n const handleInteractionSend = useCallback(\n (content: OnSendContentParams) => {\n const submittedValues = [\n ...(content.selectedValues ?? []),\n content.inputText?.trim() ?? \"\",\n content.buttonText?.trim() ?? \"\",\n ].filter(Boolean);\n const resolvedUserInput = submittedValues.join(\", \");\n\n setActiveInteractionElement((prevElement) => {\n if (!prevElement || !resolvedUserInput) {\n return prevElement;\n }\n\n return {\n ...prevElement,\n user_input: resolvedUserInput,\n };\n });\n\n onSend?.(content, activeInteractionElement);\n continueAfterInteraction();\n },\n [activeInteractionElement, continueAfterInteraction, onSend]\n );\n\n useEffect(() => {\n // Keep the player icon in sync with the actual fullscreen owner.\n const syncFullscreenState = () => {\n setIsBrowserFullscreen(document.fullscreenElement === sectionRef.current);\n };\n\n syncFullscreenState();\n document.addEventListener(\"fullscreenchange\", syncFullscreenState);\n\n return () => {\n document.removeEventListener(\"fullscreenchange\", syncFullscreenState);\n };\n }, []);\n\n useEffect(() => {\n if (activeInteractionElement && isInteractionOverlayOpen) {\n return;\n }\n\n setHasInteractionOverlayActivity(false);\n setHasFocusedInteractionTextInput(false);\n }, [activeInteractionElement, isInteractionOverlayOpen]);\n\n useEffect(() => {\n if (!shouldShowInteractionOverlay) {\n setInteractionOverlaySubtitleOffset(0);\n return;\n }\n\n const interactionOverlayElement = interactionOverlayRef.current;\n\n if (!interactionOverlayElement) {\n return;\n }\n\n const updateSubtitleOffset = () => {\n const overlayHeight = Math.ceil(\n interactionOverlayElement.getBoundingClientRect().height\n );\n\n setInteractionOverlaySubtitleOffset(\n overlayHeight + DEFAULT_INTERACTION_SUBTITLE_GAP_PX\n );\n };\n\n updateSubtitleOffset();\n\n if (typeof ResizeObserver === \"undefined\") {\n return;\n }\n\n const resizeObserver = new ResizeObserver(() => {\n updateSubtitleOffset();\n });\n\n resizeObserver.observe(interactionOverlayElement);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [shouldShowInteractionOverlay]);\n\n useEffect(() => {\n clearInteractionAutoCloseTimer();\n\n if (!isInteractionOverlayOpen) {\n return;\n }\n\n if (shouldAutoContinueInteraction) {\n // Auto-close passive interaction markers to keep playback moving.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS);\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }\n\n if (hasInteractionOverlayActivity || !hasResolvedInteractionInput) {\n return;\n }\n\n // Give resolved history interactions a short revisit window before\n // playback resumes, but stop auto-closing once the learner starts editing.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS);\n\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }, [\n clearInteractionAutoCloseTimer,\n continueAfterInteraction,\n hasInteractionOverlayActivity,\n hasResolvedInteractionInput,\n isInteractionOverlayOpen,\n shouldAutoContinueInteraction,\n ]);\n\n const renderSlideElement = (\n element?: Element,\n options: RenderSlideElementOptions = {}\n ) => {\n if (!element) {\n return null;\n }\n\n if (element.type === \"slot\") {\n return <>{element.content}</>;\n }\n\n if (element.type === \"html\") {\n return (\n <IframeSandbox\n className=\"content-render-iframe\"\n disableLoadingOverlay={disableLoadingOverlay}\n hideFullScreen\n locale={locale}\n mode=\"blackboard\"\n replaceRootScreenHeightWithFull={\n options.replaceRootScreenHeightWithFull\n }\n type=\"sandbox\"\n content={element.content as string}\n enableScaling={enableIframeScaling}\n />\n );\n }\n\n return (\n <IframeSandbox\n className=\"content-render-iframe\"\n disableLoadingOverlay={disableLoadingOverlay}\n hideFullScreen\n locale={locale}\n mode=\"blackboard\"\n type=\"markdown\"\n content={element.content as string}\n />\n );\n };\n\n const renderSlideElementList = (\n elementList: Element[] = [],\n isActiveStep = false\n ) => {\n if (elementList.length === 0) {\n return null;\n }\n\n const visibleElementCount = elementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const markdownScalingMode =\n isActiveStep && enableMarkdownScaling\n ? resolveMarkdownScalingMode(elementList)\n : \"disabled\";\n const lastVisibleElementIndex = elementList.reduce(\n (lastVisibleIndex, element, index) =>\n element.is_renderable !== false ? index : lastVisibleIndex,\n -1\n );\n\n return (\n <MarkdownSlideScaling\n className=\"slide-stage__content flex w-full flex-col gap-4\"\n mode={markdownScalingMode}\n >\n {elementList.map((element, index) => {\n const isPreRenderedHtml =\n element.type === \"html\" && element.is_renderable === false;\n\n return (\n <div\n key={element.sequence_number ?? `${element.type}-${index}`}\n ref={\n isActiveStep && index === lastVisibleElementIndex\n ? lastElementRef\n : null\n }\n aria-hidden={isPreRenderedHtml || undefined}\n className={cn(\n \"w-full shrink-0\",\n visibleElementCount === 1 &&\n element.is_renderable !== false &&\n \"slide-element--single\",\n isPreRenderedHtml\n ? \"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0\"\n : element.is_renderable === false && \"hidden\"\n )}\n >\n {renderSlideElement(element, {\n replaceRootScreenHeightWithFull:\n visibleElementCount === 1 &&\n element.type === \"html\" &&\n element.is_renderable !== false,\n })}\n </div>\n );\n })}\n </MarkdownSlideScaling>\n );\n };\n\n const handleFullscreen = useCallback(() => {\n const target = sectionRef.current;\n if (!target) {\n return;\n }\n\n if (document.fullscreenElement === target) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n\n target.requestFullscreen?.().catch(() => {});\n }, []);\n\n const scrollStageToBottom = useCallback(() => {\n const stageLayerElement = stageLayerRef.current;\n\n if (!stageLayerElement) {\n return;\n }\n\n // Keep the latest content visible after manual player navigation.\n stageLayerElement.scrollTo({\n top: stageLayerElement.scrollHeight,\n behavior: \"smooth\",\n });\n }, []);\n\n const canJumpToSubtitleTarget = useCallback(\n (target: SlidePlayerSubtitleJumpTarget) =>\n canReachSubtitleJumpTarget({\n currentIndex,\n resolvedCurrentInteractionElement: activeInteractionElement,\n slideElementList,\n targetSlideIndex: audioSlideIndexes[target.audioIndex],\n }),\n [\n activeInteractionElement,\n audioSlideIndexes,\n currentIndex,\n slideElementList,\n ]\n );\n\n const handleSubtitleJump = useCallback(\n (\n target: SlidePlayerSubtitleJumpTarget,\n context: SlidePlayerNavigationContext\n ) => {\n const targetAudio = audioList[target.audioIndex];\n const targetAudioKey = targetAudio?.audioKey;\n const targetSlideIndex = audioSlideIndexes[target.audioIndex];\n\n if (!targetAudioKey || targetSlideIndex == null) {\n return false;\n }\n\n if (!canJumpToSubtitleTarget(target)) {\n return false;\n }\n\n syncPlaybackPreferenceBeforeNavigation(context);\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setHasCurrentAudioPlaybackStarted(false);\n\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n\n if (targetSlideIndex === currentIndex) {\n pendingSubtitleJumpRef.current = null;\n resetAudioSequence();\n setCurrentAudioKey(targetAudioKey);\n requestSubtitleCueSeek(target);\n return true;\n }\n\n shouldScrollToBottomRef.current = true;\n resetAudioSequence();\n pendingSubtitleJumpRef.current = {\n audioIndex: target.audioIndex,\n audioKey: targetAudioKey,\n slideIndex: targetSlideIndex,\n timeMs: target.timeMs,\n };\n goTo(targetSlideIndex);\n\n return true;\n },\n [\n audioList,\n audioSlideIndexes,\n canJumpToSubtitleTarget,\n currentIndex,\n goTo,\n requestSubtitleCueSeek,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handlePrev = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n syncPlaybackPreferenceBeforeNavigation(context);\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n resetAudioSequence();\n goPrev();\n },\n [\n goPrev,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handleNext = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n syncPlaybackPreferenceBeforeNavigation(context);\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n resetAudioSequence();\n goNext();\n },\n [\n goNext,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handlePlayerLoadingChange = useCallback(\n ({\n loading,\n reason,\n }: {\n loading: boolean;\n reason: SlidePlayerLoadingReason | null;\n }) => {\n if (disableLoadingOverlay) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (loading && reason) {\n setAudioLoadingReason(reason);\n }\n setIsAudioLoadingVisible(shouldShowBufferingOverlay(reason, loading));\n },\n [\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n ]\n );\n\n useEffect(() => {\n if (!disableLoadingOverlay) {\n return;\n }\n\n setIsAudioLoadingVisible(false);\n }, [disableLoadingOverlay]);\n\n const handlePlayerEnded = useCallback(\n (audioIndex: number) => {\n const endedAudioKey = audioList[audioIndex]?.audioKey;\n\n if (!endedAudioKey || !currentAudioKey) {\n return;\n }\n\n if (endedAudioKey !== currentAudioKey) {\n return;\n }\n\n const activeSequencePosition = currentAudioSequenceKeys.findIndex(\n (audioSequenceKey) => audioSequenceKey === endedAudioKey\n );\n if (activeSequencePosition < 0) {\n setCurrentAudioKey(null);\n return;\n }\n\n const nextSequencePosition = activeSequencePosition + 1;\n const nextAudioKey = currentAudioSequenceKeys[nextSequencePosition];\n\n if (nextAudioKey) {\n setCurrentAudioKey(nextAudioKey);\n return;\n }\n\n setCurrentAudioKey(null);\n setHasCompletedCurrentStepAudio(true);\n setIsAudioLoadingVisible(false);\n\n if (canGoNext) {\n const nextStepIndex = currentIndex + 1;\n const nextStepElement = slideElementList[nextStepIndex];\n\n if (hasCurrentStepAudioUrl && nextStepElement?.type === \"interaction\") {\n pendingInteractionOverlayStepIndexRef.current = nextStepIndex;\n }\n\n goNext();\n return;\n }\n },\n [\n audioList,\n canGoNext,\n currentIndex,\n currentAudioKey,\n currentAudioSequenceKeys,\n goNext,\n hasCurrentStepAudioUrl,\n slideElementList,\n ]\n );\n\n const handleInteractionToggle = useCallback(() => {\n if (!activeInteractionElement) {\n return;\n }\n\n setIsInteractionOverlayOpen((prevOpen) => !prevOpen);\n }, [activeInteractionElement]);\n\n const handlePlayerControlsPointerEnter = useCallback(() => {\n isPointerInsidePlayerControlsRef.current = true;\n clearPlayerHideTimer();\n\n if (shouldMountPlayer) {\n setIsPlayerVisible(true);\n }\n }, [clearPlayerHideTimer, shouldMountPlayer]);\n\n const handlePlayerControlsPointerLeave = useCallback(() => {\n isPointerInsidePlayerControlsRef.current = false;\n revealPlayerControls(true);\n }, [revealPlayerControls]);\n\n const stopOverlayPropagation = useCallback(\n (\n event:\n | React.PointerEvent<HTMLDivElement>\n | React.MouseEvent<HTMLDivElement>\n ) => {\n event.stopPropagation();\n\n // Keep the player visible a bit longer when users interact with the overlay.\n if (playerControlsVisible) {\n revealPlayerControls(true);\n }\n },\n [playerControlsVisible, revealPlayerControls]\n );\n\n const handleSurfacePointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n activateKeyboardShortcutOwner();\n onPointerDown?.(event);\n },\n [activateKeyboardShortcutOwner, onPointerDown]\n );\n\n const handleSurfaceFocusCapture = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n activateKeyboardShortcutOwner();\n onFocusCapture?.(event);\n },\n [activateKeyboardShortcutOwner, onFocusCapture]\n );\n\n const handleSurfaceClick = useCallback(() => {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }, [revealPlayerControls]);\n useEffect(() => {\n const prevKeys = prevRenderElementKeysRef.current;\n const hasStablePrefix =\n prevKeys.length > 0 &&\n prevKeys.length < currentRenderElementKeys.length &&\n prevKeys.every((key, index) => key === currentRenderElementKeys[index]);\n const appendedElements = hasStablePrefix\n ? currentElementList.slice(prevKeys.length)\n : [];\n const shouldAutoScrollToAppend = appendedElements.some(\n (element) => element.is_new === false\n );\n\n prevRenderElementKeysRef.current = currentRenderElementKeys;\n\n if (!shouldAutoScrollToAppend) {\n return;\n }\n\n const animationFrameId = window.requestAnimationFrame(() => {\n const stageLayerElement = stageLayerRef.current;\n const targetElement = lastElementRef.current;\n\n if (!stageLayerElement || !targetElement) {\n return;\n }\n\n const stageLayerRect = stageLayerElement.getBoundingClientRect();\n const targetRect = targetElement.getBoundingClientRect();\n const nextScrollTop =\n stageLayerElement.scrollTop + (targetRect.top - stageLayerRect.top);\n\n // Keep newly appended content visible when the current slide grows downward.\n stageLayerElement.scrollTo({\n top: Math.max(nextScrollTop, 0),\n behavior: \"smooth\",\n });\n });\n\n return () => {\n window.cancelAnimationFrame(animationFrameId);\n };\n }, [currentElementList, currentRenderElementKeys]);\n\n useEffect(() => {\n if (!shouldScrollToBottomRef.current) {\n return;\n }\n\n shouldScrollToBottomRef.current = false;\n\n if (currentElementList.length === 0) {\n return;\n }\n\n const animationFrameId = window.requestAnimationFrame(() => {\n scrollStageToBottom();\n });\n\n return () => {\n window.cancelAnimationFrame(animationFrameId);\n };\n }, [currentElementList, scrollStageToBottom]);\n\n return (\n <section\n ref={sectionRef}\n className={cn(\n \"relative h-full w-full\",\n isMobileDevice && \"slide--mobile-device\",\n isDesktopBrowserFullscreen && \"slide--browser-fullscreen\",\n isImmersiveMobileFullscreen && \"slide--mobile-landscape\",\n isNativeMobileFullscreen && \"slide--mobile-landscape-native\",\n className\n )}\n onClick={handleSurfaceClick}\n onFocusCapture={handleSurfaceFocusCapture}\n onPointerDown={handleSurfacePointerDown}\n {...props}\n >\n {shouldShowMobileFullscreenMask ? (\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]\"\n />\n ) : null}\n\n <div\n ref={viewportRef}\n className={cn(\n \"slide__viewport relative h-full min-h-0 w-full\",\n isImmersiveMobileFullscreen && \"slide__viewport--mobile-landscape\",\n isImmersiveMobileFullscreen &&\n !shouldRotateFullscreenViewport &&\n \"slide__viewport--mobile-landscape-native\"\n )}\n >\n {shouldShowFullscreenHeader ? (\n <div className=\"slide-landscape-header\">\n <button\n aria-label={\n fullscreenHeader?.backAriaLabel ??\n localeTexts.fullscreenBackAriaLabel\n }\n className=\"slide-landscape-header__back\"\n onClick={handleFullscreenHeaderBack}\n type=\"button\"\n >\n <ChevronLeft\n className=\"slide-landscape-header__icon h-6 w-6\"\n strokeWidth={2.25}\n />\n </button>\n\n {fullscreenHeader?.content ? (\n <div className=\"min-w-0 flex-1 overflow-hidden\">\n {fullscreenHeader.content}\n </div>\n ) : null}\n </div>\n ) : null}\n\n <div\n className={cn(\n \"h-full min-h-0 w-full\",\n shouldApplyFullscreenViewportPadding &&\n \"slide__viewport-content--with-header\",\n isSingleSlide ? \"slide-content--single\" : \"grid gap-4\"\n )}\n >\n {currentElementList.length > 0 ? (\n <div className=\"slide-stage\">\n <div ref={stageLayerRef} className=\"slide-stage__layer w-full\">\n {mountedStepStates.map(\n (mountedStepState, mountedStepStateIndex) => {\n const isActiveStep =\n mountedStepStateIndex === currentMountedStateIndex;\n\n return (\n <div\n key={\n mountedStepState.sourceStepIndexes[0] ??\n mountedStepStateIndex\n }\n data-active-step={isActiveStep ? \"true\" : undefined}\n aria-hidden={!isActiveStep || undefined}\n className=\"w-full h-full\"\n style={{ display: isActiveStep ? undefined : \"none\" }}\n >\n {renderSlideElementList(\n mountedStepState.elementList,\n isActiveStep\n )}\n </div>\n );\n }\n )}\n </div>\n </div>\n ) : null}\n </div>\n\n {isAudioLoadingVisible ? (\n <LoadingOverlayCard\n message={resolveBufferingTextByReason(\n resolvedBufferingText,\n audioLoadingReason\n )}\n className=\"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2\"\n />\n ) : null}\n\n <SubtitleOverlay\n extraBottomOffset={interactionOverlaySubtitleOffset}\n hasPlayerGap={playerControlsVisible}\n isEnabled={isSubtitleEnabled && hasCurrentAudioPlaybackStarted}\n isPlayerHidden={shouldMountPlayer && !playerControlsVisible}\n playbackTimeStore={playbackTimeStore}\n subtitleCues={currentSubtitleCues}\n />\n\n {shouldShowInteractionOverlay ? (\n <div\n ref={interactionOverlayRef}\n data-player-keyboard-shortcuts-ignore=\"true\"\n className={cn(\n \"slide-interaction-overlay\",\n playerControlsVisible && shouldMountPlayer\n ? \"slide-interaction-overlay--with-player\"\n : \"slide-interaction-overlay--standalone\"\n )}\n onClick={stopOverlayPropagation}\n onPointerDown={stopOverlayPropagation}\n onPointerDownCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n onFocusCapture={(event) => {\n if (isTextEntryTarget(event.target)) {\n setHasFocusedInteractionTextInput(true);\n }\n\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n onBlurCapture={(event) => {\n if (!isTextEntryTarget(event.target)) {\n return;\n }\n\n const nextFocusTarget = event.relatedTarget;\n\n if (\n nextFocusTarget instanceof HTMLElement &&\n interactionOverlayRef.current?.contains(nextFocusTarget)\n ) {\n return;\n }\n\n setHasFocusedInteractionTextInput(false);\n }}\n onInputCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n style={interactionOverlayStyle}\n >\n <InteractionOverlayCard\n content={String(activeInteractionElement?.content ?? \"\")}\n locale={locale}\n defaultButtonText={interactionDefaults.buttonText ?? \"\"}\n defaultInputText={interactionDefaults.inputText ?? \"\"}\n defaultSelectedValues={interactionDefaultSelectedValues}\n confirmButtonText={\n interactionTexts?.confirmButtonText ??\n localeTexts.interactionTexts.confirmButtonText\n }\n copyButtonText={\n interactionTexts?.copyButtonText ??\n localeTexts.interactionTexts.copyButtonText\n }\n copiedButtonText={\n interactionTexts?.copiedButtonText ??\n localeTexts.interactionTexts.copiedButtonText\n }\n onSend={handleInteractionSend}\n readonly={isInteractionReadonly}\n title={\n interactionTexts?.title ??\n interactionTitle ??\n localeTexts.interactionTexts.title\n }\n />\n </div>\n ) : null}\n\n {shouldMountPlayer ? (\n <PlayerKeyboardShortcutContext.Provider\n value={keyboardShortcutContextValue}\n >\n <Player\n audioList={audioList}\n className={cn(\n \"absolute left-1/2 z-[2] -translate-x-1/2\",\n isDesktopBrowserFullscreen ? \"bottom-3\" : \"-bottom-3\",\n playerClassName,\n !playerControlsVisible && \"pointer-events-none opacity-0\"\n )}\n currentAudioIndex={currentAudioIndex}\n defaultPlaying={isPlaybackRequested}\n enableKeyboardShortcuts={enableKeyboardShortcuts}\n isPlaybackPaused={shouldPausePlaybackForCustomAction}\n isAutoAdvanceEnabled={isAutoAdvanceEnabled}\n locale={locale}\n hasInteraction={Boolean(activeInteractionElement)}\n isInteractionOpen={isInteractionOverlayOpen}\n isSubtitleEnabled={isSubtitleEnabled}\n onAutoAdvanceToggle={setIsAutoAdvanceEnabled}\n onLoadingChange={handlePlayerLoadingChange}\n onPlaybackStarted={() => {\n setHasCurrentAudioPlaybackStarted(true);\n }}\n onPlaybackPreferenceChange={handlePlaybackPreferenceChange}\n onPlaybackTimeChange={playbackTimeStore.setTime}\n onSubtitleToggle={() => {\n setIsSubtitleEnabled((previousEnabled) => !previousEnabled);\n }}\n nextDisabled={!canGoNext}\n onEnded={handlePlayerEnded}\n onFullscreen={handleFullscreen}\n isFullscreen={isBrowserFullscreen}\n mobileViewMode={effectiveMobileViewMode}\n settingsPortalContainer={viewportRef.current}\n onMobileViewModeChange={handleMobileViewModeSelect}\n onControlsPointerEnter={handlePlayerControlsPointerEnter}\n onControlsPointerLeave={handlePlayerControlsPointerLeave}\n onInteractionToggle={handleInteractionToggle}\n onNext={handleNext}\n onPrev={handlePrev}\n onSubtitleJump={handleSubtitleJump}\n canJumpToSubtitleTarget={canJumpToSubtitleTarget}\n prevDisabled={!canGoPrev}\n showControls={playerControlsVisible}\n subtitleSeekRequest={subtitleSeekRequest}\n texts={playerTexts}\n customActionContext={playerCustomActionContext}\n customActions={playerCustomActions}\n useAutoAdvanceToggle={shouldUseSilentStepAutoAdvanceToggle}\n />\n </PlayerKeyboardShortcutContext.Provider>\n ) : null}\n </div>\n </section>\n );\n};\n\nexport default Slide;\n"],"names":["DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX","DEFAULT_INTERACTION_SUBTITLE_GAP_PX","DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS","INTERACTION_ACTIVITY_SELECTOR","DEFAULT_BUFFERING_REASON","resolveBufferingTextByReason","bufferingText","reason","DEFAULT_SLIDE_BUFFERING_TEXTS","mergeBufferingTextWithLocaleDefaults","localeBufferingText","shouldShowBufferingOverlay","loading","InteractionOverlayCard","memo","content","title","locale","defaultButtonText","defaultInputText","defaultSelectedValues","confirmButtonText","copyButtonText","copiedButtonText","onSend","readonly","jsxs","jsx","ContentRender","areStepElementListsEqual","prevElementList","nextElementList","element","index","nextElement","isInteractionActivityTarget","target","TEXT_ENTRY_SELECTOR","isTextEntryTarget","Slide","elementList","playerEnabled","playerControlsVisibility","playerClassName","fullscreenHeader","playerCustomActions","playerCustomActionPauseOnActive","interactionTitle","interactionTexts","playerTexts","playerAutoHideDelay","markerAutoAdvanceDelay","interactionDefaultValueOptions","onPlayerVisibilityChange","onMobileViewModeChange","onStepChange","enableKeyboardShortcuts","enableIframeScaling","enableMarkdownScaling","disableLoadingOverlay","className","onPointerDown","onFocusCapture","props","localeTexts","useMemo","getSlideLocaleTexts","resolvedBufferingText","resolvedPlayerEnabled","resolvedPlayerControlsVisibility","resolveSlidePlayerVisibility","keyboardShortcutOwnerId","useId","sectionRef","useRef","viewportRef","stageLayerRef","lastElementRef","playerHideTimerRef","isPointerInsidePlayerControlsRef","autoAdvanceTimerRef","imageOnlyStepReadyTimeoutRef","interactionAutoCloseTimerRef","interactionOverlayOpenTimerRef","interactionOverlayRef","prevRenderElementKeysRef","shouldScrollToBottomRef","pendingInteractionOverlayStepIndexRef","pendingSubtitleJumpRef","subtitleSeekRequestIdRef","playbackResetKeyRef","appendedMarkerAdvanceStateRef","shouldSkipDefaultAudioStartForSubtitleJumpRef","currentElementList","stepElementLists","slideElementList","currentIndex","audioList","audioSlideIndexes","currentAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement","canGoPrev","canGoNext","goPrev","goNext","goTo","useSlide","currentStepElement","currentRenderElementKeys","isSingleSlide","shouldMountPlayer","keyboardShortcutContextValue","activateKeyboardShortcutOwner","useCallback","activatePlayerKeyboardShortcutOwner","currentAudioSequenceKeys","audioIndex","audioKey","isPlayerVisible","setIsPlayerVisible","useState","hasPlayerInteracted","setHasPlayerInteracted","isPlaybackRequested","setIsPlaybackRequested","isAutoAdvanceEnabled","setIsAutoAdvanceEnabled","currentAudioKey","setCurrentAudioKey","subtitleSeekRequest","setSubtitleSeekRequest","isAudioLoadingVisible","setIsAudioLoadingVisible","audioLoadingReason","setAudioLoadingReason","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","hasCurrentAudioPlaybackStarted","setHasCurrentAudioPlaybackStarted","isSubtitleEnabled","setIsSubtitleEnabled","isPlayerCustomActionActive","setIsPlayerCustomActionActive","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","hasInteractionOverlayActivity","setHasInteractionOverlayActivity","hasFocusedInteractionTextInput","setHasFocusedInteractionTextInput","interactionOverlaySubtitleOffset","setInteractionOverlaySubtitleOffset","isBrowserFullscreen","setIsBrowserFullscreen","isMobileDevice","getIsMobileDevice","mobileViewMode","setMobileViewMode","DEFAULT_MOBILE_VIEW_MODE","hasManualMobileViewMode","setHasManualMobileViewMode","isViewportFullscreenPreferred","setIsViewportFullscreenPreferred","getIsFullscreenPreferredViewport","playbackTimeStore","createPlaybackTimeStore","effectiveMobileViewMode","isImmersiveMobileFullscreen","isNativeMobileFullscreen","shouldRotateFullscreenViewport","resolveMobileViewModeState","previousEffectiveMobileViewModeRef","playerControlsVisible","shouldShowFullscreenHeader","shouldApplyFullscreenViewportPadding","shouldShowMobileFullscreenMask","isDesktopBrowserFullscreen","handleMobileViewModeSelect","nextViewMode","handleMobileViewModeReset","handleFullscreenHeaderBack","setPlayerCustomActionActive","active","togglePlayerCustomActionActive","previous","mountedStepStates","currentMountedStateIndex","nextMountedStepStates","mountedStateIndexByStep","stepElementList","stepIndex","existingMountedStateIndex","mountedStepState","currentStepKey","currentAudioIndex","audioItem","currentAudioItem","currentSubtitleCues","currentAudioSequenceStartKey","playerCustomActionContext","resolvePlayerCustomActionElement","playerCustomActionCount","getPlayerCustomActionCount","interactionOverlayStyle","hasAvailableStepAudio","currentInteractionResetKey","currentPlaybackResetKey","currentPlaybackStartedResetKey","hasCurrentStepAudioUrl","shouldPausePlaybackForCustomAction","shouldUseSilentStepAutoAdvanceToggle","shouldUseAutoAdvanceToggle","silentStepAutoAdvanceBehavior","resolveSilentStepAutoAdvanceBehavior","silentStepAutoAdvanceDelay","isImageOnlySilentStep","imageOnlyStepVisualReadyKey","readyImageOnlyStepKey","setReadyImageOnlyStepKey","isImageOnlyStepVisualReady","clearPlayerHideTimer","clearInteractionAutoCloseTimer","clearInteractionOverlayOpenTimer","clearAutoAdvanceTimer","clearImageOnlyStepReadyTimeout","resetAudioSequence","options","requestSubtitleCueSeek","startCurrentAudioSequence","nextAudioKey","continueAfterInteraction","scheduleInteractionOverlayOpen","interactionElement","openOverlay","isPlayerControlsHovered","revealPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","hasResolvedInteractionElement","shouldBlockPlaybackForInteraction","handlePlaybackPreferenceChange","playing","syncPlaybackPreferenceBeforeNavigation","context","useEffect","cancelled","rafId","cleanupListeners","detachListeners","finishVisualReady","evaluateVisualReady","activeStepContainer","iframeElements","areImageOnlyStepIframeVisualsReady","cleanupCallbacks","queueRecheck","registerEvent","eventName","listener","iframeElement","iframeDocument","image","cleanup","DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS","syncViewportFullscreenPreference","subscribeMobileDeviceChange","previousState","shouldAdvanceIntoAppendedMarker","shouldAutoAdvanceIntoAppendedMarker","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","hasPlaybackContextChanged","shouldInitializeAudioSequence","getPlaybackSequenceTransition","shouldOpenInteractionOverlayAfterAudio","shouldPresentOverlay","shouldPresentInteractionOverlay","pendingSubtitleJump","shouldPreservePendingSubtitleJump","canReachSubtitleJumpTarget","shouldSkipDefaultAudioStart","shouldStartDefaultAudioSequence","interactionDefaults","interactionDefaultSelectedValues","hasResolvedInteractionInput","resolvedInteractionReadonly","shouldAutoContinueInteraction","resolveSlideInteractionState","isInteractionReadonly","shouldShowInteractionOverlay","shouldRenderInteractionOverlay","handleInteractionSend","resolvedUserInput","prevElement","syncFullscreenState","interactionOverlayElement","updateSubtitleOffset","overlayHeight","resizeObserver","renderSlideElement","Fragment","IframeSandbox","renderSlideElementList","isActiveStep","visibleElementCount","markdownScalingMode","resolveMarkdownScalingMode","lastVisibleElementIndex","lastVisibleIndex","MarkdownSlideScaling","isPreRenderedHtml","cn","handleFullscreen","scrollStageToBottom","stageLayerElement","canJumpToSubtitleTarget","handleSubtitleJump","targetAudioKey","targetSlideIndex","shouldWakePlayerControlsAfterNavigation","handlePrev","handleNext","handlePlayerLoadingChange","handlePlayerEnded","endedAudioKey","activeSequencePosition","audioSequenceKey","nextSequencePosition","nextStepIndex","nextStepElement","handleInteractionToggle","prevOpen","handlePlayerControlsPointerEnter","handlePlayerControlsPointerLeave","stopOverlayPropagation","handleSurfacePointerDown","handleSurfaceFocusCapture","handleSurfaceClick","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","ChevronLeft","mountedStepStateIndex","LoadingOverlayCard","SubtitleOverlay","nextFocusTarget","PlayerKeyboardShortcutContext","Player","previousEnabled"],"mappings":"6qDA4FMA,GAAuC,IACvCC,GAA4C,IAC5CC,GAAiD,IACjDC,GAAsC,GACtCC,GAAmD,IACnDC,GAAgC,CACpC,SACA,QACA,WACA,uBACA,2BACA,oCACF,EAAE,KAAK,IAAI,EACLC,GAAiD,kBAQjDC,GAA+B,CACnCC,EACAC,IAEI,OAAOD,GAAkB,SACpBA,EAIPA,EAAcC,CAAM,GACpBD,EAAcF,EAAwB,GACtCI,GAAAA,8BAA8BD,CAAM,EAIlCE,GAAuC,CAC3CH,EACAI,IAEI,OAAOJ,GAAkB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ACV,MACEpP,GAAkB,OAClBD,IACAiB,EAAY,iBAAiB,KAAA,CAAA,CAEjC,CAAA,EAEA,KAEH+C,EACCpF,EAAAA,kBAAAA,IAACwU,GAAAA,8BAA8B,SAA9B,CACC,MAAOnP,GAEP,SAAArF,EAAAA,kBAAAA,IAACyU,GAAAA,QAAA,CACC,UAAAnQ,EACA,UAAW0N,GAAAA,GACT,2CACAzI,GAA6B,WAAa,YAC1CvI,EACA,CAACmI,GAAyB,+BAAA,EAE5B,kBAAAsB,EACA,eAAgBxE,GAChB,wBAAApE,EACA,iBAAkB2J,EAClB,qBAAArF,GACA,OAAA7G,EACA,eAAgB,EAAQ+H,EACxB,kBAAmBE,GACnB,kBAAAN,GACA,oBAAqBb,GACrB,gBAAiBuM,GACjB,kBAAmB,IAAM,CACvB3L,GAAkC,EAAI,CACxC,EACA,2BAA4BuG,GAC5B,qBAAsB5E,GAAkB,QACxC,iBAAkB,IAAM,CACtBzB,GAAsBwN,GAAoB,CAACA,CAAe,CAC5D,EACA,aAAc,CAAC9P,EACf,QAASgO,GACT,aAAcX,GACd,aAAclK,GACd,eAAgBc,GAChB,wBAAyB7F,GAAY,QACrC,uBAAwBwG,GACxB,uBAAwB6J,GACxB,uBAAwBC,GACxB,oBAAqBH,GACrB,OAAQT,GACR,OAAQD,GACR,eAAgBJ,GAChB,wBAAAD,GACA,aAAc,CAACzN,GACf,aAAcwE,EACd,oBAAA5C,GACA,MAAOjF,GACP,oBAAqBwJ,GACrB,cAAe5J,EACf,qBAAsBuK,EAAA,CAAA,CACxB,CAAA,EAEA,IAAA,CAAA,CAAA,CACN,CAAA,CAAA,CAGN"}
|
|
1
|
+
{"version":3,"file":"Slide.cjs.js","sources":["../../../src/components/Slide/Slide.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronLeft, GripHorizontal } from \"lucide-react\";\n\nimport { isSandboxInteractionMessage } from \"../../lib/sandboxInteraction\";\nimport { cn } from \"../../lib/utils\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\nimport ContentRender from \"../ContentRender\";\nimport type { ContentRenderProps } from \"../ContentRender/ContentRender\";\nimport IframeSandbox from \"../ContentRender/IframeSandbox\";\nimport type { OnSendContentParams } from \"../types\";\nimport type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport {\n isLandscapeViewport as getIsFullscreenPreferredViewport,\n isMobileDevice as getIsMobileDevice,\n subscribeMobileDeviceChange,\n} from \"../../lib/mobileDevice\";\nimport Player from \"./Player\";\nimport MarkdownSlideScaling from \"./MarkdownSlideScaling\";\nimport SubtitleOverlay from \"./SubtitleOverlay\";\nimport type {\n PlayerProps,\n SlidePlayerNavigationContext,\n SlidePlayerSubtitleJumpTarget,\n SlidePlayerSubtitleSeekRequest,\n SlidePlayerTexts,\n} from \"./Player\";\nimport type { SlidePlayerLoadingReason } from \"./Player\";\nimport type { Element } from \"./types\";\nimport useSlide from \"./useSlide\";\nimport useWakePlayerFromIframe from \"./useWakePlayerFromIframe\";\nimport { PlayerKeyboardShortcutContext } from \"./utils/playerKeyboardShortcutContext\";\nimport { activatePlayerKeyboardShortcutOwner } from \"./utils/playerKeyboardShortcuts\";\nimport {\n DEFAULT_MOBILE_VIEW_MODE,\n resolveMobileViewModeState,\n type MobileViewMode,\n} from \"./utils/mobileScreenMode\";\nimport {\n clampInteractionOverlayDragOffset,\n shouldPresentInteractionOverlay,\n shouldRenderInteractionOverlay,\n type InteractionOverlayDragBounds,\n type InteractionOverlayDragOffset,\n} from \"./utils/interactionPlayback\";\nimport { resolveMarkdownScalingMode } from \"./utils/markdownScaling\";\nimport { shouldWakePlayerControlsAfterNavigation } from \"./utils/playerNavigationContext\";\nimport { shouldAutoAdvanceIntoAppendedMarker } from \"./utils/appendedMarkerAdvance\";\nimport {\n getPlaybackSequenceTransition,\n shouldStartDefaultAudioSequence,\n} from \"./utils/playbackSequence\";\nimport {\n canReachSubtitleJumpTarget,\n hasResolvedInteractionElement,\n} from \"./utils/subtitleJumpNavigation\";\nimport {\n getPlayerCustomActionCount,\n resolvePlayerCustomActionElement,\n} from \"./utils/playerCustomActions\";\nimport { createPlaybackTimeStore } from \"./utils/playbackTimeStore\";\nimport { resolveSlideInteractionState } from \"./utils/interactionResolution\";\nimport { shouldUseAutoAdvanceToggle } from \"./utils/playerToggleMode\";\nimport {\n areImageOnlyStepIframeVisualsReady,\n DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS,\n} from \"./utils/imageOnlyStepVisualReady\";\nimport { resolveSilentStepAutoAdvanceBehavior } from \"./utils/silentStepAutoAdvance\";\nimport {\n resolveSlidePlayerVisibility,\n type SlidePlayerControlsVisibility,\n} from \"./utils/playerVisibility\";\nimport {\n DEFAULT_SLIDE_BUFFERING_TEXTS,\n getSlideLocaleTexts,\n type SlideBufferingReason,\n} from \"./slideI18n\";\nimport \"./slide.css\";\nexport type {\n Element,\n ElementAudioSegment,\n ElementSubtitleCue,\n SlidePlayerCustomActionContext,\n SlidePlayerCustomActions,\n} from \"./types\";\nexport type { SlidePlayerControlsVisibility } from \"./utils/playerVisibility\";\n\nconst DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS = 2000;\nconst DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS = 300;\nconst DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX = 160;\nconst DEFAULT_INTERACTION_SUBTITLE_GAP_PX = 16;\nconst DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS = 3000;\nconst DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET: InteractionOverlayDragOffset = {\n x: 0,\n y: 0,\n};\ntype InteractionOverlayLayoutRect = Pick<DOMRect, \"left\" | \"top\">;\nconst useIsomorphicLayoutEffect =\n typeof window === \"undefined\" ? useEffect : useLayoutEffect;\nconst INTERACTION_ACTIVITY_SELECTOR = [\n \"button\",\n \"input\",\n \"textarea\",\n '[contenteditable=\"\"]',\n '[contenteditable=\"true\"]',\n '[contenteditable=\"plaintext-only\"]',\n].join(\", \");\nconst DEFAULT_BUFFERING_REASON: SlideBufferingReason = \"waitingForAudio\";\n\nexport type { SlideBufferingReason } from \"./slideI18n\";\n\nexport type SlideBufferingTextConfig =\n | string\n | Partial<Record<SlideBufferingReason, string>>;\n\nconst resolveBufferingTextByReason = (\n bufferingText: SlideBufferingTextConfig,\n reason: SlideBufferingReason\n) => {\n if (typeof bufferingText === \"string\") {\n return bufferingText;\n }\n\n return (\n bufferingText[reason] ??\n bufferingText[DEFAULT_BUFFERING_REASON] ??\n DEFAULT_SLIDE_BUFFERING_TEXTS[reason]\n );\n};\n\nconst mergeBufferingTextWithLocaleDefaults = (\n bufferingText: SlideBufferingTextConfig | undefined,\n localeBufferingText: Record<string, string>\n): SlideBufferingTextConfig => {\n if (typeof bufferingText === \"string\") {\n return bufferingText;\n }\n\n return {\n ...localeBufferingText,\n ...bufferingText,\n };\n};\n\nconst shouldShowBufferingOverlay = (\n reason: SlideBufferingReason | null,\n loading: boolean\n) => {\n if (!loading) {\n return false;\n }\n\n // Keep the silent preload/loading phase invisible until audio is actually playable.\n return reason !== \"loadingAudio\";\n};\n\ntype RenderSlideElementOptions = {\n replaceRootScreenHeightWithFull?: boolean;\n};\n\ninterface InteractionOverlayCardProps {\n content: string;\n title: string;\n locale?: MarkdownFlowLocale;\n defaultButtonText?: string;\n defaultInputText?: string;\n defaultSelectedValues?: string[];\n confirmButtonText?: string;\n copyButtonText?: string;\n copiedButtonText?: string;\n onSend?: (content: OnSendContentParams) => void;\n onDragHandlePointerCancel?: React.PointerEventHandler<HTMLButtonElement>;\n onDragHandlePointerDown?: React.PointerEventHandler<HTMLButtonElement>;\n onDragHandlePointerMove?: React.PointerEventHandler<HTMLButtonElement>;\n onDragHandlePointerUp?: React.PointerEventHandler<HTMLButtonElement>;\n readonly?: boolean;\n}\n\nexport interface SlideInteractionTexts\n extends Pick<\n ContentRenderProps,\n \"confirmButtonText\" | \"copyButtonText\" | \"copiedButtonText\"\n > {\n title?: string;\n}\n\nexport type SlideFullscreenHeader = {\n content?: React.ReactNode;\n backAriaLabel?: string;\n onBack?: () => void;\n};\n\nconst InteractionOverlayCard = memo(\n ({\n content,\n title,\n locale,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n onSend,\n onDragHandlePointerCancel,\n onDragHandlePointerDown,\n onDragHandlePointerMove,\n onDragHandlePointerUp,\n readonly = false,\n }: InteractionOverlayCardProps) => (\n <div className=\"slide-player__interaction-card\">\n <button\n type=\"button\"\n className=\"slide-player__interaction-drag-handle\"\n aria-label=\"Move interaction\"\n onPointerCancel={onDragHandlePointerCancel}\n onPointerDown={onDragHandlePointerDown}\n onPointerMove={onDragHandlePointerMove}\n onPointerUp={onDragHandlePointerUp}\n >\n <span className=\"slide-player__interaction-drag-handle-icon\">\n <GripHorizontal aria-hidden=\"true\" />\n </span>\n </button>\n <div className=\"slide-player__interaction-header\">\n <p className=\"slide-player__interaction-title\">{title}</p>\n </div>\n <div className=\"slide-player__interaction-body\">\n <ContentRender\n content={content}\n locale={locale}\n defaultButtonText={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n onSend={onSend}\n readonly={readonly}\n sandboxMode=\"content\"\n />\n </div>\n </div>\n )\n);\n\nInteractionOverlayCard.displayName = \"InteractionOverlayCard\";\n\nconst areStepElementListsEqual = (\n prevElementList: Element[],\n nextElementList: Element[]\n) =>\n prevElementList.length === nextElementList.length &&\n prevElementList.every((element, index) => {\n const nextElement = nextElementList[index];\n\n return (\n element.sequence_number === nextElement?.sequence_number &&\n element.type === nextElement?.type &&\n element.content === nextElement?.content\n );\n });\n\nconst isInteractionActivityTarget = (\n target: EventTarget | null\n): target is HTMLElement =>\n target instanceof HTMLElement &&\n Boolean(target.closest(INTERACTION_ACTIVITY_SELECTOR));\nexport interface SlideProps extends React.ComponentProps<\"section\"> {\n elementList?: Element[];\n /** Locale used for built-in UI text when a more specific text prop is not provided. */\n locale?: MarkdownFlowLocale;\n /** Enables the player runtime, including audio playback and keyboard shortcuts. */\n playerEnabled?: boolean;\n /**\n * Controls whether the player controls are always visible, always hidden, or auto-hidden.\n *\n * Use `\"hidden\"` to keep audio playback and keyboard shortcuts active while\n * hiding the visual controls.\n *\n * @example\n * ```tsx\n * <Slide playerControlsVisibility=\"hidden\" enableKeyboardShortcuts />\n * ```\n */\n playerControlsVisibility?: SlidePlayerControlsVisibility;\n playerClassName?: string;\n fullscreenHeader?: SlideFullscreenHeader;\n playerCustomActions?: PlayerProps[\"customActions\"];\n playerCustomActionPauseOnActive?: boolean;\n bufferingText?: SlideBufferingTextConfig;\n interactionTitle?: string;\n interactionTexts?: SlideInteractionTexts;\n playerTexts?: SlidePlayerTexts;\n playerAutoHideDelay?: number;\n markerAutoAdvanceDelay?: number;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n onSend?: (content: OnSendContentParams, element?: Element) => void;\n onPlayerVisibilityChange?: (visible: boolean) => void;\n onMobileViewModeChange?: (viewMode: MobileViewMode) => void;\n onStepChange?: (element: Element | undefined, index: number) => void;\n /**\n * Enables keyboard shortcuts for existing player actions.\n *\n * Defaults to `true`. The active slide responds after users click, touch, or\n * focus the slide/player surface; ignored targets include form controls and\n * interaction overlays.\n *\n * @example\n * ```tsx\n * <Slide elementList={slides} enableKeyboardShortcuts={false} />\n * ```\n */\n enableKeyboardShortcuts?: boolean;\n enableIframeScaling?: boolean;\n /**\n * Fits Markdown-only slides to the available presentation viewport.\n *\n * Defaults to `true`. Disable this to preserve the fixed 16px article\n * typography used by standalone ContentRender.\n */\n enableMarkdownScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n locale,\n playerEnabled,\n playerControlsVisibility,\n playerClassName,\n fullscreenHeader,\n playerCustomActions,\n playerCustomActionPauseOnActive = true,\n bufferingText,\n interactionTitle,\n interactionTexts,\n playerTexts,\n playerAutoHideDelay = 3000,\n markerAutoAdvanceDelay = DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS,\n interactionDefaultValueOptions,\n onSend,\n onPlayerVisibilityChange,\n onMobileViewModeChange,\n onStepChange,\n enableKeyboardShortcuts = true,\n enableIframeScaling = true,\n enableMarkdownScaling = true,\n disableLoadingOverlay = false,\n className,\n onPointerDown,\n onFocusCapture,\n ...props\n}) => {\n const localeTexts = useMemo(() => getSlideLocaleTexts(locale), [locale]);\n const resolvedBufferingText = useMemo(\n () =>\n mergeBufferingTextWithLocaleDefaults(\n bufferingText,\n localeTexts.bufferingText\n ),\n [bufferingText, localeTexts.bufferingText]\n );\n const {\n playerEnabled: resolvedPlayerEnabled,\n playerControlsVisibility: resolvedPlayerControlsVisibility,\n } = resolveSlidePlayerVisibility({\n playerEnabled,\n playerControlsVisibility,\n });\n const keyboardShortcutOwnerId = useId();\n const sectionRef = useRef<HTMLElement | null>(null);\n const viewportRef = useRef<HTMLDivElement | null>(null);\n const stageLayerRef = useRef<HTMLDivElement | null>(null);\n const lastElementRef = useRef<HTMLDivElement | null>(null);\n const playerHideTimerRef = useRef<number | null>(null);\n const isPointerInsidePlayerControlsRef = useRef(false);\n const autoAdvanceTimerRef = useRef<number | null>(null);\n const imageOnlyStepReadyTimeoutRef = useRef<number | null>(null);\n const interactionAutoCloseTimerRef = useRef<number | null>(null);\n const interactionOverlayOpenTimerRef = useRef<number | null>(null);\n const interactionOverlayRef = useRef<HTMLDivElement | null>(null);\n const interactionOverlayLayoutRectRef =\n useRef<InteractionOverlayLayoutRect | null>(null);\n const interactionOverlayDragRef = useRef<{\n pointerId: number;\n startClientX: number;\n startClientY: number;\n startOffset: InteractionOverlayDragOffset;\n bounds: InteractionOverlayDragBounds;\n } | null>(null);\n const prevRenderElementKeysRef = useRef<string[]>([]);\n const shouldScrollToBottomRef = useRef(false);\n const pendingInteractionOverlayStepIndexRef = useRef<number | null>(null);\n const pendingSubtitleJumpRef = useRef<{\n audioIndex: number;\n audioKey: string;\n slideIndex: number;\n timeMs: number;\n } | null>(null);\n const subtitleSeekRequestIdRef = useRef(0);\n const playbackResetKeyRef = useRef<string | null>(null);\n const appendedMarkerAdvanceStateRef = useRef({\n markerCount: 0,\n currentIndex: -1,\n canGoNext: false,\n });\n const shouldSkipDefaultAudioStartForSubtitleJumpRef = useRef(false);\n const {\n currentElementList,\n stepElementLists,\n slideElementList,\n currentIndex,\n audioList,\n audioSlideIndexes,\n currentAudioSequenceIndexes,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n canGoPrev,\n canGoNext,\n handlePrev: goPrev,\n handleNext: goNext,\n handleGoTo: goTo,\n } = useSlide(elementList);\n const currentStepElement = useMemo(() => {\n if (currentIndex < 0) {\n return undefined;\n }\n\n return slideElementList[currentIndex];\n }, [currentIndex, slideElementList]);\n const currentRenderElementKeys = useMemo(\n () =>\n currentElementList.map(\n (element, index) =>\n `${element.sequence_number ?? `${element.type}-${index}`}:${String(element.is_new ?? \"\")}`\n ),\n [currentElementList]\n );\n const visibleMarkerCount = slideElementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const isSingleSlide = visibleMarkerCount === 1;\n const shouldMountPlayer =\n resolvedPlayerEnabled &&\n (slideElementList.length > 0 ||\n audioList.length > 0 ||\n Boolean(currentInteractionElement));\n const keyboardShortcutContextValue = useMemo(\n () => ({\n enabled: enableKeyboardShortcuts,\n ownerId: keyboardShortcutOwnerId,\n }),\n [enableKeyboardShortcuts, keyboardShortcutOwnerId]\n );\n const activateKeyboardShortcutOwner = useCallback(() => {\n if (!enableKeyboardShortcuts || !shouldMountPlayer) {\n return;\n }\n\n activatePlayerKeyboardShortcutOwner(keyboardShortcutOwnerId);\n }, [enableKeyboardShortcuts, keyboardShortcutOwnerId, shouldMountPlayer]);\n const currentAudioSequenceKeys = useMemo(\n () =>\n currentAudioSequenceIndexes\n .map((audioIndex) => audioList[audioIndex]?.audioKey)\n .filter((audioKey): audioKey is string => Boolean(audioKey)),\n [audioList, currentAudioSequenceIndexes]\n );\n const [isPlayerVisible, setIsPlayerVisible] = useState(true);\n const [hasPlayerInteracted, setHasPlayerInteracted] = useState(false);\n const [isPlaybackRequested, setIsPlaybackRequested] = useState(true);\n const [isAutoAdvanceEnabled, setIsAutoAdvanceEnabled] = useState(true);\n const [currentAudioKey, setCurrentAudioKey] = useState<string | null>(null);\n const [subtitleSeekRequest, setSubtitleSeekRequest] =\n useState<SlidePlayerSubtitleSeekRequest | null>(null);\n const [isAudioLoadingVisible, setIsAudioLoadingVisible] = useState(false);\n const [audioLoadingReason, setAudioLoadingReason] =\n useState<SlideBufferingReason>(DEFAULT_BUFFERING_REASON);\n const [hasCompletedCurrentStepAudio, setHasCompletedCurrentStepAudio] =\n useState(false);\n const [hasCurrentAudioPlaybackStarted, setHasCurrentAudioPlaybackStarted] =\n useState(false);\n const [isSubtitleEnabled, setIsSubtitleEnabled] = useState(true);\n const [isPlayerCustomActionActive, setIsPlayerCustomActionActive] =\n useState(false);\n const [activeInteractionElement, setActiveInteractionElement] = useState<\n Element | undefined\n >();\n const [isInteractionOverlayOpen, setIsInteractionOverlayOpen] =\n useState(false);\n const [hasInteractionOverlayActivity, setHasInteractionOverlayActivity] =\n useState(false);\n const [interactionOverlayDragOffset, setInteractionOverlayDragOffset] =\n useState<InteractionOverlayDragOffset>(\n DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET\n );\n const [isInteractionOverlayDragging, setIsInteractionOverlayDragging] =\n useState(false);\n const [\n interactionOverlaySubtitleOffset,\n setInteractionOverlaySubtitleOffset,\n ] = useState(0);\n const [isBrowserFullscreen, setIsBrowserFullscreen] = useState(false);\n const isMobileDevice = useMemo(() => getIsMobileDevice(), []);\n const [mobileViewMode, setMobileViewMode] = useState<MobileViewMode>(\n DEFAULT_MOBILE_VIEW_MODE\n );\n const [hasManualMobileViewMode, setHasManualMobileViewMode] = useState(false);\n const [isViewportFullscreenPreferred, setIsViewportFullscreenPreferred] =\n useState(() =>\n isMobileDevice ? getIsFullscreenPreferredViewport() : false\n );\n const playbackTimeStore = useMemo(() => createPlaybackTimeStore(), []);\n const {\n effectiveMobileViewMode,\n isImmersiveMobileFullscreen,\n isNativeMobileFullscreen,\n shouldRotateFullscreenViewport,\n } = useMemo(\n () =>\n resolveMobileViewModeState({\n hasManualMobileViewMode,\n isMobileDevice,\n isViewportFullscreenPreferred,\n mobileViewMode,\n }),\n [\n hasManualMobileViewMode,\n isMobileDevice,\n isViewportFullscreenPreferred,\n mobileViewMode,\n ]\n );\n const previousEffectiveMobileViewModeRef = useRef(effectiveMobileViewMode);\n const playerControlsVisible =\n shouldMountPlayer &&\n resolvedPlayerControlsVisibility !== \"hidden\" &&\n (resolvedPlayerControlsVisibility === \"visible\" || isPlayerVisible);\n const shouldShowFullscreenHeader =\n isImmersiveMobileFullscreen && playerControlsVisible;\n const shouldApplyFullscreenViewportPadding =\n isImmersiveMobileFullscreen && playerControlsVisible;\n const shouldShowMobileFullscreenMask =\n isImmersiveMobileFullscreen || isNativeMobileFullscreen;\n const isDesktopBrowserFullscreen = isBrowserFullscreen && !isMobileDevice;\n const handleMobileViewModeSelect = useCallback(\n (nextViewMode: MobileViewMode) => {\n setHasManualMobileViewMode(true);\n setMobileViewMode(nextViewMode);\n },\n []\n );\n const handleMobileViewModeReset = useCallback(() => {\n // Clear manual override so the effective mode returns to the default non-fullscreen state.\n setHasManualMobileViewMode(false);\n setMobileViewMode(DEFAULT_MOBILE_VIEW_MODE);\n }, []);\n const handleFullscreenHeaderBack = useCallback(() => {\n handleMobileViewModeReset();\n fullscreenHeader?.onBack?.();\n }, [fullscreenHeader, handleMobileViewModeReset]);\n const setPlayerCustomActionActive = useCallback((active: boolean) => {\n setIsPlayerCustomActionActive(active);\n }, []);\n const togglePlayerCustomActionActive = useCallback(() => {\n setIsPlayerCustomActionActive((previous) => !previous);\n }, []);\n const { mountedStepStates, currentMountedStateIndex } = useMemo(() => {\n const nextMountedStepStates: Array<{\n elementList: Element[];\n sourceStepIndexes: number[];\n }> = [];\n const mountedStateIndexByStep = new Map<number, number>();\n\n stepElementLists.forEach((stepElementList, stepIndex) => {\n const existingMountedStateIndex = nextMountedStepStates.findIndex(\n (mountedStepState) =>\n areStepElementListsEqual(\n mountedStepState.elementList,\n stepElementList\n )\n );\n\n if (existingMountedStateIndex >= 0) {\n nextMountedStepStates[\n existingMountedStateIndex\n ]?.sourceStepIndexes.push(stepIndex);\n mountedStateIndexByStep.set(stepIndex, existingMountedStateIndex);\n return;\n }\n\n nextMountedStepStates.push({\n elementList: stepElementList,\n sourceStepIndexes: [stepIndex],\n });\n mountedStateIndexByStep.set(stepIndex, nextMountedStepStates.length - 1);\n });\n\n return {\n mountedStepStates: nextMountedStepStates,\n currentMountedStateIndex:\n currentIndex >= 0\n ? (mountedStateIndexByStep.get(currentIndex) ?? -1)\n : -1,\n };\n }, [currentIndex, stepElementLists]);\n const currentStepKey = useMemo(() => String(currentIndex), [currentIndex]);\n const currentAudioIndex = useMemo(() => {\n if (!currentAudioKey) {\n return -1;\n }\n\n return audioList.findIndex(\n (audioItem) => (audioItem.audioKey ?? \"\") === currentAudioKey\n );\n }, [audioList, currentAudioKey]);\n const currentAudioItem = useMemo(\n () => (currentAudioIndex >= 0 ? audioList[currentAudioIndex] : undefined),\n [audioList, currentAudioIndex]\n );\n const currentSubtitleCues = currentAudioItem?.element?.subtitle_cues ?? [];\n const currentAudioSequenceStartKey = useMemo(\n () => currentAudioSequenceKeys[0] ?? \"none\",\n [currentAudioSequenceKeys]\n );\n const playerCustomActionContext = useMemo(\n () => ({\n currentElement: resolvePlayerCustomActionElement({\n currentAudioIndex,\n currentAudioSequenceIndexes,\n audioList,\n currentInteractionElement: activeInteractionElement,\n currentStepElement,\n }),\n currentIndex,\n currentStepElement,\n isActive: isPlayerCustomActionActive,\n setActive: setPlayerCustomActionActive,\n toggleActive: togglePlayerCustomActionActive,\n }),\n [\n activeInteractionElement,\n audioList,\n currentAudioIndex,\n currentAudioSequenceIndexes,\n currentIndex,\n currentStepElement,\n isPlayerCustomActionActive,\n setPlayerCustomActionActive,\n togglePlayerCustomActionActive,\n ]\n );\n const playerCustomActionCount = useMemo(\n () =>\n getPlayerCustomActionCount(\n playerCustomActions,\n playerCustomActionContext\n ),\n [playerCustomActionContext, playerCustomActions]\n );\n const interactionOverlayStyle = useMemo(\n () =>\n ({\n \"--slide-player-custom-action-count\": String(playerCustomActionCount),\n \"--slide-player-mobile-control-count\": String(\n playerCustomActionCount + 4\n ),\n \"--slide-interaction-drag-x\": `${interactionOverlayDragOffset.x}px`,\n \"--slide-interaction-drag-y\": `${interactionOverlayDragOffset.y}px`,\n }) as React.CSSProperties,\n [\n interactionOverlayDragOffset.x,\n interactionOverlayDragOffset.y,\n playerCustomActionCount,\n ]\n );\n const hasAvailableStepAudio = currentAudioSequenceKeys.length > 0;\n const currentInteractionResetKey = useMemo(() => {\n if (!currentInteractionElement) {\n return \"none\";\n }\n\n return `${currentInteractionElement.sequence_number ?? \"none\"}:${String(\n currentInteractionElement.content ?? \"\"\n )}`;\n }, [currentInteractionElement]);\n const currentPlaybackResetKey = useMemo(\n () => [currentStepKey, currentInteractionResetKey].join(\"|\"),\n [currentInteractionResetKey, currentStepKey]\n );\n const currentPlaybackStartedResetKey = useMemo(\n () =>\n [\n currentPlaybackResetKey,\n currentAudioItem?.audioKey ?? \"none\",\n String(currentAudioIndex),\n ].join(\"|\"),\n [currentAudioIndex, currentAudioItem?.audioKey, currentPlaybackResetKey]\n );\n const currentStepAudioUrl = useMemo(() => {\n if (\n !currentAudioSequenceStartKey ||\n currentAudioSequenceStartKey === \"none\"\n ) {\n return \"\";\n }\n\n const currentStepAudioItem = audioList.find(\n (audioItem) => audioItem.audioKey === currentAudioSequenceStartKey\n );\n\n return currentStepAudioItem?.audioUrl?.trim() ?? \"\";\n }, [audioList, currentAudioSequenceStartKey]);\n const hasCurrentStepAudioUrl = Boolean(currentStepAudioUrl);\n const shouldPausePlaybackForCustomAction =\n playerCustomActionPauseOnActive &&\n Boolean(playerCustomActions) &&\n isPlayerCustomActionActive;\n const shouldUseSilentStepAutoAdvanceToggle = useMemo(\n () =>\n shouldUseAutoAdvanceToggle({\n canGoNext,\n currentAudioIndex,\n currentStepHasSpeakableElement,\n hasInteraction: Boolean(currentInteractionElement),\n }),\n [\n canGoNext,\n currentAudioIndex,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n ]\n );\n const silentStepAutoAdvanceBehavior = useMemo(\n () =>\n resolveSilentStepAutoAdvanceBehavior({\n currentElementList,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n markerAutoAdvanceDelay,\n }),\n [\n currentElementList,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n markerAutoAdvanceDelay,\n ]\n );\n const silentStepAutoAdvanceDelay = silentStepAutoAdvanceBehavior.delayMs;\n const isImageOnlySilentStep =\n silentStepAutoAdvanceBehavior.usesImageOnlyDelay;\n const imageOnlyStepVisualReadyKey = useMemo(\n () => `${currentIndex}:${currentRenderElementKeys.join(\"|\")}`,\n [currentIndex, currentRenderElementKeys]\n );\n const [readyImageOnlyStepKey, setReadyImageOnlyStepKey] = useState<\n string | null\n >(null);\n const isImageOnlyStepVisualReady =\n !isImageOnlySilentStep ||\n readyImageOnlyStepKey === imageOnlyStepVisualReadyKey;\n\n const clearPlayerHideTimer = useCallback(() => {\n if (playerHideTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(playerHideTimerRef.current);\n playerHideTimerRef.current = null;\n }, []);\n\n const clearInteractionAutoCloseTimer = useCallback(() => {\n if (interactionAutoCloseTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(interactionAutoCloseTimerRef.current);\n interactionAutoCloseTimerRef.current = null;\n }, []);\n\n const clearInteractionOverlayOpenTimer = useCallback(() => {\n if (interactionOverlayOpenTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(interactionOverlayOpenTimerRef.current);\n interactionOverlayOpenTimerRef.current = null;\n }, []);\n\n const clearAutoAdvanceTimer = useCallback(() => {\n if (autoAdvanceTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(autoAdvanceTimerRef.current);\n autoAdvanceTimerRef.current = null;\n }, []);\n\n const clearImageOnlyStepReadyTimeout = useCallback(() => {\n if (imageOnlyStepReadyTimeoutRef.current === null) {\n return;\n }\n\n window.clearTimeout(imageOnlyStepReadyTimeoutRef.current);\n imageOnlyStepReadyTimeoutRef.current = null;\n }, []);\n\n const resetAudioSequence = useCallback(\n (\n options: {\n preservePendingSubtitleJump?: boolean;\n } = {}\n ) => {\n clearAutoAdvanceTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n clearImageOnlyStepReadyTimeout();\n setCurrentAudioKey(null);\n playbackTimeStore.reset();\n setIsAudioLoadingVisible(false);\n setAudioLoadingReason(DEFAULT_BUFFERING_REASON);\n setHasCompletedCurrentStepAudio(false);\n setHasCurrentAudioPlaybackStarted(false);\n setSubtitleSeekRequest(null);\n if (!options.preservePendingSubtitleJump) {\n pendingSubtitleJumpRef.current = null;\n }\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n },\n [\n clearAutoAdvanceTimer,\n clearImageOnlyStepReadyTimeout,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n playbackTimeStore,\n ]\n );\n\n const requestSubtitleCueSeek = useCallback(\n (target: SlidePlayerSubtitleJumpTarget) => {\n subtitleSeekRequestIdRef.current += 1;\n setSubtitleSeekRequest({\n ...target,\n id: subtitleSeekRequestIdRef.current,\n });\n },\n []\n );\n\n const startCurrentAudioSequence = useCallback(() => {\n const nextAudioKey = currentAudioSequenceKeys[0];\n\n if (!nextAudioKey) {\n return false;\n }\n\n // Start the first audio segment for the current step immediately.\n setCurrentAudioKey(nextAudioKey);\n return true;\n }, [currentAudioSequenceKeys]);\n\n const continueAfterInteraction = useCallback(() => {\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (canGoNext) {\n goNext();\n }\n }, [\n canGoNext,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n goNext,\n startCurrentAudioSequence,\n ]);\n\n const scheduleInteractionOverlayOpen = useCallback(\n (interactionElement?: Element) => {\n clearInteractionOverlayOpenTimer();\n\n if (!interactionElement) {\n return;\n }\n\n const openOverlay = () => {\n interactionOverlayOpenTimerRef.current = null;\n setInteractionOverlaySubtitleOffset(\n DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX\n );\n setIsInteractionOverlayOpen(true);\n pendingInteractionOverlayStepIndexRef.current = null;\n };\n\n interactionOverlayOpenTimerRef.current = window.setTimeout(\n openOverlay,\n DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS\n );\n },\n [clearInteractionOverlayOpenTimer]\n );\n\n const isPlayerControlsHovered = useCallback(\n () =>\n isPointerInsidePlayerControlsRef.current ||\n Boolean(\n sectionRef.current?.querySelector(\".slide-player__controls:hover\")\n ),\n []\n );\n\n const revealPlayerControls = useCallback(\n (enableAutoHide = hasPlayerInteracted) => {\n if (!shouldMountPlayer || resolvedPlayerControlsVisibility === \"hidden\") {\n return;\n }\n\n setIsPlayerVisible(true);\n clearPlayerHideTimer();\n\n if (\n resolvedPlayerControlsVisibility === \"visible\" ||\n !enableAutoHide ||\n playerAutoHideDelay <= 0 ||\n isPlayerControlsHovered()\n ) {\n return;\n }\n\n playerHideTimerRef.current = window.setTimeout(() => {\n if (isPlayerControlsHovered()) {\n playerHideTimerRef.current = null;\n return;\n }\n\n setIsPlayerVisible(false);\n playerHideTimerRef.current = null;\n }, playerAutoHideDelay);\n },\n [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n isPlayerControlsHovered,\n playerAutoHideDelay,\n resolvedPlayerControlsVisibility,\n shouldMountPlayer,\n ]\n );\n\n const hasResolvedCurrentInteraction = Boolean(\n hasResolvedInteractionElement(currentInteractionElement)\n );\n\n const shouldBlockPlaybackForInteraction =\n Boolean(currentInteractionElement) && !hasResolvedCurrentInteraction;\n\n const handlePlaybackPreferenceChange = useCallback((playing: boolean) => {\n setIsPlaybackRequested(playing);\n }, []);\n\n const syncPlaybackPreferenceBeforeNavigation = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n if (context) {\n setIsPlaybackRequested(context.shouldContinuePlayback);\n }\n },\n []\n );\n\n useEffect(() => {\n // Keep silent-step autoplay aligned with the same play/pause preference as audio.\n setIsAutoAdvanceEnabled(isPlaybackRequested);\n }, [currentIndex, isPlaybackRequested, playerCustomActionPauseOnActive]);\n\n useEffect(() => {\n if (playerCustomActionPauseOnActive) {\n setIsPlayerCustomActionActive(false);\n }\n }, [currentIndex, playerCustomActionPauseOnActive]);\n\n useEffect(() => {\n return () => {\n clearAutoAdvanceTimer();\n clearImageOnlyStepReadyTimeout();\n clearPlayerHideTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n };\n }, [\n clearAutoAdvanceTimer,\n clearImageOnlyStepReadyTimeout,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n clearPlayerHideTimer,\n ]);\n\n useEffect(() => {\n if (!isImageOnlySilentStep) {\n clearImageOnlyStepReadyTimeout();\n return;\n }\n\n let cancelled = false;\n let rafId: number | null = null;\n let cleanupListeners: (() => void) | null = null;\n\n const detachListeners = () => {\n cleanupListeners?.();\n cleanupListeners = null;\n };\n\n const finishVisualReady = () => {\n if (cancelled) {\n return;\n }\n\n detachListeners();\n clearImageOnlyStepReadyTimeout();\n setReadyImageOnlyStepKey(imageOnlyStepVisualReadyKey);\n };\n\n const evaluateVisualReady = () => {\n if (cancelled) {\n return;\n }\n\n detachListeners();\n\n const activeStepContainer = stageLayerRef.current?.querySelector(\n '[data-active-step=\"true\"]'\n ) as HTMLElement | null;\n\n if (!activeStepContainer) {\n return;\n }\n\n const iframeElements = Array.from(\n activeStepContainer.querySelectorAll(\"iframe\")\n ) as HTMLIFrameElement[];\n\n if (\n iframeElements.length === 0 ||\n areImageOnlyStepIframeVisualsReady(iframeElements)\n ) {\n finishVisualReady();\n return;\n }\n\n const cleanupCallbacks: Array<() => void> = [];\n const queueRecheck = () => {\n if (cancelled) {\n return;\n }\n\n if (rafId !== null) {\n window.cancelAnimationFrame(rafId);\n }\n\n rafId = window.requestAnimationFrame(() => {\n rafId = null;\n evaluateVisualReady();\n });\n };\n const registerEvent = (\n target: EventTarget,\n eventName: string,\n listener: EventListener\n ) => {\n target.addEventListener(eventName, listener, { once: true });\n cleanupCallbacks.push(() =>\n target.removeEventListener(eventName, listener)\n );\n };\n\n iframeElements.forEach((iframeElement) => {\n const iframeDocument = iframeElement.contentDocument;\n\n if (!iframeDocument || iframeDocument.readyState !== \"complete\") {\n registerEvent(iframeElement, \"load\", queueRecheck);\n return;\n }\n\n Array.from(iframeDocument.images)\n .filter((image) => !image.complete)\n .forEach((image) => {\n registerEvent(image, \"load\", queueRecheck);\n registerEvent(image, \"error\", queueRecheck);\n });\n });\n\n cleanupListeners = () => {\n cleanupCallbacks.forEach((cleanup) => cleanup());\n };\n };\n\n rafId = window.requestAnimationFrame(() => {\n rafId = null;\n evaluateVisualReady();\n });\n\n imageOnlyStepReadyTimeoutRef.current = window.setTimeout(() => {\n finishVisualReady();\n }, DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS);\n\n return () => {\n cancelled = true;\n detachListeners();\n clearImageOnlyStepReadyTimeout();\n if (rafId !== null) {\n window.cancelAnimationFrame(rafId);\n }\n };\n }, [\n clearImageOnlyStepReadyTimeout,\n currentElementList,\n currentIndex,\n imageOnlyStepVisualReadyKey,\n isImageOnlySilentStep,\n ]);\n\n useEffect(() => {\n onPlayerVisibilityChange?.(playerControlsVisible);\n\n return () => {\n onPlayerVisibilityChange?.(false);\n };\n }, [onPlayerVisibilityChange, playerControlsVisible]);\n\n useEffect(() => {\n if (playerControlsVisible) {\n return;\n }\n\n isPointerInsidePlayerControlsRef.current = false;\n }, [playerControlsVisible]);\n\n useEffect(() => {\n if (isMobileDevice || mobileViewMode === DEFAULT_MOBILE_VIEW_MODE) {\n return;\n }\n\n setHasManualMobileViewMode(false);\n setMobileViewMode(DEFAULT_MOBILE_VIEW_MODE);\n }, [isMobileDevice, mobileViewMode]);\n\n useEffect(() => {\n if (!isMobileDevice) {\n setIsViewportFullscreenPreferred(false);\n return;\n }\n\n const syncViewportFullscreenPreference = () => {\n setIsViewportFullscreenPreferred(getIsFullscreenPreferredViewport());\n };\n\n syncViewportFullscreenPreference();\n\n return subscribeMobileDeviceChange(syncViewportFullscreenPreference);\n }, [isMobileDevice]);\n\n useEffect(() => {\n onMobileViewModeChange?.(effectiveMobileViewMode);\n }, [effectiveMobileViewMode, onMobileViewModeChange]);\n\n useEffect(() => {\n previousEffectiveMobileViewModeRef.current = effectiveMobileViewMode;\n }, [effectiveMobileViewMode]);\n\n useEffect(() => {\n onStepChange?.(currentStepElement, currentIndex);\n }, [currentIndex, currentStepElement, onStepChange]);\n\n useEffect(() => {\n const previousState = appendedMarkerAdvanceStateRef.current;\n const shouldAdvanceIntoAppendedMarker = shouldAutoAdvanceIntoAppendedMarker(\n {\n previousMarkerCount: previousState.markerCount,\n nextMarkerCount: slideElementList.length,\n previousIndex: previousState.currentIndex,\n previousCanGoNext: previousState.canGoNext,\n nextCanGoNext: canGoNext,\n currentAudioKey,\n hasCompletedCurrentStepAudio,\n hasResolvedCurrentInteraction,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n isAutoAdvanceEnabled,\n shouldUseSilentStepAutoAdvanceToggle,\n }\n );\n\n appendedMarkerAdvanceStateRef.current = {\n markerCount: slideElementList.length,\n currentIndex,\n canGoNext,\n };\n\n if (!shouldAdvanceIntoAppendedMarker) {\n return;\n }\n\n goNext();\n }, [\n canGoNext,\n currentAudioKey,\n currentIndex,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n goNext,\n hasCompletedCurrentStepAudio,\n hasResolvedCurrentInteraction,\n isAutoAdvanceEnabled,\n shouldUseSilentStepAutoAdvanceToggle,\n slideElementList.length,\n ]);\n\n useEffect(() => {\n if (!shouldMountPlayer || resolvedPlayerControlsVisibility === \"hidden\") {\n clearPlayerHideTimer();\n setIsPlayerVisible(false);\n return;\n }\n\n if (resolvedPlayerControlsVisibility === \"visible\") {\n clearPlayerHideTimer();\n setIsPlayerVisible(true);\n return;\n }\n\n if (!hasPlayerInteracted) {\n // Keep the initial player visible briefly, then hide it automatically.\n revealPlayerControls(true);\n }\n }, [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n resolvedPlayerControlsVisibility,\n shouldMountPlayer,\n revealPlayerControls,\n ]);\n\n useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const handleSandboxInteraction = (event: MessageEvent) => {\n if (event.origin !== window.location.origin) {\n return;\n }\n\n if (!isSandboxInteractionMessage(event.data)) {\n return;\n }\n\n if (event.data.eventType !== \"click\") {\n return;\n }\n\n if (!shouldMountPlayer) {\n return;\n }\n\n // Restore player controls on explicit click/tap without waking on scroll start.\n activateKeyboardShortcutOwner();\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n };\n\n window.addEventListener(\"message\", handleSandboxInteraction);\n\n return () => {\n window.removeEventListener(\"message\", handleSandboxInteraction);\n };\n }, [activateKeyboardShortcutOwner, shouldMountPlayer, revealPlayerControls]);\n\n useWakePlayerFromIframe({\n sectionRef,\n enabled: shouldMountPlayer,\n keyboardShortcutsEnabled: enableKeyboardShortcuts,\n onKeyboardShortcut: activateKeyboardShortcutOwner,\n onWake: () => {\n activateKeyboardShortcutOwner();\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n },\n });\n\n useEffect(() => {\n if (!shouldMountPlayer) {\n resetAudioSequence();\n return;\n }\n\n const { hasPlaybackContextChanged, shouldInitializeAudioSequence } =\n getPlaybackSequenceTransition({\n previousResetKey: playbackResetKeyRef.current,\n nextResetKey: currentPlaybackResetKey,\n currentAudioKey,\n hasCompletedCurrentStepAudio,\n });\n\n playbackResetKeyRef.current = currentPlaybackResetKey;\n\n const shouldOpenInteractionOverlayAfterAudio =\n pendingInteractionOverlayStepIndexRef.current === currentIndex &&\n Boolean(currentInteractionElement);\n const shouldPresentOverlay = shouldPresentInteractionOverlay({\n hasInteraction: Boolean(currentInteractionElement),\n shouldBlockPlaybackForInteraction,\n shouldOpenInteractionOverlayAfterAudio,\n hasPlaybackContextChanged,\n hasResolvedCurrentInteraction,\n currentStepHasSpeakableElement,\n });\n\n const pendingSubtitleJump = pendingSubtitleJumpRef.current;\n const shouldPreservePendingSubtitleJump =\n pendingSubtitleJump?.slideIndex === currentIndex;\n\n if (hasPlaybackContextChanged) {\n resetAudioSequence({\n preservePendingSubtitleJump: shouldPreservePendingSubtitleJump,\n });\n }\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldPausePlaybackForCustomAction) {\n return;\n }\n\n if (pendingSubtitleJump?.slideIndex === currentIndex) {\n if (\n !canReachSubtitleJumpTarget({\n currentIndex,\n resolvedCurrentInteractionElement: activeInteractionElement,\n slideElementList,\n targetSlideIndex: pendingSubtitleJump.slideIndex,\n })\n ) {\n // Keep the pending seek queued while the interaction overlay gates playback.\n } else {\n pendingSubtitleJumpRef.current = null;\n // The default audio-start effect still sees the pre-seek render state.\n // Skip it once so it does not replace the subtitle target audio.\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current = true;\n setCurrentAudioKey(pendingSubtitleJump.audioKey);\n requestSubtitleCueSeek({\n audioIndex: pendingSubtitleJump.audioIndex,\n timeMs: pendingSubtitleJump.timeMs,\n });\n return;\n }\n }\n\n if (currentInteractionElement) {\n setActiveInteractionElement(currentInteractionElement);\n }\n\n if (shouldPresentOverlay) {\n // Delay auto-presenting the overlay so subtitles can settle above it.\n scheduleInteractionOverlayOpen(currentInteractionElement);\n return;\n }\n\n clearInteractionOverlayOpenTimer();\n pendingInteractionOverlayStepIndexRef.current = null;\n\n if (!shouldInitializeAudioSequence) {\n return;\n }\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (currentStepHasSpeakableElement) {\n if (disableLoadingOverlay) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(true);\n return;\n }\n\n if (!canGoNext) {\n return;\n }\n\n if (shouldUseSilentStepAutoAdvanceToggle && !isAutoAdvanceEnabled) {\n return;\n }\n\n if (isImageOnlySilentStep && !isImageOnlyStepVisualReady) {\n return;\n }\n\n // Auto-advance silent marker-only steps so playback flow does not stall.\n autoAdvanceTimerRef.current = window.setTimeout(() => {\n autoAdvanceTimerRef.current = null;\n goNext();\n }, silentStepAutoAdvanceDelay);\n\n return () => {\n clearAutoAdvanceTimer();\n };\n }, [\n activeInteractionElement,\n canGoNext,\n clearAutoAdvanceTimer,\n currentElementList.length,\n currentIndex,\n currentInteractionElement,\n currentAudioKey,\n currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n isImageOnlySilentStep,\n isImageOnlyStepVisualReady,\n silentStepAutoAdvanceDelay,\n goNext,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n isAutoAdvanceEnabled,\n hasResolvedCurrentInteraction,\n shouldBlockPlaybackForInteraction,\n clearInteractionOverlayOpenTimer,\n resetAudioSequence,\n requestSubtitleCueSeek,\n scheduleInteractionOverlayOpen,\n shouldMountPlayer,\n slideElementList,\n startCurrentAudioSequence,\n shouldPausePlaybackForCustomAction,\n shouldUseSilentStepAutoAdvanceToggle,\n ]);\n\n useEffect(() => {\n if (\n disableLoadingOverlay ||\n shouldPausePlaybackForCustomAction ||\n !currentStepHasSpeakableElement ||\n shouldBlockPlaybackForInteraction\n ) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (hasAvailableStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setAudioLoadingReason(\"waitingForAudio\");\n setIsAudioLoadingVisible(true);\n }, [\n hasAvailableStepAudio,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n ]);\n\n useEffect(() => {\n const shouldSkipDefaultAudioStart =\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current;\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current = false;\n\n if (\n !shouldStartDefaultAudioSequence({\n currentAudioKey,\n currentAudioSequenceLength: currentAudioSequenceKeys.length,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldBlockPlaybackForInteraction,\n shouldPausePlaybackForCustomAction,\n shouldSkipDefaultAudioStart,\n })\n ) {\n return;\n }\n\n startCurrentAudioSequence();\n }, [\n currentAudioKey,\n currentAudioSequenceKeys,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n startCurrentAudioSequence,\n ]);\n\n useEffect(() => {\n if (!currentAudioKey || currentAudioIndex >= 0) {\n return;\n }\n\n setCurrentAudioKey(null);\n }, [currentAudioIndex, currentAudioKey]);\n\n useEffect(() => {\n if (currentAudioIndex >= 0) {\n return;\n }\n\n playbackTimeStore.reset();\n }, [currentAudioIndex, playbackTimeStore]);\n\n useEffect(() => {\n setHasCurrentAudioPlaybackStarted(false);\n }, [currentPlaybackStartedResetKey]);\n\n const {\n interactionDefaults,\n interactionDefaultSelectedValues,\n hasResolvedInteractionInput,\n isInteractionReadonly: resolvedInteractionReadonly,\n shouldAutoContinueInteraction,\n } = useMemo(\n () =>\n resolveSlideInteractionState(activeInteractionElement, {\n interactionDefaultValueOptions,\n }),\n [activeInteractionElement, interactionDefaultValueOptions]\n );\n\n const isInteractionReadonly =\n Boolean(activeInteractionElement?.readonly) || resolvedInteractionReadonly;\n const shouldShowInteractionOverlay = shouldRenderInteractionOverlay({\n hasActiveInteraction: Boolean(activeInteractionElement),\n isInteractionOverlayOpen,\n });\n\n const handleInteractionSend = useCallback(\n (content: OnSendContentParams) => {\n const submittedValues = [\n ...(content.selectedValues ?? []),\n content.inputText?.trim() ?? \"\",\n content.buttonText?.trim() ?? \"\",\n ].filter(Boolean);\n const resolvedUserInput = submittedValues.join(\", \");\n\n setActiveInteractionElement((prevElement) => {\n if (!prevElement || !resolvedUserInput) {\n return prevElement;\n }\n\n return {\n ...prevElement,\n user_input: resolvedUserInput,\n };\n });\n\n onSend?.(content, activeInteractionElement);\n continueAfterInteraction();\n },\n [activeInteractionElement, continueAfterInteraction, onSend]\n );\n\n useEffect(() => {\n // Keep the player icon in sync with the actual fullscreen owner.\n const syncFullscreenState = () => {\n setIsBrowserFullscreen(document.fullscreenElement === sectionRef.current);\n };\n\n syncFullscreenState();\n document.addEventListener(\"fullscreenchange\", syncFullscreenState);\n\n return () => {\n document.removeEventListener(\"fullscreenchange\", syncFullscreenState);\n };\n }, []);\n\n useEffect(() => {\n if (activeInteractionElement && isInteractionOverlayOpen) {\n return;\n }\n\n setHasInteractionOverlayActivity(false);\n }, [activeInteractionElement, isInteractionOverlayOpen]);\n\n useEffect(() => {\n setInteractionOverlayDragOffset(DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET);\n setIsInteractionOverlayDragging(false);\n interactionOverlayDragRef.current = null;\n interactionOverlayLayoutRectRef.current = null;\n }, [activeInteractionElement]);\n\n useEffect(() => {\n if (!shouldShowInteractionOverlay) {\n setInteractionOverlaySubtitleOffset(0);\n return;\n }\n\n const interactionOverlayElement = interactionOverlayRef.current;\n\n if (!interactionOverlayElement) {\n return;\n }\n\n const updateSubtitleOffset = () => {\n const overlayHeight = Math.ceil(\n interactionOverlayElement.getBoundingClientRect().height\n );\n\n setInteractionOverlaySubtitleOffset(\n overlayHeight + DEFAULT_INTERACTION_SUBTITLE_GAP_PX\n );\n };\n\n updateSubtitleOffset();\n\n if (typeof ResizeObserver === \"undefined\") {\n return;\n }\n\n const resizeObserver = new ResizeObserver(() => {\n updateSubtitleOffset();\n });\n\n resizeObserver.observe(interactionOverlayElement);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [shouldShowInteractionOverlay]);\n\n useEffect(() => {\n clearInteractionAutoCloseTimer();\n\n if (!isInteractionOverlayOpen) {\n return;\n }\n\n if (shouldAutoContinueInteraction) {\n // Auto-close passive interaction markers to keep playback moving.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS);\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }\n\n if (hasInteractionOverlayActivity || !hasResolvedInteractionInput) {\n return;\n }\n\n // Give resolved history interactions a short revisit window before\n // playback resumes, but stop auto-closing once the learner starts editing.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS);\n\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }, [\n clearInteractionAutoCloseTimer,\n continueAfterInteraction,\n hasInteractionOverlayActivity,\n hasResolvedInteractionInput,\n isInteractionOverlayOpen,\n shouldAutoContinueInteraction,\n ]);\n\n const renderSlideElement = (\n element?: Element,\n options: RenderSlideElementOptions = {}\n ) => {\n if (!element) {\n return null;\n }\n\n if (element.type === \"slot\") {\n return <>{element.content}</>;\n }\n\n if (element.type === \"html\") {\n return (\n <IframeSandbox\n className=\"content-render-iframe\"\n disableLoadingOverlay={disableLoadingOverlay}\n hideFullScreen\n locale={locale}\n mode=\"blackboard\"\n replaceRootScreenHeightWithFull={\n options.replaceRootScreenHeightWithFull\n }\n type=\"sandbox\"\n content={element.content as string}\n enableScaling={enableIframeScaling}\n />\n );\n }\n\n return (\n <IframeSandbox\n className=\"content-render-iframe\"\n disableLoadingOverlay={disableLoadingOverlay}\n hideFullScreen\n locale={locale}\n mode=\"blackboard\"\n type=\"markdown\"\n content={element.content as string}\n />\n );\n };\n\n const renderSlideElementList = (\n elementList: Element[] = [],\n isActiveStep = false\n ) => {\n if (elementList.length === 0) {\n return null;\n }\n\n const visibleElementCount = elementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const markdownScalingMode =\n isActiveStep && enableMarkdownScaling\n ? resolveMarkdownScalingMode(elementList)\n : \"disabled\";\n const lastVisibleElementIndex = elementList.reduce(\n (lastVisibleIndex, element, index) =>\n element.is_renderable !== false ? index : lastVisibleIndex,\n -1\n );\n\n return (\n <MarkdownSlideScaling\n className=\"slide-stage__content flex w-full flex-col gap-4\"\n mode={markdownScalingMode}\n >\n {elementList.map((element, index) => {\n const isPreRenderedHtml =\n element.type === \"html\" && element.is_renderable === false;\n\n return (\n <div\n key={element.sequence_number ?? `${element.type}-${index}`}\n ref={\n isActiveStep && index === lastVisibleElementIndex\n ? lastElementRef\n : null\n }\n aria-hidden={isPreRenderedHtml || undefined}\n className={cn(\n \"w-full shrink-0\",\n visibleElementCount === 1 &&\n element.is_renderable !== false &&\n \"slide-element--single\",\n isPreRenderedHtml\n ? \"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0\"\n : element.is_renderable === false && \"hidden\"\n )}\n >\n {renderSlideElement(element, {\n replaceRootScreenHeightWithFull:\n visibleElementCount === 1 &&\n element.type === \"html\" &&\n element.is_renderable !== false,\n })}\n </div>\n );\n })}\n </MarkdownSlideScaling>\n );\n };\n\n const handleFullscreen = useCallback(() => {\n const target = sectionRef.current;\n if (!target) {\n return;\n }\n\n if (document.fullscreenElement === target) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n\n target.requestFullscreen?.().catch(() => {});\n }, []);\n\n const scrollStageToBottom = useCallback(() => {\n const stageLayerElement = stageLayerRef.current;\n\n if (!stageLayerElement) {\n return;\n }\n\n // Keep the latest content visible after manual player navigation.\n stageLayerElement.scrollTo({\n top: stageLayerElement.scrollHeight,\n behavior: \"smooth\",\n });\n }, []);\n\n const canJumpToSubtitleTarget = useCallback(\n (target: SlidePlayerSubtitleJumpTarget) =>\n canReachSubtitleJumpTarget({\n currentIndex,\n resolvedCurrentInteractionElement: activeInteractionElement,\n slideElementList,\n targetSlideIndex: audioSlideIndexes[target.audioIndex],\n }),\n [\n activeInteractionElement,\n audioSlideIndexes,\n currentIndex,\n slideElementList,\n ]\n );\n\n const handleSubtitleJump = useCallback(\n (\n target: SlidePlayerSubtitleJumpTarget,\n context: SlidePlayerNavigationContext\n ) => {\n const targetAudio = audioList[target.audioIndex];\n const targetAudioKey = targetAudio?.audioKey;\n const targetSlideIndex = audioSlideIndexes[target.audioIndex];\n\n if (!targetAudioKey || targetSlideIndex == null) {\n return false;\n }\n\n if (!canJumpToSubtitleTarget(target)) {\n return false;\n }\n\n syncPlaybackPreferenceBeforeNavigation(context);\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setHasCurrentAudioPlaybackStarted(false);\n\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n\n if (targetSlideIndex === currentIndex) {\n pendingSubtitleJumpRef.current = null;\n resetAudioSequence();\n setCurrentAudioKey(targetAudioKey);\n requestSubtitleCueSeek(target);\n return true;\n }\n\n shouldScrollToBottomRef.current = true;\n resetAudioSequence();\n pendingSubtitleJumpRef.current = {\n audioIndex: target.audioIndex,\n audioKey: targetAudioKey,\n slideIndex: targetSlideIndex,\n timeMs: target.timeMs,\n };\n goTo(targetSlideIndex);\n\n return true;\n },\n [\n audioList,\n audioSlideIndexes,\n canJumpToSubtitleTarget,\n currentIndex,\n goTo,\n requestSubtitleCueSeek,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handlePrev = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n syncPlaybackPreferenceBeforeNavigation(context);\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n resetAudioSequence();\n goPrev();\n },\n [\n goPrev,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handleNext = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n syncPlaybackPreferenceBeforeNavigation(context);\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n resetAudioSequence();\n goNext();\n },\n [\n goNext,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handlePlayerLoadingChange = useCallback(\n ({\n loading,\n reason,\n }: {\n loading: boolean;\n reason: SlidePlayerLoadingReason | null;\n }) => {\n if (disableLoadingOverlay) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (loading && reason) {\n setAudioLoadingReason(reason);\n }\n setIsAudioLoadingVisible(shouldShowBufferingOverlay(reason, loading));\n },\n [\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n ]\n );\n\n useEffect(() => {\n if (!disableLoadingOverlay) {\n return;\n }\n\n setIsAudioLoadingVisible(false);\n }, [disableLoadingOverlay]);\n\n const handlePlayerEnded = useCallback(\n (audioIndex: number) => {\n const endedAudioKey = audioList[audioIndex]?.audioKey;\n\n if (!endedAudioKey || !currentAudioKey) {\n return;\n }\n\n if (endedAudioKey !== currentAudioKey) {\n return;\n }\n\n const activeSequencePosition = currentAudioSequenceKeys.findIndex(\n (audioSequenceKey) => audioSequenceKey === endedAudioKey\n );\n if (activeSequencePosition < 0) {\n setCurrentAudioKey(null);\n return;\n }\n\n const nextSequencePosition = activeSequencePosition + 1;\n const nextAudioKey = currentAudioSequenceKeys[nextSequencePosition];\n\n if (nextAudioKey) {\n setCurrentAudioKey(nextAudioKey);\n return;\n }\n\n setCurrentAudioKey(null);\n setHasCompletedCurrentStepAudio(true);\n setIsAudioLoadingVisible(false);\n\n if (canGoNext) {\n const nextStepIndex = currentIndex + 1;\n const nextStepElement = slideElementList[nextStepIndex];\n\n if (hasCurrentStepAudioUrl && nextStepElement?.type === \"interaction\") {\n pendingInteractionOverlayStepIndexRef.current = nextStepIndex;\n }\n\n goNext();\n return;\n }\n },\n [\n audioList,\n canGoNext,\n currentIndex,\n currentAudioKey,\n currentAudioSequenceKeys,\n goNext,\n hasCurrentStepAudioUrl,\n slideElementList,\n ]\n );\n\n const handleInteractionToggle = useCallback(() => {\n if (!activeInteractionElement) {\n return;\n }\n\n setIsInteractionOverlayOpen((prevOpen) => !prevOpen);\n }, [activeInteractionElement]);\n\n const handlePlayerControlsPointerEnter = useCallback(() => {\n isPointerInsidePlayerControlsRef.current = true;\n clearPlayerHideTimer();\n\n if (shouldMountPlayer) {\n setIsPlayerVisible(true);\n }\n }, [clearPlayerHideTimer, shouldMountPlayer]);\n\n const handlePlayerControlsPointerLeave = useCallback(() => {\n isPointerInsidePlayerControlsRef.current = false;\n revealPlayerControls(true);\n }, [revealPlayerControls]);\n\n const stopOverlayPropagation = useCallback(\n (\n event: React.PointerEvent<HTMLElement> | React.MouseEvent<HTMLElement>\n ) => {\n event.stopPropagation();\n\n // Keep the player visible a bit longer when users interact with the overlay.\n if (playerControlsVisible) {\n revealPlayerControls(true);\n }\n },\n [playerControlsVisible, revealPlayerControls]\n );\n\n const getInteractionOverlayDragBounds = useCallback(\n (\n overlayElement: HTMLElement,\n startOffset: InteractionOverlayDragOffset\n ): InteractionOverlayDragBounds | null => {\n const viewportElement = viewportRef.current;\n\n if (!viewportElement) {\n return null;\n }\n\n const overlayRect = overlayElement.getBoundingClientRect();\n const viewportRect = viewportElement.getBoundingClientRect();\n\n return {\n minX: startOffset.x + viewportRect.left - overlayRect.left,\n maxX: startOffset.x + viewportRect.right - overlayRect.right,\n minY: startOffset.y + viewportRect.top - overlayRect.top,\n maxY: startOffset.y + viewportRect.bottom - overlayRect.bottom,\n };\n },\n []\n );\n\n useIsomorphicLayoutEffect(() => {\n const overlayElement = interactionOverlayRef.current;\n\n if (!shouldShowInteractionOverlay || !overlayElement) {\n interactionOverlayLayoutRectRef.current = null;\n return;\n }\n\n const previousRect = interactionOverlayLayoutRectRef.current;\n const currentRect = overlayElement.getBoundingClientRect();\n\n if (!previousRect || isInteractionOverlayDragging) {\n interactionOverlayLayoutRectRef.current = currentRect;\n return;\n }\n\n const nextOffset = {\n x: interactionOverlayDragOffset.x + previousRect.left - currentRect.left,\n y: interactionOverlayDragOffset.y + previousRect.top - currentRect.top,\n };\n const bounds = getInteractionOverlayDragBounds(\n overlayElement,\n interactionOverlayDragOffset\n );\n const clampedOffset = bounds\n ? clampInteractionOverlayDragOffset(nextOffset, bounds)\n : nextOffset;\n\n interactionOverlayLayoutRectRef.current = {\n left: currentRect.left + clampedOffset.x - interactionOverlayDragOffset.x,\n top: currentRect.top + clampedOffset.y - interactionOverlayDragOffset.y,\n };\n\n if (\n clampedOffset.x !== interactionOverlayDragOffset.x ||\n clampedOffset.y !== interactionOverlayDragOffset.y\n ) {\n setInteractionOverlayDragOffset(clampedOffset);\n }\n }, [\n getInteractionOverlayDragBounds,\n interactionOverlayDragOffset,\n isInteractionOverlayDragging,\n playerControlsVisible,\n shouldMountPlayer,\n shouldShowInteractionOverlay,\n ]);\n\n const handleInteractionOverlayPointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n stopOverlayPropagation(event);\n\n if (\n event.button !== 0 ||\n !event.currentTarget.isConnected ||\n !interactionOverlayRef.current\n ) {\n return;\n }\n\n const bounds = getInteractionOverlayDragBounds(\n interactionOverlayRef.current,\n interactionOverlayDragOffset\n );\n\n if (!bounds) {\n return;\n }\n\n event.preventDefault();\n event.currentTarget.setPointerCapture(event.pointerId);\n interactionOverlayDragRef.current = {\n pointerId: event.pointerId,\n startClientX: event.clientX,\n startClientY: event.clientY,\n startOffset: interactionOverlayDragOffset,\n bounds,\n };\n setIsInteractionOverlayDragging(true);\n },\n [\n getInteractionOverlayDragBounds,\n interactionOverlayDragOffset,\n stopOverlayPropagation,\n ]\n );\n\n const handleInteractionOverlayPointerMove = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n const dragState = interactionOverlayDragRef.current;\n\n if (!dragState || dragState.pointerId !== event.pointerId) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n setInteractionOverlayDragOffset(\n clampInteractionOverlayDragOffset(\n {\n x: dragState.startOffset.x + event.clientX - dragState.startClientX,\n y: dragState.startOffset.y + event.clientY - dragState.startClientY,\n },\n dragState.bounds\n )\n );\n },\n []\n );\n\n const endInteractionOverlayDrag = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n const dragState = interactionOverlayDragRef.current;\n\n if (!dragState || dragState.pointerId !== event.pointerId) {\n return;\n }\n\n event.stopPropagation();\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n interactionOverlayDragRef.current = null;\n setIsInteractionOverlayDragging(false);\n },\n []\n );\n\n const handleSurfacePointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n activateKeyboardShortcutOwner();\n onPointerDown?.(event);\n },\n [activateKeyboardShortcutOwner, onPointerDown]\n );\n\n const handleSurfaceFocusCapture = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n activateKeyboardShortcutOwner();\n onFocusCapture?.(event);\n },\n [activateKeyboardShortcutOwner, onFocusCapture]\n );\n\n const handleSurfaceClick = useCallback(() => {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }, [revealPlayerControls]);\n useEffect(() => {\n const prevKeys = prevRenderElementKeysRef.current;\n const hasStablePrefix =\n prevKeys.length > 0 &&\n prevKeys.length < currentRenderElementKeys.length &&\n prevKeys.every((key, index) => key === currentRenderElementKeys[index]);\n const appendedElements = hasStablePrefix\n ? currentElementList.slice(prevKeys.length)\n : [];\n const shouldAutoScrollToAppend = appendedElements.some(\n (element) => element.is_new === false\n );\n\n prevRenderElementKeysRef.current = currentRenderElementKeys;\n\n if (!shouldAutoScrollToAppend) {\n return;\n }\n\n const animationFrameId = window.requestAnimationFrame(() => {\n const stageLayerElement = stageLayerRef.current;\n const targetElement = lastElementRef.current;\n\n if (!stageLayerElement || !targetElement) {\n return;\n }\n\n const stageLayerRect = stageLayerElement.getBoundingClientRect();\n const targetRect = targetElement.getBoundingClientRect();\n const nextScrollTop =\n stageLayerElement.scrollTop + (targetRect.top - stageLayerRect.top);\n\n // Keep newly appended content visible when the current slide grows downward.\n stageLayerElement.scrollTo({\n top: Math.max(nextScrollTop, 0),\n behavior: \"smooth\",\n });\n });\n\n return () => {\n window.cancelAnimationFrame(animationFrameId);\n };\n }, [currentElementList, currentRenderElementKeys]);\n\n useEffect(() => {\n if (!shouldScrollToBottomRef.current) {\n return;\n }\n\n shouldScrollToBottomRef.current = false;\n\n if (currentElementList.length === 0) {\n return;\n }\n\n const animationFrameId = window.requestAnimationFrame(() => {\n scrollStageToBottom();\n });\n\n return () => {\n window.cancelAnimationFrame(animationFrameId);\n };\n }, [currentElementList, scrollStageToBottom]);\n\n return (\n <section\n ref={sectionRef}\n className={cn(\n \"relative h-full w-full\",\n isMobileDevice && \"slide--mobile-device\",\n isDesktopBrowserFullscreen && \"slide--browser-fullscreen\",\n isImmersiveMobileFullscreen && \"slide--mobile-landscape\",\n isNativeMobileFullscreen && \"slide--mobile-landscape-native\",\n className\n )}\n onClick={handleSurfaceClick}\n onFocusCapture={handleSurfaceFocusCapture}\n onPointerDown={handleSurfacePointerDown}\n {...props}\n >\n {shouldShowMobileFullscreenMask ? (\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]\"\n />\n ) : null}\n\n <div\n ref={viewportRef}\n className={cn(\n \"slide__viewport relative h-full min-h-0 w-full\",\n isImmersiveMobileFullscreen && \"slide__viewport--mobile-landscape\",\n isImmersiveMobileFullscreen &&\n !shouldRotateFullscreenViewport &&\n \"slide__viewport--mobile-landscape-native\"\n )}\n >\n {shouldShowFullscreenHeader ? (\n <div className=\"slide-landscape-header\">\n <button\n aria-label={\n fullscreenHeader?.backAriaLabel ??\n localeTexts.fullscreenBackAriaLabel\n }\n className=\"slide-landscape-header__back\"\n onClick={handleFullscreenHeaderBack}\n type=\"button\"\n >\n <ChevronLeft\n className=\"slide-landscape-header__icon h-6 w-6\"\n strokeWidth={2.25}\n />\n </button>\n\n {fullscreenHeader?.content ? (\n <div className=\"min-w-0 flex-1 overflow-hidden\">\n {fullscreenHeader.content}\n </div>\n ) : null}\n </div>\n ) : null}\n\n <div\n className={cn(\n \"h-full min-h-0 w-full\",\n shouldApplyFullscreenViewportPadding &&\n \"slide__viewport-content--with-header\",\n isSingleSlide ? \"slide-content--single\" : \"grid gap-4\"\n )}\n >\n {currentElementList.length > 0 ? (\n <div className=\"slide-stage\">\n <div ref={stageLayerRef} className=\"slide-stage__layer w-full\">\n {mountedStepStates.map(\n (mountedStepState, mountedStepStateIndex) => {\n const isActiveStep =\n mountedStepStateIndex === currentMountedStateIndex;\n\n return (\n <div\n key={\n mountedStepState.sourceStepIndexes[0] ??\n mountedStepStateIndex\n }\n data-active-step={isActiveStep ? \"true\" : undefined}\n aria-hidden={!isActiveStep || undefined}\n className=\"w-full h-full\"\n style={{ display: isActiveStep ? undefined : \"none\" }}\n >\n {renderSlideElementList(\n mountedStepState.elementList,\n isActiveStep\n )}\n </div>\n );\n }\n )}\n </div>\n </div>\n ) : null}\n </div>\n\n {isAudioLoadingVisible ? (\n <LoadingOverlayCard\n message={resolveBufferingTextByReason(\n resolvedBufferingText,\n audioLoadingReason\n )}\n className=\"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2\"\n />\n ) : null}\n\n <SubtitleOverlay\n extraBottomOffset={interactionOverlaySubtitleOffset}\n hasPlayerGap={playerControlsVisible}\n isEnabled={isSubtitleEnabled && hasCurrentAudioPlaybackStarted}\n isPlayerHidden={shouldMountPlayer && !playerControlsVisible}\n playbackTimeStore={playbackTimeStore}\n subtitleCues={currentSubtitleCues}\n />\n\n {shouldShowInteractionOverlay ? (\n <div\n ref={interactionOverlayRef}\n data-player-keyboard-shortcuts-ignore=\"true\"\n className={cn(\n \"slide-interaction-overlay\",\n playerControlsVisible && shouldMountPlayer\n ? \"slide-interaction-overlay--with-player\"\n : \"slide-interaction-overlay--standalone\",\n isInteractionOverlayDragging &&\n \"slide-interaction-overlay--dragging\"\n )}\n onClick={stopOverlayPropagation}\n onPointerDownCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n onFocusCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n onInputCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n style={interactionOverlayStyle}\n >\n <InteractionOverlayCard\n content={String(activeInteractionElement?.content ?? \"\")}\n locale={locale}\n defaultButtonText={interactionDefaults.buttonText ?? \"\"}\n defaultInputText={interactionDefaults.inputText ?? \"\"}\n defaultSelectedValues={interactionDefaultSelectedValues}\n confirmButtonText={\n interactionTexts?.confirmButtonText ??\n localeTexts.interactionTexts.confirmButtonText\n }\n copyButtonText={\n interactionTexts?.copyButtonText ??\n localeTexts.interactionTexts.copyButtonText\n }\n copiedButtonText={\n interactionTexts?.copiedButtonText ??\n localeTexts.interactionTexts.copiedButtonText\n }\n onSend={handleInteractionSend}\n onDragHandlePointerCancel={endInteractionOverlayDrag}\n onDragHandlePointerDown={handleInteractionOverlayPointerDown}\n onDragHandlePointerMove={handleInteractionOverlayPointerMove}\n onDragHandlePointerUp={endInteractionOverlayDrag}\n readonly={isInteractionReadonly}\n title={\n interactionTexts?.title ??\n interactionTitle ??\n localeTexts.interactionTexts.title\n }\n />\n </div>\n ) : null}\n\n {shouldMountPlayer ? (\n <PlayerKeyboardShortcutContext.Provider\n value={keyboardShortcutContextValue}\n >\n <Player\n audioList={audioList}\n className={cn(\n \"absolute left-1/2 z-[2] -translate-x-1/2\",\n isDesktopBrowserFullscreen ? \"bottom-3\" : \"-bottom-3\",\n playerClassName,\n !playerControlsVisible && \"pointer-events-none opacity-0\"\n )}\n currentAudioIndex={currentAudioIndex}\n defaultPlaying={isPlaybackRequested}\n enableKeyboardShortcuts={enableKeyboardShortcuts}\n isPlaybackPaused={shouldPausePlaybackForCustomAction}\n isAutoAdvanceEnabled={isAutoAdvanceEnabled}\n locale={locale}\n hasInteraction={Boolean(activeInteractionElement)}\n isInteractionOpen={isInteractionOverlayOpen}\n isSubtitleEnabled={isSubtitleEnabled}\n onAutoAdvanceToggle={setIsAutoAdvanceEnabled}\n onLoadingChange={handlePlayerLoadingChange}\n onPlaybackStarted={() => {\n setHasCurrentAudioPlaybackStarted(true);\n }}\n onPlaybackPreferenceChange={handlePlaybackPreferenceChange}\n onPlaybackTimeChange={playbackTimeStore.setTime}\n onSubtitleToggle={() => {\n setIsSubtitleEnabled((previousEnabled) => !previousEnabled);\n }}\n nextDisabled={!canGoNext}\n onEnded={handlePlayerEnded}\n onFullscreen={handleFullscreen}\n isFullscreen={isBrowserFullscreen}\n mobileViewMode={effectiveMobileViewMode}\n settingsPortalContainer={viewportRef.current}\n onMobileViewModeChange={handleMobileViewModeSelect}\n onControlsPointerEnter={handlePlayerControlsPointerEnter}\n onControlsPointerLeave={handlePlayerControlsPointerLeave}\n onInteractionToggle={handleInteractionToggle}\n onNext={handleNext}\n onPrev={handlePrev}\n onSubtitleJump={handleSubtitleJump}\n canJumpToSubtitleTarget={canJumpToSubtitleTarget}\n prevDisabled={!canGoPrev}\n showControls={playerControlsVisible}\n subtitleSeekRequest={subtitleSeekRequest}\n texts={playerTexts}\n customActionContext={playerCustomActionContext}\n customActions={playerCustomActions}\n useAutoAdvanceToggle={shouldUseSilentStepAutoAdvanceToggle}\n />\n </PlayerKeyboardShortcutContext.Provider>\n ) : null}\n </div>\n </section>\n );\n};\n\nexport default Slide;\n"],"names":["DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX","DEFAULT_INTERACTION_SUBTITLE_GAP_PX","DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","INTERACTION_ACTIVITY_SELECTOR","DEFAULT_BUFFERING_REASON","resolveBufferingTextByReason","bufferingText","reason","DEFAULT_SLIDE_BUFFERING_TEXTS","mergeBufferingTextWithLocaleDefaults","localeBufferingText","shouldShowBufferingOverlay","loading","InteractionOverlayCard","memo","content","title","locale","defaultButtonText","defaultInputText","defaultSelectedValues","confirmButtonText","copyButtonText","copiedButtonText","onSend","onDragHandlePointerCancel","onDragHandlePointerDown","onDragHandlePointerMove","onDragHandlePointerUp","readonly","jsxs","jsx","GripHorizontal","ContentRender","areStepElementListsEqual","prevElementList","nextElementList","element","index","nextElement","isInteractionActivityTarget","target","Slide","elementList","playerEnabled","playerControlsVisibility","playerClassName","fullscreenHeader","playerCustomActions","playerCustomActionPauseOnActive","interactionTitle","interactionTexts","playerTexts","playerAutoHideDelay","markerAutoAdvanceDelay","interactionDefaultValueOptions","onPlayerVisibilityChange","onMobileViewModeChange","onStepChange","enableKeyboardShortcuts","enableIframeScaling","enableMarkdownScaling","disableLoadingOverlay","className","onPointerDown","onFocusCapture","props","localeTexts","useMemo","getSlideLocaleTexts","resolvedBufferingText","resolvedPlayerEnabled","resolvedPlayerControlsVisibility","resolveSlidePlayerVisibility","keyboardShortcutOwnerId","useId","sectionRef","useRef","viewportRef","stageLayerRef","lastElementRef","playerHideTimerRef","isPointerInsidePlayerControlsRef","autoAdvanceTimerRef","imageOnlyStepReadyTimeoutRef","interactionAutoCloseTimerRef","interactionOverlayOpenTimerRef","interactionOverlayRef","interactionOverlayLayoutRectRef","interactionOverlayDragRef","prevRenderElementKeysRef","shouldScrollToBottomRef","pendingInteractionOverlayStepIndexRef","pendingSubtitleJumpRef","subtitleSeekRequestIdRef","playbackResetKeyRef","appendedMarkerAdvanceStateRef","shouldSkipDefaultAudioStartForSubtitleJumpRef","currentElementList","stepElementLists","slideElementList","currentIndex","audioList","audioSlideIndexes","currentAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement","canGoPrev","canGoNext","goPrev","goNext","goTo","useSlide","currentStepElement","currentRenderElementKeys","isSingleSlide","shouldMountPlayer","keyboardShortcutContextValue","activateKeyboardShortcutOwner","useCallback","activatePlayerKeyboardShortcutOwner","currentAudioSequenceKeys","audioIndex","audioKey","isPlayerVisible","setIsPlayerVisible","useState","hasPlayerInteracted","setHasPlayerInteracted","isPlaybackRequested","setIsPlaybackRequested","isAutoAdvanceEnabled","setIsAutoAdvanceEnabled","currentAudioKey","setCurrentAudioKey","subtitleSeekRequest","setSubtitleSeekRequest","isAudioLoadingVisible","setIsAudioLoadingVisible","audioLoadingReason","setAudioLoadingReason","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","hasCurrentAudioPlaybackStarted","setHasCurrentAudioPlaybackStarted","isSubtitleEnabled","setIsSubtitleEnabled","isPlayerCustomActionActive","setIsPlayerCustomActionActive","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","hasInteractionOverlayActivity","setHasInteractionOverlayActivity","interactionOverlayDragOffset","setInteractionOverlayDragOffset","isInteractionOverlayDragging","setIsInteractionOverlayDragging","interactionOverlaySubtitleOffset","setInteractionOverlaySubtitleOffset","isBrowserFullscreen","setIsBrowserFullscreen","isMobileDevice","getIsMobileDevice","mobileViewMode","setMobileViewMode","DEFAULT_MOBILE_VIEW_MODE","hasManualMobileViewMode","setHasManualMobileViewMode","isViewportFullscreenPreferred","setIsViewportFullscreenPreferred","getIsFullscreenPreferredViewport","playbackTimeStore","createPlaybackTimeStore","effectiveMobileViewMode","isImmersiveMobileFullscreen","isNativeMobileFullscreen","shouldRotateFullscreenViewport","resolveMobileViewModeState","previousEffectiveMobileViewModeRef","playerControlsVisible","shouldShowFullscreenHeader","shouldApplyFullscreenViewportPadding","shouldShowMobileFullscreenMask","isDesktopBrowserFullscreen","handleMobileViewModeSelect","nextViewMode","handleMobileViewModeReset","handleFullscreenHeaderBack","setPlayerCustomActionActive","active","togglePlayerCustomActionActive","previous","mountedStepStates","currentMountedStateIndex","nextMountedStepStates","mountedStateIndexByStep","stepElementList","stepIndex","existingMountedStateIndex","mountedStepState","currentStepKey","currentAudioIndex","audioItem","currentAudioItem","currentSubtitleCues","currentAudioSequenceStartKey","playerCustomActionContext","resolvePlayerCustomActionElement","playerCustomActionCount","getPlayerCustomActionCount","interactionOverlayStyle","hasAvailableStepAudio","currentInteractionResetKey","currentPlaybackResetKey","currentPlaybackStartedResetKey","hasCurrentStepAudioUrl","shouldPausePlaybackForCustomAction","shouldUseSilentStepAutoAdvanceToggle","shouldUseAutoAdvanceToggle","silentStepAutoAdvanceBehavior","resolveSilentStepAutoAdvanceBehavior","silentStepAutoAdvanceDelay","isImageOnlySilentStep","imageOnlyStepVisualReadyKey","readyImageOnlyStepKey","setReadyImageOnlyStepKey","isImageOnlyStepVisualReady","clearPlayerHideTimer","clearInteractionAutoCloseTimer","clearInteractionOverlayOpenTimer","clearAutoAdvanceTimer","clearImageOnlyStepReadyTimeout","resetAudioSequence","options","requestSubtitleCueSeek","startCurrentAudioSequence","nextAudioKey","continueAfterInteraction","scheduleInteractionOverlayOpen","interactionElement","openOverlay","isPlayerControlsHovered","revealPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","hasResolvedInteractionElement","shouldBlockPlaybackForInteraction","handlePlaybackPreferenceChange","playing","syncPlaybackPreferenceBeforeNavigation","context","cancelled","rafId","cleanupListeners","detachListeners","finishVisualReady","evaluateVisualReady","activeStepContainer","iframeElements","areImageOnlyStepIframeVisualsReady","cleanupCallbacks","queueRecheck","registerEvent","eventName","listener","iframeElement","iframeDocument","image","cleanup","DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS","syncViewportFullscreenPreference","subscribeMobileDeviceChange","previousState","shouldAdvanceIntoAppendedMarker","shouldAutoAdvanceIntoAppendedMarker","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","hasPlaybackContextChanged","shouldInitializeAudioSequence","getPlaybackSequenceTransition","shouldOpenInteractionOverlayAfterAudio","shouldPresentOverlay","shouldPresentInteractionOverlay","pendingSubtitleJump","shouldPreservePendingSubtitleJump","canReachSubtitleJumpTarget","shouldSkipDefaultAudioStart","shouldStartDefaultAudioSequence","interactionDefaults","interactionDefaultSelectedValues","hasResolvedInteractionInput","resolvedInteractionReadonly","shouldAutoContinueInteraction","resolveSlideInteractionState","isInteractionReadonly","shouldShowInteractionOverlay","shouldRenderInteractionOverlay","handleInteractionSend","resolvedUserInput","prevElement","syncFullscreenState","interactionOverlayElement","updateSubtitleOffset","overlayHeight","resizeObserver","renderSlideElement","Fragment","IframeSandbox","renderSlideElementList","isActiveStep","visibleElementCount","markdownScalingMode","resolveMarkdownScalingMode","lastVisibleElementIndex","lastVisibleIndex","MarkdownSlideScaling","isPreRenderedHtml","cn","handleFullscreen","scrollStageToBottom","stageLayerElement","canJumpToSubtitleTarget","handleSubtitleJump","targetAudioKey","targetSlideIndex","shouldWakePlayerControlsAfterNavigation","handlePrev","handleNext","handlePlayerLoadingChange","handlePlayerEnded","endedAudioKey","activeSequencePosition","audioSequenceKey","nextSequencePosition","nextStepIndex","nextStepElement","handleInteractionToggle","prevOpen","handlePlayerControlsPointerEnter","handlePlayerControlsPointerLeave","stopOverlayPropagation","getInteractionOverlayDragBounds","overlayElement","startOffset","viewportElement","overlayRect","viewportRect","previousRect","currentRect","nextOffset","bounds","clampedOffset","clampInteractionOverlayDragOffset","handleInteractionOverlayPointerDown","handleInteractionOverlayPointerMove","dragState","endInteractionOverlayDrag","handleSurfacePointerDown","handleSurfaceFocusCapture","handleSurfaceClick","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","ChevronLeft","mountedStepStateIndex","LoadingOverlayCard","SubtitleOverlay","PlayerKeyboardShortcutContext","Player","previousEnabled"],"mappings":"iwDAgGMA,GAAuC,IACvCC,GAA4C,IAC5CC,GAAiD,IACjDC,GAAsC,GACtCC,GAAmD,IACnDC,GAAwE,CAC5E,EAAG,EACH,EAAG,CACL,EAEMC,GACJ,OAAO,OAAW,IAAcC,EAAAA,UAAYC,EAAAA,gBACxCC,GAAgC,CACpC,SACA,QACA,WACA,uBACA,2BACA,oCACF,EAAE,KAAK,IAAI,EACLC,GAAiD,kBAQjDC,GAA+B,CACnCC,EACAC,IAEI,OAAOD,GAAkB,SACpBA,EAIPA,EAAcC,CAAM,GACpBD,EAAcF,EAAwB,GACtCI,GAAAA,8BAA8BD,CAAM,EAIlCE,GAAuC,CAC3CH,EACAI,IAEI,OAAOJ,GAAkB,SACpBA,EAGF,CACL,GAAGI,EACH,GAAGJ,CAAA,EAIDK,GAA6B,CACjCJ,EACAK,IAEKA,EAKEL,IAAW,eAJT,GA2CLM,GAAyBC,EAAAA,KAC7B,CAAC,CACC,QAAAC,EACA,MAAAC,EACA,OAAAC,EACA,kBAAAC,GACA,iBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,iBAAAC,GACA,OAAAC,GACA,0BAAAC,EAC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