markdown-flow-ui 0.2.9 → 0.2.11

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 (51) hide show
  1. package/dist/_virtual/index.cjs8.js +1 -1
  2. package/dist/_virtual/index.cjs9.js +1 -1
  3. package/dist/_virtual/index.es8.js +2 -2
  4. package/dist/_virtual/index.es9.js +2 -2
  5. package/dist/assets/markdown-flow-ui.css +1 -1
  6. package/dist/components/MarkdownFlow/ScrollToBottomButton.cjs.js +2 -0
  7. package/dist/components/MarkdownFlow/ScrollToBottomButton.cjs.js.map +1 -0
  8. package/dist/components/MarkdownFlow/ScrollToBottomButton.d.ts +8 -0
  9. package/dist/components/MarkdownFlow/ScrollToBottomButton.es.js +28 -0
  10. package/dist/components/MarkdownFlow/ScrollToBottomButton.es.js.map +1 -0
  11. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.cjs.js +2 -0
  12. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.cjs.js.map +1 -0
  13. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.es.js +68 -0
  14. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.es.js.map +1 -0
  15. package/dist/components/MarkdownFlow/index.cjs.js +1 -1
  16. package/dist/components/MarkdownFlow/index.d.ts +4 -1
  17. package/dist/components/MarkdownFlow/index.es.js +1 -0
  18. package/dist/components/MarkdownFlow/index.es.js.map +1 -1
  19. package/dist/components/MarkdownFlow/useScrollToBottom.cjs.js +2 -0
  20. package/dist/components/MarkdownFlow/useScrollToBottom.cjs.js.map +1 -0
  21. package/dist/components/MarkdownFlow/useScrollToBottom.d.ts +20 -8
  22. package/dist/components/MarkdownFlow/useScrollToBottom.es.js +101 -0
  23. package/dist/components/MarkdownFlow/useScrollToBottom.es.js.map +1 -0
  24. package/dist/components/MarkdownFlow/useScrollToBottom.test.d.ts +1 -0
  25. package/dist/components/Slide/Slide.cjs.js +1 -1
  26. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  27. package/dist/components/Slide/Slide.es.js +412 -402
  28. package/dist/components/Slide/Slide.es.js.map +1 -1
  29. package/dist/components/Slide/utils/stepAudioProgress.cjs.js +2 -0
  30. package/dist/components/Slide/utils/stepAudioProgress.cjs.js.map +1 -0
  31. package/dist/components/Slide/utils/stepAudioProgress.d.ts +22 -0
  32. package/dist/components/Slide/utils/stepAudioProgress.es.js +6 -0
  33. package/dist/components/Slide/utils/stepAudioProgress.es.js.map +1 -0
  34. package/dist/components/Slide/utils/stepAudioProgress.test.d.ts +1 -0
  35. package/dist/components/index.d.ts +4 -1
  36. package/dist/index.cjs.js +1 -1
  37. package/dist/index.es.js +21 -19
  38. package/dist/index.es.js.map +1 -1
  39. package/dist/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
  40. package/dist/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
  41. package/dist/node_modules/classnames/index.cjs.js +1 -1
  42. package/dist/node_modules/classnames/index.es.js +1 -1
  43. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs.js +7 -0
  44. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs.js.map +1 -0
  45. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.es.js +13 -0
  46. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.es.js.map +1 -0
  47. package/dist/renderer.cjs.js +1 -1
  48. package/dist/renderer.d.ts +5 -2
  49. package/dist/renderer.es.js +19 -17
  50. package/dist/renderer.es.js.map +1 -1
  51. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("../../_virtual/jsx-runtime.cjs.js"),c=require("react-dom"),i=require("../../node_modules/lucide-react/dist/esm/icons/chevron-down.cjs.js"),u=({visible:n,ariaLabel:l,portalTarget:t,className:s="",...e})=>{if(!n)return null;const o=r.jsxRuntimeExports.jsx("button",{...e,type:e.type||"button",className:`scroll-to-bottom-btn ${s}`.trim(),"aria-label":l,children:r.jsxRuntimeExports.jsx(i.default,{"aria-hidden":"true",focusable:"false"})});return t?c.createPortal(o,t):o};exports.ScrollToBottomButton=u;exports.default=u;
2
+ //# sourceMappingURL=ScrollToBottomButton.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollToBottomButton.cjs.js","sources":["../../../src/components/MarkdownFlow/ScrollToBottomButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ChevronDown } from \"lucide-react\";\n\nexport interface ScrollToBottomButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n visible: boolean;\n ariaLabel: string;\n portalTarget?: HTMLElement | null;\n}\n\nexport const ScrollToBottomButton: React.FC<ScrollToBottomButtonProps> = ({\n visible,\n ariaLabel,\n portalTarget,\n className = \"\",\n ...props\n}) => {\n if (!visible) return null;\n const button = (\n <button\n {...props}\n type={props.type || \"button\"}\n className={`scroll-to-bottom-btn ${className}`.trim()}\n aria-label={ariaLabel}\n >\n <ChevronDown aria-hidden=\"true\" focusable=\"false\" />\n </button>\n );\n return portalTarget ? createPortal(button, portalTarget) : button;\n};\n\nexport default ScrollToBottomButton;\n"],"names":["ScrollToBottomButton","visible","ariaLabel","portalTarget","className","props","button","jsx","ChevronDown","createPortal"],"mappings":"wQAWaA,EAA4D,CAAC,CACxE,QAAAC,EACA,UAAAC,EACA,aAAAC,EACA,UAAAC,EAAY,GACZ,GAAGC,CACL,IAAM,CACJ,GAAI,CAACJ,EAAS,OAAO,KACrB,MAAMK,EACJC,EAAAA,kBAAAA,IAAC,SAAA,CACE,GAAGF,EACJ,KAAMA,EAAM,MAAQ,SACpB,UAAW,wBAAwBD,CAAS,GAAG,KAAA,EAC/C,aAAYF,EAEZ,SAAAK,EAAAA,kBAAAA,IAACC,UAAA,CAAY,cAAY,OAAO,UAAU,OAAA,CAAQ,CAAA,CAAA,EAGtD,OAAOL,EAAeM,EAAAA,aAAaH,EAAQH,CAAY,EAAIG,CAC7D"}
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ export interface ScrollToBottomButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
+ visible: boolean;
4
+ ariaLabel: string;
5
+ portalTarget?: HTMLElement | null;
6
+ }
7
+ export declare const ScrollToBottomButton: React.FC<ScrollToBottomButtonProps>;
8
+ export default ScrollToBottomButton;
@@ -0,0 +1,28 @@
1
+ import { j as e } from "../../_virtual/jsx-runtime.es.js";
2
+ import { createPortal as s } from "react-dom";
3
+ import m from "../../node_modules/lucide-react/dist/esm/icons/chevron-down.es.js";
4
+ const b = ({
5
+ visible: n,
6
+ ariaLabel: l,
7
+ portalTarget: t,
8
+ className: a = "",
9
+ ...o
10
+ }) => {
11
+ if (!n) return null;
12
+ const r = /* @__PURE__ */ e.jsx(
13
+ "button",
14
+ {
15
+ ...o,
16
+ type: o.type || "button",
17
+ className: `scroll-to-bottom-btn ${a}`.trim(),
18
+ "aria-label": l,
19
+ children: /* @__PURE__ */ e.jsx(m, { "aria-hidden": "true", focusable: "false" })
20
+ }
21
+ );
22
+ return t ? s(r, t) : r;
23
+ };
24
+ export {
25
+ b as ScrollToBottomButton,
26
+ b as default
27
+ };
28
+ //# sourceMappingURL=ScrollToBottomButton.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollToBottomButton.es.js","sources":["../../../src/components/MarkdownFlow/ScrollToBottomButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ChevronDown } from \"lucide-react\";\n\nexport interface ScrollToBottomButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n visible: boolean;\n ariaLabel: string;\n portalTarget?: HTMLElement | null;\n}\n\nexport const ScrollToBottomButton: React.FC<ScrollToBottomButtonProps> = ({\n visible,\n ariaLabel,\n portalTarget,\n className = \"\",\n ...props\n}) => {\n if (!visible) return null;\n const button = (\n <button\n {...props}\n type={props.type || \"button\"}\n className={`scroll-to-bottom-btn ${className}`.trim()}\n aria-label={ariaLabel}\n >\n <ChevronDown aria-hidden=\"true\" focusable=\"false\" />\n </button>\n );\n return portalTarget ? createPortal(button, portalTarget) : button;\n};\n\nexport default ScrollToBottomButton;\n"],"names":["ScrollToBottomButton","visible","ariaLabel","portalTarget","className","props","button","jsx","ChevronDown","createPortal"],"mappings":";;;AAWO,MAAMA,IAA4D,CAAC;AAAA,EACxE,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MAAM;AACJ,MAAI,CAACJ,EAAS,QAAO;AACrB,QAAMK,IACJC,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAGF;AAAA,MACJ,MAAMA,EAAM,QAAQ;AAAA,MACpB,WAAW,wBAAwBD,CAAS,GAAG,KAAA;AAAA,MAC/C,cAAYF;AAAA,MAEZ,UAAAK,gBAAAA,EAAAA,IAACC,GAAA,EAAY,eAAY,QAAO,WAAU,QAAA,CAAQ;AAAA,IAAA;AAAA,EAAA;AAGtD,SAAOL,IAAeM,EAAaH,GAAQH,CAAY,IAAIG;AAC7D;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../../_virtual/jsx-runtime.cjs.js"),b=require("react"),v=require("./MarkdownFlow.cjs.js"),f=require("./useScrollToBottom.cjs.js"),h=require("./ScrollToBottomButton.cjs.js"),q=require("../ContentRender/contentRenderI18n.cjs.js");;/* empty css */const w=({initialContentList:e=[],customRenderBar:n,onSend:c,height:u="100%",className:i="",locale:t,confirmButtonText:a,copyButtonText:d,copiedButtonText:m,beforeSend:x,interactionDefaultValueOptions:T,scrollToBottomAriaLabel:j,...r})=>{const l=b.useRef(null),B=q.getContentRenderLocaleTexts(t),R=j||B.scrollToBottomLabel,{showScrollToBottom:s,scrollToBottom:S}=f.useScrollToBottom(l,{contentVersion:e,autoScrollOnInit:!0,scrollThreshold:150});return o.jsxRuntimeExports.jsxs("div",{className:`scrollable-markdown-container ${i}`,style:{height:u,position:"relative"},...r,children:[o.jsxRuntimeExports.jsx("div",{ref:l,style:{height:"100%",overflow:"auto"},children:o.jsxRuntimeExports.jsx(v.default,{...r,initialContentList:e,customRenderBar:n,onSend:c,locale:t,confirmButtonText:a,copyButtonText:d,copiedButtonText:m,beforeSend:x,interactionDefaultValueOptions:T})}),s&&o.jsxRuntimeExports.jsx(h.ScrollToBottomButton,{visible:s,onClick:()=>S(),ariaLabel:R})]})};exports.default=w;
2
+ //# sourceMappingURL=ScrollableMarkdownFlow.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollableMarkdownFlow.cjs.js","sources":["../../../src/components/MarkdownFlow/ScrollableMarkdownFlow.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport MarkdownFlow from \"./MarkdownFlow\";\nimport useScrollToBottom from \"./useScrollToBottom\";\n// import type { OnSendContentParams, CustomRenderBarProps } from \"../types\";\nimport ScrollToBottomButton from \"./ScrollToBottomButton\";\nimport type { MarkdownFlowProps } from \"./MarkdownFlow\";\nimport { getContentRenderLocaleTexts } from \"../ContentRender/contentRenderI18n\";\n\nimport \"./markdownFlow.css\";\n\nexport interface ScrollableMarkdownFlowProps extends MarkdownFlowProps {\n height?: string | number;\n className?: string;\n scrollToBottomAriaLabel?: string;\n}\n\nconst ScrollableMarkdownFlow: React.FC<ScrollableMarkdownFlowProps> = ({\n initialContentList = [],\n customRenderBar,\n onSend,\n height = \"100%\",\n className = \"\",\n locale,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend,\n interactionDefaultValueOptions,\n scrollToBottomAriaLabel,\n ...restProps\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedScrollToBottomAriaLabel =\n scrollToBottomAriaLabel || localeTexts.scrollToBottomLabel;\n\n const { showScrollToBottom, scrollToBottom } = useScrollToBottom(\n containerRef,\n {\n contentVersion: initialContentList,\n autoScrollOnInit: true,\n scrollThreshold: 150,\n }\n );\n\n return (\n <div\n className={`scrollable-markdown-container ${className}`}\n style={{ height, position: \"relative\" }}\n {...restProps}\n >\n <div ref={containerRef} style={{ height: \"100%\", overflow: \"auto\" }}>\n <MarkdownFlow\n {...restProps}\n initialContentList={initialContentList}\n customRenderBar={customRenderBar}\n onSend={onSend}\n locale={locale}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n beforeSend={beforeSend}\n interactionDefaultValueOptions={interactionDefaultValueOptions}\n />\n </div>\n {showScrollToBottom && (\n <ScrollToBottomButton\n visible={showScrollToBottom}\n onClick={() => scrollToBottom()}\n ariaLabel={resolvedScrollToBottomAriaLabel}\n />\n )}\n </div>\n );\n};\n\nexport default ScrollableMarkdownFlow;\n"],"names":["ScrollableMarkdownFlow","initialContentList","customRenderBar","onSend","height","className","locale","confirmButtonText","copyButtonText","copiedButtonText","beforeSend","interactionDefaultValueOptions","scrollToBottomAriaLabel","restProps","containerRef","useRef","localeTexts","getContentRenderLocaleTexts","resolvedScrollToBottomAriaLabel","showScrollToBottom","scrollToBottom","useScrollToBottom","jsxs","jsx","MarkdownFlow","ScrollToBottomButton"],"mappings":"sYAgBA,MAAMA,EAAgE,CAAC,CACrE,mBAAAC,EAAqB,CAAA,EACrB,gBAAAC,EACA,OAAAC,EACA,OAAAC,EAAS,OACT,UAAAC,EAAY,GACZ,OAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,WAAAC,EACA,+BAAAC,EACA,wBAAAC,EACA,GAAGC,CACL,IAAM,CACJ,MAAMC,EAAeC,EAAAA,OAAuB,IAAI,EAC1CC,EAAcC,EAAAA,4BAA4BX,CAAM,EAChDY,EACJN,GAA2BI,EAAY,oBAEnC,CAAE,mBAAAG,EAAoB,eAAAC,CAAA,EAAmBC,EAAAA,kBAC7CP,EACA,CACE,eAAgBb,EAChB,iBAAkB,GAClB,gBAAiB,GAAA,CACnB,EAGF,OACEqB,EAAAA,kBAAAA,KAAC,MAAA,CACC,UAAW,iCAAiCjB,CAAS,GACrD,MAAO,CAAE,OAAAD,EAAQ,SAAU,UAAA,EAC1B,GAAGS,EAEJ,SAAA,CAAAU,EAAAA,kBAAAA,IAAC,MAAA,CAAI,IAAKT,EAAc,MAAO,CAAE,OAAQ,OAAQ,SAAU,MAAA,EACzD,SAAAS,EAAAA,kBAAAA,IAACC,EAAAA,QAAA,CACE,GAAGX,EACJ,mBAAAZ,EACA,gBAAAC,EACA,OAAAC,EACA,OAAAG,EACA,kBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,WAAAC,EACA,+BAAAC,CAAA,CAAA,EAEJ,EACCQ,GACCI,EAAAA,kBAAAA,IAACE,EAAAA,qBAAA,CACC,QAASN,EACT,QAAS,IAAMC,EAAA,EACf,UAAWF,CAAA,CAAA,CACb,CAAA,CAAA,CAIR"}
@@ -0,0 +1,68 @@
1
+ import { j as o } from "../../_virtual/jsx-runtime.es.js";
2
+ import { useRef as B } from "react";
3
+ import b from "./MarkdownFlow.es.js";
4
+ import { useScrollToBottom as j } from "./useScrollToBottom.es.js";
5
+ import { ScrollToBottomButton as v } from "./ScrollToBottomButton.es.js";
6
+ import { getContentRenderLocaleTexts as S } from "../ContentRender/contentRenderI18n.es.js";
7
+ /* empty css */
8
+ const A = ({
9
+ initialContentList: t = [],
10
+ customRenderBar: n,
11
+ onSend: c,
12
+ height: m = "100%",
13
+ className: a = "",
14
+ locale: r,
15
+ confirmButtonText: i,
16
+ copyButtonText: d,
17
+ copiedButtonText: f,
18
+ beforeSend: u,
19
+ interactionDefaultValueOptions: p,
20
+ scrollToBottomAriaLabel: x,
21
+ ...l
22
+ }) => {
23
+ const e = B(null), T = S(r), h = x || T.scrollToBottomLabel, { showScrollToBottom: s, scrollToBottom: w } = j(
24
+ e,
25
+ {
26
+ contentVersion: t,
27
+ autoScrollOnInit: !0,
28
+ scrollThreshold: 150
29
+ }
30
+ );
31
+ return /* @__PURE__ */ o.jsxs(
32
+ "div",
33
+ {
34
+ className: `scrollable-markdown-container ${a}`,
35
+ style: { height: m, position: "relative" },
36
+ ...l,
37
+ children: [
38
+ /* @__PURE__ */ o.jsx("div", { ref: e, style: { height: "100%", overflow: "auto" }, children: /* @__PURE__ */ o.jsx(
39
+ b,
40
+ {
41
+ ...l,
42
+ initialContentList: t,
43
+ customRenderBar: n,
44
+ onSend: c,
45
+ locale: r,
46
+ confirmButtonText: i,
47
+ copyButtonText: d,
48
+ copiedButtonText: f,
49
+ beforeSend: u,
50
+ interactionDefaultValueOptions: p
51
+ }
52
+ ) }),
53
+ s && /* @__PURE__ */ o.jsx(
54
+ v,
55
+ {
56
+ visible: s,
57
+ onClick: () => w(),
58
+ ariaLabel: h
59
+ }
60
+ )
61
+ ]
62
+ }
63
+ );
64
+ };
65
+ export {
66
+ A as default
67
+ };
68
+ //# sourceMappingURL=ScrollableMarkdownFlow.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollableMarkdownFlow.es.js","sources":["../../../src/components/MarkdownFlow/ScrollableMarkdownFlow.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport MarkdownFlow from \"./MarkdownFlow\";\nimport useScrollToBottom from \"./useScrollToBottom\";\n// import type { OnSendContentParams, CustomRenderBarProps } from \"../types\";\nimport ScrollToBottomButton from \"./ScrollToBottomButton\";\nimport type { MarkdownFlowProps } from \"./MarkdownFlow\";\nimport { getContentRenderLocaleTexts } from \"../ContentRender/contentRenderI18n\";\n\nimport \"./markdownFlow.css\";\n\nexport interface ScrollableMarkdownFlowProps extends MarkdownFlowProps {\n height?: string | number;\n className?: string;\n scrollToBottomAriaLabel?: string;\n}\n\nconst ScrollableMarkdownFlow: React.FC<ScrollableMarkdownFlowProps> = ({\n initialContentList = [],\n customRenderBar,\n onSend,\n height = \"100%\",\n className = \"\",\n locale,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend,\n interactionDefaultValueOptions,\n scrollToBottomAriaLabel,\n ...restProps\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedScrollToBottomAriaLabel =\n scrollToBottomAriaLabel || localeTexts.scrollToBottomLabel;\n\n const { showScrollToBottom, scrollToBottom } = useScrollToBottom(\n containerRef,\n {\n contentVersion: initialContentList,\n autoScrollOnInit: true,\n scrollThreshold: 150,\n }\n );\n\n return (\n <div\n className={`scrollable-markdown-container ${className}`}\n style={{ height, position: \"relative\" }}\n {...restProps}\n >\n <div ref={containerRef} style={{ height: \"100%\", overflow: \"auto\" }}>\n <MarkdownFlow\n {...restProps}\n initialContentList={initialContentList}\n customRenderBar={customRenderBar}\n onSend={onSend}\n locale={locale}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n beforeSend={beforeSend}\n interactionDefaultValueOptions={interactionDefaultValueOptions}\n />\n </div>\n {showScrollToBottom && (\n <ScrollToBottomButton\n visible={showScrollToBottom}\n onClick={() => scrollToBottom()}\n ariaLabel={resolvedScrollToBottomAriaLabel}\n />\n )}\n </div>\n );\n};\n\nexport default ScrollableMarkdownFlow;\n"],"names":["ScrollableMarkdownFlow","initialContentList","customRenderBar","onSend","height","className","locale","confirmButtonText","copyButtonText","copiedButtonText","beforeSend","interactionDefaultValueOptions","scrollToBottomAriaLabel","restProps","containerRef","useRef","localeTexts","getContentRenderLocaleTexts","resolvedScrollToBottomAriaLabel","showScrollToBottom","scrollToBottom","useScrollToBottom","jsxs","jsx","MarkdownFlow","ScrollToBottomButton"],"mappings":";;;;;;;AAgBA,MAAMA,IAAgE,CAAC;AAAA,EACrE,oBAAAC,IAAqB,CAAA;AAAA,EACrB,iBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,WAAAC,IAAY;AAAA,EACZ,QAAAC;AAAA,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kdownFlow.cjs.js");require("../../_virtual/jsx-runtime.cjs.js");require("react");require("../ContentRender/contentRenderI18n.cjs.js");;/* empty css */exports.MarkdownFlow=e.default;exports.default=e.default;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./MarkdownFlow.cjs.js");require("../../_virtual/jsx-runtime.cjs.js");require("react");require("react-dom");require("../ContentRender/contentRenderI18n.cjs.js");;/* empty css */exports.MarkdownFlow=e.default;exports.default=e.default;
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -1,4 +1,7 @@
1
1
  import { default as MarkdownFlow } from './MarkdownFlow';
