markdown-flow-ui 0.1.116 → 0.1.117

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 (62) hide show
  1. package/dist/_virtual/index.cjs10.js +1 -1
  2. package/dist/_virtual/index.cjs4.js +1 -1
  3. package/dist/_virtual/index.cjs5.js +1 -1
  4. package/dist/_virtual/index.cjs6.js +1 -1
  5. package/dist/_virtual/index.cjs7.js +1 -1
  6. package/dist/_virtual/index.cjs8.js +1 -1
  7. package/dist/_virtual/index.cjs9.js +1 -1
  8. package/dist/_virtual/index.es10.js +2 -2
  9. package/dist/_virtual/index.es4.js +5 -5
  10. package/dist/_virtual/index.es5.js +4 -4
  11. package/dist/_virtual/index.es6.js +2 -5
  12. package/dist/_virtual/index.es6.js.map +1 -1
  13. package/dist/_virtual/index.es7.js +5 -2
  14. package/dist/_virtual/index.es7.js.map +1 -1
  15. package/dist/_virtual/index.es8.js +3 -2
  16. package/dist/_virtual/index.es8.js.map +1 -1
  17. package/dist/_virtual/index.es9.js +2 -3
  18. package/dist/_virtual/index.es9.js.map +1 -1
  19. package/dist/components/Slide/Player.cjs.js +1 -1
  20. package/dist/components/Slide/Player.cjs.js.map +1 -1
  21. package/dist/components/Slide/Player.es.js +330 -326
  22. package/dist/components/Slide/Player.es.js.map +1 -1
  23. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  24. package/dist/components/Slide/Slide.es.js.map +1 -1
  25. package/dist/components/Slide/utils/playbackSource.cjs.js +2 -0
  26. package/dist/components/Slide/utils/playbackSource.cjs.js.map +1 -0
  27. package/dist/components/Slide/utils/playbackSource.d.ts +9 -0
  28. package/dist/components/Slide/utils/playbackSource.es.js +14 -0
  29. package/dist/components/Slide/utils/playbackSource.es.js.map +1 -0
  30. package/dist/components/Slide/utils/playbackSource.test.d.ts +1 -0
  31. package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
  32. package/dist/components/ui/inputGroup/textarea.es.js +1 -1
  33. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
  34. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js.map +1 -1
  35. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
  36. package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
  37. package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js +1 -1
  38. package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.cjs.js +1 -1
  39. package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
  40. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js +1 -1
  41. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.es.js +1 -1
  42. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js +1 -1
  43. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.es.js +1 -1
  44. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js +1 -1
  45. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.es.js +1 -1
  46. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js +1 -1
  47. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.es.js +1 -1
  48. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js +1 -1
  49. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.es.js +1 -1
  50. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
  51. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
  52. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
  53. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
  54. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
  55. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
  56. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
  57. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
  58. package/dist/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.cjs.js +1 -1
  59. package/dist/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.es.js +1 -1
  60. package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
  61. package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
  62. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={};exports.__exports=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
2
2
  //# sourceMappingURL=index.cjs10.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),r=require("../markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js");var s=r.__require();const t=e.getDefaultExportFromCjs(s);exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),t=require("../markdown-flow-ui/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.cjs.js");var r=t.__require();const o=e.getDefaultExportFromCjs(r);exports.default=o;
2
2
  //# sourceMappingURL=index.cjs4.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),t=require("../markdown-flow-ui/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.cjs.js");var r=t.__require();const o=e.getDefaultExportFromCjs(r);exports.default=o;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),r=require("../markdown-flow-ui/node_modules/.pnpm/style-to-js@1.1.18/node_modules/style-to-js/cjs/index.cjs.js");var t=r.__require();const o=e.getDefaultExportFromCjs(t);exports.default=o;
2
2
  //# sourceMappingURL=index.cjs5.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),r=require("../markdown-flow-ui/node_modules/.pnpm/style-to-js@1.1.18/node_modules/style-to-js/cjs/index.cjs.js");var t=r.__require();const o=e.getDefaultExportFromCjs(t);exports.default=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={};exports.__exports=e;
2
2
  //# sourceMappingURL=index.cjs6.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={};exports.__exports=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs.js"),r=require("../markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js");var s=r.__require();const t=e.getDefaultExportFromCjs(s);exports.default=t;
2
2
  //# sourceMappingURL=index.cjs7.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js");var r=e.__require();exports.distExports=r;
2
2
  //# sourceMappingURL=index.cjs8.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js");var r=e.__require();exports.distExports=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={};exports.__exports=e;
2
2
  //# sourceMappingURL=index.cjs9.js.map
@@ -1,5 +1,5 @@
1
- var r = {};
1
+ var s = { exports: {} };
2
2
  export {
3
- r as __exports
3
+ s as __module
4
4
  };
5
5
  //# sourceMappingURL=index.es10.js.map
@@ -1,8 +1,8 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
2
- import { __require as s } from "../markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js";
3
- var e = s();
4
- const t = /* @__PURE__ */ r(e);
1
+ import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.es.js";
2
+ import { __require as r } from "../markdown-flow-ui/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.es.js";
3
+ var t = r();
4
+ const a = /* @__PURE__ */ e(t);
5
5
  export {
6
- t as default
6
+ a as default
7
7
  };
8
8
  //# sourceMappingURL=index.es4.js.map
@@ -1,7 +1,7 @@
1
- import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.es.js";
2
- import { __require as r } from "../markdown-flow-ui/node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.es.js";
3
- var t = r();
4
- const a = /* @__PURE__ */ e(t);
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
2
+ import { __require as o } from "../markdown-flow-ui/node_modules/.pnpm/style-to-js@1.1.18/node_modules/style-to-js/cjs/index.es.js";
3
+ var t = o();
4
+ const a = /* @__PURE__ */ r(t);
5
5
  export {
6
6
  a as default
7
7
  };
@@ -1,8 +1,5 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
2
- import { __require as o } from "../markdown-flow-ui/node_modules/.pnpm/style-to-js@1.1.18/node_modules/style-to-js/cjs/index.es.js";
3
- var t = o();
4
- const a = /* @__PURE__ */ r(t);
1
+ var r = {};
5
2
  export {
6
- a as default
3
+ r as __exports
7
4
  };
8
5
  //# sourceMappingURL=index.es6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +1,8 @@
1
- var r = {};
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
2
+ import { __require as s } from "../markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js";
3
+ var e = s();
4
+ const t = /* @__PURE__ */ r(e);
2
5
  export {
3
- r as __exports
6
+ t as default
4
7
  };
5
8
  //# sourceMappingURL=index.es7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,5 +1,6 @@
1
- var s = { exports: {} };
1
+ import { __require as r } from "../markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js";
2
+ var i = r();
2
3
  export {
3
- s as __module
4
+ i as d
4
5
  };
5
6
  //# sourceMappingURL=index.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.es8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,6 +1,5 @@
1
- import { __require as r } from "../markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js";
2
- var i = r();
1
+ var r = {};
3
2
  export {
4
- i as d
3
+ r as __exports
5
4
  };
