markdown-flow-ui 0.1.114 → 0.1.115

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.
Files changed (41) hide show
  1. package/dist/_virtual/index.cjs7.js +1 -1
  2. package/dist/_virtual/index.cjs8.js +1 -1
  3. package/dist/_virtual/index.es7.js +2 -3
  4. package/dist/_virtual/index.es7.js.map +1 -1
  5. package/dist/_virtual/index.es8.js +3 -2
  6. package/dist/_virtual/index.es8.js.map +1 -1
  7. package/dist/assets/markdown-flow-ui.css +1 -1
  8. package/dist/components/Slide/Slide.cjs.js +1 -1
  9. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  10. package/dist/components/Slide/Slide.es.js +427 -440
  11. package/dist/components/Slide/Slide.es.js.map +1 -1
  12. package/dist/components/Slide/constants.cjs.js +1 -1
  13. package/dist/components/Slide/constants.cjs.js.map +1 -1
  14. package/dist/components/Slide/constants.es.js +2 -3
  15. package/dist/components/Slide/constants.es.js.map +1 -1
  16. package/dist/components/Slide/useSlide.cjs.js +1 -1
  17. package/dist/components/Slide/useSlide.cjs.js.map +1 -1
  18. package/dist/components/Slide/useSlide.d.ts +5 -0
  19. package/dist/components/Slide/useSlide.es.js +84 -77
  20. package/dist/components/Slide/useSlide.es.js.map +1 -1
  21. package/dist/components/Slide/useSlide.test.d.ts +1 -0
  22. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
  23. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
  24. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js +1 -1
  25. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.es.js +1 -1
  26. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js +1 -1
  27. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.es.js +1 -1
  28. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js +1 -1
  29. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.es.js +1 -1
  30. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js +1 -1
  31. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.es.js +1 -1
  32. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js +1 -1
  33. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.es.js +1 -1
  34. package/dist/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.cjs.js +1 -1
  35. package/dist/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.es.js +1 -1
  36. package/dist/markdown-flow-ui-lib.css +1 -1
  37. package/package.json +1 -1
  38. package/dist/components/Slide/SlideFullscreenHint.cjs.js +0 -2
  39. package/dist/components/Slide/SlideFullscreenHint.cjs.js.map +0 -1
  40. package/dist/components/Slide/SlideFullscreenHint.es.js +0 -42
  41. package/dist/components/Slide/SlideFullscreenHint.es.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Slide.es.js","sources":["../../../src/components/Slide/Slide.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\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 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 {\n getInteractionDefaultSelectedValues,\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\nimport {\n isLandscapeViewport as getIsFullscreenPreferredViewport,\n isMobileDevice as getIsMobileDevice,\n subscribeMobileDeviceChange,\n} from \"../../lib/mobileDevice\";\nimport Player from \"./Player\";\nimport SubtitleOverlay from \"./SubtitleOverlay\";\nimport type { PlayerProps, SlidePlayerTexts } from \"./Player\";\nimport { DEFAULT_SLIDE_PLAYER_TEXTS } from \"./constants\";\nimport SlideFullscreenHint from \"./SlideFullscreenHint\";\nimport type { Element } from \"./types\";\nimport useSlide from \"./useSlide\";\nimport useWakePlayerFromIframe from \"./useWakePlayerFromIframe\";\nimport {\n DEFAULT_MOBILE_VIEW_MODE,\n resolveMobileViewModeState,\n type MobileViewMode,\n} from \"./utils/mobileScreenMode\";\nimport { shouldPresentInteractionOverlay } from \"./utils/interactionPlayback\";\nimport { shouldAutoAdvanceIntoAppendedMarker } from \"./utils/appendedMarkerAdvance\";\nimport { getPlaybackSequenceTransition } from \"./utils/playbackSequence\";\nimport {\n getPlayerCustomActionCount,\n resolvePlayerCustomActionElement,\n} from \"./utils/playerCustomActions\";\nimport { createPlaybackTimeStore } from \"./utils/playbackTimeStore\";\nimport { shouldUseAutoAdvanceToggle } from \"./utils/playerToggleMode\";\nimport \"./slide.css\";\nexport type {\n Element,\n ElementAudioSegment,\n ElementSubtitleCue,\n SlidePlayerCustomActionContext,\n SlidePlayerCustomActions,\n} from \"./types\";\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;\n\ntype RenderSlideElementOptions = {\n replaceRootScreenHeightWithFull?: boolean;\n};\n\ninterface InteractionOverlayCardProps {\n content: string;\n title: string;\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 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 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 defaultButtonText={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n onSend={onSend}\n readonly={readonly}\n enableTypewriter={false}\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\nexport interface SlideProps extends React.ComponentProps<\"section\"> {\n elementList?: Element[];\n showPlayer?: boolean;\n playerAlwaysVisible?: boolean;\n playerClassName?: string;\n fullscreenHeader?: SlideFullscreenHeader;\n playerCustomActions?: PlayerProps[\"customActions\"];\n playerCustomActionPauseOnActive?: boolean;\n bufferingText?: string;\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 enableIframeScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n showPlayer = true,\n playerAlwaysVisible = false,\n playerClassName,\n fullscreenHeader,\n playerCustomActions,\n playerCustomActionPauseOnActive = true,\n bufferingText = \"Buffering...\",\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 enableIframeScaling = true,\n disableLoadingOverlay = false,\n className,\n onPointerDown,\n ...props\n}) => {\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 autoAdvanceTimerRef = 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 playbackResetKeyRef = useRef<string | null>(null);\n const appendedMarkerAdvanceStateRef = useRef({\n markerCount: 0,\n currentIndex: -1,\n canGoNext: false,\n });\n const {\n currentElementList,\n stepElementLists,\n slideElementList,\n currentIndex,\n audioList,\n currentAudioSequenceIndexes,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n canGoPrev,\n canGoNext,\n handlePrev: goPrev,\n handleNext: goNext,\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 visibleMarkerCount = slideElementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const isSingleSlide = visibleMarkerCount === 1;\n const shouldRenderPlayer =\n showPlayer &&\n (slideElementList.length > 0 ||\n audioList.length > 0 ||\n Boolean(currentInteractionElement));\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 [isAutoAdvanceEnabled, setIsAutoAdvanceEnabled] = useState(true);\n const [currentAudioKey, setCurrentAudioKey] = useState<string | null>(null);\n const [isAudioLoadingVisible, setIsAudioLoadingVisible] = useState(false);\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 [\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 [isFullscreenHintOpen, setIsFullscreenHintOpen] = useState(false);\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 playerVisible =\n shouldRenderPlayer && (playerAlwaysVisible || isPlayerVisible);\n const shouldShowFullscreenHeader =\n isImmersiveMobileFullscreen && playerVisible;\n const shouldApplyFullscreenViewportPadding =\n isImmersiveMobileFullscreen && playerVisible;\n const shouldShowMobileFullscreenMask =\n isImmersiveMobileFullscreen || isNativeMobileFullscreen;\n const fullscreenHintText =\n playerTexts?.fullscreenHintText ??\n DEFAULT_SLIDE_PLAYER_TEXTS.fullscreenHintText;\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 handleFullscreenHintClose = useCallback(() => {\n setIsFullscreenHintOpen(false);\n }, []);\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\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 resetAudioSequence = useCallback(() => {\n clearAutoAdvanceTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n setCurrentAudioKey(null);\n playbackTimeStore.reset();\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setHasCurrentAudioPlaybackStarted(false);\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n }, [\n clearAutoAdvanceTimer,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n playbackTimeStore,\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 showPlayerControls = useCallback(\n (enableAutoHide = hasPlayerInteracted) => {\n if (!shouldRenderPlayer) {\n return;\n }\n\n setIsPlayerVisible(true);\n clearPlayerHideTimer();\n\n if (playerAlwaysVisible || !enableAutoHide || playerAutoHideDelay <= 0) {\n return;\n }\n\n playerHideTimerRef.current = window.setTimeout(() => {\n setIsPlayerVisible(false);\n playerHideTimerRef.current = null;\n }, playerAutoHideDelay);\n },\n [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n playerAlwaysVisible,\n playerAutoHideDelay,\n shouldRenderPlayer,\n ]\n );\n\n const hasResolvedCurrentInteraction = Boolean(\n currentInteractionElement?.readonly ||\n currentInteractionElement?.user_input?.trim()\n );\n\n const shouldBlockPlaybackForInteraction =\n Boolean(currentInteractionElement) && !hasResolvedCurrentInteraction;\n\n useEffect(() => {\n // Reset silent-step autoplay toggle whenever navigation lands on a new step.\n setIsAutoAdvanceEnabled(true);\n\n if (playerCustomActionPauseOnActive) {\n setIsPlayerCustomActionActive(false);\n }\n }, [currentIndex, playerCustomActionPauseOnActive]);\n\n useEffect(() => {\n return () => {\n clearAutoAdvanceTimer();\n clearPlayerHideTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n };\n }, [\n clearAutoAdvanceTimer,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n clearPlayerHideTimer,\n ]);\n\n useEffect(() => {\n onPlayerVisibilityChange?.(playerVisible);\n\n return () => {\n onPlayerVisibilityChange?.(false);\n };\n }, [onPlayerVisibilityChange, playerVisible]);\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 const previousMode = previousEffectiveMobileViewModeRef.current;\n const hasEnteredFullscreen =\n previousMode !== \"fullscreen\" && effectiveMobileViewMode === \"fullscreen\";\n const shouldShowFullscreenHint =\n hasEnteredFullscreen && !isViewportFullscreenPreferred;\n\n previousEffectiveMobileViewModeRef.current = effectiveMobileViewMode;\n\n if (!isMobileDevice) {\n setIsFullscreenHintOpen(false);\n return;\n }\n\n if (shouldShowFullscreenHint) {\n setIsFullscreenHintOpen(true);\n return;\n }\n\n if (effectiveMobileViewMode !== \"fullscreen\") {\n setIsFullscreenHintOpen(false);\n }\n }, [effectiveMobileViewMode, isMobileDevice, isViewportFullscreenPreferred]);\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 (!shouldRenderPlayer) {\n clearPlayerHideTimer();\n setIsPlayerVisible(false);\n return;\n }\n\n if (playerAlwaysVisible) {\n clearPlayerHideTimer();\n setIsPlayerVisible(true);\n return;\n }\n\n if (!hasPlayerInteracted) {\n // Keep the initial player visible briefly, then hide it automatically.\n showPlayerControls(true);\n }\n }, [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n playerAlwaysVisible,\n shouldRenderPlayer,\n showPlayerControls,\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 (!shouldRenderPlayer) {\n return;\n }\n\n // Restore player controls on explicit click/tap without waking on scroll start.\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n };\n\n window.addEventListener(\"message\", handleSandboxInteraction);\n\n return () => {\n window.removeEventListener(\"message\", handleSandboxInteraction);\n };\n }, [shouldRenderPlayer, showPlayerControls]);\n\n useWakePlayerFromIframe({\n sectionRef,\n enabled: shouldRenderPlayer,\n onWake: () => {\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n },\n });\n\n useEffect(() => {\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 if (hasPlaybackContextChanged) {\n resetAudioSequence();\n }\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldPausePlaybackForCustomAction) {\n return;\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 // Auto-advance silent marker-only steps so playback flow does not stall.\n autoAdvanceTimerRef.current = window.setTimeout(() => {\n autoAdvanceTimerRef.current = null;\n goNext();\n }, markerAutoAdvanceDelay);\n\n return () => {\n clearAutoAdvanceTimer();\n };\n }, [\n canGoNext,\n clearAutoAdvanceTimer,\n currentElementList.length,\n currentInteractionElement,\n currentAudioKey,\n currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n markerAutoAdvanceDelay,\n goNext,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n isAutoAdvanceEnabled,\n hasResolvedCurrentInteraction,\n shouldBlockPlaybackForInteraction,\n clearInteractionOverlayOpenTimer,\n resetAudioSequence,\n scheduleInteractionOverlayOpen,\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 setIsAudioLoadingVisible(true);\n }, [\n hasAvailableStepAudio,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n ]);\n\n useEffect(() => {\n if (currentAudioKey || currentAudioSequenceKeys.length === 0) {\n return;\n }\n\n if (\n shouldPausePlaybackForCustomAction ||\n !currentStepHasSpeakableElement ||\n shouldBlockPlaybackForInteraction\n ) {\n return;\n }\n\n if (hasCompletedCurrentStepAudio) {\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 interactionDefaults = useMemo(() => {\n if (!activeInteractionElement) {\n return {};\n }\n\n const shouldPreferResolvedInteractionInput = Boolean(\n activeInteractionElement.user_input?.trim()\n );\n\n return getInteractionDefaultValues(\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined,\n activeInteractionElement.user_input,\n shouldPreferResolvedInteractionInput\n ? undefined\n : interactionDefaultValueOptions\n );\n }, [activeInteractionElement, interactionDefaultValueOptions]);\n\n const interactionDefaultSelectedValues = useMemo(() => {\n if (!activeInteractionElement) {\n return undefined;\n }\n\n const shouldPreferResolvedInteractionInput = Boolean(\n activeInteractionElement.user_input?.trim()\n );\n\n return getInteractionDefaultSelectedValues(\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined,\n activeInteractionElement.user_input,\n shouldPreferResolvedInteractionInput\n ? undefined\n : interactionDefaultValueOptions\n );\n }, [activeInteractionElement, interactionDefaultValueOptions]);\n\n const hasResolvedInteractionInput = Boolean(\n activeInteractionElement?.user_input?.trim()\n );\n\n const isInteractionReadonly =\n Boolean(activeInteractionElement?.readonly) || hasResolvedInteractionInput;\n const shouldAutoContinueInteraction =\n isInteractionReadonly || hasResolvedInteractionInput;\n const shouldShowInteractionOverlay =\n Boolean(activeInteractionElement) && isInteractionOverlayOpen;\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 (!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 || !shouldAutoContinueInteraction) {\n return;\n }\n\n // Auto-close passive interaction markers to keep playback moving.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, 2000);\n\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }, [\n clearInteractionAutoCloseTimer,\n continueAfterInteraction,\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 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 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 lastVisibleElementIndex = elementList.reduce(\n (lastVisibleIndex, element, index) =>\n element.is_renderable !== false ? index : lastVisibleIndex,\n -1\n );\n\n return (\n <div className=\"slide-stage__content flex w-full flex-col gap-4\">\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 </div>\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 handlePrev = useCallback(() => {\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setHasPlayerInteracted(true);\n setIsAudioLoadingVisible(false);\n showPlayerControls(true);\n resetAudioSequence();\n goPrev();\n }, [goPrev, resetAudioSequence, showPlayerControls]);\n\n const handleNext = useCallback(() => {\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setHasPlayerInteracted(true);\n setIsAudioLoadingVisible(false);\n showPlayerControls(true);\n resetAudioSequence();\n goNext();\n }, [goNext, resetAudioSequence, showPlayerControls]);\n\n const handlePlayerLoadingChange = useCallback(\n (loading: boolean) => {\n if (disableLoadingOverlay) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(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 }\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 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 (playerVisible) {\n showPlayerControls(true);\n }\n },\n [isPlayerVisible, showPlayerControls]\n );\n\n const handleSurfacePointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n onPointerDown?.(event);\n },\n [onPointerDown]\n );\n\n const handleSurfaceClick = useCallback(() => {\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n }, [showPlayerControls]);\n\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\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 isImmersiveMobileFullscreen && \"slide--mobile-landscape\",\n isNativeMobileFullscreen && \"slide--mobile-landscape-native\",\n className\n )}\n onClick={handleSurfaceClick}\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={fullscreenHeader?.backAriaLabel ?? \"Back\"}\n className=\"slide-landscape-header__back\"\n onClick={handleFullscreenHeaderBack}\n type=\"button\"\n >\n <ChevronLeft className=\"h-6 w-6 text-white\" strokeWidth={2.25} />\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 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={bufferingText}\n className=\"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2\"\n />\n ) : null}\n\n <SlideFullscreenHint\n onClose={handleFullscreenHintClose}\n open={isFullscreenHintOpen}\n text={fullscreenHintText}\n />\n\n <SubtitleOverlay\n extraBottomOffset={interactionOverlaySubtitleOffset}\n hasPlayerGap={playerVisible}\n isEnabled={isSubtitleEnabled && hasCurrentAudioPlaybackStarted}\n isPlayerHidden={shouldRenderPlayer && !playerVisible}\n playbackTimeStore={playbackTimeStore}\n subtitleCues={currentSubtitleCues}\n />\n\n {shouldShowInteractionOverlay ? (\n <div\n ref={interactionOverlayRef}\n className={cn(\n \"slide-interaction-overlay\",\n playerVisible && shouldRenderPlayer\n ? \"slide-interaction-overlay--with-player\"\n : \"slide-interaction-overlay--standalone\"\n )}\n onClick={stopOverlayPropagation}\n onPointerDown={stopOverlayPropagation}\n style={interactionOverlayStyle}\n >\n <InteractionOverlayCard\n content={String(activeInteractionElement?.content ?? \"\")}\n defaultButtonText={interactionDefaults.buttonText ?? \"\"}\n defaultInputText={interactionDefaults.inputText ?? \"\"}\n defaultSelectedValues={interactionDefaultSelectedValues}\n confirmButtonText={interactionTexts?.confirmButtonText}\n copyButtonText={interactionTexts?.copyButtonText}\n copiedButtonText={interactionTexts?.copiedButtonText}\n onSend={handleInteractionSend}\n readonly={isInteractionReadonly}\n title={\n interactionTexts?.title ??\n interactionTitle ??\n \"Submit the content below to continue.\"\n }\n />\n </div>\n ) : null}\n\n {shouldRenderPlayer ? (\n <Player\n audioList={audioList}\n className={cn(\n \"absolute left-1/2 bottom-6 z-[2] -translate-x-1/2\",\n playerClassName,\n !playerVisible && \"pointer-events-none opacity-0\"\n )}\n currentAudioIndex={currentAudioIndex}\n defaultPlaying\n isPlaybackPaused={shouldPausePlaybackForCustomAction}\n isAutoAdvanceEnabled={isAutoAdvanceEnabled}\n hasInteraction={Boolean(activeInteractionElement)}\n isInteractionOpen={isInteractionOverlayOpen}\n isSubtitleEnabled={isSubtitleEnabled}\n onAutoAdvanceToggle={setIsAutoAdvanceEnabled}\n onLoadingChange={handlePlayerLoadingChange}\n onPlaybackStarted={() => {\n setHasCurrentAudioPlaybackStarted(true);\n }}\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 onInteractionToggle={handleInteractionToggle}\n onNext={handleNext}\n onPrev={handlePrev}\n prevDisabled={!canGoPrev}\n showControls={playerVisible}\n texts={playerTexts}\n customActionContext={playerCustomActionContext}\n customActions={playerCustomActions}\n useAutoAdvanceToggle={shouldUseSilentStepAutoAdvanceToggle}\n />\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","InteractionOverlayCard","memo","content","title","defaultButtonText","defaultInputText","defaultSelectedValues","confirmButtonText","copyButtonText","copiedButtonText","onSend","readonly","jsxs","jsx","ContentRender","areStepElementListsEqual","prevElementList","nextElementList","element","index","nextElement","Slide","elementList","showPlayer","playerAlwaysVisible","playerClassName","fullscreenHeader","playerCustomActions","playerCustomActionPauseOnActive","bufferingText","interactionTitle","interactionTexts","playerTexts","playerAutoHideDelay","markerAutoAdvanceDelay","interactionDefaultValueOptions","onPlayerVisibilityChange","onMobileViewModeChange","onStepChange","enableIframeScaling","disableLoadingOverlay","className","onPointerDown","props","sectionRef","useRef","viewportRef","stageLayerRef","lastElementRef","playerHideTimerRef","autoAdvanceTimerRef","interactionAutoCloseTimerRef","interactionOverlayOpenTimerRef","interactionOverlayRef","prevRenderElementKeysRef","shouldScrollToBottomRef","pendingInteractionOverlayStepIndexRef","playbackResetKeyRef","appendedMarkerAdvanceStateRef","currentElementList","stepElementLists","slideElementList","currentIndex","audioList","currentAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement","canGoPrev","canGoNext","goPrev","goNext","useSlide","currentStepElement","useMemo","isSingleSlide","shouldRenderPlayer","currentAudioSequenceKeys","audioIndex","audioKey","isPlayerVisible","setIsPlayerVisible","useState","hasPlayerInteracted","setHasPlayerInteracted","isAutoAdvanceEnabled","setIsAutoAdvanceEnabled","currentAudioKey","setCurrentAudioKey","isAudioLoadingVisible","setIsAudioLoadingVisible","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","hasCurrentAudioPlaybackStarted","setHasCurrentAudioPlaybackStarted","isSubtitleEnabled","setIsSubtitleEnabled","isPlayerCustomActionActive","setIsPlayerCustomActionActive","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","interactionOverlaySubtitleOffset","setInteractionOverlaySubtitleOffset","isBrowserFullscreen","setIsBrowserFullscreen","isMobileDevice","getIsMobileDevice","mobileViewMode","setMobileViewMode","DEFAULT_MOBILE_VIEW_MODE","hasManualMobileViewMode","setHasManualMobileViewMode","isViewportFullscreenPreferred","setIsViewportFullscreenPreferred","getIsFullscreenPreferredViewport","isFullscreenHintOpen","setIsFullscreenHintOpen","playbackTimeStore","createPlaybackTimeStore","effectiveMobileViewMode","isImmersiveMobileFullscreen","isNativeMobileFullscreen","shouldRotateFullscreenViewport","resolveMobileViewModeState","previousEffectiveMobileViewModeRef","playerVisible","shouldShowFullscreenHeader","shouldApplyFullscreenViewportPadding","shouldShowMobileFullscreenMask","fullscreenHintText","DEFAULT_SLIDE_PLAYER_TEXTS","handleMobileViewModeSelect","useCallback","nextViewMode","handleMobileViewModeReset","handleFullscreenHeaderBack","handleFullscreenHintClose","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","clearPlayerHideTimer","clearInteractionAutoCloseTimer","clearInteractionOverlayOpenTimer","clearAutoAdvanceTimer","resetAudioSequence","startCurrentAudioSequence","nextAudioKey","continueAfterInteraction","scheduleInteractionOverlayOpen","interactionElement","openOverlay","showPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","shouldBlockPlaybackForInteraction","useEffect","syncViewportFullscreenPreference","subscribeMobileDeviceChange","shouldShowFullscreenHint","previousState","shouldAdvanceIntoAppendedMarker","shouldAutoAdvanceIntoAppendedMarker","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","hasPlaybackContextChanged","shouldInitializeAudioSequence","getPlaybackSequenceTransition","shouldOpenInteractionOverlayAfterAudio","shouldPresentOverlay","shouldPresentInteractionOverlay","interactionDefaults","shouldPreferResolvedInteractionInput","getInteractionDefaultValues","interactionDefaultSelectedValues","getInteractionDefaultSelectedValues","hasResolvedInteractionInput","isInteractionReadonly","shouldAutoContinueInteraction","shouldShowInteractionOverlay","handleInteractionSend","resolvedUserInput","prevElement","syncFullscreenState","interactionOverlayElement","updateSubtitleOffset","overlayHeight","resizeObserver","renderSlideElement","options","Fragment","IframeSandbox","renderSlideElementList","isActiveStep","visibleElementCount","lastVisibleElementIndex","lastVisibleIndex","isPreRenderedHtml","cn","handleFullscreen","target","scrollStageToBottom","stageLayerElement","handlePrev","handleNext","handlePlayerLoadingChange","loading","handlePlayerEnded","endedAudioKey","activeSequencePosition","audioSequenceKey","nextSequencePosition","nextStepIndex","nextStepElement","handleInteractionToggle","prevOpen","stopOverlayPropagation","handleSurfacePointerDown","handleSurfaceClick","currentRenderElementKeys","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","ChevronLeft","mountedStepStateIndex","LoadingOverlayCard","SlideFullscreenHint","SubtitleOverlay","Player","previousEnabled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAMA,KAAuC,KACvCC,KAA4C,KAC5CC,KAAiD,KACjDC,KAAsC,IAgCtCC,KAAyBC;AAAA,EAC7B,CAAC;AAAA,IACC,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,QAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,EAAA,MAEXC,gBAAAA,EAAAA,KAAC,OAAA,EAAI,WAA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AA,oBACA3M;AAAA,oBACA,CAACqG,KAAiB;AAAA,kBAAA;AAAA,kBAEpB,mBAAAyB;AAAA,kBACA,gBAAc;AAAA,kBACd,kBAAkBe;AAAA,kBAClB,sBAAAlF;AAAA,kBACA,gBAAgB,EAAQc;AAAA,kBACxB,mBAAmBE;AAAA,kBACnB,mBAAAN;AAAA,kBACA,qBAAqBT;AAAA,kBACrB,iBAAiBsJ;AAAA,kBACjB,mBAAmB,MAAM;AACvB,oBAAA9I,GAAkC,EAAI;AAAA,kBACxC;AAAA,kBACA,sBAAsByB,EAAkB;AAAA,kBACxC,kBAAkB,MAAM;AACtB,oBAAAvB,GAAqB,CAACyK,MAAoB,CAACA,CAAe;AAAA,kBAC5D;AAAA,kBACA,cAAc,CAACpM;AAAA,kBACf,SAASyK;AAAA,kBACT,cAAcR;AAAA,kBACd,cAAc7H;AAAA,kBACd,gBAAgBgB;AAAA,kBAChB,yBAAyB1E,GAAY;AAAA,kBACrC,wBAAwBsF;AAAA,kBACxB,qBAAqBgH;AAAA,kBACrB,QAAQV;AAAA,kBACR,QAAQD;AAAA,kBACR,cAAc,CAACtK;AAAA,kBACf,cAAc2D;AAAA,kBACd,OAAO9F;AAAA,kBACP,qBAAqB4H;AAAA,kBACrB,eAAejI;AAAA,kBACf,sBAAsB4I;AAAA,gBAAA;AAAA,cAAA,IAEtB;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACN;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"Slide.es.js","sources":["../../../src/components/Slide/Slide.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\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 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 {\n getInteractionDefaultSelectedValues,\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\nimport {\n isLandscapeViewport as getIsFullscreenPreferredViewport,\n isMobileDevice as getIsMobileDevice,\n subscribeMobileDeviceChange,\n} from \"../../lib/mobileDevice\";\nimport Player from \"./Player\";\nimport SubtitleOverlay from \"./SubtitleOverlay\";\nimport type { PlayerProps, SlidePlayerTexts } from \"./Player\";\nimport type { Element } from \"./types\";\nimport useSlide from \"./useSlide\";\nimport useWakePlayerFromIframe from \"./useWakePlayerFromIframe\";\nimport {\n DEFAULT_MOBILE_VIEW_MODE,\n resolveMobileViewModeState,\n type MobileViewMode,\n} from \"./utils/mobileScreenMode\";\nimport { shouldPresentInteractionOverlay } from \"./utils/interactionPlayback\";\nimport { shouldAutoAdvanceIntoAppendedMarker } from \"./utils/appendedMarkerAdvance\";\nimport { getPlaybackSequenceTransition } from \"./utils/playbackSequence\";\nimport {\n getPlayerCustomActionCount,\n resolvePlayerCustomActionElement,\n} from \"./utils/playerCustomActions\";\nimport { createPlaybackTimeStore } from \"./utils/playbackTimeStore\";\nimport { shouldUseAutoAdvanceToggle } from \"./utils/playerToggleMode\";\nimport \"./slide.css\";\nexport type {\n Element,\n ElementAudioSegment,\n ElementSubtitleCue,\n SlidePlayerCustomActionContext,\n SlidePlayerCustomActions,\n} from \"./types\";\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;\n\ntype RenderSlideElementOptions = {\n replaceRootScreenHeightWithFull?: boolean;\n};\n\ninterface InteractionOverlayCardProps {\n content: string;\n title: string;\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 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 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 defaultButtonText={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n onSend={onSend}\n readonly={readonly}\n enableTypewriter={false}\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\nexport interface SlideProps extends React.ComponentProps<\"section\"> {\n elementList?: Element[];\n showPlayer?: boolean;\n playerAlwaysVisible?: boolean;\n playerClassName?: string;\n fullscreenHeader?: SlideFullscreenHeader;\n playerCustomActions?: PlayerProps[\"customActions\"];\n playerCustomActionPauseOnActive?: boolean;\n bufferingText?: string;\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 enableIframeScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n showPlayer = true,\n playerAlwaysVisible = false,\n playerClassName,\n fullscreenHeader,\n playerCustomActions,\n playerCustomActionPauseOnActive = true,\n bufferingText = \"Buffering...\",\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 enableIframeScaling = true,\n disableLoadingOverlay = false,\n className,\n onPointerDown,\n ...props\n}) => {\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 autoAdvanceTimerRef = 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 playbackResetKeyRef = useRef<string | null>(null);\n const appendedMarkerAdvanceStateRef = useRef({\n markerCount: 0,\n currentIndex: -1,\n canGoNext: false,\n });\n const {\n currentElementList,\n stepElementLists,\n slideElementList,\n currentIndex,\n audioList,\n currentAudioSequenceIndexes,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n canGoPrev,\n canGoNext,\n handlePrev: goPrev,\n handleNext: goNext,\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 visibleMarkerCount = slideElementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const isSingleSlide = visibleMarkerCount === 1;\n const shouldRenderPlayer =\n showPlayer &&\n (slideElementList.length > 0 ||\n audioList.length > 0 ||\n Boolean(currentInteractionElement));\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 [isAutoAdvanceEnabled, setIsAutoAdvanceEnabled] = useState(true);\n const [currentAudioKey, setCurrentAudioKey] = useState<string | null>(null);\n const [isAudioLoadingVisible, setIsAudioLoadingVisible] = useState(false);\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 [\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 playerVisible =\n shouldRenderPlayer && (playerAlwaysVisible || isPlayerVisible);\n const shouldShowFullscreenHeader =\n isImmersiveMobileFullscreen && playerVisible;\n const shouldApplyFullscreenViewportPadding =\n isImmersiveMobileFullscreen && playerVisible;\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\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 resetAudioSequence = useCallback(() => {\n clearAutoAdvanceTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n setCurrentAudioKey(null);\n playbackTimeStore.reset();\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setHasCurrentAudioPlaybackStarted(false);\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n }, [\n clearAutoAdvanceTimer,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n playbackTimeStore,\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 showPlayerControls = useCallback(\n (enableAutoHide = hasPlayerInteracted) => {\n if (!shouldRenderPlayer) {\n return;\n }\n\n setIsPlayerVisible(true);\n clearPlayerHideTimer();\n\n if (playerAlwaysVisible || !enableAutoHide || playerAutoHideDelay <= 0) {\n return;\n }\n\n playerHideTimerRef.current = window.setTimeout(() => {\n setIsPlayerVisible(false);\n playerHideTimerRef.current = null;\n }, playerAutoHideDelay);\n },\n [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n playerAlwaysVisible,\n playerAutoHideDelay,\n shouldRenderPlayer,\n ]\n );\n\n const hasResolvedCurrentInteraction = Boolean(\n currentInteractionElement?.readonly ||\n currentInteractionElement?.user_input?.trim()\n );\n\n const shouldBlockPlaybackForInteraction =\n Boolean(currentInteractionElement) && !hasResolvedCurrentInteraction;\n\n useEffect(() => {\n // Reset silent-step autoplay toggle whenever navigation lands on a new step.\n setIsAutoAdvanceEnabled(true);\n\n if (playerCustomActionPauseOnActive) {\n setIsPlayerCustomActionActive(false);\n }\n }, [currentIndex, playerCustomActionPauseOnActive]);\n\n useEffect(() => {\n return () => {\n clearAutoAdvanceTimer();\n clearPlayerHideTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n };\n }, [\n clearAutoAdvanceTimer,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n clearPlayerHideTimer,\n ]);\n\n useEffect(() => {\n onPlayerVisibilityChange?.(playerVisible);\n\n return () => {\n onPlayerVisibilityChange?.(false);\n };\n }, [onPlayerVisibilityChange, playerVisible]);\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 (!shouldRenderPlayer) {\n clearPlayerHideTimer();\n setIsPlayerVisible(false);\n return;\n }\n\n if (playerAlwaysVisible) {\n clearPlayerHideTimer();\n setIsPlayerVisible(true);\n return;\n }\n\n if (!hasPlayerInteracted) {\n // Keep the initial player visible briefly, then hide it automatically.\n showPlayerControls(true);\n }\n }, [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n playerAlwaysVisible,\n shouldRenderPlayer,\n showPlayerControls,\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 (!shouldRenderPlayer) {\n return;\n }\n\n // Restore player controls on explicit click/tap without waking on scroll start.\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n };\n\n window.addEventListener(\"message\", handleSandboxInteraction);\n\n return () => {\n window.removeEventListener(\"message\", handleSandboxInteraction);\n };\n }, [shouldRenderPlayer, showPlayerControls]);\n\n useWakePlayerFromIframe({\n sectionRef,\n enabled: shouldRenderPlayer,\n onWake: () => {\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n },\n });\n\n useEffect(() => {\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 if (hasPlaybackContextChanged) {\n resetAudioSequence();\n }\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldPausePlaybackForCustomAction) {\n return;\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 // Auto-advance silent marker-only steps so playback flow does not stall.\n autoAdvanceTimerRef.current = window.setTimeout(() => {\n autoAdvanceTimerRef.current = null;\n goNext();\n }, markerAutoAdvanceDelay);\n\n return () => {\n clearAutoAdvanceTimer();\n };\n }, [\n canGoNext,\n clearAutoAdvanceTimer,\n currentElementList.length,\n currentInteractionElement,\n currentAudioKey,\n currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n markerAutoAdvanceDelay,\n goNext,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n isAutoAdvanceEnabled,\n hasResolvedCurrentInteraction,\n shouldBlockPlaybackForInteraction,\n clearInteractionOverlayOpenTimer,\n resetAudioSequence,\n scheduleInteractionOverlayOpen,\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 setIsAudioLoadingVisible(true);\n }, [\n hasAvailableStepAudio,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n ]);\n\n useEffect(() => {\n if (currentAudioKey || currentAudioSequenceKeys.length === 0) {\n return;\n }\n\n if (\n shouldPausePlaybackForCustomAction ||\n !currentStepHasSpeakableElement ||\n shouldBlockPlaybackForInteraction\n ) {\n return;\n }\n\n if (hasCompletedCurrentStepAudio) {\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 interactionDefaults = useMemo(() => {\n if (!activeInteractionElement) {\n return {};\n }\n\n const shouldPreferResolvedInteractionInput = Boolean(\n activeInteractionElement.user_input?.trim()\n );\n\n return getInteractionDefaultValues(\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined,\n activeInteractionElement.user_input,\n shouldPreferResolvedInteractionInput\n ? undefined\n : interactionDefaultValueOptions\n );\n }, [activeInteractionElement, interactionDefaultValueOptions]);\n\n const interactionDefaultSelectedValues = useMemo(() => {\n if (!activeInteractionElement) {\n return undefined;\n }\n\n const shouldPreferResolvedInteractionInput = Boolean(\n activeInteractionElement.user_input?.trim()\n );\n\n return getInteractionDefaultSelectedValues(\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined,\n activeInteractionElement.user_input,\n shouldPreferResolvedInteractionInput\n ? undefined\n : interactionDefaultValueOptions\n );\n }, [activeInteractionElement, interactionDefaultValueOptions]);\n\n const hasResolvedInteractionInput = Boolean(\n activeInteractionElement?.user_input?.trim()\n );\n\n const isInteractionReadonly =\n Boolean(activeInteractionElement?.readonly) || hasResolvedInteractionInput;\n const shouldAutoContinueInteraction =\n isInteractionReadonly || hasResolvedInteractionInput;\n const shouldShowInteractionOverlay =\n Boolean(activeInteractionElement) && isInteractionOverlayOpen;\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 (!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 || !shouldAutoContinueInteraction) {\n return;\n }\n\n // Auto-close passive interaction markers to keep playback moving.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, 2000);\n\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }, [\n clearInteractionAutoCloseTimer,\n continueAfterInteraction,\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 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 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 lastVisibleElementIndex = elementList.reduce(\n (lastVisibleIndex, element, index) =>\n element.is_renderable !== false ? index : lastVisibleIndex,\n -1\n );\n\n return (\n <div className=\"slide-stage__content flex w-full flex-col gap-4\">\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 </div>\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 handlePrev = useCallback(() => {\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setHasPlayerInteracted(true);\n setIsAudioLoadingVisible(false);\n showPlayerControls(true);\n resetAudioSequence();\n goPrev();\n }, [goPrev, resetAudioSequence, showPlayerControls]);\n\n const handleNext = useCallback(() => {\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setHasPlayerInteracted(true);\n setIsAudioLoadingVisible(false);\n showPlayerControls(true);\n resetAudioSequence();\n goNext();\n }, [goNext, resetAudioSequence, showPlayerControls]);\n\n const handlePlayerLoadingChange = useCallback(\n (loading: boolean) => {\n if (disableLoadingOverlay) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(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 }\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 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 (playerVisible) {\n showPlayerControls(true);\n }\n },\n [isPlayerVisible, showPlayerControls]\n );\n\n const handleSurfacePointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n onPointerDown?.(event);\n },\n [onPointerDown]\n );\n\n const handleSurfaceClick = useCallback(() => {\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n }, [showPlayerControls]);\n\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\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 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={fullscreenHeader?.backAriaLabel ?? \"Back\"}\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 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={bufferingText}\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={playerVisible}\n isEnabled={isSubtitleEnabled && hasCurrentAudioPlaybackStarted}\n isPlayerHidden={shouldRenderPlayer && !playerVisible}\n playbackTimeStore={playbackTimeStore}\n subtitleCues={currentSubtitleCues}\n />\n\n {shouldShowInteractionOverlay ? (\n <div\n ref={interactionOverlayRef}\n className={cn(\n \"slide-interaction-overlay\",\n playerVisible && shouldRenderPlayer\n ? \"slide-interaction-overlay--with-player\"\n : \"slide-interaction-overlay--standalone\"\n )}\n onClick={stopOverlayPropagation}\n onPointerDown={stopOverlayPropagation}\n style={interactionOverlayStyle}\n >\n <InteractionOverlayCard\n content={String(activeInteractionElement?.content ?? \"\")}\n defaultButtonText={interactionDefaults.buttonText ?? \"\"}\n defaultInputText={interactionDefaults.inputText ?? \"\"}\n defaultSelectedValues={interactionDefaultSelectedValues}\n confirmButtonText={interactionTexts?.confirmButtonText}\n copyButtonText={interactionTexts?.copyButtonText}\n copiedButtonText={interactionTexts?.copiedButtonText}\n onSend={handleInteractionSend}\n readonly={isInteractionReadonly}\n title={\n interactionTexts?.title ??\n interactionTitle ??\n \"Submit the content below to continue.\"\n }\n />\n </div>\n ) : null}\n\n {shouldRenderPlayer ? (\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 !playerVisible && \"pointer-events-none opacity-0\"\n )}\n currentAudioIndex={currentAudioIndex}\n defaultPlaying\n isPlaybackPaused={shouldPausePlaybackForCustomAction}\n isAutoAdvanceEnabled={isAutoAdvanceEnabled}\n hasInteraction={Boolean(activeInteractionElement)}\n isInteractionOpen={isInteractionOverlayOpen}\n isSubtitleEnabled={isSubtitleEnabled}\n onAutoAdvanceToggle={setIsAutoAdvanceEnabled}\n onLoadingChange={handlePlayerLoadingChange}\n onPlaybackStarted={() => {\n setHasCurrentAudioPlaybackStarted(true);\n }}\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 onInteractionToggle={handleInteractionToggle}\n onNext={handleNext}\n onPrev={handlePrev}\n prevDisabled={!canGoPrev}\n showControls={playerVisible}\n texts={playerTexts}\n customActionContext={playerCustomActionContext}\n customActions={playerCustomActions}\n useAutoAdvanceToggle={shouldUseSilentStepAutoAdvanceToggle}\n />\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","InteractionOverlayCard","memo","content","title","defaultButtonText","defaultInputText","defaultSelectedValues","confirmButtonText","copyButtonText","copiedButtonText","onSend","readonly","jsxs","jsx","ContentRender","areStepElementListsEqual","prevElementList","nextElementList","element","index","nextElement","Slide","elementList","showPlayer","playerAlwaysVisible","playerClassName","fullscreenHeader","playerCustomActions","playerCustomActionPauseOnActive","bufferingText","interactionTitle","interactionTexts","playerTexts","playerAutoHideDelay","markerAutoAdvanceDelay","interactionDefaultValueOptions","onPlayerVisibilityChange","onMobileViewModeChange","onStepChange","enableIframeScaling","disableLoadingOverlay","className","onPointerDown","props","sectionRef","useRef","viewportRef","stageLayerRef","lastElementRef","playerHideTimerRef","autoAdvanceTimerRef","interactionAutoCloseTimerRef","interactionOverlayOpenTimerRef","interactionOverlayRef","prevRenderElementKeysRef","shouldScrollToBottomRef","pendingInteractionOverlayStepIndexRef","playbackResetKeyRef","appendedMarkerAdvanceStateRef","currentElementList","stepElementLists","slideElementList","currentIndex","audioList","currentAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement","canGoPrev","canGoNext","goPrev","goNext","useSlide","currentStepElement","useMemo","isSingleSlide","shouldRenderPlayer","currentAudioSequenceKeys","audioIndex","audioKey","isPlayerVisible","setIsPlayerVisible","useState","hasPlayerInteracted","setHasPlayerInteracted","isAutoAdvanceEnabled","setIsAutoAdvanceEnabled","currentAudioKey","setCurrentAudioKey","isAudioLoadingVisible","setIsAudioLoadingVisible","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","hasCurrentAudioPlaybackStarted","setHasCurrentAudioPlaybackStarted","isSubtitleEnabled","setIsSubtitleEnabled","isPlayerCustomActionActive","setIsPlayerCustomActionActive","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","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","playerVisible","shouldShowFullscreenHeader","shouldApplyFullscreenViewportPadding","shouldShowMobileFullscreenMask","isDesktopBrowserFullscreen","handleMobileViewModeSelect","useCallback","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","clearPlayerHideTimer","clearInteractionAutoCloseTimer","clearInteractionOverlayOpenTimer","clearAutoAdvanceTimer","resetAudioSequence","startCurrentAudioSequence","nextAudioKey","continueAfterInteraction","scheduleInteractionOverlayOpen","interactionElement","openOverlay","showPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","shouldBlockPlaybackForInteraction","useEffect","syncViewportFullscreenPreference","subscribeMobileDeviceChange","previousState","shouldAdvanceIntoAppendedMarker","shouldAutoAdvanceIntoAppendedMarker","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","hasPlaybackContextChanged","shouldInitializeAudioSequence","getPlaybackSequenceTransition","shouldOpenInteractionOverlayAfterAudio","shouldPresentOverlay","shouldPresentInteractionOverlay","interactionDefaults","shouldPreferResolvedInteractionInput","getInteractionDefaultValues","interactionDefaultSelectedValues","getInteractionDefaultSelectedValues","hasResolvedInteractionInput","isInteractionReadonly","shouldAutoContinueInteraction","shouldShowInteractionOverlay","handleInteractionSend","resolvedUserInput","prevElement","syncFullscreenState","interactionOverlayElement","updateSubtitleOffset","overlayHeight","resizeObserver","renderSlideElement","options","Fragment","IframeSandbox","renderSlideElementList","isActiveStep","visibleElementCount","lastVisibleElementIndex","lastVisibleIndex","isPreRenderedHtml","cn","handleFullscreen","target","scrollStageToBottom","stageLayerElement","handlePrev","handleNext","handlePlayerLoadingChange","loading","handlePlayerEnded","endedAudioKey","activeSequencePosition","audioSequenceKey","nextSequencePosition","nextStepIndex","nextStepElement","handleInteractionToggle","prevOpen","stopOverlayPropagation","handleSurfacePointerDown","handleSurfaceClick","currentRenderElementKeys","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","ChevronLeft","mountedStepStateIndex","LoadingOverlayCard","SubtitleOverlay","Player","previousEnabled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAMA,KAAuC,KACvCC,KAA4C,KAC5CC,KAAiD,KACjDC,KAAsC,IAgCtCC,KAAyBC;AAAA,EAC7B,CAAC;AAAA,IACC,SAAAC;A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A,kBACA,qBAAqBT;AAAA,kBACrB,iBAAiBiJ;AAAA,kBACjB,mBAAmB,MAAM;AACvB,oBAAAzI,GAAkC,EAAI;AAAA,kBACxC;AAAA,kBACA,sBAAsBuB,EAAkB;AAAA,kBACxC,kBAAkB,MAAM;AACtB,oBAAArB,GAAqB,CAACmK,MAAoB,CAACA,CAAe;AAAA,kBAC5D;AAAA,kBACA,cAAc,CAAC9L;AAAA,kBACf,SAASoK;AAAA,kBACT,cAAcR;AAAA,kBACd,cAAcxH;AAAA,kBACd,gBAAgBc;AAAA,kBAChB,yBAAyBxE,GAAY;AAAA,kBACrC,wBAAwBmF;AAAA,kBACxB,qBAAqB8G;AAAA,kBACrB,QAAQV;AAAA,kBACR,QAAQD;AAAA,kBACR,cAAc,CAACjK;AAAA,kBACf,cAAcyD;AAAA,kBACd,OAAO5F;AAAA,kBACP,qBAAqBwH;AAAA,kBACrB,eAAe7H;AAAA,kBACf,sBAAsBwI;AAAA,gBAAA;AAAA,cAAA,IAEtB;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACN;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=3e3,t={settingsTitle:"Settings",subtitleLabel:"Subtitles",subtitleToggleAriaLabel:"Toggle subtitles",screenLabel:"Screen",nonFullscreenLabel:"Non-fullscreen",fullscreenLabel:"Fullscreen",fullscreenHintText:"Rotate your screen for the best experience."};exports.DEFAULT_FULLSCREEN_HINT_DURATION_MS=e;exports.DEFAULT_SLIDE_PLAYER_TEXTS=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={settingsTitle:"Settings",subtitleLabel:"Subtitles",subtitleToggleAriaLabel:"Toggle subtitles",screenLabel:"Screen",nonFullscreenLabel:"Non-fullscreen",fullscreenLabel:"Fullscreen",fullscreenHintText:"Rotate your screen for the best experience."};exports.DEFAULT_SLIDE_PLAYER_TEXTS=e;
2
2
  //# sourceMappingURL=constants.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs.js","sources":["../../../src/components/Slide/constants.ts"],"sourcesContent":["export const DEFAULT_FULLSCREEN_HINT_DURATION_MS = 3000;\n\nexport const DEFAULT_SLIDE_PLAYER_TEXTS = {\n settingsTitle: \"Settings\",\n subtitleLabel: \"Subtitles\",\n subtitleToggleAriaLabel: \"Toggle subtitles\",\n screenLabel: \"Screen\",\n nonFullscreenLabel: \"Non-fullscreen\",\n fullscreenLabel: \"Fullscreen\",\n fullscreenHintText: \"Rotate your screen for the best experience.\",\n} as const;\n"],"names":["DEFAULT_FULLSCREEN_HINT_DURATION_MS","DEFAULT_SLIDE_PLAYER_TEXTS"],"mappings":"gFAAO,MAAMA,EAAsC,IAEtCC,EAA6B,CACxC,cAAe,WACf,cAAe,YACf,wBAAyB,mBACzB,YAAa,SACb,mBAAoB,iBACpB,gBAAiB,aACjB,mBAAoB,6CACtB"}
1
+ {"version":3,"file":"constants.cjs.js","sources":["../../../src/components/Slide/constants.ts"],"sourcesContent":["export const DEFAULT_FULLSCREEN_HINT_DURATION_MS = 3000;\n\nexport const DEFAULT_SLIDE_PLAYER_TEXTS = {\n settingsTitle: \"Settings\",\n subtitleLabel: \"Subtitles\",\n subtitleToggleAriaLabel: \"Toggle subtitles\",\n screenLabel: \"Screen\",\n nonFullscreenLabel: \"Non-fullscreen\",\n fullscreenLabel: \"Fullscreen\",\n fullscreenHintText: \"Rotate your screen for the best experience.\",\n} as const;\n"],"names":["DEFAULT_SLIDE_PLAYER_TEXTS"],"mappings":"gFAEO,MAAMA,EAA6B,CACxC,cAAe,WACf,cAAe,YACf,wBAAyB,mBACzB,YAAa,SACb,mBAAoB,iBACpB,gBAAiB,aACjB,mBAAoB,6CACtB"}
@@ -1,4 +1,4 @@
1
- const e = 3e3, l = {
1
+ const e = {
2
2
  settingsTitle: "Settings",
3
3
  subtitleLabel: "Subtitles",
4
4
  subtitleToggleAriaLabel: "Toggle subtitles",
@@ -8,7 +8,6 @@ const e = 3e3, l = {
8
8
  fullscreenHintText: "Rotate your screen for the best experience."
9
9
  };
10
10
  export {
11
- e as DEFAULT_FULLSCREEN_HINT_DURATION_MS,
12
- l as DEFAULT_SLIDE_PLAYER_TEXTS
11
+ e as DEFAULT_SLIDE_PLAYER_TEXTS
13
12
  };
14
13
  //# sourceMappingURL=constants.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.es.js","sources":["../../../src/components/Slide/constants.ts"],"sourcesContent":["export const DEFAULT_FULLSCREEN_HINT_DURATION_MS = 3000;\n\nexport const DEFAULT_SLIDE_PLAYER_TEXTS = {\n settingsTitle: \"Settings\",\n subtitleLabel: \"Subtitles\",\n subtitleToggleAriaLabel: \"Toggle subtitles\",\n screenLabel: \"Screen\",\n nonFullscreenLabel: \"Non-fullscreen\",\n fullscreenLabel: \"Fullscreen\",\n fullscreenHintText: \"Rotate your screen for the best experience.\",\n} as const;\n"],"names":["DEFAULT_FULLSCREEN_HINT_DURATION_MS","DEFAULT_SLIDE_PLAYER_TEXTS"],"mappings":"AAAO,MAAMA,IAAsC,KAEtCC,IAA6B;AAAA,EACxC,eAAe;AAAA,EACf,eAAe;AAAA,EACf,yBAAyB;AAAA,EACzB,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,oBAAoB;AACtB;"}
1
+ {"version":3,"file":"constants.es.js","sources":["../../../src/components/Slide/constants.ts"],"sourcesContent":["export const DEFAULT_FULLSCREEN_HINT_DURATION_MS = 3000;\n\nexport const DEFAULT_SLIDE_PLAYER_TEXTS = {\n settingsTitle: \"Settings\",\n subtitleLabel: \"Subtitles\",\n subtitleToggleAriaLabel: \"Toggle subtitles\",\n screenLabel: \"Screen\",\n nonFullscreenLabel: \"Non-fullscreen\",\n fullscreenLabel: \"Fullscreen\",\n fullscreenHintText: \"Rotate your screen for the best experience.\",\n} as const;\n"],"names":["DEFAULT_SLIDE_PLAYER_TEXTS"],"mappings":"AAEO,MAAMA,IAA6B;AAAA,EACxC,eAAe;AAAA,EACf,eAAe;AAAA,EACf,yBAAyB;AAAA,EACzB,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,oBAAoB;AACtB;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react"),N=require("./diff-utils.cjs.js"),C=require("./utils/streamingNavigation.cjs.js"),P=e=>e.filter(n=>n.is_marker),w=e=>e.reduce((n,t,s)=>(t.is_marker&&n.push(s),n),[]),S=e=>!!(e?.is_speakable&&(e.audio_url||(e.audio_segments?.length??0)>0)),B=(e=[])=>e.length>0&&!e.some(n=>n.is_final),G=(e,n)=>{const t=e;return t.element_bid||t.blockBid||t.generated_block_bid||`${e.type}:${String(e.sequence_number??n)}`},H=e=>e.reduce((n,t,s)=>{if(S(t)){const r=t.audio_segments??[],c=r.length>0;n.push({audioKey:G(t,s),sequenceNumber:t.sequence_number,audioUrl:c?"":t.audio_url,audioSegments:r,isAudioStreaming:B(r),element:t})}return n},[]),K=e=>{const n=new Map;let t=0;return e.forEach((s,r)=>{S(s)&&(n.set(r,t),t+=1)}),n},U=(e,n,t)=>n.reduce((s,r,c)=>{const d=n[c+1]??e.length,l=[];for(let a=r;a<d;a+=1){const f=e[a];if(!S(f))continue;const o=t.get(a);o!=null&&l.push(o)}return s.set(c,l),s},new Map),b=e=>{const n=e.findIndex(t=>t.is_renderable===!0);return n>=0?n:e.findIndex(t=>t.is_renderable!==!1)},h=e=>({...e,is_renderable:!0}),p=(e,n)=>n<0?[]:e.slice(0,n+1).reduce((t,s)=>{if(s.type==="interaction")return t;const r=h(s);return r.type==="diff"?N.applyDiffElement(t,r)??[...t,r]:s.is_new?[r]:t.length===0?[r]:[...t,r]},[]),$=e=>e.map((n,t)=>p(e,t)),j=(e,n,t)=>{if(t<0)return!1;const s=n[t];if(typeof s!="number")return!1;const r=n[t+1]??e.length;for(let c=s;c<r;c+=1)if(e[c]?.is_speakable)return!0;return!1},z=(e,n)=>e.length===n.length&&e.every((t,s)=>t===n[s]),D=(e,n)=>e.length===n.length&&e.every((t,s)=>t===n[s]),L=(e=[])=>{const n=u.useRef(e),t=u.useRef([]),s=u.useMemo(()=>z(n.current,e)?n.current:(n.current=e,e),[e]),r=u.useMemo(()=>P(s),[s]),c=u.useRef(r),d=u.useMemo(()=>w(s),[s]),l=u.useMemo(()=>H(s),[s]),a=u.useMemo(()=>K(s),[s]),f=u.useMemo(()=>U(s,d,a),[a,d,s]),[o,g]=u.useState(()=>b(r));u.useEffect(()=>{const i=c.current;g(R=>{const M=C.resolveNextSlideIndexAfterMarkerAppend({previousIndex:R,previousSlideElementList:i,nextSlideElementList:r});return M>=0?M:b(r)}),c.current=r},[r]);const x=u.useCallback(()=>{g(i=>i<=0?Math.max(i,0):Math.max(i-1,0))},[]),_=u.useCallback(()=>{g(i=>i<0?i:Math.min(i+1,r.length-1))},[r.length]),E=o>0,A=o>=0&&o<r.length-1,m=u.useMemo(()=>{if(o<0)return;const i=r[o];if(i)return h(i)},[o,r]),I=u.useMemo(()=>p(r,o),[o,r]),k=u.useMemo(()=>$(r),[r]),y=u.useMemo(()=>{const i=f.get(o)??[];return D(t.current,i)?t.current:(t.current=i,i)},[o,f]),q=u.useMemo(()=>j(s,d,o),[o,d,s]),v=u.useMemo(()=>m?.type==="interaction"?m:void 0,[m]);return{currentElementList:I,stepElementLists:k,slideElementList:r,currentIndex:o,audioList:l,currentAudioSequenceIndexes:y,currentStepHasSpeakableElement:q,currentInteractionElement:v,canGoPrev:E,canGoNext:A,handlePrev:x,handleNext:_}};exports.default=L;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react"),C=require("./diff-utils.cjs.js"),P=require("./utils/streamingNavigation.cjs.js"),w=e=>e.filter(n=>n.is_marker),U=e=>e.reduce((n,t,r)=>(t.is_marker&&n.push(r),n),[]),S=e=>!!(e?.is_speakable&&(e.audio_url||(e.audio_segments?.length??0)>0)),B=(e=[])=>e.length>0&&!e.some(n=>n.is_final),p=e=>{const n=e.audio_url?.trim()??"",t=e.audio_segments??[];return{audioUrl:n,audioSegments:t,isAudioStreaming:!n&&B(t)}},G=(e,n)=>{const t=e;return t.element_bid||t.blockBid||t.generated_block_bid||`${e.type}:${String(e.sequence_number??n)}`},H=e=>e.reduce((n,t,r)=>{if(S(t)){const{audioUrl:s,audioSegments:c,isAudioStreaming:a}=p(t);n.push({audioKey:G(t,r),sequenceNumber:t.sequence_number,audioUrl:s,audioSegments:c,isAudioStreaming:a,element:t})}return n},[]),K=e=>{const n=new Map;let t=0;return e.forEach((r,s)=>{S(r)&&(n.set(s,t),t+=1)}),n},$=(e,n,t)=>n.reduce((r,s,c)=>{const a=n[c+1]??e.length,l=[];for(let d=s;d<a;d+=1){const f=e[d];if(!S(f))continue;const o=t.get(d);o!=null&&l.push(o)}return r.set(c,l),r},new Map),b=e=>{const n=e.findIndex(t=>t.is_renderable===!0);return n>=0?n:e.findIndex(t=>t.is_renderable!==!1)},h=e=>({...e,is_renderable:!0}),x=(e,n)=>n<0?[]:e.slice(0,n+1).reduce((t,r)=>{if(r.type==="interaction")return t;const s=h(r);return s.type==="diff"?C.applyDiffElement(t,s)??[...t,s]:r.is_new?[s]:t.length===0?[s]:[...t,s]},[]),j=e=>e.map((n,t)=>x(e,t)),D=(e,n,t)=>{if(t<0)return!1;const r=n[t];if(typeof r!="number")return!1;const s=n[t+1]??e.length;for(let c=r;c<s;c+=1)if(e[c]?.is_speakable)return!0;return!1},L=(e,n)=>e.length===n.length&&e.every((t,r)=>t===n[r]),O=(e,n)=>e.length===n.length&&e.every((t,r)=>t===n[r]),T=(e=[])=>{const n=u.useRef(e),t=u.useRef([]),r=u.useMemo(()=>L(n.current,e)?n.current:(n.current=e,e),[e]),s=u.useMemo(()=>w(r),[r]),c=u.useRef(s),a=u.useMemo(()=>U(r),[r]),l=u.useMemo(()=>H(r),[r]),d=u.useMemo(()=>K(r),[r]),f=u.useMemo(()=>$(r,a,d),[d,a,r]),[o,m]=u.useState(()=>b(s));u.useEffect(()=>{const i=c.current;m(N=>{const M=P.resolveNextSlideIndexAfterMarkerAppend({previousIndex:N,previousSlideElementList:i,nextSlideElementList:s});return M>=0?M:b(s)}),c.current=s},[s]);const _=u.useCallback(()=>{m(i=>i<=0?Math.max(i,0):Math.max(i-1,0))},[]),E=u.useCallback(()=>{m(i=>i<0?i:Math.min(i+1,s.length-1))},[s.length]),I=o>0,A=o>=0&&o<s.length-1,g=u.useMemo(()=>{if(o<0)return;const i=s[o];if(i)return h(i)},[o,s]),k=u.useMemo(()=>x(s,o),[o,s]),v=u.useMemo(()=>j(s),[s]),y=u.useMemo(()=>{const i=f.get(o)??[];return O(t.current,i)?t.current:(t.current=i,i)},[o,f]),q=u.useMemo(()=>D(r,a,o),[o,a,r]),R=u.useMemo(()=>g?.type==="interaction"?g:void 0,[g]);return{currentElementList:k,stepElementLists:v,slideElementList:s,currentIndex:o,audioList:l,currentAudioSequenceIndexes:y,currentStepHasSpeakableElement:q,currentInteractionElement:R,canGoPrev:I,canGoNext:A,handlePrev:_,handleNext:E}};exports.default=T;exports.resolveSlideAudioItemSource=p;
2
2
  //# sourceMappingURL=useSlide.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSlide.cjs.js","sources":["../../../src/components/Slide/useSlide.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { applyDiffElement } from \"./diff-utils\";\nimport type { Element, ElementAudioSegment } from \"./types\";\nimport { resolveNextSlideIndexAfterMarkerAppend } from \"./utils/streamingNavigation\";\n\nexport interface SlideAudioItem {\n audioKey?: string;\n sequenceNumber?: number;\n audioUrl?: string;\n audioSegments?: ElementAudioSegment[];\n isAudioStreaming?: boolean;\n element?: Element;\n}\n\nexport interface UseSlideResult {\n currentElementList: Element[];\n stepElementLists: Element[][];\n slideElementList: Element[];\n currentIndex: number;\n audioList: SlideAudioItem[];\n currentAudioSequenceIndexes: number[];\n currentStepHasSpeakableElement: boolean;\n currentInteractionElement?: Element;\n canGoPrev: boolean;\n canGoNext: boolean;\n handlePrev: () => void;\n handleNext: () => void;\n}\n\nconst getMarkerElementList = (elementList: Element[]) =>\n elementList.filter((element) => element.is_marker);\n\nconst getMarkerElementIndexes = (elementList: Element[]) =>\n elementList.reduce<number[]>((indexes, element, index) => {\n if (element.is_marker) {\n indexes.push(index);\n }\n\n return indexes;\n }, []);\n\nconst hasPlayableAudio = (element?: Element) =>\n Boolean(\n element?.is_speakable &&\n (element.audio_url || (element.audio_segments?.length ?? 0) > 0)\n );\n\nconst isStreamingAudio = (segments: ElementAudioSegment[] = []) =>\n segments.length > 0 && !segments.some((segment) => segment.is_final);\n\nconst getElementAudioKey = (element: Element, index: number) => {\n const candidateElement = element as Element & {\n element_bid?: string;\n blockBid?: string;\n generated_block_bid?: string;\n };\n\n return (\n candidateElement.element_bid ||\n candidateElement.blockBid ||\n candidateElement.generated_block_bid ||\n `${element.type}:${String(element.sequence_number ?? index)}`\n );\n};\n\nconst getAudioList = (elementList: Element[]) =>\n elementList.reduce<SlideAudioItem[]>((list, element, elementIndex) => {\n if (hasPlayableAudio(element)) {\n const normalizedAudioSegments = element.audio_segments ?? [];\n const hasAudioSegments = normalizedAudioSegments.length > 0;\n\n list.push({\n audioKey: getElementAudioKey(element, elementIndex),\n sequenceNumber: element.sequence_number,\n // Keep one canonical source to avoid duplicated playback resets.\n // When streaming segments exist, keep playback on the segment source.\n audioUrl: hasAudioSegments ? \"\" : element.audio_url,\n audioSegments: normalizedAudioSegments,\n isAudioStreaming: isStreamingAudio(normalizedAudioSegments),\n element,\n });\n }\n\n return list;\n }, []);\n\nconst getAudioIndexMap = (elementList: Element[]) => {\n const audioIndexMap = new Map<number, number>();\n let audioIndex = 0;\n\n elementList.forEach((element, index) => {\n if (hasPlayableAudio(element)) {\n audioIndexMap.set(index, audioIndex);\n audioIndex += 1;\n }\n });\n\n return audioIndexMap;\n};\n\nconst getSlideAudioSequenceMap = (\n elementList: Element[],\n markerElementIndexes: number[],\n audioIndexMap: Map<number, number>\n) =>\n markerElementIndexes.reduce<Map<number, number[]>>(\n (sequenceMap, startIndex, slideIndex) => {\n const nextMarkerIndex =\n markerElementIndexes[slideIndex + 1] ?? elementList.length;\n const sequenceIndexes: number[] = [];\n\n for (let index = startIndex; index < nextMarkerIndex; index += 1) {\n const element = elementList[index];\n\n if (!hasPlayableAudio(element)) {\n continue;\n }\n\n const audioIndex = audioIndexMap.get(index);\n\n if (audioIndex == null) {\n continue;\n }\n\n sequenceIndexes.push(audioIndex);\n }\n\n sequenceMap.set(slideIndex, sequenceIndexes);\n return sequenceMap;\n },\n new Map<number, number[]>()\n );\n\nconst getInitialSlideIndex = (slideElementList: Element[]) => {\n const visibleIndex = slideElementList.findIndex(\n (element) => element.is_renderable === true\n );\n\n if (visibleIndex >= 0) {\n return visibleIndex;\n }\n\n return slideElementList.findIndex(\n (element) => element.is_renderable !== false\n );\n};\n\nconst getVisibleElement = (element: Element): Element => ({\n ...element,\n is_renderable: true,\n});\n\nconst getCurrentElementList = (\n slideElementList: Element[],\n currentIndex: number\n) => {\n if (currentIndex < 0) {\n return [];\n }\n\n return slideElementList\n .slice(0, currentIndex + 1)\n .reduce<Element[]>((currentList, element) => {\n if (element.type === \"interaction\") {\n return currentList;\n }\n\n const visibleElement = getVisibleElement(element);\n\n if (visibleElement.type === \"diff\") {\n const nextList = applyDiffElement(currentList, visibleElement);\n\n return nextList ?? [...currentList, visibleElement];\n }\n\n if (element.is_new) {\n return [visibleElement];\n }\n\n if (currentList.length === 0) {\n return [visibleElement];\n }\n\n return [...currentList, visibleElement];\n }, []);\n};\n\nconst getStepElementLists = (slideElementList: Element[]) =>\n slideElementList.map((_, index) =>\n getCurrentElementList(slideElementList, index)\n );\n\nconst getStepHasSpeakableElement = (\n elementList: Element[],\n markerElementIndexes: number[],\n currentIndex: number\n) => {\n if (currentIndex < 0) {\n return false;\n }\n\n const startIndex = markerElementIndexes[currentIndex];\n\n if (typeof startIndex !== \"number\") {\n return false;\n }\n\n const nextMarkerIndex =\n markerElementIndexes[currentIndex + 1] ?? elementList.length;\n\n for (let index = startIndex; index < nextMarkerIndex; index += 1) {\n if (elementList[index]?.is_speakable) {\n return true;\n }\n }\n\n return false;\n};\n\nconst hasSameElementReferences = (\n prevElementList: Element[],\n nextElementList: Element[]\n) =>\n prevElementList.length === nextElementList.length &&\n prevElementList.every((element, index) => element === nextElementList[index]);\n\nconst hasSameNumberValues = (prevValues: number[], nextValues: number[]) =>\n prevValues.length === nextValues.length &&\n prevValues.every((value, index) => value === nextValues[index]);\n\nconst useSlide = (elementList: Element[] = []): UseSlideResult => {\n const stableElementListRef = useRef(elementList);\n const stableCurrentAudioSequenceIndexesRef = useRef<number[]>([]);\n const stableElementList = useMemo(() => {\n if (hasSameElementReferences(stableElementListRef.current, elementList)) {\n return stableElementListRef.current;\n }\n\n // Reuse the previous wrapper array when the element references are unchanged.\n stableElementListRef.current = elementList;\n return elementList;\n }, [elementList]);\n const slideElementList = useMemo(\n () => getMarkerElementList(stableElementList),\n [stableElementList]\n );\n const previousSlideElementListRef = useRef(slideElementList);\n const markerElementIndexes = useMemo(\n () => getMarkerElementIndexes(stableElementList),\n [stableElementList]\n );\n const audioList = useMemo(\n () => getAudioList(stableElementList),\n [stableElementList]\n );\n const audioIndexMap = useMemo(\n () => getAudioIndexMap(stableElementList),\n [stableElementList]\n );\n const slideAudioSequenceMap = useMemo(\n () =>\n getSlideAudioSequenceMap(\n stableElementList,\n markerElementIndexes,\n audioIndexMap\n ),\n [audioIndexMap, markerElementIndexes, stableElementList]\n );\n const [currentIndex, setCurrentIndex] = useState(() =>\n getInitialSlideIndex(slideElementList)\n );\n\n useEffect(() => {\n const previousSlideElementList = previousSlideElementListRef.current;\n\n setCurrentIndex((prevIndex) => {\n const resolvedNextIndex = resolveNextSlideIndexAfterMarkerAppend({\n previousIndex: prevIndex,\n previousSlideElementList,\n nextSlideElementList: slideElementList,\n });\n\n if (resolvedNextIndex >= 0) {\n return resolvedNextIndex;\n }\n\n return getInitialSlideIndex(slideElementList);\n });\n\n previousSlideElementListRef.current = slideElementList;\n }, [slideElementList]);\n\n const handlePrev = useCallback(() => {\n setCurrentIndex((prevIndex) => {\n if (prevIndex <= 0) {\n return Math.max(prevIndex, 0);\n }\n\n return Math.max(prevIndex - 1, 0);\n });\n }, []);\n\n const handleNext = useCallback(() => {\n setCurrentIndex((prevIndex) => {\n if (prevIndex < 0) {\n return prevIndex;\n }\n\n return Math.min(prevIndex + 1, slideElementList.length - 1);\n });\n }, [slideElementList.length]);\n\n const canGoPrev = currentIndex > 0;\n const canGoNext =\n currentIndex >= 0 && currentIndex < slideElementList.length - 1;\n const currentStepElement = useMemo(() => {\n if (currentIndex < 0) {\n return undefined;\n }\n\n const element = slideElementList[currentIndex];\n\n if (!element) {\n return undefined;\n }\n\n return getVisibleElement(element);\n }, [currentIndex, slideElementList]);\n const currentElementList = useMemo(\n () => getCurrentElementList(slideElementList, currentIndex),\n [currentIndex, slideElementList]\n );\n const stepElementLists = useMemo(\n () => getStepElementLists(slideElementList),\n [slideElementList]\n );\n const currentAudioSequenceIndexes = useMemo(() => {\n const nextAudioSequenceIndexes =\n slideAudioSequenceMap.get(currentIndex) ?? [];\n\n if (\n hasSameNumberValues(\n stableCurrentAudioSequenceIndexesRef.current,\n nextAudioSequenceIndexes\n )\n ) {\n return stableCurrentAudioSequenceIndexesRef.current;\n }\n\n stableCurrentAudioSequenceIndexesRef.current = nextAudioSequenceIndexes;\n\n return nextAudioSequenceIndexes;\n }, [currentIndex, slideAudioSequenceMap]);\n const currentStepHasSpeakableElement = useMemo(\n () =>\n getStepHasSpeakableElement(\n stableElementList,\n markerElementIndexes,\n currentIndex\n ),\n [currentIndex, markerElementIndexes, stableElementList]\n );\n const currentInteractionElement = useMemo(\n () =>\n currentStepElement?.type === \"interaction\"\n ? currentStepElement\n : undefined,\n [currentStepElement]\n );\n\n return {\n currentElementList,\n stepElementLists,\n slideElementList,\n currentIndex,\n audioList,\n currentAudioSequenceIndexes,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n canGoPrev,\n canGoNext,\n handlePrev,\n handleNext,\n };\n};\n\nexport default useSlide;\n"],"names":["getMarkerElementList","elementList","element","getMarkerElementIndexes","indexes","index","hasPlayableAudio","isStreamingAudio","segments","segment","getElementAudioKey","candidateElement","getAudioList","list","elementIndex","normalizedAudioSegments","hasAudioSegments","getAudioIndexMap","audioIndexMap","audioIndex","getSlideAudioSequenceMap","markerElementIndexes","sequenceMap","startIndex","slideIndex","nextMarkerIndex","sequenceIndexes","getInitialSlideIndex","slideElementList","visibleIndex","getVisibleElement","getCurrentElementList","currentIndex","currentList","visibleElement","applyDiffElement","getStepElementLists","_","getStepHasSpeakableElement","hasSameElementReferences","prevElementList","nextElementList","hasSameNumberValues","prevValues","nextValues","value","useSlide","stableElementListRef","useRef","stableCurrentAudioSequenceIndexesRef","stableElementList","useMemo","previousSlideElementListRef","audioList","slideAudioSequenceMap","setCurrentIndex","useState","useEffect","previousSlideElementList","prevIndex","resolvedNextIndex","resolveNextSlideIndexAfterMarkerAppend","handlePrev","useCallback","handleNext","canGoPrev","canGoNext","currentStepElement","currentElementList","stepElementLists","currentAudioSequenceIndexes","nextAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement"],"mappings":"sNA8BMA,EAAwBC,GAC5BA,EAAY,OAAQC,GAAYA,EAAQ,SAAS,EAE7CC,EAA2BF,GAC/BA,EAAY,OAAiB,CAACG,EAASF,EAASG,KAC1CH,EAAQ,WACVE,EAAQ,KAAKC,CAAK,EAGbD,GACN,EAAE,EAEDE,EAAoBJ,GACxB,GACEA,GAAS,eACRA,EAAQ,YAAcA,EAAQ,gBAAgB,QAAU,GAAK,IAG5DK,EAAmB,CAACC,EAAkC,KAC1DA,EAAS,OAAS,GAAK,CAACA,EAAS,K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AC,EACA,iBAAAzC,EACA,aAAAI,EACA,UAAAqB,EACA,4BAAAiB,EACA,+BAAAE,EACA,0BAAAC,EACA,UAAAR,EACA,UAAAC,EACA,WAAAJ,EACA,WAAAE,CAAA,CAEJ"}
1
+ {"version":3,"file":"useSlide.cjs.js","sources":["../../../src/components/Slide/useSlide.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { applyDiffElement } from \"./diff-utils\";\nimport type { Element, ElementAudioSegment } from \"./types\";\nimport { resolveNextSlideIndexAfterMarkerAppend } from \"./utils/streamingNavigation\";\n\nexport interface SlideAudioItem {\n audioKey?: string;\n sequenceNumber?: number;\n audioUrl?: string;\n audioSegments?: ElementAudioSegment[];\n isAudioStreaming?: boolean;\n element?: Element;\n}\n\nexport interface UseSlideResult {\n currentElementList: Element[];\n stepElementLists: Element[][];\n slideElementList: Element[];\n currentIndex: number;\n audioList: SlideAudioItem[];\n currentAudioSequenceIndexes: number[];\n currentStepHasSpeakableElement: boolean;\n currentInteractionElement?: Element;\n canGoPrev: boolean;\n canGoNext: boolean;\n handlePrev: () => void;\n handleNext: () => void;\n}\n\nconst getMarkerElementList = (elementList: Element[]) =>\n elementList.filter((element) => element.is_marker);\n\nconst getMarkerElementIndexes = (elementList: Element[]) =>\n elementList.reduce<number[]>((indexes, element, index) => {\n if (element.is_marker) {\n indexes.push(index);\n }\n\n return indexes;\n }, []);\n\nconst hasPlayableAudio = (element?: Element) =>\n Boolean(\n element?.is_speakable &&\n (element.audio_url || (element.audio_segments?.length ?? 0) > 0)\n );\n\nconst isStreamingAudio = (segments: ElementAudioSegment[] = []) =>\n segments.length > 0 && !segments.some((segment) => segment.is_final);\n\nexport const resolveSlideAudioItemSource = (element: Element) => {\n const audioUrl = element.audio_url?.trim() ?? \"\";\n const audioSegments = element.audio_segments ?? [];\n\n return {\n audioUrl,\n audioSegments,\n isAudioStreaming: !audioUrl && isStreamingAudio(audioSegments),\n };\n};\n\nconst getElementAudioKey = (element: Element, index: number) => {\n const candidateElement = element as Element & {\n element_bid?: string;\n blockBid?: string;\n generated_block_bid?: string;\n };\n\n return (\n candidateElement.element_bid ||\n candidateElement.blockBid ||\n candidateElement.generated_block_bid ||\n `${element.type}:${String(element.sequence_number ?? index)}`\n );\n};\n\nconst getAudioList = (elementList: Element[]) =>\n elementList.reduce<SlideAudioItem[]>((list, element, elementIndex) => {\n if (hasPlayableAudio(element)) {\n const { audioUrl, audioSegments, isAudioStreaming } =\n resolveSlideAudioItemSource(element);\n\n list.push({\n audioKey: getElementAudioKey(element, elementIndex),\n sequenceNumber: element.sequence_number,\n // Keep the completed URL available once it arrives so loading can end.\n audioUrl,\n audioSegments,\n isAudioStreaming,\n element,\n });\n }\n\n return list;\n }, []);\n\nconst getAudioIndexMap = (elementList: Element[]) => {\n const audioIndexMap = new Map<number, number>();\n let audioIndex = 0;\n\n elementList.forEach((element, index) => {\n if (hasPlayableAudio(element)) {\n audioIndexMap.set(index, audioIndex);\n audioIndex += 1;\n }\n });\n\n return audioIndexMap;\n};\n\nconst getSlideAudioSequenceMap = (\n elementList: Element[],\n markerElementIndexes: number[],\n audioIndexMap: Map<number, number>\n) =>\n markerElementIndexes.reduce<Map<number, number[]>>(\n (sequenceMap, startIndex, slideIndex) => {\n const nextMarkerIndex =\n markerElementIndexes[slideIndex + 1] ?? elementList.length;\n const sequenceIndexes: number[] = [];\n\n for (let index = startIndex; index < nextMarkerIndex; index += 1) {\n const element = elementList[index];\n\n if (!hasPlayableAudio(element)) {\n continue;\n }\n\n const audioIndex = audioIndexMap.get(index);\n\n if (audioIndex == null) {\n continue;\n }\n\n sequenceIndexes.push(audioIndex);\n }\n\n sequenceMap.set(slideIndex, sequenceIndexes);\n return sequenceMap;\n },\n new Map<number, number[]>()\n );\n\nconst getInitialSlideIndex = (slideElementList: Element[]) => {\n const visibleIndex = slideElementList.findIndex(\n (element) => element.is_renderable === true\n );\n\n if (visibleIndex >= 0) {\n return visibleIndex;\n }\n\n return slideElementList.findIndex(\n (element) => element.is_renderable !== false\n );\n};\n\nconst getVisibleElement = (element: Element): Element => ({\n ...element,\n is_renderable: true,\n});\n\nconst getCurrentElementList = (\n slideElementList: Element[],\n currentIndex: number\n) => {\n if (currentIndex < 0) {\n return [];\n }\n\n return slideElementList\n .slice(0, currentIndex + 1)\n .reduce<Element[]>((currentList, element) => {\n if (element.type === \"interaction\") {\n return currentList;\n }\n\n const visibleElement = getVisibleElement(element);\n\n if (visibleElement.type === \"diff\") {\n const nextList = applyDiffElement(currentList, visibleElement);\n\n return nextList ?? [...currentList, visibleElement];\n }\n\n if (element.is_new) {\n return [visibleElement];\n }\n\n if (currentList.length === 0) {\n return [visibleElement];\n }\n\n return [...currentList, visibleElement];\n }, []);\n};\n\nconst getStepElementLists = (slideElementList: Element[]) =>\n slideElementList.map((_, index) =>\n getCurrentElementList(slideElementList, index)\n );\n\nconst getStepHasSpeakableElement = (\n elementList: Element[],\n markerElementIndexes: number[],\n currentIndex: number\n) => {\n if (currentIndex < 0) {\n return false;\n }\n\n const startIndex = markerElementIndexes[currentIndex];\n\n if (typeof startIndex !== \"number\") {\n return false;\n }\n\n const nextMarkerIndex =\n markerElementIndexes[currentIndex + 1] ?? elementList.length;\n\n for (let index = startIndex; index < nextMarkerIndex; index += 1) {\n if (elementList[index]?.is_speakable) {\n return true;\n }\n }\n\n return false;\n};\n\nconst hasSameElementReferences = (\n prevElementList: Element[],\n nextElementList: Element[]\n) =>\n prevElementList.length === nextElementList.length &&\n prevElementList.every((element, index) => element === nextElementList[index]);\n\nconst hasSameNumberValues = (prevValues: number[], nextValues: number[]) =>\n prevValues.length === nextValues.length &&\n prevValues.every((value, index) => value === nextValues[index]);\n\nconst useSlide = (elementList: Element[] = []): UseSlideResult => {\n const stableElementListRef = useRef(elementList);\n const stableCurrentAudioSequenceIndexesRef = useRef<number[]>([]);\n const stableElementList = useMemo(() => {\n if (hasSameElementReferences(stableElementListRef.current, elementList)) {\n return stableElementListRef.current;\n }\n\n // Reuse the previous wrapper array when the element references are unchanged.\n stableElementListRef.current = elementList;\n return elementList;\n }, [elementList]);\n const slideElementList = useMemo(\n () => getMarkerElementList(stableElementList),\n [stableElementList]\n );\n const previousSlideElementListRef = useRef(slideElementList);\n const markerElementIndexes = useMemo(\n () => getMarkerElementIndexes(stableElementList),\n [stableElementList]\n );\n const audioList = useMemo(\n () => getAudioList(stableElementList),\n [stableElementList]\n );\n const audioIndexMap = useMemo(\n () => getAudioIndexMap(stableElementList),\n [stableElementList]\n );\n const slideAudioSequenceMap = useMemo(\n () =>\n getSlideAudioSequenceMap(\n stableElementList,\n markerElementIndexes,\n audioIndexMap\n ),\n [audioIndexMap, markerElementIndexes, stableElementList]\n );\n const [currentIndex, setCurrentIndex] = useState(() =>\n getInitialSlideIndex(slideElementList)\n );\n\n useEffect(() => {\n const previousSlideElementList = previousSlideElementListRef.current;\n\n setCurrentIndex((prevIndex) => {\n const resolvedNextIndex = resolveNextSlideIndexAfterMarkerAppend({\n previousIndex: prevIndex,\n previousSlideElementList,\n nextSlideElementList: slideElementList,\n });\n\n if (resolvedNextIndex >= 0) {\n return resolvedNextIndex;\n }\n\n return getInitialSlideIndex(slideElementList);\n });\n\n previousSlideElementListRef.current = slideElementList;\n }, [slideElementList]);\n\n const handlePrev = useCallback(() => {\n setCurrentIndex((prevIndex) => {\n if (prevIndex <= 0) {\n return Math.max(prevIndex, 0);\n }\n\n return Math.max(prevIndex - 1, 0);\n });\n }, []);\n\n const handleNext = useCallback(() => {\n setCurrentIndex((prevIndex) => {\n if (prevIndex < 0) {\n return prevIndex;\n }\n\n return Math.min(prevIndex + 1, slideElementList.length - 1);\n });\n }, [slideElementList.length]);\n\n const canGoPrev = currentIndex > 0;\n const canGoNext =\n currentIndex >= 0 && currentIndex < slideElementList.length - 1;\n const currentStepElement = useMemo(() => {\n if (currentIndex < 0) {\n return undefined;\n }\n\n const element = slideElementList[currentIndex];\n\n if (!element) {\n return undefined;\n }\n\n return getVisibleElement(element);\n }, [currentIndex, slideElementList]);\n const currentElementList = useMemo(\n () => getCurrentElementList(slideElementList, currentIndex),\n [currentIndex, slideElementList]\n );\n const stepElementLists = useMemo(\n () => getStepElementLists(slideElementList),\n [slideElementList]\n );\n const currentAudioSequenceIndexes = useMemo(() => {\n const nextAudioSequenceIndexes =\n slideAudioSequenceMap.get(currentIndex) ?? [];\n\n if (\n hasSameNumberValues(\n stableCurrentAudioSequenceIndexesRef.current,\n nextAudioSequenceIndexes\n )\n ) {\n return stableCurrentAudioSequenceIndexesRef.current;\n }\n\n stableCurrentAudioSequenceIndexesRef.current = nextAudioSequenceIndexes;\n\n return nextAudioSequenceIndexes;\n }, [currentIndex, slideAudioSequenceMap]);\n const currentStepHasSpeakableElement = useMemo(\n () =>\n getStepHasSpeakableElement(\n stableElementList,\n markerElementIndexes,\n currentIndex\n ),\n [currentIndex, markerElementIndexes, stableElementList]\n );\n const currentInteractionElement = useMemo(\n () =>\n currentStepElement?.type === \"interaction\"\n ? currentStepElement\n : undefined,\n [currentStepElement]\n );\n\n return {\n currentElementList,\n stepElementLists,\n slideElementList,\n currentIndex,\n audioList,\n currentAudioSequenceIndexes,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n canGoPrev,\n canGoNext,\n handlePrev,\n handleNext,\n };\n};\n\nexport default useSlide;\n"],"names":["getMarkerElementList","elementList","element","getMarkerElementIndexes","indexes","index","hasPlayableAudio","isStreamingAudio","segments","segment","resolveSlideAudioItemSource","audioUrl","audioSegments","getElementAudioKey","candidateElement","getAudioList","list","elementIndex","isAudioStreaming","getAudioIndexMap","audioIndexMap","audioIndex","getSlideAudioSequenceMap","markerElementIndexes","sequenceMap","startIndex","slideIndex","nextMarkerIndex","sequenceIndexes","getInitialSlideIndex","slideElementList","visibleIndex","getVisibleElement","getCurrentElementList","currentIndex","currentList","visibleElement","applyDiffElement","getStepElementLists","_","getStepHasSpeakableElement","hasSameElementReferences","prevElementList","nextElementList","hasSameNumberValues","prevValues","nextValues","value","useSlide","stableElementListRef","useRef","stableCurrentAudioSequenceIndexesRef","stableElementList","useMemo","previousSlideElementListRef","audioList","slideAudioSequenceMap","setCurrentIndex","useState","useEffect","previousSlideElementList","prevIndex","resolvedNextIndex","resolveNextSlideIndexAfterMarkerAppend","handlePrev","useCallback","handleNext","canGoPrev","canGoNext","currentStepElement","currentElementList","stepElementLists","currentAudioSequenceIndexes","nextAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement"],"mappings":"sNA8BMA,EAAwBC,GAC5BA,EAAY,OAAQC,GAAYA,EAAQ,SAAS,EAE7CC,EAA2BF,GAC/BA,EAAY,OAAiB,CAACG,EAASF,EAASG,KAC1CH,EAAQ,WACVE,EAAQ,KAAKC,CAAK,EAGbD,GACN,EAAE,EAEDE,EAAoBJ,GACxB,GACEA,GAAS,eACRA,EAAQ,YAAcA,EAAQ,gBAAgB,QAAU,GAAK,IAG5DK,EAAmB,CAACC,EAAkC,KAC1DA,EAAS,OAAS,GAAK,CAACA,EAAS,KAAMC,GAAYA,EAAQ,QAAQ,EAExDC,EAA+BR,GAAqB,CAC/D,MAAMS,EAAWT,EAAQ,WAAW,KAAA,GAAU,GACxCU,EAAgBV,EAAQ,gBAAkB,CAAA,EAEhD,MAAO,CACL,SAAAS,EACA,cAAAC,EACA,iBAAkB,CAACD,GAAYJ,EAAiBK,CAAa,CAAA,CAEjE,EAEMC,EAAqB,CAACX,EAAkBG,IAAkB,CAC9D,MAAMS,EAAmBZ,EAMzB,OACEY,EAAiB,aACjBA,EAAiB,UACjBA,EAAiB,qBACjB,GAAGZ,EAAQ,IAAI,IAAI,OAAOA,EAAQ,iBAAmBG,CAAK,CAAC,EAE/D,EAEMU,EAAgBd,GACpBA,EAAY,OAAyB,CAACe,EAAMd,EAASe,IAAiB,CACpE,GAAIX,EAAiBJ,CAAO,EAAG,CAC7B,KAAM,CAAE,SAAAS,EAAU,cAAAC,EAAe,iBAAAM,CAAA,EAC/BR,EAA4BR,CAAO,EAErCc,EAAK,KAAK,CACR,SAA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AInB,EAAe,EACjB,OAGF,MAAMhC,EAAU4B,EAAiBI,CAAY,EAE7C,GAAKhC,EAIL,OAAO8B,EAAkB9B,CAAO,CAClC,EAAG,CAACgC,EAAcJ,CAAgB,CAAC,EAC7BwC,EAAqBjB,EAAAA,QACzB,IAAMpB,EAAsBH,EAAkBI,CAAY,EAC1D,CAACA,EAAcJ,CAAgB,CAAA,EAE3ByC,EAAmBlB,EAAAA,QACvB,IAAMf,EAAoBR,CAAgB,EAC1C,CAACA,CAAgB,CAAA,EAEb0C,EAA8BnB,EAAAA,QAAQ,IAAM,CAChD,MAAMoB,EACJjB,EAAsB,IAAItB,CAAY,GAAK,CAAA,EAE7C,OACEU,EACEO,EAAqC,QACrCsB,CAAA,EAGKtB,EAAqC,SAG9CA,EAAqC,QAAUsB,EAExCA,EACT,EAAG,CAACvC,EAAcsB,CAAqB,CAAC,EAClCkB,EAAiCrB,EAAAA,QACrC,IACEb,EACEY,EACA7B,EACAW,CAAA,EAEJ,CAACA,EAAcX,EAAsB6B,CAAiB,CAAA,EAElDuB,EAA4BtB,EAAAA,QAChC,IACEgB,GAAoB,OAAS,cACzBA,EACA,OACN,CAACA,CAAkB,CAAA,EAGrB,MAAO,CACL,mBAAAC,EACA,iBAAAC,EACA,iBAAAzC,EACA,aAAAI,EACA,UAAAqB,EACA,4BAAAiB,EACA,+BAAAE,EACA,0BAAAC,EACA,UAAAR,EACA,UAAAC,EACA,WAAAJ,EACA,WAAAE,CAAA,CAEJ"}
@@ -21,5 +21,10 @@ export interface UseSlideResult {
21
21
  handlePrev: () => void;
22
22
  handleNext: () => void;
23
23
  }
24
+ export declare const resolveSlideAudioItemSource: (element: Element) => {
25
+ audioUrl: string;
26
+ audioSegments: ElementAudioSegment[];
27
+ isAudioStreaming: boolean;
28
+ };
24
29
  declare const useSlide: (elementList?: Element[]) => UseSlideResult;
25
30
  export default useSlide;