2
2
  import { default as ScrollableMarkdownFlow } from './ScrollableMarkdownFlow';
3
+ import { default as ScrollToBottomButton } from './ScrollToBottomButton';
3
4
  export default MarkdownFlow;
4
- export { MarkdownFlow, ScrollableMarkdownFlow };
5
+ export { MarkdownFlow, ScrollableMarkdownFlow, ScrollToBottomButton };
6
+ export { default as useScrollToBottom } from './useScrollToBottom';
7
+ export type { ScrollTarget, ScrollTargetRef, UseScrollToBottomOptions, UseScrollToBottomReturn, } from './useScrollToBottom';
@@ -1,6 +1,7 @@
1
1
  import r from "./MarkdownFlow.es.js";
2
2
  import "../../_virtual/jsx-runtime.es.js";
3
3
  import "react";
4
+ import "react-dom";
4
5
  import "../ContentRender/contentRenderI18n.es.js";
5
6
  /* empty css */
6
7
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react"),p=e=>typeof Window<"u"&&e instanceof Window,y=e=>typeof Document<"u"&&e instanceof Document,B=e=>{const n=p(e)?e.document:e;return n.scrollingElement||n.documentElement},h=e=>{if(p(e)||y(e)){const n=B(e),t=p(e)?e.innerHeight:n?.clientHeight||0;return{scrollTop:n?.scrollTop||0,scrollHeight:n?.scrollHeight||0,clientHeight:t}}return{scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}},F=e=>e?"current"in e?e.current:e:null,R=e=>{const n=typeof window<"u"?window.getComputedStyle(e):null,t=n?.overflowY||n?.overflow;return e.scrollHeight>e.clientHeight&&t!=="visible"},v=(e,n)=>{const t=F(n);if(t)return t;const l=e?.current;if(!l)return null;if(R(l))return l;let s=l.parentElement;for(;s;){if(R(s))return s;s=s.parentElement}return typeof window<"u"?window:null},A=(e,n={})=>{const{contentRef:t=e,scrollTarget:l,scrollThreshold:s=150,contentVersion:C,followNewContent:g=!0,autoScrollOnInit:T=!1,behavior:S="smooth"}=n,[M,H]=u.useState(!1),[z,b]=u.useState(!0),a=u.useRef(g),E=u.useRef(!1),d=u.useRef(null),m=u.useCallback(()=>{const o=v(t,l);if(!o)return;const{scrollTop:r,scrollHeight:f,clientHeight:i}=h(o),c=r+i>=f-s;b(c),H(!c&&f>i),c&&(a.current=!0)},[t,l,s]),w=u.useCallback((o=S)=>{const r=v(t,l);if(!r)return;const f=typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,i=o==="smooth"&&f?"auto":o,c=h(r).scrollHeight;p(r)?r.scrollTo({top:c,behavior:i}):y(r)?B(r)?.scrollTo({top:c,behavior:i}):r.scrollTo({top:c,behavior:i}),a.current=!0,b(!0),H(!1)},[S,t,l]);return u.useEffect(()=>{const o=v(t,l);if(!o)return;const r=()=>{d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null;const c=h(o);c.scrollTop+c.clientHeight<c.scrollHeight-s&&(a.current=!1),m()})},f=()=>r();o.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",f);const i=typeof ResizeObserver<"u"?new ResizeObserver(f):null;return t.current&&i?.observe(t.current),typeof Element<"u"&&o instanceof Element&&o!==t.current&&i?.observe(o),m(),()=>{o.removeEventListener("scroll",r),window.removeEventListener("resize",f),i?.disconnect(),d.current!==null&&cancelAnimationFrame(d.current)}},[t,m,l,s]),u.useEffect(()=>{if(!E.current){E.current=!0,T&&w("auto");return}if(a.current){const o=requestAnimationFrame(()=>w("auto"));return()=>cancelAnimationFrame(o)}m()},[T,C,m,w]),u.useEffect(()=>{a.current=g},[g]),{showScrollToBottom:M,isAtBottom:z,followNewContent:a.current,scrollToBottom:w,refresh:m}};exports.default=A;exports.getScrollMetrics=h;exports.resolveScrollTarget=v;exports.useScrollToBottom=A;
2
+ //# sourceMappingURL=useScrollToBottom.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollToBottom.cjs.js","sources":["../../../src/components/MarkdownFlow/useScrollToBottom.ts"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useRef,\n useState,\n type RefObject,\n} from \"react\";\n\nexport type ScrollBehavior = \"smooth\" | \"auto\";\nexport type ScrollTarget = HTMLElement | Document | Window;\nexport type ScrollTargetRef = RefObject<ScrollTarget | null>;\n\nexport interface UseScrollToBottomOptions {\n contentRef?: RefObject<HTMLElement | null>;\n scrollTarget?: ScrollTarget | ScrollTargetRef | null;\n scrollThreshold?: number;\n contentVersion?: unknown;\n followNewContent?: boolean;\n autoScrollOnInit?: boolean;\n behavior?: ScrollBehavior;\n}\n\nexport interface UseScrollToBottomReturn {\n showScrollToBottom: boolean;\n isAtBottom: boolean;\n followNewContent: boolean;\n scrollToBottom: (behavior?: ScrollBehavior) => void;\n refresh: () => void;\n}\n\nconst isWindow = (target: ScrollTarget): target is Window =>\n typeof Window !== \"undefined\" && target instanceof Window;\n\nconst isDocument = (target: ScrollTarget): target is Document =>\n typeof Document !== \"undefined\" && target instanceof Document;\n\nconst getDocumentScroller = (target: Document | Window): HTMLElement | null => {\n const document = isWindow(target) ? target.document : target;\n return (document.scrollingElement || document.documentElement) as HTMLElement;\n};\n\nexport const getScrollMetrics = (target: ScrollTarget) => {\n if (isWindow(target) || isDocument(target)) {\n const scroller = getDocumentScroller(target);\n const viewportHeight = isWindow(target)\n ? target.innerHeight\n : scroller?.clientHeight || 0;\n return {\n scrollTop: scroller?.scrollTop || 0,\n scrollHeight: scroller?.scrollHeight || 0,\n clientHeight: viewportHeight,\n };\n }\n return {\n scrollTop: target.scrollTop,\n scrollHeight: target.scrollHeight,\n clientHeight: target.clientHeight,\n };\n};\n\nconst scrollTargetValue = (\n target: ScrollTarget | ScrollTargetRef | null | undefined\n): ScrollTarget | null => {\n if (!target) return null;\n return \"current\" in target ? target.current : target;\n};\n\nconst isScrollable = (element: HTMLElement) => {\n const style =\n typeof window !== \"undefined\" ? window.getComputedStyle(element) : null;\n const overflow = style?.overflowY || style?.overflow;\n return element.scrollHeight > element.clientHeight && overflow !== \"visible\";\n};\n\nexport const resolveScrollTarget = (\n contentRef: RefObject<HTMLElement | null> | undefined,\n explicitTarget: ScrollTarget | ScrollTargetRef | null | undefined\n): ScrollTarget | null => {\n const explicit = scrollTargetValue(explicitTarget);\n if (explicit) return explicit;\n const content = contentRef?.current;\n if (!content) return null;\n if (isScrollable(content)) return content;\n let parent = content.parentElement;\n while (parent) {\n if (isScrollable(parent)) return parent;\n parent = parent.parentElement;\n }\n return typeof window !== \"undefined\" ? window : null;\n};\n\nexport const useScrollToBottom = (\n containerRef: RefObject<HTMLElement | null>,\n options: UseScrollToBottomOptions = {}\n): UseScrollToBottomReturn => {\n const {\n contentRef = containerRef,\n scrollTarget,\n scrollThreshold = 150,\n contentVersion,\n followNewContent: followNewContentOption = true,\n autoScrollOnInit = false,\n behavior = \"smooth\",\n } = options;\n const [showScrollToBottom, setShowScrollToBottom] = useState(false);\n const [isAtBottom, setIsAtBottom] = useState(true);\n const followingRef = useRef(followNewContentOption);\n const mountedRef = useRef(false);\n const frameRef = useRef<number | null>(null);\n\n const refresh = useCallback(() => {\n const target = resolveScrollTarget(contentRef, scrollTarget);\n if (!target) return;\n const { scrollTop, scrollHeight, clientHeight } = getScrollMetrics(target);\n const atBottom = scrollTop + clientHeight >= scrollHeight - scrollThreshold;\n setIsAtBottom(atBottom);\n setShowScrollToBottom(!atBottom && scrollHeight > clientHeight);\n if (atBottom) followingRef.current = true;\n }, [contentRef, scrollTarget, scrollThreshold]);\n\n const scrollToBottom = useCallback(\n (requestedBehavior: ScrollBehavior = behavior) => {\n const target = resolveScrollTarget(contentRef, scrollTarget);\n if (!target) return;\n const reducedMotion =\n typeof window !== \"undefined\" &&\n window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;\n const actualBehavior =\n requestedBehavior === \"smooth\" && reducedMotion\n ? \"auto\"\n : requestedBehavior;\n const top = getScrollMetrics(target).scrollHeight;\n if (isWindow(target)) {\n target.scrollTo({ top, behavior: actualBehavior });\n } else if (isDocument(target)) {\n getDocumentScroller(target)?.scrollTo({\n top,\n behavior: actualBehavior,\n });\n } else {\n target.scrollTo({ top, behavior: actualBehavior });\n }\n followingRef.current = true;\n setIsAtBottom(true);\n setShowScrollToBottom(false);\n },\n [behavior, contentRef, scrollTarget]\n );\n\n useEffect(() => {\n const target = resolveScrollTarget(contentRef, scrollTarget);\n if (!target) return;\n const handleScroll = () => {\n if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);\n frameRef.current = requestAnimationFrame(() => {\n frameRef.current = null;\n const metrics = getScrollMetrics(target);\n if (\n metrics.scrollTop + metrics.clientHeight <\n metrics.scrollHeight - scrollThreshold\n ) {\n followingRef.current = false;\n }\n refresh();\n });\n };\n const handleResize = () => handleScroll();\n target.addEventListener(\"scroll\", handleScroll, { passive: true });\n window.addEventListener(\"resize\", handleResize);\n const observer =\n typeof ResizeObserver !== \"undefined\"\n ? new ResizeObserver(handleResize)\n : null;\n if (contentRef.current) observer?.observe(contentRef.current);\n if (\n typeof Element !== \"undefined\" &&\n target instanceof Element &&\n target !== contentRef.current\n ) {\n observer?.observe(target);\n }\n refresh();\n return () => {\n target.removeEventListener(\"scroll\", handleScroll);\n window.removeEventListener(\"resize\", handleResize);\n observer?.disconnect();\n if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);\n };\n }, [contentRef, refresh, scrollTarget, scrollThreshold]);\n\n useEffect(() => {\n if (!mountedRef.current) {\n mountedRef.current = true;\n if (autoScrollOnInit) scrollToBottom(\"auto\");\n return;\n }\n if (followingRef.current) {\n const frame = requestAnimationFrame(() => scrollToBottom(\"auto\"));\n return () => cancelAnimationFrame(frame);\n }\n refresh();\n }, [autoScrollOnInit, contentVersion, refresh, scrollToBottom]);\n\n useEffect(() => {\n followingRef.current = followNewContentOption;\n }, [followNewContentOption]);\n\n return {\n showScrollToBottom,\n isAtBottom,\n followNewContent: followingRef.current,\n scrollToBottom,\n refresh,\n };\n};\n\nexport default useScrollToBottom;\n"],"names":["isWindow","target","isDocument","getDocumentScroller","document","getScrollMetrics","scroller","viewportHeight","scrollTargetValue","isScrollable","element","style","overflow","resolveScrollTarget","contentRef","explicitTarget","explicit","content","parent","useScrollToBottom","containerRef","options","scrollTarget","scrollThreshold","contentVersion","followNewContentOption","autoScrollOnInit","behavior","showScrollToBottom","setShowScrollToBottom","useState","isAtBottom","setIsAtBottom","followingRef","useRef","mountedRef","frameRef","refresh","useCallback","scrollTop","scrollHeight","clientHeight","atBottom","scrollToBottom","requestedBehavior","reducedMotion","actualBehavior","top","useEffect","handleScroll","metrics","handleResize","observer","frame"],"mappings":"qIA8BMA,EAAYC,GAChB,OAAO,OAAW,KAAeA,aAAkB,OAE/CC,EAAcD,GAClB,OAAO,SAAa,KAAeA,aAAkB,SAEjDE,EAAuBF,GAAkD,CAC7E,MAAMG,EAAWJ,EAASC,CAAM,EAAIA,EAAO,SAAWA,EACtD,OAAQG,EAAS,kBAAoBA,EAAS,eAChD,EAEaC,EAAoBJ,GAAyB,CACxD,GAAID,EAASC,CAAM,GAAKC,EAAWD,CAAM,EAAG,CAC1C,MAAMK,EAAWH,EAAoBF,CAAM,EACrCM,EAAiBP,EAASC,CAAM,EAClCA,EAAO,YACPK,GAAU,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AU,IAEzBI,EAAA,CACF,CAAC,CACH,EACMc,EAAe,IAAMF,EAAA,EAC3BhD,EAAO,iBAAiB,SAAUgD,EAAc,CAAE,QAAS,GAAM,EACjE,OAAO,iBAAiB,SAAUE,CAAY,EAC9C,MAAMC,EACJ,OAAO,eAAmB,IACtB,IAAI,eAAeD,CAAY,EAC/B,KACN,OAAIrC,EAAW,SAASsC,GAAU,QAAQtC,EAAW,OAAO,EAE1D,OAAO,QAAY,KACnBb,aAAkB,SAClBA,IAAWa,EAAW,SAEtBsC,GAAU,QAAQnD,CAAM,EAE1BoC,EAAA,EACO,IAAM,CACXpC,EAAO,oBAAoB,SAAUgD,CAAY,EACjD,OAAO,oBAAoB,SAAUE,CAAY,EACjDC,GAAU,WAAA,EACNhB,EAAS,UAAY,MAAM,qBAAqBA,EAAS,OAAO,CACtE,CACF,EAAG,CAACtB,EAAYuB,EAASf,EAAcC,CAAe,CAAC,EAEvDyB,EAAAA,UAAU,IAAM,CACd,GAAI,CAACb,EAAW,QAAS,CACvBA,EAAW,QAAU,GACjBT,KAAiC,MAAM,EAC3C,MACF,CACA,GAAIO,EAAa,QAAS,CACxB,MAAMoB,EAAQ,sBAAsB,IAAMV,EAAe,MAAM,CAAC,EAChE,MAAO,IAAM,qBAAqBU,CAAK,CACzC,CACAhB,EAAA,CACF,EAAG,CAACX,EAAkBF,EAAgBa,EAASM,CAAc,CAAC,EAE9DK,EAAAA,UAAU,IAAM,CACdf,EAAa,QAAUR,CACzB,EAAG,CAACA,CAAsB,CAAC,EAEpB,CACL,mBAAAG,EACA,WAAAG,EACA,iBAAkBE,EAAa,QAC/B,eAAAU,EACA,QAAAN,CAAA,CAEJ"}
@@ -1,16 +1,28 @@
1
1
  import { RefObject } from 'react';
