markdown-flow-ui 0.1.100 → 0.1.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.cjs.js +7 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.cjs.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.es.js +17 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.es.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.cjs.js +7 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.cjs.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.es.js +29 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.es.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.cjs.js +7 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.cjs.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.es.js +18 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.es.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js +7 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.es.js +16 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.es.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js +7 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.es.js +16 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.es.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.cjs.js +7 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.cjs.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.es.js +23 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.es.js.map +1 -0
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-custom-variable.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-custom-variable.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-interaction.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-interaction.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
- package/dist/_virtual/index.cjs.js +1 -1
- package/dist/_virtual/index.cjs3.js +1 -1
- package/dist/_virtual/index.cjs4.js +1 -1
- package/dist/_virtual/index.cjs5.js +1 -1
- package/dist/_virtual/index.cjs6.js +1 -1
- package/dist/_virtual/index.es.js +1 -0
- package/dist/_virtual/index.es3.js +4 -5
- package/dist/_virtual/index.es3.js.map +1 -1
- package/dist/_virtual/index.es4.js +5 -4
- package/dist/_virtual/index.es4.js.map +1 -1
- package/dist/_virtual/index.es5.js +4 -4
- package/dist/_virtual/index.es6.js +5 -5
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +13 -10
- package/dist/components/ContentRender/ContentRender.es.js +172 -155
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.stories.d.ts +1 -0
- package/dist/components/ContentRender/IframeSandbox.cjs.js +4 -4
- package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.d.ts +1 -0
- package/dist/components/ContentRender/IframeSandbox.es.js +214 -192
- package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.cjs.js +3 -3
- package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.d.ts +1 -0
- package/dist/components/ContentRender/SandboxApp.es.js +90 -90
- package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.cjs.js +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.cjs.js.map +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.es.js +94 -86
- package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
- package/dist/components/ContentRender/utils/iframe-viewport-height.cjs.js +2 -0
- package/dist/components/ContentRender/utils/iframe-viewport-height.cjs.js.map +1 -0
- package/dist/components/ContentRender/utils/iframe-viewport-height.d.ts +24 -0
- package/dist/components/ContentRender/utils/iframe-viewport-height.es.js +127 -0
- package/dist/components/ContentRender/utils/iframe-viewport-height.es.js.map +1 -0
- package/dist/components/ContentRender/utils/iframe-viewport-height.test.d.ts +1 -0
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +3 -0
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js +19 -16
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
- package/dist/components/Slide/Player.cjs.js +2 -0
- package/dist/components/Slide/Player.cjs.js.map +1 -0
- package/dist/components/Slide/Player.d.ts +21 -0
- package/dist/components/Slide/Player.es.js +386 -0
- package/dist/components/Slide/Player.es.js.map +1 -0
- package/dist/components/Slide/Slide.cjs.js +2 -0
- package/dist/components/Slide/Slide.cjs.js.map +1 -0
- package/dist/components/Slide/Slide.d.ts +27 -0
- package/dist/components/Slide/Slide.es.js +583 -0
- package/dist/components/Slide/Slide.es.js.map +1 -0
- package/dist/components/Slide/Slide.stories.d.ts +79 -0
- package/dist/components/Slide/diff-utils.cjs.js +5 -0
- package/dist/components/Slide/diff-utils.cjs.js.map +1 -0
- package/dist/components/Slide/diff-utils.d.ts +18 -0
- package/dist/components/Slide/diff-utils.es.js +113 -0
- package/dist/components/Slide/diff-utils.es.js.map +1 -0
- package/dist/components/Slide/index.cjs.js +2 -0
- package/dist/components/Slide/index.cjs.js.map +1 -0
- package/dist/components/Slide/index.d.ts +12 -0
- package/dist/components/Slide/index.es.js +12 -0
- package/dist/components/Slide/index.es.js.map +1 -0
- package/dist/components/Slide/types.d.ts +24 -0
- package/dist/components/Slide/useSlide.cjs.js +2 -0
- package/dist/components/Slide/useSlide.cjs.js.map +1 -0
- package/dist/components/Slide/useSlide.d.ts +24 -0
- package/dist/components/Slide/useSlide.es.js +144 -0
- package/dist/components/Slide/useSlide.es.js.map +1 -0
- package/dist/components/Slide/useWakePlayerFromIframe.cjs.js +2 -0
- package/dist/components/Slide/useWakePlayerFromIframe.cjs.js.map +1 -0
- package/dist/components/Slide/useWakePlayerFromIframe.d.ts +7 -0
- package/dist/components/Slide/useWakePlayerFromIframe.es.js +89 -0
- package/dist/components/Slide/useWakePlayerFromIframe.es.js.map +1 -0
- package/dist/components/Slide/utils/interactionPlayback.cjs.js +2 -0
- package/dist/components/Slide/utils/interactionPlayback.cjs.js.map +1 -0
- package/dist/components/Slide/utils/interactionPlayback.d.ts +9 -0
- package/dist/components/Slide/utils/interactionPlayback.es.js +11 -0
- package/dist/components/Slide/utils/interactionPlayback.es.js.map +1 -0
- package/dist/components/Slide/utils/interactionPlayback.test.d.ts +1 -0
- package/dist/components/Slide/utils/listenModeElementList.d.ts +81 -0
- package/dist/components/Slide/utils/listenModeElementList.test.d.ts +1 -0
- package/dist/components/Slide/utils/playbackSequence.cjs.js +2 -0
- package/dist/components/Slide/utils/playbackSequence.cjs.js.map +1 -0
- package/dist/components/Slide/utils/playbackSequence.d.ts +11 -0
- package/dist/components/Slide/utils/playbackSequence.es.js +16 -0
- package/dist/components/Slide/utils/playbackSequence.es.js.map +1 -0
- package/dist/components/Slide/utils/playbackSequence.test.d.ts +1 -0
- package/dist/components/Slide/utils/playerCustomActions.cjs.js +2 -0
- package/dist/components/Slide/utils/playerCustomActions.cjs.js.map +1 -0
- package/dist/components/Slide/utils/playerCustomActions.d.ts +3 -0
- package/dist/components/Slide/utils/playerCustomActions.es.js +7 -0
- package/dist/components/Slide/utils/playerCustomActions.es.js.map +1 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +13 -10
- package/dist/index.es.js.map +1 -1
- package/dist/lib/browserUserActivation.d.ts +5 -0
- package/dist/lib/interaction-defaults.cjs.js +2 -0
- package/dist/lib/interaction-defaults.cjs.js.map +1 -0
- package/dist/lib/interaction-defaults.d.ts +23 -0
- package/dist/lib/interaction-defaults.es.js +145 -0
- package/dist/lib/interaction-defaults.es.js.map +1 -0
- package/dist/lib/sandboxInteraction.cjs.js +2 -0
- package/dist/lib/sandboxInteraction.cjs.js.map +1 -0
- package/dist/lib/sandboxInteraction.d.ts +8 -0
- package/dist/lib/sandboxInteraction.es.js +12 -0
- package/dist/lib/sandboxInteraction.es.js.map +1 -0
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/dist/renderer.cjs.js +1 -1
- package/dist/renderer.d.ts +3 -1
- package/dist/renderer.es.js +9 -6
- package/dist/renderer.es.js.map +1 -1
- package/dist/slide.cjs.js +2 -0
- package/dist/slide.cjs.js.map +1 -0
- package/dist/slide.d.ts +2 -0
- package/dist/slide.es.js +18 -0
- package/dist/slide.es.js.map +1 -0
- package/package.json +25 -2
|
@@ -0,0 +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 { LoaderCircle } from \"lucide-react\";\n\nimport { isSandboxInteractionMessage } from \"../../lib/sandboxInteraction\";\nimport { cn } from \"../../lib/utils\";\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 Player from \"./Player\";\nimport type { PlayerProps } from \"./Player\";\nimport type { Element } from \"./types\";\nimport useSlide from \"./useSlide\";\nimport useWakePlayerFromIframe from \"./useWakePlayerFromIframe\";\nimport { shouldPresentInteractionOverlay } from \"./utils/interactionPlayback\";\nimport { getPlaybackSequenceTransition } from \"./utils/playbackSequence\";\nimport { getPlayerCustomActionCount } from \"./utils/playerCustomActions\";\nimport \"./slide.css\";\nexport type { Element, ElementAudioSegment } from \"./types\";\n\nconst CHECKPOINT_AUTO_ADVANCE_DELAY_MS = 1000;\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\n extends Pick<\n ContentRenderProps,\n \"confirmButtonText\" | \"copyButtonText\" | \"copiedButtonText\"\n > {\n title?: string;\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 className=\"slide-player__interaction-arrow\" />\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 playerCustomActions?: PlayerProps[\"customActions\"];\n bufferingText?: string;\n interactionTitle?: string;\n interactionTexts?: SlideInteractionTexts;\n playerAutoHideDelay?: number;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n onSend?: (content: OnSendContentParams, element?: Element) => void;\n onPlayerVisibilityChange?: (visible: boolean) => void;\n onStepChange?: (element: Element | undefined, index: number) => void;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n showPlayer = true,\n playerAlwaysVisible = false,\n playerClassName,\n playerCustomActions,\n bufferingText = \"Buffering...\",\n interactionTitle,\n interactionTexts,\n playerAutoHideDelay = 3000,\n interactionDefaultValueOptions,\n onSend,\n onPlayerVisibilityChange,\n onStepChange,\n className,\n onPointerDown,\n ...props\n}) => {\n const sectionRef = useRef<HTMLElement | 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 prevRenderElementKeysRef = useRef<string[]>([]);\n const shouldScrollToBottomRef = useRef(false);\n const pendingInteractionOverlayStepIndexRef = useRef<number | null>(null);\n const playbackResetKeyRef = useRef<string | null>(null);\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 [currentAudioKey, setCurrentAudioKey] = useState<string | null>(null);\n const [isAudioLoadingVisible, setIsAudioLoadingVisible] = useState(false);\n const [hasCompletedCurrentStepAudio, setHasCompletedCurrentStepAudio] =\n useState(false);\n const [activeInteractionElement, setActiveInteractionElement] = useState<\n Element | undefined\n >();\n const [isInteractionOverlayOpen, setIsInteractionOverlayOpen] =\n useState(false);\n const playerVisible =\n shouldRenderPlayer && (playerAlwaysVisible || isPlayerVisible);\n const playerCustomActionCount = useMemo(\n () => getPlayerCustomActionCount(playerCustomActions),\n [playerCustomActions]\n );\n const interactionOverlayStyle = useMemo(\n () =>\n ({\n \"--slide-player-custom-action-count\": String(playerCustomActionCount),\n }) as React.CSSProperties,\n [playerCustomActionCount]\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 currentAudioSequenceStartKey = useMemo(\n () => currentAudioSequenceKeys[0] ?? \"none\",\n [currentAudioSequenceKeys]\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 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\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 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 setCurrentAudioKey(null);\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n }, [clearAutoAdvanceTimer, clearInteractionAutoCloseTimer]);\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 setIsInteractionOverlayOpen(false);\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (canGoNext) {\n goNext();\n }\n }, [\n canGoNext,\n clearInteractionAutoCloseTimer,\n goNext,\n startCurrentAudioSequence,\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 return () => {\n clearAutoAdvanceTimer();\n clearPlayerHideTimer();\n clearInteractionAutoCloseTimer();\n };\n }, [\n clearAutoAdvanceTimer,\n clearInteractionAutoCloseTimer,\n clearPlayerHideTimer,\n ]);\n\n useEffect(() => {\n onPlayerVisibilityChange?.(playerVisible);\n\n return () => {\n onPlayerVisibilityChange?.(false);\n };\n }, [onPlayerVisibilityChange, playerVisible]);\n\n useEffect(() => {\n onStepChange?.(currentStepElement, currentIndex);\n }, [currentIndex, currentStepElement, onStepChange]);\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 (!shouldRenderPlayer) {\n return;\n }\n\n // Restore player controls without blocking native iframe scrolling.\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 hasResolvedCurrentInteraction,\n currentStepHasSpeakableElement,\n });\n\n if (hasPlaybackContextChanged) {\n resetAudioSequence();\n }\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldPresentOverlay) {\n // Re-open history interaction checkpoints so manual prev/next still reveals the overlay.\n setActiveInteractionElement(currentInteractionElement);\n setIsInteractionOverlayOpen(true);\n pendingInteractionOverlayStepIndexRef.current = null;\n return;\n }\n\n if (currentInteractionElement) {\n setActiveInteractionElement(currentInteractionElement);\n setIsInteractionOverlayOpen(false);\n pendingInteractionOverlayStepIndexRef.current = null;\n }\n\n if (!shouldInitializeAudioSequence) {\n return;\n }\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (currentStepHasSpeakableElement) {\n setIsAudioLoadingVisible(true);\n return;\n }\n\n if (!canGoNext) {\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 }, CHECKPOINT_AUTO_ADVANCE_DELAY_MS);\n\n return () => {\n clearAutoAdvanceTimer();\n };\n }, [\n canGoNext,\n clearAutoAdvanceTimer,\n currentElementList.length,\n currentInteractionElement,\n currentAudioKey,\n currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n goNext,\n hasCompletedCurrentStepAudio,\n hasResolvedCurrentInteraction,\n shouldBlockPlaybackForInteraction,\n resetAudioSequence,\n startCurrentAudioSequence,\n ]);\n\n useEffect(() => {\n if (!currentStepHasSpeakableElement || shouldBlockPlaybackForInteraction) {\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 shouldBlockPlaybackForInteraction,\n ]);\n\n useEffect(() => {\n if (currentAudioKey || currentAudioSequenceKeys.length === 0) {\n return;\n }\n\n if (!currentStepHasSpeakableElement || shouldBlockPlaybackForInteraction) {\n return;\n }\n\n if (hasCompletedCurrentStepAudio) {\n return;\n }\n\n startCurrentAudioSequence();\n }, [\n currentAudioKey,\n currentAudioSequenceKeys,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\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 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\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 clearInteractionAutoCloseTimer();\n\n if (!isInteractionOverlayOpen || !shouldAutoContinueInteraction) {\n return;\n }\n\n // Auto-close passive interaction checkpoints 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 hideFullScreen\n mode=\"blackboard\"\n replaceRootScreenHeightWithFull={\n options.replaceRootScreenHeightWithFull\n }\n type=\"sandbox\"\n content={element.content as string}\n />\n );\n }\n\n return (\n <IframeSandbox\n className=\"content-render-iframe\"\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 = () => {\n const target = sectionRef.current;\n if (!target) return;\n\n if (document.fullscreenElement) {\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 (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(loading);\n },\n [currentStepHasSpeakableElement, hasCompletedCurrentStepAudio]\n );\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 setHasPlayerInteracted(true);\n showPlayerControls(true);\n },\n [onPointerDown, showPlayerControls]\n );\n\n const shouldShowInteractionOverlay =\n Boolean(activeInteractionElement) && isInteractionOverlayOpen;\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(\"relative h-full w-full\", className)}\n onPointerDown={handleSurfacePointerDown}\n {...props}\n >\n <div\n className={cn(\n \"h-full min-h-0 w-full\",\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 <div className=\"pointer-events-none absolute left-1/2 top-1/2 z-[3] flex size-28 -translate-x-1/2 -translate-y-1/2 flex-col items-center justify-center gap-2 rounded-2xl bg-foreground/65 px-3 py-4 text-center text-xs leading-4 font-medium text-background shadow-lg backdrop-blur-sm\">\n <LoaderCircle className=\"size-5 animate-spin text-background\" />\n <span>{bufferingText}</span>\n </div>\n ) : null}\n\n {shouldShowInteractionOverlay ? (\n <div\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 hasInteraction={Boolean(activeInteractionElement)}\n isInteractionOpen={isInteractionOverlayOpen}\n onLoadingChange={handlePlayerLoadingChange}\n nextDisabled={!canGoNext}\n onEnded={handlePlayerEnded}\n onFullscreen={handleFullscreen}\n onInteractionToggle={handleInteractionToggle}\n onNext={handleNext}\n onPrev={handlePrev}\n prevDisabled={!canGoPrev}\n showControls={playerVisible}\n customActions={playerCustomActions}\n />\n ) : null}\n </section>\n );\n};\n\nexport default Slide;\n"],"names":["CHECKPOINT_AUTO_ADVANCE_DELAY_MS","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","playerCustomActions","bufferingText","interactionTitle","interactionTexts","playerAutoHideDelay","interactionDefaultValueOptions","onPlayerVisibilityChange","onStepChange","className","onPointerDown","props","sectionRef","useRef","stageLayerRef","lastElementRef","playerHideTimerRef","autoAdvanceTimerRef","interactionAutoCloseTimerRef","prevRenderElementKeysRef","shouldScrollToBottomRef","pendingInteractionOverlayStepIndexRef","playbackResetKeyRef","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","currentAudioKey","setCurrentAudioKey","isAudioLoadingVisible","setIsAudioLoadingVisible","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","playerVisible","playerCustomActionCount","getPlayerCustomActionCount","interactionOverlayStyle","mountedStepStates","currentMountedStateIndex","nextMountedStepStates","mountedStateIndexByStep","stepElementList","stepIndex","existingMountedStateIndex","mountedStepState","currentStepKey","currentAudioIndex","audioItem","currentAudioSequenceStartKey","hasAvailableStepAudio","currentInteractionResetKey","currentPlaybackResetKey","hasCurrentStepAudioUrl","clearPlayerHideTimer","useCallback","clearInteractionAutoCloseTimer","clearAutoAdvanceTimer","resetAudioSequence","startCurrentAudioSequence","nextAudioKey","continueAfterInteraction","showPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","shouldBlockPlaybackForInteraction","useEffect","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","hasPlaybackContextChanged","shouldInitializeAudioSequence","getPlaybackSequenceTransition","shouldOpenInteractionOverlayAfterAudio","shouldPresentOverlay","shouldPresentInteractionOverlay","interactionDefaults","shouldPreferResolvedInteractionInput","getInteractionDefaultValues","interactionDefaultSelectedValues","getInteractionDefaultSelectedValues","hasResolvedInteractionInput","isInteractionReadonly","shouldAutoContinueInteraction","handleInteractionSend","resolvedUserInput","prevElement","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","shouldShowInteractionOverlay","currentRenderElementKeys","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","mountedStepStateIndex","LoaderCircle","Player"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAMA,KAAmC,KA2BnCC,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,WAAU,kCACb,UAAA;AAAA,IAAAC,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,oCACb,UAAAA,gBAAAA,EAAAA,IAAC,OAAE,WAAU,mCAAmC,aAAM,EAAA,CACxD;AAAA,IACAA,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,kCACb,UAAAA,gBAAAA,EAAAA;AAAAA,MAACC;AAAA,MAAA;AAAA,QACC,SAAAZ;AAAA,QACA,mBAAAE;AAAA,QACA,kBAAAC;AAAA,QACA,uBAAAC;AAAA,QACA,mBAAAC;AAAA,QACA,gBAAAC;AAAA,QACA,kBAAAC;AAAA,QACA,QAAAC;AAAA,QACA,UAAAC;AAAA,QACA,kBAAkB;AAAA,QAClB,aAAY;AAAA,MAAA;AAAA,IAAA,GAEhB;AAAA,IACAE,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,kCAAA,CAAkC;AAAA,EAAA,EAAA,CACnD;AAEJ;AAEAb,GAAuB,cAAc;AAErC,MAAMe,KAA2B,CAC/BC,GACAC,MAEAD,EAAgB,WAAWC,EAAgB,UAC3CD,EAAgB,MAAM,CAACE,GAASC,MAAU;AACxC,QAAMC,IAAcH,EAAgBE,CAAK;AAEzC,SACED,E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: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import('react').FC<import('./Slide').SlideProps>;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
tags: string[];
|
|
14
|
+
argTypes: {
|
|
15
|
+
elementList: {
|
|
16
|
+
description: string;
|
|
17
|
+
table: {
|
|
18
|
+
type: {
|
|
19
|
+
summary: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
interactionTitle: {
|
|
24
|
+
control: "text";
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
interactionTexts: {
|
|
28
|
+
control: "object";
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
playerAutoHideDelay: {
|
|
32
|
+
control: {
|
|
33
|
+
type: "number";
|
|
34
|
+
min: number;
|
|
35
|
+
step: number;
|
|
36
|
+
};
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
playerAlwaysVisible: {
|
|
40
|
+
control: "boolean";
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
playerCustomActions: {
|
|
44
|
+
control: false;
|
|
45
|
+
description: string;
|
|
46
|
+
table: {
|
|
47
|
+
type: {
|
|
48
|
+
summary: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
args: {
|
|
54
|
+
elementList: never[];
|
|
55
|
+
interactionTexts: {
|
|
56
|
+
title: string;
|
|
57
|
+
confirmButtonText: string;
|
|
58
|
+
copyButtonText: string;
|
|
59
|
+
copiedButtonText: string;
|
|
60
|
+
};
|
|
61
|
+
playerAutoHideDelay: number;
|
|
62
|
+
playerAlwaysVisible: false;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export default meta;
|
|
66
|
+
type Story = StoryObj<typeof meta>;
|
|
67
|
+
export declare const Default: Story;
|
|
68
|
+
export declare const CustomPlayerActionButton: Story;
|
|
69
|
+
export declare const FullViewportSlides: Story;
|
|
70
|
+
export declare const FullViewportSingleSlide: Story;
|
|
71
|
+
export declare const FullViewportSingleSlideWithEmptyPpt: Story;
|
|
72
|
+
export declare const HistorySlides: Story;
|
|
73
|
+
export declare const StreamingSingleIframeSlide: Story;
|
|
74
|
+
export declare const StreamingSpeakableLoadingOnlySlide: Story;
|
|
75
|
+
export declare const FullViewportSingleSlideWithSSE: Story;
|
|
76
|
+
export declare const HistoryInteractionTriggeredSSE: Story;
|
|
77
|
+
export declare const InteractionTriggeredFixtureSwitchSSE: Story;
|
|
78
|
+
export declare const AudioSegmentsPlayback: Story;
|
|
79
|
+
export declare const StreamingSpeakableDelayedAudioSlide: Story;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=/!\+\+\+\s*([\s\S]*?)\s*!\+\+\+/,x=/^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/,h=(e,n)=>e===n||e.trim()===n.trim(),d=e=>{if(!e)return{};const n=e.match(m);if(!n)return{trailingContent:e.trim()||void 0};const s=n[1]?.trim(),i=e.slice(n.index+n[0].length).trim();return{patchText:s||void 0,trailingContent:i||void 0}},p=e=>{const n=e.split(`
|
|
2
|
+
`),s=n[0]?.match(/^---\s+a\/(\d+)/),i=n[1]?.match(/^\+\+\+\s+b\/(\d+)/);if(!s||!i||s[1]!==i[1])return null;const r=[];let t=null;return n.slice(2).forEach(o=>{const l=o.match(x);if(l){t&&r.push(t),t={oldStart:Number.parseInt(l[1],10),lines:[]};return}t&&t.lines.push(o)}),t&&r.push(t),r.length===0?null:{targetIndex:Number.parseInt(s[1],10),hunks:r}},g=(e,n)=>{const s=p(n);if(!s)return null;const i=e.split(`
|
|
3
|
+
`),r=[];let t=0;for(const o of s.hunks){const l=Math.max(o.oldStart-1,0);for(;t<l&&t<i.length;)r.push(i[t]),t+=1;for(const f of o.lines){const u=f[0],a=f.slice(1);if(u===" "){const c=i[t];if(c==null||!h(c,a))return null;r.push(c),t+=1;continue}if(u==="-"){const c=i[t];if(c==null||!h(c,a))return null;t+=1;continue}if(u==="+"){r.push(a);continue}}}for(;t<i.length;)r.push(i[t]),t+=1;return r.join(`
|
|
4
|
+
`)},C=(e,n)=>{const s=typeof n.content=="string"?n.content:void 0,{patchText:i,trailingContent:r}=d(s);if(!i)return r?[...e,{...n,type:"text",content:r}]:null;const t=p(i);if(!t)return null;const o=e[t.targetIndex],l=typeof o?.content=="string"?o.content:void 0;if(!o||!l)return null;const f=g(l,i);if(!f)return null;const u=e.map((a,c)=>c===t.targetIndex?{...a,content:f}:a);return r?[...u,{...n,type:"text",content:r}]:u};exports.applyDiffElement=C;exports.applyUnifiedDiff=g;exports.parseUnifiedDiff=p;exports.splitDiffContent=d;
|
|
5
|
+
//# sourceMappingURL=diff-utils.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-utils.cjs.js","sources":["../../../src/components/Slide/diff-utils.ts"],"sourcesContent":["import type { Element } from \"./types\";\n\ntype DiffHunk = {\n oldStart: number;\n lines: string[];\n};\n\ntype ParsedUnifiedDiff = {\n targetIndex: number;\n hunks: DiffHunk[];\n};\n\ntype DiffContentParts = {\n patchText?: string;\n trailingContent?: string;\n};\n\nconst DIFF_BLOCK_PATTERN = /!\\+\\+\\+\\s*([\\s\\S]*?)\\s*!\\+\\+\\+/;\nconst HUNK_HEADER_PATTERN = /^@@\\s+-(\\d+)(?:,(\\d+))?\\s+\\+(\\d+)(?:,(\\d+))?\\s+@@/;\n\nconst isComparableLineMatch = (sourceLine: string, expectedLine: string) =>\n sourceLine === expectedLine || sourceLine.trim() === expectedLine.trim();\n\nexport const splitDiffContent = (content?: string): DiffContentParts => {\n if (!content) {\n return {};\n }\n\n const matched = content.match(DIFF_BLOCK_PATTERN);\n\n if (!matched) {\n return {\n trailingContent: content.trim() || undefined,\n };\n }\n\n const patchText = matched[1]?.trim();\n const trailingContent = content\n .slice(matched.index + matched[0].length)\n .trim();\n\n return {\n patchText: patchText || undefined,\n trailingContent: trailingContent || undefined,\n };\n};\n\nexport const parseUnifiedDiff = (\n patchText: string\n): ParsedUnifiedDiff | null => {\n const lines = patchText.split(\"\\n\");\n const targetMatch = lines[0]?.match(/^---\\s+a\\/(\\d+)/);\n const nextMatch = lines[1]?.match(/^\\+\\+\\+\\s+b\\/(\\d+)/);\n\n if (!targetMatch || !nextMatch || targetMatch[1] !== nextMatch[1]) {\n return null;\n }\n\n const hunks: DiffHunk[] = [];\n let currentHunk: DiffHunk | null = null;\n\n lines.slice(2).forEach((line) => {\n const headerMatch = line.match(HUNK_HEADER_PATTERN);\n\n if (headerMatch) {\n if (currentHunk) {\n hunks.push(currentHunk);\n }\n\n currentHunk = {\n oldStart: Number.parseInt(headerMatch[1], 10),\n lines: [],\n };\n return;\n }\n\n if (currentHunk) {\n currentHunk.lines.push(line);\n }\n });\n\n if (currentHunk) {\n hunks.push(currentHunk);\n }\n\n if (hunks.length === 0) {\n return null;\n }\n\n return {\n targetIndex: Number.parseInt(targetMatch[1], 10),\n hunks,\n };\n};\n\nexport const applyUnifiedDiff = (\n source: string,\n patchText: string\n): string | null => {\n const parsed = parseUnifiedDiff(patchText);\n\n if (!parsed) {\n return null;\n }\n\n const sourceLines = source.split(\"\\n\");\n const resultLines: string[] = [];\n let sourceCursor = 0;\n\n for (const hunk of parsed.hunks) {\n const hunkStartIndex = Math.max(hunk.oldStart - 1, 0);\n\n while (sourceCursor < hunkStartIndex && sourceCursor < sourceLines.length) {\n resultLines.push(sourceLines[sourceCursor]);\n sourceCursor += 1;\n }\n\n for (const line of hunk.lines) {\n const marker = line[0];\n const expectedLine = line.slice(1);\n\n if (marker === \" \") {\n const currentLine = sourceLines[sourceCursor];\n\n if (\n currentLine == null ||\n !isComparableLineMatch(currentLine, expectedLine)\n ) {\n return null;\n }\n\n resultLines.push(currentLine);\n sourceCursor += 1;\n continue;\n }\n\n if (marker === \"-\") {\n const currentLine = sourceLines[sourceCursor];\n\n if (\n currentLine == null ||\n !isComparableLineMatch(currentLine, expectedLine)\n ) {\n return null;\n }\n\n sourceCursor += 1;\n continue;\n }\n\n if (marker === \"+\") {\n resultLines.push(expectedLine);\n continue;\n }\n\n if (marker === \"\\\\\") {\n continue;\n }\n }\n }\n\n while (sourceCursor < sourceLines.length) {\n resultLines.push(sourceLines[sourceCursor]);\n sourceCursor += 1;\n }\n\n return resultLines.join(\"\\n\");\n};\n\nexport const applyDiffElement = (\n currentList: Element[],\n diffElement: Element\n): Element[] | null => {\n const content =\n typeof diffElement.content === \"string\" ? diffElement.content : undefined;\n const { patchText, trailingContent } = splitDiffContent(content);\n\n if (!patchText) {\n return trailingContent\n ? [\n ...currentList,\n {\n ...diffElement,\n type: \"text\",\n content: trailingContent,\n },\n ]\n : null;\n }\n\n const parsed = parseUnifiedDiff(patchText);\n\n if (!parsed) {\n return null;\n }\n\n const targetElement = currentList[parsed.targetIndex];\n const targetContent =\n typeof targetElement?.content === \"string\"\n ? targetElement.content\n : undefined;\n\n if (!targetElement || !targetContent) {\n return null;\n }\n\n const patchedContent = applyUnifiedDiff(targetContent, patchText);\n\n if (!patchedContent) {\n return null;\n }\n\n const nextList = currentList.map((element, index) =>\n index === parsed.targetIndex\n ? {\n ...element,\n content: patchedContent,\n }\n : element\n );\n\n if (!trailingContent) {\n return nextList;\n }\n\n return [\n ...nextList,\n {\n ...diffElement,\n type: \"text\",\n content: trailingContent,\n },\n ];\n};\n"],"names":["DIFF_BLOCK_PATTERN","HUNK_HEADER_PATTERN","isComparableLineMatch","sourceLine","expectedLine","splitDiffContent","content","matched","patchText","trailingContent","parseUnifiedDiff","lines","targetMatch","nextMatch","hunks","currentHunk","line","headerMatch","applyUnifiedDiff","source","parsed","sourceLines","resultLines","sourceCursor","hunk","hunkStartIndex","marker","currentLine","applyDiffElement","currentList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E,GAAGoB,EACH,CACE,GAAGC,EACH,KAAM,OACN,QAASrB,CAAA,CACX,EAEF,KAGN,MAAMW,EAASV,EAAiBF,CAAS,EAEzC,GAAI,CAACY,EACH,OAAO,KAGT,MAAMW,EAAgBF,EAAYT,EAAO,WAAW,EAC9CY,EACJ,OAAOD,GAAe,SAAY,SAC9BA,EAAc,QACd,OAEN,GAAI,CAACA,GAAiB,CAACC,EACrB,OAAO,KAGT,MAAMC,EAAiBf,EAAiBc,EAAexB,CAAS,EAEhE,GAAI,CAACyB,EACH,OAAO,KAGT,MAAMC,EAAWL,EAAY,IAAI,CAACM,EAASC,IACzCA,IAAUhB,EAAO,YACb,CACE,GAAGe,EACH,QAASF,CAAA,EAEXE,CAAA,EAGN,OAAK1B,EAIE,CACL,GAAGyB,EACH,CACE,GAAGJ,EACH,KAAM,OACN,QAASrB,CAAA,CACX,EATOyB,CAWX"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Element } from './types';
|
|
2
|
+
type DiffHunk = {
|
|
3
|
+
oldStart: number;
|
|
4
|
+
lines: string[];
|
|
5
|
+
};
|
|
6
|
+
type ParsedUnifiedDiff = {
|
|
7
|
+
targetIndex: number;
|
|
8
|
+
hunks: DiffHunk[];
|
|
9
|
+
};
|
|
10
|
+
type DiffContentParts = {
|
|
11
|
+
patchText?: string;
|
|
12
|
+
trailingContent?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const splitDiffContent: (content?: string) => DiffContentParts;
|
|
15
|
+
export declare const parseUnifiedDiff: (patchText: string) => ParsedUnifiedDiff | null;
|
|
16
|
+
export declare const applyUnifiedDiff: (source: string, patchText: string) => string | null;
|
|
17
|
+
export declare const applyDiffElement: (currentList: Element[], diffElement: Element) => Element[] | null;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const d = /!\+\+\+\s*([\s\S]*?)\s*!\+\+\+/, g = /^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/, f = (e, n) => e === n || e.trim() === n.trim(), m = (e) => {
|
|
2
|
+
if (!e)
|
|
3
|
+
return {};
|
|
4
|
+
const n = e.match(d);
|
|
5
|
+
if (!n)
|
|
6
|
+
return {
|
|
7
|
+
trailingContent: e.trim() || void 0
|
|
8
|
+
};
|
|
9
|
+
const i = n[1]?.trim(), r = e.slice(n.index + n[0].length).trim();
|
|
10
|
+
return {
|
|
11
|
+
patchText: i || void 0,
|
|
12
|
+
trailingContent: r || void 0
|
|
13
|
+
};
|
|
14
|
+
}, p = (e) => {
|
|
15
|
+
const n = e.split(`
|
|
16
|
+
`), i = n[0]?.match(/^---\s+a\/(\d+)/), r = n[1]?.match(/^\+\+\+\s+b\/(\d+)/);
|
|
17
|
+
if (!i || !r || i[1] !== r[1])
|
|
18
|
+
return null;
|
|
19
|
+
const s = [];
|
|
20
|
+
let t = null;
|
|
21
|
+
return n.slice(2).forEach((o) => {
|
|
22
|
+
const u = o.match(g);
|
|
23
|
+
if (u) {
|
|
24
|
+
t && s.push(t), t = {
|
|
25
|
+
oldStart: Number.parseInt(u[1], 10),
|
|
26
|
+
lines: []
|
|
27
|
+
};
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
t && t.lines.push(o);
|
|
31
|
+
}), t && s.push(t), s.length === 0 ? null : {
|
|
32
|
+
targetIndex: Number.parseInt(i[1], 10),
|
|
33
|
+
hunks: s
|
|
34
|
+
};
|
|
35
|
+
}, x = (e, n) => {
|
|
36
|
+
const i = p(n);
|
|
37
|
+
if (!i)
|
|
38
|
+
return null;
|
|
39
|
+
const r = e.split(`
|
|
40
|
+
`), s = [];
|
|
41
|
+
let t = 0;
|
|
42
|
+
for (const o of i.hunks) {
|
|
43
|
+
const u = Math.max(o.oldStart - 1, 0);
|
|
44
|
+
for (; t < u && t < r.length; )
|
|
45
|
+
s.push(r[t]), t += 1;
|
|
46
|
+
for (const h of o.lines) {
|
|
47
|
+
const l = h[0], a = h.slice(1);
|
|
48
|
+
if (l === " ") {
|
|
49
|
+
const c = r[t];
|
|
50
|
+
if (c == null || !f(c, a))
|
|
51
|
+
return null;
|
|
52
|
+
s.push(c), t += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (l === "-") {
|
|
56
|
+
const c = r[t];
|
|
57
|
+
if (c == null || !f(c, a))
|
|
58
|
+
return null;
|
|
59
|
+
t += 1;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (l === "+") {
|
|
63
|
+
s.push(a);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
for (; t < r.length; )
|
|
69
|
+
s.push(r[t]), t += 1;
|
|
70
|
+
return s.join(`
|
|
71
|
+
`);
|
|
72
|
+
}, C = (e, n) => {
|
|
73
|
+
const i = typeof n.content == "string" ? n.content : void 0, { patchText: r, trailingContent: s } = m(i);
|
|
74
|
+
if (!r)
|
|
75
|
+
return s ? [
|
|
76
|
+
...e,
|
|
77
|
+
{
|
|
78
|
+
...n,
|
|
79
|
+
type: "text",
|
|
80
|
+
content: s
|
|
81
|
+
}
|
|
82
|
+
] : null;
|
|
83
|
+
const t = p(r);
|
|
84
|
+
if (!t)
|
|
85
|
+
return null;
|
|
86
|
+
const o = e[t.targetIndex], u = typeof o?.content == "string" ? o.content : void 0;
|
|
87
|
+
if (!o || !u)
|
|
88
|
+
return null;
|
|
89
|
+
const h = x(u, r);
|
|
90
|
+
if (!h)
|
|
91
|
+
return null;
|
|
92
|
+
const l = e.map(
|
|
93
|
+
(a, c) => c === t.targetIndex ? {
|
|
94
|
+
...a,
|
|
95
|
+
content: h
|
|
96
|
+
} : a
|
|
97
|
+
);
|
|
98
|
+
return s ? [
|
|
99
|
+
...l,
|
|
100
|
+
{
|
|
101
|
+
...n,
|
|
102
|
+
type: "text",
|
|
103
|
+
content: s
|
|
104
|
+
}
|
|
105
|
+
] : l;
|
|
106
|
+
};
|
|
107
|
+
export {
|
|
108
|
+
C as applyDiffElement,
|
|
109
|
+
x as applyUnifiedDiff,
|
|
110
|
+
p as parseUnifiedDiff,
|
|
111
|
+
m as splitDiffContent
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=diff-utils.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-utils.es.js","sources":["../../../src/components/Slide/diff-utils.ts"],"sourcesContent":["import type { Element } from \"./types\";\n\ntype DiffHunk = {\n oldStart: number;\n lines: string[];\n};\n\ntype ParsedUnifiedDiff = {\n targetIndex: number;\n hunks: DiffHunk[];\n};\n\ntype DiffContentParts = {\n patchText?: string;\n trailingContent?: string;\n};\n\nconst DIFF_BLOCK_PATTERN = /!\\+\\+\\+\\s*([\\s\\S]*?)\\s*!\\+\\+\\+/;\nconst HUNK_HEADER_PATTERN = /^@@\\s+-(\\d+)(?:,(\\d+))?\\s+\\+(\\d+)(?:,(\\d+))?\\s+@@/;\n\nconst isComparableLineMatch = (sourceLine: string, expectedLine: string) =>\n sourceLine === expectedLine || sourceLine.trim() === expectedLine.trim();\n\nexport const splitDiffContent = (content?: string): DiffContentParts => {\n if (!content) {\n return {};\n }\n\n const matched = content.match(DIFF_BLOCK_PATTERN);\n\n if (!matched) {\n return {\n trailingContent: content.trim() || undefined,\n };\n }\n\n const patchText = matched[1]?.trim();\n const trailingContent = content\n .slice(matched.index + matched[0].length)\n .trim();\n\n return {\n patchText: patchText || undefined,\n trailingContent: trailingContent || undefined,\n };\n};\n\nexport const parseUnifiedDiff = (\n patchText: string\n): ParsedUnifiedDiff | null => {\n const lines = patchText.split(\"\\n\");\n const targetMatch = lines[0]?.match(/^---\\s+a\\/(\\d+)/);\n const nextMatch = lines[1]?.match(/^\\+\\+\\+\\s+b\\/(\\d+)/);\n\n if (!targetMatch || !nextMatch || targetMatch[1] !== nextMatch[1]) {\n return null;\n }\n\n const hunks: DiffHunk[] = [];\n let currentHunk: DiffHunk | null = null;\n\n lines.slice(2).forEach((line) => {\n const headerMatch = line.match(HUNK_HEADER_PATTERN);\n\n if (headerMatch) {\n if (currentHunk) {\n hunks.push(currentHunk);\n }\n\n currentHunk = {\n oldStart: Number.parseInt(headerMatch[1], 10),\n lines: [],\n };\n return;\n }\n\n if (currentHunk) {\n currentHunk.lines.push(line);\n }\n });\n\n if (currentHunk) {\n hunks.push(currentHunk);\n }\n\n if (hunks.length === 0) {\n return null;\n }\n\n return {\n targetIndex: Number.parseInt(targetMatch[1], 10),\n hunks,\n };\n};\n\nexport const applyUnifiedDiff = (\n source: string,\n patchText: string\n): string | null => {\n const parsed = parseUnifiedDiff(patchText);\n\n if (!parsed) {\n return null;\n }\n\n const sourceLines = source.split(\"\\n\");\n const resultLines: string[] = [];\n let sourceCursor = 0;\n\n for (const hunk of parsed.hunks) {\n const hunkStartIndex = Math.max(hunk.oldStart - 1, 0);\n\n while (sourceCursor < hunkStartIndex && sourceCursor < sourceLines.length) {\n resultLines.push(sourceLines[sourceCursor]);\n sourceCursor += 1;\n }\n\n for (const line of hunk.lines) {\n const marker = line[0];\n const expectedLine = line.slice(1);\n\n if (marker === \" \") {\n const currentLine = sourceLines[sourceCursor];\n\n if (\n currentLine == null ||\n !isComparableLineMatch(currentLine, expectedLine)\n ) {\n return null;\n }\n\n resultLines.push(currentLine);\n sourceCursor += 1;\n continue;\n }\n\n if (marker === \"-\") {\n const currentLine = sourceLines[sourceCursor];\n\n if (\n currentLine == null ||\n !isComparableLineMatch(currentLine, expectedLine)\n ) {\n return null;\n }\n\n sourceCursor += 1;\n continue;\n }\n\n if (marker === \"+\") {\n resultLines.push(expectedLine);\n continue;\n }\n\n if (marker === \"\\\\\") {\n continue;\n }\n }\n }\n\n while (sourceCursor < sourceLines.length) {\n resultLines.push(sourceLines[sourceCursor]);\n sourceCursor += 1;\n }\n\n return resultLines.join(\"\\n\");\n};\n\nexport const applyDiffElement = (\n currentList: Element[],\n diffElement: Element\n): Element[] | null => {\n const content =\n typeof diffElement.content === \"string\" ? diffElement.content : undefined;\n const { patchText, trailingContent } = splitDiffContent(content);\n\n if (!patchText) {\n return trailingContent\n ? [\n ...currentList,\n {\n ...diffElement,\n type: \"text\",\n content: trailingContent,\n },\n ]\n : null;\n }\n\n const parsed = parseUnifiedDiff(patchText);\n\n if (!parsed) {\n return null;\n }\n\n const targetElement = currentList[parsed.targetIndex];\n const targetContent =\n typeof targetElement?.content === \"string\"\n ? targetElement.content\n : undefined;\n\n if (!targetElement || !targetContent) {\n return null;\n }\n\n const patchedContent = applyUnifiedDiff(targetContent, patchText);\n\n if (!patchedContent) {\n return null;\n }\n\n const nextList = currentList.map((element, index) =>\n index === parsed.targetIndex\n ? {\n ...element,\n content: patchedContent,\n }\n : element\n );\n\n if (!trailingContent) {\n return nextList;\n }\n\n return [\n ...nextList,\n {\n ...diffElement,\n type: \"text\",\n content: trailingContent,\n },\n ];\n};\n"],"names":["DIFF_BLOCK_PATTERN","HUNK_HEADER_PATTERN","isComparableLineMatch","sourceLine","expectedLine","splitDiffContent","content","matched","patchText","trailingContent","parseUnifiedDiff","lines","targetMatch","nextMatch","hunks","currentHunk","line","headerMatch","applyUnifiedDiff","source","parsed","sourceLines","resultLines","sourceCursor","hunk","hunkStartIndex","marker","currentLine","applyDiffElement","currentList","diffElement","targetElement","targetContent","patchedContent","nextList","element","index"],"mappings":"AAiBA,MAAMA,IAAqB,kCACrBC,IAAsB,qDAEtBC,IAAwB,CAACC,GAAoBC,MACjDD,MAAeC,KAAgBD,EAAW,KAAA,MAAWC,EAAa,KAAA,GAEvDC,IAAmB,CAACC,MAAuC;AACtE,MAAI,CAACA;AACH,WAAO,CAAA;AAGT,QAAMC,IAAUD,EAAQ,MAAMN,CAAkB;AAEhD,MAAI,CAACO;AACH,WAAO;AAAA,MACL,iBAAiBD,EAAQ,UAAU;AAAA,IAAA;AAIvC,QAAME,IAAYD,EAAQ,CAAC,GAAG,KAAA,GACxBE,IAAkBH,EACrB,MAAMC,EAAQ,QAAQA,EAAQ,CAAC,EAAE,MAAM,EACvC,KAA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ACrB,WAAO;AAGT,QAAMC,IAAiBf,EAAiBc,GAAexB,CAAS;AAEhE,MAAI,CAACyB;AACH,WAAO;AAGT,QAAMC,IAAWL,EAAY;AAAA,IAAI,CAACM,GAASC,MACzCA,MAAUhB,EAAO,cACb;AAAA,MACE,GAAGe;AAAA,MACH,SAASF;AAAA,IAAA,IAEXE;AAAA,EAAA;AAGN,SAAK1B,IAIE;AAAA,IACL,GAAGyB;AAAA,IACH;AAAA,MACE,GAAGJ;AAAA,MACH,MAAM;AAAA,MACN,SAASrB;AAAA,IAAA;AAAA,EACX,IATOyB;AAWX;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Slide.cjs.js");require("../../_virtual/jsx-runtime.cjs.js");require("react");;/* empty css */const t=require("../../lib/interaction-defaults.cjs.js");exports.Slide=e.default;exports.default=e.default;exports.getInteractionDefaultSelectedValues=t.getInteractionDefaultSelectedValues;exports.getInteractionDefaultValues=t.getInteractionDefaultValues;
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as Slide } from './Slide';
|
|
2
|
+
import { default as Player } from './Player';
|
|
3
|
+
import { applyDiffElement, applyUnifiedDiff, parseUnifiedDiff, splitDiffContent } from './diff-utils';
|
|
4
|
+
import { getInteractionDefaultSelectedValues, getInteractionDefaultValues } from '../../lib/interaction-defaults';
|
|
5
|
+
import { default as useSlide } from './useSlide';
|
|
6
|
+
export default Slide;
|
|
7
|
+
export { Slide, applyDiffElement, applyUnifiedDiff, parseUnifiedDiff, splitDiffContent, Player, useSlide, getInteractionDefaultValues, getInteractionDefaultSelectedValues, };
|
|
8
|
+
export type { SlideInteractionTexts, SlideProps } from './Slide';
|
|
9
|
+
export type { InteractionDefaultResolver, InteractionDefaultResolverParams, InteractionDefaultValueOptions, InteractionDefaultValues, InteractionParseResult, } from '../../lib/interaction-defaults';
|
|
10
|
+
export type { Element, ElementAudioSegment } from './types';
|
|
11
|
+
export type { PlayerProps } from './Player';
|
|
12
|
+
export type { UseSlideResult } from './useSlide';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import e from "./Slide.es.js";
|
|
2
|
+
import "../../_virtual/jsx-runtime.es.js";
|
|
3
|
+
import "react";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { getInteractionDefaultSelectedValues as m, getInteractionDefaultValues as p } from "../../lib/interaction-defaults.es.js";
|
|
6
|
+
export {
|
|
7
|
+
e as Slide,
|
|
8
|
+
e as default,
|
|
9
|
+
m as getInteractionDefaultSelectedValues,
|
|
10
|
+
p as getInteractionDefaultValues
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type ElementType = "slot" | "html" | "svg" | "diff" | "img" | "interaction" | "tables" | "code" | "latex" | "md_img" | "mermaid" | "title" | "text" | "link" | string;
|
|
3
|
+
export interface ElementAudioSegment {
|
|
4
|
+
segment_index: number;
|
|
5
|
+
audio_data: string;
|
|
6
|
+
duration_ms: number;
|
|
7
|
+
is_final: boolean;
|
|
8
|
+
position?: number;
|
|
9
|
+
slide_id?: string;
|
|
10
|
+
av_contract?: Record<string, unknown> | null;
|
|
11
|
+
}
|
|
12
|
+
export interface Element {
|
|
13
|
+
content: React.ReactNode;
|
|
14
|
+
type: ElementType;
|
|
15
|
+
is_renderable?: boolean;
|
|
16
|
+
is_new?: boolean;
|
|
17
|
+
is_marker?: boolean;
|
|
18
|
+
sequence_number?: number;
|
|
19
|
+
is_speakable?: boolean;
|
|
20
|
+
audio_url?: string;
|
|
21
|
+
user_input?: string;
|
|
22
|
+
readonly?: boolean;
|
|
23
|
+
audio_segments?: ElementAudioSegment[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react"),I=require("./diff-utils.cjs.js"),R=e=>e.filter(n=>n.is_marker),C=e=>e.reduce((n,t,r)=>(t.is_marker&&n.push(r),n),[]),m=e=>!!(e?.is_speakable&&(e.audio_url||(e.audio_segments?.length??0)>0)),N=(e=[])=>e.length>0&&!e.some(n=>n.is_final),P=(e,n)=>{const t=e;return t.element_bid||t.blockBid||t.generated_block_bid||`${e.type}:${String(e.sequence_number??n)}`},v=e=>e.reduce((n,t,r)=>{if(m(t)){const s=t.audio_segments??[],c=s.length>0;n.push({audioKey:P(t,r),sequenceNumber:t.sequence_number,audioUrl:c?"":t.audio_url,audioSegments:s,isAudioStreaming:N(s)})}return n},[]),w=e=>{const n=new Map;let t=0;return e.forEach((r,s)=>{m(r)&&(n.set(s,t),t+=1)}),n},B=(e,n,t)=>n.reduce((r,s,c)=>{const f=n[c+1]??e.length,d=[];for(let a=s;a<f;a+=1){const i=e[a];if(!m(i))continue;const l=t.get(a);l!=null&&d.push(l)}return r.set(c,d),r},new Map),h=e=>{const n=e.findIndex(t=>t.is_renderable===!0);return n>=0?n:e.findIndex(t=>t.is_renderable!==!1)},b=e=>({...e,is_renderable:!0}),M=(e,n)=>n<0?[]:e.slice(0,n+1).reduce((t,r)=>{if(r.type==="interaction")return t;const s=b(r);return s.type==="diff"?I.applyDiffElement(t,s)??[...t,s]:r.is_new?[s]:t.length===0?[s]:[...t,s]},[]),G=e=>e.map((n,t)=>M(e,t)),H=(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},K=(e,n)=>e.length===n.length&&e.every((t,r)=>t===n[r]),U=(e,n)=>e.length===n.length&&e.every((t,r)=>t===n[r]),$=(e=[])=>{const n=o.useRef(e),t=o.useRef([]),r=o.useMemo(()=>K(n.current,e)?n.current:(n.current=e,e),[e]),s=o.useMemo(()=>R(r),[r]),c=o.useMemo(()=>C(r),[r]),f=o.useMemo(()=>v(r),[r]),d=o.useMemo(()=>w(r),[r]),a=o.useMemo(()=>B(r,c,d),[d,c,r]),[i,l]=o.useState(()=>h(s));o.useEffect(()=>{l(u=>s.length===0?-1:u>=0&&u<s.length?u:h(s))},[s]);const S=o.useCallback(()=>{l(u=>u<=0?Math.max(u,0):Math.max(u-1,0))},[]),_=o.useCallback(()=>{l(u=>u<0?u:Math.min(u+1,s.length-1))},[s.length]),p=i>0,x=i>=0&&i<s.length-1,g=o.useMemo(()=>{if(i<0)return;const u=s[i];if(u)return b(u)},[i,s]),E=o.useMemo(()=>M(s,i),[i,s]),k=o.useMemo(()=>G(s),[s]),A=o.useMemo(()=>{const u=a.get(i)??[];return U(t.current,u)?t.current:(t.current=u,u)},[i,a]),y=o.useMemo(()=>H(r,c,i),[i,c,r]),q=o.useMemo(()=>g?.type==="interaction"?g:void 0,[g]);return{currentElementList:E,stepElementLists:k,slideElementList:s,currentIndex:i,audioList:f,currentAudioSequenceIndexes:A,currentStepHasSpeakableElement:y,currentInteractionElement:q,canGoPrev:p,canGoNext:x,handlePrev:S,handleNext:_}};exports.default=$;
|
|
2
|
+
//# sourceMappingURL=useSlide.cjs.js.map
|
|
@@ -0,0 +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\";\n\nexport interface SlideAudioItem {\n audioKey?: string;\n sequenceNumber?: number;\n audioUrl?: string;\n audioSegments?: ElementAudioSegment[];\n isAudioStreaming?: boolean;\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 });\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 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 setCurrentIndex((prevIndex) => {\n if (slideElementList.length === 0) {\n return -1;\n }\n\n if (prevIndex >= 0 && prevIndex < slideElementList.length) {\n return prevIndex;\n }\n\n return getInitialSlideIndex(slideElementList);\n });\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","audioList","slideAudioSequenceMap","setCurrentIndex","useState","useEffect","prevIndex","handlePrev","useCallback","handleNext","canGoPrev","canGoNext","currentStepElement","currentElementList","stepElementLists","currentAudioSequenceIndexes","nextAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement"],"mappings":"sKA4BMA,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,EAE/DC,EAAqB,CAACR,EAAkBG,IAAkB,CAC9D,MAAMM,EAAmBT,EAMzB,OACES,EAAiB,aACjBA,EAAiB,UACjBA,EAAiB,qBACjB,GAA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A,EAAiB,MAAM,CAAC,EAEtBiC,EAAY7B,EAAe,EAC3B8B,EACJ9B,GAAgB,GAAKA,EAAeJ,EAAiB,OAAS,EAC1DmC,EAAqBZ,EAAAA,QAAQ,IAAM,CACvC,GAAInB,EAAe,EACjB,OAGF,MAAM9B,EAAU0B,EAAiBI,CAAY,EAE7C,GAAK9B,EAIL,OAAO4B,EAAkB5B,CAAO,CAClC,EAAG,CAAC8B,EAAcJ,CAAgB,CAAC,EAC7BoC,EAAqBb,EAAAA,QACzB,IAAMpB,EAAsBH,EAAkBI,CAAY,EAC1D,CAACA,EAAcJ,CAAgB,CAAA,EAE3BqC,EAAmBd,EAAAA,QACvB,IAAMf,EAAoBR,CAAgB,EAC1C,CAACA,CAAgB,CAAA,EAEbsC,EAA8Bf,EAAAA,QAAQ,IAAM,CAChD,MAAMgB,EACJd,EAAsB,IAAIrB,CAAY,GAAK,CAAA,EAE7C,OACEU,EACEO,EAAqC,QACrCkB,CAAA,EAGKlB,EAAqC,SAG9CA,EAAqC,QAAUkB,EAExCA,EACT,EAAG,CAACnC,EAAcqB,CAAqB,CAAC,EAClCe,EAAiCjB,EAAAA,QACrC,IACEb,EACEY,EACA7B,EACAW,CAAA,EAEJ,CAACA,EAAcX,EAAsB6B,CAAiB,CAAA,EAElDmB,EAA4BlB,EAAAA,QAChC,IACEY,GAAoB,OAAS,cACzBA,EACA,OACN,CAACA,CAAkB,CAAA,EAGrB,MAAO,CACL,mBAAAC,EACA,iBAAAC,EACA,iBAAArC,EACA,aAAAI,EACA,UAAAoB,EACA,4BAAAc,EACA,+BAAAE,EACA,0BAAAC,EACA,UAAAR,EACA,UAAAC,EACA,WAAAJ,EACA,WAAAE,CAAA,CAEJ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Element, ElementAudioSegment } from './types';
|
|
2
|
+
export interface SlideAudioItem {
|
|
3
|
+
audioKey?: string;
|
|
4
|
+
sequenceNumber?: number;
|
|
5
|
+
audioUrl?: string;
|
|
6
|
+
audioSegments?: ElementAudioSegment[];
|
|
7
|
+
isAudioStreaming?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface UseSlideResult {
|
|
10
|
+
currentElementList: Element[];
|
|
11
|
+
stepElementLists: Element[][];
|
|
12
|
+
slideElementList: Element[];
|
|
13
|
+
currentIndex: number;
|
|
14
|
+
audioList: SlideAudioItem[];
|
|
15
|
+
currentAudioSequenceIndexes: number[];
|
|
16
|
+
currentStepHasSpeakableElement: boolean;
|
|
17
|
+
currentInteractionElement?: Element;
|
|
18
|
+
canGoPrev: boolean;
|
|
19
|
+
canGoNext: boolean;
|
|
20
|
+
handlePrev: () => void;
|
|
21
|
+
handleNext: () => void;
|
|
22
|
+
}
|
|
23
|
+
declare const useSlide: (elementList?: Element[]) => UseSlideResult;
|
|
24
|
+
export default useSlide;
|