6
5
  //# sourceMappingURL=index.es9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es9.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index.es9.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../../_virtual/jsx-runtime.cjs.js"),r=require("react"),je=require("../../lib/utils.cjs.js"),Je=require("./MobilePlayerSettingsSheet.cjs.js"),Qe=require("./constants.cjs.js"),Ie=require("./utils/mobileScreenMode.cjs.js"),er=require("./utils/audioCompletion.cjs.js"),rr=require("./utils/playerCustomActions.cjs.js");;/* empty css */const tr=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.cjs.js"),nr=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.cjs.js"),sr=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/captions.cjs.js"),ur=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/captions-off.cjs.js"),lr=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js"),ar=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js"),cr=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/scan-line.cjs.js"),ir=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.cjs.js"),or=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.cjs.js"),ke=new Map,Se=w=>{if(typeof window>"u"||!w||ke.has(w))return;const T=window.document.createElement("audio");T.preload="auto",T.setAttribute("playsinline","true"),T.src=w,T.load(),ke.set(w,T)},fr=()=>n.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"34",height:"34",viewBox:"0 0 34 34",fill:"none",children:[n.jsxRuntimeExports.jsx("path",{d:"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z",fill:"#0A0A0A"}),n.jsxRuntimeExports.jsx("path",{d:"M12 10H16V24H12V10ZM18 10H22V24H18V10Z",fill:"white"})]}),dr=()=>n.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"34",height:"34",viewBox:"0 0 34 34",fill:"none",children:[n.jsxRuntimeExports.jsx("path",{d:"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z",fill:"#0A0A0A"}),n.jsxRuntimeExports.jsx("path",{d:"M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z",fill:"white"})]}),mr=({audioList:w=[],className:T,currentAudioIndex:d=-1,defaultPlaying:E=!0,isPlaybackPaused:v=!1,isAutoAdvanceEnabled:D=!0,useAutoAdvanceToggle:X=!1,onLoadingChange:ee,onPlaybackStarted:re,onPlaybackTimeChange:Z,onSubtitleToggle:te,onPrev:we,onNext:Me,onFullscreen:ne,isFullscreen:se=!1,mobileViewMode:Ae=Ie.DEFAULT_MOBILE_VIEW_MODE,settingsPortalContainer:Ne,onMobileViewModeChange:ue,onEnded:le,onAutoAdvanceToggle:Te,onInteractionToggle:ve,hasInteraction:Le=!1,isInteractionOpen:B=!1,isSubtitleEnabled:Y=!0,prevDisabled:qe=!1,nextDisabled:Fe=!1,showControls:G=!0,customActions:ae,customActionContext:ce,texts:ie,...Ue})=>{const m=r.useRef(null),oe=r.useRef(B),_=r.useRef(null),fe=r.useRef(null),y=r.useRef(0),a=r.useRef(null),$=r.useRef(void 0),j=r.useRef([]),K=r.useRef(!1),de=r.useRef(!1),x=r.useRef(!1),M=r.useRef(null),h=r.useRef(!1),u=r.useRef(!1),p=r.useRef(null),R=r.useRef(!1),L=r.useRef(null),J=r.useRef(0),A=r.useRef("unknown"),[Q,c]=r.useState(E),[me,W]=r.useState(!1),o=d>=0?w[d]:void 0,P=o?.audioUrl,k=r.useMemo(()=>[...o?.audioSegments??[]].sort((e,t)=>e.segment_index-t.segment_index),[o?.audioSegments]),pe=r.useMemo(()=>rr.toPlayerCustomActionList(ae,ce),[ce,ae]),xe=pe.length+5,We=r.useMemo(()=>({"--slide-player-mobile-control-count":String(xe)}),[xe]),q=r.useMemo(()=>({...Qe.DEFAULT_SLIDE_PLAYER_TEXTS,...ie}),[ie]),I=r.useMemo(()=>o?o.audioKey??`${String(o.sequenceNumber??"none")}:${String(o.audioUrl??"")}`:"none",[o]),Pe=X?D:Q,Ve=X?D?"Pause autoplay":"Play autoplay":Q?"Pause":"Play";r.useEffect(()=>{$.current=o},[o]),r.useEffect(()=>{G||W(!1)},[G]),r.useEffect(()=>{!oe.current&&B&&W(!1),oe.current=B},[B]),r.useEffect(()=>{j.current=k},[k]),r.useEffect(()=>{const e=o?.audioUrl,t=d>=0?w[d+1]?.audioUrl:void 0;Se(e),Se(t)},[w,o?.audioUrl,d]);const s=r.useCallback((e,t=null)=>{de.current===e&&(!e||t===null)||(de.current=e,ee?.({loading:e,reason:e?t:null}))},[ee]),he=r.useCallback(e=>e instanceof DOMException?e.name==="NotAllowedError"||e.name==="SecurityError":!1,[]),N=r.useCallback(()=>E&&!v&&!x.current&&A.current!=="blocked",[E,v]),be=r.useCallback(e=>e?e.startsWith("data:")?e:`data:audio/mpeg;base64,${e}`:"",[]),ge=r.useCallback(()=>{const e=a.current;return e==null||e<=0?0:j.current.slice(0,e).reduce((t,l)=>t+Math.max(Number(l.duration_ms??0),0),0)/1e3},[]),F=r.useCallback(e=>e<=0?0:j.current.slice(0,e).reduce((t,l)=>t+Math.max(Number(l.duration_ms??0),0),0),[]),ye=r.useCallback(()=>{const e=m.current;return e?M.current==="segment"?F(y.current)+Math.max(e.currentTime,0)*1e3:p.current!==null&&e.readyState===0?p.current*1e3:Math.max(e.currentTime,0)*1e3:a.current!=null?F(a.current):0},[F]),b=r.useCallback(e=>{const t=Math.max(e,0);J.current!==t&&(J.current=t,Z?.(t))},[Z]),i=r.useCallback(()=>{b(ye())},[ye,b]),f=r.useCallback(()=>{typeof window>"u"||L.current===null||(window.cancelAnimationFrame(L.current),L.current=null)},[]),Re=r.useCallback(()=>{if(typeof window>"u"||L.current!==null)return;const e=()=>{i();const t=m.current;if(!t||t.paused||t.ended){L.current=null;return}L.current=window.requestAnimationFrame(e)};L.current=window.requestAnimationFrame(e)},[i]),O=r.useCallback(()=>{const e=m.current;e&&(f(),u.current=!1,x.current=!1,K.current=!1,M.current=null,p.current=null,h.current=!1,R.current=!1,e.pause(),e.removeAttribute("src"),e.load(),_.current=null,y.current=0,a.current=null,b(0),c(!1),s(!1))},[b,f,s]),g=r.useCallback(e=>{const t=m.current;if(!t)return!1;const l=t.play();return l&&typeof l.then=="function"&&l.then(()=>{A.current==="unknown"&&(A.current="auto"),u.current=!1,R.current=!1}).catch(U=>{A.current==="unknown"&&he(U)&&(A.current="blocked",u.current=!1,s(!1)),R.current=!1,c(!1)}),!0},[he,s]),S=r.useCallback((e,t)=>{const l=m.current,U=j.current[e];if(!l||!U)return!1;const C=be(U.audio_data);y.current=e,a.current=null,h.current=!1,R.current=!0,b(F(e));const z=N();u.current=z,s(!1);const Ge=_.current!==C;return M.current="segment",Ge&&(l.pause(),l.removeAttribute("src"),l.load(),_.current=C,l.src=C,l.load()),p.current=0,l.readyState>0&&(l.currentTime=0,p.current=null),z?g(`start-segment:${t}`):(u.current=!1,R.current=!1,l.pause(),c(!1),!0)},[N,be,F,b,g,s]),V=r.useCallback(e=>{f(),u.current=!1,h.current=!1,R.current=!1,i(),c(!1),s(!1),d>=0&&le?.(d)},[d,le,f,i,s]),H=r.useCallback(e=>{const t=m.current;return!t||M.current!=="url"||!er.hasReachedAudioEnd({currentTimeSeconds:Math.max(t.currentTime,0),durationSeconds:t.duration})?!1:(u.current=!1,t.pause(),V(e),!0)},[V]),Ee=r.useCallback(()=>{const e=y.current+1,t=j.current,l=t[e],U=$.current,C=t.some(z=>z.is_final);if(l){S(e,"ended");return}if(U?.isAudioStreaming||!C){y.current=e,a.current=e,h.current=!0,u.current=E,b(F(e)),c(!1),s(!0,"waitingForMoreAudio");return}V("segments-completed")},[E,V,F,b,S,s]);r.useEffect(()=>{if(fe.current===I)return;fe.current=I,y.current=0,a.current=null,h.current=!1,x.current=!1,K.current=!1,u.current=!1,R.current=!1,M.current=null,_.current=null,f(),b(0),s(!1);const e=m.current;e&&(e.pause(),e.removeAttribute("src"),e.load(),c(!1))},[d,I,k.length,P,b,f,s]),r.useEffect(()=>{const e=m.current;if(e){if(v){K.current=!!($.current&&!x.current&&(!e.paused||u.current||a.current!==null)),u.current=!1,s(!1),e.pause(),c(!1);return}if(!(!K.current||!$.current||x.current)){if(K.current=!1,a.current!==null){if(a.current<j.current.length){S(a.current,"external-resume");return}u.current=!0,s(!0,"waitingForMoreAudio");return}if(!_.current&&j.current.length>0){S(Math.min(y.current,j.current.length-1),"external-resume-init");return}e.paused&&(u.current=!0,g("external-resume"))}}},[v,S,g,s]),r.useEffect(()=>{const e=m.current;if(e){if(!o){O();return}if(v){u.current=!1,s(!1),e.pause(),c(!1);return}if(P){const t=_.current!==P,l=N();if(M.current==="segment"&&!!_.current&&a.current===null){if(!l){u.current=!1,e.pause(),c(!1);return}e.paused&&(u.current=!0,g("keep-segment-source"));return}if(t){const C=a.current!==null?ge():0;e.pause(),e.removeAttribute("src"),e.load(),_.current=P,M.current="url",e.src=P,e.load(),p.current=C,b(C*1e3),e.readyState>0&&(e.currentTime=C,p.current=null)}if(u.current=l,h.current=!1,R.current=!1,s(!1),!l){u.current=!1,e.pause(),c(!1);return}g(t?"sync-url-init":"sync-url");return}if(a.current!==null){if(a.current<k.length){if(x.current){c(!1),s(!1);return}S(a.current,"wait-resume");return}h.current=!0,u.current=N(),c(!1),s(N());return}if(!k.length){if(o.isAudioStreaming){a.current=y.current,h.current=!0,u.current=N(),c(!1),s(N());return}O();return}if(!_.current){S(Math.min(y.current,k.length-1),"effect-init");return}if(!E||x.current){u.current=!1,e.pause(),c(!1);return}e.paused&&(u.current=!0,g("sync-paused-retry"))}},[o,d,k,P,E,v,N,b,O,S,g,ge,s]),r.useEffect(()=>O,[O]),r.useEffect(()=>f,[f]);const Be=r.useCallback(()=>{i(),Re(),c(!0),s(!1),re?.()},[re,Re,i,s]),Ke=r.useCallback(()=>{h.current||R.current||(f(),i(),c(!1))},[d,f,i]),Oe=r.useCallback(()=>{const e=m.current;e&&p.current!==null&&(e.currentTime=p.current,p.current=null),i(),!H("canplay-seek-finished")&&(!u.current||!E||g("canplay"))},[d,E,H,i,g]),Ze=r.useCallback(()=>{const e=m.current;e&&p.current!==null&&(e.currentTime=p.current,p.current=null),i(),H("metadata-seek-finished")},[d,H,i]),$e=r.useCallback(()=>{i()},[i]),He=r.useCallback(()=>{h.current||s(!0,"loadingAudio")},[s]),ze=r.useCallback(()=>{if(h.current){s(!0,"waitingForMoreAudio");return}s(!0,"loadingAudio")},[s]),_e=r.useCallback(()=>{i()},[i]),De=r.useCallback(()=>{const e=M.current==="url"||j.current.length===0;if(f(),R.current=!1,e){V("url-ended");return}Ee()},[V,Ee,f]),Xe=r.useCallback(()=>{f(),i(),c(!1),s(!1)},[f,i,s]),Ye=r.useCallback(e=>{ue?.(e),W(!1)},[ue]);return r.useEffect(()=>{Z?.(J.current)},[Z]),n.jsxRuntimeExports.jsxs("div",{className:je.cn("slide-player",T),...Ue,children:[n.jsxRuntimeExports.jsx("audio",{ref:m,preload:"auto",playsInline:!0,onLoadStart:He,onLoadedMetadata:Ze,onCanPlay:Oe,onPlay:Be,onPause:Ke,onWaiting:ze,onSeeking:_e,onSeeked:_e,onTimeUpdate:$e,onEnded:De,onError:Xe}),G?n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[n.jsxRuntimeExports.jsx(Je.default,{container:Ne,labels:{fullscreen:q.fullscreenLabel,nonFullscreen:q.nonFullscreenLabel,screen:q.screenLabel,subtitle:q.subtitleLabel,subtitleToggle:q.subtitleToggleAriaLabel,title:q.settingsTitle},isSubtitleEnabled:Y,onClose:()=>W(!1),onOpenChange:W,onSubtitleToggle:te??(()=>{}),onViewModeChange:Ye,open:me,viewMode:Ae}),n.jsxRuntimeExports.jsxs("div",{className:"slide-player__controls",style:We,children:[n.jsxRuntimeExports.jsxs("div",{className:"slide-player__group",children:[n.jsxRuntimeExports.jsx("button",{"aria-expanded":me,"aria-haspopup":"dialog","aria-label":"More options",className:"slide-player__action slide-player__action--mobile-more",onClick:()=>{W(e=>!e)},type:"button",children:n.jsxRuntimeExports.jsx(tr.default,{className:"slide-player__icon",strokeWidth:2.25})}),n.jsxRuntimeExports.jsx("button",{"aria-label":"Volume",className:"hidden",type:"button",children:n.jsxRuntimeExports.jsx(nr.default,{className:"slide-player__icon",strokeWidth:2.25})}),n.jsxRuntimeExports.jsx("button",{"aria-label":q.subtitleToggleAriaLabel,"aria-pressed":Y,className:"slide-player__action slide-player__action--subtitle",onClick:te,type:"button",children:Y?n.jsxRuntimeExports.jsx(sr.default,{className:"slide-player__icon",strokeWidth:2.25}):n.jsxRuntimeExports.jsx(ur.default,{className:"slide-player__icon",strokeWidth:2.25})}),n.jsxRuntimeExports.jsx("button",{"aria-label":"Rewind",className:"slide-player__action slide-player__action--prev",disabled:qe,onClick:we,type:"button",children:n.jsxRuntimeExports.jsx(lr.default,{className:"slide-player__icon",strokeWidth:2.25})}),n.jsxRuntimeExports.jsx("button",{"aria-label":Ve,className:"slide-player__toggle slide-player__toggle--playback",onClick:()=>{if(X){Te?.(!D);return}const e=m.current;if(!(v||!e||!o)){if(a.current!==null){if(Q){u.current=!1,x.current=!0,a.current=null,h.current=!1,c(!1),s(!1),e.pause();return}A.current="manual",x.current=!1,u.current=!0,s(!0,"waitingForMoreAudio");return}if(!e.src&&k.length>0){A.current="manual",x.current=!1,S(Math.min(y.current,k.length-1),"toggle");return}if(e.paused){A.current="manual",x.current=!1,u.current=!0,g("toggle-resume");return}u.current=!1,x.current=!0,e.pause()}},type:"button",children:Pe?n.jsxRuntimeExports.jsx(fr,{}):n.jsxRuntimeExports.jsx(dr,{})}),n.jsxRuntimeExports.jsx("button",{"aria-label":"Forward",className:"slide-player__action slide-player__action--next",disabled:Fe,onClick:Me,type:"button",children:n.jsxRuntimeExports.jsx(ar.default,{className:"slide-player__icon",strokeWidth:2.25})}),ne?n.jsxRuntimeExports.jsx("button",{"aria-label":se?"Exit fullscreen":"Enter fullscreen",className:"slide-player__action slide-player__action--fullscreen",onClick:ne,type:"button",children:se?n.jsxRuntimeExports.jsx(cr.default,{className:"slide-player__icon",strokeWidth:2.25}):n.jsxRuntimeExports.jsx(ir.default,{className:"slide-player__icon",strokeWidth:2.25})}):null]}),n.jsxRuntimeExports.jsx("div",{className:"slide-player__separator"}),n.jsxRuntimeExports.jsxs("div",{className:"slide-player__group",children:[pe.map((e,t)=>n.jsxRuntimeExports.jsx(r.Fragment,{children:e},`custom-action-${t}`)),n.jsxRuntimeExports.jsx("button",{"aria-label":"Notes",className:je.cn("slide-player__action slide-player__action--notes",B&&"slide-player__action--active"),disabled:!Le,onClick:ve,type:"button",children:n.jsxRuntimeExports.jsx(or.default,{className:"slide-player__icon",strokeWidth:2.25})})]})]})]}):null]})},Ce=r.memo(mr);Ce.displayName="Player";exports.default=Ce;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../../_virtual/jsx-runtime.cjs.js"),r=require("react"),ke=require("../../lib/utils.cjs.js"),Qe=require("./MobilePlayerSettingsSheet.cjs.js"),Ie=require("./constants.cjs.js"),er=require("./utils/mobileScreenMode.cjs.js"),rr=require("./utils/audioCompletion.cjs.js"),tr=require("./utils/playbackSource.cjs.js"),nr=require("./utils/playerCustomActions.cjs.js");;/* empty css */const sr=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.cjs.js"),ur=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.cjs.js"),lr=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/captions.cjs.js"),ar=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/captions-off.cjs.js"),cr=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js"),ir=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js"),or=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/scan-line.cjs.js"),fr=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.cjs.js"),dr=require("../../markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.cjs.js"),Se=new Map,Ce=w=>{if(typeof window>"u"||!w||Se.has(w))return;const v=window.document.createElement("audio");v.preload="auto",v.setAttribute("playsinline","true"),v.src=w,v.load(),Se.set(w,v)},mr=()=>n.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"34",height:"34",viewBox:"0 0 34 34",fill:"none",children:[n.jsxRuntimeExports.jsx("path",{d:"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z",fill:"#0A0A0A"}),n.jsxRuntimeExports.jsx("path",{d:"M12 10H16V24H12V10ZM18 10H22V24H18V10Z",fill:"white"})]}),pr=()=>n.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"34",height:"34",viewBox:"0 0 34 34",fill:"none",children:[n.jsxRuntimeExports.jsx("path",{d:"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z",fill:"#0A0A0A"}),n.jsxRuntimeExports.jsx("path",{d:"M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z",fill:"white"})]}),xr=({audioList:w=[],className:v,currentAudioIndex:d=-1,defaultPlaying:_=!0,isPlaybackPaused:L=!1,isAutoAdvanceEnabled:X=!0,useAutoAdvanceToggle:Y=!1,onLoadingChange:re,onPlaybackStarted:te,onPlaybackTimeChange:H,onSubtitleToggle:ne,onPrev:Me,onNext:Ae,onFullscreen:se,isFullscreen:ue=!1,mobileViewMode:Te=er.DEFAULT_MOBILE_VIEW_MODE,settingsPortalContainer:Ne,onMobileViewModeChange:le,onEnded:ae,onAutoAdvanceToggle:ve,onInteractionToggle:Le,hasInteraction:qe=!1,isInteractionOpen:Z=!1,isSubtitleEnabled:G=!0,prevDisabled:Fe=!1,nextDisabled:Ue=!1,showControls:J=!0,customActions:ce,customActionContext:ie,texts:oe,...Pe})=>{const m=r.useRef(null),fe=r.useRef(Z),M=r.useRef(null),de=r.useRef(null),g=r.useRef(0),a=r.useRef(null),K=r.useRef(void 0),j=r.useRef([]),$=r.useRef(!1),me=r.useRef(!1),x=r.useRef(!1),A=r.useRef(null),W=r.useRef(null),h=r.useRef(!1),u=r.useRef(!1),p=r.useRef(null),b=r.useRef(!1),q=r.useRef(null),Q=r.useRef(0),T=r.useRef("unknown"),[I,i]=r.useState(_),[pe,V]=r.useState(!1),o=d>=0?w[d]:void 0,F=o?.audioUrl,R=r.useMemo(()=>[...o?.audioSegments??[]].sort((e,t)=>e.segment_index-t.segment_index),[o?.audioSegments]),xe=r.useMemo(()=>nr.toPlayerCustomActionList(ce,ie),[ie,ce]),he=xe.length+5,We=r.useMemo(()=>({"--slide-player-mobile-control-count":String(he)}),[he]),U=r.useMemo(()=>({...Ie.DEFAULT_SLIDE_PLAYER_TEXTS,...oe}),[oe]),ee=r.useMemo(()=>o?o.audioKey??`${String(o.sequenceNumber??"none")}:${String(o.audioUrl??"")}`:"none",[o]),Ve=Y?X:I,Be=Y?X?"Pause autoplay":"Play autoplay":I?"Pause":"Play";r.useEffect(()=>{K.current=o},[o]),r.useEffect(()=>{J||V(!1)},[J]),r.useEffect(()=>{!fe.current&&Z&&V(!1),fe.current=Z},[Z]),r.useEffect(()=>{j.current=R},[R]),r.useEffect(()=>{const e=o?.audioUrl,t=d>=0?w[d+1]?.audioUrl:void 0;Ce(e),Ce(t)},[w,o?.audioUrl,d]);const s=r.useCallback((e,t=null)=>{me.current===e&&(!e||t===null)||(me.current=e,re?.({loading:e,reason:e?t:null}))},[re]),ye=r.useCallback(e=>e instanceof DOMException?e.name==="NotAllowedError"||e.name==="SecurityError":!1,[]),N=r.useCallback(()=>_&&!L&&!x.current&&T.current!=="blocked",[_,L]),ge=r.useCallback(e=>e?e.startsWith("data:")?e:`data:audio/mpeg;base64,${e}`:"",[]),be=r.useCallback(()=>{const e=a.current;return e==null||e<=0?0:j.current.slice(0,e).reduce((t,l)=>t+Math.max(Number(l.duration_ms??0),0),0)/1e3},[]),P=r.useCallback(e=>e<=0?0:j.current.slice(0,e).reduce((t,l)=>t+Math.max(Number(l.duration_ms??0),0),0),[]),Re=r.useCallback(()=>{const e=m.current;return e?A.current==="segment"?P(g.current)+Math.max(e.currentTime,0)*1e3:p.current!==null&&e.readyState===0?p.current*1e3:Math.max(e.currentTime,0)*1e3:a.current!=null?P(a.current):0},[P]),y=r.useCallback(e=>{const t=Math.max(e,0);Q.current!==t&&(Q.current=t,H?.(t))},[H]),c=r.useCallback(()=>{y(Re())},[Re,y]),f=r.useCallback(()=>{typeof window>"u"||q.current===null||(window.cancelAnimationFrame(q.current),q.current=null)},[]),Ee=r.useCallback(()=>{if(typeof window>"u"||q.current!==null)return;const e=()=>{c();const t=m.current;if(!t||t.paused||t.ended){q.current=null;return}q.current=window.requestAnimationFrame(e)};q.current=window.requestAnimationFrame(e)},[c]),B=r.useCallback(()=>{const e=m.current;e&&(f(),u.current=!1,x.current=!1,$.current=!1,A.current=null,p.current=null,h.current=!1,b.current=!1,W.current=null,e.pause(),e.removeAttribute("src"),e.load(),M.current=null,g.current=0,a.current=null,y(0),i(!1),s(!1))},[y,f,s]),E=r.useCallback(e=>{const t=m.current;if(!t)return!1;const l=t.play();return l&&typeof l.then=="function"&&l.then(()=>{T.current==="unknown"&&(T.current="auto"),u.current=!1,b.current=!1}).catch(S=>{T.current==="unknown"&&ye(S)&&(T.current="blocked",u.current=!1,s(!1)),b.current=!1,i(!1)}),!0},[ye,s]),k=r.useCallback((e,t)=>{const l=m.current,S=j.current[e];if(!l||!S)return!1;const C=ge(S.audio_data);g.current=e,a.current=null,h.current=!1,b.current=!0,W.current="segment",y(P(e));const D=N();u.current=D,s(!1);const Je=M.current!==C;return A.current="segment",Je&&(l.pause(),l.removeAttribute("src"),l.load(),M.current=C,l.src=C,l.load()),p.current=0,l.readyState>0&&(l.currentTime=0,p.current=null),D?E(`start-segment:${t}`):(u.current=!1,b.current=!1,l.pause(),i(!1),!0)},[N,ge,P,y,E,s]),O=r.useCallback(e=>{f(),u.current=!1,h.current=!1,b.current=!1,c(),i(!1),s(!1),d>=0&&ae?.(d)},[d,ae,f,c,s]),z=r.useCallback(e=>{const t=m.current;return!t||A.current!=="url"||!rr.hasReachedAudioEnd({currentTimeSeconds:Math.max(t.currentTime,0),durationSeconds:t.duration})?!1:(u.current=!1,t.pause(),O(e),!0)},[O]),_e=r.useCallback(()=>{const e=g.current+1,t=j.current,l=t[e],S=K.current,C=t.some(D=>D.is_final);if(l){k(e,"ended");return}if(S?.isAudioStreaming||!C){g.current=e,a.current=e,h.current=!0,u.current=_,y(P(e)),i(!1),s(!0,"waitingForMoreAudio");return}O("segments-completed")},[_,O,P,y,k,s]);r.useEffect(()=>{if(de.current===ee)return;de.current=ee,g.current=0,a.current=null,h.current=!1,x.current=!1,$.current=!1,u.current=!1,b.current=!1,A.current=null,W.current=null,M.current=null,f(),y(0),s(!1);const e=m.current;e&&(e.pause(),e.removeAttribute("src"),e.load(),i(!1))},[d,ee,R.length,F,y,f,s]),r.useEffect(()=>{const e=m.current;if(e){if(L){$.current=!!(K.current&&!x.current&&(!e.paused||u.current||a.current!==null)),u.current=!1,s(!1),e.pause(),i(!1);return}if(!(!$.current||!K.current||x.current)){if($.current=!1,a.current!==null){if(a.current<j.current.length){k(a.current,"external-resume");return}u.current=!0,s(!0,"waitingForMoreAudio");return}if(!M.current&&j.current.length>0){k(Math.min(g.current,j.current.length-1),"external-resume-init");return}e.paused&&(u.current=!0,E("external-resume"))}}},[L,k,E,s]),r.useEffect(()=>{const e=m.current;if(!e)return;if(!o){B();return}if(L){u.current=!1,s(!1),e.pause(),i(!1);return}const t=tr.resolveAudioPlaybackSourceType({activeSourceType:A.current,hasAudioUrl:!!F,segmentCount:R.length,preferredSourceType:W.current,waitingSegmentIndex:a.current});if(t&&W.current!==t&&(W.current=t),t==="url"&&F){const l=M.current!==F,S=N();if(l){const C=a.current!==null?be():0;e.pause(),e.removeAttribute("src"),e.load(),M.current=F,A.current="url",e.src=F,e.load(),p.current=C,y(C*1e3),e.readyState>0&&(e.currentTime=C,p.current=null)}if(u.current=S,h.current=!1,b.current=!1,s(!1),!S){u.current=!1,e.pause(),i(!1);return}E(l?"sync-url-init":"sync-url");return}if(t==="segment"&&a.current!==null){if(a.current<R.length){if(x.current){i(!1),s(!1);return}k(a.current,"wait-resume");return}h.current=!0,u.current=N(),i(!1),s(N());return}if(t==="segment"&&!R.length){if(o.isAudioStreaming){a.current=g.current,h.current=!0,u.current=N(),i(!1),s(N());return}B();return}if(t==="segment"&&!M.current){k(Math.min(g.current,R.length-1),"effect-init");return}if(t!=="segment"){B();return}if(!_||x.current){u.current=!1,e.pause(),i(!1);return}e.paused&&(u.current=!0,E("sync-paused-retry"))},[o,d,R,F,_,L,N,y,B,k,E,be,s]),r.useEffect(()=>B,[B]),r.useEffect(()=>f,[f]);const Oe=r.useCallback(()=>{c(),Ee(),i(!0),s(!1),te?.()},[te,Ee,c,s]),Ze=r.useCallback(()=>{h.current||b.current||(f(),c(),i(!1))},[d,f,c]),$e=r.useCallback(()=>{const e=m.current;e&&p.current!==null&&(e.currentTime=p.current,p.current=null),c(),!z("canplay-seek-finished")&&(!u.current||!_||E("canplay"))},[d,_,z,c,E]),He=r.useCallback(()=>{const e=m.current;e&&p.current!==null&&(e.currentTime=p.current,p.current=null),c(),z("metadata-seek-finished")},[d,z,c]),Ke=r.useCallback(()=>{c()},[c]),ze=r.useCallback(()=>{h.current||s(!0,"loadingAudio")},[s]),De=r.useCallback(()=>{if(h.current){s(!0,"waitingForMoreAudio");return}s(!0,"loadingAudio")},[s]),je=r.useCallback(()=>{c()},[c]),Xe=r.useCallback(()=>{const e=A.current==="url"||j.current.length===0;if(f(),b.current=!1,e){O("url-ended");return}_e()},[O,_e,f]),Ye=r.useCallback(()=>{f(),c(),i(!1),s(!1)},[f,c,s]),Ge=r.useCallback(e=>{le?.(e),V(!1)},[le]);return r.useEffect(()=>{H?.(Q.current)},[H]),n.jsxRuntimeExports.jsxs("div",{className:ke.cn("slide-player",v),...Pe,children:[n.jsxRuntimeExports.jsx("audio",{ref:m,preload:"auto",playsInline:!0,onLoadStart:ze,onLoadedMetadata:He,onCanPlay:$e,onPlay:Oe,onPause:Ze,onWaiting:De,onSeeking:je,onSeeked:je,onTimeUpdate:Ke,onEnded:Xe,onError:Ye}),J?n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[n.jsxRuntimeExports.jsx(Qe.default,{container:Ne,labels:{fullscreen:U.fullscreenLabel,nonFullscreen:U.nonFullscreenLabel,screen:U.screenLabel,subtitle:U.subtitleLabel,subtitleToggle:U.subtitleToggleAriaLabel,title:U.settingsTitle},isSubtitleEnabled:G,onClose:()=>V(!1),onOpenChange:V,onSubtitleToggle:ne??(()=>{}),onViewModeChange:Ge,open:pe,viewMode:Te}),n.jsxRuntimeExports.jsxs("div",{className:"slide-player__controls",style:We,children:[n.jsxRuntimeExports.jsxs("div",{className:"slide-player__group",children:[n.jsxRuntimeExports.jsx("button",{"aria-expanded":pe,"aria-haspopup":"dialog","aria-label":"More options",className:"slide-player__action slide-player__action--mobile-more",onClick:()=>{V(e=>!e)},type:"button",children:n.jsxRuntimeExports.jsx(sr.default,{className:"slide-player__icon",strokeWidth:2.25})}),n.jsxRuntimeExports.jsx("button",{"aria-label":"Volume",className:"hidden",type:"button",children:n.jsxRuntimeExports.jsx(ur.default,{className:"slide-player__icon",strokeWidth:2.25})}),n.jsxRuntimeExports.jsx("button",{"aria-label":U.subtitleToggleAriaLabel,"aria-pressed":G,className:"slide-player__action slide-player__action--subtitle",onClick:ne,type:"button",children:G?n.jsxRuntimeExports.jsx(lr.default,{className:"slide-player__icon",strokeWidth:2.25}):n.jsxRuntimeExports.jsx(ar.default,{className:"slide-player__icon",strokeWidth:2.25})}),n.jsxRuntimeExports.jsx("button",{"aria-label":"Rewind",className:"slide-player__action slide-player__action--prev",disabled:Fe,onClick:Me,type:"button",children:n.jsxRuntimeExports.jsx(cr.default,{className:"slide-player__icon",strokeWidth:2.25})}),n.jsxRuntimeExports.jsx("button",{"aria-label":Be,className:"slide-player__toggle slide-player__toggle--playback",onClick:()=>{if(Y){ve?.(!X);return}const e=m.current;if(!(L||!e||!o)){if(a.current!==null){if(I){u.current=!1,x.current=!0,a.current=null,h.current=!1,i(!1),s(!1),e.pause();return}T.current="manual",x.current=!1,u.current=!0,s(!0,"waitingForMoreAudio");return}if(!e.src&&R.length>0){T.current="manual",x.current=!1,k(Math.min(g.current,R.length-1),"toggle");return}if(e.paused){T.current="manual",x.current=!1,u.current=!0,E("toggle-resume");return}u.current=!1,x.current=!0,e.pause()}},type:"button",children:Ve?n.jsxRuntimeExports.jsx(mr,{}):n.jsxRuntimeExports.jsx(pr,{})}),n.jsxRuntimeExports.jsx("button",{"aria-label":"Forward",className:"slide-player__action slide-player__action--next",disabled:Ue,onClick:Ae,type:"button",children:n.jsxRuntimeExports.jsx(ir.default,{className:"slide-player__icon",strokeWidth:2.25})}),se?n.jsxRuntimeExports.jsx("button",{"aria-label":ue?"Exit fullscreen":"Enter fullscreen",className:"slide-player__action slide-player__action--fullscreen",onClick:se,type:"button",children:ue?n.jsxRuntimeExports.jsx(or.default,{className:"slide-player__icon",strokeWidth:2.25}):n.jsxRuntimeExports.jsx(fr.default,{className:"slide-player__icon",strokeWidth:2.25})}):null]}),n.jsxRuntimeExports.jsx("div",{className:"slide-player__separator"}),n.jsxRuntimeExports.jsxs("div",{className:"slide-player__group",children:[xe.map((e,t)=>n.jsxRuntimeExports.jsx(r.Fragment,{children:e},`custom-action-${t}`)),n.jsxRuntimeExports.jsx("button",{"aria-label":"Notes",className:ke.cn("slide-player__action slide-player__action--notes",Z&&"slide-player__action--active"),disabled:!qe,onClick:Le,type:"button",children:n.jsxRuntimeExports.jsx(dr.default,{className:"slide-player__icon",strokeWidth:2.25})})]})]})]}):null]})},we=r.memo(xr);we.displayName="Player";exports.default=we;
