markdown-flow-ui 0.1.100-beta.25 → 0.1.100-beta.26

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),et=require("../../lib/sandboxInteraction.cjs.js"),L=require("../../lib/utils.cjs.js"),tt=require("../ContentRender/ContentRender.cjs.js"),Ie=require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");const we=require("../../lib/interaction-defaults.cjs.js"),nt=require("./Player.cjs.js"),rt=require("./useSlide.cjs.js"),st=require("./useWakePlayerFromIframe.cjs.js"),ot=require("./utils/playerCustomActions.cjs.js");;/* empty css */const ut=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/loader-circle.cjs.js"),lt=1e3,Ce=t.memo(({content:R,title:j,defaultButtonText:d,defaultInputText:q,defaultSelectedValues:p,confirmButtonText:Z,copyButtonText:ee,copiedButtonText:I,onSend:A,readonly:w=!1})=>n.jsxRuntimeExports.jsxs("div",{className:"slide-player__interaction-card",children:[n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-header",children:n.jsxRuntimeExports.jsx("p",{className:"slide-player__interaction-title",children:j})}),n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-body",children:n.jsxRuntimeExports.jsx(tt.default,{content:R,defaultButtonText:d,defaultInputText:q,defaultSelectedValues:p,confirmButtonText:Z,copyButtonText:ee,copiedButtonText:I,onSend:A,readonly:w,enableTypewriter:!1,sandboxMode:"content"})}),n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-arrow"})]}));Ce.displayName="InteractionOverlayCard";const it=(R,j)=>R.length===j.length&&R.every((d,q)=>{const p=j[q];return d.sequence_number===p?.sequence_number&&d.type===p?.type&&d.content===p?.content}),at=({elementList:R=[],showPlayer:j=!0,playerAlwaysVisible:d=!1,playerClassName:q,playerCustomActions:p,bufferingText:Z="Buffering...",interactionTitle:ee,interactionTexts:I,playerAutoHideDelay:A=3e3,interactionDefaultValueOptions:w,onSend:se,onPlayerVisibilityChange:te,onStepChange:oe,className:_e,onPointerDown:ue,...Te})=>{const ne=t.useRef(null),re=t.useRef(null),le=t.useRef(null),P=t.useRef(null),N=t.useRef(null),M=t.useRef(null),ie=t.useRef([]),O=t.useRef(!1),{currentElementList:h,stepElementLists:ae,slideElementList:H,currentIndex:f,audioList:ce,currentAudioSequenceIndexes:g,currentStepHasSpeakableElement:C,currentInteractionElement:i,canGoPrev:ke,canGoNext:v,handlePrev:de,handleNext:y}=rt.default(R),fe=t.useMemo(()=>{if(!(f<0))return H[f]},[f,H]),qe=H.filter(e=>e.is_renderable!==!1).length===1,m=j&&(H.length>0||ce.length>0||!!i),[me,K]=t.useState(!0),[$,B]=t.useState(!1),[Ae,D]=t.useState(-1),[z,V]=t.useState(-1),[Pe,x]=t.useState(!1),[W,xe]=t.useState(!1),[s,G]=t.useState(),[U,F]=t.useState(!1),_=m&&(d||me),pe=t.useMemo(()=>ot.getPlayerCustomActionCount(p),[p]),Ne=t.useMemo(()=>({"--slide-player-custom-action-count":String(pe)}),[pe]),{mountedStepStates:Me,currentMountedStateIndex:Be}=t.useMemo(()=>{const e=[],r=new Map;return ae.forEach((u,c)=>{const o=e.findIndex(l=>it(l.elementList,u));if(o>=0){e[o]?.sourceStepIndexes.push(c),r.set(c,o);return}e.push({elementList:u,sourceStepIndexes:[c]}),r.set(c,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:f>=0?r.get(f)??-1:-1}},[f,ae]),he=t.useMemo(()=>String(f),[f]),ge=t.useMemo(()=>String(g[0]??"none"),[g]),be=t.useMemo(()=>i?`${i.sequence_number??"none"}:${String(i.content??"")}`:"none",[i]),Fe=t.useMemo(()=>[he,be,ge].join("|"),[ge,be,he]),E=t.useCallback(()=>{P.current!==null&&(window.clearTimeout(P.current),P.current=null)},[]),b=t.useCallback(()=>{M.current!==null&&(window.clearTimeout(M.current),M.current=null)},[]),T=t.useCallback(()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null)},[]),k=t.useCallback(()=>{T(),b(),D(-1),V(-1),x(!1),xe(!1),G(void 0),F(!1)},[T,b]),Y=t.useCallback(()=>{const e=g[0];return typeof e!="number"?!1:(V(0),D(e),!0)},[g]),J=t.useCallback(()=>{b(),F(!1),!Y()&&v&&y()},[v,b,y,Y]),a=t.useCallback((e=$)=>{m&&(K(!0),E(),!(d||!e||A<=0)&&(P.current=window.setTimeout(()=>{K(!1),P.current=null},A)))},[E,$,d,A,m]),Le=!!(i?.readonly||i?.user_input?.trim()),Q=!!i&&!Le;t.useEffect(()=>()=>{T(),E(),b()},[T,b,E]),t.useEffect(()=>(te?.(_),()=>{te?.(!1)}),[te,_]),t.useEffect(()=>{oe?.(fe,f)},[f,fe,oe]),t.useEffect(()=>{if(!m){E(),K(!1);return}if(d){E(),K(!0);return}$||a(!0)},[E,$,d,m,a]),t.useEffect(()=>{if(typeof window>"u")return;const e=r=>{r.origin===window.location.origin&&et.isSandboxInteractionMessage(r.data)&&m&&(B(!0),a(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[m,a]),st.default({sectionRef:ne,enabled:m,onWake:()=>{B(!0),a(!0)}}),t.useEffect(()=>{if(k(),!(h.length===0&&!i)){if(Q){G(i),F(!0);return}if(i&&(G(i),F(!1)),!Y()){if(C){x(!0);return}if(v)return N.current=window.setTimeout(()=>{N.current=null,y()},lt),()=>{T()}}}},[v,T,h.length,i,Fe,C,y,Q,k,Y]),t.useEffect(()=>{if(!C||Q){x(!1);return}if(W){x(!1);return}g.length===0&&x(!0)},[g.length,C,W,Q]);const Se=t.useMemo(()=>s?we.getInteractionDefaultValues(typeof s.content=="string"?s.content:void 0,s.user_input,w):{},[s,w]),Oe=t.useMemo(()=>{if(s)return we.getInteractionDefaultSelectedValues(typeof s.content=="string"?s.content:void 0,s.user_input,w)},[s,w]),ye=!!s?.user_input?.trim(),ve=!!s?.readonly||ye,Ee=ve||ye,He=t.useCallback(e=>{const u=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");G(c=>!c||!u?c:{...c,user_input:u}),se?.(e,s),J()},[s,J,se]);t.useEffect(()=>{if(b(),!(!U||!Ee))return M.current=window.setTimeout(()=>{M.current=null,J()},2e3),()=>{b()}},[b,J,U,Ee]);const Ke=(e,r={})=>e?e.type==="slot"?n.jsxRuntimeExports.jsx(n.jsxRuntimeExports.Fragment,{children:e.content}):e.type==="html"?n.jsxRuntimeExports.jsx(Ie.default,{className:"content-render-iframe",hideFullScreen:!0,mode:"blackboard",replaceRootScreenHeightWithFull:r.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content}):n.jsxRuntimeExports.jsx(Ie.default,{className:"content-render-iframe",hideFullScreen:!0,mode:"blackboard",type:"markdown",content:e.content}):null,$e=(e=[],r=!1)=>{if(e.length===0)return null;const u=e.filter(o=>o.is_renderable!==!1).length,c=e.reduce((o,l,S)=>l.is_renderable!==!1?S:o,-1);return n.jsxRuntimeExports.jsx("div",{className:"slide-stage__content flex w-full flex-col gap-4",children:e.map((o,l)=>{const S=o.type==="html"&&o.is_renderable===!1;return n.jsxRuntimeExports.jsx("div",{ref:r&&l===c?le:null,"aria-hidden":S||void 0,className:L.cn("w-full shrink-0",u===1&&o.is_renderable!==!1&&"slide-element--single",S?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":o.is_renderable===!1&&"hidden"),children:Ke(o,{replaceRootScreenHeightWithFull:u===1&&o.type==="html"&&o.is_renderable!==!1})},o.sequence_number??`${o.type}-${l}`)})})},De=()=>{const e=ne.current;if(e){if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},Re=t.useCallback(()=>{const e=re.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),ze=t.useCallback(()=>{O.current=!0,B(!0),x(!1),a(!0),k(),de()},[de,k,a]),Ve=t.useCallback(()=>{O.current=!0,B(!0),x(!1),a(!0),k(),y()},[y,k,a]),We=t.useCallback(e=>{if(!C||W){x(!1);return}x(e)},[C,W]),Ge=t.useCallback(e=>{if(z<0||g[z]!==e)return;const r=z+1,u=g[r];if(typeof u=="number"){V(r),D(u);return}D(-1),V(-1),xe(!0),x(!1),v&&y()},[v,g,z,y]),Ue=t.useCallback(()=>{s&&F(e=>!e)},[s]),je=t.useCallback(e=>{e.stopPropagation(),_&&a(!0)},[me,a]),Ye=t.useCallback(e=>{ue?.(e),B(!0),a(!0)},[ue,a]),Je=!!s&&U,X=t.useMemo(()=>h.map((e,r)=>`${e.sequence_number??`${e.type}-${r}`}:${String(e.is_new??"")}`),[h]);return t.useEffect(()=>{const e=ie.current,c=(e.length>0&&e.length<X.length&&e.every((l,S)=>l===X[S])?h.slice(e.length):[]).some(l=>l.is_new===!1);if(ie.current=X,!c)return;const o=window.requestAnimationFrame(()=>{const l=re.current,S=le.current;if(!l||!S)return;const Qe=l.getBoundingClientRect(),Xe=S.getBoundingClientRect(),Ze=l.scrollTop+(Xe.top-Qe.top);l.scrollTo({top:Math.max(Ze,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(o)}},[h,X]),t.useEffect(()=>{if(!O.current||(O.current=!1,h.length===0))return;const e=window.requestAnimationFrame(()=>{Re()});return()=>{window.cancelAnimationFrame(e)}},[h,Re]),n.jsxRuntimeExports.jsxs("section",{ref:ne,className:L.cn("relative h-full w-full",_e),onPointerDown:Ye,...Te,children:[n.jsxRuntimeExports.jsx("div",{className:L.cn("h-full min-h-0 w-full",qe?"slide-content--single":"grid gap-4"),children:h.length>0?n.jsxRuntimeExports.jsx("div",{className:"slide-stage",children:n.jsxRuntimeExports.jsx("div",{ref:re,className:"slide-stage__layer w-full",children:Me.map((e,r)=>{const u=r===Be;return n.jsxRuntimeExports.jsx("div",{"aria-hidden":!u||void 0,className:"w-full h-full",style:{display:u?void 0:"none"},children:$e(e.elementList,u)},e.sourceStepIndexes[0]??r)})})}):null}),Pe?n.jsxRuntimeExports.jsxs("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",children:[n.jsxRuntimeExports.jsx(ut.default,{className:"size-5 animate-spin text-background"}),n.jsxRuntimeExports.jsx("span",{children:Z})]}):null,Je?n.jsxRuntimeExports.jsx("div",{className:L.cn("slide-interaction-overlay",_&&m?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone"),onClick:je,onPointerDown:je,style:Ne,children:n.jsxRuntimeExports.jsx(Ce,{content:String(s?.content??""),defaultButtonText:Se.buttonText??"",defaultInputText:Se.inputText??"",defaultSelectedValues:Oe,confirmButtonText:I?.confirmButtonText,copyButtonText:I?.copyButtonText,copiedButtonText:I?.copiedButtonText,onSend:He,readonly:ve,title:I?.title??ee??"Submit the content below to continue."})}):null,m?n.jsxRuntimeExports.jsx(nt.default,{audioList:ce,className:L.cn("absolute left-1/2 bottom-6 z-[2] -translate-x-1/2",q,!_&&"pointer-events-none opacity-0"),currentAudioIndex:Ae,defaultPlaying:!0,hasInteraction:!!s,isInteractionOpen:U,onLoadingChange:We,nextDisabled:!v,onEnded:Ge,onFullscreen:De,onInteractionToggle:Ue,onNext:Ve,onPrev:ze,prevDisabled:!ke,showControls:_,customActions:p}):null]})};exports.default=at;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),tt=require("../../lib/sandboxInteraction.cjs.js"),H=require("../../lib/utils.cjs.js"),nt=require("../ContentRender/ContentRender.cjs.js"),we=require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");const Ce=require("../../lib/interaction-defaults.cjs.js"),rt=require("./Player.cjs.js"),st=require("./useSlide.cjs.js"),ot=require("./useWakePlayerFromIframe.cjs.js"),ut=require("./utils/playerCustomActions.cjs.js");;/* empty css */const lt=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/loader-circle.cjs.js"),it=1e3,_e=t.memo(({content:R,title:I,defaultButtonText:f,defaultInputText:P,defaultSelectedValues:p,confirmButtonText:ee,copyButtonText:te,copiedButtonText:j,onSend:N,readonly:w=!1})=>n.jsxRuntimeExports.jsxs("div",{className:"slide-player__interaction-card",children:[n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-header",children:n.jsxRuntimeExports.jsx("p",{className:"slide-player__interaction-title",children:I})}),n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-body",children:n.jsxRuntimeExports.jsx(nt.default,{content:R,defaultButtonText:f,defaultInputText:P,defaultSelectedValues:p,confirmButtonText:ee,copyButtonText:te,copiedButtonText:j,onSend:N,readonly:w,enableTypewriter:!1,sandboxMode:"content"})}),n.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-arrow"})]}));_e.displayName="InteractionOverlayCard";const at=(R,I)=>R.length===I.length&&R.every((f,P)=>{const p=I[P];return f.sequence_number===p?.sequence_number&&f.type===p?.type&&f.content===p?.content}),ct=({elementList:R=[],showPlayer:I=!0,playerAlwaysVisible:f=!1,playerClassName:P,playerCustomActions:p,bufferingText:ee="Buffering...",interactionTitle:te,interactionTexts:j,playerAutoHideDelay:N=3e3,interactionDefaultValueOptions:w,onSend:oe,onPlayerVisibilityChange:ne,onStepChange:ue,className:Te,onPointerDown:le,...ke})=>{const re=t.useRef(null),se=t.useRef(null),ie=t.useRef(null),M=t.useRef(null),B=t.useRef(null),F=t.useRef(null),ae=t.useRef([]),K=t.useRef(!1),C=t.useRef(null),{currentElementList:h,stepElementLists:ce,slideElementList:_,currentIndex:c,audioList:de,currentAudioSequenceIndexes:g,currentStepHasSpeakableElement:T,currentInteractionElement:a,canGoPrev:Ae,canGoNext:v,handlePrev:fe,handleNext:y}=st.default(R),me=t.useMemo(()=>{if(!(c<0))return _[c]},[c,_]),qe=_.filter(e=>e.is_renderable!==!1).length===1,m=I&&(_.length>0||de.length>0||!!a),[xe,$]=t.useState(!0),[D,L]=t.useState(!1),[Pe,z]=t.useState(-1),[V,W]=t.useState(-1),[Ne,x]=t.useState(!1),[G,pe]=t.useState(!1),[o,U]=t.useState(),[Y,O]=t.useState(!1),k=m&&(f||xe),he=t.useMemo(()=>ut.getPlayerCustomActionCount(p),[p]),Me=t.useMemo(()=>({"--slide-player-custom-action-count":String(he)}),[he]),{mountedStepStates:Be,currentMountedStateIndex:Fe}=t.useMemo(()=>{const e=[],r=new Map;return ce.forEach((u,l)=>{const s=e.findIndex(i=>at(i.elementList,u));if(s>=0){e[s]?.sourceStepIndexes.push(l),r.set(l,s);return}e.push({elementList:u,sourceStepIndexes:[l]}),r.set(l,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:c>=0?r.get(c)??-1:-1}},[c,ce]),ge=t.useMemo(()=>String(c),[c]),Se=t.useMemo(()=>String(g[0]??"none"),[g]),be=t.useMemo(()=>a?`${a.sequence_number??"none"}:${String(a.content??"")}`:"none",[a]),Le=t.useMemo(()=>[ge,be,Se].join("|"),[Se,be,ge]),E=t.useCallback(()=>{M.current!==null&&(window.clearTimeout(M.current),M.current=null)},[]),S=t.useCallback(()=>{F.current!==null&&(window.clearTimeout(F.current),F.current=null)},[]),A=t.useCallback(()=>{B.current!==null&&(window.clearTimeout(B.current),B.current=null)},[]),q=t.useCallback(()=>{A(),S(),z(-1),W(-1),x(!1),pe(!1),U(void 0),O(!1)},[A,S]),J=t.useCallback(()=>{const e=g[0];return typeof e!="number"?!1:(W(0),z(e),!0)},[g]),Q=t.useCallback(()=>{S(),O(!1),!J()&&v&&y()},[v,S,y,J]),d=t.useCallback((e=D)=>{m&&($(!0),E(),!(f||!e||N<=0)&&(M.current=window.setTimeout(()=>{$(!1),M.current=null},N)))},[E,D,f,N,m]),Oe=!!(a?.readonly||a?.user_input?.trim()),X=!!a&&!Oe;t.useEffect(()=>()=>{A(),E(),S()},[A,S,E]),t.useEffect(()=>(ne?.(k),()=>{ne?.(!1)}),[ne,k]),t.useEffect(()=>{ue?.(me,c)},[c,me,ue]),t.useEffect(()=>{if(!m){E(),$(!1);return}if(f){E(),$(!0);return}D||d(!0)},[E,D,f,m,d]),t.useEffect(()=>{if(typeof window>"u")return;const e=r=>{r.origin===window.location.origin&&tt.isSandboxInteractionMessage(r.data)&&m&&(L(!0),d(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[m,d]),ot.default({sectionRef:re,enabled:m,onWake:()=>{L(!0),d(!0)}}),t.useEffect(()=>{const e=C.current===c&&!!a;if(q(),!(h.length===0&&!a)){if(X||e){U(a),O(!0),C.current=null;return}if(a&&(U(a),O(!1),C.current=null),!J()){if(T){x(!0);return}if(v)return B.current=window.setTimeout(()=>{B.current=null,y()},it),()=>{A()}}}},[v,A,h.length,a,Le,T,y,X,q,J]),t.useEffect(()=>{if(!T||X){x(!1);return}if(G){x(!1);return}g.length===0&&x(!0)},[g.length,T,G,X]);const ye=t.useMemo(()=>o?Ce.getInteractionDefaultValues(typeof o.content=="string"?o.content:void 0,o.user_input,w):{},[o,w]),He=t.useMemo(()=>{if(o)return Ce.getInteractionDefaultSelectedValues(typeof o.content=="string"?o.content:void 0,o.user_input,w)},[o,w]),ve=!!o?.user_input?.trim(),Ee=!!o?.readonly||ve,Re=Ee||ve,Ke=t.useCallback(e=>{const u=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");U(l=>!l||!u?l:{...l,user_input:u}),oe?.(e,o),Q()},[o,Q,oe]);t.useEffect(()=>{if(S(),!(!Y||!Re))return F.current=window.setTimeout(()=>{F.current=null,Q()},2e3),()=>{S()}},[S,Q,Y,Re]);const $e=(e,r={})=>e?e.type==="slot"?n.jsxRuntimeExports.jsx(n.jsxRuntimeExports.Fragment,{children:e.content}):e.type==="html"?n.jsxRuntimeExports.jsx(we.default,{className:"content-render-iframe",hideFullScreen:!0,mode:"blackboard",replaceRootScreenHeightWithFull:r.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content}):n.jsxRuntimeExports.jsx(we.default,{className:"content-render-iframe",hideFullScreen:!0,mode:"blackboard",type:"markdown",content:e.content}):null,De=(e=[],r=!1)=>{if(e.length===0)return null;const u=e.filter(s=>s.is_renderable!==!1).length,l=e.reduce((s,i,b)=>i.is_renderable!==!1?b:s,-1);return n.jsxRuntimeExports.jsx("div",{className:"slide-stage__content flex w-full flex-col gap-4",children:e.map((s,i)=>{const b=s.type==="html"&&s.is_renderable===!1;return n.jsxRuntimeExports.jsx("div",{ref:r&&i===l?ie:null,"aria-hidden":b||void 0,className:H.cn("w-full shrink-0",u===1&&s.is_renderable!==!1&&"slide-element--single",b?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":s.is_renderable===!1&&"hidden"),children:$e(s,{replaceRootScreenHeightWithFull:u===1&&s.type==="html"&&s.is_renderable!==!1})},s.sequence_number??`${s.type}-${i}`)})})},ze=()=>{const e=re.current;if(e){if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},Ie=t.useCallback(()=>{const e=se.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),Ve=t.useCallback(()=>{K.current=!0,C.current=null,L(!0),x(!1),d(!0),q(),fe()},[fe,q,d]),We=t.useCallback(()=>{K.current=!0,C.current=null,L(!0),x(!1),d(!0),q(),y()},[y,q,d]),Ge=t.useCallback(e=>{if(!T||G){x(!1);return}x(e)},[T,G]),Ue=t.useCallback(e=>{if(V<0||g[V]!==e)return;const r=V+1,u=g[r];if(typeof u=="number"){W(r),z(u);return}if(z(-1),W(-1),pe(!0),x(!1),v){const l=c+1;_[l]?.type==="interaction"&&(C.current=l),y()}},[v,c,g,V,y,_]),Ye=t.useCallback(()=>{o&&O(e=>!e)},[o]),je=t.useCallback(e=>{e.stopPropagation(),k&&d(!0)},[xe,d]),Je=t.useCallback(e=>{le?.(e),L(!0),d(!0)},[le,d]),Qe=!!o&&Y,Z=t.useMemo(()=>h.map((e,r)=>`${e.sequence_number??`${e.type}-${r}`}:${String(e.is_new??"")}`),[h]);return t.useEffect(()=>{const e=ae.current,l=(e.length>0&&e.length<Z.length&&e.every((i,b)=>i===Z[b])?h.slice(e.length):[]).some(i=>i.is_new===!1);if(ae.current=Z,!l)return;const s=window.requestAnimationFrame(()=>{const i=se.current,b=ie.current;if(!i||!b)return;const Xe=i.getBoundingClientRect(),Ze=b.getBoundingClientRect(),et=i.scrollTop+(Ze.top-Xe.top);i.scrollTo({top:Math.max(et,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(s)}},[h,Z]),t.useEffect(()=>{if(!K.current||(K.current=!1,h.length===0))return;const e=window.requestAnimationFrame(()=>{Ie()});return()=>{window.cancelAnimationFrame(e)}},[h,Ie]),n.jsxRuntimeExports.jsxs("section",{ref:re,className:H.cn("relative h-full w-full",Te),onPointerDown:Je,...ke,children:[n.jsxRuntimeExports.jsx("div",{className:H.cn("h-full min-h-0 w-full",qe?"slide-content--single":"grid gap-4"),children:h.length>0?n.jsxRuntimeExports.jsx("div",{className:"slide-stage",children:n.jsxRuntimeExports.jsx("div",{ref:se,className:"slide-stage__layer w-full",children:Be.map((e,r)=>{const u=r===Fe;return n.jsxRuntimeExports.jsx("div",{"aria-hidden":!u||void 0,className:"w-full h-full",style:{display:u?void 0:"none"},children:De(e.elementList,u)},e.sourceStepIndexes[0]??r)})})}):null}),Ne?n.jsxRuntimeExports.jsxs("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",children:[n.jsxRuntimeExports.jsx(lt.default,{className:"size-5 animate-spin text-background"}),n.jsxRuntimeExports.jsx("span",{children:ee})]}):null,Qe?n.jsxRuntimeExports.jsx("div",{className:H.cn("slide-interaction-overlay",k&&m?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone"),onClick:je,onPointerDown:je,style:Me,children:n.jsxRuntimeExports.jsx(_e,{content:String(o?.content??""),defaultButtonText:ye.buttonText??"",defaultInputText:ye.inputText??"",defaultSelectedValues:He,confirmButtonText:j?.confirmButtonText,copyButtonText:j?.copyButtonText,copiedButtonText:j?.copiedButtonText,onSend:Ke,readonly:Ee,title:j?.title??te??"Submit the content below to continue."})}):null,m?n.jsxRuntimeExports.jsx(rt.default,{audioList:de,className:H.cn("absolute left-1/2 bottom-6 z-[2] -translate-x-1/2",P,!k&&"pointer-events-none opacity-0"),currentAudioIndex:Pe,defaultPlaying:!0,hasInteraction:!!o,isInteractionOpen:Y,onLoadingChange:Ge,nextDisabled:!v,onEnded:Ue,onFullscreen:ze,onInteractionToggle:Ye,onNext:We,onPrev:Ve,prevDisabled:!Ae,showControls:k,customActions:p}):null]})};exports.default=ct;
2
2
  //# sourceMappingURL=Slide.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Slide.cjs.js","sources":["../../../src/components/Slide/Slide.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n 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\n extends Pick<\n ContentRenderProps,\n \"confirmButtonText\" | \"copyButtonText\" | \"copiedButtonText\"\n > {\n title?: string;\n}\n\nconst InteractionOverlayCard = memo(\n ({\n content,\n title,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n onSend,\n readonly = false,\n }: InteractionOverlayCardProps) => (\n <div className=\"slide-player__interaction-card\">\n <div className=\"slide-player__interaction-header\">\n <p className=\"slide-player__interaction-title\">{title}</p>\n </div>\n <div className=\"slide-player__interaction-body\">\n <ContentRender\n content={content}\n defaultButtonText={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n onSend={onSend}\n readonly={readonly}\n enableTypewriter={false}\n sandboxMode=\"content\"\n />\n </div>\n <div className=\"slide-player__interaction-arrow\" />\n </div>\n )\n);\n\nInteractionOverlayCard.displayName = \"InteractionOverlayCard\";\n\nconst areStepElementListsEqual = (\n prevElementList: Element[],\n nextElementList: Element[]\n) =>\n prevElementList.length === nextElementList.length &&\n prevElementList.every((element, index) => {\n const nextElement = nextElementList[index];\n\n return (\n element.sequence_number === nextElement?.sequence_number &&\n element.type === nextElement?.type &&\n element.content === nextElement?.content\n );\n });\n\nexport interface SlideProps extends React.ComponentProps<\"section\"> {\n elementList?: Element[];\n showPlayer?: boolean;\n playerAlwaysVisible?: boolean;\n playerClassName?: string;\n playerCustomActions?: PlayerProps[\"customActions\"];\n bufferingText?: string;\n interactionTitle?: string;\n interactionTexts?: SlideInteractionTexts;\n playerAutoHideDelay?: number;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n onSend?: (content: OnSendContentParams, element?: Element) => void;\n onPlayerVisibilityChange?: (visible: boolean) => void;\n onStepChange?: (element: Element | undefined, index: number) => void;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n showPlayer = true,\n playerAlwaysVisible = false,\n playerClassName,\n playerCustomActions,\n bufferingText = \"Buffering...\",\n interactionTitle,\n interactionTexts,\n playerAutoHideDelay = 3000,\n interactionDefaultValueOptions,\n onSend,\n onPlayerVisibilityChange,\n onStepChange,\n className,\n onPointerDown,\n ...props\n}) => {\n const sectionRef = useRef<HTMLElement | null>(null);\n const stageLayerRef = useRef<HTMLDivElement | null>(null);\n const lastElementRef = useRef<HTMLDivElement | null>(null);\n const playerHideTimerRef = useRef<number | null>(null);\n const autoAdvanceTimerRef = useRef<number | null>(null);\n const interactionAutoCloseTimerRef = useRef<number | null>(null);\n const prevRenderElementKeysRef = useRef<string[]>([]);\n const shouldScrollToBottomRef = useRef(false);\n const {\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 [isPlayerVisible, setIsPlayerVisible] = useState(true);\n const [hasPlayerInteracted, setHasPlayerInteracted] = useState(false);\n const [currentAudioIndex, setCurrentAudioIndex] = useState(-1);\n const [currentAudioSequencePosition, setCurrentAudioSequencePosition] =\n useState(-1);\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 currentAudioSequenceStartKey = useMemo(\n () => String(currentAudioSequenceIndexes[0] ?? \"none\"),\n [currentAudioSequenceIndexes]\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 () =>\n [\n currentStepKey,\n currentInteractionResetKey,\n currentAudioSequenceStartKey,\n ].join(\"|\"),\n [currentAudioSequenceStartKey, currentInteractionResetKey, currentStepKey]\n );\n\n const clearPlayerHideTimer = useCallback(() => {\n if (playerHideTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(playerHideTimerRef.current);\n playerHideTimerRef.current = null;\n }, []);\n\n const clearInteractionAutoCloseTimer = useCallback(() => {\n if (interactionAutoCloseTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(interactionAutoCloseTimerRef.current);\n interactionAutoCloseTimerRef.current = null;\n }, []);\n\n const 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 setCurrentAudioIndex(-1);\n setCurrentAudioSequencePosition(-1);\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n }, [clearAutoAdvanceTimer, clearInteractionAutoCloseTimer]);\n\n const startCurrentAudioSequence = useCallback(() => {\n const nextAudioIndex = currentAudioSequenceIndexes[0];\n\n if (typeof nextAudioIndex !== \"number\") {\n return false;\n }\n\n // Start the first audio segment for the current step immediately.\n setCurrentAudioSequencePosition(0);\n setCurrentAudioIndex(nextAudioIndex);\n return true;\n }, [currentAudioSequenceIndexes]);\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 resetAudioSequence();\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldBlockPlaybackForInteraction) {\n // Show the interaction gate before playing any follow-up audio.\n setActiveInteractionElement(currentInteractionElement);\n setIsInteractionOverlayOpen(true);\n return;\n }\n\n if (currentInteractionElement) {\n setActiveInteractionElement(currentInteractionElement);\n setIsInteractionOverlayOpen(false);\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 (currentAudioSequenceIndexes.length === 0) {\n setIsAudioLoadingVisible(true);\n }\n }, [\n currentAudioSequenceIndexes.length,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldBlockPlaybackForInteraction,\n ]);\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 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 setHasPlayerInteracted(true);\n setIsAudioLoadingVisible(false);\n showPlayerControls(true);\n resetAudioSequence();\n goNext();\n }, [goNext, resetAudioSequence, showPlayerControls]);\n\n const handlePlayerLoadingChange = useCallback(\n (loading: boolean) => {\n if (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(loading);\n },\n [currentStepHasSpeakableElement, hasCompletedCurrentStepAudio]\n );\n\n const handlePlayerEnded = useCallback(\n (audioIndex: number) => {\n if (currentAudioSequencePosition < 0) {\n return;\n }\n\n if (\n currentAudioSequenceIndexes[currentAudioSequencePosition] !== audioIndex\n ) {\n return;\n }\n\n const nextSequencePosition = currentAudioSequencePosition + 1;\n const nextAudioIndex = currentAudioSequenceIndexes[nextSequencePosition];\n\n if (typeof nextAudioIndex === \"number\") {\n setCurrentAudioSequencePosition(nextSequencePosition);\n setCurrentAudioIndex(nextAudioIndex);\n return;\n }\n\n setCurrentAudioIndex(-1);\n setCurrentAudioSequencePosition(-1);\n setHasCompletedCurrentStepAudio(true);\n setIsAudioLoadingVisible(false);\n\n if (canGoNext) {\n goNext();\n }\n },\n [\n canGoNext,\n currentAudioSequenceIndexes,\n currentAudioSequencePosition,\n goNext,\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","currentElementList","stepElementLists","slideElementList","currentIndex","audioList","currentAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement","canGoPrev","canGoNext","goPrev","goNext","useSlide","currentStepElement","useMemo","isSingleSlide","shouldRenderPlayer","isPlayerVisible","setIsPlayerVisible","useState","hasPlayerInteracted","setHasPlayerInteracted","currentAudioIndex","setCurrentAudioIndex","currentAudioSequencePosition","setCurrentAudioSequencePosition","isAudioLoadingVisible","setIsAudioLoadingVisible","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","playerVisible","playerCustomActionCount","getPlayerCustomActionCount","interactionOverlayStyle","mountedStepStates","currentMountedStateIndex","nextMountedStepStates","mountedStateIndexByStep","stepElementList","stepIndex","existingMountedStateIndex","mountedStepState","currentStepKey","currentAudioSequenceStartKey","currentInteractionResetKey","currentPlaybackResetKey","clearPlayerHideTimer","useCallback","clearInteractionAutoCloseTimer","clearAutoAdvanceTimer","resetAudioSequence","startCurrentAudioSequence","nextAudioIndex","continueAfterInteraction","showPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","shouldBlockPlaybackForInteraction","useEffect","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","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","audioIndex","nextSequencePosition","handleInteractionToggle","prevOpen","stopOverlayPropagation","handleSurfacePointerDown","shouldShowInteractionOverlay","currentRenderElementKeys","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","mountedStepStateIndex","LoaderCircle","Player"],"mappings":"w0BA8BMA,GAAmC,IA2BnCC,GAAyBC,EAAAA,KAC7B,CAAC,CACC,QAAAC,EACA,MAAAC,EACA,kBAAAC,EACA,iBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,eAAAC,GACA,iBAAAC,EACA,OAAAC,EACA,SAAAC,EAAW,EAAA,IAEXC,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,iCACb,SAAA,CAAAC,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,mCACb,SAAAA,EAAAA,kBAAAA,IAAC,KAAE,UAAU,kCAAmC,WAAM,CAAA,CACxD,EACAA,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,iCACb,SAAAA,EAAAA,kBAAAA,IAACC,GAAAA,QAAA,CACC,QAAAZ,EACA,kBAAAE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ACT,aAAcR,GACd,oBAAqBW,GACrB,OAAQN,GACR,OAAQD,GACR,aAAc,CAACpF,GACf,aAAc0B,EACd,cAAetD,CAAA,CAAA,EAEf,IAAA,CAAA,CAAA,CAGV"}
1
+ {"version":3,"file":"Slide.cjs.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\n extends Pick<\n ContentRenderProps,\n \"confirmButtonText\" | \"copyButtonText\" | \"copiedButtonText\"\n > {\n title?: string;\n}\n\nconst InteractionOverlayCard = memo(\n ({\n content,\n title,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n onSend,\n readonly = false,\n }: InteractionOverlayCardProps) => (\n <div className=\"slide-player__interaction-card\">\n <div className=\"slide-player__interaction-header\">\n <p className=\"slide-player__interaction-title\">{title}</p>\n </div>\n <div className=\"slide-player__interaction-body\">\n <ContentRender\n content={content}\n defaultButtonText={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n onSend={onSend}\n readonly={readonly}\n enableTypewriter={false}\n sandboxMode=\"content\"\n />\n </div>\n <div className=\"slide-player__interaction-arrow\" />\n </div>\n )\n);\n\nInteractionOverlayCard.displayName = \"InteractionOverlayCard\";\n\nconst areStepElementListsEqual = (\n prevElementList: Element[],\n nextElementList: Element[]\n) =>\n prevElementList.length === nextElementList.length &&\n prevElementList.every((element, index) => {\n const nextElement = nextElementList[index];\n\n return (\n element.sequence_number === nextElement?.sequence_number &&\n element.type === nextElement?.type &&\n element.content === nextElement?.content\n );\n });\n\nexport interface SlideProps extends React.ComponentProps<\"section\"> {\n elementList?: Element[];\n showPlayer?: boolean;\n playerAlwaysVisible?: boolean;\n playerClassName?: string;\n playerCustomActions?: PlayerProps[\"customActions\"];\n bufferingText?: string;\n interactionTitle?: string;\n interactionTexts?: SlideInteractionTexts;\n playerAutoHideDelay?: number;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n onSend?: (content: OnSendContentParams, element?: Element) => void;\n onPlayerVisibilityChange?: (visible: boolean) => void;\n onStepChange?: (element: Element | undefined, index: number) => void;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n showPlayer = true,\n playerAlwaysVisible = false,\n playerClassName,\n playerCustomActions,\n bufferingText = \"Buffering...\",\n interactionTitle,\n interactionTexts,\n playerAutoHideDelay = 3000,\n interactionDefaultValueOptions,\n onSend,\n onPlayerVisibilityChange,\n onStepChange,\n className,\n onPointerDown,\n ...props\n}) => {\n const sectionRef = useRef<HTMLElement | null>(null);\n const stageLayerRef = useRef<HTMLDivElement | null>(null);\n const lastElementRef = useRef<HTMLDivElement | null>(null);\n const playerHideTimerRef = useRef<number | null>(null);\n const autoAdvanceTimerRef = useRef<number | null>(null);\n const interactionAutoCloseTimerRef = useRef<number | null>(null);\n const prevRenderElementKeysRef = useRef<string[]>([]);\n const shouldScrollToBottomRef = useRef(false);\n const pendingInteractionOverlayStepIndexRef = useRef<number | null>(null);\n const {\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 [isPlayerVisible, setIsPlayerVisible] = useState(true);\n const [hasPlayerInteracted, setHasPlayerInteracted] = useState(false);\n const [currentAudioIndex, setCurrentAudioIndex] = useState(-1);\n const [currentAudioSequencePosition, setCurrentAudioSequencePosition] =\n useState(-1);\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 currentAudioSequenceStartKey = useMemo(\n () => String(currentAudioSequenceIndexes[0] ?? \"none\"),\n [currentAudioSequenceIndexes]\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 () =>\n [\n currentStepKey,\n currentInteractionResetKey,\n currentAudioSequenceStartKey,\n ].join(\"|\"),\n [currentAudioSequenceStartKey, currentInteractionResetKey, currentStepKey]\n );\n\n const clearPlayerHideTimer = useCallback(() => {\n if (playerHideTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(playerHideTimerRef.current);\n playerHideTimerRef.current = null;\n }, []);\n\n const clearInteractionAutoCloseTimer = useCallback(() => {\n if (interactionAutoCloseTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(interactionAutoCloseTimerRef.current);\n interactionAutoCloseTimerRef.current = null;\n }, []);\n\n const 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 setCurrentAudioIndex(-1);\n setCurrentAudioSequencePosition(-1);\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n }, [clearAutoAdvanceTimer, clearInteractionAutoCloseTimer]);\n\n const startCurrentAudioSequence = useCallback(() => {\n const nextAudioIndex = currentAudioSequenceIndexes[0];\n\n if (typeof nextAudioIndex !== \"number\") {\n return false;\n }\n\n // Start the first audio segment for the current step immediately.\n setCurrentAudioSequencePosition(0);\n setCurrentAudioIndex(nextAudioIndex);\n return true;\n }, [currentAudioSequenceIndexes]);\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 (currentAudioSequenceIndexes.length === 0) {\n setIsAudioLoadingVisible(true);\n }\n }, [\n currentAudioSequenceIndexes.length,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldBlockPlaybackForInteraction,\n ]);\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 (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(loading);\n },\n [currentStepHasSpeakableElement, hasCompletedCurrentStepAudio]\n );\n\n const handlePlayerEnded = useCallback(\n (audioIndex: number) => {\n if (currentAudioSequencePosition < 0) {\n return;\n }\n\n if (\n currentAudioSequenceIndexes[currentAudioSequencePosition] !== audioIndex\n ) {\n return;\n }\n\n const nextSequencePosition = currentAudioSequencePosition + 1;\n const nextAudioIndex = currentAudioSequenceIndexes[nextSequencePosition];\n\n if (typeof nextAudioIndex === \"number\") {\n setCurrentAudioSequencePosition(nextSequencePosition);\n setCurrentAudioIndex(nextAudioIndex);\n return;\n }\n\n setCurrentAudioIndex(-1);\n setCurrentAudioSequencePosition(-1);\n setHasCompletedCurrentStepAudio(true);\n setIsAudioLoadingVisible(false);\n\n if (canGoNext) {\n const nextStepIndex = currentIndex + 1;\n const nextStepElement = slideElementList[nextStepIndex];\n\n if (nextStepElement?.type === \"interaction\") {\n pendingInteractionOverlayStepIndexRef.current = nextStepIndex;\n }\n\n goNext();\n }\n },\n [\n canGoNext,\n currentIndex,\n currentAudioSequenceIndexes,\n currentAudioSequencePosition,\n goNext,\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","isPlayerVisible","setIsPlayerVisible","useState","hasPlayerInteracted","setHasPlayerInteracted","currentAudioIndex","setCurrentAudioIndex","currentAudioSequencePosition","setCurrentAudioSequencePosition","isAudioLoadingVisible","setIsAudioLoadingVisible","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","playerVisible","playerCustomActionCount","getPlayerCustomActionCount","interactionOverlayStyle","mountedStepStates","currentMountedStateIndex","nextMountedStepStates","mountedStateIndexByStep","stepElementList","stepIndex","existingMountedStateIndex","mountedStepState","currentStepKey","currentAudioSequenceStartKey","currentInteractionResetKey","currentPlaybackResetKey","clearPlayerHideTimer","useCallback","clearInteractionAutoCloseTimer","clearAutoAdvanceTimer","resetAudioSequence","startCurrentAudioSequence","nextAudioIndex","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","audioIndex","nextSequencePosition","nextStepIndex","handleInteractionToggle","prevOpen","stopOverlayPropagation","handleSurfacePointerDown","shouldShowInteractionOverlay","currentRenderElementKeys","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","mountedStepStateIndex","LoaderCircle","Player"],"mappings":"w0BA8BMA,GAAmC,IA2BnCC,GAAyBC,EAAAA,KAC7B,CAAC,CACC,QAAAC,EACA,MAAAC,EACA,kBAAAC,EACA,iBAAAC,EACA,sBAAAC,EACA,kBAAAC,GACA,eAAAC,GACA,iBAAAC,EACA,OAAAC,EACA,SAAAC,EAAW,EAAA,IAEXC,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,iCACb,SAAA,CAAAC,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,mCACb,SAAAA,EAAAA,kBAAAA,IAAC,KAAE,UAAU,kCAAmC,WAAM,CAAA,CACxD,EACAA,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,iCACb,SAAAA,EAAAA,kBAAAA,IAACC,GAAAA,QAAA,CACC,QAAAZ,EACA,kBAAAE,EACA,iBAAAC,EACA,sBAAAC,EACA,kBAAAC,GACA,eAAAC,GACA,iBAAAC,EACA,OAAAC,EACA,SAAAC,EACA,iBAAkB,GAClB,YAAY,SAAA,CAAA,EAEhB,EACAE,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,iCAAA,CAAkC,CAAA,CAAA,CACnD,CAEJ,EAEAb,GAAuB,YAAc,yBAErC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