markdown-flow-ui 0.1.100-beta.47 → 0.1.100-beta.49

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 (39) hide show
  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.cjs.js +1 -1
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.cjs.js +1 -1
  12. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.es.js +1 -1
  13. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
  14. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
  15. package/dist/_virtual/index.cjs4.js +1 -1
  16. package/dist/_virtual/index.cjs5.js +1 -1
  17. package/dist/_virtual/index.cjs6.js +1 -1
  18. package/dist/_virtual/index.cjs7.js +1 -1
  19. package/dist/_virtual/index.es4.js +4 -4
  20. package/dist/_virtual/index.es5.js +4 -4
  21. package/dist/_virtual/index.es6.js +2 -5
  22. package/dist/_virtual/index.es6.js.map +1 -1
  23. package/dist/_virtual/index.es7.js +5 -2
  24. package/dist/_virtual/index.es7.js.map +1 -1
  25. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js +1 -1
  26. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js.map +1 -1
  27. package/dist/components/ContentRender/plugins/CustomVariable.es.js +109 -105
  28. package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
  29. package/dist/components/Slide/Slide.cjs.js +1 -1
  30. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  31. package/dist/components/Slide/Slide.es.js +159 -151
  32. package/dist/components/Slide/Slide.es.js.map +1 -1
  33. package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
  34. package/dist/components/ui/inputGroup/textarea.es.js +1 -1
  35. package/dist/lib/interaction-defaults.cjs.js +1 -1
  36. package/dist/lib/interaction-defaults.cjs.js.map +1 -1
  37. package/dist/lib/interaction-defaults.es.js +84 -58
  38. package/dist/lib/interaction-defaults.es.js.map +1 -1
  39. package/package.json +1 -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 { 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 { 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 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 {\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 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 shouldOpenInteractionOverlayAfterAudio =\n pendingInteractionOverlayStepIndexRef.current === currentIndex &&\n Boolean(currentInteractionElement);\n\n resetAudioSequence();\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (\n shouldBlockPlaybackForInteraction ||\n shouldOpenInteractionOverlayAfterAudio\n ) {\n // Show the interaction gate before playing any follow-up audio.\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 (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 currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n goNext,\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 (currentAudioSequenceKeys.length === 0) {\n setIsAudioLoadingVisible(true);\n }\n }, [\n currentAudioSequenceKeys.length,\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 useEffect(() => {\n if (!hasCurrentStepAudioUrl) {\n return;\n }\n\n // Treat the arrived audio URL as ready and hide the buffering overlay.\n setIsAudioLoadingVisible(false);\n }, [hasCurrentStepAudioUrl]);\n\n const interactionDefaults = useMemo(() => {\n if (!activeInteractionElement) {\n return {};\n }\n\n return getInteractionDefaultValues(\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined,\n activeInteractionElement.user_input,\n interactionDefaultValueOptions\n );\n }, [activeInteractionElement, interactionDefaultValueOptions]);\n\n const interactionDefaultSelectedValues = useMemo(() => {\n if (!activeInteractionElement) {\n return undefined;\n }\n\n return getInteractionDefaultSelectedValues(\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined,\n activeInteractionElement.user_input,\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 (hasCurrentStepAudioUrl) {\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 hasCurrentStepAudioUrl,\n ]\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","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","currentInteractionResetKey","currentPlaybackResetKey","hasCurrentStepAudioUrl","clearPlayerHideTimer","useCallback","clearInteractionAutoCloseTimer","clearAutoAdvanceTimer","resetAudioSequence","startCurrentAudioSequence","nextAudioKey","continueAfterInteraction","showPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","shouldBlockPlaybackForInteraction","useEffect","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","shouldOpenInteractionOverlayAfterAudio","interactionDefaults","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":";;;;;;;;;;;;;;AA8BA,MAAMA,KAAmC,KA0BnCC,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,QAC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T,eAAeA;AAAA,YACf,OAAOxE;AAAA,YAEP,UAAAxE,gBAAAA,EAAAA;AAAAA,cAACb;AAAA,cAAA;AAAA,gBACC,SAAS,OAAO8E,GAA0B,WAAW,EAAE;AAAA,gBACvD,mBAAmByC,GAAoB,cAAc;AAAA,gBACrD,kBAAkBA,GAAoB,aAAa;AAAA,gBACnD,uBAAuBE;AAAA,gBACvB,mBAAmB5F,GAAkB;AAAA,gBACrC,gBAAgBA,GAAkB;AAAA,gBAClC,kBAAkBA,GAAkB;AAAA,gBACpC,QAAQiG;AAAA,gBACR,UAAUF;AAAA,gBACV,OACE/F,GAAkB,SAClBD,MACA;AAAA,cAAA;AAAA,YAAA;AAAA,UAEJ;AAAA,QAAA,IAEA;AAAA,QAEHmC,IACClD,gBAAAA,EAAAA;AAAAA,UAAC8J;AAAA,UAAA;AAAA,YACC,WAAAxH;AAAA,YACA,WAAWwF;AAAA,cACT;AAAA,cACAlH;AAAA,cACA,CAACyD,KAAiB;AAAA,YAAA;AAAA,YAEpB,mBAAAa;AAAA,YACA,gBAAc;AAAA,YACd,gBAAgB,EAAQjB;AAAA,YACxB,mBAAmBE;AAAA,YACnB,iBAAiBkE;AAAA,YACjB,cAAc,CAAC1F;AAAA,YACf,SAAS4F;AAAA,YACT,cAAcR;AAAA,YACd,qBAAqBe;AAAA,YACrB,QAAQV;AAAA,YACR,QAAQD;AAAA,YACR,cAAc,CAACzF;AAAA,YACf,cAAc2B;AAAA,YACd,eAAexD;AAAA,UAAA;AAAA,QAAA,IAEf;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGV;"}
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 { 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 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 {\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 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 shouldOpenInteractionOverlayAfterAudio =\n pendingInteractionOverlayStepIndexRef.current === currentIndex &&\n Boolean(currentInteractionElement);\n const shouldPresentInteractionOverlay =\n Boolean(currentInteractionElement) &&\n (shouldBlockPlaybackForInteraction ||\n shouldOpenInteractionOverlayAfterAudio ||\n hasResolvedCurrentInteraction);\n\n resetAudioSequence();\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldPresentInteractionOverlay) {\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 (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 currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n goNext,\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 (currentAudioSequenceKeys.length === 0) {\n setIsAudioLoadingVisible(true);\n }\n }, [\n currentAudioSequenceKeys.length,\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 useEffect(() => {\n if (!hasCurrentStepAudioUrl) {\n return;\n }\n\n // Treat the arrived audio URL as ready and hide the buffering overlay.\n setIsAudioLoadingVisible(false);\n }, [hasCurrentStepAudioUrl]);\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 (hasCurrentStepAudioUrl) {\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 hasCurrentStepAudioUrl,\n ]\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","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","currentInteractionResetKey","currentPlaybackResetKey","hasCurrentStepAudioUrl","clearPlayerHideTimer","useCallback","clearInteractionAutoCloseTimer","clearAutoAdvanceTimer","resetAudioSequence","startCurrentAudioSequence","nextAudioKey","continueAfterInteraction","showPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","shouldBlockPlaybackForInteraction","useEffect","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","shouldOpenInteractionOverlayAfterAudio","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":";;;;;;;;;;;;;;AA8BA,MAAMA,KAAmC,KA0BnCC,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,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AAAA,UAAA;AAAA,YACC,WAAWgI;AAAA,cACT;AAAA,cACA3D,KAAiBnB,IACb,2CACA;AAAA,YAAA;AAAA,YAEN,SAASgG;AAAA,YACT,eAAeA;AAAA,YACf,OAAO1E;AAAA,YAEP,UAAAxE,gBAAAA,EAAAA;AAAAA,cAACb;AAAA,cAAA;AAAA,gBACC,SAAS,OAAO8E,GAA0B,WAAW,EAAE;AAAA,gBACvD,mBAAmB0C,GAAoB,cAAc;AAAA,gBACrD,kBAAkBA,GAAoB,aAAa;AAAA,gBACnD,uBAAuBG;AAAA,gBACvB,mBAAmB9F,GAAkB;AAAA,gBACrC,gBAAgBA,GAAkB;AAAA,gBAClC,kBAAkBA,GAAkB;AAAA,gBACpC,QAAQmG;AAAA,gBACR,UAAUF;AAAA,gBACV,OACEjG,GAAkB,SAClBD,MACA;AAAA,cAAA;AAAA,YAAA;AAAA,UAEJ;AAAA,QAAA,IAEA;AAAA,QAEHmC,IACClD,gBAAAA,EAAAA;AAAAA,UAACgK;AAAA,UAAA;AAAA,YACC,WAAA1H;AAAA,YACA,WAAW0F;AAAA,cACT;AAAA,cACApH;AAAA,cACA,CAACyD,KAAiB;AAAA,YAAA;AAAA,YAEpB,mBAAAa;AAAA,YACA,gBAAc;AAAA,YACd,gBAAgB,EAAQjB;AAAA,YACxB,mBAAmBE;AAAA,YACnB,iBAAiBoE;AAAA,YACjB,cAAc,CAAC5F;AAAA,YACf,SAAS8F;AAAA,YACT,cAAcR;AAAA,YACd,qBAAqBe;AAAA,YACrB,QAAQV;AAAA,YACR,QAAQD;AAAA,YACR,cAAc,CAAC3F;AAAA,YACf,cAAc2B;AAAA,YACd,eAAexD;AAAA,UAAA;AAAA,QAAA,IAEf;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGV;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../_virtual/jsx-runtime.cjs.js"),s=require("react"),u=require("../../../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");require("../../../_virtual/index.cjs4.js");require("../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.cjs.js");require("../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.cjs.js");require("../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/raf.cjs.js");const d=require("../../../lib/utils.cjs.js");function c(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const l=c(s),i=l.forwardRef(({className:e,autoSize:t={minRows:1},style:r,...a},n)=>o.jsxRuntimeExports.jsx(u.default,{ref:n,autoSize:t,className:d.cn("border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 w-full rounded-md border bg-transparent pl-3 py-1.5 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50","resize-none",e),style:{whiteSpace:"pre-wrap",wordBreak:"break-word",...r},...a}));i.displayName="Textarea";exports.Textarea=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../_virtual/jsx-runtime.cjs.js"),s=require("react"),u=require("../../../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");require("../../../_virtual/index.cjs7.js");require("../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.cjs.js");require("../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.cjs.js");require("../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/raf.cjs.js");const d=require("../../../lib/utils.cjs.js");function c(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const l=c(s),i=l.forwardRef(({className:e,autoSize:t={minRows:1},style:r,...a},n)=>o.jsxRuntimeExports.jsx(u.default,{ref:n,autoSize:t,className:d.cn("border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 w-full rounded-md border bg-transparent pl-3 py-1.5 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50","resize-none",e),style:{whiteSpace:"pre-wrap",wordBreak:"break-word",...r},...a}));i.displayName="Textarea";exports.Textarea=i;
2
2
  //# sourceMappingURL=textarea.cjs.js.map
@@ -1,7 +1,7 @@
1
1
  import { j as i } from "../../../_virtual/jsx-runtime.es.js";
2
2
  import * as d from "react";
3
3
  import n from "../../../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";
4
- import "../../../_virtual/index.es4.js";
4
+ import "../../../_virtual/index.es7.js";
5
5
  import "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-resize-observer@1.4.3_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-resize-observer/es/index.es.js";
6
6
  import "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/hooks/useLayoutEffect.es.js";
7
7
  import "../../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/raf.es.js";
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("../_virtual/index.cjs.js"),b=I.distExports.createInteractionParser(),v=/<custom-variable\b/i,h=/^[\[{]/,V=t=>{if(!t)return null;try{return b.parseToRemarkFormat(t)}catch(n){return console.warn("Failed to parse interaction block",n),null}},T=(t,n)=>{if(!t)return null;const r=t.trim(),e=n.buttonValues||[],s=n.buttonTexts||[],l=e.indexOf(r);if(l>-1)return{value:e[l],display:s[l]};const u=s.indexOf(r);return u>-1?{value:e[u]||s[u],display:s[u]}:null},g=t=>t.split(/[,,\n]/).map(n=>n.trim()).filter(Boolean),D=t=>{if(!t||Array.isArray(t))return null;const n=Array.isArray(t.selectedValues)?t.selectedValues.map(s=>`${s??""}`.trim()).filter(Boolean):void 0,r=`${t.buttonText??""}`.trim(),e=typeof t.inputText=="string"?t.inputText:void 0;return!n?.length&&!r&&!e?null:{buttonText:r||void 0,inputText:e,selectedValues:n?.length?n:void 0}},S=t=>{if(!t||!h.test(t.trim()))return null;try{const n=JSON.parse(t);return D(n)}catch{return null}},A=t=>!!(t&&v.test(t)),x=(t,n,r,e)=>e?.resolveDefaultValues?.({content:t,rawValue:n,interactionInfo:r})??null,m=(t,n,r)=>{const e=n?.toString().trim();if(!e)return{};const s=S(e);if(s)return s;const l=x(t,e,null,r);if(l)return l;if(!A(t))return{buttonText:e,inputText:e};const u=V(t),f=x(t,e,u,r);if(f)return f;if(!u)return{buttonText:e,inputText:e};if(u.isMultiSelect){const d=g(e);if(!d.length)return{};const i=[],c=[];return d.forEach(a=>{const p=T(a,u);if(p){i.push(p.value);return}if(u.placeholder){c.push(a);return}i.push(a)}),{selectedValues:i.length?i:void 0,inputText:c.length?c.join(", "):void 0}}const o=T(e,u);return o?{buttonText:o.value||o.display||e}:u.placeholder?{inputText:e}:{buttonText:e,inputText:e}},B=(t,n,r)=>{const e=m(t,n,r);return e.selectedValues?e.selectedValues:n?n.split(",").map(s=>s.trim()).filter(Boolean):void 0};exports.getInteractionDefaultSelectedValues=B;exports.getInteractionDefaultValues=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../_virtual/index.cjs.js"),I=b.distExports.createInteractionParser(),v=/<custom-variable\b/i,h=/\?\[%\{\{([^}]+)\}\}([\s\S]*?)\]/,g=/^[\[{]/,V=t=>{if(!t)return null;const r=t.match(h),s=r?.[1]?.trim(),e=r?.[2]?.trim();if(!e)return null;const u=e.includes("||"),o=u?"||":"|",n=e.split(o).map(l=>l.trim()).filter(Boolean);if(!n.length)return null;const c=[],i=[];let f;return n.forEach(l=>{if(l.startsWith("...")){const a=l.replace(/^\.\.\./,"").trim();a&&(f=a);return}c.push(l),i.push(l)}),{variableName:s,buttonTexts:c.length?c:void 0,buttonValues:i.length?i:void 0,placeholder:f,isMultiSelect:u}},S=t=>{if(!t)return null;try{return I.parseToRemarkFormat(t)}catch(r){console.warn("Failed to parse interaction block",r)}return V(t)},T=(t,r)=>{if(!t)return null;const s=t.trim(),e=r.buttonValues||[],u=r.buttonTexts||[],o=e.indexOf(s);if(o>-1)return{value:e[o],display:u[o]};const n=u.indexOf(s);return n>-1?{value:e[n]||u[n],display:u[n]}:null},D=t=>t.split(/[,,\n]/).map(r=>r.trim()).filter(Boolean),A=t=>{if(!t||Array.isArray(t))return null;const r=Array.isArray(t.selectedValues)?t.selectedValues.map(u=>`${u??""}`.trim()).filter(Boolean):void 0,s=`${t.buttonText??""}`.trim(),e=typeof t.inputText=="string"?t.inputText:void 0;return!r?.length&&!s&&!e?null:{buttonText:s||void 0,inputText:e,selectedValues:r?.length?r:void 0}},E=t=>{if(!t||!g.test(t.trim()))return null;try{const r=JSON.parse(t);return A(r)}catch{return null}},N=t=>!!(t&&(v.test(t)||h.test(t))),m=(t,r,s,e)=>e?.resolveDefaultValues?.({content:t,rawValue:r,interactionInfo:s})??null,x=(t,r,s)=>{const e=r?.toString().trim();if(!e)return{};const u=E(e);if(u)return u;const o=m(t,e,null,s);if(o)return o;if(!N(t))return{buttonText:e,inputText:e};const n=S(t),c=m(t,e,n,s);if(c)return c;if(!n)return{buttonText:e,inputText:e};if(n.isMultiSelect){const f=D(e);if(!f.length)return{};const l=[],a=[];return f.forEach(d=>{const p=T(d,n);if(p){l.push(p.value);return}if(n.placeholder){a.push(d);return}l.push(d)}),{selectedValues:l.length?l:void 0,inputText:a.length?a.join(", "):void 0}}const i=T(e,n);return i?{buttonText:i.value||i.display||e}:n.placeholder?{inputText:e}:{buttonText:e,inputText:e}},O=(t,r,s)=>{const e=x(t,r,s);return e.selectedValues?e.selectedValues:r?r.split(",").map(u=>u.trim()).filter(Boolean):void 0};exports.getInteractionDefaultSelectedValues=O;exports.getInteractionDefaultValues=x;
2
2
  //# sourceMappingURL=interaction-defaults.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interaction-defaults.cjs.js","sources":["../../src/lib/interaction-defaults.ts"],"sourcesContent":["import { createInteractionParser } from \"remark-flow\";\n\nexport interface InteractionParseResult {\n buttonTexts?: string[];\n buttonValues?: string[];\n placeholder?: string;\n variableName?: string;\n isMultiSelect?: boolean;\n}\n\nexport interface InteractionDefaultValues {\n buttonText?: string;\n inputText?: string;\n selectedValues?: string[];\n}\n\nexport interface InteractionDefaultResolverParams {\n content?: string | null;\n rawValue?: string | null;\n interactionInfo?: InteractionParseResult | null;\n}\n\nexport type InteractionDefaultResolver = (\n params: InteractionDefaultResolverParams\n) => InteractionDefaultValues | null | undefined;\n\nexport interface InteractionDefaultValueOptions {\n resolveDefaultValues?: InteractionDefaultResolver;\n}\n\ninterface StructuredInteractionPayload {\n buttonText?: unknown;\n inputText?: unknown;\n selectedValues?: unknown;\n}\n\nconst interactionParser = createInteractionParser();\nconst INTERACTION_TAG_PATTERN = /<custom-variable\\b/i;\nconst JSON_LIKE_VALUE_PATTERN = /^[\\[{]/;\n\nconst parseInteractionBlock = (\n content?: string | null\n): InteractionParseResult | null => {\n if (!content) {\n return null;\n }\n\n try {\n return interactionParser.parseToRemarkFormat(\n content\n ) as InteractionParseResult;\n } catch (error) {\n console.warn(\"Failed to parse interaction block\", error);\n return null;\n }\n};\n\nconst normalizeButtonValue = (\n token: string,\n info: InteractionParseResult\n): { value: string; display?: string } | null => {\n if (!token) {\n return null;\n }\n\n const cleaned = token.trim();\n const buttonValues = info.buttonValues || [];\n const buttonTexts = info.buttonTexts || [];\n const valueIndex = buttonValues.indexOf(cleaned);\n\n if (valueIndex > -1) {\n return {\n value: buttonValues[valueIndex],\n display: buttonTexts[valueIndex],\n };\n }\n\n const textIndex = buttonTexts.indexOf(cleaned);\n\n if (textIndex > -1) {\n return {\n value: buttonValues[textIndex] || buttonTexts[textIndex],\n display: buttonTexts[textIndex],\n };\n }\n\n return null;\n};\n\nconst splitPresetValues = (raw: string) => {\n return raw\n .split(/[,,\\n]/)\n .map((item) => item.trim())\n .filter(Boolean);\n};\n\nconst normalizeStructuredInteractionDefaults = (\n payload?: StructuredInteractionPayload | null\n): InteractionDefaultValues | null => {\n if (!payload || Array.isArray(payload)) {\n return null;\n }\n\n const selectedValues = Array.isArray(payload.selectedValues)\n ? payload.selectedValues\n .map((item) => `${item ?? \"\"}`.trim())\n .filter(Boolean)\n : undefined;\n const buttonText = `${payload.buttonText ?? \"\"}`.trim();\n const inputText =\n typeof payload.inputText === \"string\" ? payload.inputText : undefined;\n\n if (!selectedValues?.length && !buttonText && !inputText) {\n return null;\n }\n\n return {\n buttonText: buttonText || undefined,\n inputText,\n selectedValues: selectedValues?.length ? selectedValues : undefined,\n };\n};\n\nconst parseStructuredInteractionDefaults = (rawValue?: string | null) => {\n if (!rawValue) {\n return null;\n }\n\n if (!JSON_LIKE_VALUE_PATTERN.test(rawValue.trim())) {\n return null;\n }\n\n try {\n const parsed = JSON.parse(rawValue) as StructuredInteractionPayload;\n return normalizeStructuredInteractionDefaults(parsed);\n } catch {\n return null;\n }\n};\n\nconst hasPotentialInteractionBlock = (content?: string | null) =>\n Boolean(content && INTERACTION_TAG_PATTERN.test(content));\n\nconst resolveCustomInteractionDefaults = (\n content?: string | null,\n rawValue?: string | null,\n interactionInfo?: InteractionParseResult | null,\n options?: InteractionDefaultValueOptions\n) => {\n return (\n options?.resolveDefaultValues?.({\n content,\n rawValue,\n interactionInfo,\n }) ?? null\n );\n};\n\nexport const getInteractionDefaultValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n): InteractionDefaultValues => {\n const normalized = rawValue?.toString().trim();\n\n if (!normalized) {\n return {};\n }\n\n const structuredDefaults = parseStructuredInteractionDefaults(normalized);\n\n if (structuredDefaults) {\n return structuredDefaults;\n }\n\n const customDefaults = resolveCustomInteractionDefaults(\n content,\n normalized,\n null,\n options\n );\n\n if (customDefaults) {\n return customDefaults;\n }\n\n if (!hasPotentialInteractionBlock(content)) {\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n }\n\n const interactionInfo = parseInteractionBlock(content);\n const customDefaultsWithInteraction = resolveCustomInteractionDefaults(\n content,\n normalized,\n interactionInfo,\n options\n );\n\n if (customDefaultsWithInteraction) {\n return customDefaultsWithInteraction;\n }\n\n if (!interactionInfo) {\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n }\n\n if (interactionInfo.isMultiSelect) {\n const tokens = splitPresetValues(normalized);\n\n if (!tokens.length) {\n return {};\n }\n\n const selectedValues: string[] = [];\n const customInputs: string[] = [];\n\n tokens.forEach((token) => {\n const mapped = normalizeButtonValue(token, interactionInfo);\n\n if (mapped) {\n selectedValues.push(mapped.value);\n return;\n }\n\n if (interactionInfo.placeholder) {\n customInputs.push(token);\n return;\n }\n\n selectedValues.push(token);\n });\n\n return {\n selectedValues: selectedValues.length ? selectedValues : undefined,\n inputText: customInputs.length ? customInputs.join(\", \") : undefined,\n };\n }\n\n const mapped = normalizeButtonValue(normalized, interactionInfo);\n\n if (mapped) {\n return {\n buttonText: mapped.value || mapped.display || normalized,\n };\n }\n\n if (interactionInfo.placeholder) {\n return {\n inputText: normalized,\n };\n }\n\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n};\n\nexport const getInteractionDefaultSelectedValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n) => {\n const defaults = getInteractionDefaultValues(content, rawValue, options);\n\n if (defaults.selectedValues) {\n return defaults.selectedValues;\n }\n\n return rawValue\n ? rawValue\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined;\n};\n"],"names":["interactionParser","createInteractionParser","INTERACTION_TAG_PATTERN","JSON_LIKE_VALUE_PATTERN","parseInteractionBlock","content","error","normalizeButtonValue","token","info","cleaned","buttonValues","buttonTexts","valueIndex","textIndex","splitPresetValues","raw","item","normalizeStructuredInteractionDefaults","payload","selectedValues","buttonText","inputText","parseStructuredInteractionDefaults","rawValue","parsed","hasPotentialInteractionBlock","resolveCustomInteractionDefaults","interactionInfo","options","getInteractionDefaultValues","normalized","structuredDefaults","customDefaults","customDefaultsWithInteraction","tokens","customInputs","mapped","getInteractionDefaultSelectedValues","defaults","value"],"mappings":"4HAoCMA,EAAoBC,EAAAA,YAAAA,wBAAA,EACpBC,EAA0B,sBAC1BC,EAA0B,SAE1BC,EACJC,GACkC,CAClC,GAAI,CAACA,EACH,OAAO,KAGT,GAAI,CACF,OAAOL,EAAkB,oBACvBK,CAAA,CAEJ,OAAS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I,MAAA,CAE/D,CAEA,MAAMC,EAAS9B,EAAqBwB,EAAYH,CAAe,EAE/D,OAAIS,EACK,CACL,WAAYA,EAAO,OAASA,EAAO,SAAWN,CAAA,EAI9CH,EAAgB,YACX,CACL,UAAWG,CAAA,EAIR,CACL,WAAYA,EACZ,UAAWA,CAAA,CAEf,EAEaO,EAAsC,CACjDjC,EACAmB,EACAK,IACG,CACH,MAAMU,EAAWT,EAA4BzB,EAASmB,EAAUK,CAAO,EAEvE,OAAIU,EAAS,eACJA,EAAS,eAGXf,EACHA,EACG,MAAM,GAAG,EACT,IAAKgB,GAAUA,EAAM,KAAA,CAAM,EAC3B,OAAO,OAAO,EACjB,MACN"}
1
+ {"version":3,"file":"interaction-defaults.cjs.js","sources":["../../src/lib/interaction-defaults.ts"],"sourcesContent":["import { createInteractionParser } from \"remark-flow\";\n\nexport interface InteractionParseResult {\n buttonTexts?: string[];\n buttonValues?: string[];\n placeholder?: string;\n variableName?: string;\n isMultiSelect?: boolean;\n}\n\nexport interface InteractionDefaultValues {\n buttonText?: string;\n inputText?: string;\n selectedValues?: string[];\n}\n\nexport interface InteractionDefaultResolverParams {\n content?: string | null;\n rawValue?: string | null;\n interactionInfo?: InteractionParseResult | null;\n}\n\nexport type InteractionDefaultResolver = (\n params: InteractionDefaultResolverParams\n) => InteractionDefaultValues | null | undefined;\n\nexport interface InteractionDefaultValueOptions {\n resolveDefaultValues?: InteractionDefaultResolver;\n}\n\ninterface StructuredInteractionPayload {\n buttonText?: unknown;\n inputText?: unknown;\n selectedValues?: unknown;\n}\n\nconst interactionParser = createInteractionParser();\nconst INTERACTION_TAG_PATTERN = /<custom-variable\\b/i;\nconst INTERACTION_SHORTCODE_PATTERN = /\\?\\[%\\{\\{([^}]+)\\}\\}([\\s\\S]*?)\\]/;\nconst JSON_LIKE_VALUE_PATTERN = /^[\\[{]/;\n\nconst parseInteractionShortcode = (\n content?: string | null\n): InteractionParseResult | null => {\n if (!content) {\n return null;\n }\n\n const matched = content.match(INTERACTION_SHORTCODE_PATTERN);\n const variableName = matched?.[1]?.trim();\n const interactionBody = matched?.[2]?.trim();\n\n if (!interactionBody) {\n return null;\n }\n\n const isMultiSelect = interactionBody.includes(\"||\");\n const separator = isMultiSelect ? \"||\" : \"|\";\n const rawOptions = interactionBody\n .split(separator)\n .map((item) => item.trim())\n .filter(Boolean);\n\n if (!rawOptions.length) {\n return null;\n }\n\n const buttonTexts: string[] = [];\n const buttonValues: string[] = [];\n let placeholder: string | undefined;\n\n rawOptions.forEach((option) => {\n if (option.startsWith(\"...\")) {\n const normalizedPlaceholder = option.replace(/^\\.\\.\\./, \"\").trim();\n if (normalizedPlaceholder) {\n placeholder = normalizedPlaceholder;\n }\n return;\n }\n\n buttonTexts.push(option);\n buttonValues.push(option);\n });\n\n return {\n variableName,\n buttonTexts: buttonTexts.length ? buttonTexts : undefined,\n buttonValues: buttonValues.length ? buttonValues : undefined,\n placeholder,\n isMultiSelect,\n };\n};\n\nconst parseInteractionBlock = (\n content?: string | null\n): InteractionParseResult | null => {\n if (!content) {\n return null;\n }\n\n try {\n return interactionParser.parseToRemarkFormat(\n content\n ) as InteractionParseResult;\n } catch (error) {\n console.warn(\"Failed to parse interaction block\", error);\n }\n\n return parseInteractionShortcode(content);\n};\n\nconst normalizeButtonValue = (\n token: string,\n info: InteractionParseResult\n): { value: string; display?: string } | null => {\n if (!token) {\n return null;\n }\n\n const cleaned = token.trim();\n const buttonValues = info.buttonValues || [];\n const buttonTexts = info.buttonTexts || [];\n const valueIndex = buttonValues.indexOf(cleaned);\n\n if (valueIndex > -1) {\n return {\n value: buttonValues[valueIndex],\n display: buttonTexts[valueIndex],\n };\n }\n\n const textIndex = buttonTexts.indexOf(cleaned);\n\n if (textIndex > -1) {\n return {\n value: buttonValues[textIndex] || buttonTexts[textIndex],\n display: buttonTexts[textIndex],\n };\n }\n\n return null;\n};\n\nconst splitPresetValues = (raw: string) => {\n return raw\n .split(/[,,\\n]/)\n .map((item) => item.trim())\n .filter(Boolean);\n};\n\nconst normalizeStructuredInteractionDefaults = (\n payload?: StructuredInteractionPayload | null\n): InteractionDefaultValues | null => {\n if (!payload || Array.isArray(payload)) {\n return null;\n }\n\n const selectedValues = Array.isArray(payload.selectedValues)\n ? payload.selectedValues\n .map((item) => `${item ?? \"\"}`.trim())\n .filter(Boolean)\n : undefined;\n const buttonText = `${payload.buttonText ?? \"\"}`.trim();\n const inputText =\n typeof payload.inputText === \"string\" ? payload.inputText : undefined;\n\n if (!selectedValues?.length && !buttonText && !inputText) {\n return null;\n }\n\n return {\n buttonText: buttonText || undefined,\n inputText,\n selectedValues: selectedValues?.length ? selectedValues : undefined,\n };\n};\n\nconst parseStructuredInteractionDefaults = (rawValue?: string | null) => {\n if (!rawValue) {\n return null;\n }\n\n if (!JSON_LIKE_VALUE_PATTERN.test(rawValue.trim())) {\n return null;\n }\n\n try {\n const parsed = JSON.parse(rawValue) as StructuredInteractionPayload;\n return normalizeStructuredInteractionDefaults(parsed);\n } catch {\n return null;\n }\n};\n\nconst hasPotentialInteractionBlock = (content?: string | null) =>\n Boolean(\n content &&\n (INTERACTION_TAG_PATTERN.test(content) ||\n INTERACTION_SHORTCODE_PATTERN.test(content))\n );\n\nconst resolveCustomInteractionDefaults = (\n content?: string | null,\n rawValue?: string | null,\n interactionInfo?: InteractionParseResult | null,\n options?: InteractionDefaultValueOptions\n) => {\n return (\n options?.resolveDefaultValues?.({\n content,\n rawValue,\n interactionInfo,\n }) ?? null\n );\n};\n\nexport const getInteractionDefaultValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n): InteractionDefaultValues => {\n const normalized = rawValue?.toString().trim();\n\n if (!normalized) {\n return {};\n }\n\n const structuredDefaults = parseStructuredInteractionDefaults(normalized);\n\n if (structuredDefaults) {\n return structuredDefaults;\n }\n\n const customDefaults = resolveCustomInteractionDefaults(\n content,\n normalized,\n null,\n options\n );\n\n if (customDefaults) {\n return customDefaults;\n }\n\n if (!hasPotentialInteractionBlock(content)) {\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n }\n\n const interactionInfo = parseInteractionBlock(content);\n const customDefaultsWithInteraction = resolveCustomInteractionDefaults(\n content,\n normalized,\n interactionInfo,\n options\n );\n\n if (customDefaultsWithInteraction) {\n return customDefaultsWithInteraction;\n }\n\n if (!interactionInfo) {\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n }\n\n if (interactionInfo.isMultiSelect) {\n const tokens = splitPresetValues(normalized);\n\n if (!tokens.length) {\n return {};\n }\n\n const selectedValues: string[] = [];\n const customInputs: string[] = [];\n\n tokens.forEach((token) => {\n const mapped = normalizeButtonValue(token, interactionInfo);\n\n if (mapped) {\n selectedValues.push(mapped.value);\n return;\n }\n\n if (interactionInfo.placeholder) {\n customInputs.push(token);\n return;\n }\n\n selectedValues.push(token);\n });\n\n return {\n selectedValues: selectedValues.length ? selectedValues : undefined,\n inputText: customInputs.length ? customInputs.join(\", \") : undefined,\n };\n }\n\n const mapped = normalizeButtonValue(normalized, interactionInfo);\n\n if (mapped) {\n return {\n buttonText: mapped.value || mapped.display || normalized,\n };\n }\n\n if (interactionInfo.placeholder) {\n return {\n inputText: normalized,\n };\n }\n\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n};\n\nexport const getInteractionDefaultSelectedValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n) => {\n const defaults = getInteractionDefaultValues(content, rawValue, options);\n\n if (defaults.selectedValues) {\n return defaults.selectedValues;\n }\n\n return rawValue\n ? rawValue\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined;\n};\n"],"names":["interactionParser","createInteractionParser","INTERACTION_TAG_PATTERN","INTERACTION_SHORTCODE_PATTERN","JSON_LIKE_VALUE_PATTERN","parseInteractionShortcode","content","matched","variableName","interactionBody","isMultiSelect","separator","rawOptions","item","buttonTexts","buttonValues","placeholder","option","normalizedPlaceholder","parseInteractionBlock","error","normalizeButtonValue","token","info","cleaned","valueIndex","textIndex","splitPresetValues","raw","normalizeStructuredInteractionDefaults","payload","selectedValues","buttonText","inputText","parseStructuredInteractionDefaults","rawValue","parsed","hasPotentialInteractionBlock","resolveCustomInteractionDefaults","interactionInfo","options","getInteractionDefaultValues","normalized","structuredDefaults","customDefaults","customDefaultsWithInteraction","tokens","customInputs","mapped","getInteractionDefaultSelectedValues","defaults","value"],"mappings":"4HAoCMA,EAAoBC,EAAAA,YAAAA,wBAAA,EACpBC,EAA0B,sBAC1BC,EAAgC,mCAChCC,EAA0B,SAE1BC,EACJC,GACkC,CAClC,GAAI,CAACA,EACH,OAAO,KAGT,MAAMC,EAAUD,EAAQ,MAAMH,CAA6B,EACrDK,EAAeD,IAAU,CAAC,GAAG,KAAA,EAC7BE,EAAkBF,IAAU,CAAC,GAAG,KAAA,EAEtC,GAAI,CAACE,EACH,OAAO,KAGT,MAAMC,EAAgBD,EAAgB,SAAS,IAAI,EAC7CE,EAAYD,EAAgB,KAAO,IACnCE,EAAaH,EAChB,MAAME,CAAS,EACf,IAAKE,GAASA,EAAK,KAAA,CAAM,EACzB,OAAO,OAAO,EAEjB,GAAI,CAACD,EAAW,OACd,OAAO,KAGT,MAAME,EAAwB,CAAA,EACxBC,EAAyB,CAAA,EAC/B,IAAIC,EAEJ,OAAAJ,EAAW,QAASK,GAAW,CAC7B,GAAIA,EAAO,WAAW,KAAK,EAAG,CAC5B,MAAMC,EAAwBD,EAAO,QAAQ,UAAW,EAAE,EAAE,KAAA,EACxDC,IACFF,EAAcE,GAEhB,MACF,CAEAJ,EAAY,KAAKG,CAAM,EACvBF,EAAa,KAAKE,CAAM,CAC1B,CAAC,EAEM,CACL,aAAAT,EACA,YAAaM,EAAY,OAASA,EAAc,OAChD,aAAcC,EAAa,OAASA,EAAe,OACnD,YAAAC,EACA,cAAAN,CAAA,CAEJ,EAEMS,EACJb,GACkC,CAClC,GAAI,CAACA,EACH,OAAO,KAGT,GAAI,CACF,OAAON,EAAkB,oBACvBM,CAAA,CAEJ,OAASc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EAAiB,OACzD,UAAWgB,EAAa,OAASA,EAAa,KAAK,IAAI,EAAI,MAAA,CAE/D,CAEA,MAAMC,EAAS3B,EAAqBqB,EAAYH,CAAe,EAE/D,OAAIS,EACK,CACL,WAAYA,EAAO,OAASA,EAAO,SAAWN,CAAA,EAI9CH,EAAgB,YACX,CACL,UAAWG,CAAA,EAIR,CACL,WAAYA,EACZ,UAAWA,CAAA,CAEf,EAEaO,EAAsC,CACjD3C,EACA6B,EACAK,IACG,CACH,MAAMU,EAAWT,EAA4BnC,EAAS6B,EAAUK,CAAO,EAEvE,OAAIU,EAAS,eACJA,EAAS,eAGXf,EACHA,EACG,MAAM,GAAG,EACT,IAAKgB,GAAUA,EAAM,KAAA,CAAM,EAC3B,OAAO,OAAO,EACjB,MACN"}
@@ -1,119 +1,145 @@
1
1
  import { d as x } from "../_virtual/index.es.js";
2
- const I = x.createInteractionParser(), h = /<custom-variable\b/i, v = /^[\[{]/, b = (t) => {
2
+ const b = x.createInteractionParser(), I = /<custom-variable\b/i, h = /\?\[%\{\{([^}]+)\}\}([\s\S]*?)\]/, v = /^[\[{]/, V = (t) => {
3
+ if (!t)
4
+ return null;
5
+ const r = t.match(h), s = r?.[1]?.trim(), e = r?.[2]?.trim();
6
+ if (!e)
7
+ return null;
8
+ const u = e.includes("||"), o = u ? "||" : "|", n = e.split(o).map((l) => l.trim()).filter(Boolean);
9
+ if (!n.length)
10
+ return null;
11
+ const c = [], i = [];
12
+ let f;
13
+ return n.forEach((l) => {
14
+ if (l.startsWith("...")) {
15
+ const a = l.replace(/^\.\.\./, "").trim();
16
+ a && (f = a);
17
+ return;
18
+ }
19
+ c.push(l), i.push(l);
20
+ }), {
21
+ variableName: s,
22
+ buttonTexts: c.length ? c : void 0,
23
+ buttonValues: i.length ? i : void 0,
24
+ placeholder: f,
25
+ isMultiSelect: u
26
+ };
27
+ }, g = (t) => {
3
28
  if (!t)
4
29
  return null;
5
30
  try {
6
- return I.parseToRemarkFormat(
31
+ return b.parseToRemarkFormat(
7
32
  t
8
33
  );
9
- } catch (n) {
10
- return console.warn("Failed to parse interaction block", n), null;
34
+ } catch (r) {
35
+ console.warn("Failed to parse interaction block", r);
11
36
  }
12
- }, T = (t, n) => {
37
+ return V(t);
38
+ }, m = (t, r) => {
13
39
  if (!t)
14
40
  return null;
15
- const r = t.trim(), e = n.buttonValues || [], s = n.buttonTexts || [], l = e.indexOf(r);
16
- if (l > -1)
41
+ const s = t.trim(), e = r.buttonValues || [], u = r.buttonTexts || [], o = e.indexOf(s);
42
+ if (o > -1)
17
43
  return {
18
- value: e[l],
19
- display: s[l]
44
+ value: e[o],
45
+ display: u[o]
20
46
  };
21
- const u = s.indexOf(r);
22
- return u > -1 ? {
23
- value: e[u] || s[u],
24
- display: s[u]
47
+ const n = u.indexOf(s);
48
+ return n > -1 ? {
49
+ value: e[n] || u[n],
50
+ display: u[n]
25
51
  } : null;
26
- }, V = (t) => t.split(/[,,\n]/).map((n) => n.trim()).filter(Boolean), g = (t) => {
52
+ }, A = (t) => t.split(/[,,\n]/).map((r) => r.trim()).filter(Boolean), E = (t) => {
27
53
  if (!t || Array.isArray(t))
28
54
  return null;
29
- const n = Array.isArray(t.selectedValues) ? t.selectedValues.map((s) => `${s ?? ""}`.trim()).filter(Boolean) : void 0, r = `${t.buttonText ?? ""}`.trim(), e = typeof t.inputText == "string" ? t.inputText : void 0;
30
- return !n?.length && !r && !e ? null : {
31
- buttonText: r || void 0,
55
+ const r = Array.isArray(t.selectedValues) ? t.selectedValues.map((u) => `${u ?? ""}`.trim()).filter(Boolean) : void 0, s = `${t.buttonText ?? ""}`.trim(), e = typeof t.inputText == "string" ? t.inputText : void 0;
56
+ return !r?.length && !s && !e ? null : {
57
+ buttonText: s || void 0,
32
58
  inputText: e,
33
- selectedValues: n?.length ? n : void 0
59
+ selectedValues: r?.length ? r : void 0
34
60
  };
35
- }, A = (t) => {
61
+ }, S = (t) => {
36
62
  if (!t || !v.test(t.trim()))
37
63
  return null;
38
64
  try {
39
- const n = JSON.parse(t);
40
- return g(n);
65
+ const r = JSON.parse(t);
66
+ return E(r);
41
67
  } catch {
42
68
  return null;
43
69
  }
44
- }, D = (t) => !!(t && h.test(t)), m = (t, n, r, e) => e?.resolveDefaultValues?.({
70
+ }, D = (t) => !!(t && (I.test(t) || h.test(t))), T = (t, r, s, e) => e?.resolveDefaultValues?.({
45
71
  content: t,
46
- rawValue: n,
47
- interactionInfo: r
48
- }) ?? null, B = (t, n, r) => {
49
- const e = n?.toString().trim();
72
+ rawValue: r,
73
+ interactionInfo: s
74
+ }) ?? null, N = (t, r, s) => {
75
+ const e = r?.toString().trim();
50
76
  if (!e)
51
77
  return {};
52
- const s = A(e);
53
- if (s)
54
- return s;
55
- const l = m(
78
+ const u = S(e);
79
+ if (u)
80
+ return u;
81
+ const o = T(
56
82
  t,
57
83
  e,
58
84
  null,
59
- r
85
+ s
60
86
  );
61
- if (l)
62
- return l;
87
+ if (o)
88
+ return o;
63
89
  if (!D(t))
64
90
  return {
65
91
  buttonText: e,
66
92
  inputText: e
67
93
  };
68
- const u = b(t), f = m(
94
+ const n = g(t), c = T(
69
95
  t,
70
96
  e,
71
- u,
72
- r
97
+ n,
98
+ s
73
99
  );
74
- if (f)
75
- return f;
76
- if (!u)
100
+ if (c)
101
+ return c;
102
+ if (!n)
77
103
  return {
78
104
  buttonText: e,
79
105
  inputText: e
80
106
  };
81
- if (u.isMultiSelect) {
82
- const d = V(e);
83
- if (!d.length)
107
+ if (n.isMultiSelect) {
108
+ const f = A(e);
109
+ if (!f.length)
84
110
  return {};
85
- const o = [], c = [];
86
- return d.forEach((a) => {
87
- const p = T(a, u);
111
+ const l = [], a = [];
112
+ return f.forEach((d) => {
113
+ const p = m(d, n);
88
114
  if (p) {
89
- o.push(p.value);
115
+ l.push(p.value);
90
116
  return;
91
117
  }
92
- if (u.placeholder) {
93
- c.push(a);
118
+ if (n.placeholder) {
119
+ a.push(d);
94
120
  return;
95
121
  }
96
- o.push(a);
122
+ l.push(d);
97
123
  }), {
98
- selectedValues: o.length ? o : void 0,
99
- inputText: c.length ? c.join(", ") : void 0
124
+ selectedValues: l.length ? l : void 0,
125
+ inputText: a.length ? a.join(", ") : void 0
100
126
  };
101
127
  }
102
- const i = T(e, u);
128
+ const i = m(e, n);
103
129
  return i ? {
104
130
  buttonText: i.value || i.display || e
105
- } : u.placeholder ? {
131
+ } : n.placeholder ? {
106
132
  inputText: e
107
133
  } : {
108
134
  buttonText: e,
109
135
  inputText: e
110
136
  };
111
- }, S = (t, n, r) => {
112
- const e = B(t, n, r);
113
- return e.selectedValues ? e.selectedValues : n ? n.split(",").map((s) => s.trim()).filter(Boolean) : void 0;
137
+ }, O = (t, r, s) => {
138
+ const e = N(t, r, s);
139
+ return e.selectedValues ? e.selectedValues : r ? r.split(",").map((u) => u.trim()).filter(Boolean) : void 0;
114
140
  };
115
141
  export {
116
- S as getInteractionDefaultSelectedValues,
117
- B as getInteractionDefaultValues
142
+ O as getInteractionDefaultSelectedValues,
143
+ N as getInteractionDefaultValues
118
144
  };
119
145
  //# sourceMappingURL=interaction-defaults.es.js.map