2
2
  //# sourceMappingURL=Player.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Player.cjs.js","sources":["../../../src/components/Slide/Player.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n Captions,\n CaptionsOff,\n EllipsisVertical,\n FilePenLine,\n Maximize,\n RotateCcw,\n RotateCw,\n ScanLine,\n Volume2,\n} from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\nimport MobilePlayerSettingsSheet from \"./MobilePlayerSettingsSheet\";\nimport { DEFAULT_SLIDE_PLAYER_TEXTS } from \"./constants\";\nimport type { SlideAudioItem } from \"./useSlide\";\nimport type {\n SlidePlayerCustomActionContext,\n SlidePlayerCustomActions,\n} from \"./types\";\nimport {\n DEFAULT_MOBILE_VIEW_MODE,\n type MobileViewMode,\n} from \"./utils/mobileScreenMode\";\nimport { hasReachedAudioEnd } from \"./utils/audioCompletion\";\nimport { toPlayerCustomActionList } from \"./utils/playerCustomActions\";\nimport \"./player.css\";\n\nconst audioPreloadElementCache = new Map<string, HTMLAudioElement>();\n\nexport interface SlidePlayerTexts {\n settingsTitle?: string;\n subtitleLabel?: string;\n subtitleToggleAriaLabel?: string;\n screenLabel?: string;\n nonFullscreenLabel?: string;\n fullscreenLabel?: string;\n fullscreenHintText?: string;\n}\n\nexport type SlidePlayerLoadingReason = \"loadingAudio\" | \"waitingForMoreAudio\";\n\nconst preloadAudioUrl = (url?: string) => {\n if (typeof window === \"undefined\" || !url) {\n return;\n }\n\n if (audioPreloadElementCache.has(url)) {\n return;\n }\n\n // Use a detached audio element so warm-up follows the same media loading\n // path as the visible player instead of relying on link preload hints.\n const audio = window.document.createElement(\"audio\");\n audio.preload = \"auto\";\n audio.setAttribute(\"playsinline\", \"true\");\n audio.src = url;\n audio.load();\n\n audioPreloadElementCache.set(url, audio);\n};\n\nexport type PlayerProps = Omit<React.ComponentProps<\"div\">, \"onEnded\"> & {\n audioList?: SlideAudioItem[];\n currentAudioIndex?: number;\n defaultPlaying?: boolean;\n isPlaybackPaused?: boolean;\n isAutoAdvanceEnabled?: boolean;\n useAutoAdvanceToggle?: boolean;\n onLoadingChange?: (state: {\n loading: boolean;\n reason: SlidePlayerLoadingReason | null;\n }) => void;\n onPlaybackStarted?: () => void;\n onPlaybackTimeChange?: (timeMs: number) => void;\n onSubtitleToggle?: () => void;\n onPrev?: () => void;\n onNext?: () => void;\n onFullscreen?: () => void;\n isFullscreen?: boolean;\n mobileViewMode?: MobileViewMode;\n settingsPortalContainer?: HTMLElement | null;\n onMobileViewModeChange?: (viewMode: MobileViewMode) => void;\n onEnded?: (audioIndex: number) => void;\n onAutoAdvanceToggle?: (enabled: boolean) => void;\n onInteractionToggle?: () => void;\n hasInteraction?: boolean;\n isInteractionOpen?: boolean;\n isSubtitleEnabled?: boolean;\n prevDisabled?: boolean;\n nextDisabled?: boolean;\n showControls?: boolean;\n customActions?: SlidePlayerCustomActions;\n customActionContext?: SlidePlayerCustomActionContext;\n texts?: SlidePlayerTexts;\n};\n\nconst PauseIcon = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"34\"\n height=\"34\"\n viewBox=\"0 0 34 34\"\n fill=\"none\"\n >\n <path\n d=\"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z\"\n fill=\"#0A0A0A\"\n />\n <path d=\"M12 10H16V24H12V10ZM18 10H22V24H18V10Z\" fill=\"white\" />\n </svg>\n);\n\nconst PlayIcon = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"34\"\n height=\"34\"\n viewBox=\"0 0 34 34\"\n fill=\"none\"\n >\n <path\n d=\"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z\"\n fill=\"#0A0A0A\"\n />\n <path d=\"M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z\" fill=\"white\" />\n </svg>\n);\n\nconst Player = ({\n audioList = [],\n className,\n currentAudioIndex = -1,\n defaultPlaying = true,\n isPlaybackPaused = false,\n isAutoAdvanceEnabled = true,\n useAutoAdvanceToggle = false,\n onLoadingChange,\n onPlaybackStarted,\n onPlaybackTimeChange,\n onSubtitleToggle,\n onPrev,\n onNext,\n onFullscreen,\n isFullscreen = false,\n mobileViewMode = DEFAULT_MOBILE_VIEW_MODE,\n settingsPortalContainer,\n onMobileViewModeChange,\n onEnded,\n onAutoAdvanceToggle,\n onInteractionToggle,\n hasInteraction = false,\n isInteractionOpen = false,\n isSubtitleEnabled = true,\n prevDisabled = false,\n nextDisabled = false,\n showControls = true,\n customActions,\n customActionContext,\n texts,\n ...props\n}: PlayerProps) => {\n const audioRef = useRef<HTMLAudioElement | null>(null);\n const previousInteractionOpenRef = useRef(isInteractionOpen);\n const audioSrcRef = useRef<string | null>(null);\n const currentAudioKeyRef = useRef<string | null>(null);\n const currentSegmentIndexRef = useRef(0);\n const waitingSegmentIndexRef = useRef<number | null>(null);\n const currentAudioRef = useRef<SlideAudioItem | undefined>(undefined);\n const currentAudioSegmentsRef = useRef<\n NonNullable<SlideAudioItem[\"audioSegments\"]>\n >([]);\n const wasPlayingBeforeExternalPauseRef = useRef(false);\n const isLoadingRef = useRef(false);\n const isPausedByUserRef = useRef(false);\n const activeSourceTypeRef = useRef<\"url\" | \"segment\" | null>(null);\n const isWaitingForSegmentRef = useRef(false);\n const pendingAutoPlayRef = useRef(false);\n const pendingSeekTimeRef = useRef<number | null>(null);\n const isSwitchingSegmentRef = useRef(false);\n const playbackAnimationFrameRef = useRef<number | null>(null);\n const playbackTimeMsRef = useRef(0);\n const playbackAccessModeRef = useRef<\n \"unknown\" | \"auto\" | \"manual\" | \"blocked\"\n >(\"unknown\");\n const [isPlaying, setIsPlaying] = useState(defaultPlaying);\n const [isMobileMoreOpen, setIsMobileMoreOpen] = useState(false);\n const currentAudio =\n currentAudioIndex >= 0 ? audioList[currentAudioIndex] : undefined;\n const currentAudioUrl = currentAudio?.audioUrl;\n const currentAudioSegments = useMemo(\n () =>\n [...(currentAudio?.audioSegments ?? [])].sort(\n (prevSegment, nextSegment) =>\n prevSegment.segment_index - nextSegment.segment_index\n ),\n [currentAudio?.audioSegments]\n );\n const customActionList = useMemo(\n () => toPlayerCustomActionList(customActions, customActionContext),\n [customActionContext, customActions]\n );\n const mobileVisibleActionCount = customActionList.length + 5;\n const controlsStyle = useMemo(\n () =>\n ({\n \"--slide-player-mobile-control-count\": String(mobileVisibleActionCount),\n }) as React.CSSProperties,\n [mobileVisibleActionCount]\n );\n const playerTexts = useMemo(\n () => ({\n ...DEFAULT_SLIDE_PLAYER_TEXTS,\n ...texts,\n }),\n [texts]\n );\n const currentAudioKey = useMemo(() => {\n if (!currentAudio) {\n return \"none\";\n }\n\n return (\n currentAudio.audioKey ??\n `${String(currentAudio.sequenceNumber ?? \"none\")}:${String(currentAudio.audioUrl ?? \"\")}`\n );\n }, [currentAudio]);\n const isTogglePlaying = useAutoAdvanceToggle\n ? isAutoAdvanceEnabled\n : isPlaying;\n const toggleAriaLabel = useAutoAdvanceToggle\n ? isAutoAdvanceEnabled\n ? \"Pause autoplay\"\n : \"Play autoplay\"\n : isPlaying\n ? \"Pause\"\n : \"Play\";\n\n useEffect(() => {\n currentAudioRef.current = currentAudio;\n }, [currentAudio]);\n\n useEffect(() => {\n if (showControls) {\n return;\n }\n\n setIsMobileMoreOpen(false);\n }, [showControls]);\n\n useEffect(() => {\n if (!previousInteractionOpenRef.current && isInteractionOpen) {\n setIsMobileMoreOpen(false);\n }\n\n previousInteractionOpenRef.current = isInteractionOpen;\n }, [isInteractionOpen]);\n\n useEffect(() => {\n currentAudioSegmentsRef.current = currentAudioSegments;\n }, [currentAudioSegments]);\n\n useEffect(() => {\n const currentUrl = currentAudio?.audioUrl;\n const nextUrl =\n currentAudioIndex >= 0\n ? audioList[currentAudioIndex + 1]?.audioUrl\n : undefined;\n\n preloadAudioUrl(currentUrl);\n preloadAudioUrl(nextUrl);\n }, [audioList, currentAudio?.audioUrl, currentAudioIndex]);\n\n const updateLoading = useCallback(\n (loading: boolean, reason: SlidePlayerLoadingReason | null = null) => {\n if (isLoadingRef.current === loading && (!loading || reason === null)) {\n return;\n }\n\n isLoadingRef.current = loading;\n onLoadingChange?.({\n loading,\n reason: loading ? reason : null,\n });\n },\n [onLoadingChange]\n );\n\n const isAutoplayBlockedError = useCallback((error: unknown) => {\n if (!(error instanceof DOMException)) {\n return false;\n }\n\n return error.name === \"NotAllowedError\" || error.name === \"SecurityError\";\n }, []);\n\n const canStartPlaybackAutomatically = useCallback(() => {\n return (\n defaultPlaying &&\n !isPlaybackPaused &&\n !isPausedByUserRef.current &&\n playbackAccessModeRef.current !== \"blocked\"\n );\n }, [defaultPlaying, isPlaybackPaused]);\n\n const getSegmentSrc = useCallback((audioData: string) => {\n if (!audioData) {\n return \"\";\n }\n\n if (audioData.startsWith(\"data:\")) {\n return audioData;\n }\n\n return `data:audio/mpeg;base64,${audioData}`;\n }, []);\n\n const getWaitingSegmentSeekTime = useCallback(() => {\n const waitingSegmentIndex = waitingSegmentIndexRef.current;\n\n if (waitingSegmentIndex == null || waitingSegmentIndex <= 0) {\n return 0;\n }\n\n return (\n currentAudioSegmentsRef.current\n .slice(0, waitingSegmentIndex)\n .reduce(\n (totalDurationMs, segment) =>\n totalDurationMs + Math.max(Number(segment.duration_ms ?? 0), 0),\n 0\n ) / 1000\n );\n }, []);\n\n const getSegmentStartTimeMs = useCallback((segmentIndex: number) => {\n if (segmentIndex <= 0) {\n return 0;\n }\n\n return currentAudioSegmentsRef.current\n .slice(0, segmentIndex)\n .reduce(\n (totalDurationMs, segment) =>\n totalDurationMs + Math.max(Number(segment.duration_ms ?? 0), 0),\n 0\n );\n }, []);\n\n const getCurrentPlaybackTimeMs = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return waitingSegmentIndexRef.current != null\n ? getSegmentStartTimeMs(waitingSegmentIndexRef.current)\n : 0;\n }\n\n if (activeSourceTypeRef.current === \"segment\") {\n return (\n getSegmentStartTimeMs(currentSegmentIndexRef.current) +\n Math.max(audioElement.currentTime, 0) * 1000\n );\n }\n\n if (pendingSeekTimeRef.current !== null && audioElement.readyState === 0) {\n return pendingSeekTimeRef.current * 1000;\n }\n\n return Math.max(audioElement.currentTime, 0) * 1000;\n }, [getSegmentStartTimeMs]);\n\n const publishPlaybackTime = useCallback(\n (timeMs: number) => {\n const nextPlaybackTimeMs = Math.max(timeMs, 0);\n\n if (playbackTimeMsRef.current === nextPlaybackTimeMs) {\n return;\n }\n\n playbackTimeMsRef.current = nextPlaybackTimeMs;\n onPlaybackTimeChange?.(nextPlaybackTimeMs);\n },\n [onPlaybackTimeChange]\n );\n\n const syncPlaybackTime = useCallback(() => {\n publishPlaybackTime(getCurrentPlaybackTimeMs());\n }, [getCurrentPlaybackTimeMs, publishPlaybackTime]);\n\n const stopPlaybackTimeLoop = useCallback(() => {\n if (\n typeof window === \"undefined\" ||\n playbackAnimationFrameRef.current === null\n ) {\n return;\n }\n\n window.cancelAnimationFrame(playbackAnimationFrameRef.current);\n playbackAnimationFrameRef.current = null;\n }, []);\n\n const startPlaybackTimeLoop = useCallback(() => {\n if (\n typeof window === \"undefined\" ||\n playbackAnimationFrameRef.current !== null\n ) {\n return;\n }\n\n const updateFrame = () => {\n syncPlaybackTime();\n\n const audioElement = audioRef.current;\n\n if (!audioElement || audioElement.paused || audioElement.ended) {\n playbackAnimationFrameRef.current = null;\n return;\n }\n\n playbackAnimationFrameRef.current =\n window.requestAnimationFrame(updateFrame);\n };\n\n playbackAnimationFrameRef.current =\n window.requestAnimationFrame(updateFrame);\n }, [syncPlaybackTime]);\n\n const resetAudio = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n stopPlaybackTimeLoop();\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = false;\n wasPlayingBeforeExternalPauseRef.current = false;\n activeSourceTypeRef.current = null;\n pendingSeekTimeRef.current = null;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = null;\n currentSegmentIndexRef.current = 0;\n waitingSegmentIndexRef.current = null;\n publishPlaybackTime(0);\n setIsPlaying(false);\n updateLoading(false);\n }, [publishPlaybackTime, stopPlaybackTimeLoop, updateLoading]);\n\n const tryPlayCurrentAudio = useCallback(\n (_reason: string) => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return false;\n }\n\n const playPromise = audioElement.play();\n\n if (playPromise && typeof playPromise.then === \"function\") {\n void playPromise\n .then(() => {\n if (playbackAccessModeRef.current === \"unknown\") {\n playbackAccessModeRef.current = \"auto\";\n }\n\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n })\n .catch((error: unknown) => {\n if (\n playbackAccessModeRef.current === \"unknown\" &&\n isAutoplayBlockedError(error)\n ) {\n // Lock autoplay after the first browser rejection.\n playbackAccessModeRef.current = \"blocked\";\n pendingAutoPlayRef.current = false;\n updateLoading(false);\n }\n\n isSwitchingSegmentRef.current = false;\n setIsPlaying(false);\n });\n }\n\n return true;\n },\n [isAutoplayBlockedError, updateLoading]\n );\n\n const startSegmentPlayback = useCallback(\n (segmentIndex: number, _reason: string) => {\n const audioElement = audioRef.current;\n const segment = currentAudioSegmentsRef.current[segmentIndex];\n\n if (!audioElement || !segment) {\n return false;\n }\n\n const nextAudioSrc = getSegmentSrc(segment.audio_data);\n\n currentSegmentIndexRef.current = segmentIndex;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = true;\n publishPlaybackTime(getSegmentStartTimeMs(segmentIndex));\n const shouldAutoResume = canStartPlaybackAutomatically();\n\n pendingAutoPlayRef.current = shouldAutoResume;\n updateLoading(false);\n\n const hasNewSrc = audioSrcRef.current !== nextAudioSrc;\n\n activeSourceTypeRef.current = \"segment\";\n\n if (hasNewSrc) {\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = nextAudioSrc;\n audioElement.src = nextAudioSrc;\n audioElement.load();\n }\n\n pendingSeekTimeRef.current = 0;\n\n if (audioElement.readyState > 0) {\n audioElement.currentTime = 0;\n pendingSeekTimeRef.current = null;\n }\n\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return true;\n }\n\n return tryPlayCurrentAudio(`start-segment:${_reason}`);\n },\n [\n canStartPlaybackAutomatically,\n getSegmentSrc,\n getSegmentStartTimeMs,\n publishPlaybackTime,\n tryPlayCurrentAudio,\n updateLoading,\n ]\n );\n\n const finishAudioItem = useCallback(\n (_reason?: string) => {\n stopPlaybackTimeLoop();\n pendingAutoPlayRef.current = false;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n syncPlaybackTime();\n setIsPlaying(false);\n updateLoading(false);\n\n if (currentAudioIndex >= 0) {\n onEnded?.(currentAudioIndex);\n }\n },\n [\n currentAudioIndex,\n onEnded,\n stopPlaybackTimeLoop,\n syncPlaybackTime,\n updateLoading,\n ]\n );\n\n const finishUrlAudioIfSeekedToEnd = useCallback(\n (_reason: string) => {\n const audioElement = audioRef.current;\n\n if (!audioElement || activeSourceTypeRef.current !== \"url\") {\n return false;\n }\n\n if (\n !hasReachedAudioEnd({\n currentTimeSeconds: Math.max(audioElement.currentTime, 0),\n durationSeconds: audioElement.duration,\n })\n ) {\n return false;\n }\n\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n finishAudioItem(_reason);\n return true;\n },\n [finishAudioItem]\n );\n\n const handleSegmentEnded = useCallback(() => {\n const nextSegmentIndex = currentSegmentIndexRef.current + 1;\n const segments = currentAudioSegmentsRef.current;\n const nextSegment = segments[nextSegmentIndex];\n const activeAudio = currentAudioRef.current;\n const hasFinal = segments.some((segment) => segment.is_final);\n\n if (nextSegment) {\n startSegmentPlayback(nextSegmentIndex, \"ended\");\n return;\n }\n\n if (activeAudio?.isAudioStreaming || !hasFinal) {\n currentSegmentIndexRef.current = nextSegmentIndex;\n waitingSegmentIndexRef.current = nextSegmentIndex;\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = defaultPlaying;\n publishPlaybackTime(getSegmentStartTimeMs(nextSegmentIndex));\n setIsPlaying(false);\n updateLoading(true, \"waitingForMoreAudio\");\n\n return;\n }\n\n finishAudioItem(\"segments-completed\");\n }, [\n defaultPlaying,\n finishAudioItem,\n getSegmentStartTimeMs,\n publishPlaybackTime,\n startSegmentPlayback,\n updateLoading,\n ]);\n\n useEffect(() => {\n if (currentAudioKeyRef.current === currentAudioKey) {\n return;\n }\n\n currentAudioKeyRef.current = currentAudioKey;\n currentSegmentIndexRef.current = 0;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n isPausedByUserRef.current = false;\n wasPlayingBeforeExternalPauseRef.current = false;\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n activeSourceTypeRef.current = null;\n audioSrcRef.current = null;\n stopPlaybackTimeLoop();\n publishPlaybackTime(0);\n updateLoading(false);\n\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n setIsPlaying(false);\n }, [\n currentAudioIndex,\n currentAudioKey,\n currentAudioSegments.length,\n currentAudioUrl,\n publishPlaybackTime,\n stopPlaybackTimeLoop,\n updateLoading,\n ]);\n\n useEffect(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n if (isPlaybackPaused) {\n wasPlayingBeforeExternalPauseRef.current = Boolean(\n currentAudioRef.current &&\n !isPausedByUserRef.current &&\n (!audioElement.paused ||\n pendingAutoPlayRef.current ||\n waitingSegmentIndexRef.current !== null)\n );\n\n pendingAutoPlayRef.current = false;\n updateLoading(false);\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (\n !wasPlayingBeforeExternalPauseRef.current ||\n !currentAudioRef.current ||\n isPausedByUserRef.current\n ) {\n return;\n }\n\n wasPlayingBeforeExternalPauseRef.current = false;\n\n if (waitingSegmentIndexRef.current !== null) {\n if (\n waitingSegmentIndexRef.current < currentAudioSegmentsRef.current.length\n ) {\n startSegmentPlayback(waitingSegmentIndexRef.current, \"external-resume\");\n return;\n }\n\n pendingAutoPlayRef.current = true;\n updateLoading(true, \"waitingForMoreAudio\");\n return;\n }\n\n if (!audioSrcRef.current && currentAudioSegmentsRef.current.length > 0) {\n startSegmentPlayback(\n Math.min(\n currentSegmentIndexRef.current,\n currentAudioSegmentsRef.current.length - 1\n ),\n \"external-resume-init\"\n );\n return;\n }\n\n if (!audioElement.paused) {\n return;\n }\n\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"external-resume\");\n }, [\n isPlaybackPaused,\n startSegmentPlayback,\n tryPlayCurrentAudio,\n updateLoading,\n ]);\n\n useEffect(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n if (!currentAudio) {\n resetAudio();\n return;\n }\n\n if (isPlaybackPaused) {\n pendingAutoPlayRef.current = false;\n updateLoading(false);\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (currentAudioUrl) {\n const hasNewSrc = audioSrcRef.current !== currentAudioUrl;\n const shouldAutoResume = canStartPlaybackAutomatically();\n const shouldKeepSegmentSource =\n activeSourceTypeRef.current === \"segment\" &&\n Boolean(audioSrcRef.current) &&\n waitingSegmentIndexRef.current === null;\n\n if (shouldKeepSegmentSource) {\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (audioElement.paused) {\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"keep-segment-source\");\n }\n\n return;\n }\n\n if (hasNewSrc) {\n const nextSeekTime =\n waitingSegmentIndexRef.current !== null\n ? getWaitingSegmentSeekTime()\n : 0;\n\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = currentAudioUrl;\n activeSourceTypeRef.current = \"url\";\n audioElement.src = currentAudioUrl;\n audioElement.load();\n pendingSeekTimeRef.current = nextSeekTime;\n publishPlaybackTime(nextSeekTime * 1000);\n\n if (audioElement.readyState > 0) {\n audioElement.currentTime = nextSeekTime;\n pendingSeekTimeRef.current = null;\n }\n }\n\n pendingAutoPlayRef.current = shouldAutoResume;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n updateLoading(false);\n\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n tryPlayCurrentAudio(hasNewSrc ? \"sync-url-init\" : \"sync-url\");\n return;\n }\n\n if (waitingSegmentIndexRef.current !== null) {\n if (waitingSegmentIndexRef.current < currentAudioSegments.length) {\n if (isPausedByUserRef.current) {\n setIsPlaying(false);\n updateLoading(false);\n return;\n }\n\n startSegmentPlayback(waitingSegmentIndexRef.current, \"wait-resume\");\n return;\n }\n\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = canStartPlaybackAutomatically();\n setIsPlaying(false);\n updateLoading(canStartPlaybackAutomatically());\n return;\n }\n\n if (!currentAudioSegments.length) {\n if (currentAudio.isAudioStreaming) {\n waitingSegmentIndexRef.current = currentSegmentIndexRef.current;\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = canStartPlaybackAutomatically();\n setIsPlaying(false);\n updateLoading(canStartPlaybackAutomatically());\n return;\n }\n\n resetAudio();\n return;\n }\n\n if (!audioSrcRef.current) {\n startSegmentPlayback(\n Math.min(\n currentSegmentIndexRef.current,\n currentAudioSegments.length - 1\n ),\n \"effect-init\"\n );\n return;\n }\n\n if (!defaultPlaying || isPausedByUserRef.current) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (audioElement.paused) {\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"sync-paused-retry\");\n }\n }, [\n currentAudio,\n currentAudioIndex,\n currentAudioSegments,\n currentAudioUrl,\n defaultPlaying,\n isPlaybackPaused,\n canStartPlaybackAutomatically,\n publishPlaybackTime,\n resetAudio,\n startSegmentPlayback,\n tryPlayCurrentAudio,\n getWaitingSegmentSeekTime,\n updateLoading,\n ]);\n\n useEffect(() => resetAudio, [resetAudio]);\n\n useEffect(() => stopPlaybackTimeLoop, [stopPlaybackTimeLoop]);\n\n const handleAudioPlay = useCallback(() => {\n syncPlaybackTime();\n startPlaybackTimeLoop();\n setIsPlaying(true);\n updateLoading(false);\n onPlaybackStarted?.();\n }, [\n onPlaybackStarted,\n startPlaybackTimeLoop,\n syncPlaybackTime,\n updateLoading,\n ]);\n\n const handleAudioPause = useCallback(() => {\n if (isWaitingForSegmentRef.current || isSwitchingSegmentRef.current) {\n return;\n }\n\n stopPlaybackTimeLoop();\n syncPlaybackTime();\n setIsPlaying(false);\n }, [currentAudioIndex, stopPlaybackTimeLoop, syncPlaybackTime]);\n\n const handleAudioCanPlay = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (audioElement && pendingSeekTimeRef.current !== null) {\n audioElement.currentTime = pendingSeekTimeRef.current;\n pendingSeekTimeRef.current = null;\n }\n\n syncPlaybackTime();\n\n if (finishUrlAudioIfSeekedToEnd(\"canplay-seek-finished\")) {\n return;\n }\n\n if (!pendingAutoPlayRef.current || !defaultPlaying) {\n return;\n }\n\n tryPlayCurrentAudio(\"canplay\");\n }, [\n currentAudioIndex,\n defaultPlaying,\n finishUrlAudioIfSeekedToEnd,\n syncPlaybackTime,\n tryPlayCurrentAudio,\n ]);\n\n const handleLoadedMetadata = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (audioElement && pendingSeekTimeRef.current !== null) {\n audioElement.currentTime = pendingSeekTimeRef.current;\n pendingSeekTimeRef.current = null;\n }\n\n syncPlaybackTime();\n\n finishUrlAudioIfSeekedToEnd(\"metadata-seek-finished\");\n }, [currentAudioIndex, finishUrlAudioIfSeekedToEnd, syncPlaybackTime]);\n\n const handleAudioTimeUpdate = useCallback(() => {\n syncPlaybackTime();\n }, [syncPlaybackTime]);\n\n const handleAudioLoadStart = useCallback(() => {\n if (isWaitingForSegmentRef.current) {\n return;\n }\n\n updateLoading(true, \"loadingAudio\");\n }, [updateLoading]);\n\n const handleAudioWaiting = useCallback(() => {\n if (isWaitingForSegmentRef.current) {\n updateLoading(true, \"waitingForMoreAudio\");\n return;\n }\n\n updateLoading(true, \"loadingAudio\");\n }, [updateLoading]);\n\n const handleAudioSeeking = useCallback(() => {\n syncPlaybackTime();\n }, [syncPlaybackTime]);\n\n const handleAudioEnded = useCallback(() => {\n const shouldFinishAsUrl =\n activeSourceTypeRef.current === \"url\" ||\n currentAudioSegmentsRef.current.length === 0;\n\n stopPlaybackTimeLoop();\n isSwitchingSegmentRef.current = false;\n\n if (shouldFinishAsUrl) {\n finishAudioItem(\"url-ended\");\n return;\n }\n\n handleSegmentEnded();\n }, [finishAudioItem, handleSegmentEnded, stopPlaybackTimeLoop]);\n\n const handleAudioError = useCallback(() => {\n stopPlaybackTimeLoop();\n syncPlaybackTime();\n setIsPlaying(false);\n updateLoading(false);\n }, [stopPlaybackTimeLoop, syncPlaybackTime, updateLoading]);\n const handleMobileViewModeChange = useCallback(\n (nextViewMode: MobileViewMode) => {\n onMobileViewModeChange?.(nextViewMode);\n setIsMobileMoreOpen(false);\n },\n [onMobileViewModeChange]\n );\n\n useEffect(() => {\n onPlaybackTimeChange?.(playbackTimeMsRef.current);\n }, [onPlaybackTimeChange]);\n\n return (\n <div className={cn(\"slide-player\", className)} {...props}>\n <audio\n ref={audioRef}\n preload=\"auto\"\n playsInline\n onLoadStart={handleAudioLoadStart}\n onLoadedMetadata={handleLoadedMetadata}\n onCanPlay={handleAudioCanPlay}\n onPlay={handleAudioPlay}\n onPause={handleAudioPause}\n onWaiting={handleAudioWaiting}\n onSeeking={handleAudioSeeking}\n onSeeked={handleAudioSeeking}\n onTimeUpdate={handleAudioTimeUpdate}\n onEnded={handleAudioEnded}\n onError={handleAudioError}\n />\n\n {showControls ? (\n <>\n <MobilePlayerSettingsSheet\n container={settingsPortalContainer}\n labels={{\n fullscreen: playerTexts.fullscreenLabel,\n nonFullscreen: playerTexts.nonFullscreenLabel,\n screen: playerTexts.screenLabel,\n subtitle: playerTexts.subtitleLabel,\n subtitleToggle: playerTexts.subtitleToggleAriaLabel,\n title: playerTexts.settingsTitle,\n }}\n isSubtitleEnabled={isSubtitleEnabled}\n onClose={() => setIsMobileMoreOpen(false)}\n onOpenChange={setIsMobileMoreOpen}\n onSubtitleToggle={onSubtitleToggle ?? (() => {})}\n onViewModeChange={handleMobileViewModeChange}\n open={isMobileMoreOpen}\n viewMode={mobileViewMode}\n />\n\n <div className=\"slide-player__controls\" style={controlsStyle}>\n <div className=\"slide-player__group\">\n <button\n aria-expanded={isMobileMoreOpen}\n aria-haspopup=\"dialog\"\n aria-label=\"More options\"\n className=\"slide-player__action slide-player__action--mobile-more\"\n onClick={() => {\n setIsMobileMoreOpen((prevOpen) => !prevOpen);\n }}\n type=\"button\"\n >\n <EllipsisVertical\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n </button>\n <button aria-label=\"Volume\" className=\"hidden\" type=\"button\">\n <Volume2 className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n <button\n aria-label={playerTexts.subtitleToggleAriaLabel}\n aria-pressed={isSubtitleEnabled}\n className=\"slide-player__action slide-player__action--subtitle\"\n onClick={onSubtitleToggle}\n type=\"button\"\n >\n {isSubtitleEnabled ? (\n <Captions className=\"slide-player__icon\" strokeWidth={2.25} />\n ) : (\n <CaptionsOff\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n )}\n </button>\n <button\n aria-label=\"Rewind\"\n className=\"slide-player__action slide-player__action--prev\"\n disabled={prevDisabled}\n onClick={onPrev}\n type=\"button\"\n >\n <RotateCcw className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n <button\n aria-label={toggleAriaLabel}\n className=\"slide-player__toggle slide-player__toggle--playback\"\n onClick={() => {\n if (useAutoAdvanceToggle) {\n onAutoAdvanceToggle?.(!isAutoAdvanceEnabled);\n return;\n }\n\n const audioElement = audioRef.current;\n\n if (isPlaybackPaused || !audioElement || !currentAudio) {\n return;\n }\n\n if (waitingSegmentIndexRef.current !== null) {\n if (isPlaying) {\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = true;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n setIsPlaying(false);\n updateLoading(false);\n audioElement.pause();\n return;\n }\n\n playbackAccessModeRef.current = \"manual\";\n isPausedByUserRef.current = false;\n pendingAutoPlayRef.current = true;\n updateLoading(true, \"waitingForMoreAudio\");\n return;\n }\n\n if (!audioElement.src && currentAudioSegments.length > 0) {\n playbackAccessModeRef.current = \"manual\";\n isPausedByUserRef.current = false;\n startSegmentPlayback(\n Math.min(\n currentSegmentIndexRef.current,\n currentAudioSegments.length - 1\n ),\n \"toggle\"\n );\n return;\n }\n\n if (audioElement.paused) {\n playbackAccessModeRef.current = \"manual\";\n isPausedByUserRef.current = false;\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"toggle-resume\");\n return;\n }\n\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = true;\n audioElement.pause();\n }}\n type=\"button\"\n >\n {isTogglePlaying ? <PauseIcon /> : <PlayIcon />}\n </button>\n <button\n aria-label=\"Forward\"\n className=\"slide-player__action slide-player__action--next\"\n disabled={nextDisabled}\n onClick={onNext}\n type=\"button\"\n >\n <RotateCw className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n {onFullscreen ? (\n <button\n aria-label={\n isFullscreen ? \"Exit fullscreen\" : \"Enter fullscreen\"\n }\n className=\"slide-player__action slide-player__action--fullscreen\"\n onClick={onFullscreen}\n type=\"button\"\n >\n {isFullscreen ? (\n <ScanLine\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n ) : (\n <Maximize\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n )}\n </button>\n ) : null}\n </div>\n\n <div className=\"slide-player__separator\" />\n\n <div className=\"slide-player__group\">\n {customActionList.map((customAction, customActionIndex) => (\n <React.Fragment key={`custom-action-${customActionIndex}`}>\n {customAction}\n </React.Fragment>\n ))}\n <button\n aria-label=\"Notes\"\n className={cn(\n \"slide-player__action slide-player__action--notes\",\n isInteractionOpen && \"slide-player__action--active\"\n )}\n disabled={!hasInteraction}\n onClick={onInteractionToggle}\n type=\"button\"\n >\n <FilePenLine\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n </button>\n </div>\n </div>\n </>\n ) : null}\n </div>\n );\n};\n\nconst MemoizedPlayer = memo(Player);\n\nMemoizedPlayer.displayName = \"Player\";\n\nexport default MemoizedPlayer;\n"],"names":["audioPreloadElementCache","preloadAudioUrl","url","audio","PauseIcon","jsxs","jsx","PlayIcon","Player","audioList","className","currentAudioIndex","defaultPlaying","isPlaybackPaused","isAutoAdvanceEnabled","useAutoAdvanceToggle","onLoadingChange","onPlaybackStarted","onPlaybackTimeChange","onSubtitleToggle","onPrev","onNext","onFullscreen","isFullscreen","mobileViewMode","DEFAULT_MOBILE_VIEW_MODE","settingsPortalContainer","onMobileViewModeChange","onEnded","onAutoAdvanceToggle","onInteractionToggle","hasInteraction","isInteractionOpen","isSubtitleEnabled","prevDisabled","nextDisabled","showControls","customActions","customActionContext","texts","props","audioRef","useRef","previousInteractionOpenRef","audioSrcRef","currentAudioKeyRef","currentSegmentIndexRef","waitingSegmentIndexRef","currentAudioRef","currentAudioSegmentsRef","wasPlayingBeforeExternalPauseRef","isLoadingRef","isPausedByUserRef","activeSourceTypeRef","isWaitingForSegmentRef","pendingAutoPlayRef","pendingSeekTimeRef","isSwitchingSegmentRef","playbackAnimationFrameRef","playbackTimeMsRef","playbackAccessModeRef","isPlaying","setIsPlaying","useState","isMobileMoreOpen","setIsMobileMoreOpen","currentAudio","currentAudioUrl","currentAudioSegments","useMemo","prevSegment","nextSegment","customActionList","toPlayerCustomActionList","mobileVisibleActionCount","controlsStyle","playerTexts","DEFAULT_SLIDE_PLAYER_TEXTS","currentAudioKey","isTogglePlaying","toggleAriaLabel","useEffect","currentUrl","nextUrl","updateLoading","useCallback","loading","reason","isAutoplayBlockedError","error","canStartPlaybackAutomatically","getSegmentSrc","audioData","getWaitingSegmentSeekTime","waitingSegmentIndex","totalDurationMs","segment","getSegmentStartTimeMs","segmentIndex","getCurrentPlaybackTimeMs","audioElement","publishPlaybackTime","timeMs","nextPlaybackTimeMs","syncPlaybackTime","stopPlaybackTimeLoop","startPlaybackTimeLoop","updateFrame","resetAudio","tryPlayCurrentAudio","_reason","playPromise","startSegmentPlayback","nextAudioSrc","shouldAutoResume","hasNewSrc","finishAudioItem","finishUrlAudioIfSeekedToEnd","hasReachedAudioEnd","handleSegmentEnded","nextSegmentIndex","segments","activeAudio","hasFinal","nextSeekTime","handleAudioPlay","handleAudioPause","handleAudioCanPlay","handleLoadedMetadata","handleAudioTimeUpdate","handleAudioLoadStart","handleAudioWaiting","handleAudioSeeking","handleAudioEnded","shouldFinishAsUrl","handleAudioError","handleMobileViewModeChange","nextViewMode","cn","Fragment","MobilePlayerSettingsSheet","prevOpen","EllipsisVertical","Volume2","Captions","CaptionsOff","RotateCcw","RotateCw","ScanLine","Maximize","customAction","customActionIndex","React","FilePenLine","MemoizedPlayer","memo"],"mappings":"6xDAoCMA,OAA+B,IAc/BC,GAAmBC,GAAiB,CAKxC,GAJI,OAAO,OAAW,KAAe,CAACA,GAIlCF,GAAyB,IAAIE,CAAG,EAClC,O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A,CAAS,UAAU,qBAAqB,YAAa,IAAA,CAAM,CAAA,CAAA,EAE7D7H,GACChB,EAAAA,kBAAAA,IAAC,SAAA,CACC,aACEiB,GAAe,kBAAoB,mBAErC,UAAU,wDACV,QAASD,GACT,KAAK,SAEJ,SAAAC,GACCjB,EAAAA,kBAAAA,IAAC8I,GAAAA,QAAA,CACC,UAAU,qBACV,YAAa,IAAA,CAAA,EAGf9I,EAAAA,kBAAAA,IAAC+I,GAAAA,QAAA,CACC,UAAU,qBACV,YAAa,IAAA,CAAA,CACf,CAAA,EAGF,IAAA,EACN,EAEA/I,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,yBAAA,CAA0B,EAEzCD,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,sBACZ,SAAA,CAAAmE,GAAiB,IAAI,CAAC8E,EAAcC,IACnCjJ,EAAAA,kBAAAA,IAACkJ,EAAM,SAAN,CACE,SAAAF,CAAA,EADkB,iBAAiBC,CAAiB,EAEvD,CACD,EACDjJ,EAAAA,kBAAAA,IAAC,SAAA,CACC,aAAW,QACX,UAAWoI,GAAAA,GACT,mDACA1G,GAAqB,8BAAA,EAEvB,SAAU,CAACD,GACX,QAASD,GACT,KAAK,SAEL,SAAAxB,EAAAA,kBAAAA,IAACmJ,GAAAA,QAAA,CACC,UAAU,qBACV,YAAa,IAAA,CAAA,CACf,CAAA,CACF,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,EACE,IAAA,EACN,CAEJ,EAEMC,GAAiBC,EAAAA,KAAKnJ,EAAM,EAElCkJ,GAAe,YAAc"}
