@hyperframes/studio 0.8.49 → 0.8.51

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 (281) hide show
  1. package/dist/assets/{hyperframes-player-CqON2Rzo.js → hyperframes-player-Cn_PpHqP.js} +3 -3
  2. package/dist/assets/index-C05SNrvY.js +360 -0
  3. package/dist/assets/{index-mIgSsKqs.js → index-CPS3Cvj8.js} +1 -1
  4. package/dist/assets/{index-BGovDksE.js → index-Clrb11lj.js} +1 -1
  5. package/dist/assets/index-DUR9qzQM.css +1 -0
  6. package/dist/index.d.ts +29 -16
  7. package/dist/index.html +2 -2
  8. package/dist/index.js +7283 -8606
  9. package/dist/index.js.map +1 -1
  10. package/dist/styles/tailwind-preset.js.map +1 -1
  11. package/package.json +11 -12
  12. package/src/App.tsx +132 -143
  13. package/src/captions/components/CaptionAnimationPanel.tsx +4 -4
  14. package/src/captions/components/CaptionOverlayUtils.ts +2 -3
  15. package/src/captions/components/CaptionPropertyPanel.tsx +3 -3
  16. package/src/captions/components/CaptionTimeline.tsx +1 -1
  17. package/src/captions/components/shared.tsx +2 -2
  18. package/src/components/AskAgentModal.tsx +5 -5
  19. package/src/components/EditorShell.selectionSync.test.tsx +4 -0
  20. package/src/components/EditorShell.tsx +28 -7
  21. package/src/components/ExternalFileConflictBanner.tsx +16 -16
  22. package/src/components/LintModal.tsx +6 -16
  23. package/src/components/MediaPreview.tsx +2 -2
  24. package/src/components/SaveQueuePausedBanner.tsx +2 -2
  25. package/src/components/StudioHeader.tsx +2 -62
  26. package/src/components/StudioLeftSidebar.tsx +7 -4
  27. package/src/components/StudioOverlays.tsx +2 -6
  28. package/src/components/StudioRightPanel.tsx +4 -4
  29. package/src/components/StudioToast.tsx +2 -2
  30. package/src/components/TimelineToolbar.tsx +7 -7
  31. package/src/components/dock/Dock.test.tsx +192 -0
  32. package/src/components/dock/Dock.tsx +264 -0
  33. package/src/components/dock/dock.css +23 -0
  34. package/src/components/dock/dockLayout.ts +58 -0
  35. package/src/components/dock/dockLayoutSchema.ts +66 -0
  36. package/src/components/dock/dockLayoutStore.ts +91 -0
  37. package/src/components/dock/panelRegistry.ts +67 -0
  38. package/src/components/editor/AnimationCard.tsx +4 -4
  39. package/src/components/editor/AnimationCardParts.tsx +6 -6
  40. package/src/components/editor/BlockParamsPanel.tsx +4 -4
  41. package/src/components/editor/BorderRadiusEditor.tsx +1 -1
  42. package/src/components/editor/CanvasContextMenu.tsx +1 -1
  43. package/src/components/editor/ComputedTweenNotice.tsx +1 -1
  44. package/src/components/editor/DomEditOverlay.tsx +1 -1
  45. package/src/components/editor/EaseCurveSection.tsx +1 -1
  46. package/src/components/editor/EaseParamFields.tsx +5 -5
  47. package/src/components/editor/FileTree.tsx +4 -4
  48. package/src/components/editor/FileTreeIcons.tsx +1 -1
  49. package/src/components/editor/FileTreeNodes.tsx +13 -13
  50. package/src/components/editor/InlineTextToolbar.tsx +1 -1
  51. package/src/components/editor/InspectorHeaderActions.tsx +3 -3
  52. package/src/components/editor/KeyframeDiamond.tsx +1 -1
  53. package/src/components/editor/KeyframeEaseList.tsx +1 -1
  54. package/src/components/editor/LayersPanel.tsx +3 -3
  55. package/src/components/editor/MarqueeOverlay.tsx +1 -1
  56. package/src/components/editor/OffCanvasIndicators.tsx +1 -1
  57. package/src/components/editor/PreviewGuides.test.tsx +88 -0
  58. package/src/components/editor/PreviewGuides.tsx +125 -0
  59. package/src/components/editor/PromotableControl.tsx +2 -2
  60. package/src/components/editor/PropertyPanelEmptyState.tsx +7 -7
  61. package/src/components/editor/PropertyPanelFlatHeader.tsx +2 -2
  62. package/src/components/editor/SnapToolbar.test.tsx +21 -0
  63. package/src/components/editor/SnapToolbar.tsx +27 -3
  64. package/src/components/editor/TimelineFxPopover.tsx +1 -1
  65. package/src/components/editor/TopologyLens.tsx +4 -4
  66. package/src/components/editor/Transform3DCube.tsx +2 -2
  67. package/src/components/editor/audioFxRevealTarget.ts +1 -0
  68. package/src/components/editor/domEditing.test.ts +1 -1
  69. package/src/components/editor/domEditingAgentPrompt.test.ts +8 -6
  70. package/src/components/editor/domEditingAgentPrompt.ts +9 -3
  71. package/src/components/editor/previewGuidesStore.ts +26 -0
  72. package/src/components/editor/propertyPanelColor.tsx +11 -11
  73. package/src/components/editor/propertyPanelColorCurveGraph.tsx +1 -1
  74. package/src/components/editor/propertyPanelColorGradingControls.tsx +7 -9
  75. package/src/components/editor/propertyPanelColorGradingSection.tsx +6 -6
  76. package/src/components/editor/propertyPanelColorGradingSlider.tsx +5 -5
  77. package/src/components/editor/propertyPanelColorWheels.tsx +1 -1
  78. package/src/components/editor/propertyPanelCommitField.tsx +1 -1
  79. package/src/components/editor/propertyPanelFill.tsx +4 -4
  80. package/src/components/editor/propertyPanelFlatColorGradingAccessory.tsx +3 -3
  81. package/src/components/editor/propertyPanelFlatColorGradingSection.tsx +7 -7
  82. package/src/components/editor/propertyPanelFlatEffectsSection.tsx +4 -4
  83. package/src/components/editor/propertyPanelFlatMediaSection.tsx +3 -3
  84. package/src/components/editor/propertyPanelFlatOverlaysSection.tsx +1 -1
  85. package/src/components/editor/propertyPanelFlatPrimitives.tsx +10 -10
  86. package/src/components/editor/propertyPanelFlatSelectRow.tsx +3 -3
  87. package/src/components/editor/propertyPanelFlatTextSection.test.tsx +8 -9
  88. package/src/components/editor/propertyPanelFlatTextSection.tsx +5 -5
  89. package/src/components/editor/propertyPanelFlatToggle.tsx +1 -1
  90. package/src/components/editor/propertyPanelFont.tsx +5 -5
  91. package/src/components/editor/propertyPanelFxCarveModule.tsx +1 -1
  92. package/src/components/editor/propertyPanelFxControls.test.tsx +1 -1
  93. package/src/components/editor/propertyPanelFxControls.tsx +6 -6
  94. package/src/components/editor/propertyPanelFxEqModule.tsx +2 -2
  95. package/src/components/editor/propertyPanelFxPresetStyle.ts +2 -2
  96. package/src/components/editor/propertyPanelGradingNumberField.tsx +1 -1
  97. package/src/components/editor/propertyPanelMediaSection.tsx +1 -1
  98. package/src/components/editor/propertyPanelPrimitives.tsx +7 -7
  99. package/src/components/editor/propertyPanelSections.tsx +8 -8
  100. package/src/components/feedback/StudioFeedbackCard.tsx +7 -7
  101. package/src/components/feedback/feedbackTrigger.ts +0 -1
  102. package/src/components/nle/AssetPreviewOverlay.tsx +6 -2
  103. package/src/components/nle/CompositionBreadcrumb.tsx +3 -3
  104. package/src/components/nle/NLEPreview.test.ts +13 -0
  105. package/src/components/nle/NLEPreview.tsx +12 -7
  106. package/src/components/nle/PreviewOverlays.tsx +6 -6
  107. package/src/components/nle/PreviewPane.test.tsx +52 -0
  108. package/src/components/nle/PreviewPane.tsx +4 -2
  109. package/src/components/nle/TimelinePane.tsx +17 -3
  110. package/src/components/nle/TimelineResizeDivider.tsx +2 -2
  111. package/src/components/nle/useCanvasZOrderTimelineMirror.test.tsx +1 -1
  112. package/src/components/nle/useCanvasZOrderTimelineMirror.ts +3 -3
  113. package/src/components/panels/SlideshowPanel.tsx +2 -2
  114. package/src/components/panels/SlideshowSubPanels.tsx +20 -17
  115. package/src/components/panels/VariablesBindElement.tsx +2 -2
  116. package/src/components/panels/VariablesDeclarationForm.tsx +2 -2
  117. package/src/components/panels/VariablesOtherCompositions.tsx +1 -1
  118. package/src/components/panels/VariablesPanel.tsx +3 -3
  119. package/src/components/panels/VariablesValueControls.tsx +2 -2
  120. package/src/components/renders/FfmpegRequiredNotice.tsx +5 -5
  121. package/src/components/renders/RenderQueue.test.tsx +7 -0
  122. package/src/components/renders/RenderQueue.tsx +6 -6
  123. package/src/components/renders/RenderQueueItem.tsx +6 -6
  124. package/src/components/sidebar/AssetCard.tsx +8 -8
  125. package/src/components/sidebar/AssetContextMenu.tsx +8 -8
  126. package/src/components/sidebar/AssetsTab.tsx +2 -2
  127. package/src/components/sidebar/AudioRow.tsx +6 -6
  128. package/src/components/sidebar/BlocksTab.tsx +6 -6
  129. package/src/components/sidebar/CompositionsTab.tsx +5 -5
  130. package/src/components/sidebar/GlobalAssetsView.tsx +1 -1
  131. package/src/components/sidebar/LeftSidebar.lintBadge.test.tsx +58 -0
  132. package/src/components/sidebar/LeftSidebar.tsx +19 -5
  133. package/src/components/sidebar/PromptPreviewModal.tsx +3 -3
  134. package/src/components/ui/Button.test.tsx +60 -0
  135. package/src/components/ui/Button.tsx +4 -4
  136. package/src/components/ui/SearchInput.tsx +2 -2
  137. package/src/components/ui/Tooltip.tsx +1 -1
  138. package/src/hooks/appHotkeysDispatch.ts +11 -0
  139. package/src/hooks/timelineAudioGroupCreate.ts +2 -2
  140. package/src/hooks/timelineTrackVisibility.ts +8 -11
  141. package/src/hooks/useAppHotkeys.textEditing.test.tsx +1 -0
  142. package/src/hooks/useAppHotkeys.ts +4 -1
  143. package/src/hooks/useAskAgentModal.ts +2 -0
  144. package/src/hooks/useClipboard.test.ts +234 -0
  145. package/src/hooks/useClipboard.ts +264 -70
  146. package/src/hooks/useGroupCommits.test.ts +0 -1
  147. package/src/hooks/useLintModal.test.tsx +65 -0
  148. package/src/hooks/useLintModal.ts +3 -0
  149. package/src/hooks/useRazorSplit.history.test.tsx +0 -1
  150. package/src/hooks/useRazorSplit.test.ts +0 -2
  151. package/src/hooks/useRazorSplit.test.tsx +0 -1
  152. package/src/hooks/useSdkSession.lifecycle.test.tsx +49 -4
  153. package/src/hooks/useSdkSession.ts +43 -10
  154. package/src/hooks/useStudioContextValue.ts +5 -19
  155. package/src/hooks/useTimelineAssetDropOps.test.tsx +41 -1
  156. package/src/hooks/useTimelineAssetDropOps.ts +52 -11
  157. package/src/hooks/useTimelineEditing.test.tsx +0 -1
  158. package/src/main.tsx +9 -3
  159. package/src/player/components/AudioWaveform.tsx +1 -1
  160. package/src/player/components/AutomationSelectionMenu.tsx +2 -2
  161. package/src/player/components/ClipContextMenu.tsx +90 -10
  162. package/src/player/components/CompositionThumbnail.test.ts +0 -3
  163. package/src/player/components/CompositionThumbnail.tsx +3 -4
  164. package/src/player/components/EditModal.tsx +1 -1
  165. package/src/player/components/ImageThumbnail.tsx +1 -1
  166. package/src/player/components/KeyframeDiamondContextMenu.tsx +4 -4
  167. package/src/player/components/LayerDisclosureRow.tsx +2 -2
  168. package/src/player/components/PlayerControls.tsx +1 -1
  169. package/src/player/components/ShortcutsPanel.tsx +9 -9
  170. package/src/player/components/SpeedMenu.tsx +3 -5
  171. package/src/player/components/Timeline.tsx +16 -15
  172. package/src/player/components/TimelineCanvas.tsx +45 -8
  173. package/src/player/components/TimelineDiamondConnectors.tsx +1 -1
  174. package/src/player/components/TimelineEmptyState.tsx +5 -5
  175. package/src/player/components/TimelineFxButton.tsx +6 -6
  176. package/src/player/components/TimelineGestureOverlay.test.tsx +35 -1
  177. package/src/player/components/TimelineGestureOverlay.tsx +1 -1
  178. package/src/player/components/TimelineGroupHeader.tsx +5 -5
  179. package/src/player/components/TimelineGroupLaneLabels.tsx +1 -1
  180. package/src/player/components/TimelineGroupRow.tsx +1 -1
  181. package/src/player/components/TimelineLanes.test.tsx +54 -1
  182. package/src/player/components/TimelineLanes.tsx +2 -5
  183. package/src/player/components/TimelineLayerGroupHeader.tsx +2 -2
  184. package/src/player/components/TimelineOverlays.tsx +12 -0
  185. package/src/player/components/TimelineRuler.tsx +1 -1
  186. package/src/player/components/TimelineShortcutHint.tsx +1 -1
  187. package/src/player/components/TimelineTrackHeader.tsx +1 -1
  188. package/src/player/components/TimelineTrackPlainHeader.tsx +3 -3
  189. package/src/player/components/TimelineTypes.ts +6 -1
  190. package/src/player/components/TrackGapContextMenu.tsx +1 -1
  191. package/src/player/components/VideoThumbnail.tsx +4 -2
  192. package/src/player/components/VolumeControl.tsx +2 -2
  193. package/src/player/components/timelineAuthoredMoveTarget.ts +1 -2
  194. package/src/player/components/timelineCallbacks.ts +8 -8
  195. package/src/player/components/timelineClipChildren.test.ts +2 -2
  196. package/src/player/components/timelineClipChildren.tsx +2 -1
  197. package/src/player/components/timelineClipDragCommit.ts +2 -2
  198. package/src/player/components/timelineClipDragPreview.ts +51 -27
  199. package/src/player/components/timelineClipDragTypes.ts +3 -0
  200. package/src/player/components/timelineDragDrop.test.tsx +92 -1
  201. package/src/player/components/timelineDragDrop.ts +82 -33
  202. package/src/player/components/timelineEditCapabilities.ts +1 -2
  203. package/src/player/components/timelineEditing.test.ts +0 -16
  204. package/src/player/components/timelineGroupEditing.test.ts +1 -3
  205. package/src/player/components/timelineGroupEditing.ts +0 -1
  206. package/src/player/components/timelineLaneProps.ts +3 -0
  207. package/src/player/components/timelineSnapping.test.ts +27 -0
  208. package/src/player/components/timelineSnapping.ts +14 -1
  209. package/src/player/components/timelineTrackDisplay.ts +1 -1
  210. package/src/player/components/timelineTrackPersistPipeline.test.ts +0 -53
  211. package/src/player/components/trackHeaderLabelRows.tsx +4 -4
  212. package/src/player/components/useTimelineClipContextMenu.ts +32 -0
  213. package/src/player/components/useTimelineClipDrag.resize.test.tsx +136 -2
  214. package/src/player/components/useTimelineClipDrag.ts +30 -3
  215. package/src/player/components/useTimelineTrackDerivations.ts +1 -1
  216. package/src/player/hooks/timelineDomBinding.test.ts +0 -3
  217. package/src/player/hooks/timelineSyncHydration.test.ts +18 -0
  218. package/src/player/hooks/timelineSyncHydration.ts +37 -18
  219. package/src/player/hooks/useTimelinePlayer.test.ts +3 -20
  220. package/src/player/hooks/useTimelineRowElements.test.ts +28 -0
  221. package/src/player/hooks/useTimelineRowElements.ts +17 -0
  222. package/src/player/hooks/useTimelineSyncCallbacks.emptyManifest.test.tsx +41 -0
  223. package/src/player/hooks/useTimelineSyncCallbacks.ts +9 -10
  224. package/src/player/lib/describeClips.test.ts +95 -0
  225. package/src/player/lib/describeClips.ts +52 -0
  226. package/src/player/lib/timelineDOM.test.ts +0 -80
  227. package/src/player/lib/timelineDOM.ts +1 -61
  228. package/src/player/lib/timelineElementHelpers.ts +2 -53
  229. package/src/player/store/playerStore.ts +5 -0
  230. package/src/player/store/timelineElement.ts +1 -3
  231. package/src/shims/canvasBrowserStub.js +50 -0
  232. package/src/styles/iconTokens.ts +20 -0
  233. package/src/styles/palette-reset.css +6 -0
  234. package/src/styles/studio.css +24 -21
  235. package/src/styles/tailwind-preset.shared.js +3 -0
  236. package/src/styles/theme.css +213 -0
  237. package/src/styles/theme.test.ts +196 -0
  238. package/src/utils/clipboardPayload.test.ts +42 -2
  239. package/src/utils/clipboardPayload.ts +57 -32
  240. package/src/utils/previewSafeMargins.test.ts +34 -0
  241. package/src/utils/previewSafeMargins.ts +10 -0
  242. package/src/utils/razorSplitTransaction.test.ts +0 -1
  243. package/src/utils/sdkCanvasComposition.test.ts +77 -0
  244. package/src/utils/studioUiPreferences.test.ts +43 -0
  245. package/src/utils/studioUiPreferences.ts +34 -6
  246. package/src/utils/timelineDropTrackInsert.test.ts +134 -0
  247. package/src/utils/timelineDropTrackInsert.ts +83 -0
  248. package/src/utils/timelineElementSplit.test.ts +1 -2
  249. package/src/utils/timelineElementSplit.ts +0 -1
  250. package/src/webmcp/tools/lookTools.test.ts +40 -0
  251. package/src/webmcp/tools/lookTools.ts +32 -1
  252. package/dist/assets/index-B9LfWNyM.css +0 -1
  253. package/dist/assets/index-Bgmx2h7W.js +0 -441
  254. package/src/components/StudioGlobalDragOverlay.tsx +0 -24
  255. package/src/components/storyboard/AgentChatMessageButton.test.tsx +0 -47
  256. package/src/components/storyboard/AgentChatMessageButton.tsx +0 -45
  257. package/src/components/storyboard/FramePoster.test.tsx +0 -61
  258. package/src/components/storyboard/FramePoster.tsx +0 -86
  259. package/src/components/storyboard/StoryboardDirection.tsx +0 -45
  260. package/src/components/storyboard/StoryboardFrameFocus.tsx +0 -412
  261. package/src/components/storyboard/StoryboardFrameTile.tsx +0 -117
  262. package/src/components/storyboard/StoryboardGrid.tsx +0 -55
  263. package/src/components/storyboard/StoryboardLoaded.tsx +0 -307
  264. package/src/components/storyboard/StoryboardReviewGuide.tsx +0 -300
  265. package/src/components/storyboard/StoryboardScriptPanel.tsx +0 -26
  266. package/src/components/storyboard/StoryboardSourceEditor.tsx +0 -231
  267. package/src/components/storyboard/StoryboardStatusLegend.tsx +0 -21
  268. package/src/components/storyboard/StoryboardView.tsx +0 -169
  269. package/src/components/storyboard/StoryboardViewModeGuard.test.tsx +0 -187
  270. package/src/components/storyboard/frameComments.test.ts +0 -95
  271. package/src/components/storyboard/frameComments.ts +0 -115
  272. package/src/components/storyboard/frameStatus.ts +0 -36
  273. package/src/components/storyboard/storyboardReviewStage.test.ts +0 -40
  274. package/src/components/storyboard/storyboardReviewStage.ts +0 -45
  275. package/src/components/storyboard/useFrameComments.ts +0 -98
  276. package/src/contexts/ViewModeContext.tsx +0 -142
  277. package/src/hooks/useProjectSignaturePoll.test.tsx +0 -135
  278. package/src/hooks/useProjectSignaturePoll.ts +0 -68
  279. package/src/hooks/useStoryboard.ts +0 -99
  280. package/src/player/hooks/useExpandedTimelineElements.test.ts +0 -774
  281. package/src/player/hooks/useExpandedTimelineElements.ts +0 -460