2
- interface UseScrollToBottomOptions {
3
- behavior?: "smooth" | "auto";
4
- autoScrollOnInit?: boolean;
5
- scrollDelay?: number;
2
+ export type ScrollBehavior = "smooth" | "auto";
3
+ export type ScrollTarget = HTMLElement | Document | Window;
4
+ export type ScrollTargetRef = RefObject<ScrollTarget | null>;
5
+ export interface UseScrollToBottomOptions {
6
+ contentRef?: RefObject<HTMLElement | null>;
7
+ scrollTarget?: ScrollTarget | ScrollTargetRef | null;
6
8
  scrollThreshold?: number;
9
+ contentVersion?: unknown;
10
+ followNewContent?: boolean;
11
+ autoScrollOnInit?: boolean;
12
+ behavior?: ScrollBehavior;
7
13
  }
8
- interface UseScrollToBottomReturn {
14
+ export interface UseScrollToBottomReturn {
9
15
  showScrollToBottom: boolean;
10
- scrollToBottom: () => void;
11
- handleUserScrollToBottom: () => void;
12
16
  isAtBottom: boolean;
13
17
  followNewContent: boolean;
18
+ scrollToBottom: (behavior?: ScrollBehavior) => void;
19
+ refresh: () => void;
14
20
  }
15
- declare const useScrollToBottom: (containerRef: RefObject<HTMLDivElement | null>, dependencies?: any[], options?: UseScrollToBottomOptions) => UseScrollToBottomReturn;
21
+ export declare const getScrollMetrics: (target: ScrollTarget) => {
22
+ scrollTop: number;
23
+ scrollHeight: number;
24
+ clientHeight: number;
25
+ };
26
+ export declare const resolveScrollTarget: (contentRef: RefObject<HTMLElement | null> | undefined, explicitTarget: ScrollTarget | ScrollTargetRef | null | undefined) => ScrollTarget | null;
27
+ export declare const useScrollToBottom: (containerRef: RefObject<HTMLElement | null>, options?: UseScrollToBottomOptions) => UseScrollToBottomReturn;
16
28
  export default useScrollToBottom;
@@ -0,0 +1,101 @@
1
+ import { useState as R, useRef as p, useCallback as A, useEffect as v } from "react";
2
+ const w = (e) => typeof Window < "u" && e instanceof Window, z = (e) => typeof Document < "u" && e instanceof Document, C = (e) => {
3
+ const o = w(e) ? e.document : e;
4
+ return o.scrollingElement || o.documentElement;
5
+ }, H = (e) => {
6
+ if (w(e) || z(e)) {
7
+ const o = C(e), t = w(e) ? e.innerHeight : o?.clientHeight || 0;
8
+ return {
9
+ scrollTop: o?.scrollTop || 0,
10
+ scrollHeight: o?.scrollHeight || 0,
11
+ clientHeight: t
12
+ };
13
+ }
14
+ return {
15
+ scrollTop: e.scrollTop,
16
+ scrollHeight: e.scrollHeight,
17
+ clientHeight: e.clientHeight
18
+ };
19
+ }, O = (e) => e ? "current" in e ? e.current : e : null, B = (e) => {
20
+ const o = typeof window < "u" ? window.getComputedStyle(e) : null, t = o?.overflowY || o?.overflow;
21
+ return e.scrollHeight > e.clientHeight && t !== "visible";
22
+ }, T = (e, o) => {
23
+ const t = O(o);
24
+ if (t) return t;
25
+ const l = e?.current;
26
+ if (!l) return null;
27
+ if (B(l)) return l;
28
+ let s = l.parentElement;
29
+ for (; s; ) {
30
+ if (B(s)) return s;
31
+ s = s.parentElement;
32
+ }
33
+ return typeof window < "u" ? window : null;
34
+ }, N = (e, o = {}) => {
35
+ const {
36
+ contentRef: t = e,
37
+ scrollTarget: l,
38
+ scrollThreshold: s = 150,
39
+ contentVersion: F,
40
+ followNewContent: h = !0,
41
+ autoScrollOnInit: g = !1,
42
+ behavior: b = "smooth"
43
+ } = o, [D, S] = R(!1), [L, E] = R(!0), f = p(h), y = p(!1), a = p(null), d = A(() => {
44
+ const n = T(t, l);
45
+ if (!n) return;
46
+ const { scrollTop: r, scrollHeight: u, clientHeight: i } = H(n), c = r + i >= u - s;
47
+ E(c), S(!c && u > i), c && (f.current = !0);
48
+ }, [t, l, s]), m = A(
49
+ (n = b) => {
50
+ const r = T(t, l);
51
+ if (!r) return;
52
+ const u = typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches, i = n === "smooth" && u ? "auto" : n, c = H(r).scrollHeight;
53
+ w(r) ? r.scrollTo({ top: c, behavior: i }) : z(r) ? C(r)?.scrollTo({
54
+ top: c,
55
+ behavior: i
56
+ }) : r.scrollTo({ top: c, behavior: i }), f.current = !0, E(!0), S(!1);
57
+ },
58
+ [b, t, l]
59
+ );
60
+ return v(() => {
61
+ const n = T(t, l);
62
+ if (!n) return;
63
+ const r = () => {
64
+ a.current !== null && cancelAnimationFrame(a.current), a.current = requestAnimationFrame(() => {
65
+ a.current = null;
66
+ const c = H(n);
67
+ c.scrollTop + c.clientHeight < c.scrollHeight - s && (f.current = !1), d();
68
+ });
69
+ }, u = () => r();
70
+ n.addEventListener("scroll", r, { passive: !0 }), window.addEventListener("resize", u);
71
+ const i = typeof ResizeObserver < "u" ? new ResizeObserver(u) : null;
72
+ return t.current && i?.observe(t.current), typeof Element < "u" && n instanceof Element && n !== t.current && i?.observe(n), d(), () => {
73
+ n.removeEventListener("scroll", r), window.removeEventListener("resize", u), i?.disconnect(), a.current !== null && cancelAnimationFrame(a.current);
74
+ };
75
+ }, [t, d, l, s]), v(() => {
76
+ if (!y.current) {
77
+ y.current = !0, g && m("auto");
78
+ return;
79
+ }
80
+ if (f.current) {
81
+ const n = requestAnimationFrame(() => m("auto"));
82
+ return () => cancelAnimationFrame(n);
83
+ }
84
+ d();
85
+ }, [g, F, d, m]), v(() => {
86
+ f.current = h;
87
+ }, [h]), {
88
+ showScrollToBottom: D,
89
+ isAtBottom: L,
90
+ followNewContent: f.current,
91
+ scrollToBottom: m,
92
+ refresh: d
93
+ };
94
+ };
95
+ export {
96
+ N as default,
97
+ H as getScrollMetrics,
98
+ T as resolveScrollTarget,
99
+ N as useScrollToBottom
100
+ };
101
+ //# sourceMappingURL=useScrollToBottom.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollToBottom.es.js","sources":["../../../src/components/MarkdownFlow/useScrollToBottom.ts"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useRef,\n useState,\n type RefObject,\n} from \"react\";\n\nexport type ScrollBehavior = \"smooth\" | \"auto\";\nexport type ScrollTarget = HTMLElement | Document | Window;\nexport type ScrollTargetRef = RefObject<ScrollTarget | null>;\n\nexport interface UseScrollToBottomOptions {\n contentRef?: RefObject<HTMLElement | null>;\n scrollTarget?: ScrollTarget | ScrollTargetRef | null;\n scrollThreshold?: number;\n contentVersion?: unknown;\n followNewContent?: boolean;\n autoScrollOnInit?: boolean;\n behavior?: ScrollBehavior;\n}\n\nexport interface UseScrollToBottomReturn {\n showScrollToBottom: boolean;\n isAtBottom: boolean;\n followNewContent: boolean;\n scrollToBottom: (behavior?: ScrollBehavior) => void;\n refresh: () => void;\n}\n\nconst isWindow = (target: ScrollTarget): target is Window =>\n typeof Window !== \"undefined\" && target instanceof Window;\n\nconst isDocument = (target: ScrollTarget): target is Document =>\n typeof Document !== \"undefined\" && target instanceof Document;\n\nconst getDocumentScroller = (target: Document | Window): HTMLElement | null => {\n const document = isWindow(target) ? target.document : target;\n return (document.scrollingElement || document.documentElement) as HTMLElement;\n};\n\nexport const getScrollMetrics = (target: ScrollTarget) => {\n if (isWindow(target) || isDocument(target)) {\n const scroller = getDocumentScroller(target);\n const viewportHeight = isWindow(target)\n ? target.innerHeight\n : scroller?.clientHeight || 0;\n return {\n scrollTop: scroller?.scrollTop || 0,\n scrollHeight: scroller?.scrollHeight || 0,\n clientHeight: viewportHeight,\n };\n }\n return {\n scrollTop: target.scrollTop,\n scrollHeight: target.scrollHeight,\n clientHeight: target.clientHeight,\n };\n};\n\nconst scrollTargetValue = (\n target: ScrollTarget | ScrollTargetRef | null | undefined\n): ScrollTarget | null => {\n if (!target) return null;\n return \"current\" in target ? target.current : target;\n};\n\nconst isScrollable = (element: HTMLElement) => {\n const style =\n typeof window !== \"undefined\" ? window.getComputedStyle(element) : null;\n const overflow = style?.overflowY || style?.overflow;\n return element.scrollHeight > element.clientHeight && overflow !== \"visible\";\n};\n\nexport const resolveScrollTarget = (\n contentRef: RefObject<HTMLElement | null> | undefined,\n explicitTarget: ScrollTarget | ScrollTargetRef | null | undefined\n): ScrollTarget | null => {\n const explicit = scrollTargetValue(explicitTarget);\n if (explicit) return explicit;\n const content = contentRef?.current;\n if (!content) return null;\n if (isScrollable(content)) return content;\n let parent = content.parentElement;\n while (parent) {\n if (isScrollable(parent)) return parent;\n parent = parent.parentElement;\n }\n return typeof window !== \"undefined\" ? window : null;\n};\n\nexport const useScrollToBottom = (\n containerRef: RefObject<HTMLElement | null>,\n options: UseScrollToBottomOptions = {}\n): UseScrollToBottomReturn => {\n const {\n contentRef = containerRef,\n scrollTarget,\n scrollThreshold = 150,\n contentVersion,\n followNewContent: followNewContentOption = true,\n autoScrollOnInit = false,\n behavior = \"smooth\",\n } = options;\n const [showScrollToBottom, setShowScrollToBottom] = useState(false);\n const [isAtBottom, setIsAtBottom] = useState(true);\n const followingRef = useRef(followNewContentOption);\n const mountedRef = useRef(false);\n const frameRef = useRef<number | null>(null);\n\n const refresh = useCallback(() => {\n const target = resolveScrollTarget(contentRef, scrollTarget);\n if (!target) return;\n const { scrollTop, scrollHeight, clientHeight } = getScrollMetrics(target);\n const atBottom = scrollTop + clientHeight >= scrollHeight - scrollThreshold;\n setIsAtBottom(atBottom);\n setShowScrollToBottom(!atBottom && scrollHeight > clientHeight);\n if (atBottom) followingRef.current = true;\n }, [contentRef, scrollTarget, scrollThreshold]);\n\n const scrollToBottom = useCallback(\n (requestedBehavior: ScrollBehavior = behavior) => {\n const target = resolveScrollTarget(contentRef, scrollTarget);\n if (!target) return;\n const reducedMotion =\n typeof window !== \"undefined\" &&\n window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;\n const actualBehavior =\n requestedBehavior === \"smooth\" && reducedMotion\n ? \"auto\"\n : requestedBehavior;\n const top = getScrollMetrics(target).scrollHeight;\n if (isWindow(target)) {\n target.scrollTo({ top, behavior: actualBehavior });\n } else if (isDocument(target)) {\n getDocumentScroller(target)?.scrollTo({\n top,\n behavior: actualBehavior,\n });\n } else {\n target.scrollTo({ top, behavior: actualBehavior });\n }\n followingRef.current = true;\n setIsAtBottom(true);\n setShowScrollToBottom(false);\n },\n [behavior, contentRef, scrollTarget]\n );\n\n useEffect(() => {\n const target = resolveScrollTarget(contentRef, scrollTarget);\n if (!target) return;\n const handleScroll = () => {\n if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);\n frameRef.current = requestAnimationFrame(() => {\n frameRef.current = null;\n const metrics = getScrollMetrics(target);\n if (\n metrics.scrollTop + metrics.clientHeight <\n metrics.scrollHeight - scrollThreshold\n ) {\n followingRef.current = false;\n }\n refresh();\n });\n };\n const handleResize = () => handleScroll();\n target.addEventListener(\"scroll\", handleScroll, { passive: true });\n window.addEventListener(\"resize\", handleResize);\n const observer =\n typeof ResizeObserver !== \"undefined\"\n ? new ResizeObserver(handleResize)\n : null;\n if (contentRef.current) observer?.observe(contentRef.current);\n if (\n typeof Element !== \"undefined\" &&\n target instanceof Element &&\n target !== contentRef.current\n ) {\n observer?.observe(target);\n }\n refresh();\n return () => {\n target.removeEventListener(\"scroll\", handleScroll);\n window.removeEventListener(\"resize\", handleResize);\n observer?.disconnect();\n if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);\n };\n }, [contentRef, refresh, scrollTarget, scrollThreshold]);\n\n useEffect(() => {\n if (!mountedRef.current) {\n mountedRef.current = true;\n if (autoScrollOnInit) scrollToBottom(\"auto\");\n return;\n }\n if (followingRef.current) {\n const frame = requestAnimationFrame(() => scrollToBottom(\"auto\"));\n return () => cancelAnimationFrame(frame);\n }\n refresh();\n }, [autoScrollOnInit, contentVersion, refresh, scrollToBottom]);\n\n useEffect(() => {\n followingRef.current = followNewContentOption;\n }, [followNewContentOption]);\n\n return {\n showScrollToBottom,\n isAtBottom,\n followNewContent: followingRef.current,\n scrollToBottom,\n refresh,\n };\n};\n\nexport default useScrollToBottom;\n"],"names":["isWindow","target","isDocument","getDocumentScroller","document","getScrollMetrics","scroller","viewportHeight","scrollTargetValue","isScrollable","element","style","overflow","resolveScrollTarget","contentRef","explicitTarget","explicit","content","parent","useScrollToBottom","containerRef","options","scrollTarget","scrollThreshold","contentVersion","followNewContentOption","autoScrollOnInit","behavior","showScrollToBottom","setShowScrollToBottom","useState","isAtBottom","setIsAtBottom","followingRef","useRef","mountedRef","frameRef","refresh","useCallback","scrollTop","scrollHeight","clientHeight","atBottom","scrollToBottom","requestedBehavior","reducedMotion","actualBehavior","top","useEffect","handleScroll","metrics","handleResize","observer","frame"],"mappings":";AA8BA,MAAMA,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AAiC,MAAM;AAC3C;AAAA,IACF;AACA,QAAIO,EAAa,SAAS;AACxB,YAAMoB,IAAQ,sBAAsB,MAAMV,EAAe,MAAM,CAAC;AAChE,aAAO,MAAM,qBAAqBU,CAAK;AAAA,IACzC;AACA,IAAAhB,EAAA;AAAA,EACF,GAAG,CAACX,GAAkBF,GAAgBa,GAASM,CAAc,CAAC,GAE9DK,EAAU,MAAM;AACd,IAAAf,EAAa,UAAUR;AAAA,EACzB,GAAG,CAACA,CAAsB,CAAC,GAEpB;AAAA,IACL,oBAAAG;AAAA,IACA,YAAAG;AAAA,IACA,kBAAkBE,EAAa;AAAA,IAC/B,gBAAAU;AAAA,IACA,SAAAN;AAAA,EAAA;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),Ar=require("../../lib/sandboxInteraction.cjs.js"),pe=require("../../lib/utils.cjs.js"),wr=require("../ui/loading-overlay-card.cjs.js"),Tr=require("../ContentRender/ContentRender.cjs.js"),Sn=require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");require("../ContentRender/contentRenderI18n.cjs.js");const Ze=require("../../lib/mobileDevice.cjs.js"),kr=require("./Player.cjs.js"),Mr=require("./MarkdownSlideScaling.cjs.js"),_r=require("./SubtitleOverlay.cjs.js"),Pr=require("./useSlide.cjs.js"),Or=require("./useWakePlayerFromIframe.cjs.js"),jr=require("./utils/playerKeyboardShortcutContext.cjs.js"),qr=require("./utils/playerKeyboardShortcuts.cjs.js"),qe=require("./utils/mobileScreenMode.cjs.js"),et=require("./utils/interactionPlayback.cjs.js"),Fr=require("./utils/markdownScaling.cjs.js"),At=require("./utils/playerNavigationContext.cjs.js"),Lr=require("./utils/appendedMarkerAdvance.cjs.js"),gn=require("./utils/playbackSequence.cjs.js"),wt=require("./utils/subtitleJumpNavigation.cjs.js"),vn=require("./utils/playerCustomActions.cjs.js"),Dr=require("./utils/playbackTimeStore.cjs.js"),Nr=require("./utils/interactionResolution.cjs.js"),Br=require("./utils/playerToggleMode.cjs.js"),En=require("./utils/imageOnlyStepVisualReady.cjs.js"),Vr=require("./utils/silentStepAutoAdvance.cjs.js"),Kr=require("./utils/playerVisibility.cjs.js"),An=require("./slideI18n.cjs.js");;/* empty css */const Tt=require("../../node_modules/lucide-react/dist/esm/icons/grip-horizontal.cjs.js"),Ur=require("../../node_modules/lucide-react/dist/esm/icons/chevron-left.cjs.js"),Hr=2e3,Yr=300,Wr=160,Gr=16,In=3e3,tt={x:0,y:0},Mt=.5,Jr=typeof window>"u"?t.useEffect:t.useLayoutEffect,Xr=["button","input","textarea",'[contenteditable=""]','[contenteditable="true"]','[contenteditable="plaintext-only"]'].join(", "),_t="waitingForAudio",zr=({x:u,y:c})=>({x:Number(u.toFixed(2)),y:Number(c.toFixed(2))}),Rn=u=>Math.abs(u)>=Mt,Cn=(u,c)=>Math.abs(u.x-c.x)<Mt&&Math.abs(u.y-c.y)<Mt,$r=(u,c)=>typeof u=="string"?u:u[c]??u[_t]??An.DEFAULT_SLIDE_BUFFERING_TEXTS[c],Qr=(u,c)=>typeof u=="string"?u:{...c,...u},Zr=(u,c)=>c?u!=="loadingAudio":!1,wn=t.memo(({content:u,title:c,locale:B,defaultButtonText:ye,defaultInputText:V,defaultSelectedValues:K,confirmButtonText:Q,copyButtonText:Z,copiedButtonText:Fe,onSend:nt,onDragHandlePointerCancel:ee,onDragHandlePointerDown:rt,onDragHandlePointerMove:he,onDragHandlePointerUp:Le,readonly:De=!1})=>l.jsxRuntimeExports.jsxs("div",{className:"slide-player__interaction-card",children:[l.jsxRuntimeExports.jsx("button",{type:"button",className:"slide-player__interaction-drag-handle","aria-label":"Move interaction",onPointerCancel:ee,onPointerDown:rt,onPointerMove:he,onPointerUp:Le,children:l.jsxRuntimeExports.jsxs("span",{className:"slide-player__interaction-drag-handle-icon",children:[l.jsxRuntimeExports.jsx(Tt.default,{"aria-hidden":"true"}),l.jsxRuntimeExports.jsx(Tt.default,{"aria-hidden":"true"}),l.jsxRuntimeExports.jsx(Tt.default,{"aria-hidden":"true"})]})}),l.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-header",children:l.jsxRuntimeExports.jsx("p",{className:"slide-player__interaction-title",children:c})}),l.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-body",children:l.jsxRuntimeExports.jsx(Tr.default,{content:u,locale:B,defaultButtonText:ye,defaultInputText:V,defaultSelectedValues:K,confirmButtonText:Q,copyButtonText:Z,copiedButtonText:Fe,onSend:nt,readonly:De,sandboxMode:"content"})})]}));wn.displayName="InteractionOverlayCard";const eo=(u,c)=>u.length===c.length&&u.every((B,ye)=>{const V=c[ye];return B.sequence_number===V?.sequence_number&&B.type===V?.type&&B.content===V?.content}),kt=u=>u instanceof HTMLElement&&!!u.closest(Xr),to=({elementList:u=[],locale:c,playerEnabled:B,playerControlsVisibility:ye,playerClassName:V,fullscreenHeader:K,playerCustomActions:Q,playerCustomActionPauseOnActive:Z=!0,bufferingText:Fe,interactionTitle:nt,interactionTexts:ee,playerTexts:rt,playerAutoHideDelay:he=3e3,markerAutoAdvanceDelay:Le=Hr,interactionDefaultValueOptions:De,onSend:Pt,onPlayerVisibilityChange:ot,onMobileViewModeChange:Ot,onStepChange:jt,enableKeyboardShortcuts:te=!0,enableIframeScaling:Tn=!0,enableMarkdownScaling:kn=!0,disableLoadingOverlay:w=!1,className:Mn,onPointerDown:qt,onFocusCapture:Ft,..._n})=>{const U=t.useMemo(()=>An.getSlideLocaleTexts(c),[c]),Pn=t.useMemo(()=>Qr(Fe,U.bufferingText),[Fe,U.bufferingText]),{playerEnabled:On,playerControlsVisibility:F}=Kr.resolveSlidePlayerVisibility({playerEnabled:B,playerControlsVisibility:ye}),Ne=t.useId(),xe=t.useRef(null),st=t.useRef(null),Be=t.useRef(null),Lt=t.useRef(null),ne=t.useRef(null),Ve=t.useRef(!1),be=t.useRef(null),Ke=t.useRef(null),H=t.useRef(null),Se=t.useRef(null),ge=t.useRef(null),re=t.useRef(null),ve=t.useRef(null),Dt=t.useRef([]),Ee=t.useRef(!1),Y=t.useRef(null),Ie=t.useRef(null),Nt=t.useRef(0),Bt=t.useRef(null),Vt=t.useRef({markerCount:0,currentIndex:-1,canGoNext:!1}),at=t.useRef(!1),{currentElementList:C,stepElementLists:Kt,slideElementList:R,currentIndex:i,audioList:h,audioSlideIndexes:Ue,currentAudioSequenceIndexes:He,currentStepHasSpeakableElement:b,currentInteractionElement:d,canGoPrev:jn,canGoNext:A,handlePrev:Ut,handleNext:T,handleGoTo:Ht}=Pr.default(u),Re=t.useMemo(()=>{if(!(i<0))return R[i]},[i,R]),oe=t.useMemo(()=>C.map((e,n)=>`${e.sequence_number??`${e.type}-${n}`}:${String(e.is_new??"")}`),[C]),qn=R.filter(e=>e.is_renderable!==!1).length===1,m=On&&(R.length>0||h.length>0||!!d),Fn=t.useMemo(()=>({enabled:te,ownerId:Ne}),[te,Ne]),L=t.useCallback(()=>{!te||!m||qr.activatePlayerKeyboardShortcutOwner(Ne)},[te,Ne,m]),k=t.useMemo(()=>He.map(e=>h[e]?.audioKey).filter(e=>!!e),[h,He]),[Ln,Ce]=t.useState(!0),[Ye,se]=t.useState(!1),[lt,Yt]=t.useState(!0),[Ae,Wt]=t.useState(!0),[g,D]=t.useState(null),[Dn,Gt]=t.useState(null),[Nn,S]=t.useState(!1),[Bn,it]=t.useState(_t),[M,ut]=t.useState(!1),[Vn,We]=t.useState(!1),[Jt,Kn]=t.useState(!0),[ct,dt]=t.useState(!1),[f,ft]=t.useState(),[ae,Ge]=t.useState(!1),[Xt,Je]=t.useState(!1),[v,mt]=t.useState(tt),[pt,yt]=t.useState(!1),[Un,we]=t.useState(0),[zt,Hn]=t.useState(!1),j=t.useMemo(()=>Ze.isMobileDevice(),[]),[Xe,ht]=t.useState(qe.DEFAULT_MOBILE_VIEW_MODE),[$t,xt]=t.useState(!1),[Yn,Qt]=t.useState(()=>j?Ze.isLandscapeViewport():!1),le=t.useMemo(()=>Dr.createPlaybackTimeStore(),[]),{effectiveMobileViewMode:W,isImmersiveMobileFullscreen:ie,isNativeMobileFullscreen:Zt,shouldRotateFullscreenViewport:Wn}=t.useMemo(()=>qe.resolveMobileViewModeState({hasManualMobileViewMode:$t,isMobileDevice:j,mobileViewMode:Xe}),[$t,j,Yn,Xe]),en=t.useRef(W),E=m&&F!=="hidden"&&(F==="visible"||Ln),Gn=ie&&E,Jn=ie&&E,Xn=ie||Zt,tn=zt&&!j,zn=t.useCallback(e=>{xt(!0),ht(e)},[]),nn=t.useCallback(()=>{xt(!1),ht(qe.DEFAULT_MOBILE_VIEW_MODE)},[]),$n=t.useCallback(()=>{nn(),K?.onBack?.()},[K,nn]),rn=t.useCallback(e=>{dt(e)},[]),on=t.useCallback(()=>{dt(e=>!e)},[]),G=t.useCallback(()=>{mt(e=>e.x===tt.x&&e.y===tt.y?e:tt),yt(!1),ve.current=null,re.current=null},[]),{mountedStepStates:Qn,currentMountedStateIndex:Zn}=t.useMemo(()=>{const e=[],n=new Map;return Kt.forEach((r,s)=>{const a=e.findIndex(o=>eo(o.elementList,r));if(a>=0){e[a]?.sourceStepIndexes.push(s),n.set(s,a);return}e.push({elementList:r,sourceStepIndexes:[s]}),n.set(s,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:i>=0?n.get(i)??-1:-1}},[i,Kt]),sn=t.useMemo(()=>String(i),[i]),I=t.useMemo(()=>g?h.findIndex(e=>(e.audioKey??"")===g):-1,[h,g]),bt=t.useMemo(()=>I>=0?h[I]:void 0,[h,I]),er=bt?.element?.subtitle_cues??[],ze=t.useMemo(()=>k[0]??"none",[k]),St=t.useMemo(()=>({currentElement:vn.resolvePlayerCustomActionElement({currentAudioIndex:I,currentAudioSequenceIndexes:He,audioList:h,currentInteractionElement:f,currentStepElement:Re}),currentIndex:i,currentStepElement:Re,isActive:ct,setActive:rn,toggleActive:on}),[f,h,I,He,i,Re,ct,rn,on]),gt=t.useMemo(()=>vn.getPlayerCustomActionCount(Q,St),[St,Q]),tr=t.useMemo(()=>({"--slide-player-custom-action-count":String(gt),"--slide-player-mobile-control-count":String(gt+4),"--slide-interaction-drag-x":`${v.x}px`,"--slide-interaction-drag-y":`${v.y}px`}),[v.x,v.y,gt]),an=k.length>0,ln=t.useMemo(()=>d?`${d.sequence_number??"none"}:${String(d.content??"")}`:"none",[d]),Te=t.useMemo(()=>[sn,ln].join("|"),[ln,sn]),nr=t.useMemo(()=>[Te,bt?.audioKey??"none",String(I)].join("|"),[I,bt?.audioKey,Te]),un=!!t.useMemo(()=>!ze||ze==="none"?"":h.find(n=>n.audioKey===ze)?.audioUrl?.trim()??"",[h,ze]),J=Z&&!!Q&&ct,ke=t.useMemo(()=>Br.shouldUseAutoAdvanceToggle({canGoNext:A,currentAudioIndex:I,currentStepHasSpeakableElement:b,hasInteraction:!!d}),[A,I,d,b]),cn=t.useMemo(()=>Vr.resolveSilentStepAutoAdvanceBehavior({currentElementList:C,currentStepHasSpeakableElement:b,currentInteractionElement:d,markerAutoAdvanceDelay:Le}),[C,d,b,Le]),dn=cn.delayMs,Me=cn.usesImageOnlyDelay,vt=t.useMemo(()=>`${i}:${oe.join("|")}`,[i,oe]),[rr,or]=t.useState(null),fn=!Me||rr===vt,q=t.useCallback(()=>{ne.current!==null&&(window.clearTimeout(ne.current),ne.current=null)},[]),_=t.useCallback(()=>{H.current!==null&&(window.clearTimeout(H.current),H.current=null)},[]),P=t.useCallback(()=>{Se.current!==null&&(window.clearTimeout(Se.current),Se.current=null)},[]),ue=t.useCallback(()=>{be.current!==null&&(window.clearTimeout(be.current),be.current=null)},[]),N=t.useCallback(()=>{Ke.current!==null&&(window.clearTimeout(Ke.current),Ke.current=null)},[]),O=t.useCallback((e={})=>{ue(),_(),P(),N(),D(null),le.reset(),S(!1),it(_t),ut(!1),We(!1),Gt(null),e.preservePendingSubtitleJump||(Ie.current=null),ft(void 0),Ge(!1),we(0)},[ue,N,_,P,le]),$e=t.useCallback(e=>{Nt.current+=1,Gt({...e,id:Nt.current})},[]),ce=t.useCallback(()=>{const e=k[0];return e?(D(e),!0):!1},[k]),_e=t.useCallback(()=>{_(),P(),Ge(!1),we(0),!ce()&&A&&T()},[A,_,P,T,ce]),mn=t.useCallback(e=>{if(P(),!e)return;const n=()=>{Se.current=null,we(Wr),Ge(!0),Y.current=null};Se.current=window.setTimeout(n,Yr)},[P]),Et=t.useCallback(()=>Ve.current||!!xe.current?.querySelector(".slide-player__controls:hover"),[]),p=t.useCallback((e=Ye)=>{!m||F==="hidden"||(Ce(!0),q(),!(F==="visible"||!e||he<=0||Et())&&(ne.current=window.setTimeout(()=>{if(Et()){ne.current=null;return}Ce(!1),ne.current=null},he)))},[q,Ye,Et,he,F,m]),Pe=!!wt.hasResolvedInteractionElement(d),de=!!d&&!Pe,sr=t.useCallback(e=>{Yt(e)},[]),fe=t.useCallback(e=>{e&&Yt(e.shouldContinuePlayback)},[]);t.useEffect(()=>{Wt(lt)},[i,lt,Z]),t.useEffect(()=>{Z&&dt(!1)},[i,Z]),t.useEffect(()=>()=>{ue(),N(),q(),_(),P()},[ue,N,_,P,q]),t.useEffect(()=>{if(!Me){N();return}let e=!1,n=null,r=null;const s=()=>{r?.(),r=null},a=()=>{e||(s(),N(),or(vt))},o=()=>{if(e)return;s();const y=Be.current?.querySelector('[data-active-step="true"]');if(!y)return;const x=Array.from(y.querySelectorAll("iframe"));if(x.length===0||En.areImageOnlyStepIframeVisualsReady(x)){a();return}const X=[],je=()=>{e||(n!==null&&window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{n=null,o()}))},Ct=(z,me,$)=>{z.addEventListener(me,$,{once:!0}),X.push(()=>z.removeEventListener(me,$))};x.forEach(z=>{const me=z.contentDocument;if(!me||me.readyState!=="complete"){Ct(z,"load",je);return}Array.from(me.images).filter($=>!$.complete).forEach($=>{Ct($,"load",je),Ct($,"error",je)})}),r=()=>{X.forEach(z=>z())}};return n=window.requestAnimationFrame(()=>{n=null,o()}),Ke.current=window.setTimeout(()=>{a()},En.DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS),()=>{e=!0,s(),N(),n!==null&&window.cancelAnimationFrame(n)}},[N,C,i,vt,Me]),t.useEffect(()=>(ot?.(E),()=>{ot?.(!1)}),[ot,E]),t.useEffect(()=>{E||(Ve.current=!1)},[E]),t.useEffect(()=>{j||Xe===qe.DEFAULT_MOBILE_VIEW_MODE||(xt(!1),ht(qe.DEFAULT_MOBILE_VIEW_MODE))},[j,Xe]),t.useEffect(()=>{if(!j){Qt(!1);return}const e=()=>{Qt(Ze.isLandscapeViewport()),G()},n=()=>{G()};e(),window.addEventListener("orientationchange",n),window.screen?.orientation?.addEventListener?.("change",n);const r=Ze.subscribeMobileDeviceChange(e);return()=>{r(),window.removeEventListener("orientationchange",n),window.screen?.orientation?.removeEventListener?.("change",n)}},[j,G]),t.useEffect(()=>{Ot?.(W)},[W,Ot]),t.useEffect(()=>{en.current!==W&&G(),en.current=W},[W,G]),t.useEffect(()=>{jt?.(Re,i)},[i,Re,jt]),t.useEffect(()=>{const e=Vt.current,n=Lr.shouldAutoAdvanceIntoAppendedMarker({previousMarkerCount:e.markerCount,nextMarkerCount:R.length,previousIndex:e.currentIndex,previousCanGoNext:e.canGoNext,nextCanGoNext:A,currentAudioKey:g,hasCompletedCurrentStepAudio:M,hasResolvedCurrentInteraction:Pe,currentStepHasSpeakableElement:b,currentInteractionElement:d,isAutoAdvanceEnabled:Ae,shouldUseSilentStepAutoAdvanceToggle:ke});Vt.current={markerCount:R.length,currentIndex:i,canGoNext:A},n&&T()},[A,g,i,d,b,T,M,Pe,Ae,ke,R.length]),t.useEffect(()=>{if(!m||F==="hidden"){q(),Ce(!1);return}if(F==="visible"){q(),Ce(!0);return}Ye||p(!0)},[q,Ye,F,m,p]),t.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.origin===window.location.origin&&Ar.isSandboxInteractionMessage(n.data)&&n.data.eventType==="click"&&m&&(L(),se(!0),p(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[L,m,p]),Or.default({sectionRef:xe,enabled:m,keyboardShortcutsEnabled:te,onKeyboardShortcut:L,onWake:()=>{L(),se(!0),p(!0)}}),t.useEffect(()=>{if(!m){O();return}const{hasPlaybackContextChanged:e,shouldInitializeAudioSequence:n}=gn.getPlaybackSequenceTransition({previousResetKey:Bt.current,nextResetKey:Te,currentAudioKey:g,hasCompletedCurrentStepAudio:M});Bt.current=Te;const r=Y.current===i&&!!d,s=et.shouldPresentInteractionOverlay({hasInteraction:!!d,shouldBlockPlaybackForInteraction:de,shouldOpenInteractionOverlayAfterAudio:r,hasPlaybackContextChanged:e,hasResolvedCurrentInteraction:Pe,currentStepHasSpeakableElement:b}),a=Ie.current,o=a?.slideIndex===i;if(e&&O({preservePendingSubtitleJump:o}),!(C.length===0&&!d)&&!J){if(a?.slideIndex===i&&wt.canReachSubtitleJumpTarget({currentIndex:i,resolvedCurrentInteractionElement:f,slideElementList:R,targetSlideIndex:a.slideIndex})){Ie.current=null,at.current=!0,D(a.audioKey),$e({audioIndex:a.audioIndex,timeMs:a.timeMs});return}if(d&&ft(d),s){mn(d);return}if(P(),Y.current=null,!!n&&!ce()){if(b){if(w){S(!1);return}S(!0);return}if(A&&!(ke&&!Ae)&&!(Me&&!fn))return be.current=window.setTimeout(()=>{be.current=null,T()},dn),()=>{ue()}}}},[f,A,ue,C.length,i,d,g,Te,b,Me,fn,dn,T,M,w,Ae,Pe,de,P,O,$e,mn,m,R,ce,J,ke]),t.useEffect(()=>{if(w||J||!b||de){S(!1);return}if(M){S(!1);return}if(an){S(!1);return}it("waitingForAudio"),S(!0)},[an,b,M,w,J,de]),t.useEffect(()=>{const e=at.current;at.current=!1,gn.shouldStartDefaultAudioSequence({currentAudioKey:g,currentAudioSequenceLength:k.length,currentStepHasSpeakableElement:b,hasCompletedCurrentStepAudio:M,shouldBlockPlaybackForInteraction:de,shouldPausePlaybackForCustomAction:J,shouldSkipDefaultAudioStart:e})&&ce()},[g,k,b,M,J,de,ce]),t.useEffect(()=>{!g||I>=0||D(null)},[I,g]),t.useEffect(()=>{I>=0||le.reset()},[I,le]),t.useEffect(()=>{We(!1)},[nr]);const{interactionDefaults:pn,interactionDefaultSelectedValues:ar,hasResolvedInteractionInput:yn,isInteractionReadonly:lr,shouldAutoContinueInteraction:hn}=t.useMemo(()=>Nr.resolveSlideInteractionState(f,{interactionDefaultValueOptions:De}),[f,De]),ir=!!f?.readonly||lr,Oe=et.shouldRenderInteractionOverlay({hasActiveInteraction:!!f,isInteractionOverlayOpen:ae}),ur=t.useCallback(e=>{const r=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");ft(s=>!s||!r?s:{...s,user_input:r}),Pt?.(e,f),_e()},[f,_e,Pt]);t.useEffect(()=>{const e=()=>{Hn(document.fullscreenElement===xe.current)};return e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),t.useEffect(()=>{f&&ae||Je(!1)},[f,ae]),t.useEffect(()=>{G()},[f,G]),t.useEffect(()=>{if(!Oe){we(0);return}const e=ge.current;if(!e)return;const n=()=>{const s=Math.ceil(e.getBoundingClientRect().height);we(s+Gr)};if(n(),typeof ResizeObserver>"u")return;const r=new ResizeObserver(()=>{n()});return r.observe(e),()=>{r.disconnect()}},[Oe]),t.useEffect(()=>{if(_(),!!ae){if(hn)return H.current=window.setTimeout(()=>{H.current=null,_e()},In),()=>{_()};if(!(Xt||!yn))return H.current=window.setTimeout(()=>{H.current=null,_e()},In),()=>{_()}}},[_,_e,Xt,yn,ae,hn]);const cr=(e,n={})=>e?e.type==="slot"?l.jsxRuntimeExports.jsx(l.jsxRuntimeExports.Fragment,{children:e.content}):e.type==="html"?l.jsxRuntimeExports.jsx(Sn.default,{className:"content-render-iframe",disableLoadingOverlay:w,hideFullScreen:!0,locale:c,mode:"blackboard",replaceRootScreenHeightWithFull:n.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content,enableScaling:Tn}):l.jsxRuntimeExports.jsx(Sn.default,{className:"content-render-iframe",disableLoadingOverlay:w,hideFullScreen:!0,locale:c,mode:"blackboard",type:"markdown",content:e.content}):null,dr=(e=[],n=!1)=>{if(e.length===0)return null;const r=e.filter(o=>o.is_renderable!==!1).length,s=n&&kn?Fr.resolveMarkdownScalingMode(e):"disabled",a=e.reduce((o,y,x)=>y.is_renderable!==!1?x:o,-1);return l.jsxRuntimeExports.jsx(Mr.default,{className:"slide-stage__content flex w-full flex-col gap-4",mode:s,children:e.map((o,y)=>{const x=o.type==="html"&&o.is_renderable===!1;return l.jsxRuntimeExports.jsx("div",{ref:n&&y===a?Lt:null,"aria-hidden":x||void 0,className:pe.cn("w-full shrink-0",r===1&&o.is_renderable!==!1&&"slide-element--single",x?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":o.is_renderable===!1&&"hidden"),children:cr(o,{replaceRootScreenHeightWithFull:r===1&&o.type==="html"&&o.is_renderable!==!1})},o.sequence_number??`${o.type}-${y}`)})})},fr=t.useCallback(()=>{const e=xe.current;if(e){if(document.fullscreenElement===e){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},[]),xn=t.useCallback(()=>{const e=Be.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),It=t.useCallback(e=>wt.canReachSubtitleJumpTarget({currentIndex:i,resolvedCurrentInteractionElement:f,slideElementList:R,targetSlideIndex:Ue[e.audioIndex]}),[f,Ue,i,R]),mr=t.useCallback((e,n)=>{const s=h[e.audioIndex]?.audioKey,a=Ue[e.audioIndex];return!s||a==null||!It(e)?!1:(fe(n),Y.current=null,S(!1),ut(!1),We(!1),At.shouldWakePlayerControlsAfterNavigation(n)&&(se(!0),p(!0)),a===i?(Ie.current=null,O(),D(s),$e(e),!0):(Ee.current=!0,O(),Ie.current={audioIndex:e.audioIndex,audioKey:s,slideIndex:a,timeMs:e.timeMs},Ht(a),!0))},[h,Ue,It,i,Ht,$e,O,p,fe]),pr=t.useCallback(e=>{fe(e),Ee.current=!0,Y.current=null,S(!1),At.shouldWakePlayerControlsAfterNavigation(e)&&(se(!0),p(!0)),O(),Ut()},[Ut,O,p,fe]),yr=t.useCallback(e=>{fe(e),Ee.current=!0,Y.current=null,S(!1),At.shouldWakePlayerControlsAfterNavigation(e)&&(se(!0),p(!0)),O(),T()},[T,O,p,fe]),hr=t.useCallback(({loading:e,reason:n})=>{if(w){S(!1);return}if(!b||M){S(!1);return}e&&n&&it(n),S(Zr(n,e))},[b,M,w]);t.useEffect(()=>{w&&S(!1)},[w]);const xr=t.useCallback(e=>{const n=h[e]?.audioKey;if(!n||!g||n!==g)return;const r=k.findIndex(o=>o===n);if(r<0){D(null);return}const s=r+1,a=k[s];if(a){D(a);return}if(D(null),ut(!0),S(!1),A){const o=i+1,y=R[o];un&&y?.type==="interaction"&&(Y.current=o),T();return}},[h,A,i,g,k,T,un,R]),br=t.useCallback(()=>{f&&Ge(e=>!e)},[f]),Sr=t.useCallback(()=>{Ve.current=!0,q(),m&&Ce(!0)},[q,m]),gr=t.useCallback(()=>{Ve.current=!1,p(!0)},[p]),Rt=t.useCallback(e=>{e.stopPropagation(),E&&p(!0)},[E,p]),Qe=t.useCallback((e,n)=>{const r=st.current;if(!r)return null;const s=e.getBoundingClientRect(),a=r.getBoundingClientRect();return{minX:n.x+a.left-s.left,maxX:n.x+a.right-s.right,minY:n.y+a.top-s.top,maxY:n.y+a.bottom-s.bottom}},[]);Jr(()=>{const e=ge.current;if(!Oe||!e){re.current=null;return}const n=re.current,r=e.getBoundingClientRect();if(!n||pt){re.current={left:r.left,top:r.top};return}const s=n.left-r.left,a=n.top-r.top;if(!Rn(s)&&!Rn(a)){re.current={left:r.left,top:r.top};return}const o={x:v.x+s,y:v.y+a},y=Qe(e,v),x=zr(y?et.clampInteractionOverlayDragOffset(o,y):o);re.current={left:r.left+x.x-v.x,top:r.top+x.y-v.y},Cn(x,v)||mt(X=>Cn(X,x)?X:x)},[Qe,v,pt,E,m,Oe]);const vr=t.useCallback(e=>{if(Rt(e),e.button!==0||!e.currentTarget.isConnected||!ge.current)return;const n=Qe(ge.current,v);n&&(e.preventDefault(),e.currentTarget.hasPointerCapture?.(e.pointerId)!==!0&&e.currentTarget.setPointerCapture(e.pointerId),ve.current={pointerId:e.pointerId,startClientX:e.clientX,startClientY:e.clientY,startOffset:v,bounds:n},yt(!0))},[Qe,v,Rt]),Er=t.useCallback(e=>{const n=ve.current;!n||n.pointerId!==e.pointerId||(e.preventDefault(),e.stopPropagation(),mt(et.clampInteractionOverlayDragOffset({x:n.startOffset.x+e.clientX-n.startClientX,y:n.startOffset.y+e.clientY-n.startClientY},n.bounds)))},[]),bn=t.useCallback(e=>{const n=ve.current;!n||n.pointerId!==e.pointerId||(e.stopPropagation(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),ve.current=null,yt(!1))},[]),Ir=t.useCallback(e=>{L(),qt?.(e)},[L,qt]),Rr=t.useCallback(e=>{L(),Ft?.(e)},[L,Ft]),Cr=t.useCallback(()=>{se(!0),p(!0)},[p]);return t.useEffect(()=>{const e=Dt.current,s=(e.length>0&&e.length<oe.length&&e.every((o,y)=>o===oe[y])?C.slice(e.length):[]).some(o=>o.is_new===!1);if(Dt.current=oe,!s)return;const a=window.requestAnimationFrame(()=>{const o=Be.current,y=Lt.current;if(!o||!y)return;const x=o.getBoundingClientRect(),X=y.getBoundingClientRect(),je=o.scrollTop+(X.top-x.top);o.scrollTo({top:Math.max(je,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(a)}},[C,oe]),t.useEffect(()=>{if(!Ee.current||(Ee.current=!1,C.length===0))return;const e=window.requestAnimationFrame(()=>{xn()});return()=>{window.cancelAnimationFrame(e)}},[C,xn]),l.jsxRuntimeExports.jsxs("section",{ref:xe,className:pe.cn("relative h-full w-full",j&&"slide--mobile-device",tn&&"slide--browser-fullscreen",ie&&"slide--mobile-landscape",Zt&&"slide--mobile-landscape-native",Mn),onClick:Cr,onFocusCapture:Rr,onPointerDown:Ir,..._n,children:[Xn?l.jsxRuntimeExports.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]"}):null,l.jsxRuntimeExports.jsxs("div",{ref:st,className:pe.cn("slide__viewport relative h-full min-h-0 w-full",ie&&"slide__viewport--mobile-landscape",ie&&!Wn&&"slide__viewport--mobile-landscape-native"),children:[Gn?l.jsxRuntimeExports.jsxs("div",{className:"slide-landscape-header",children:[l.jsxRuntimeExports.jsx("button",{"aria-label":K?.backAriaLabel??U.fullscreenBackAriaLabel,className:"slide-landscape-header__back",onClick:$n,type:"button",children:l.jsxRuntimeExports.jsx(Ur.default,{className:"slide-landscape-header__icon h-6 w-6",strokeWidth:2.25})}),K?.content?l.jsxRuntimeExports.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:K.content}):null]}):null,l.jsxRuntimeExports.jsx("div",{className:pe.cn("h-full min-h-0 w-full",Jn&&"slide__viewport-content--with-header",qn?"slide-content--single":"grid gap-4"),children:C.length>0?l.jsxRuntimeExports.jsx("div",{className:"slide-stage",children:l.jsxRuntimeExports.jsx("div",{ref:Be,className:"slide-stage__layer w-full",children:Qn.map((e,n)=>{const r=n===Zn;return l.jsxRuntimeExports.jsx("div",{"data-active-step":r?"true":void 0,"aria-hidden":!r||void 0,className:"w-full h-full",style:{display:r?void 0:"none"},children:dr(e.elementList,r)},e.sourceStepIndexes[0]??n)})})}):null}),Nn?l.jsxRuntimeExports.jsx(wr.default,{message:$r(Pn,Bn),className:"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2"}):null,l.jsxRuntimeExports.jsx(_r.default,{extraBottomOffset:Un,hasPlayerGap:E,isEnabled:Jt&&Vn,isPlayerHidden:m&&!E,playbackTimeStore:le,subtitleCues:er}),Oe?l.jsxRuntimeExports.jsx("div",{ref:ge,"data-player-keyboard-shortcuts-ignore":"true",className:pe.cn("slide-interaction-overlay",E&&m?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone",pt&&"slide-interaction-overlay--dragging"),onClick:Rt,onPointerDownCapture:e=>{kt(e.target)&&Je(!0)},onFocusCapture:e=>{kt(e.target)&&Je(!0)},onInputCapture:e=>{kt(e.target)&&Je(!0)},style:tr,children:l.jsxRuntimeExports.jsx(wn,{content:String(f?.content??""),locale:c,defaultButtonText:pn.buttonText??"",defaultInputText:pn.inputText??"",defaultSelectedValues:ar,confirmButtonText:ee?.confirmButtonText??U.interactionTexts.confirmButtonText,copyButtonText:ee?.copyButtonText??U.interactionTexts.copyButtonText,copiedButtonText:ee?.copiedButtonText??U.interactionTexts.copiedButtonText,onSend:ur,onDragHandlePointerCancel:bn,onDragHandlePointerDown:vr,onDragHandlePointerMove:Er,onDragHandlePointerUp:bn,readonly:ir,title:ee?.title??nt??U.interactionTexts.title})}):null,m?l.jsxRuntimeExports.jsx(jr.PlayerKeyboardShortcutContext.Provider,{value:Fn,children:l.jsxRuntimeExports.jsx(kr.default,{audioList:h,className:pe.cn("absolute left-1/2 z-[2] -translate-x-1/2",tn?"bottom-3":"-bottom-3",V,!E&&"pointer-events-none opacity-0"),currentAudioIndex:I,defaultPlaying:lt,enableKeyboardShortcuts:te,isPlaybackPaused:J,isAutoAdvanceEnabled:Ae,locale:c,hasInteraction:!!f,isInteractionOpen:ae,isSubtitleEnabled:Jt,onAutoAdvanceToggle:Wt,onLoadingChange:hr,onPlaybackStarted:()=>{We(!0)},onPlaybackPreferenceChange:sr,onPlaybackTimeChange:le.setTime,onSubtitleToggle:()=>{Kn(e=>!e)},nextDisabled:!A,onEnded:xr,onFullscreen:fr,isFullscreen:zt,mobileViewMode:W,settingsPortalContainer:st.current,onMobileViewModeChange:zn,onControlsPointerEnter:Sr,onControlsPointerLeave:gr,onInteractionToggle:br,onNext:yr,onPrev:pr,onSubtitleJump:mr,canJumpToSubtitleTarget:It,prevDisabled:!jn,showControls:E,subtitleSeekRequest:Dn,texts:rt,customActionContext:St,customActions:Q,useAutoAdvanceToggle:ke})}):null]})]})};exports.default=to;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),Tr=require("../../lib/sandboxInteraction.cjs.js"),me=require("../../lib/utils.cjs.js"),kr=require("../ui/loading-overlay-card.cjs.js"),Mr=require("../ContentRender/ContentRender.cjs.js"),gn=require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");require("../ContentRender/contentRenderI18n.cjs.js");const tt=require("../../lib/mobileDevice.cjs.js"),Pr=require("./Player.cjs.js"),_r=require("./MarkdownSlideScaling.cjs.js"),Or=require("./SubtitleOverlay.cjs.js"),jr=require("./useSlide.cjs.js"),qr=require("./useWakePlayerFromIframe.cjs.js"),Fr=require("./utils/playerKeyboardShortcutContext.cjs.js"),Lr=require("./utils/playerKeyboardShortcuts.cjs.js"),qe=require("./utils/mobileScreenMode.cjs.js"),nt=require("./utils/interactionPlayback.cjs.js"),Dr=require("./utils/markdownScaling.cjs.js"),wt=require("./utils/playerNavigationContext.cjs.js"),Nr=require("./utils/appendedMarkerAdvance.cjs.js"),vn=require("./utils/stepAudioProgress.cjs.js"),En=require("./utils/playbackSequence.cjs.js"),Tt=require("./utils/subtitleJumpNavigation.cjs.js"),In=require("./utils/playerCustomActions.cjs.js"),Br=require("./utils/playbackTimeStore.cjs.js"),Vr=require("./utils/interactionResolution.cjs.js"),Kr=require("./utils/playerToggleMode.cjs.js"),Rn=require("./utils/imageOnlyStepVisualReady.cjs.js"),Ur=require("./utils/silentStepAutoAdvance.cjs.js"),Hr=require("./utils/playerVisibility.cjs.js"),Tn=require("./slideI18n.cjs.js");;/* empty css */const kt=require("../../node_modules/lucide-react/dist/esm/icons/grip-horizontal.cjs.js"),Yr=require("../../node_modules/lucide-react/dist/esm/icons/chevron-left.cjs.js"),Wr=2e3,Gr=300,Jr=160,Xr=16,An=3e3,rt={x:0,y:0},Pt=.5,zr=typeof window>"u"?t.useEffect:t.useLayoutEffect,$r=["button","input","textarea",'[contenteditable=""]','[contenteditable="true"]','[contenteditable="plaintext-only"]'].join(", "),_t="waitingForAudio",Qr=({x:u,y:c})=>({x:Number(u.toFixed(2)),y:Number(c.toFixed(2))}),Cn=u=>Math.abs(u)>=Pt,wn=(u,c)=>Math.abs(u.x-c.x)<Pt&&Math.abs(u.y-c.y)<Pt,Zr=(u,c)=>typeof u=="string"?u:u[c]??u[_t]??Tn.DEFAULT_SLIDE_BUFFERING_TEXTS[c],eo=(u,c)=>typeof u=="string"?u:{...c,...u},to=(u,c)=>c?u!=="loadingAudio":!1,kn=t.memo(({content:u,title:c,locale:B,defaultButtonText:ye,defaultInputText:V,defaultSelectedValues:K,confirmButtonText:Q,copyButtonText:Z,copiedButtonText:Fe,onSend:ot,onDragHandlePointerCancel:ee,onDragHandlePointerDown:st,onDragHandlePointerMove:he,onDragHandlePointerUp:Le,readonly:De=!1})=>l.jsxRuntimeExports.jsxs("div",{className:"slide-player__interaction-card",children:[l.jsxRuntimeExports.jsx("button",{type:"button",className:"slide-player__interaction-drag-handle","aria-label":"Move interaction",onPointerCancel:ee,onPointerDown:st,onPointerMove:he,onPointerUp:Le,children:l.jsxRuntimeExports.jsxs("span",{className:"slide-player__interaction-drag-handle-icon",children:[l.jsxRuntimeExports.jsx(kt.default,{"aria-hidden":"true"}),l.jsxRuntimeExports.jsx(kt.default,{"aria-hidden":"true"}),l.jsxRuntimeExports.jsx(kt.default,{"aria-hidden":"true"})]})}),l.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-header",children:l.jsxRuntimeExports.jsx("p",{className:"slide-player__interaction-title",children:c})}),l.jsxRuntimeExports.jsx("div",{className:"slide-player__interaction-body",children:l.jsxRuntimeExports.jsx(Mr.default,{content:u,locale:B,defaultButtonText:ye,defaultInputText:V,defaultSelectedValues:K,confirmButtonText:Q,copyButtonText:Z,copiedButtonText:Fe,onSend:ot,readonly:De,sandboxMode:"content"})})]}));kn.displayName="InteractionOverlayCard";const no=(u,c)=>u.length===c.length&&u.every((B,ye)=>{const V=c[ye];return B.sequence_number===V?.sequence_number&&B.type===V?.type&&B.content===V?.content}),Mt=u=>u instanceof HTMLElement&&!!u.closest($r),ro=({elementList:u=[],locale:c,playerEnabled:B,playerControlsVisibility:ye,playerClassName:V,fullscreenHeader:K,playerCustomActions:Q,playerCustomActionPauseOnActive:Z=!0,bufferingText:Fe,interactionTitle:ot,interactionTexts:ee,playerTexts:st,playerAutoHideDelay:he=3e3,markerAutoAdvanceDelay:Le=Wr,interactionDefaultValueOptions:De,onSend:Ot,onPlayerVisibilityChange:at,onMobileViewModeChange:jt,onStepChange:qt,enableKeyboardShortcuts:te=!0,enableIframeScaling:Mn=!0,enableMarkdownScaling:Pn=!0,disableLoadingOverlay:k=!1,className:_n,onPointerDown:Ft,onFocusCapture:Lt,...On})=>{const U=t.useMemo(()=>Tn.getSlideLocaleTexts(c),[c]),jn=t.useMemo(()=>eo(Fe,U.bufferingText),[Fe,U.bufferingText]),{playerEnabled:qn,playerControlsVisibility:F}=Hr.resolveSlidePlayerVisibility({playerEnabled:B,playerControlsVisibility:ye}),Ne=t.useId(),xe=t.useRef(null),lt=t.useRef(null),Be=t.useRef(null),Dt=t.useRef(null),ne=t.useRef(null),Ve=t.useRef(!1),Se=t.useRef(null),Ke=t.useRef(null),H=t.useRef(null),be=t.useRef(null),ge=t.useRef(null),re=t.useRef(null),ve=t.useRef(null),Nt=t.useRef([]),Ee=t.useRef(!1),Y=t.useRef(null),Ie=t.useRef(null),Bt=t.useRef(0),Vt=t.useRef(null),Kt=t.useRef({markerCount:0,currentIndex:-1,canGoNext:!1}),it=t.useRef(!1),{currentElementList:A,stepElementLists:Ut,slideElementList:R,currentIndex:i,audioList:h,audioSlideIndexes:Ue,currentAudioSequenceIndexes:He,currentStepHasSpeakableElement:S,currentInteractionElement:d,canGoPrev:Fn,canGoNext:C,handlePrev:Ht,handleNext:M,handleGoTo:Yt}=jr.default(u),Re=t.useMemo(()=>{if(!(i<0))return R[i]},[i,R]),oe=t.useMemo(()=>A.map((e,n)=>`${e.sequence_number??`${e.type}-${n}`}:${String(e.is_new??"")}`),[A]),Ln=R.filter(e=>e.is_renderable!==!1).length===1,p=qn&&(R.length>0||h.length>0||!!d),Dn=t.useMemo(()=>({enabled:te,ownerId:Ne}),[te,Ne]),L=t.useCallback(()=>{!te||!p||Lr.activatePlayerKeyboardShortcutOwner(Ne)},[te,Ne,p]),w=t.useMemo(()=>He.map(e=>h[e]?.audioKey).filter(e=>!!e),[h,He]),[Nn,Ae]=t.useState(!0),[Ye,se]=t.useState(!1),[ut,Wt]=t.useState(!0),[Ce,Gt]=t.useState(!0),[g,D]=t.useState(null),[Bn,Jt]=t.useState(null),[Vn,b]=t.useState(!1),[Kn,ct]=t.useState(_t),[T,We]=t.useState(!1),Ge=t.useRef(new Set),[Un,Je]=t.useState(!1),[Xt,Hn]=t.useState(!0),[dt,ft]=t.useState(!1),[f,pt]=t.useState(),[ae,Xe]=t.useState(!1),[zt,ze]=t.useState(!1),[v,mt]=t.useState(rt),[yt,ht]=t.useState(!1),[Yn,we]=t.useState(0),[$t,Wn]=t.useState(!1),j=t.useMemo(()=>tt.isMobileDevice(),[]),[$e,xt]=t.useState(qe.DEFAULT_MOBILE_VIEW_MODE),[Qt,St]=t.useState(!1),[Gn,Zt]=t.useState(()=>j?tt.isLandscapeViewport():!1),le=t.useMemo(()=>Br.createPlaybackTimeStore(),[]),{effectiveMobileViewMode:W,isImmersiveMobileFullscreen:ie,isNativeMobileFullscreen:en,shouldRotateFullscreenViewport:Jn}=t.useMemo(()=>qe.resolveMobileViewModeState({hasManualMobileViewMode:Qt,isMobileDevice:j,mobileViewMode:$e}),[Qt,j,Gn,$e]),tn=t.useRef(W),E=p&&F!=="hidden"&&(F==="visible"||Nn),Xn=ie&&E,zn=ie&&E,$n=ie||en,nn=$t&&!j,Qn=t.useCallback(e=>{St(!0),xt(e)},[]),rn=t.useCallback(()=>{St(!1),xt(qe.DEFAULT_MOBILE_VIEW_MODE)},[]),Zn=t.useCallback(()=>{rn(),K?.onBack?.()},[K,rn]),on=t.useCallback(e=>{ft(e)},[]),sn=t.useCallback(()=>{ft(e=>!e)},[]),G=t.useCallback(()=>{mt(e=>e.x===rt.x&&e.y===rt.y?e:rt),ht(!1),ve.current=null,re.current=null},[]),{mountedStepStates:er,currentMountedStateIndex:tr}=t.useMemo(()=>{const e=[],n=new Map;return Ut.forEach((r,s)=>{const a=e.findIndex(o=>no(o.elementList,r));if(a>=0){e[a]?.sourceStepIndexes.push(s),n.set(s,a);return}e.push({elementList:r,sourceStepIndexes:[s]}),n.set(s,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:i>=0?n.get(i)??-1:-1}},[i,Ut]),an=t.useMemo(()=>String(i),[i]),I=t.useMemo(()=>g?h.findIndex(e=>(e.audioKey??"")===g):-1,[h,g]),bt=t.useMemo(()=>I>=0?h[I]:void 0,[h,I]),nr=bt?.element?.subtitle_cues??[],Qe=t.useMemo(()=>w[0]??"none",[w]),gt=t.useMemo(()=>({currentElement:In.resolvePlayerCustomActionElement({currentAudioIndex:I,currentAudioSequenceIndexes:He,audioList:h,currentInteractionElement:f,currentStepElement:Re}),currentIndex:i,currentStepElement:Re,isActive:dt,setActive:on,toggleActive:sn}),[f,h,I,He,i,Re,dt,on,sn]),vt=t.useMemo(()=>In.getPlayerCustomActionCount(Q,gt),[gt,Q]),rr=t.useMemo(()=>({"--slide-player-custom-action-count":String(vt),"--slide-player-mobile-control-count":String(vt+4),"--slide-interaction-drag-x":`${v.x}px`,"--slide-interaction-drag-y":`${v.y}px`}),[v.x,v.y,vt]),ln=w.length>0,un=t.useMemo(()=>d?`${d.sequence_number??"none"}:${String(d.content??"")}`:"none",[d]),Te=t.useMemo(()=>[an,un].join("|"),[un,an]),or=t.useMemo(()=>[Te,bt?.audioKey??"none",String(I)].join("|"),[I,bt?.audioKey,Te]),cn=!!t.useMemo(()=>!Qe||Qe==="none"?"":h.find(n=>n.audioKey===Qe)?.audioUrl?.trim()??"",[h,Qe]),J=Z&&!!Q&&dt,ke=t.useMemo(()=>Kr.shouldUseAutoAdvanceToggle({canGoNext:C,currentAudioIndex:I,currentStepHasSpeakableElement:S,hasInteraction:!!d}),[C,I,d,S]),dn=t.useMemo(()=>Ur.resolveSilentStepAutoAdvanceBehavior({currentElementList:A,currentStepHasSpeakableElement:S,currentInteractionElement:d,markerAutoAdvanceDelay:Le}),[A,d,S,Le]),fn=dn.delayMs,Me=dn.usesImageOnlyDelay,Et=t.useMemo(()=>`${i}:${oe.join("|")}`,[i,oe]),[sr,ar]=t.useState(null),pn=!Me||sr===Et,q=t.useCallback(()=>{ne.current!==null&&(window.clearTimeout(ne.current),ne.current=null)},[]),P=t.useCallback(()=>{H.current!==null&&(window.clearTimeout(H.current),H.current=null)},[]),_=t.useCallback(()=>{be.current!==null&&(window.clearTimeout(be.current),be.current=null)},[]),ue=t.useCallback(()=>{Se.current!==null&&(window.clearTimeout(Se.current),Se.current=null)},[]),N=t.useCallback(()=>{Ke.current!==null&&(window.clearTimeout(Ke.current),Ke.current=null)},[]),O=t.useCallback((e={})=>{ue(),P(),_(),N(),D(null),le.reset(),b(!1),ct(_t),We(!1),Ge.current=new Set,Je(!1),Jt(null),e.preservePendingSubtitleJump||(Ie.current=null),pt(void 0),Xe(!1),we(0)},[ue,N,P,_,le]),Ze=t.useCallback(e=>{Bt.current+=1,Jt({...e,id:Bt.current})},[]),ce=t.useCallback(()=>{const e=vn.resolvePendingStepAudioKey(w,Ge.current);return e?(D(e),!0):!1},[w]),Pe=t.useCallback(()=>{P(),_(),Xe(!1),we(0),!ce()&&C&&M()},[C,P,_,M,ce]),mn=t.useCallback(e=>{if(_(),!e)return;const n=()=>{be.current=null,we(Jr),Xe(!0),Y.current=null};be.current=window.setTimeout(n,Gr)},[_]),It=t.useCallback(()=>Ve.current||!!xe.current?.querySelector(".slide-player__controls:hover"),[]),m=t.useCallback((e=Ye)=>{!p||F==="hidden"||(Ae(!0),q(),!(F==="visible"||!e||he<=0||It())&&(ne.current=window.setTimeout(()=>{if(It()){ne.current=null;return}Ae(!1),ne.current=null},he)))},[q,Ye,It,he,F,p]),_e=!!Tt.hasResolvedInteractionElement(d),de=!!d&&!_e,lr=t.useCallback(e=>{Wt(e)},[]),fe=t.useCallback(e=>{e&&Wt(e.shouldContinuePlayback)},[]);t.useEffect(()=>{Gt(ut)},[i,ut,Z]),t.useEffect(()=>{Z&&ft(!1)},[i,Z]),t.useEffect(()=>()=>{ue(),N(),q(),P(),_()},[ue,N,P,_,q]),t.useEffect(()=>{if(!Me){N();return}let e=!1,n=null,r=null;const s=()=>{r?.(),r=null},a=()=>{e||(s(),N(),ar(Et))},o=()=>{if(e)return;s();const y=Be.current?.querySelector('[data-active-step="true"]');if(!y)return;const x=Array.from(y.querySelectorAll("iframe"));if(x.length===0||Rn.areImageOnlyStepIframeVisualsReady(x)){a();return}const X=[],je=()=>{e||(n!==null&&window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{n=null,o()}))},Ct=(z,pe,$)=>{z.addEventListener(pe,$,{once:!0}),X.push(()=>z.removeEventListener(pe,$))};x.forEach(z=>{const pe=z.contentDocument;if(!pe||pe.readyState!=="complete"){Ct(z,"load",je);return}Array.from(pe.images).filter($=>!$.complete).forEach($=>{Ct($,"load",je),Ct($,"error",je)})}),r=()=>{X.forEach(z=>z())}};return n=window.requestAnimationFrame(()=>{n=null,o()}),Ke.current=window.setTimeout(()=>{a()},Rn.DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS),()=>{e=!0,s(),N(),n!==null&&window.cancelAnimationFrame(n)}},[N,A,i,Et,Me]),t.useEffect(()=>(at?.(E),()=>{at?.(!1)}),[at,E]),t.useEffect(()=>{E||(Ve.current=!1)},[E]),t.useEffect(()=>{j||$e===qe.DEFAULT_MOBILE_VIEW_MODE||(St(!1),xt(qe.DEFAULT_MOBILE_VIEW_MODE))},[j,$e]),t.useEffect(()=>{if(!j){Zt(!1);return}const e=()=>{Zt(tt.isLandscapeViewport()),G()},n=()=>{G()};e(),window.addEventListener("orientationchange",n),window.screen?.orientation?.addEventListener?.("change",n);const r=tt.subscribeMobileDeviceChange(e);return()=>{r(),window.removeEventListener("orientationchange",n),window.screen?.orientation?.removeEventListener?.("change",n)}},[j,G]),t.useEffect(()=>{jt?.(W)},[W,jt]),t.useEffect(()=>{tn.current!==W&&G(),tn.current=W},[W,G]),t.useEffect(()=>{qt?.(Re,i)},[i,Re,qt]),t.useEffect(()=>{const e=Kt.current,n=Nr.shouldAutoAdvanceIntoAppendedMarker({previousMarkerCount:e.markerCount,nextMarkerCount:R.length,previousIndex:e.currentIndex,previousCanGoNext:e.canGoNext,nextCanGoNext:C,currentAudioKey:g,hasCompletedCurrentStepAudio:T,hasResolvedCurrentInteraction:_e,currentStepHasSpeakableElement:S,currentInteractionElement:d,isAutoAdvanceEnabled:Ce,shouldUseSilentStepAutoAdvanceToggle:ke});Kt.current={markerCount:R.length,currentIndex:i,canGoNext:C},n&&M()},[C,g,i,d,S,M,T,_e,Ce,ke,R.length]),t.useEffect(()=>{if(!p||F==="hidden"){q(),Ae(!1);return}if(F==="visible"){q(),Ae(!0);return}Ye||m(!0)},[q,Ye,F,p,m]),t.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.origin===window.location.origin&&Tr.isSandboxInteractionMessage(n.data)&&n.data.eventType==="click"&&p&&(L(),se(!0),m(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[L,p,m]),qr.default({sectionRef:xe,enabled:p,keyboardShortcutsEnabled:te,onKeyboardShortcut:L,onWake:()=>{L(),se(!0),m(!0)}}),t.useEffect(()=>{if(!p){O();return}const{hasPlaybackContextChanged:e,shouldInitializeAudioSequence:n}=En.getPlaybackSequenceTransition({previousResetKey:Vt.current,nextResetKey:Te,currentAudioKey:g,hasCompletedCurrentStepAudio:T});Vt.current=Te;const r=Y.current===i&&!!d,s=nt.shouldPresentInteractionOverlay({hasInteraction:!!d,shouldBlockPlaybackForInteraction:de,shouldOpenInteractionOverlayAfterAudio:r,hasPlaybackContextChanged:e,hasResolvedCurrentInteraction:_e,currentStepHasSpeakableElement:S}),a=Ie.current,o=a?.slideIndex===i;if(e&&O({preservePendingSubtitleJump:o}),!(A.length===0&&!d)&&!J){if(a?.slideIndex===i&&Tt.canReachSubtitleJumpTarget({currentIndex:i,resolvedCurrentInteractionElement:f,slideElementList:R,targetSlideIndex:a.slideIndex})){Ie.current=null,it.current=!0,D(a.audioKey),Ze({audioIndex:a.audioIndex,timeMs:a.timeMs});return}if(d&&pt(d),s){mn(d);return}if(_(),Y.current=null,!!n&&!ce()){if(S){if(k){b(!1);return}b(!0);return}if(C&&!(ke&&!Ce)&&!(Me&&!pn))return Se.current=window.setTimeout(()=>{Se.current=null,M()},fn),()=>{ue()}}}},[f,C,ue,A.length,i,d,g,Te,S,Me,pn,fn,M,T,k,Ce,_e,de,_,O,Ze,mn,p,R,ce,J,ke]),t.useEffect(()=>{if(k||J||!S||de){b(!1);return}if(T){b(!1);return}if(ln){b(!1);return}ct("waitingForAudio"),b(!0)},[ln,S,T,k,J,de]),t.useEffect(()=>{T&&vn.hasUnplayedStepAudio(w,Ge.current)&&We(!1)},[w,T]),t.useEffect(()=>{const e=it.current;it.current=!1,En.shouldStartDefaultAudioSequence({currentAudioKey:g,currentAudioSequenceLength:w.length,currentStepHasSpeakableElement:S,hasCompletedCurrentStepAudio:T,shouldBlockPlaybackForInteraction:de,shouldPausePlaybackForCustomAction:J,shouldSkipDefaultAudioStart:e})&&ce()},[g,w,S,T,J,de,ce]),t.useEffect(()=>{!g||I>=0||D(null)},[I,g]),t.useEffect(()=>{I>=0||le.reset()},[I,le]),t.useEffect(()=>{Je(!1)},[or]);const{interactionDefaults:yn,interactionDefaultSelectedValues:ir,hasResolvedInteractionInput:hn,isInteractionReadonly:ur,shouldAutoContinueInteraction:xn}=t.useMemo(()=>Vr.resolveSlideInteractionState(f,{interactionDefaultValueOptions:De}),[f,De]),cr=!!f?.readonly||ur,Oe=nt.shouldRenderInteractionOverlay({hasActiveInteraction:!!f,isInteractionOverlayOpen:ae}),dr=t.useCallback(e=>{const r=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");pt(s=>!s||!r?s:{...s,user_input:r}),Ot?.(e,f),Pe()},[f,Pe,Ot]);t.useEffect(()=>{const e=()=>{Wn(document.fullscreenElement===xe.current)};return e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),t.useEffect(()=>{f&&ae||ze(!1)},[f,ae]),t.useEffect(()=>{G()},[f,G]),t.useEffect(()=>{if(!Oe){we(0);return}const e=ge.current;if(!e)return;const n=()=>{const s=Math.ceil(e.getBoundingClientRect().height);we(s+Xr)};if(n(),typeof ResizeObserver>"u")return;const r=new ResizeObserver(()=>{n()});return r.observe(e),()=>{r.disconnect()}},[Oe]),t.useEffect(()=>{if(P(),!!ae){if(xn)return H.current=window.setTimeout(()=>{H.current=null,Pe()},An),()=>{P()};if(!(zt||!hn))return H.current=window.setTimeout(()=>{H.current=null,Pe()},An),()=>{P()}}},[P,Pe,zt,hn,ae,xn]);const fr=(e,n={})=>e?e.type==="slot"?l.jsxRuntimeExports.jsx(l.jsxRuntimeExports.Fragment,{children:e.content}):e.type==="html"?l.jsxRuntimeExports.jsx(gn.default,{className:"content-render-iframe",disableLoadingOverlay:k,hideFullScreen:!0,locale:c,mode:"blackboard",replaceRootScreenHeightWithFull:n.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content,enableScaling:Mn}):l.jsxRuntimeExports.jsx(gn.default,{className:"content-render-iframe",disableLoadingOverlay:k,hideFullScreen:!0,locale:c,mode:"blackboard",type:"markdown",content:e.content}):null,pr=(e=[],n=!1)=>{if(e.length===0)return null;const r=e.filter(o=>o.is_renderable!==!1).length,s=n&&Pn?Dr.resolveMarkdownScalingMode(e):"disabled",a=e.reduce((o,y,x)=>y.is_renderable!==!1?x:o,-1);return l.jsxRuntimeExports.jsx(_r.default,{className:"slide-stage__content flex w-full flex-col gap-4",mode:s,children:e.map((o,y)=>{const x=o.type==="html"&&o.is_renderable===!1;return l.jsxRuntimeExports.jsx("div",{ref:n&&y===a?Dt:null,"aria-hidden":x||void 0,className:me.cn("w-full shrink-0",r===1&&o.is_renderable!==!1&&"slide-element--single",x?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":o.is_renderable===!1&&"hidden"),children:fr(o,{replaceRootScreenHeightWithFull:r===1&&o.type==="html"&&o.is_renderable!==!1})},o.sequence_number??`${o.type}-${y}`)})})},mr=t.useCallback(()=>{const e=xe.current;if(e){if(document.fullscreenElement===e){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},[]),Sn=t.useCallback(()=>{const e=Be.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),Rt=t.useCallback(e=>Tt.canReachSubtitleJumpTarget({currentIndex:i,resolvedCurrentInteractionElement:f,slideElementList:R,targetSlideIndex:Ue[e.audioIndex]}),[f,Ue,i,R]),yr=t.useCallback((e,n)=>{const s=h[e.audioIndex]?.audioKey,a=Ue[e.audioIndex];return!s||a==null||!Rt(e)?!1:(fe(n),Y.current=null,b(!1),We(!1),Je(!1),wt.shouldWakePlayerControlsAfterNavigation(n)&&(se(!0),m(!0)),a===i?(Ie.current=null,O(),D(s),Ze(e),!0):(Ee.current=!0,O(),Ie.current={audioIndex:e.audioIndex,audioKey:s,slideIndex:a,timeMs:e.timeMs},Yt(a),!0))},[h,Ue,Rt,i,Yt,Ze,O,m,fe]),hr=t.useCallback(e=>{fe(e),Ee.current=!0,Y.current=null,b(!1),wt.shouldWakePlayerControlsAfterNavigation(e)&&(se(!0),m(!0)),O(),Ht()},[Ht,O,m,fe]),xr=t.useCallback(e=>{fe(e),Ee.current=!0,Y.current=null,b(!1),wt.shouldWakePlayerControlsAfterNavigation(e)&&(se(!0),m(!0)),O(),M()},[M,O,m,fe]),Sr=t.useCallback(({loading:e,reason:n})=>{if(k){b(!1);return}if(!S||T){b(!1);return}e&&n&&ct(n),b(to(n,e))},[S,T,k]);t.useEffect(()=>{k&&b(!1)},[k]);const br=t.useCallback(e=>{const n=h[e]?.audioKey;if(!n||!g||n!==g)return;Ge.current.add(n);const r=w.findIndex(o=>o===n);if(r<0){D(null);return}const s=r+1,a=w[s];if(a){D(a);return}if(D(null),We(!0),b(!1),C){const o=i+1,y=R[o];cn&&y?.type==="interaction"&&(Y.current=o),M();return}},[h,C,i,g,w,M,cn,R]),gr=t.useCallback(()=>{f&&Xe(e=>!e)},[f]),vr=t.useCallback(()=>{Ve.current=!0,q(),p&&Ae(!0)},[q,p]),Er=t.useCallback(()=>{Ve.current=!1,m(!0)},[m]),At=t.useCallback(e=>{e.stopPropagation(),E&&m(!0)},[E,m]),et=t.useCallback((e,n)=>{const r=lt.current;if(!r)return null;const s=e.getBoundingClientRect(),a=r.getBoundingClientRect();return{minX:n.x+a.left-s.left,maxX:n.x+a.right-s.right,minY:n.y+a.top-s.top,maxY:n.y+a.bottom-s.bottom}},[]);zr(()=>{const e=ge.current;if(!Oe||!e){re.current=null;return}const n=re.current,r=e.getBoundingClientRect();if(!n||yt){re.current={left:r.left,top:r.top};return}const s=n.left-r.left,a=n.top-r.top;if(!Cn(s)&&!Cn(a)){re.current={left:r.left,top:r.top};return}const o={x:v.x+s,y:v.y+a},y=et(e,v),x=Qr(y?nt.clampInteractionOverlayDragOffset(o,y):o);re.current={left:r.left+x.x-v.x,top:r.top+x.y-v.y},wn(x,v)||mt(X=>wn(X,x)?X:x)},[et,v,yt,E,p,Oe]);const Ir=t.useCallback(e=>{if(At(e),e.button!==0||!e.currentTarget.isConnected||!ge.current)return;const n=et(ge.current,v);n&&(e.preventDefault(),e.currentTarget.hasPointerCapture?.(e.pointerId)!==!0&&e.currentTarget.setPointerCapture(e.pointerId),ve.current={pointerId:e.pointerId,startClientX:e.clientX,startClientY:e.clientY,startOffset:v,bounds:n},ht(!0))},[et,v,At]),Rr=t.useCallback(e=>{const n=ve.current;!n||n.pointerId!==e.pointerId||(e.preventDefault(),e.stopPropagation(),mt(nt.clampInteractionOverlayDragOffset({x:n.startOffset.x+e.clientX-n.startClientX,y:n.startOffset.y+e.clientY-n.startClientY},n.bounds)))},[]),bn=t.useCallback(e=>{const n=ve.current;!n||n.pointerId!==e.pointerId||(e.stopPropagation(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),ve.current=null,ht(!1))},[]),Ar=t.useCallback(e=>{L(),Ft?.(e)},[L,Ft]),Cr=t.useCallback(e=>{L(),Lt?.(e)},[L,Lt]),wr=t.useCallback(()=>{se(!0),m(!0)},[m]);return t.useEffect(()=>{const e=Nt.current,s=(e.length>0&&e.length<oe.length&&e.every((o,y)=>o===oe[y])?A.slice(e.length):[]).some(o=>o.is_new===!1);if(Nt.current=oe,!s)return;const a=window.requestAnimationFrame(()=>{const o=Be.current,y=Dt.current;if(!o||!y)return;const x=o.getBoundingClientRect(),X=y.getBoundingClientRect(),je=o.scrollTop+(X.top-x.top);o.scrollTo({top:Math.max(je,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(a)}},[A,oe]),t.useEffect(()=>{if(!Ee.current||(Ee.current=!1,A.length===0))return;const e=window.requestAnimationFrame(()=>{Sn()});return()=>{window.cancelAnimationFrame(e)}},[A,Sn]),l.jsxRuntimeExports.jsxs("section",{ref:xe,className:me.cn("relative h-full w-full",j&&"slide--mobile-device",nn&&"slide--browser-fullscreen",ie&&"slide--mobile-landscape",en&&"slide--mobile-landscape-native",_n),onClick:wr,onFocusCapture:Cr,onPointerDown:Ar,...On,children:[$n?l.jsxRuntimeExports.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]"}):null,l.jsxRuntimeExports.jsxs("div",{ref:lt,className:me.cn("slide__viewport relative h-full min-h-0 w-full",ie&&"slide__viewport--mobile-landscape",ie&&!Jn&&"slide__viewport--mobile-landscape-native"),children:[Xn?l.jsxRuntimeExports.jsxs("div",{className:"slide-landscape-header",children:[l.jsxRuntimeExports.jsx("button",{"aria-label":K?.backAriaLabel??U.fullscreenBackAriaLabel,className:"slide-landscape-header__back",onClick:Zn,type:"button",children:l.jsxRuntimeExports.jsx(Yr.default,{className:"slide-landscape-header__icon h-6 w-6",strokeWidth:2.25})}),K?.content?l.jsxRuntimeExports.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:K.content}):null]}):null,l.jsxRuntimeExports.jsx("div",{className:me.cn("h-full min-h-0 w-full",zn&&"slide__viewport-content--with-header",Ln?"slide-content--single":"grid gap-4"),children:A.length>0?l.jsxRuntimeExports.jsx("div",{className:"slide-stage",children:l.jsxRuntimeExports.jsx("div",{ref:Be,className:"slide-stage__layer w-full",children:er.map((e,n)=>{const r=n===tr;return l.jsxRuntimeExports.jsx("div",{"data-active-step":r?"true":void 0,"aria-hidden":!r||void 0,className:"w-full h-full",style:{display:r?void 0:"none"},children:pr(e.elementList,r)},e.sourceStepIndexes[0]??n)})})}):null}),Vn?l.jsxRuntimeExports.jsx(kr.default,{message:Zr(jn,Kn),className:"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2"}):null,l.jsxRuntimeExports.jsx(Or.default,{extraBottomOffset:Yn,hasPlayerGap:E,isEnabled:Xt&&Un,isPlayerHidden:p&&!E,playbackTimeStore:le,subtitleCues:nr}),Oe?l.jsxRuntimeExports.jsx("div",{ref:ge,"data-player-keyboard-shortcuts-ignore":"true",className:me.cn("slide-interaction-overlay",E&&p?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone",yt&&"slide-interaction-overlay--dragging"),onClick:At,onPointerDownCapture:e=>{Mt(e.target)&&ze(!0)},onFocusCapture:e=>{Mt(e.target)&&ze(!0)},onInputCapture:e=>{Mt(e.target)&&ze(!0)},style:rr,children:l.jsxRuntimeExports.jsx(kn,{content:String(f?.content??""),locale:c,defaultButtonText:yn.buttonText??"",defaultInputText:yn.inputText??"",defaultSelectedValues:ir,confirmButtonText:ee?.confirmButtonText??U.interactionTexts.confirmButtonText,copyButtonText:ee?.copyButtonText??U.interactionTexts.copyButtonText,copiedButtonText:ee?.copiedButtonText??U.interactionTexts.copiedButtonText,onSend:dr,onDragHandlePointerCancel:bn,onDragHandlePointerDown:Ir,onDragHandlePointerMove:Rr,onDragHandlePointerUp:bn,readonly:cr,title:ee?.title??ot??U.interactionTexts.title})}):null,p?l.jsxRuntimeExports.jsx(Fr.PlayerKeyboardShortcutContext.Provider,{value:Dn,children:l.jsxRuntimeExports.jsx(Pr.default,{audioList:h,className:me.cn("absolute left-1/2 z-[2] -translate-x-1/2",nn?"bottom-3":"-bottom-3",V,!E&&"pointer-events-none opacity-0"),currentAudioIndex:I,defaultPlaying:ut,enableKeyboardShortcuts:te,isPlaybackPaused:J,isAutoAdvanceEnabled:Ce,locale:c,hasInteraction:!!f,isInteractionOpen:ae,isSubtitleEnabled:Xt,onAutoAdvanceToggle:Gt,onLoadingChange:Sr,onPlaybackStarted:()=>{Je(!0)},onPlaybackPreferenceChange:lr,onPlaybackTimeChange:le.setTime,onSubtitleToggle:()=>{Hn(e=>!e)},nextDisabled:!C,onEnded:br,onFullscreen:mr,isFullscreen:$t,mobileViewMode:W,settingsPortalContainer:lt.current,onMobileViewModeChange:Qn,onControlsPointerEnter:vr,onControlsPointerLeave:Er,onInteractionToggle:gr,onNext:xr,onPrev:hr,onSubtitleJump:yr,canJumpToSubtitleTarget:Rt,prevDisabled:!Fn,showControls:E,subtitleSeekRequest:Bn,texts:st,customActionContext:gt,customActions:Q,useAutoAdvanceToggle:ke})}):null]})]})};exports.default=ro;
2
2
  //# sourceMappingURL=Slide.cjs.js.map