1
+ {"version":3,"file":"Player.cjs.js","sources":["../../../src/components/Slide/Player.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n Captions,\n CaptionsOff,\n EllipsisVertical,\n FilePenLine,\n Maximize,\n RotateCcw,\n RotateCw,\n ScanLine,\n Volume2,\n} from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\nimport MobilePlayerSettingsSheet from \"./MobilePlayerSettingsSheet\";\nimport { DEFAULT_SLIDE_PLAYER_TEXTS } from \"./constants\";\nimport type { SlideAudioItem } from \"./useSlide\";\nimport type {\n SlidePlayerCustomActionContext,\n SlidePlayerCustomActions,\n} from \"./types\";\nimport {\n DEFAULT_MOBILE_VIEW_MODE,\n type MobileViewMode,\n} from \"./utils/mobileScreenMode\";\nimport { hasReachedAudioEnd } from \"./utils/audioCompletion\";\nimport {\n resolveAudioPlaybackSourceType,\n type AudioPlaybackSourceType,\n} from \"./utils/playbackSource\";\nimport { toPlayerCustomActionList } from \"./utils/playerCustomActions\";\nimport \"./player.css\";\n\nconst audioPreloadElementCache = new Map<string, HTMLAudioElement>();\n\nexport interface SlidePlayerTexts {\n settingsTitle?: string;\n subtitleLabel?: string;\n subtitleToggleAriaLabel?: string;\n screenLabel?: string;\n nonFullscreenLabel?: string;\n fullscreenLabel?: string;\n fullscreenHintText?: string;\n}\n\nexport type SlidePlayerLoadingReason = \"loadingAudio\" | \"waitingForMoreAudio\";\n\nconst preloadAudioUrl = (url?: string) => {\n if (typeof window === \"undefined\" || !url) {\n return;\n }\n\n if (audioPreloadElementCache.has(url)) {\n return;\n }\n\n // Use a detached audio element so warm-up follows the same media loading\n // path as the visible player instead of relying on link preload hints.\n const audio = window.document.createElement(\"audio\");\n audio.preload = \"auto\";\n audio.setAttribute(\"playsinline\", \"true\");\n audio.src = url;\n audio.load();\n\n audioPreloadElementCache.set(url, audio);\n};\n\nexport type PlayerProps = Omit<React.ComponentProps<\"div\">, \"onEnded\"> & {\n audioList?: SlideAudioItem[];\n currentAudioIndex?: number;\n defaultPlaying?: boolean;\n isPlaybackPaused?: boolean;\n isAutoAdvanceEnabled?: boolean;\n useAutoAdvanceToggle?: boolean;\n onLoadingChange?: (state: {\n loading: boolean;\n reason: SlidePlayerLoadingReason | null;\n }) => void;\n onPlaybackStarted?: () => void;\n onPlaybackTimeChange?: (timeMs: number) => void;\n onSubtitleToggle?: () => void;\n onPrev?: () => void;\n onNext?: () => void;\n onFullscreen?: () => void;\n isFullscreen?: boolean;\n mobileViewMode?: MobileViewMode;\n settingsPortalContainer?: HTMLElement | null;\n onMobileViewModeChange?: (viewMode: MobileViewMode) => void;\n onEnded?: (audioIndex: number) => void;\n onAutoAdvanceToggle?: (enabled: boolean) => void;\n onInteractionToggle?: () => void;\n hasInteraction?: boolean;\n isInteractionOpen?: boolean;\n isSubtitleEnabled?: boolean;\n prevDisabled?: boolean;\n nextDisabled?: boolean;\n showControls?: boolean;\n customActions?: SlidePlayerCustomActions;\n customActionContext?: SlidePlayerCustomActionContext;\n texts?: SlidePlayerTexts;\n};\n\nconst PauseIcon = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"34\"\n height=\"34\"\n viewBox=\"0 0 34 34\"\n fill=\"none\"\n >\n <path\n d=\"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z\"\n fill=\"#0A0A0A\"\n />\n <path d=\"M12 10H16V24H12V10ZM18 10H22V24H18V10Z\" fill=\"white\" />\n </svg>\n);\n\nconst PlayIcon = () => (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"34\"\n height=\"34\"\n viewBox=\"0 0 34 34\"\n fill=\"none\"\n >\n <path\n d=\"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z\"\n fill=\"#0A0A0A\"\n />\n <path d=\"M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z\" fill=\"white\" />\n </svg>\n);\n\nconst Player = ({\n audioList = [],\n className,\n currentAudioIndex = -1,\n defaultPlaying = true,\n isPlaybackPaused = false,\n isAutoAdvanceEnabled = true,\n useAutoAdvanceToggle = false,\n onLoadingChange,\n onPlaybackStarted,\n onPlaybackTimeChange,\n onSubtitleToggle,\n onPrev,\n onNext,\n onFullscreen,\n isFullscreen = false,\n mobileViewMode = DEFAULT_MOBILE_VIEW_MODE,\n settingsPortalContainer,\n onMobileViewModeChange,\n onEnded,\n onAutoAdvanceToggle,\n onInteractionToggle,\n hasInteraction = false,\n isInteractionOpen = false,\n isSubtitleEnabled = true,\n prevDisabled = false,\n nextDisabled = false,\n showControls = true,\n customActions,\n customActionContext,\n texts,\n ...props\n}: PlayerProps) => {\n const audioRef = useRef<HTMLAudioElement | null>(null);\n const previousInteractionOpenRef = useRef(isInteractionOpen);\n const audioSrcRef = useRef<string | null>(null);\n const currentAudioKeyRef = useRef<string | null>(null);\n const currentSegmentIndexRef = useRef(0);\n const waitingSegmentIndexRef = useRef<number | null>(null);\n const currentAudioRef = useRef<SlideAudioItem | undefined>(undefined);\n const currentAudioSegmentsRef = useRef<\n NonNullable<SlideAudioItem[\"audioSegments\"]>\n >([]);\n const wasPlayingBeforeExternalPauseRef = useRef(false);\n const isLoadingRef = useRef(false);\n const isPausedByUserRef = useRef(false);\n const activeSourceTypeRef = useRef<\"url\" | \"segment\" | null>(null);\n const preferredSourceTypeRef = useRef<AudioPlaybackSourceType | null>(null);\n const isWaitingForSegmentRef = useRef(false);\n const pendingAutoPlayRef = useRef(false);\n const pendingSeekTimeRef = useRef<number | null>(null);\n const isSwitchingSegmentRef = useRef(false);\n const playbackAnimationFrameRef = useRef<number | null>(null);\n const playbackTimeMsRef = useRef(0);\n const playbackAccessModeRef = useRef<\n \"unknown\" | \"auto\" | \"manual\" | \"blocked\"\n >(\"unknown\");\n const [isPlaying, setIsPlaying] = useState(defaultPlaying);\n const [isMobileMoreOpen, setIsMobileMoreOpen] = useState(false);\n const currentAudio =\n currentAudioIndex >= 0 ? audioList[currentAudioIndex] : undefined;\n const currentAudioUrl = currentAudio?.audioUrl;\n const currentAudioSegments = useMemo(\n () =>\n [...(currentAudio?.audioSegments ?? [])].sort(\n (prevSegment, nextSegment) =>\n prevSegment.segment_index - nextSegment.segment_index\n ),\n [currentAudio?.audioSegments]\n );\n const customActionList = useMemo(\n () => toPlayerCustomActionList(customActions, customActionContext),\n [customActionContext, customActions]\n );\n const mobileVisibleActionCount = customActionList.length + 5;\n const controlsStyle = useMemo(\n () =>\n ({\n \"--slide-player-mobile-control-count\": String(mobileVisibleActionCount),\n }) as React.CSSProperties,\n [mobileVisibleActionCount]\n );\n const playerTexts = useMemo(\n () => ({\n ...DEFAULT_SLIDE_PLAYER_TEXTS,\n ...texts,\n }),\n [texts]\n );\n const currentAudioKey = useMemo(() => {\n if (!currentAudio) {\n return \"none\";\n }\n\n return (\n currentAudio.audioKey ??\n `${String(currentAudio.sequenceNumber ?? \"none\")}:${String(currentAudio.audioUrl ?? \"\")}`\n );\n }, [currentAudio]);\n const isTogglePlaying = useAutoAdvanceToggle\n ? isAutoAdvanceEnabled\n : isPlaying;\n const toggleAriaLabel = useAutoAdvanceToggle\n ? isAutoAdvanceEnabled\n ? \"Pause autoplay\"\n : \"Play autoplay\"\n : isPlaying\n ? \"Pause\"\n : \"Play\";\n\n useEffect(() => {\n currentAudioRef.current = currentAudio;\n }, [currentAudio]);\n\n useEffect(() => {\n if (showControls) {\n return;\n }\n\n setIsMobileMoreOpen(false);\n }, [showControls]);\n\n useEffect(() => {\n if (!previousInteractionOpenRef.current && isInteractionOpen) {\n setIsMobileMoreOpen(false);\n }\n\n previousInteractionOpenRef.current = isInteractionOpen;\n }, [isInteractionOpen]);\n\n useEffect(() => {\n currentAudioSegmentsRef.current = currentAudioSegments;\n }, [currentAudioSegments]);\n\n useEffect(() => {\n const currentUrl = currentAudio?.audioUrl;\n const nextUrl =\n currentAudioIndex >= 0\n ? audioList[currentAudioIndex + 1]?.audioUrl\n : undefined;\n\n preloadAudioUrl(currentUrl);\n preloadAudioUrl(nextUrl);\n }, [audioList, currentAudio?.audioUrl, currentAudioIndex]);\n\n const updateLoading = useCallback(\n (loading: boolean, reason: SlidePlayerLoadingReason | null = null) => {\n if (isLoadingRef.current === loading && (!loading || reason === null)) {\n return;\n }\n\n isLoadingRef.current = loading;\n onLoadingChange?.({\n loading,\n reason: loading ? reason : null,\n });\n },\n [onLoadingChange]\n );\n\n const isAutoplayBlockedError = useCallback((error: unknown) => {\n if (!(error instanceof DOMException)) {\n return false;\n }\n\n return error.name === \"NotAllowedError\" || error.name === \"SecurityError\";\n }, []);\n\n const canStartPlaybackAutomatically = useCallback(() => {\n return (\n defaultPlaying &&\n !isPlaybackPaused &&\n !isPausedByUserRef.current &&\n playbackAccessModeRef.current !== \"blocked\"\n );\n }, [defaultPlaying, isPlaybackPaused]);\n\n const getSegmentSrc = useCallback((audioData: string) => {\n if (!audioData) {\n return \"\";\n }\n\n if (audioData.startsWith(\"data:\")) {\n return audioData;\n }\n\n return `data:audio/mpeg;base64,${audioData}`;\n }, []);\n\n const getWaitingSegmentSeekTime = useCallback(() => {\n const waitingSegmentIndex = waitingSegmentIndexRef.current;\n\n if (waitingSegmentIndex == null || waitingSegmentIndex <= 0) {\n return 0;\n }\n\n return (\n currentAudioSegmentsRef.current\n .slice(0, waitingSegmentIndex)\n .reduce(\n (totalDurationMs, segment) =>\n totalDurationMs + Math.max(Number(segment.duration_ms ?? 0), 0),\n 0\n ) / 1000\n );\n }, []);\n\n const getSegmentStartTimeMs = useCallback((segmentIndex: number) => {\n if (segmentIndex <= 0) {\n return 0;\n }\n\n return currentAudioSegmentsRef.current\n .slice(0, segmentIndex)\n .reduce(\n (totalDurationMs, segment) =>\n totalDurationMs + Math.max(Number(segment.duration_ms ?? 0), 0),\n 0\n );\n }, []);\n\n const getCurrentPlaybackTimeMs = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return waitingSegmentIndexRef.current != null\n ? getSegmentStartTimeMs(waitingSegmentIndexRef.current)\n : 0;\n }\n\n if (activeSourceTypeRef.current === \"segment\") {\n return (\n getSegmentStartTimeMs(currentSegmentIndexRef.current) +\n Math.max(audioElement.currentTime, 0) * 1000\n );\n }\n\n if (pendingSeekTimeRef.current !== null && audioElement.readyState === 0) {\n return pendingSeekTimeRef.current * 1000;\n }\n\n return Math.max(audioElement.currentTime, 0) * 1000;\n }, [getSegmentStartTimeMs]);\n\n const publishPlaybackTime = useCallback(\n (timeMs: number) => {\n const nextPlaybackTimeMs = Math.max(timeMs, 0);\n\n if (playbackTimeMsRef.current === nextPlaybackTimeMs) {\n return;\n }\n\n playbackTimeMsRef.current = nextPlaybackTimeMs;\n onPlaybackTimeChange?.(nextPlaybackTimeMs);\n },\n [onPlaybackTimeChange]\n );\n\n const syncPlaybackTime = useCallback(() => {\n publishPlaybackTime(getCurrentPlaybackTimeMs());\n }, [getCurrentPlaybackTimeMs, publishPlaybackTime]);\n\n const stopPlaybackTimeLoop = useCallback(() => {\n if (\n typeof window === \"undefined\" ||\n playbackAnimationFrameRef.current === null\n ) {\n return;\n }\n\n window.cancelAnimationFrame(playbackAnimationFrameRef.current);\n playbackAnimationFrameRef.current = null;\n }, []);\n\n const startPlaybackTimeLoop = useCallback(() => {\n if (\n typeof window === \"undefined\" ||\n playbackAnimationFrameRef.current !== null\n ) {\n return;\n }\n\n const updateFrame = () => {\n syncPlaybackTime();\n\n const audioElement = audioRef.current;\n\n if (!audioElement || audioElement.paused || audioElement.ended) {\n playbackAnimationFrameRef.current = null;\n return;\n }\n\n playbackAnimationFrameRef.current =\n window.requestAnimationFrame(updateFrame);\n };\n\n playbackAnimationFrameRef.current =\n window.requestAnimationFrame(updateFrame);\n }, [syncPlaybackTime]);\n\n const resetAudio = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n stopPlaybackTimeLoop();\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = false;\n wasPlayingBeforeExternalPauseRef.current = false;\n activeSourceTypeRef.current = null;\n pendingSeekTimeRef.current = null;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n preferredSourceTypeRef.current = null;\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = null;\n currentSegmentIndexRef.current = 0;\n waitingSegmentIndexRef.current = null;\n publishPlaybackTime(0);\n setIsPlaying(false);\n updateLoading(false);\n }, [publishPlaybackTime, stopPlaybackTimeLoop, updateLoading]);\n\n const tryPlayCurrentAudio = useCallback(\n (_reason: string) => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return false;\n }\n\n const playPromise = audioElement.play();\n\n if (playPromise && typeof playPromise.then === \"function\") {\n void playPromise\n .then(() => {\n if (playbackAccessModeRef.current === \"unknown\") {\n playbackAccessModeRef.current = \"auto\";\n }\n\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n })\n .catch((error: unknown) => {\n if (\n playbackAccessModeRef.current === \"unknown\" &&\n isAutoplayBlockedError(error)\n ) {\n // Lock autoplay after the first browser rejection.\n playbackAccessModeRef.current = \"blocked\";\n pendingAutoPlayRef.current = false;\n updateLoading(false);\n }\n\n isSwitchingSegmentRef.current = false;\n setIsPlaying(false);\n });\n }\n\n return true;\n },\n [isAutoplayBlockedError, updateLoading]\n );\n\n const startSegmentPlayback = useCallback(\n (segmentIndex: number, _reason: string) => {\n const audioElement = audioRef.current;\n const segment = currentAudioSegmentsRef.current[segmentIndex];\n\n if (!audioElement || !segment) {\n return false;\n }\n\n const nextAudioSrc = getSegmentSrc(segment.audio_data);\n\n currentSegmentIndexRef.current = segmentIndex;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = true;\n preferredSourceTypeRef.current = \"segment\";\n publishPlaybackTime(getSegmentStartTimeMs(segmentIndex));\n const shouldAutoResume = canStartPlaybackAutomatically();\n\n pendingAutoPlayRef.current = shouldAutoResume;\n updateLoading(false);\n\n const hasNewSrc = audioSrcRef.current !== nextAudioSrc;\n\n activeSourceTypeRef.current = \"segment\";\n\n if (hasNewSrc) {\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = nextAudioSrc;\n audioElement.src = nextAudioSrc;\n audioElement.load();\n }\n\n pendingSeekTimeRef.current = 0;\n\n if (audioElement.readyState > 0) {\n audioElement.currentTime = 0;\n pendingSeekTimeRef.current = null;\n }\n\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return true;\n }\n\n return tryPlayCurrentAudio(`start-segment:${_reason}`);\n },\n [\n canStartPlaybackAutomatically,\n getSegmentSrc,\n getSegmentStartTimeMs,\n publishPlaybackTime,\n tryPlayCurrentAudio,\n updateLoading,\n ]\n );\n\n const finishAudioItem = useCallback(\n (_reason?: string) => {\n stopPlaybackTimeLoop();\n pendingAutoPlayRef.current = false;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n syncPlaybackTime();\n setIsPlaying(false);\n updateLoading(false);\n\n if (currentAudioIndex >= 0) {\n onEnded?.(currentAudioIndex);\n }\n },\n [\n currentAudioIndex,\n onEnded,\n stopPlaybackTimeLoop,\n syncPlaybackTime,\n updateLoading,\n ]\n );\n\n const finishUrlAudioIfSeekedToEnd = useCallback(\n (_reason: string) => {\n const audioElement = audioRef.current;\n\n if (!audioElement || activeSourceTypeRef.current !== \"url\") {\n return false;\n }\n\n if (\n !hasReachedAudioEnd({\n currentTimeSeconds: Math.max(audioElement.currentTime, 0),\n durationSeconds: audioElement.duration,\n })\n ) {\n return false;\n }\n\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n finishAudioItem(_reason);\n return true;\n },\n [finishAudioItem]\n );\n\n const handleSegmentEnded = useCallback(() => {\n const nextSegmentIndex = currentSegmentIndexRef.current + 1;\n const segments = currentAudioSegmentsRef.current;\n const nextSegment = segments[nextSegmentIndex];\n const activeAudio = currentAudioRef.current;\n const hasFinal = segments.some((segment) => segment.is_final);\n\n if (nextSegment) {\n startSegmentPlayback(nextSegmentIndex, \"ended\");\n return;\n }\n\n if (activeAudio?.isAudioStreaming || !hasFinal) {\n currentSegmentIndexRef.current = nextSegmentIndex;\n waitingSegmentIndexRef.current = nextSegmentIndex;\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = defaultPlaying;\n publishPlaybackTime(getSegmentStartTimeMs(nextSegmentIndex));\n setIsPlaying(false);\n updateLoading(true, \"waitingForMoreAudio\");\n\n return;\n }\n\n finishAudioItem(\"segments-completed\");\n }, [\n defaultPlaying,\n finishAudioItem,\n getSegmentStartTimeMs,\n publishPlaybackTime,\n startSegmentPlayback,\n updateLoading,\n ]);\n\n useEffect(() => {\n if (currentAudioKeyRef.current === currentAudioKey) {\n return;\n }\n\n currentAudioKeyRef.current = currentAudioKey;\n currentSegmentIndexRef.current = 0;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n isPausedByUserRef.current = false;\n wasPlayingBeforeExternalPauseRef.current = false;\n pendingAutoPlayRef.current = false;\n isSwitchingSegmentRef.current = false;\n activeSourceTypeRef.current = null;\n preferredSourceTypeRef.current = null;\n audioSrcRef.current = null;\n stopPlaybackTimeLoop();\n publishPlaybackTime(0);\n updateLoading(false);\n\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n setIsPlaying(false);\n }, [\n currentAudioIndex,\n currentAudioKey,\n currentAudioSegments.length,\n currentAudioUrl,\n publishPlaybackTime,\n stopPlaybackTimeLoop,\n updateLoading,\n ]);\n\n useEffect(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n if (isPlaybackPaused) {\n wasPlayingBeforeExternalPauseRef.current = Boolean(\n currentAudioRef.current &&\n !isPausedByUserRef.current &&\n (!audioElement.paused ||\n pendingAutoPlayRef.current ||\n waitingSegmentIndexRef.current !== null)\n );\n\n pendingAutoPlayRef.current = false;\n updateLoading(false);\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (\n !wasPlayingBeforeExternalPauseRef.current ||\n !currentAudioRef.current ||\n isPausedByUserRef.current\n ) {\n return;\n }\n\n wasPlayingBeforeExternalPauseRef.current = false;\n\n if (waitingSegmentIndexRef.current !== null) {\n if (\n waitingSegmentIndexRef.current < currentAudioSegmentsRef.current.length\n ) {\n startSegmentPlayback(waitingSegmentIndexRef.current, \"external-resume\");\n return;\n }\n\n pendingAutoPlayRef.current = true;\n updateLoading(true, \"waitingForMoreAudio\");\n return;\n }\n\n if (!audioSrcRef.current && currentAudioSegmentsRef.current.length > 0) {\n startSegmentPlayback(\n Math.min(\n currentSegmentIndexRef.current,\n currentAudioSegmentsRef.current.length - 1\n ),\n \"external-resume-init\"\n );\n return;\n }\n\n if (!audioElement.paused) {\n return;\n }\n\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"external-resume\");\n }, [\n isPlaybackPaused,\n startSegmentPlayback,\n tryPlayCurrentAudio,\n updateLoading,\n ]);\n\n useEffect(() => {\n const audioElement = audioRef.current;\n\n if (!audioElement) {\n return;\n }\n\n if (!currentAudio) {\n resetAudio();\n return;\n }\n\n if (isPlaybackPaused) {\n pendingAutoPlayRef.current = false;\n updateLoading(false);\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n const resolvedSourceType = resolveAudioPlaybackSourceType({\n activeSourceType: activeSourceTypeRef.current,\n hasAudioUrl: Boolean(currentAudioUrl),\n segmentCount: currentAudioSegments.length,\n preferredSourceType: preferredSourceTypeRef.current,\n waitingSegmentIndex: waitingSegmentIndexRef.current,\n });\n\n if (\n resolvedSourceType &&\n preferredSourceTypeRef.current !== resolvedSourceType\n ) {\n preferredSourceTypeRef.current = resolvedSourceType;\n }\n\n if (resolvedSourceType === \"url\" && currentAudioUrl) {\n const hasNewSrc = audioSrcRef.current !== currentAudioUrl;\n const shouldAutoResume = canStartPlaybackAutomatically();\n\n if (hasNewSrc) {\n const nextSeekTime =\n waitingSegmentIndexRef.current !== null\n ? getWaitingSegmentSeekTime()\n : 0;\n\n audioElement.pause();\n audioElement.removeAttribute(\"src\");\n audioElement.load();\n audioSrcRef.current = currentAudioUrl;\n activeSourceTypeRef.current = \"url\";\n audioElement.src = currentAudioUrl;\n audioElement.load();\n pendingSeekTimeRef.current = nextSeekTime;\n publishPlaybackTime(nextSeekTime * 1000);\n\n if (audioElement.readyState > 0) {\n audioElement.currentTime = nextSeekTime;\n pendingSeekTimeRef.current = null;\n }\n }\n\n pendingAutoPlayRef.current = shouldAutoResume;\n isWaitingForSegmentRef.current = false;\n isSwitchingSegmentRef.current = false;\n updateLoading(false);\n\n if (!shouldAutoResume) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n tryPlayCurrentAudio(hasNewSrc ? \"sync-url-init\" : \"sync-url\");\n return;\n }\n\n if (\n resolvedSourceType === \"segment\" &&\n waitingSegmentIndexRef.current !== null\n ) {\n if (waitingSegmentIndexRef.current < currentAudioSegments.length) {\n if (isPausedByUserRef.current) {\n setIsPlaying(false);\n updateLoading(false);\n return;\n }\n\n startSegmentPlayback(waitingSegmentIndexRef.current, \"wait-resume\");\n return;\n }\n\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = canStartPlaybackAutomatically();\n setIsPlaying(false);\n updateLoading(canStartPlaybackAutomatically());\n return;\n }\n\n if (resolvedSourceType === \"segment\" && !currentAudioSegments.length) {\n if (currentAudio.isAudioStreaming) {\n waitingSegmentIndexRef.current = currentSegmentIndexRef.current;\n isWaitingForSegmentRef.current = true;\n pendingAutoPlayRef.current = canStartPlaybackAutomatically();\n setIsPlaying(false);\n updateLoading(canStartPlaybackAutomatically());\n return;\n }\n\n resetAudio();\n return;\n }\n\n if (resolvedSourceType === \"segment\" && !audioSrcRef.current) {\n startSegmentPlayback(\n Math.min(\n currentSegmentIndexRef.current,\n currentAudioSegments.length - 1\n ),\n \"effect-init\"\n );\n return;\n }\n\n if (resolvedSourceType !== \"segment\") {\n resetAudio();\n return;\n }\n\n if (!defaultPlaying || isPausedByUserRef.current) {\n pendingAutoPlayRef.current = false;\n audioElement.pause();\n setIsPlaying(false);\n return;\n }\n\n if (audioElement.paused) {\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"sync-paused-retry\");\n }\n }, [\n currentAudio,\n currentAudioIndex,\n currentAudioSegments,\n currentAudioUrl,\n defaultPlaying,\n isPlaybackPaused,\n canStartPlaybackAutomatically,\n publishPlaybackTime,\n resetAudio,\n startSegmentPlayback,\n tryPlayCurrentAudio,\n getWaitingSegmentSeekTime,\n updateLoading,\n ]);\n\n useEffect(() => resetAudio, [resetAudio]);\n\n useEffect(() => stopPlaybackTimeLoop, [stopPlaybackTimeLoop]);\n\n const handleAudioPlay = useCallback(() => {\n syncPlaybackTime();\n startPlaybackTimeLoop();\n setIsPlaying(true);\n updateLoading(false);\n onPlaybackStarted?.();\n }, [\n onPlaybackStarted,\n startPlaybackTimeLoop,\n syncPlaybackTime,\n updateLoading,\n ]);\n\n const handleAudioPause = useCallback(() => {\n if (isWaitingForSegmentRef.current || isSwitchingSegmentRef.current) {\n return;\n }\n\n stopPlaybackTimeLoop();\n syncPlaybackTime();\n setIsPlaying(false);\n }, [currentAudioIndex, stopPlaybackTimeLoop, syncPlaybackTime]);\n\n const handleAudioCanPlay = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (audioElement && pendingSeekTimeRef.current !== null) {\n audioElement.currentTime = pendingSeekTimeRef.current;\n pendingSeekTimeRef.current = null;\n }\n\n syncPlaybackTime();\n\n if (finishUrlAudioIfSeekedToEnd(\"canplay-seek-finished\")) {\n return;\n }\n\n if (!pendingAutoPlayRef.current || !defaultPlaying) {\n return;\n }\n\n tryPlayCurrentAudio(\"canplay\");\n }, [\n currentAudioIndex,\n defaultPlaying,\n finishUrlAudioIfSeekedToEnd,\n syncPlaybackTime,\n tryPlayCurrentAudio,\n ]);\n\n const handleLoadedMetadata = useCallback(() => {\n const audioElement = audioRef.current;\n\n if (audioElement && pendingSeekTimeRef.current !== null) {\n audioElement.currentTime = pendingSeekTimeRef.current;\n pendingSeekTimeRef.current = null;\n }\n\n syncPlaybackTime();\n\n finishUrlAudioIfSeekedToEnd(\"metadata-seek-finished\");\n }, [currentAudioIndex, finishUrlAudioIfSeekedToEnd, syncPlaybackTime]);\n\n const handleAudioTimeUpdate = useCallback(() => {\n syncPlaybackTime();\n }, [syncPlaybackTime]);\n\n const handleAudioLoadStart = useCallback(() => {\n if (isWaitingForSegmentRef.current) {\n return;\n }\n\n updateLoading(true, \"loadingAudio\");\n }, [updateLoading]);\n\n const handleAudioWaiting = useCallback(() => {\n if (isWaitingForSegmentRef.current) {\n updateLoading(true, \"waitingForMoreAudio\");\n return;\n }\n\n updateLoading(true, \"loadingAudio\");\n }, [updateLoading]);\n\n const handleAudioSeeking = useCallback(() => {\n syncPlaybackTime();\n }, [syncPlaybackTime]);\n\n const handleAudioEnded = useCallback(() => {\n const shouldFinishAsUrl =\n activeSourceTypeRef.current === \"url\" ||\n currentAudioSegmentsRef.current.length === 0;\n\n stopPlaybackTimeLoop();\n isSwitchingSegmentRef.current = false;\n\n if (shouldFinishAsUrl) {\n finishAudioItem(\"url-ended\");\n return;\n }\n\n handleSegmentEnded();\n }, [finishAudioItem, handleSegmentEnded, stopPlaybackTimeLoop]);\n\n const handleAudioError = useCallback(() => {\n stopPlaybackTimeLoop();\n syncPlaybackTime();\n setIsPlaying(false);\n updateLoading(false);\n }, [stopPlaybackTimeLoop, syncPlaybackTime, updateLoading]);\n const handleMobileViewModeChange = useCallback(\n (nextViewMode: MobileViewMode) => {\n onMobileViewModeChange?.(nextViewMode);\n setIsMobileMoreOpen(false);\n },\n [onMobileViewModeChange]\n );\n\n useEffect(() => {\n onPlaybackTimeChange?.(playbackTimeMsRef.current);\n }, [onPlaybackTimeChange]);\n\n return (\n <div className={cn(\"slide-player\", className)} {...props}>\n <audio\n ref={audioRef}\n preload=\"auto\"\n playsInline\n onLoadStart={handleAudioLoadStart}\n onLoadedMetadata={handleLoadedMetadata}\n onCanPlay={handleAudioCanPlay}\n onPlay={handleAudioPlay}\n onPause={handleAudioPause}\n onWaiting={handleAudioWaiting}\n onSeeking={handleAudioSeeking}\n onSeeked={handleAudioSeeking}\n onTimeUpdate={handleAudioTimeUpdate}\n onEnded={handleAudioEnded}\n onError={handleAudioError}\n />\n\n {showControls ? (\n <>\n <MobilePlayerSettingsSheet\n container={settingsPortalContainer}\n labels={{\n fullscreen: playerTexts.fullscreenLabel,\n nonFullscreen: playerTexts.nonFullscreenLabel,\n screen: playerTexts.screenLabel,\n subtitle: playerTexts.subtitleLabel,\n subtitleToggle: playerTexts.subtitleToggleAriaLabel,\n title: playerTexts.settingsTitle,\n }}\n isSubtitleEnabled={isSubtitleEnabled}\n onClose={() => setIsMobileMoreOpen(false)}\n onOpenChange={setIsMobileMoreOpen}\n onSubtitleToggle={onSubtitleToggle ?? (() => {})}\n onViewModeChange={handleMobileViewModeChange}\n open={isMobileMoreOpen}\n viewMode={mobileViewMode}\n />\n\n <div className=\"slide-player__controls\" style={controlsStyle}>\n <div className=\"slide-player__group\">\n <button\n aria-expanded={isMobileMoreOpen}\n aria-haspopup=\"dialog\"\n aria-label=\"More options\"\n className=\"slide-player__action slide-player__action--mobile-more\"\n onClick={() => {\n setIsMobileMoreOpen((prevOpen) => !prevOpen);\n }}\n type=\"button\"\n >\n <EllipsisVertical\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n </button>\n <button aria-label=\"Volume\" className=\"hidden\" type=\"button\">\n <Volume2 className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n <button\n aria-label={playerTexts.subtitleToggleAriaLabel}\n aria-pressed={isSubtitleEnabled}\n className=\"slide-player__action slide-player__action--subtitle\"\n onClick={onSubtitleToggle}\n type=\"button\"\n >\n {isSubtitleEnabled ? (\n <Captions className=\"slide-player__icon\" strokeWidth={2.25} />\n ) : (\n <CaptionsOff\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n )}\n </button>\n <button\n aria-label=\"Rewind\"\n className=\"slide-player__action slide-player__action--prev\"\n disabled={prevDisabled}\n onClick={onPrev}\n type=\"button\"\n >\n <RotateCcw className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n <button\n aria-label={toggleAriaLabel}\n className=\"slide-player__toggle slide-player__toggle--playback\"\n onClick={() => {\n if (useAutoAdvanceToggle) {\n onAutoAdvanceToggle?.(!isAutoAdvanceEnabled);\n return;\n }\n\n const audioElement = audioRef.current;\n\n if (isPlaybackPaused || !audioElement || !currentAudio) {\n return;\n }\n\n if (waitingSegmentIndexRef.current !== null) {\n if (isPlaying) {\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = true;\n waitingSegmentIndexRef.current = null;\n isWaitingForSegmentRef.current = false;\n setIsPlaying(false);\n updateLoading(false);\n audioElement.pause();\n return;\n }\n\n playbackAccessModeRef.current = \"manual\";\n isPausedByUserRef.current = false;\n pendingAutoPlayRef.current = true;\n updateLoading(true, \"waitingForMoreAudio\");\n return;\n }\n\n if (!audioElement.src && currentAudioSegments.length > 0) {\n playbackAccessModeRef.current = \"manual\";\n isPausedByUserRef.current = false;\n startSegmentPlayback(\n Math.min(\n currentSegmentIndexRef.current,\n currentAudioSegments.length - 1\n ),\n \"toggle\"\n );\n return;\n }\n\n if (audioElement.paused) {\n playbackAccessModeRef.current = \"manual\";\n isPausedByUserRef.current = false;\n pendingAutoPlayRef.current = true;\n tryPlayCurrentAudio(\"toggle-resume\");\n return;\n }\n\n pendingAutoPlayRef.current = false;\n isPausedByUserRef.current = true;\n audioElement.pause();\n }}\n type=\"button\"\n >\n {isTogglePlaying ? <PauseIcon /> : <PlayIcon />}\n </button>\n <button\n aria-label=\"Forward\"\n className=\"slide-player__action slide-player__action--next\"\n disabled={nextDisabled}\n onClick={onNext}\n type=\"button\"\n >\n <RotateCw className=\"slide-player__icon\" strokeWidth={2.25} />\n </button>\n {onFullscreen ? (\n <button\n aria-label={\n isFullscreen ? \"Exit fullscreen\" : \"Enter fullscreen\"\n }\n className=\"slide-player__action slide-player__action--fullscreen\"\n onClick={onFullscreen}\n type=\"button\"\n >\n {isFullscreen ? (\n <ScanLine\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n ) : (\n <Maximize\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n )}\n </button>\n ) : null}\n </div>\n\n <div className=\"slide-player__separator\" />\n\n <div className=\"slide-player__group\">\n {customActionList.map((customAction, customActionIndex) => (\n <React.Fragment key={`custom-action-${customActionIndex}`}>\n {customAction}\n </React.Fragment>\n ))}\n <button\n aria-label=\"Notes\"\n className={cn(\n \"slide-player__action slide-player__action--notes\",\n isInteractionOpen && \"slide-player__action--active\"\n )}\n disabled={!hasInteraction}\n onClick={onInteractionToggle}\n type=\"button\"\n >\n <FilePenLine\n className=\"slide-player__icon\"\n strokeWidth={2.25}\n />\n </button>\n </div>\n </div>\n </>\n ) : null}\n </div>\n );\n};\n\nconst MemoizedPlayer = memo(Player);\n\nMemoizedPlayer.displayName = \"Player\";\n\nexport default MemoizedPlayer;\n"],"names":["audioPreloadElementCache","preloadAudioUrl","url","audio","PauseIcon","jsxs","jsx","PlayIcon","Player","audioList","className","currentAudioIndex","defaultPlaying","isPlaybackPaused","isAutoAdvanceEnabled","useAutoAdvanceToggle","onLoadingChange","onPlaybackStarted","onPlaybackTimeChange","onSubtitleToggle","onPrev","onNext","onFullscreen","isFullscreen","mobileViewMode","DEFAULT_MOBILE_VIEW_MODE","settingsPortalContainer","onMobileViewModeChange","onEnded","onAutoAdvanceToggle","onInteractionToggle","hasInteraction","isInteractionOpen","isSubtitleEnabled","prevDisabled","nextDisabled","showControls","customActions","customActionContext","texts","props","audioRef","useRef","previousInteractionOpenRef","audioSrcRef","currentAudioKeyRef","currentSegmentIndexRef","waitingSegmentIndexRef","currentAudioRef","currentAudioSegmentsRef","wasPlayingBeforeExternalPauseRef","isLoadingRef","isPausedByUserRef","activeSourceTypeRef","preferredSourceTypeRef","isWaitingForSegmentRef","pendingAutoPlayRef","pendingSeekTimeRef","isSwitchingSegmentRef","playbackAnimationFrameRef","playbackTimeMsRef","playbackAccessModeRef","isPlaying","setIsPlaying","useState","isMobileMoreOpen","setIsMobileMoreOpen","currentAudio","currentAudioUrl","currentAudioSegments","useMemo","prevSegment","nextSegment","customActionList","toPlayerCustomActionList","mobileVisibleActionCount","controlsStyle","playerTexts","DEFAULT_SLIDE_PLAYER_TEXTS","currentAudioKey","isTogglePlaying","toggleAriaLabel","useEffect","currentUrl","nextUrl","updateLoading","useCallback","loading","reason","isAutoplayBlockedError","error","canStartPlaybackAutomatically","getSegmentSrc","audioData","getWaitingSegmentSeekTime","waitingSegmentIndex","totalDurationMs","segment","getSegmentStartTimeMs","segmentIndex","getCurrentPlaybackTimeMs","audioElement","publishPlaybackTime","timeMs","nextPlaybackTimeMs","syncPlaybackTime","stopPlaybackTimeLoop","startPlaybackTimeLoop","updateFrame","resetAudio","tryPlayCurrentAudio","_reason","playPromise","startSegmentPlayback","nextAudioSrc","shouldAutoResume","hasNewSrc","finishAudioItem","finishUrlAudioIfSeekedToEnd","hasReachedAudioEnd","handleSegmentEnded","nextSegmentIndex","segments","activeAudio","hasFinal","resolvedSourceType","resolveAudioPlaybackSourceType","nextSeekTime","handleAudioPlay","handleAudioPause","handleAudioCanPlay","handleLoadedMetadata","handleAudioTimeUpdate","handleAudioLoadStart","handleAudioWaiting","handleAudioSeeking","handleAudioEnded","shouldFinishAsUrl","handleAudioError","handleMobileViewModeChange","nextViewMode","cn","Fragment","MobilePlayerSettingsSheet","prevOpen","EllipsisVertical","Volume2","Captions","CaptionsOff","RotateCcw","RotateCw","ScanLine","Maximize","customAction","customActionIndex","React","FilePenLine","MemoizedPlayer","memo"],"mappings":"y0DAwCMA,OAA+B,IAc/BC,GAAmBC,GAAiB,CAKxC,GAJI,OAAO,OAAW,KAAe,CAACA,GAIlCF,GAAyB,IAAIE,CAAG,EAClC,OAKF,MAAMC,EAAQ,OAAO,SAAS,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