@@ -1,4 +1,4 @@
1
- var we=Object.defineProperty;var Ae=(s,i,e)=>i in s?we(s,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[i]=e;var u=(s,i,e)=>Ae(s,typeof i!="symbol"?i+"":i,e);import{r as ue,i as w,a as he,b as Ee,c as Te,s as Ce,d as Re}from"./index-Bgmx2h7W.js";function Se(s){return s.hasRuntime||s.runtimeInjected?!1:!!(s.hasNestedCompositions||s.hasTimelines&&s.attempts>=5)}function $(s){return typeof s=="object"&&s!==null}function xe(s){return $(s)&&typeof s.getDuration=="function"}function Le(s){return $(s)&&typeof s.duration=="function"&&typeof s.time=="function"&&typeof s.seek=="function"&&typeof s.play=="function"&&typeof s.pause=="function"}function Me(s){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(s))throw new Error(`Invalid HyperFrames runtime version: ${s}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${s}/dist/hyperframe.runtime.iife.js`}const H=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Me("0.0.0-dev");function V(s){if(s===null)return null;const i=Number.parseInt(s,10);return Number.isFinite(i)&&i>0?i:null}function De(s){const i=(s==null?void 0:s.querySelector("[data-composition-id][data-width][data-height]"))??(s==null?void 0:s.querySelector("[data-width][data-height]"));if(!i)return null;const e=V(i.getAttribute("data-width")),t=V(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}class Pe{constructor(i,e){u(this,"_interval",null);u(this,"_runtimeInjected",!1);this._iframe=i,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{var e;i++;try{const t=this._iframe.contentWindow;if(!t)return;const r=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(Se({hasRuntime:r,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:i})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;const d=this._resolvePlaybackDurationAdapter(t);if(d&&d.getDuration()>0){this.stop();const c=De(this._iframe.contentDocument);this._callbacks.onReady({duration:d.getDuration(),adapter:d,compositionSize:c});return}}catch{}i>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const i=this._iframe.contentWindow;return i?this._resolveDirectTimelineAdapterFromWindow(i):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(i){return this._resolveDirectTimelineAdapterFromWindow(i)}hasRuntimeBridge(i){return Reflect.get(i,"__hf")!==void 0||$(Reflect.get(i,"__player"))}_injectRuntime(){var i,e;this._runtimeInjected=!0;try{const t=this._iframe.contentDocument;if(!t)return;const r=t.createElement("script");r.src=H,(t.head||t.documentElement).appendChild(r),(e=(i=this._callbacks).onRuntimeInjected)==null||e.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(i){var d,c;if(this.hasRuntimeBridge(i))return null;const e=Reflect.get(i,"__timelines");if(!$(e))return null;const t=Object.keys(e);if(t.length===0)return null;const r=(c=(d=this._iframe.contentDocument)==null?void 0:d.querySelector("[data-composition-id]"))==null?void 0:c.getAttribute("data-composition-id"),n=r&&r in e?r:t[t.length-1],o=e[n];return Le(o)?o:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(xe(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const ke=`
1
+ var we=Object.defineProperty;var Ae=(s,i,e)=>i in s?we(s,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[i]=e;var u=(s,i,e)=>Ae(s,typeof i!="symbol"?i+"":i,e);import{r as ue,i as w,a as he,b as Ee,c as Te,s as Ce,d as Re}from"./index-C05SNrvY.js";function Se(s){return s.hasRuntime||s.runtimeInjected?!1:!!(s.hasNestedCompositions||s.hasTimelines&&s.attempts>=5)}function $(s){return typeof s=="object"&&s!==null}function xe(s){return $(s)&&typeof s.getDuration=="function"}function Le(s){return $(s)&&typeof s.duration=="function"&&typeof s.time=="function"&&typeof s.seek=="function"&&typeof s.play=="function"&&typeof s.pause=="function"}function Me(s){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(s))throw new Error(`Invalid HyperFrames runtime version: ${s}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${s}/dist/hyperframe.runtime.iife.js`}const H=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Me("0.0.0-dev");function V(s){if(s===null)return null;const i=Number.parseInt(s,10);return Number.isFinite(i)&&i>0?i:null}function De(s){const i=(s==null?void 0:s.querySelector("[data-composition-id][data-width][data-height]"))??(s==null?void 0:s.querySelector("[data-width][data-height]"));if(!i)return null;const e=V(i.getAttribute("data-width")),t=V(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}class Pe{constructor(i,e){u(this,"_interval",null);u(this,"_runtimeInjected",!1);this._iframe=i,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{var e;i++;try{const t=this._iframe.contentWindow;if(!t)return;const r=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(Se({hasRuntime:r,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:i})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;const d=this._resolvePlaybackDurationAdapter(t);if(d&&d.getDuration()>0){this.stop();const c=De(this._iframe.contentDocument);this._callbacks.onReady({duration:d.getDuration(),adapter:d,compositionSize:c});return}}catch{}i>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const i=this._iframe.contentWindow;return i?this._resolveDirectTimelineAdapterFromWindow(i):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(i){return this._resolveDirectTimelineAdapterFromWindow(i)}hasRuntimeBridge(i){return Reflect.get(i,"__hf")!==void 0||$(Reflect.get(i,"__player"))}_injectRuntime(){var i,e;this._runtimeInjected=!0;try{const t=this._iframe.contentDocument;if(!t)return;const r=t.createElement("script");r.src=H,(t.head||t.documentElement).appendChild(r),(e=(i=this._callbacks).onRuntimeInjected)==null||e.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(i){var d,c;if(this.hasRuntimeBridge(i))return null;const e=Reflect.get(i,"__timelines");if(!$(e))return null;const t=Object.keys(e);if(t.length===0)return null;const r=(c=(d=this._iframe.contentDocument)==null?void 0:d.querySelector("[data-composition-id]"))==null?void 0:c.getAttribute("data-composition-id"),n=r&&r in e?r:t[t.length-1],o=e[n];return Le(o)?o:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(xe(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const ke=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -460,5 +460,5 @@ var we=Object.defineProperty;var Ae=(s,i,e)=>i in s?we(s,i,{enumerable:!0,config
460
460
  background: var(--hfp-accent, #fff);
461
461
  pointer-events: none;
462
462
  }
463
- `,Ie='<svg width="24" height="24" viewBox="46 21 54 56" fill="currentColor"><path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z"/></svg>',Oe='<svg width="24" height="24" viewBox="0 0 18 18" fill="currentColor"><rect x="3" y="2" width="4" height="14"/><rect x="11" y="2" width="4" height="14"/></svg>',ce='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/><path d="M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>',pe='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/></svg>',Ne='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z" opacity="0.3"/><line x1="18" y1="7" x2="14" y2="17" stroke="currentColor" stroke-width="2"/></svg>',Fe=[.25,.5,1,1.5,2,4];function j(s){return Number.isInteger(s)?`${s}x`:`${s}x`}function me(s){if(!Number.isFinite(s)||s<0)return"0:00";const i=Math.floor(s),e=Math.floor(i/60),t=i%60;return`${e}:${t.toString().padStart(2,"0")}`}function He(s,i,e={}){const t=e.speedPresets??Fe,r=document.createElement("div");r.className="hfp-controls",r.addEventListener("click",a=>{a.stopPropagation()});const n=document.createElement("button");n.className="hfp-play-btn",n.type="button",n.innerHTML=`<span class="hfp-ico hfp-ico-play">${Ie}</span><span class="hfp-ico hfp-ico-pause">${Oe}</span>`,n.setAttribute("aria-label","Play");const o=document.createElement("div");o.className="hfp-scrubber";const d=document.createElement("div");d.className="hfp-progress",d.style.width="0%",o.appendChild(d);const c=document.createElement("span");c.className="hfp-time",c.textContent="0:00 / 0:00";const p=document.createElement("div");p.className="hfp-speed-wrap";const h=document.createElement("button");h.className="hfp-speed-btn",h.type="button",h.textContent="1x",h.setAttribute("aria-label","Playback speed");const y=document.createElement("div");y.className="hfp-speed-menu",y.setAttribute("role","menu");for(const a of t){const l=document.createElement("button");l.className="hfp-speed-option",l.type="button",l.setAttribute("role","menuitem"),l.dataset.speed=String(a),l.textContent=j(a),a===1&&l.classList.add("hfp-active"),y.appendChild(l)}p.appendChild(y),p.appendChild(h);const g=document.createElement("div");g.className="hfp-volume-wrap";const m=document.createElement("button");m.className="hfp-mute-btn",m.type="button",m.innerHTML=ce,m.setAttribute("aria-label","Mute");const b=document.createElement("div");b.className="hfp-volume-slider-wrap";const f=document.createElement("div");f.className="hfp-volume-slider",f.setAttribute("role","slider"),f.setAttribute("aria-label","Volume"),f.setAttribute("aria-valuemin","0"),f.setAttribute("aria-valuemax","100"),f.setAttribute("aria-valuenow","100"),f.tabIndex=0;const v=document.createElement("div");v.className="hfp-volume-fill",v.style.width="100%",f.appendChild(v),b.appendChild(f),g.appendChild(b),g.appendChild(m),e.audioLocked&&(g.style.display="none"),r.appendChild(n),r.appendChild(o),r.appendChild(c),r.appendChild(g),r.appendChild(p),s.appendChild(r);let M=!1,T=!1,E=1,S=null;t.indexOf(1);const D=(a,l)=>a?Ne:l===0||l<.5?pe:ce;n.addEventListener("click",a=>{a.stopPropagation(),M?i.onPause():i.onPlay()}),m.addEventListener("click",a=>{a.stopPropagation(),i.onMuteToggle()});let C=!1;const P=a=>{const l=f.getBoundingClientRect(),_=Math.max(0,Math.min(1,(a-l.left)/l.width));E=_,v.style.width=`${_*100}%`,f.setAttribute("aria-valuenow",String(Math.round(_*100))),T&&_>0&&i.onMuteToggle(),m.innerHTML=D(T,_),i.onVolumeChange(_)};f.addEventListener("mousedown",a=>{a.stopPropagation(),C=!0,P(a.clientX)});const Z=a=>{C&&P(a.clientX)},Q=()=>{C=!1};document.addEventListener("mousemove",Z),document.addEventListener("mouseup",Q),f.addEventListener("touchstart",a=>{C=!0;const l=a.touches[0];l&&P(l.clientX)},{passive:!0});const J=a=>{if(C){const l=a.touches[0];l&&P(l.clientX)}},K=()=>{C=!1};document.addEventListener("touchmove",J,{passive:!0}),document.addEventListener("touchend",K);const ee=.05;f.addEventListener("keydown",a=>{let l=E;if(a.key==="ArrowRight"||a.key==="ArrowUp")l=Math.min(1,E+ee);else if(a.key==="ArrowLeft"||a.key==="ArrowDown")l=Math.max(0,E-ee);else return;a.preventDefault(),a.stopPropagation(),E=l,v.style.width=`${l*100}%`,f.setAttribute("aria-valuenow",String(Math.round(l*100))),T&&l>0&&i.onMuteToggle(),m.innerHTML=D(T,l),i.onVolumeChange(l)});const te=a=>{for(const l of y.querySelectorAll(".hfp-speed-option"))l.classList.toggle("hfp-active",l.dataset.speed===String(a))};h.addEventListener("click",a=>{a.stopPropagation();const l=y.classList.toggle("hfp-open");h.setAttribute("aria-expanded",String(l))}),y.addEventListener("click",a=>{a.stopPropagation();const l=a.target.closest(".hfp-speed-option");if(!l)return;const _=parseFloat(l.dataset.speed);t.indexOf(_),h.textContent=j(_),te(_),y.classList.remove("hfp-open"),h.setAttribute("aria-expanded","false"),i.onSpeedChange(_)});const ie=()=>{y.classList.remove("hfp-open"),h.setAttribute("aria-expanded","false")};document.addEventListener("click",ie);const k=a=>{const l=o.getBoundingClientRect(),_=Math.max(0,Math.min(1,(a-l.left)/l.width));i.onSeek(_)};let A=!1;o.addEventListener("mousedown",a=>{var l;a.stopPropagation(),A=!0,(l=i.onScrubStart)==null||l.call(i),k(a.clientX)});const re=a=>{A&&k(a.clientX)},se=()=>{var a;A&&(A=!1,(a=i.onScrubEnd)==null||a.call(i))};document.addEventListener("mousemove",re),document.addEventListener("mouseup",se),o.addEventListener("touchstart",a=>{var _;A=!0,(_=i.onScrubStart)==null||_.call(i);const l=a.touches[0];l&&k(l.clientX)},{passive:!0});const ne=a=>{if(A){const l=a.touches[0];l&&k(l.clientX)}},oe=()=>{var a;A&&(A=!1,(a=i.onScrubEnd)==null||a.call(i))};document.addEventListener("touchmove",ne,{passive:!0}),document.addEventListener("touchend",oe);const ae=()=>{S&&clearTimeout(S),S=setTimeout(()=>{M&&r.classList.add("hfp-hidden")},3e3)},I=s instanceof ShadowRoot?s.host:s,de=()=>{r.classList.remove("hfp-hidden"),ae()},le=()=>{M&&r.classList.add("hfp-hidden")};return I.addEventListener("mousemove",de),I.addEventListener("mouseleave",le),{updateTime(a,l){const _=l>0?Math.min(a,l):a,be=l>0?_/l*100:0;d.style.width=`${be}%`,c.textContent=`${me(_)} / ${me(l)}`},updatePlaying(a){M=a,n.classList.toggle("hfp-playing",a),n.setAttribute("aria-label",a?"Pause":"Play"),a?ae():r.classList.remove("hfp-hidden")},updateSpeed(a){t.indexOf(a),h.textContent=j(a),te(a)},updateMuted(a){T=a,m.innerHTML=D(a,E),m.setAttribute("aria-label",a?"Unmute":"Mute")},updateVolume(a){E=a,v.style.width=`${a*100}%`,f.setAttribute("aria-valuenow",String(Math.round(a*100))),m.innerHTML=D(T,a)},setVolumeControlsHidden(a){g.style.display=a?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",se),document.removeEventListener("touchmove",ne),document.removeEventListener("touchend",oe),document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",Q),document.removeEventListener("touchmove",J),document.removeEventListener("touchend",K),document.removeEventListener("click",ie),I.removeEventListener("mousemove",de),I.removeEventListener("mouseleave",le),S&&clearTimeout(S),r.remove()}}}function Ue(s,i,e,t,r,n=!1){const o=t?t.split(",").map(Number).filter(p=>!isNaN(p)&&p>0):void 0,d={...o?{speedPresets:o}:{},audioLocked:n},c=He(s,r,d);return c.updateMuted(i),c.updateVolume(e),c}function fe(s,i,e){return i?(e||(e=document.createElement("img"),e.className="hfp-poster",s.appendChild(e)),e.src=i,e):(e==null||e.remove(),null)}function $e(s){return s.composedPath().some(i=>i instanceof HTMLElement&&i.classList.contains("hfp-controls"))}let O=null;function Ve(s,i){if(typeof CSSStyleSheet<"u")try{O||(O=new CSSStyleSheet,O.replaceSync(i)),s.adoptedStyleSheets=[O];return}catch{}const e=document.createElement("style");e.textContent=i,s.appendChild(e)}function je(){const s=document.createElement("div");s.className="hfp-container";const i=document.createElement("iframe");return i.className="hfp-iframe",i.sandbox.add("allow-scripts","allow-same-origin"),i.allow="autoplay; fullscreen",i.referrerPolicy="no-referrer",i.title="HyperFrames Composition",s.appendChild(i),{container:s,iframe:i}}function ze(s,i,e,t){const r=s.offsetWidth,n=s.offsetHeight;if(r===0||n===0)return!1;const o=Math.min(r/e,n/t);return i.style.width=`${e}px`,i.style.height=`${t}px`,i.style.transform=`translate(-50%, -50%) scale(${o})`,!0}const We=100;class Be{constructor(i){u(this,"_raf",null);u(this,"_lastUpdateMs",0);this._callbacks=i}start(i,e,t,r){this.stop();const n=()=>{if(r()){this._raf=null;return}let o;try{o=i.time()}catch{this._raf=null;return}const d=t();d>0&&(o=Math.min(o,d));const c=d>0&&o>=d,p=performance.now();if((p-this._lastUpdateMs>We||c)&&(this._lastUpdateMs=p,this._callbacks.onTimeUpdate(o,d)),c){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{i.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(n)};this._raf=requestAnimationFrame(n)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function qe(s){const i=Array.from(s.querySelectorAll("[data-composition-id]"));if(i.length===0)return s.body?[s.body]:[];const e=[];for(const t of i)Ye(t)||e.push(t);return Ge(s),e}function Ge(s){const i=s.body;if(!i||typeof console>"u"||typeof console.warn!="function")return;const e=i.querySelectorAll("audio[data-start], video[data-start]");if(e.length===0)return;const t=[];for(const r of e)r.closest("[data-composition-id]")||t.push(r);t.length!==0&&console.warn(`[hyperframes-player] selectMediaObserverTargets: composition hosts are present, but ${t.length} body-level timed media element(s) sit outside every [data-composition-id] subtree and will not be observed. Move them inside a composition host or the parent-frame proxy will never adopt them.`,t)}function Ye(s){let i=s.parentElement;for(;i;){if(i.hasAttribute("data-composition-id"))return!0;i=i.parentElement}return!1}const Xe=.05,Ze=2;class Qe{constructor(i){u(this,"_entries",[]);u(this,"_mediaObserver");u(this,"_playbackErrorPosted",!1);u(this,"_audioOwner","runtime");u(this,"_urlAudioEntry",null);u(this,"_urlAudioSrc",null);u(this,"_dispatchEvent");u(this,"_getMuted");u(this,"_getVolume");u(this,"_getPlaybackRate");u(this,"_getCurrentTime");u(this,"_isPaused");this._dispatchEvent=i.dispatchEvent,this._getMuted=i.getMuted,this._getVolume=i.getVolume,this._getPlaybackRate=i.getPlaybackRate,this._getCurrentTime=i.getCurrentTime,this._isPaused=i.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;const i=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll(),this.teardownObserver(),i&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(const i of this._entries)i.el.pause(),i.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(i){for(const e of this._entries)e.el.muted=i}updateVolume(i){for(const e of this._entries)e.el.volume=i}updatePlaybackRate(i){for(const e of this._entries)e.el.playbackRate=i}_playEntry(i){i.el.src&&i.el.play().catch(e=>this._reportPlaybackError(e))}_playEntryIfActive(i){this._refreshEntryBounds(i);const e=this._getCurrentTime()-i.start;e<0||e>=i.duration||this._playEntry(i)}_refreshEntryBounds(i){var t;if(!((t=i.source)!=null&&t.isConnected))return;const e=ue(i.source);i.start=e.start??0,i.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_gateEntryPlayback(i,e){return e<0||e>=i.duration?(i.el.paused||i.el.pause(),i.driftSamples=0,!1):(this._audioOwner==="parent"&&!this._isPaused()&&i.el.paused&&this._playEntry(i),!0)}playAll(){for(const i of this._entries)this._playEntryIfActive(i)}pauseAll(){for(const i of this._entries)i.el.pause()}stopAdoptedMedia(){for(const i of this._entries)i.source&&i.el.pause()}seekAll(i){for(const e of this._entries){this._refreshEntryBounds(e);const t=i-e.start;t>=0&&t<e.duration&&(e.el.currentTime=t)}}scrubAll(i){for(const e of this._entries){this._refreshEntryBounds(e);const t=i-e.start;t>=0&&t<e.duration?(e.el.currentTime=t,this._playEntry(e)):e.el.paused||e.el.pause()}}mirrorTime(i,e){const t=(e==null?void 0:e.force)===!0;for(const r of this._entries){this._refreshEntryBounds(r);const n=i-r.start;this._gateEntryPlayback(r,n)&&(Math.abs(r.el.currentTime-n)>Xe?(r.driftSamples+=1,(t||r.driftSamples>=Ze)&&(r.el.currentTime=n,r.driftSamples=0)):r.driftSamples=0)}}promoteToParentProxy(i,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",i)for(const r of i.querySelectorAll("video, audio"))w(r)&&(r.muted=!0);const t=this._getCurrentTime();e?e(t,{force:!0}):this.mirrorTime(t,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(i){const e=i.querySelectorAll("audio[data-start], video[data-start]");for(const t of e)w(t)&&this._adoptIframeMedia(t);this._observeDynamicMedia(i)}setupFromUrl(i){if(this._urlAudioSrc===i&&this._urlAudioEntry)return;this.teardownUrlAudio();const e=this._createEntry(i,"audio",0,1/0);this._urlAudioEntry=e,this._urlAudioSrc=e?i:null,e&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){const i=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!i)return;i.el.pause(),i.el.src="";const e=this._entries.indexOf(i);e!==-1&&this._entries.splice(e,1)}teardownObserver(){var i;(i=this._mediaObserver)==null||i.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(i){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:i}})))}_createEntry(i,e,t,r,n){if(this._entries.some(p=>p.el.src===i))return null;const o=e==="video"?document.createElement("video"):new Audio;o.preload="auto",o.src=i,o.load(),o.muted=this._getMuted(),o.volume=this._getVolume();const d=this._getPlaybackRate();d!==1&&(o.playbackRate=d);const c={el:o,start:t,duration:r,driftSamples:0,source:n};return this._entries.push(c),c}_resolveIframeMediaSrc(i){var t;const e=i.getAttribute("src")||((t=i.querySelector("source"))==null?void 0:t.getAttribute("src"));return e?new URL(e,i.ownerDocument.baseURI).href:null}_adoptIframeMedia(i){if(i.preload==="metadata"||i.preload==="none")return;const e=this._resolveIframeMediaSrc(i);if(!e)return;const t=ue(i),r=t.start??0,n=t.duration??Number.POSITIVE_INFINITY,o=i.tagName==="VIDEO"?"video":"audio",d=this._createEntry(e,o,r,n,i);d&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(d))}_detachIframeMedia(i){const e=this._resolveIframeMediaSrc(i);if(!e)return;const t=this._entries.findIndex(n=>n.el.src===e);if(t===-1)return;const r=this._entries[t];r.el.pause(),r.el.src="",this._entries.splice(t,1)}_observeDynamicMedia(i){if(this.teardownObserver(),typeof MutationObserver>"u"||!i.body)return;const e=new MutationObserver(n=>{for(const o of n){if(o.type==="attributes"&&o.attributeName==="preload"){const d=o.target;w(d)&&d.matches("audio[data-start], video[data-start]")&&d.preload==="auto"&&this._adoptIframeMedia(d);continue}for(const d of o.addedNodes){if(!he(d))continue;const c=[];w(d)&&d.matches("audio[data-start], video[data-start]")&&c.push(d);const p=d.querySelectorAll("audio[data-start], video[data-start]");for(const h of p)w(h)&&c.push(h);for(const h of c)this._adoptIframeMedia(h)}for(const d of o.removedNodes){if(!he(d))continue;const c=[];w(d)&&d.matches("audio[data-start], video[data-start]")&&c.push(d);const p=d.querySelectorAll("audio[data-start], video[data-start]");for(const h of p)w(h)&&c.push(h);for(const h of c)this._detachIframeMedia(h)}}}),t={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload"]},r=qe(i);for(const n of r)e.observe(n,t);this._mediaObserver=e}}const Je=100;function Ke(s,i,e,t){const r=(s.frame??0)/i,n=e.duration>0?Math.min(r,e.duration):r,o=!e.paused,d=!s.isPlaying,c=e.duration>0&&n>=e.duration&&(o||s.isPlaying);if(c&&t.getLoop())return t.media.audioOwner==="parent"&&t.media.pauseAll(),t.seek(0),t.play(),{...e,currentTime:n,paused:!1};const p={...e,currentTime:n,paused:d};t.media.audioOwner==="parent"&&(o&&d?t.media.pauseAll():!o&&!d&&t.media.playAll(),t.media.mirrorTime(n));const h=performance.now(),y=d!==e.paused;return(h-e.lastUpdateMs>Je||y)&&(p.lastUpdateMs=h,t.updateControlsTime(n,e.duration),t.updateControlsPlaying(!d),t.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:n}}))),c&&(t.media.audioOwner==="parent"&&t.media.pauseAll(),p.paused=!0,t.updateControlsPlaying(!1),t.dispatchEvent(new Event("ended"))),p}function et(s){return Array.isArray(s)?s.filter(i=>typeof i=="object"&&i!==null&&typeof i.id=="string"&&typeof i.start=="number"&&typeof i.duration=="number"):[]}function tt(s,i,e){var n,o,d,c,p;if(s.source!==i)return;const t=s.data;if(!t||t.source!=="hf-preview")return;const r=Ee(t);if(r.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:r.code,receivedVersion:r.receivedVersion}}));return}if((n=e.setRuntimeFps)==null||n.call(e,r.fps),t.type==="shader-transition-state"){const h=t.state&&typeof t.state=="object"?t.state:{};e.shaderLoader.update(h,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:t.compositionId,state:h}}));return}if(t.type==="ready"){e.onRuntimeReady();return}if(t.type==="assets-ready"){(o=e.onRuntimeAssetsReady)==null||o.call(e,t.timedOut===!0);return}if(t.type==="runtime-data-error"){(d=e.onRuntimeDataError)==null||d.call(e,t.channel,t.requestId,t.message);return}if(t.type==="runtime-data-applied"){(c=e.onRuntimeDataApplied)==null||c.call(e,t.channel,t.requestId);return}if(t.type==="state"){e.setPlaybackState(Ke({frame:t.frame??0,isPlaying:!!t.isPlaying},r.fps,e.getPlaybackState(),e));return}if(t.type==="media-autoplay-blocked"){if(((p=e.shouldPromoteMediaAutoplayFallback)==null?void 0:p.call(e))===!1)return;let h=null;try{h=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(h,(y,g)=>e.media.mirrorTime(y,g)),e.sendControl("set-media-output-muted",{muted:!0});return}if(t.type==="timeline"&&t.durationInFrames>0){const h=Number(t.durationSeconds),y=Number(t.durationInFrames),g=Number.isFinite(h)&&h>0?h:y/r.fps;if(Number.isFinite(g)&&g>0){const m=e.getPlaybackState();e.setPlaybackState({...m,duration:g}),e.updateControlsTime(m.currentTime,g),e.onRuntimeTimelineReady(g,typeof t.assetsReady=="boolean"?t.assetsReady:void 0)}Number.isFinite(t.compositionWidth)&&t.compositionWidth>0&&Number.isFinite(t.compositionHeight)&&t.compositionHeight>0&&e.setCompositionSize(t.compositionWidth,t.compositionHeight),e.setScenes(et(t.scenes));return}t.type==="stage-size"&&Number.isFinite(t.width)&&t.width>0&&Number.isFinite(t.height)&&t.height>0&&e.setCompositionSize(t.width,t.height)}function it(s,i){return s.includes(i)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(s)}const rt=new Set([">"," "," ",`
464
- `,"\r","\f"]);function z(s,i){const e=s.toLowerCase(),t=`<${i}`;let r=0;for(;r<e.length;){const n=e.indexOf(t,r);if(n<0)return null;const o=e[n+t.length];if(rt.has(o)){const d=e.indexOf(">",n+t.length);return d<0?null:{index:n,end:d+1}}r=n+t.length}return null}function st(s,i){if(!s||it(s,i))return s;const e=`<script src="${i}"><\/script>`,t=z(s,"head");if(t)return s.slice(0,t.end)+e+s.slice(t.end);const r=z(s,"body");if(r)return s.slice(0,r.index)+e+s.slice(r.index);const n=z(s,"html");return n?s.slice(0,n.end)+e+s.slice(n.end):e+s}const R="shader-capture-scale",x="shader-loading",Y="runtime-src",_e="__hf_shader_capture_scale",ge="__hf_shader_loading",U=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function X(s){if(s===null)return null;const i=Number(s);return!Number.isFinite(i)||i<=0?null:String(Math.min(1,Math.max(.25,i)))}function nt(s){if(s===null||s.trim()==="")return"composition";const i=s.trim().toLowerCase();return i==="none"||i==="false"||i==="0"||i==="off"?"none":i==="player"||i==="true"||i==="1"||i==="on"?"player":"composition"}function ye(s,i){return s.filter(e=>e!==""&&e.split("=")[0]!==i)}function ot(s,i,e){const t=s.indexOf("#"),r=t>=0?s.slice(0,t):s,n=t>=0?s.slice(t):"",o=r.indexOf("?"),d=o>=0?r.slice(0,o):r,c=o>=0?r.slice(o+1):"";let p=ye(c.split("&"),_e);p=ye(p,ge),i!==null&&p.push(`${_e}=${encodeURIComponent(i)}`),e!=="composition"&&p.push(`${ge}=${encodeURIComponent(e)}`);const h=p.join("&");return`${d}${h?`?${h}`:""}${n}`}function at(s,i,e){if(i===null&&e==="composition")return s;const t=[];i!==null&&t.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(i)};`),e!=="composition"&&t.push(`window.__HF_SHADER_LOADING=${JSON.stringify(e)};`);const r=`<script data-hyperframes-player-shader-options>${t.join("")}<\/script>`;return/<head\b[^>]*>/i.test(s)?s.replace(/<head\b[^>]*>/i,n=>`${n}${r}`):/<html\b[^>]*>/i.test(s)?s.replace(/<html\b[^>]*>/i,n=>`${n}${r}`):`${r}${s}`}function L(s){return nt(s.getAttribute(x))}function dt(s){return Number(X(s.getAttribute(R))??"1")}function N(s,i){return ot(i,X(s.getAttribute(R)),L(s))}function F(s,i){return st(at(i,X(s.getAttribute(R)),L(s)),lt(s))}function lt(s){var e;const i=(e=s.getAttribute(Y))==null?void 0:e.trim();if(!i)return H;try{const t=new URL(i,document.baseURI),r=t.protocol==="http:"||t.protocol==="https:",n=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]";return r&&(n||t.origin===location.origin)?t.href:H}catch{return H}}function ut(){const s=document.createElement("div");s.className="hfp-shader-loader",s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-label","Preparing scene transitions"),s.setAttribute("data-hyperframes-ignore",""),s.draggable=!1;const i=m=>{m.preventDefault(),m.stopPropagation()};for(const m of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])s.addEventListener(m,i,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const t=document.createElement("div");t.className="hfp-shader-loader-mark",t.draggable=!1,t.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");const r=document.createElement("div");r.className="hfp-shader-loader-title";const n=document.createElement("span");n.className="hfp-shader-loader-title-text",n.textContent=U[0],r.appendChild(n);const o=document.createElement("div");o.className="hfp-shader-loader-detail",o.textContent="Rendering animated scene samples for shader transitions.";const d=document.createElement("div");d.className="hfp-shader-loader-track",d.setAttribute("aria-hidden","true");const c=document.createElement("div");c.className="hfp-shader-loader-fill",d.appendChild(c);const p=document.createElement("div");p.className="hfp-shader-loader-progress";const h=m=>{const b=document.createElement("div");b.className="hfp-shader-loader-row";const f=document.createElement("span");f.className="hfp-shader-loader-label",f.textContent=m;const v=document.createElement("span");return v.className="hfp-shader-loader-value",b.appendChild(f),b.appendChild(v),p.appendChild(b),{row:b,label:f,value:v}},y=h("transition"),g=h("transition frame");return e.appendChild(t),e.appendChild(r),e.appendChild(o),e.appendChild(d),e.appendChild(p),s.appendChild(e),{root:s,fill:c,title:n,detail:o,transitionValue:y.value,frameLabel:g.label,frameValue:g.value,frameRow:g.row}}const ht=420;class ct{constructor(i){u(this,"_el");u(this,"_hideTimeout",null);this._el=i}show(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-hiding"),this._el.root.classList.add("hfp-visible")}hide(){if(this._el.root.classList.contains("hfp-hiding")){this._hideTimeout||this._scheduleCleanup();return}this._el.root.classList.contains("hfp-visible")&&(this._el.root.classList.add("hfp-hiding"),this._el.root.classList.remove("hfp-visible"),this._scheduleCleanup())}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._el.fill.style.transform="scaleX(0)",this._el.transitionValue.textContent="",this._el.frameValue.textContent="",this._el.frameRow.style.visibility="hidden"}update(i,e){if(e!=="player"){this.reset();return}if(i.ready||!i.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions");const t=typeof i.progress=="number"&&Number.isFinite(i.progress)?i.progress:0,r=typeof i.total=="number"&&Number.isFinite(i.total)?i.total:0,n=r>0?Math.min(1,Math.max(0,t/r)):0,o=Math.min(U.length-1,Math.floor(n*U.length));this._el.title.textContent=U[o]||"Preparing scene transitions",this._el.detail.textContent=i.phase==="cached"?"Loading cached transition frames before playback.":i.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${n})`,this._el.transitionValue.textContent=i.currentTransition!==void 0&&i.transitionTotal!==void 0?`${i.currentTransition}/${i.transitionTotal}`:r>0?`${t}/${r}`:"";const d=i.transitionFrame!==void 0&&i.transitionFrames!==void 0?`${i.transitionFrame}/${i.transitionFrames}`:"";this._el.frameLabel.textContent=i.phase==="cached"?"cached transition frames":i.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",this._el.frameValue.textContent=d,this._el.frameRow.style.visibility=d?"visible":"hidden",this._el.root.setAttribute("aria-valuenow",String(Math.round(n*100))),this.show()}showAssetsLoading(){this.reset(),this._el.title.textContent="Loading assets",this._el.detail.textContent="Waiting for images, video and fonts to finish loading.",this._el.root.setAttribute("aria-label","Loading assets"),this.show()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null)}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null},ht)}}const pt=.1,mt=5,W="sandbox-origin",ve=1e4,B=8e3,q="assets-loading",ft=150;function G(s){return!Number.isFinite(s)||s<=0?1:Math.max(pt,Math.min(mt,s))}class _t extends HTMLElement{constructor(){super();u(this,"shadow");u(this,"container");u(this,"iframe");u(this,"posterEl",null);u(this,"controlsApi",null);u(this,"resizeObserver");u(this,"shaderLoader");u(this,"probe");u(this,"_ready",!1);u(this,"_assetsReady",!1);u(this,"_pendingPlay",!1);u(this,"_assetsGeneration",0);u(this,"_assetsLoadingShowTimer",null);u(this,"_currentTime",0);u(this,"_duration",0);u(this,"_paused",!0);u(this,"_scrubbing",!1);u(this,"_lastUpdateMs",0);u(this,"_volume",1);u(this,"_compositionWidth",1920);u(this,"_compositionHeight",1080);u(this,"_rescaleWarned",!1);u(this,"_directTimelineAdapter",null);u(this,"_directTimelineClock");u(this,"_parentTickRaf",null);u(this,"_media");u(this,"_scenes",[]);u(this,"_runtimeFps",30);u(this,"_runtimeBridgeReady",!1);u(this,"_runtimeAssetsReadyGeneration",-1);u(this,"_runtimeData",new Map);u(this,"_runtimeDataRequestId",0);u(this,"_pendingRuntimeData",new Map);this.shadow=this.attachShadow({mode:"open"}),Ve(this.shadow,ke),{container:this.container,iframe:this.iframe}=je(),this.shadow.appendChild(this.container);const e=ut();this.shadow.appendChild(e.root),this.shaderLoader=new ct(e),this._media=new Qe({dispatchEvent:t=>this.dispatchEvent(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Be({onTimeUpdate:(t,r)=>{var n;this._currentTime=t,(n=this.controlsApi)==null||n.updateTime(t,r),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:t}}))},getLoop:()=>this.loop,restart:()=>{this.seek(0),this.play()},onPaused:()=>{var t;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(t=this.controlsApi)==null||t.updatePlaying(!1),this.dispatchEvent(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new Pe(this.iframe,{onReady:t=>this._onProbeReady(t),onError:t=>this.dispatchEvent(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{$e(t)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this)}static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src",W,Y,R,x]}connectedCallback(){this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.iframe.addEventListener("load",this._onIframeLoad),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=fe(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=F(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&(this.iframe.src=N(this,this.getAttribute("src"))),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.iframe.removeEventListener("load",this._onIframeLoad),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),(e=this.controlsApi)==null||e.destroy(),this.controlsApi=null,this._paused=!0,this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Player disconnected before runtime data was applied")}attributeChangedCallback(e,t,r){var n,o,d,c,p;switch(e){case"src":if(!this.isConnected)break;r&&(this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Composition navigated before runtime data was applied"),this.iframe.src=N(this,r));break;case"srcdoc":if(!this.isConnected)break;this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Composition navigated before runtime data was applied"),r!==null?this.iframe.srcdoc=F(this,r):this.iframe.removeAttribute("srcdoc");break;case W:this._applySandboxOriginPolicy(this.isConnected&&t!==r);break;case"width":this._compositionWidth=V(r)??1920,this._rescale();break;case"height":this._compositionHeight=V(r)??1080,this._rescale();break;case"controls":r!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=fe(this.shadow,r,this.posterEl);break;case"playback-rate":{const h=G(parseFloat(r||"1"));this._media.updatePlaybackRate(h),this._sendControl("set-playback-rate",{playbackRate:h}),(d=(o=this._directTimelineAdapter)==null?void 0:o.timeScale)==null||d.call(o,h),(c=this.controlsApi)==null||c.updateSpeed(h),this.dispatchEvent(new Event("ratechange"));break}case"muted":this._handleMutedChange(r);break;case"audio-locked":this._applyAudioLock(r!==null);break;case"volume":{const h=Math.max(0,Math.min(1,parseFloat(r||"1")));this._volume=h,this._media.updateVolume(h),this._sendControl("set-volume",{volume:h}),(p=this.controlsApi)==null||p.updateVolume(h),this.dispatchEvent(new Event("volumechange"));break}case"audio-src":r?this._media.setupFromUrl(r):this._media.teardownUrlAudio();break;case R:case x:case Y:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(W)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Sandbox policy changed before runtime data was applied");const e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=F(this,e);return}const t=this.getAttribute("src");this.iframe.src=t===null?"about:blank":N(this,t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){var r,n;if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,(r=this.posterEl)==null||r.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const e=this._tryDirectTimelinePlay();let t=!1;e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,t=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),(n=this.controlsApi)==null||n.updatePlaying(!0),t||this.dispatchEvent(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){var e;this._pendingPlay=!1,this._tryDirectTimelinePause()||this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1),this.dispatchEvent(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){var t,r;this._pendingPlay=!1,!this._trySyncSeek(e)&&!this._tryDirectTimelineSeek(e)&&this._sendControl("seek",{timeSeconds:e,frame:Math.round(e*this._runtimeFps)}),this._directTimelineClock.stop(),this._stopParentTickClock(),this._currentTime=e,this._media.audioOwner==="parent"&&(this._scrubbing?this._media.scrubAll(e):(this._media.pauseAll(),this._media.seekAll(e))),this._paused=!0,(t=this.controlsApi)==null||t.updatePlaying(!1),(r=this.controlsApi)==null||r.updateTime(this._currentTime,this._duration)}setColorGrading(e,t){this._sendControl("set-color-grading",{target:e,grading:t})}clearColorGrading(e){this._sendControl("set-color-grading",{target:e,grading:null})}setColorGradingCompare(e,t){this._sendControl("set-color-grading-compare",{target:e,compare:t})}clearColorGradingCompare(e){this._sendControl("set-color-grading-compare",{target:e,compare:{enabled:!1}})}setRuntimeData(e,t){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);if(typeof structuredClone!="function")throw new Error("HyperFrames runtime data requires structuredClone support; refusing an unverified payload");const r=structuredClone(t);this._runtimeData.set(e,r),this._deliverRuntimeData(e,r)}clearRuntimeData(e){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);this._runtimeData.delete(e),this._deliverRuntimeDataClear(e)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get paused(){return this._paused}get ready(){return this._ready}get assetsReady(){return this._assetsReady}get playbackRate(){return G(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(G(e)))}get shaderCaptureScale(){return dt(this)}set shaderCaptureScale(e){this.setAttribute(R,String(e))}get shaderLoading(){return L(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(x):this.setAttribute(x,e)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_isLockedHostEnvironment(){if(typeof navigator>"u")return!1;const e=navigator.userAgent||"";return/\bClaude\/\d/.test(e)&&/\bElectron\b/.test(e)}_isAudioLocked(){return this.hasAttribute("audio-locked")||this._isLockedHostEnvironment()}_isSlideshowPlayer(){return this.closest("hyperframes-slideshow")!==null}_handleMutedChange(e){var t;if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(t=this.controlsApi)==null||t.updateMuted(e!==null),this.dispatchEvent(new Event("volumechange"))}_applyAudioLock(e){var t;e&&(this.muted=!0),(t=this.controlsApi)==null||t.setVolumeControlsHidden(e)}get volume(){return this._volume}set volume(e){this.setAttribute("volume",String(Math.max(0,Math.min(1,e))))}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_sendControl(e,t={}){try{const r=this.iframe.contentWindow;return r?(r.postMessage({...t,source:"hf-parent",type:"control",action:e,...Te(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,"Composition iframe is unavailable"),!1)}catch(r){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,r instanceof Error?r.message:String(r)),!1}}_deliverRuntimeData(e,t){if(!this.isConnected||!this._runtimeBridgeReady)return;const r=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,t,r)||this._sendControl("set-runtime-data",{channel:e,payload:t,requestId:r})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;const t=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,t)||this._sendControl("clear-runtime-data",{channel:e,requestId:t})}_trySetRuntimeDataDirect(e,t,r){var n;try{const o=(n=this.iframe.contentWindow)==null?void 0:n.__hyperframes;return typeof(o==null?void 0:o.setRuntimeData)!="function"?!1:(o.setRuntimeData(e,t,r),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,t){var r;try{const n=(r=this.iframe.contentWindow)==null?void 0:r.__hyperframes;return typeof(n==null?void 0:n.clearRuntimeData)!="function"?!1:(n.clearRuntimeData(e,t),!0)}catch{return!1}}_replayRuntimeData(){for(const[e,t]of this._runtimeData)this._deliverRuntimeData(e,t)}_beginRuntimeDataDelivery(e){const t=this._pendingRuntimeData.get(e);t&&window.clearTimeout(t.timeoutId),this._runtimeDataRequestId+=1;const r=this._runtimeDataRequestId,n=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,r,`Runtime data delivery timed out after ${ve}ms`)},ve);return this._pendingRuntimeData.set(e,{requestId:r,timeoutId:n}),r}_resolveRuntimeDataDelivery(e,t){const r=this._takeRuntimeDataDelivery(e,t);r&&this.dispatchEvent(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:r.requestId}}))}_rejectRuntimeDataDelivery(e,t,r){const n=this._takeRuntimeDataDelivery(e,t);n&&this.dispatchEvent(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:n.requestId,message:typeof r=="string"?r:String(r)}}))}_takeRuntimeDataDelivery(e,t){if(typeof e!="string"||typeof t!="number"||!Number.isSafeInteger(t))return null;const r=this._pendingRuntimeData.get(e);return!r||r.requestId!==t?null:(window.clearTimeout(r.timeoutId),this._pendingRuntimeData.delete(e),r)}_rejectAllRuntimeDataDeliveries(e){for(const[t,r]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(t,r.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){const t=this._getSameOriginIframeDocument();if(t)for(const r of t.querySelectorAll("video, audio"))w(r)&&(r.muted=e||r.defaultMuted)}_stopIframeMedia(){const e=this._getSameOriginIframeDocument();if(e)for(const t of e.querySelectorAll("video, audio"))w(t)&&t.pause()}_replayBridgeState(){this._sendControl("set-muted",{muted:this.muted}),this._sendControl("set-volume",{volume:this._volume}),this._sendControl("set-playback-rate",{playbackRate:this.playbackRate}),this._sendControl("set-native-media-sync-disabled",{disabled:this._isSlideshowPlayer()}),this._sendControl("set-web-audio-media-disabled",{disabled:this._isSlideshowPlayer()})}_reloadShaderOptions(){if(this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Shader options changed before runtime data was applied"),L(this)!=="player"&&this.shaderLoader.reset(),this.hasAttribute("srcdoc")){this.iframe.srcdoc=F(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&(this.iframe.src=N(this,this.getAttribute("src")||""))}_trySyncSeek(e){try{const t=this.iframe.contentWindow,r=t==null?void 0:t.__player;return typeof(r==null?void 0:r.seek)!="function"?!1:(r.seek.call(r,e),!0)}catch{return!1}}_withDirectTimeline(e){var n;const t=this.probe.resolveDirectTimelineAdapter(),r=t||this._directTimelineAdapter;if(!r)return!1;try{if(e(r),t&&t!==this._directTimelineAdapter){const o=t.duration();Number.isFinite(o)&&o>0&&(this._duration=o,(n=this.controlsApi)==null||n.updateTime(this._currentTime,o))}return this._directTimelineAdapter=r,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(t=>{t.seek(e,!1),t.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>void e.play())}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>void e.pause())}_startParentTickClock(){this._stopParentTickClock();const e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){tt(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:t,duration:r,paused:n,lastUpdateMs:o})=>{this._currentTime=t,this._duration=r,this._paused=n,this._lastUpdateMs=o},getShaderLoadingMode:()=>L(this),shaderLoader:this.shaderLoader,setCompositionSize:(t,r)=>{this._compositionWidth=t,this._compositionHeight=r,this._rescale()},sendControl:(t,r)=>this._sendControl(t,r),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(t,r)=>this._resolveRuntimeDataDelivery(t,r),onRuntimeDataError:(t,r,n)=>this._rejectRuntimeDataDelivery(t,r,n),onRuntimeTimelineReady:(t,r)=>this._onRuntimeTimelineReady(t,r),setRuntimeFps:t=>{this._runtimeFps=t},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:t=>{this._scenes=t,this.dispatchEvent(new CustomEvent("scenes",{detail:{scenes:t}}))},updateControlsTime:(t,r)=>{var n;return(n=this.controlsApi)==null?void 0:n.updateTime(t,r)},updateControlsPlaying:t=>{var r;return(r=this.controlsApi)==null?void 0:r.updatePlaying(t)},dispatchEvent:t=>this.dispatchEvent(t),seek:t=>this.seek(t),play:()=>this.play(),getLoop:()=>this.loop,media:this._media})}_onRuntimeTimelineReady(e,t){var n;if(this._ready)return;this.probe.stop(),this._duration=e,this._directTimelineAdapter=null,this._ready=!0,(n=this.controlsApi)==null||n.updateTime(this._currentTime,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),this._rescale();const r=this._getSameOriginIframeDocument();r&&this._media.setupFromIframe(r),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(r,t),(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()}_onProbeReady({duration:e,adapter:t,compositionSize:r}){var o;this._duration=e,this._directTimelineAdapter=t.kind==="direct-timeline"?t.timeline:null,this._ready=!0,(o=this.controlsApi)==null||o.updateTime(0,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),r&&(this._compositionWidth=r.width,this._compositionHeight=r.height,this._rescale());const n=this._getSameOriginIframeDocument();n&&this._media.setupFromIframe(n),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(n),(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()}_waitForAssetsReady(e,t){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1;const r=++this._assetsGeneration;if(!e){t===!1?(this._runtimeAssetsReadyGeneration=r,this._startAssetsLoadingOverlayTimer(r),setTimeout(()=>this._settleAssetsReady(r),B)):this._settleAssetsReady(r);return}Ce(e,({timedOut:n})=>{r===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(r))},{timeoutMs:B}),this._assetsReady||this._startAssetsLoadingOverlayTimer(r)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(q,""),this.shaderLoader.showAssetsLoading())},ft)}_warnStuckAssets(e){const{pendingMedia:t,pendingImages:r,fontsLoading:n}=Re(e),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${B}ms — playing anyway`,{stuckMedia:t.map(d=>d.currentSrc||d.getAttribute("src")||`<${d.tagName.toLowerCase()}>`),stuckImages:r.map(d=>d.currentSrc||d.getAttribute("src")||"<img>"),fontsLoading:n,computeReady:(o==null?void 0:o.__renderReady)===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(q),this.shaderLoader.hide(),this.dispatchEvent(new Event("assetsready")),this._pendingPlay&&this.play())}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._pendingPlay=!1,this._assetsGeneration++,this.removeAttribute(q),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_rescale(){!ze(this,this.iframe,this._compositionWidth,this._compositionHeight)&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready — zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){this._ready&&this._getSameOriginIframeDocument()===null||(this._ready=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this._invalidateAssetsWait(),this.shaderLoader.reset(),this._media.resetForIframeLoad(),this.probe.start())}_setupControls(){this.controlsApi||(this.controlsApi=Ue(this.shadow,this.muted,this._volume,this.getAttribute("speed-presets"),{onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:e=>this.seek(e*this._duration),onScrubStart:()=>{this._scrubbing=!0},onScrubEnd:()=>{this._scrubbing=!1,this.seek(this._currentTime)},onSpeedChange:e=>void(this.playbackRate=e),onMuteToggle:()=>void(this.muted=!this.muted),onVolumeChange:e=>void(this.volume=e)},this._isAudioLocked()))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,t){this._media.mirrorTime(e,t)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(t,r)=>this._mirrorParentMediaTime(t,r)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}}customElements.get("hyperframes-player")||customElements.define("hyperframes-player",_t);export{_t as HyperframesPlayer,Fe as SPEED_PRESETS,j as formatSpeed,me as formatTime};
463
+ `,Ie='<svg width="24" height="24" viewBox="46 21 54 56" fill="currentColor"><path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z"/></svg>',Oe='<svg width="24" height="24" viewBox="0 0 18 18" fill="currentColor"><rect x="3" y="2" width="4" height="14"/><rect x="11" y="2" width="4" height="14"/></svg>',ce='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/><path d="M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>',pe='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/></svg>',Ne='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z" opacity="0.3"/><line x1="18" y1="7" x2="14" y2="17" stroke="currentColor" stroke-width="2"/></svg>',Fe=[.25,.5,1,1.5,2,4];function W(s){return Number.isInteger(s)?`${s}x`:`${s}x`}function me(s){if(!Number.isFinite(s)||s<0)return"0:00";const i=Math.floor(s),e=Math.floor(i/60),t=i%60;return`${e}:${t.toString().padStart(2,"0")}`}function He(s,i,e={}){const t=e.speedPresets??Fe,r=document.createElement("div");r.className="hfp-controls",r.addEventListener("click",a=>{a.stopPropagation()});const n=document.createElement("button");n.className="hfp-play-btn",n.type="button",n.innerHTML=`<span class="hfp-ico hfp-ico-play">${Ie}</span><span class="hfp-ico hfp-ico-pause">${Oe}</span>`,n.setAttribute("aria-label","Play");const o=document.createElement("div");o.className="hfp-scrubber";const d=document.createElement("div");d.className="hfp-progress",d.style.width="0%",o.appendChild(d);const c=document.createElement("span");c.className="hfp-time",c.textContent="0:00 / 0:00";const p=document.createElement("div");p.className="hfp-speed-wrap";const h=document.createElement("button");h.className="hfp-speed-btn",h.type="button",h.textContent="1x",h.setAttribute("aria-label","Playback speed");const y=document.createElement("div");y.className="hfp-speed-menu",y.setAttribute("role","menu");for(const a of t){const l=document.createElement("button");l.className="hfp-speed-option",l.type="button",l.setAttribute("role","menuitem"),l.dataset.speed=String(a),l.textContent=W(a),a===1&&l.classList.add("hfp-active"),y.appendChild(l)}p.appendChild(y),p.appendChild(h);const g=document.createElement("div");g.className="hfp-volume-wrap";const m=document.createElement("button");m.className="hfp-mute-btn",m.type="button",m.innerHTML=ce,m.setAttribute("aria-label","Mute");const b=document.createElement("div");b.className="hfp-volume-slider-wrap";const f=document.createElement("div");f.className="hfp-volume-slider",f.setAttribute("role","slider"),f.setAttribute("aria-label","Volume"),f.setAttribute("aria-valuemin","0"),f.setAttribute("aria-valuemax","100"),f.setAttribute("aria-valuenow","100"),f.tabIndex=0;const v=document.createElement("div");v.className="hfp-volume-fill",v.style.width="100%",f.appendChild(v),b.appendChild(f),g.appendChild(b),g.appendChild(m),e.audioLocked&&(g.style.display="none"),r.appendChild(n),r.appendChild(o),r.appendChild(c),r.appendChild(g),r.appendChild(p),s.appendChild(r);let M=!1,T=!1,E=1,S=null;t.indexOf(1);const D=(a,l)=>a?Ne:l===0||l<.5?pe:ce;n.addEventListener("click",a=>{a.stopPropagation(),M?i.onPause():i.onPlay()}),m.addEventListener("click",a=>{a.stopPropagation(),i.onMuteToggle()});let C=!1;const P=a=>{const l=f.getBoundingClientRect(),_=Math.max(0,Math.min(1,(a-l.left)/l.width));E=_,v.style.width=`${_*100}%`,f.setAttribute("aria-valuenow",String(Math.round(_*100))),T&&_>0&&i.onMuteToggle(),m.innerHTML=D(T,_),i.onVolumeChange(_)};f.addEventListener("mousedown",a=>{a.stopPropagation(),C=!0,P(a.clientX)});const Z=a=>{C&&P(a.clientX)},Q=()=>{C=!1};document.addEventListener("mousemove",Z),document.addEventListener("mouseup",Q),f.addEventListener("touchstart",a=>{C=!0;const l=a.touches[0];l&&P(l.clientX)},{passive:!0});const J=a=>{if(C){const l=a.touches[0];l&&P(l.clientX)}},K=()=>{C=!1};document.addEventListener("touchmove",J,{passive:!0}),document.addEventListener("touchend",K);const ee=.05;f.addEventListener("keydown",a=>{let l=E;if(a.key==="ArrowRight"||a.key==="ArrowUp")l=Math.min(1,E+ee);else if(a.key==="ArrowLeft"||a.key==="ArrowDown")l=Math.max(0,E-ee);else return;a.preventDefault(),a.stopPropagation(),E=l,v.style.width=`${l*100}%`,f.setAttribute("aria-valuenow",String(Math.round(l*100))),T&&l>0&&i.onMuteToggle(),m.innerHTML=D(T,l),i.onVolumeChange(l)});const te=a=>{for(const l of y.querySelectorAll(".hfp-speed-option"))l.classList.toggle("hfp-active",l.dataset.speed===String(a))};h.addEventListener("click",a=>{a.stopPropagation();const l=y.classList.toggle("hfp-open");h.setAttribute("aria-expanded",String(l))}),y.addEventListener("click",a=>{a.stopPropagation();const l=a.target.closest(".hfp-speed-option");if(!l)return;const _=parseFloat(l.dataset.speed);t.indexOf(_),h.textContent=W(_),te(_),y.classList.remove("hfp-open"),h.setAttribute("aria-expanded","false"),i.onSpeedChange(_)});const ie=()=>{y.classList.remove("hfp-open"),h.setAttribute("aria-expanded","false")};document.addEventListener("click",ie);const k=a=>{const l=o.getBoundingClientRect(),_=Math.max(0,Math.min(1,(a-l.left)/l.width));i.onSeek(_)};let A=!1;o.addEventListener("mousedown",a=>{var l;a.stopPropagation(),A=!0,(l=i.onScrubStart)==null||l.call(i),k(a.clientX)});const re=a=>{A&&k(a.clientX)},se=()=>{var a;A&&(A=!1,(a=i.onScrubEnd)==null||a.call(i))};document.addEventListener("mousemove",re),document.addEventListener("mouseup",se),o.addEventListener("touchstart",a=>{var _;A=!0,(_=i.onScrubStart)==null||_.call(i);const l=a.touches[0];l&&k(l.clientX)},{passive:!0});const ne=a=>{if(A){const l=a.touches[0];l&&k(l.clientX)}},oe=()=>{var a;A&&(A=!1,(a=i.onScrubEnd)==null||a.call(i))};document.addEventListener("touchmove",ne,{passive:!0}),document.addEventListener("touchend",oe);const ae=()=>{S&&clearTimeout(S),S=setTimeout(()=>{M&&r.classList.add("hfp-hidden")},3e3)},I=s instanceof ShadowRoot?s.host:s,de=()=>{r.classList.remove("hfp-hidden"),ae()},le=()=>{M&&r.classList.add("hfp-hidden")};return I.addEventListener("mousemove",de),I.addEventListener("mouseleave",le),{updateTime(a,l){const _=l>0?Math.min(a,l):a,be=l>0?_/l*100:0;d.style.width=`${be}%`,c.textContent=`${me(_)} / ${me(l)}`},updatePlaying(a){M=a,n.classList.toggle("hfp-playing",a),n.setAttribute("aria-label",a?"Pause":"Play"),a?ae():r.classList.remove("hfp-hidden")},updateSpeed(a){t.indexOf(a),h.textContent=W(a),te(a)},updateMuted(a){T=a,m.innerHTML=D(a,E),m.setAttribute("aria-label",a?"Unmute":"Mute")},updateVolume(a){E=a,v.style.width=`${a*100}%`,f.setAttribute("aria-valuenow",String(Math.round(a*100))),m.innerHTML=D(T,a)},setVolumeControlsHidden(a){g.style.display=a?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",se),document.removeEventListener("touchmove",ne),document.removeEventListener("touchend",oe),document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",Q),document.removeEventListener("touchmove",J),document.removeEventListener("touchend",K),document.removeEventListener("click",ie),I.removeEventListener("mousemove",de),I.removeEventListener("mouseleave",le),S&&clearTimeout(S),r.remove()}}}function Ue(s,i,e,t,r,n=!1){const o=t?t.split(",").map(Number).filter(p=>!isNaN(p)&&p>0):void 0,d={...o?{speedPresets:o}:{},audioLocked:n},c=He(s,r,d);return c.updateMuted(i),c.updateVolume(e),c}function fe(s,i,e){return i?(e||(e=document.createElement("img"),e.className="hfp-poster",s.appendChild(e)),e.src=i,e):(e==null||e.remove(),null)}function $e(s){return s.composedPath().some(i=>i instanceof HTMLElement&&i.classList.contains("hfp-controls"))}let O=null;function Ve(s,i){if(typeof CSSStyleSheet<"u")try{O||(O=new CSSStyleSheet,O.replaceSync(i)),s.adoptedStyleSheets=[O];return}catch{}const e=document.createElement("style");e.textContent=i,s.appendChild(e)}function We(){const s=document.createElement("div");s.className="hfp-container";const i=document.createElement("iframe");return i.className="hfp-iframe",i.sandbox.add("allow-scripts","allow-same-origin"),i.allow="autoplay; fullscreen",i.referrerPolicy="no-referrer",i.title="HyperFrames Composition",s.appendChild(i),{container:s,iframe:i}}function je(s,i,e,t){const r=s.offsetWidth,n=s.offsetHeight;if(r===0||n===0)return!1;const o=Math.min(r/e,n/t);return i.style.width=`${e}px`,i.style.height=`${t}px`,i.style.transform=`translate(-50%, -50%) scale(${o})`,!0}const ze=100;class Be{constructor(i){u(this,"_raf",null);u(this,"_lastUpdateMs",0);this._callbacks=i}start(i,e,t,r){this.stop();const n=()=>{if(r()){this._raf=null;return}let o;try{o=i.time()}catch{this._raf=null;return}const d=t();d>0&&(o=Math.min(o,d));const c=d>0&&o>=d,p=performance.now();if((p-this._lastUpdateMs>ze||c)&&(this._lastUpdateMs=p,this._callbacks.onTimeUpdate(o,d)),c){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{i.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(n)};this._raf=requestAnimationFrame(n)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function qe(s){const i=Array.from(s.querySelectorAll("[data-composition-id]"));if(i.length===0)return s.body?[s.body]:[];const e=[];for(const t of i)Ye(t)||e.push(t);return Ge(s),e}function Ge(s){const i=s.body;if(!i||typeof console>"u"||typeof console.warn!="function")return;const e=i.querySelectorAll("audio[data-start], video[data-start]");if(e.length===0)return;const t=[];for(const r of e)r.closest("[data-composition-id]")||t.push(r);t.length!==0&&console.warn(`[hyperframes-player] selectMediaObserverTargets: composition hosts are present, but ${t.length} body-level timed media element(s) sit outside every [data-composition-id] subtree and will not be observed. Move them inside a composition host or the parent-frame proxy will never adopt them.`,t)}function Ye(s){let i=s.parentElement;for(;i;){if(i.hasAttribute("data-composition-id"))return!0;i=i.parentElement}return!1}const Xe=(s,i,e)=>s>=i&&s<e,Ze=.05,Qe=2;class Je{constructor(i){u(this,"_entries",[]);u(this,"_mediaObserver");u(this,"_playbackErrorPosted",!1);u(this,"_audioOwner","runtime");u(this,"_urlAudioEntry",null);u(this,"_urlAudioSrc",null);u(this,"_dispatchEvent");u(this,"_getMuted");u(this,"_getVolume");u(this,"_getPlaybackRate");u(this,"_getCurrentTime");u(this,"_isPaused");this._dispatchEvent=i.dispatchEvent,this._getMuted=i.getMuted,this._getVolume=i.getVolume,this._getPlaybackRate=i.getPlaybackRate,this._getCurrentTime=i.getCurrentTime,this._isPaused=i.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;const i=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll(),this.teardownObserver(),i&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(const i of this._entries)i.el.pause(),i.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(i){for(const e of this._entries)e.el.muted=i}updateVolume(i){for(const e of this._entries)e.el.volume=i}updatePlaybackRate(i){for(const e of this._entries)e.el.playbackRate=i}_playEntry(i){i.el.src&&i.el.play().catch(e=>this._reportPlaybackError(e))}_playEntryIfActive(i){this._refreshEntryBounds(i),this._inWindow(i,this._getCurrentTime())&&this._playEntry(i)}_refreshEntryBounds(i){var t;if(!((t=i.source)!=null&&t.isConnected))return;const e=ue(i.source);i.start=e.start??0,i.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(i,e){return Xe(e,i.start,i.start+i.duration)}_gateEntryPlayback(i,e){return this._inWindow(i,e)?(this._audioOwner==="parent"&&!this._isPaused()&&i.el.paused&&this._playEntry(i),!0):(i.el.paused||i.el.pause(),i.driftSamples=0,!1)}playAll(){for(const i of this._entries)this._playEntryIfActive(i)}pauseAll(){for(const i of this._entries)i.el.pause()}stopAdoptedMedia(){for(const i of this._entries)i.source&&i.el.pause()}seekAll(i){for(const e of this._entries)this._refreshEntryBounds(e),this._inWindow(e,i)&&(e.el.currentTime=i-e.start)}scrubAll(i){for(const e of this._entries)this._refreshEntryBounds(e),this._inWindow(e,i)?(e.el.currentTime=i-e.start,this._playEntry(e)):e.el.paused||e.el.pause()}mirrorTime(i,e){const t=(e==null?void 0:e.force)===!0;for(const r of this._entries){if(this._refreshEntryBounds(r),!this._gateEntryPlayback(r,i))continue;const n=i-r.start;Math.abs(r.el.currentTime-n)>Ze?(r.driftSamples+=1,(t||r.driftSamples>=Qe)&&(r.el.currentTime=n,r.driftSamples=0)):r.driftSamples=0}}promoteToParentProxy(i,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",i)for(const r of i.querySelectorAll("video, audio"))w(r)&&(r.muted=!0);const t=this._getCurrentTime();e?e(t,{force:!0}):this.mirrorTime(t,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(i){const e=i.querySelectorAll("audio[data-start], video[data-start]");for(const t of e)w(t)&&this._adoptIframeMedia(t);this._observeDynamicMedia(i)}setupFromUrl(i){if(this._urlAudioSrc===i&&this._urlAudioEntry)return;this.teardownUrlAudio();const e=this._createEntry(i,"audio",0,1/0);this._urlAudioEntry=e,this._urlAudioSrc=e?i:null,e&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){const i=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!i)return;i.el.pause(),i.el.src="";const e=this._entries.indexOf(i);e!==-1&&this._entries.splice(e,1)}teardownObserver(){var i;(i=this._mediaObserver)==null||i.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(i){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:i}})))}_createEntry(i,e,t,r,n){if(this._entries.some(p=>p.el.src===i))return null;const o=e==="video"?document.createElement("video"):new Audio;o.preload="auto",o.src=i,o.load(),o.muted=this._getMuted(),o.volume=this._getVolume();const d=this._getPlaybackRate();d!==1&&(o.playbackRate=d);const c={el:o,start:t,duration:r,driftSamples:0,source:n};return this._entries.push(c),c}_resolveIframeMediaSrc(i){var t;const e=i.getAttribute("src")||((t=i.querySelector("source"))==null?void 0:t.getAttribute("src"));return e?new URL(e,i.ownerDocument.baseURI).href:null}_adoptIframeMedia(i){if(i.preload==="metadata"||i.preload==="none")return;const e=this._resolveIframeMediaSrc(i);if(!e)return;const t=ue(i),r=t.start??0,n=t.duration??Number.POSITIVE_INFINITY,o=i.tagName==="VIDEO"?"video":"audio",d=this._createEntry(e,o,r,n,i);d&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(d))}_detachIframeMedia(i){const e=this._resolveIframeMediaSrc(i);if(!e)return;const t=this._entries.findIndex(n=>n.el.src===e);if(t===-1)return;const r=this._entries[t];r.el.pause(),r.el.src="",this._entries.splice(t,1)}_observeDynamicMedia(i){if(this.teardownObserver(),typeof MutationObserver>"u"||!i.body)return;const e=new MutationObserver(n=>{for(const o of n){if(o.type==="attributes"&&o.attributeName==="preload"){const d=o.target;w(d)&&d.matches("audio[data-start], video[data-start]")&&d.preload==="auto"&&this._adoptIframeMedia(d);continue}for(const d of o.addedNodes){if(!he(d))continue;const c=[];w(d)&&d.matches("audio[data-start], video[data-start]")&&c.push(d);const p=d.querySelectorAll("audio[data-start], video[data-start]");for(const h of p)w(h)&&c.push(h);for(const h of c)this._adoptIframeMedia(h)}for(const d of o.removedNodes){if(!he(d))continue;const c=[];w(d)&&d.matches("audio[data-start], video[data-start]")&&c.push(d);const p=d.querySelectorAll("audio[data-start], video[data-start]");for(const h of p)w(h)&&c.push(h);for(const h of c)this._detachIframeMedia(h)}}}),t={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload"]},r=qe(i);for(const n of r)e.observe(n,t);this._mediaObserver=e}}const Ke=100;function et(s,i,e,t){const r=(s.frame??0)/i,n=e.duration>0?Math.min(r,e.duration):r,o=!e.paused,d=!s.isPlaying,c=e.duration>0&&n>=e.duration&&(o||s.isPlaying);if(c&&t.getLoop())return t.media.audioOwner==="parent"&&t.media.pauseAll(),t.seek(0),t.play(),{...e,currentTime:n,paused:!1};const p={...e,currentTime:n,paused:d};t.media.audioOwner==="parent"&&(o&&d?t.media.pauseAll():!o&&!d&&t.media.playAll(),t.media.mirrorTime(n));const h=performance.now(),y=d!==e.paused;return(h-e.lastUpdateMs>Ke||y)&&(p.lastUpdateMs=h,t.updateControlsTime(n,e.duration),t.updateControlsPlaying(!d),t.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:n}}))),c&&(t.media.audioOwner==="parent"&&t.media.pauseAll(),p.paused=!0,t.updateControlsPlaying(!1),t.dispatchEvent(new Event("ended"))),p}function tt(s){return Array.isArray(s)?s.filter(i=>typeof i=="object"&&i!==null&&typeof i.id=="string"&&typeof i.start=="number"&&typeof i.duration=="number"):[]}function it(s,i,e){var n,o,d,c,p;if(s.source!==i)return;const t=s.data;if(!t||t.source!=="hf-preview")return;const r=Ee(t);if(r.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:r.code,receivedVersion:r.receivedVersion}}));return}if((n=e.setRuntimeFps)==null||n.call(e,r.fps),t.type==="shader-transition-state"){const h=t.state&&typeof t.state=="object"?t.state:{};e.shaderLoader.update(h,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:t.compositionId,state:h}}));return}if(t.type==="ready"){e.onRuntimeReady();return}if(t.type==="assets-ready"){(o=e.onRuntimeAssetsReady)==null||o.call(e,t.timedOut===!0);return}if(t.type==="runtime-data-error"){(d=e.onRuntimeDataError)==null||d.call(e,t.channel,t.requestId,t.message);return}if(t.type==="runtime-data-applied"){(c=e.onRuntimeDataApplied)==null||c.call(e,t.channel,t.requestId);return}if(t.type==="state"){e.setPlaybackState(et({frame:t.frame??0,isPlaying:!!t.isPlaying},r.fps,e.getPlaybackState(),e));return}if(t.type==="media-autoplay-blocked"){if(((p=e.shouldPromoteMediaAutoplayFallback)==null?void 0:p.call(e))===!1)return;let h=null;try{h=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(h,(y,g)=>e.media.mirrorTime(y,g)),e.sendControl("set-media-output-muted",{muted:!0});return}if(t.type==="timeline"&&t.durationInFrames>0){const h=Number(t.durationSeconds),y=Number(t.durationInFrames),g=Number.isFinite(h)&&h>0?h:y/r.fps;if(Number.isFinite(g)&&g>0){const m=e.getPlaybackState();e.setPlaybackState({...m,duration:g}),e.updateControlsTime(m.currentTime,g),e.onRuntimeTimelineReady(g,typeof t.assetsReady=="boolean"?t.assetsReady:void 0)}Number.isFinite(t.compositionWidth)&&t.compositionWidth>0&&Number.isFinite(t.compositionHeight)&&t.compositionHeight>0&&e.setCompositionSize(t.compositionWidth,t.compositionHeight),e.setScenes(tt(t.scenes));return}t.type==="stage-size"&&Number.isFinite(t.width)&&t.width>0&&Number.isFinite(t.height)&&t.height>0&&e.setCompositionSize(t.width,t.height)}function rt(s,i){return s.includes(i)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(s)}const st=new Set([">"," "," ",`
464
+ `,"\r","\f"]);function j(s,i){const e=s.toLowerCase(),t=`<${i}`;let r=0;for(;r<e.length;){const n=e.indexOf(t,r);if(n<0)return null;const o=e[n+t.length];if(st.has(o)){const d=e.indexOf(">",n+t.length);return d<0?null:{index:n,end:d+1}}r=n+t.length}return null}function nt(s,i){if(!s||rt(s,i))return s;const e=`<script src="${i}"><\/script>`,t=j(s,"head");if(t)return s.slice(0,t.end)+e+s.slice(t.end);const r=j(s,"body");if(r)return s.slice(0,r.index)+e+s.slice(r.index);const n=j(s,"html");return n?s.slice(0,n.end)+e+s.slice(n.end):e+s}const R="shader-capture-scale",x="shader-loading",Y="runtime-src",_e="__hf_shader_capture_scale",ge="__hf_shader_loading",U=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function X(s){if(s===null)return null;const i=Number(s);return!Number.isFinite(i)||i<=0?null:String(Math.min(1,Math.max(.25,i)))}function ot(s){if(s===null||s.trim()==="")return"composition";const i=s.trim().toLowerCase();return i==="none"||i==="false"||i==="0"||i==="off"?"none":i==="player"||i==="true"||i==="1"||i==="on"?"player":"composition"}function ye(s,i){return s.filter(e=>e!==""&&e.split("=")[0]!==i)}function at(s,i,e){const t=s.indexOf("#"),r=t>=0?s.slice(0,t):s,n=t>=0?s.slice(t):"",o=r.indexOf("?"),d=o>=0?r.slice(0,o):r,c=o>=0?r.slice(o+1):"";let p=ye(c.split("&"),_e);p=ye(p,ge),i!==null&&p.push(`${_e}=${encodeURIComponent(i)}`),e!=="composition"&&p.push(`${ge}=${encodeURIComponent(e)}`);const h=p.join("&");return`${d}${h?`?${h}`:""}${n}`}function dt(s,i,e){if(i===null&&e==="composition")return s;const t=[];i!==null&&t.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(i)};`),e!=="composition"&&t.push(`window.__HF_SHADER_LOADING=${JSON.stringify(e)};`);const r=`<script data-hyperframes-player-shader-options>${t.join("")}<\/script>`;return/<head\b[^>]*>/i.test(s)?s.replace(/<head\b[^>]*>/i,n=>`${n}${r}`):/<html\b[^>]*>/i.test(s)?s.replace(/<html\b[^>]*>/i,n=>`${n}${r}`):`${r}${s}`}function L(s){return ot(s.getAttribute(x))}function lt(s){return Number(X(s.getAttribute(R))??"1")}function N(s,i){return at(i,X(s.getAttribute(R)),L(s))}function F(s,i){return nt(dt(i,X(s.getAttribute(R)),L(s)),ut(s))}function ut(s){var e;const i=(e=s.getAttribute(Y))==null?void 0:e.trim();if(!i)return H;try{const t=new URL(i,document.baseURI),r=t.protocol==="http:"||t.protocol==="https:",n=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]";return r&&(n||t.origin===location.origin)?t.href:H}catch{return H}}function ht(){const s=document.createElement("div");s.className="hfp-shader-loader",s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-label","Preparing scene transitions"),s.setAttribute("data-hyperframes-ignore",""),s.draggable=!1;const i=m=>{m.preventDefault(),m.stopPropagation()};for(const m of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])s.addEventListener(m,i,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const t=document.createElement("div");t.className="hfp-shader-loader-mark",t.draggable=!1,t.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");const r=document.createElement("div");r.className="hfp-shader-loader-title";const n=document.createElement("span");n.className="hfp-shader-loader-title-text",n.textContent=U[0],r.appendChild(n);const o=document.createElement("div");o.className="hfp-shader-loader-detail",o.textContent="Rendering animated scene samples for shader transitions.";const d=document.createElement("div");d.className="hfp-shader-loader-track",d.setAttribute("aria-hidden","true");const c=document.createElement("div");c.className="hfp-shader-loader-fill",d.appendChild(c);const p=document.createElement("div");p.className="hfp-shader-loader-progress";const h=m=>{const b=document.createElement("div");b.className="hfp-shader-loader-row";const f=document.createElement("span");f.className="hfp-shader-loader-label",f.textContent=m;const v=document.createElement("span");return v.className="hfp-shader-loader-value",b.appendChild(f),b.appendChild(v),p.appendChild(b),{row:b,label:f,value:v}},y=h("transition"),g=h("transition frame");return e.appendChild(t),e.appendChild(r),e.appendChild(o),e.appendChild(d),e.appendChild(p),s.appendChild(e),{root:s,fill:c,title:n,detail:o,transitionValue:y.value,frameLabel:g.label,frameValue:g.value,frameRow:g.row}}const ct=420;class pt{constructor(i){u(this,"_el");u(this,"_hideTimeout",null);this._el=i}show(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-hiding"),this._el.root.classList.add("hfp-visible")}hide(){if(this._el.root.classList.contains("hfp-hiding")){this._hideTimeout||this._scheduleCleanup();return}this._el.root.classList.contains("hfp-visible")&&(this._el.root.classList.add("hfp-hiding"),this._el.root.classList.remove("hfp-visible"),this._scheduleCleanup())}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._el.fill.style.transform="scaleX(0)",this._el.transitionValue.textContent="",this._el.frameValue.textContent="",this._el.frameRow.style.visibility="hidden"}update(i,e){if(e!=="player"){this.reset();return}if(i.ready||!i.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions");const t=typeof i.progress=="number"&&Number.isFinite(i.progress)?i.progress:0,r=typeof i.total=="number"&&Number.isFinite(i.total)?i.total:0,n=r>0?Math.min(1,Math.max(0,t/r)):0,o=Math.min(U.length-1,Math.floor(n*U.length));this._el.title.textContent=U[o]||"Preparing scene transitions",this._el.detail.textContent=i.phase==="cached"?"Loading cached transition frames before playback.":i.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${n})`,this._el.transitionValue.textContent=i.currentTransition!==void 0&&i.transitionTotal!==void 0?`${i.currentTransition}/${i.transitionTotal}`:r>0?`${t}/${r}`:"";const d=i.transitionFrame!==void 0&&i.transitionFrames!==void 0?`${i.transitionFrame}/${i.transitionFrames}`:"";this._el.frameLabel.textContent=i.phase==="cached"?"cached transition frames":i.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",this._el.frameValue.textContent=d,this._el.frameRow.style.visibility=d?"visible":"hidden",this._el.root.setAttribute("aria-valuenow",String(Math.round(n*100))),this.show()}showAssetsLoading(){this.reset(),this._el.title.textContent="Loading assets",this._el.detail.textContent="Waiting for images, video and fonts to finish loading.",this._el.root.setAttribute("aria-label","Loading assets"),this.show()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null)}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null},ct)}}const mt=.1,ft=5,z="sandbox-origin",ve=1e4,B=8e3,q="assets-loading",_t=150;function G(s){return!Number.isFinite(s)||s<=0?1:Math.max(mt,Math.min(ft,s))}class gt extends HTMLElement{constructor(){super();u(this,"shadow");u(this,"container");u(this,"iframe");u(this,"posterEl",null);u(this,"controlsApi",null);u(this,"resizeObserver");u(this,"shaderLoader");u(this,"probe");u(this,"_ready",!1);u(this,"_assetsReady",!1);u(this,"_pendingPlay",!1);u(this,"_assetsGeneration",0);u(this,"_assetsLoadingShowTimer",null);u(this,"_currentTime",0);u(this,"_duration",0);u(this,"_paused",!0);u(this,"_scrubbing",!1);u(this,"_lastUpdateMs",0);u(this,"_volume",1);u(this,"_compositionWidth",1920);u(this,"_compositionHeight",1080);u(this,"_rescaleWarned",!1);u(this,"_directTimelineAdapter",null);u(this,"_directTimelineClock");u(this,"_parentTickRaf",null);u(this,"_media");u(this,"_scenes",[]);u(this,"_runtimeFps",30);u(this,"_runtimeBridgeReady",!1);u(this,"_runtimeAssetsReadyGeneration",-1);u(this,"_runtimeData",new Map);u(this,"_runtimeDataRequestId",0);u(this,"_pendingRuntimeData",new Map);this.shadow=this.attachShadow({mode:"open"}),Ve(this.shadow,ke),{container:this.container,iframe:this.iframe}=We(),this.shadow.appendChild(this.container);const e=ht();this.shadow.appendChild(e.root),this.shaderLoader=new pt(e),this._media=new Je({dispatchEvent:t=>this.dispatchEvent(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Be({onTimeUpdate:(t,r)=>{var n;this._currentTime=t,(n=this.controlsApi)==null||n.updateTime(t,r),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:t}}))},getLoop:()=>this.loop,restart:()=>{this.seek(0),this.play()},onPaused:()=>{var t;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(t=this.controlsApi)==null||t.updatePlaying(!1),this.dispatchEvent(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new Pe(this.iframe,{onReady:t=>this._onProbeReady(t),onError:t=>this.dispatchEvent(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{$e(t)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this)}static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src",z,Y,R,x]}connectedCallback(){this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.iframe.addEventListener("load",this._onIframeLoad),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=fe(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=F(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&(this.iframe.src=N(this,this.getAttribute("src"))),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.iframe.removeEventListener("load",this._onIframeLoad),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),(e=this.controlsApi)==null||e.destroy(),this.controlsApi=null,this._paused=!0,this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Player disconnected before runtime data was applied")}attributeChangedCallback(e,t,r){var n,o,d,c,p;switch(e){case"src":if(!this.isConnected)break;r&&(this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Composition navigated before runtime data was applied"),this.iframe.src=N(this,r));break;case"srcdoc":if(!this.isConnected)break;this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Composition navigated before runtime data was applied"),r!==null?this.iframe.srcdoc=F(this,r):this.iframe.removeAttribute("srcdoc");break;case z:this._applySandboxOriginPolicy(this.isConnected&&t!==r);break;case"width":this._compositionWidth=V(r)??1920,this._rescale();break;case"height":this._compositionHeight=V(r)??1080,this._rescale();break;case"controls":r!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=fe(this.shadow,r,this.posterEl);break;case"playback-rate":{const h=G(parseFloat(r||"1"));this._media.updatePlaybackRate(h),this._sendControl("set-playback-rate",{playbackRate:h}),(d=(o=this._directTimelineAdapter)==null?void 0:o.timeScale)==null||d.call(o,h),(c=this.controlsApi)==null||c.updateSpeed(h),this.dispatchEvent(new Event("ratechange"));break}case"muted":this._handleMutedChange(r);break;case"audio-locked":this._applyAudioLock(r!==null);break;case"volume":{const h=Math.max(0,Math.min(1,parseFloat(r||"1")));this._volume=h,this._media.updateVolume(h),this._sendControl("set-volume",{volume:h}),(p=this.controlsApi)==null||p.updateVolume(h),this.dispatchEvent(new Event("volumechange"));break}case"audio-src":r?this._media.setupFromUrl(r):this._media.teardownUrlAudio();break;case R:case x:case Y:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(z)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Sandbox policy changed before runtime data was applied");const e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=F(this,e);return}const t=this.getAttribute("src");this.iframe.src=t===null?"about:blank":N(this,t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){var r,n;if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,(r=this.posterEl)==null||r.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const e=this._tryDirectTimelinePlay();let t=!1;e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,t=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),(n=this.controlsApi)==null||n.updatePlaying(!0),t||this.dispatchEvent(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){var e;this._pendingPlay=!1,this._tryDirectTimelinePause()||this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1),this.dispatchEvent(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){var t,r;this._pendingPlay=!1,!this._trySyncSeek(e)&&!this._tryDirectTimelineSeek(e)&&this._sendControl("seek",{timeSeconds:e,frame:Math.round(e*this._runtimeFps)}),this._directTimelineClock.stop(),this._stopParentTickClock(),this._currentTime=e,this._media.audioOwner==="parent"&&(this._scrubbing?this._media.scrubAll(e):(this._media.pauseAll(),this._media.seekAll(e))),this._paused=!0,(t=this.controlsApi)==null||t.updatePlaying(!1),(r=this.controlsApi)==null||r.updateTime(this._currentTime,this._duration)}setColorGrading(e,t){this._sendControl("set-color-grading",{target:e,grading:t})}clearColorGrading(e){this._sendControl("set-color-grading",{target:e,grading:null})}setColorGradingCompare(e,t){this._sendControl("set-color-grading-compare",{target:e,compare:t})}clearColorGradingCompare(e){this._sendControl("set-color-grading-compare",{target:e,compare:{enabled:!1}})}setRuntimeData(e,t){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);if(typeof structuredClone!="function")throw new Error("HyperFrames runtime data requires structuredClone support; refusing an unverified payload");const r=structuredClone(t);this._runtimeData.set(e,r),this._deliverRuntimeData(e,r)}clearRuntimeData(e){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);this._runtimeData.delete(e),this._deliverRuntimeDataClear(e)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get paused(){return this._paused}get ready(){return this._ready}get assetsReady(){return this._assetsReady}get playbackRate(){return G(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(G(e)))}get shaderCaptureScale(){return lt(this)}set shaderCaptureScale(e){this.setAttribute(R,String(e))}get shaderLoading(){return L(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(x):this.setAttribute(x,e)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_isLockedHostEnvironment(){if(typeof navigator>"u")return!1;const e=navigator.userAgent||"";return/\bClaude\/\d/.test(e)&&/\bElectron\b/.test(e)}_isAudioLocked(){return this.hasAttribute("audio-locked")||this._isLockedHostEnvironment()}_isSlideshowPlayer(){return this.closest("hyperframes-slideshow")!==null}_handleMutedChange(e){var t;if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(t=this.controlsApi)==null||t.updateMuted(e!==null),this.dispatchEvent(new Event("volumechange"))}_applyAudioLock(e){var t;e&&(this.muted=!0),(t=this.controlsApi)==null||t.setVolumeControlsHidden(e)}get volume(){return this._volume}set volume(e){this.setAttribute("volume",String(Math.max(0,Math.min(1,e))))}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_sendControl(e,t={}){try{const r=this.iframe.contentWindow;return r?(r.postMessage({...t,source:"hf-parent",type:"control",action:e,...Te(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,"Composition iframe is unavailable"),!1)}catch(r){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,r instanceof Error?r.message:String(r)),!1}}_deliverRuntimeData(e,t){if(!this.isConnected||!this._runtimeBridgeReady)return;const r=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,t,r)||this._sendControl("set-runtime-data",{channel:e,payload:t,requestId:r})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;const t=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,t)||this._sendControl("clear-runtime-data",{channel:e,requestId:t})}_trySetRuntimeDataDirect(e,t,r){var n;try{const o=(n=this.iframe.contentWindow)==null?void 0:n.__hyperframes;return typeof(o==null?void 0:o.setRuntimeData)!="function"?!1:(o.setRuntimeData(e,t,r),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,t){var r;try{const n=(r=this.iframe.contentWindow)==null?void 0:r.__hyperframes;return typeof(n==null?void 0:n.clearRuntimeData)!="function"?!1:(n.clearRuntimeData(e,t),!0)}catch{return!1}}_replayRuntimeData(){for(const[e,t]of this._runtimeData)this._deliverRuntimeData(e,t)}_beginRuntimeDataDelivery(e){const t=this._pendingRuntimeData.get(e);t&&window.clearTimeout(t.timeoutId),this._runtimeDataRequestId+=1;const r=this._runtimeDataRequestId,n=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,r,`Runtime data delivery timed out after ${ve}ms`)},ve);return this._pendingRuntimeData.set(e,{requestId:r,timeoutId:n}),r}_resolveRuntimeDataDelivery(e,t){const r=this._takeRuntimeDataDelivery(e,t);r&&this.dispatchEvent(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:r.requestId}}))}_rejectRuntimeDataDelivery(e,t,r){const n=this._takeRuntimeDataDelivery(e,t);n&&this.dispatchEvent(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:n.requestId,message:typeof r=="string"?r:String(r)}}))}_takeRuntimeDataDelivery(e,t){if(typeof e!="string"||typeof t!="number"||!Number.isSafeInteger(t))return null;const r=this._pendingRuntimeData.get(e);return!r||r.requestId!==t?null:(window.clearTimeout(r.timeoutId),this._pendingRuntimeData.delete(e),r)}_rejectAllRuntimeDataDeliveries(e){for(const[t,r]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(t,r.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){const t=this._getSameOriginIframeDocument();if(t)for(const r of t.querySelectorAll("video, audio"))w(r)&&(r.muted=e||r.defaultMuted)}_stopIframeMedia(){const e=this._getSameOriginIframeDocument();if(e)for(const t of e.querySelectorAll("video, audio"))w(t)&&t.pause()}_replayBridgeState(){this._sendControl("set-muted",{muted:this.muted}),this._sendControl("set-volume",{volume:this._volume}),this._sendControl("set-playback-rate",{playbackRate:this.playbackRate}),this._sendControl("set-native-media-sync-disabled",{disabled:this._isSlideshowPlayer()}),this._sendControl("set-web-audio-media-disabled",{disabled:this._isSlideshowPlayer()})}_reloadShaderOptions(){if(this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Shader options changed before runtime data was applied"),L(this)!=="player"&&this.shaderLoader.reset(),this.hasAttribute("srcdoc")){this.iframe.srcdoc=F(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&(this.iframe.src=N(this,this.getAttribute("src")||""))}_trySyncSeek(e){try{const t=this.iframe.contentWindow,r=t==null?void 0:t.__player;return typeof(r==null?void 0:r.seek)!="function"?!1:(r.seek.call(r,e),!0)}catch{return!1}}_withDirectTimeline(e){var n;const t=this.probe.resolveDirectTimelineAdapter(),r=t||this._directTimelineAdapter;if(!r)return!1;try{if(e(r),t&&t!==this._directTimelineAdapter){const o=t.duration();Number.isFinite(o)&&o>0&&(this._duration=o,(n=this.controlsApi)==null||n.updateTime(this._currentTime,o))}return this._directTimelineAdapter=r,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(t=>{t.seek(e,!1),t.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>void e.play())}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>void e.pause())}_startParentTickClock(){this._stopParentTickClock();const e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){it(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:t,duration:r,paused:n,lastUpdateMs:o})=>{this._currentTime=t,this._duration=r,this._paused=n,this._lastUpdateMs=o},getShaderLoadingMode:()=>L(this),shaderLoader:this.shaderLoader,setCompositionSize:(t,r)=>{this._compositionWidth=t,this._compositionHeight=r,this._rescale()},sendControl:(t,r)=>this._sendControl(t,r),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(t,r)=>this._resolveRuntimeDataDelivery(t,r),onRuntimeDataError:(t,r,n)=>this._rejectRuntimeDataDelivery(t,r,n),onRuntimeTimelineReady:(t,r)=>this._onRuntimeTimelineReady(t,r),setRuntimeFps:t=>{this._runtimeFps=t},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:t=>{this._scenes=t,this.dispatchEvent(new CustomEvent("scenes",{detail:{scenes:t}}))},updateControlsTime:(t,r)=>{var n;return(n=this.controlsApi)==null?void 0:n.updateTime(t,r)},updateControlsPlaying:t=>{var r;return(r=this.controlsApi)==null?void 0:r.updatePlaying(t)},dispatchEvent:t=>this.dispatchEvent(t),seek:t=>this.seek(t),play:()=>this.play(),getLoop:()=>this.loop,media:this._media})}_onRuntimeTimelineReady(e,t){var n;if(this._ready)return;this.probe.stop(),this._duration=e,this._directTimelineAdapter=null,this._ready=!0,(n=this.controlsApi)==null||n.updateTime(this._currentTime,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),this._rescale();const r=this._getSameOriginIframeDocument();r&&this._media.setupFromIframe(r),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(r,t),(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()}_onProbeReady({duration:e,adapter:t,compositionSize:r}){var o;this._duration=e,this._directTimelineAdapter=t.kind==="direct-timeline"?t.timeline:null,this._ready=!0,(o=this.controlsApi)==null||o.updateTime(0,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),r&&(this._compositionWidth=r.width,this._compositionHeight=r.height,this._rescale());const n=this._getSameOriginIframeDocument();n&&this._media.setupFromIframe(n),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(n),(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()}_waitForAssetsReady(e,t){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1;const r=++this._assetsGeneration;if(!e){t===!1?(this._runtimeAssetsReadyGeneration=r,this._startAssetsLoadingOverlayTimer(r),setTimeout(()=>this._settleAssetsReady(r),B)):this._settleAssetsReady(r);return}Ce(e,({timedOut:n})=>{r===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(r))},{timeoutMs:B}),this._assetsReady||this._startAssetsLoadingOverlayTimer(r)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(q,""),this.shaderLoader.showAssetsLoading())},_t)}_warnStuckAssets(e){const{pendingMedia:t,pendingImages:r,fontsLoading:n}=Re(e),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${B}ms — playing anyway`,{stuckMedia:t.map(d=>d.currentSrc||d.getAttribute("src")||`<${d.tagName.toLowerCase()}>`),stuckImages:r.map(d=>d.currentSrc||d.getAttribute("src")||"<img>"),fontsLoading:n,computeReady:(o==null?void 0:o.__renderReady)===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(q),this.shaderLoader.hide(),this.dispatchEvent(new Event("assetsready")),this._pendingPlay&&this.play())}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._pendingPlay=!1,this._assetsGeneration++,this.removeAttribute(q),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_rescale(){!je(this,this.iframe,this._compositionWidth,this._compositionHeight)&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready — zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){this._ready&&this._getSameOriginIframeDocument()===null||(this._ready=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this._invalidateAssetsWait(),this.shaderLoader.reset(),this._media.resetForIframeLoad(),this.probe.start())}_setupControls(){this.controlsApi||(this.controlsApi=Ue(this.shadow,this.muted,this._volume,this.getAttribute("speed-presets"),{onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:e=>this.seek(e*this._duration),onScrubStart:()=>{this._scrubbing=!0},onScrubEnd:()=>{this._scrubbing=!1,this.seek(this._currentTime)},onSpeedChange:e=>void(this.playbackRate=e),onMuteToggle:()=>void(this.muted=!this.muted),onVolumeChange:e=>void(this.volume=e)},this._isAudioLocked()))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,t){this._media.mirrorTime(e,t)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(t,r)=>this._mirrorParentMediaTime(t,r)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}}customElements.get("hyperframes-player")||customElements.define("hyperframes-player",gt);export{gt as HyperframesPlayer,Fe as SPEED_PRESETS,W as formatSpeed,me as formatTime};