@hyperframes/studio 0.8.142 → 0.8.143

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 (32) hide show
  1. package/dist/assets/{hyperframes-player-sAsRuV73.js → hyperframes-player-BXSuksFh.js} +3 -3
  2. package/dist/assets/{index-D3Vij9t1.js → index-BgOVCqjo.js} +1 -1
  3. package/dist/assets/{index-D5q2_7Gw.js → index-FgyO_5Kv.js} +1 -1
  4. package/dist/assets/{index-B-wffzRH.js → index-J7jpL4pj.js} +150 -150
  5. package/dist/index.html +1 -1
  6. package/dist/index.js +122 -160
  7. package/dist/index.js.map +1 -1
  8. package/package.json +8 -8
  9. package/src/components/MediaPreview.tsx +2 -1
  10. package/src/components/editor/mediaAudioEdits.test.ts +12 -0
  11. package/src/components/editor/mediaAudioEdits.ts +5 -5
  12. package/src/components/editor/propertyPanelFill.tsx +2 -1
  13. package/src/components/editor/propertyPanelFlatMediaSection.tsx +3 -4
  14. package/src/components/editor/propertyPanelMediaSection.tsx +3 -4
  15. package/src/components/editor/useColorGradingController.ts +2 -1
  16. package/src/hooks/useDomEditCommits.ts +2 -1
  17. package/src/hooks/useFileManager.ts +2 -1
  18. package/src/hooks/useFileTree.ts +2 -1
  19. package/src/hooks/useRenderClipContent.ts +15 -3
  20. package/src/player/components/clipMenuNormalize.ts +2 -2
  21. package/src/player/components/clipPeakMap.ts +2 -2
  22. package/src/player/components/thumbnailUtils.test.ts +33 -0
  23. package/src/player/components/thumbnailUtils.ts +5 -0
  24. package/src/player/lib/mediaProbe.test.ts +12 -0
  25. package/src/player/lib/mediaProbe.ts +4 -2
  26. package/src/utils/sourcePatcher.test.ts +135 -0
  27. package/src/utils/sourcePatcher.ts +102 -186
  28. package/src/utils/studioHelpers.test.ts +23 -0
  29. package/src/utils/studioHelpers.ts +3 -2
  30. package/src/utils/studioSelectionSnapshot.test.ts +31 -0
  31. package/src/utils/timelineAssetDrop.test.ts +14 -0
  32. package/src/utils/timelineAssetDrop.ts +2 -1
@@ -1,4 +1,4 @@
1
- var Ve=Object.defineProperty;var He=(r,i,e)=>i in r?Ve(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var l=(r,i,e)=>He(r,typeof i!="symbol"?i+"":i,e);import{i as Ue,c as We,p as Oe,a as ze,r as $e,S as je,b as ye,d as qe,e as w,f as ve,g as Be,h as Ge,j as Ye,k as Xe,s as Ze,l as be,F as we}from"./index-B-wffzRH.js";function Ae(r){if(r==null||r.trim()==="")return null;const i=Number.parseInt(r,10);return Number.isFinite(i)&&i>0?i:null}function Ke(r=document){const i=r.querySelector('[data-composition-id][data-root="true"]');return Ue(i)?i:r.querySelector("[data-composition-id]")}const Se=r=>r!==null&&Number.isFinite(r)&&r>0;function ee(r){const i=r.clipEndsSeconds.filter(t=>t===null).length;if(Se(r.authoredDurationSeconds))return{seconds:r.authoredDurationSeconds,source:"authored",pendingClips:i};const e=r.clipEndsSeconds.filter(Se);return e.length>0?{seconds:Math.max(...e),source:"derived",pendingClips:i}:{seconds:null,source:"unresolved",pendingClips:i,reason:i>0?"every clip's length is still pending":"no authored duration and no clip with a length"}}function Qe(){return{capturedTimeline:null,isPlaying:!1,currentTime:0,deterministicAdapters:[],canonicalFps:30,bridgeMuted:!1,bridgeVolume:1,mediaOutputMuted:!1,nativeMediaSyncDisabled:!1,webAudioMediaDisabled:!1,mediaAutoplayBlockedPosted:!1,mediaForceSyncNextTick:!1,playbackRate:1,bridgeLastPostedFrame:-1,bridgeLastPostedAt:0,bridgeLastPostedPlaying:!1,bridgeLastPostedMuted:!1,bridgeMaxPostIntervalMs:80,controlBridgeHandler:null,beforeUnloadHandler:null,injectedCompStyles:[],injectedCompScripts:[],injectedCompLinks:[],cachedTimedMediaEls:[],cachedMediaClips:[],cachedVideoClips:[],cachedMediaTimelineDurationSeconds:0,tornDown:!1,transportClock:null,transportRafId:null}}const te=1/60,$=r=>r!==null&&r>te?r:null;function Je(r){return{width:Ae(r.getAttribute("data-width")),height:Ae(r.getAttribute("data-height"))}}function et(r,i){const e=[];for(const t of r.querySelectorAll("video[data-start], audio[data-start]")){const s=i.mediaStart(t);if(!Number.isFinite(s))continue;const n=i.mediaDuration(t);n==null||n<=te||e.push(Math.max(0,s)+n)}return $(ee({authoredDurationSeconds:null,clipEndsSeconds:e}).seconds)}function tt(r,i){var s;const e=[];for(const n of r.querySelectorAll("[data-composition-id][data-start]")){if(((s=n.parentElement)==null?void 0:s.closest("[data-composition-id]"))!==r)continue;const o=i.resolveStartForElement(n,0),a=i.resolveDurationForElement(n);!Number.isFinite(o)||a==null||a<=0||e.push(Math.max(0,o)+a)}const t=Oe(r.getAttribute("data-duration"));return $(ee({authoredDurationSeconds:null,clipEndsSeconds:[t,...e]}).seconds)}const it=r=>r.hasAttribute("data-composition-id")||r.hasAttribute("data-composition-src");function st(r,i,{unregisteredLottie:e}){const t=[];for(const n of r.querySelectorAll("[data-start]")){const o=i.resolveStartForElement(n,0);if(!Number.isFinite(o))continue;const a=i.resolveDurationForElement(n);a!=null?t.push(Math.max(0,o)+a):(ze(n)||it(n))&&t.push(null)}r.querySelector("[data-lottie-src]")&&t.push(null);const s=ee({authoredDurationSeconds:null,clipEndsSeconds:t});return s.pendingClips>0?{...s,seconds:null,source:"unresolved",reason:"a clip's length is pending"}:s}function rt(r){if(r.declared!==null&&Number.isFinite(r.declared)&&r.declared>0)return r.declared;const i=$(r.timeline()),e=Math.max(0,...r.floors().map(n=>n??0)),t=Number.isFinite(r.fallback)&&r.fallback>te?r.fallback:0;let s;return i!==null?s=Math.max(i,e,t):$(e)!==null?s=Math.max(e,t):t>0?s=t:s=r.derived(),s>0?s:0}function nt(r){const i=Ke(r);if(!i)return null;const e=We({timelineRegistry:{},includeAuthoredTimingAttrs:!0,documentRef:r}),t=rt({declared:Oe(i.getAttribute("data-duration")),timeline:()=>null,floors:()=>[et(r,{mediaStart:e.resolveMediaStartForElement,mediaDuration:$e}),tt(i,e)],fallback:0,derived:()=>st(i,e,{unregisteredLottie:!1}).seconds??0});return{...Je(i),fps:Qe().canonicalFps,durationSeconds:t}}function ot(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function x(r){return typeof r=="object"&&r!==null}function at(r){return x(r)&&typeof r.getDuration=="function"}function dt(r){return x(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function lt(r){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(r))throw new Error(`Invalid HyperFrames runtime version: ${r}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${r}/dist/hyperframe.runtime.iife.js`}const W=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:lt("0.0.0-dev");function j(r){if(r===null)return null;const i=Number.parseInt(r,10);return Number.isFinite(i)&&i>0?i:null}function ut(r){const i=(r==null?void 0:r.querySelector("[data-composition-id][data-width][data-height]"))??(r==null?void 0:r.querySelector("[data-width][data-height]"));if(!i)return null;const e=j(i.getAttribute("data-width")),t=j(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}function ht(r){return Array.isArray(r)?r.find(i=>typeof i=="string"&&i.trim()!==""&&i!=="[object Event]")??null:null}class ct{constructor(i,e){l(this,"_interval",null);l(this,"_runtimeInjected",!1);l(this,"_failure",null);this._iframe=i,this._callbacks=e}get failed(){return this._failure!==null&&this._failure.document===this._iframe.contentDocument}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._failure=null,this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{i++;let e=null;try{e=this._poll(i)}catch(t){t instanceof DOMException&&t.name==="SecurityError"||(e={kind:"error",message:t instanceof Error?t.message:String(t)})}if(e){this.stop(),e.kind==="error"?(this._failure={document:this._iframe.contentDocument},this._callbacks.onError(e.message)):this._callbacks.onReady(e.result);return}i>=40&&(this.stop(),this._failure={document:this._iframe.contentDocument},this._callbacks.onError("Composition timeline not found after 8s"))},200)}_poll(i){const e=this._iframe.contentWindow;if(!e)return null;const t=ht(Reflect.get(e,je));if(t!==null)return{kind:"error",message:t};const s=this._iframe.contentDocument,n=Reflect.get(e,"__timelines"),o=this.hasRuntimeBridge(e);if(ot({hasRuntime:o,hasTimelines:x(n)&&Object.keys(n).length>0,hasNestedCompositions:!!(s!=null&&s.querySelector("[data-composition-src]")),runtimeInjected:this._runtimeInjected,attempts:i}))return this._injectRuntime(),null;if(this._runtimeInjected&&!o)return null;const a=this._resolveReadyResult(e,s);return a?{kind:"ready",result:a}:null}_resolveReadyResult(i,e){var n;const t=this._resolvePlaybackDurationAdapter(i)??{kind:"document",getDuration:()=>0};let s=t.getDuration();if(!Number.isFinite(s)||s<=0){if(t.kind==="direct-timeline")return null;s=e?((n=nt(e))==null?void 0:n.durationSeconds)??0:0}return s<=0?null:{duration:s,adapter:{...t,getDuration:()=>s},compositionSize:ut(e)}}stop(){this.failed||(this._failure=null),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||x(Reflect.get(i,"__player"))}_injectRuntime(){var i,e;this._runtimeInjected=!0;try{const t=this._iframe.contentDocument;if(!t)return;const s=t.createElement("script");s.src=W,(t.head||t.documentElement).appendChild(s),(e=(i=this._callbacks).onRuntimeInjected)==null||e.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(i){var a,c;if(this.hasRuntimeBridge(i))return null;const e=Reflect.get(i,"__timelines");if(!x(e))return null;const t=Object.keys(e);if(t.length===0)return null;const s=(c=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:c.getAttribute("data-composition-id"),n=s&&s in e?s:t[t.length-1],o=e[n];return dt(o)?o:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(at(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const pt=`
1
+ var He=Object.defineProperty;var Ue=(r,i,e)=>i in r?He(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var l=(r,i,e)=>Ue(r,typeof i!="symbol"?i+"":i,e);import{i as We,c as ze,p as Oe,a as $e,r as je,S as qe,b as ye,d as Be,e as w,f as ve,g as Ge,h as Ye,j as Xe,k as Ze,s as Ke,l as be,F as we}from"./index-J7jpL4pj.js";function Ae(r){if(r==null||r.trim()==="")return null;const i=Number.parseInt(r,10);return Number.isFinite(i)&&i>0?i:null}function Qe(r=document){const i=r.querySelector('[data-composition-id][data-root="true"]');return We(i)?i:r.querySelector("[data-composition-id]")}const Se=r=>r!==null&&Number.isFinite(r)&&r>0;function ee(r){const i=r.clipEndsSeconds.filter(t=>t===null).length;if(Se(r.authoredDurationSeconds))return{seconds:r.authoredDurationSeconds,source:"authored",pendingClips:i};const e=r.clipEndsSeconds.filter(Se);return e.length>0?{seconds:Math.max(...e),source:"derived",pendingClips:i}:{seconds:null,source:"unresolved",pendingClips:i,reason:i>0?"every clip's length is still pending":"no authored duration and no clip with a length"}}function Je(){return{capturedTimeline:null,isPlaying:!1,currentTime:0,deterministicAdapters:[],canonicalFps:30,bridgeMuted:!1,bridgeVolume:1,mediaOutputMuted:!1,nativeMediaSyncDisabled:!1,webAudioMediaDisabled:!1,mediaAutoplayBlockedPosted:!1,mediaForceSyncNextTick:!1,playbackRate:1,bridgeLastPostedFrame:-1,bridgeLastPostedAt:0,bridgeLastPostedPlaying:!1,bridgeLastPostedMuted:!1,bridgeMaxPostIntervalMs:80,controlBridgeHandler:null,beforeUnloadHandler:null,injectedCompStyles:[],injectedCompScripts:[],injectedCompLinks:[],cachedTimedMediaEls:[],cachedMediaClips:[],cachedVideoClips:[],cachedMediaTimelineDurationSeconds:0,tornDown:!1,transportClock:null,transportRafId:null}}const te=1/60,$=r=>r!==null&&r>te?r:null;function et(r){return{width:Ae(r.getAttribute("data-width")),height:Ae(r.getAttribute("data-height"))}}function tt(r,i){const e=[];for(const t of r.querySelectorAll("video[data-start], audio[data-start]")){const s=i.mediaStart(t);if(!Number.isFinite(s))continue;const n=i.mediaDuration(t);n==null||n<=te||e.push(Math.max(0,s)+n)}return $(ee({authoredDurationSeconds:null,clipEndsSeconds:e}).seconds)}function it(r,i){var s;const e=[];for(const n of r.querySelectorAll("[data-composition-id][data-start]")){if(((s=n.parentElement)==null?void 0:s.closest("[data-composition-id]"))!==r)continue;const o=i.resolveStartForElement(n,0),a=i.resolveDurationForElement(n);!Number.isFinite(o)||a==null||a<=0||e.push(Math.max(0,o)+a)}const t=Oe(r.getAttribute("data-duration"));return $(ee({authoredDurationSeconds:null,clipEndsSeconds:[t,...e]}).seconds)}const st=r=>r.hasAttribute("data-composition-id")||r.hasAttribute("data-composition-src");function rt(r,i,{unregisteredLottie:e}){const t=[];for(const n of r.querySelectorAll("[data-start]")){const o=i.resolveStartForElement(n,0);if(!Number.isFinite(o))continue;const a=i.resolveDurationForElement(n);a!=null?t.push(Math.max(0,o)+a):($e(n)||st(n))&&t.push(null)}r.querySelector("[data-lottie-src]")&&t.push(null);const s=ee({authoredDurationSeconds:null,clipEndsSeconds:t});return s.pendingClips>0?{...s,seconds:null,source:"unresolved",reason:"a clip's length is pending"}:s}function nt(r){if(r.declared!==null&&Number.isFinite(r.declared)&&r.declared>0)return r.declared;const i=$(r.timeline()),e=Math.max(0,...r.floors().map(n=>n??0)),t=Number.isFinite(r.fallback)&&r.fallback>te?r.fallback:0;let s;return i!==null?s=Math.max(i,e,t):$(e)!==null?s=Math.max(e,t):t>0?s=t:s=r.derived(),s>0?s:0}function ot(r){const i=Qe(r);if(!i)return null;const e=ze({timelineRegistry:{},includeAuthoredTimingAttrs:!0,documentRef:r}),t=nt({declared:Oe(i.getAttribute("data-duration")),timeline:()=>null,floors:()=>[tt(r,{mediaStart:e.resolveMediaStartForElement,mediaDuration:je}),it(i,e)],fallback:0,derived:()=>rt(i,e,{unregisteredLottie:!1}).seconds??0});return{...et(i),fps:Je().canonicalFps,durationSeconds:t}}function at(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function x(r){return typeof r=="object"&&r!==null}function dt(r){return x(r)&&typeof r.getDuration=="function"}function lt(r){return x(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function ut(r){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(r))throw new Error(`Invalid HyperFrames runtime version: ${r}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${r}/dist/hyperframe.runtime.iife.js`}const W=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:ut("0.0.0-dev");function j(r){if(r===null)return null;const i=Number.parseInt(r,10);return Number.isFinite(i)&&i>0?i:null}function ht(r){const i=(r==null?void 0:r.querySelector("[data-composition-id][data-width][data-height]"))??(r==null?void 0:r.querySelector("[data-width][data-height]"));if(!i)return null;const e=j(i.getAttribute("data-width")),t=j(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}function ct(r){return Array.isArray(r)?r.find(i=>typeof i=="string"&&i.trim()!==""&&i!=="[object Event]")??null:null}class pt{constructor(i,e){l(this,"_interval",null);l(this,"_runtimeInjected",!1);l(this,"_runtimeScript",null);l(this,"_failure",null);this._iframe=i,this._callbacks=e}get failed(){return this._failure!==null&&this._failure.document===this._iframe.contentDocument}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._failure=null,this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{i++;let e=null;try{e=this._poll(i)}catch(t){t instanceof DOMException&&t.name==="SecurityError"||(e={kind:"error",message:t instanceof Error?t.message:String(t)})}if(e){this.stop(),e.kind==="error"?(this._failure={document:this._iframe.contentDocument},this._callbacks.onError(e.message)):this._callbacks.onReady(e.result);return}i>=40&&(this.stop(),this._failure={document:this._iframe.contentDocument},this._callbacks.onError("Composition timeline not found after 8s"))},200)}_poll(i){const e=this._iframe.contentWindow;if(!e)return null;const t=ct(Reflect.get(e,qe));if(t!==null)return{kind:"error",message:t};const s=this._iframe.contentDocument,n=Reflect.get(e,"__timelines"),o=this.hasRuntimeBridge(e);if(at({hasRuntime:o,hasTimelines:x(n)&&Object.keys(n).length>0,hasNestedCompositions:!!(s!=null&&s.querySelector("[data-composition-src]")),runtimeInjected:this._runtimeInjected,attempts:i}))return this._injectRuntime(),null;if(this._runtimeInjected&&!o)return null;const a=this._resolveReadyResult(e,s);return a?{kind:"ready",result:a}:null}_resolveReadyResult(i,e){var n;const t=this._resolvePlaybackDurationAdapter(i)??{kind:"document",getDuration:()=>0};let s=t.getDuration();if(!Number.isFinite(s)||s<=0){if(t.kind==="direct-timeline")return null;s=e?((n=ot(e))==null?void 0:n.durationSeconds)??0:0}return s<=0?null:{duration:s,adapter:{...t,getDuration:()=>s},compositionSize:ht(e)}}stop(){this._runtimeScript&&(this._runtimeScript.onerror=null,this._runtimeScript=null),this.failed||(this._failure=null),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 x(Reflect.get(i,"__player"))}_injectRuntime(){var i,e,t,s;this._runtimeInjected=!0;try{const n=this._iframe.contentDocument;if(!n)return;const o=n.createElement("script");o.src=((e=(i=this._callbacks).resolveRuntimeUrl)==null?void 0:e.call(i))??W,this._runtimeScript=o,o.onerror=()=>{this._runtimeScript!==o||this._iframe.contentDocument!==n||(this.stop(),this._failure={document:n},this._callbacks.onError("HyperFrames runtime failed to load from "+o.src))},(n.head||n.documentElement).appendChild(o),(s=(t=this._callbacks).onRuntimeInjected)==null||s.call(t)}catch{}}_resolveDirectTimelineAdapterFromWindow(i){var a,c;if(this.hasRuntimeBridge(i))return null;const e=Reflect.get(i,"__timelines");if(!x(e))return null;const t=Object.keys(e);if(t.length===0)return null;const s=(c=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:c.getAttribute("data-composition-id"),n=s&&s in e?s:t[t.length-1],o=e[n];return lt(o)?o:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(dt(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const mt=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -469,5 +469,5 @@ var Ve=Object.defineProperty;var He=(r,i,e)=>i in r?Ve(r,i,{enumerable:!0,config
469
469
  background: var(--hfp-accent, #fff);
470
470
  pointer-events: none;
471
471
  }
472
- `,mt='<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>',ft='<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>',Re='<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>',Ee='<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>',_t='<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>',gt=[.25,.5,1,1.5,2,4];function B(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function Te(r){if(!Number.isFinite(r)||r<0)return"0:00";const i=Math.floor(r),e=Math.floor(i/60),t=i%60;return`${e}:${t.toString().padStart(2,"0")}`}function yt(r,i,e={}){const t=e.speedPresets??gt,s=document.createElement("div");s.className="hfp-controls",s.addEventListener("click",d=>{d.stopPropagation()});const n=document.createElement("button");n.className="hfp-play-btn",n.type="button",n.innerHTML=`<span class="hfp-ico hfp-ico-play">${mt}</span><span class="hfp-ico hfp-ico-pause">${ft}</span>`,n.setAttribute("aria-label","Play");const o=document.createElement("div");o.className="hfp-scrubber";const a=document.createElement("div");a.className="hfp-progress",a.style.width="0%",o.appendChild(a);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 u=document.createElement("button");u.className="hfp-speed-btn",u.type="button",u.textContent="1x",u.setAttribute("aria-label","Playback speed");const y=document.createElement("div");y.className="hfp-speed-menu",y.setAttribute("role","menu");for(const d of t){const h=document.createElement("button");h.className="hfp-speed-option",h.type="button",h.setAttribute("role","menuitem"),h.dataset.speed=String(d),h.textContent=B(d),d===1&&h.classList.add("hfp-active"),y.appendChild(h)}p.appendChild(y),p.appendChild(u);const m=document.createElement("div");m.className="hfp-volume-wrap";const f=document.createElement("button");f.className="hfp-mute-btn",f.type="button",f.innerHTML=Re,f.setAttribute("aria-label","Mute");const g=document.createElement("div");g.className="hfp-volume-slider-wrap";const _=document.createElement("div");_.className="hfp-volume-slider",_.setAttribute("role","slider"),_.setAttribute("aria-label","Volume"),_.setAttribute("aria-valuemin","0"),_.setAttribute("aria-valuemax","100"),_.setAttribute("aria-valuenow","100"),_.tabIndex=0;const b=document.createElement("div");b.className="hfp-volume-fill",b.style.width="100%",_.appendChild(b),g.appendChild(_),m.appendChild(g),m.appendChild(f),e.audioLocked&&(m.style.display="none"),s.appendChild(n),s.appendChild(o),s.appendChild(c),s.appendChild(m),s.appendChild(p),r.appendChild(s);let E=!1,A=!1,R=1,P=null;t.indexOf(1);const I=(d,h)=>d?_t:h===0||h<.5?Ee:Re;n.addEventListener("click",d=>{d.stopPropagation(),E?i.onPause():i.onPlay()}),f.addEventListener("click",d=>{d.stopPropagation(),i.onMuteToggle()});let T=!1;const O=d=>{const h=_.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-h.left)/h.width));R=v,b.style.width=`${v*100}%`,_.setAttribute("aria-valuenow",String(Math.round(v*100))),A&&v>0&&i.onMuteToggle(),f.innerHTML=I(A,v),i.onVolumeChange(v)};_.addEventListener("mousedown",d=>{d.stopPropagation(),T=!0,O(d.clientX)});const re=d=>{T&&O(d.clientX)},ne=()=>{T=!1};document.addEventListener("mousemove",re),document.addEventListener("mouseup",ne),_.addEventListener("touchstart",d=>{T=!0;const h=d.touches[0];h&&O(h.clientX)},{passive:!0});const oe=d=>{if(T){const h=d.touches[0];h&&O(h.clientX)}},ae=()=>{T=!1};document.addEventListener("touchmove",oe,{passive:!0}),document.addEventListener("touchend",ae);const de=.05;_.addEventListener("keydown",d=>{let h=R;if(d.key==="ArrowRight"||d.key==="ArrowUp")h=Math.min(1,R+de);else if(d.key==="ArrowLeft"||d.key==="ArrowDown")h=Math.max(0,R-de);else return;d.preventDefault(),d.stopPropagation(),R=h,b.style.width=`${h*100}%`,_.setAttribute("aria-valuenow",String(Math.round(h*100))),A&&h>0&&i.onMuteToggle(),f.innerHTML=I(A,h),i.onVolumeChange(h)});const le=d=>{for(const h of y.querySelectorAll(".hfp-speed-option"))h.classList.toggle("hfp-active",h.dataset.speed===String(d))};u.addEventListener("click",d=>{d.stopPropagation();const h=y.classList.toggle("hfp-open");u.setAttribute("aria-expanded",String(h))}),y.addEventListener("click",d=>{d.stopPropagation();const h=d.target.closest(".hfp-speed-option");if(!h)return;const v=parseFloat(h.dataset.speed);t.indexOf(v),u.textContent=B(v),le(v),y.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false"),i.onSpeedChange(v)});const ue=()=>{y.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false")};document.addEventListener("click",ue);const F=d=>{const h=o.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-h.left)/h.width));i.onSeek(v)};let S=!1;o.addEventListener("mousedown",d=>{var h;d.stopPropagation(),S=!0,(h=i.onScrubStart)==null||h.call(i),F(d.clientX)});const he=d=>{S&&F(d.clientX)},ce=()=>{var d;S&&(S=!1,(d=i.onScrubEnd)==null||d.call(i))};document.addEventListener("mousemove",he),document.addEventListener("mouseup",ce),o.addEventListener("touchstart",d=>{var v;S=!0,(v=i.onScrubStart)==null||v.call(i);const h=d.touches[0];h&&F(h.clientX)},{passive:!0});const pe=d=>{if(S){const h=d.touches[0];h&&F(h.clientX)}},me=()=>{var d;S&&(S=!1,(d=i.onScrubEnd)==null||d.call(i))};document.addEventListener("touchmove",pe,{passive:!0}),document.addEventListener("touchend",me);const fe=()=>{P&&clearTimeout(P),P=setTimeout(()=>{E&&s.classList.add("hfp-hidden")},3e3)},N=r instanceof ShadowRoot?r.host:r,_e=()=>{s.classList.remove("hfp-hidden"),fe()},ge=()=>{E&&s.classList.add("hfp-hidden")};return N.addEventListener("mousemove",_e),N.addEventListener("mouseleave",ge),{updateTime(d,h){const v=h>0?Math.min(d,h):d,Ne=h>0?v/h*100:0;a.style.width=`${Ne}%`,c.textContent=`${Te(v)} / ${Te(h)}`},updatePlaying(d){E=d,n.classList.toggle("hfp-playing",d),n.setAttribute("aria-label",d?"Pause":"Play"),d?fe():s.classList.remove("hfp-hidden")},updateSpeed(d){t.indexOf(d),u.textContent=B(d),le(d)},updateMuted(d){A=d,f.innerHTML=I(d,R),f.setAttribute("aria-label",d?"Unmute":"Mute")},updateVolume(d){R=d,b.style.width=`${d*100}%`,_.setAttribute("aria-valuenow",String(Math.round(d*100))),f.innerHTML=I(A,d)},setVolumeControlsHidden(d){m.style.display=d?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",ce),document.removeEventListener("touchmove",pe),document.removeEventListener("touchend",me),document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",ne),document.removeEventListener("touchmove",oe),document.removeEventListener("touchend",ae),document.removeEventListener("click",ue),N.removeEventListener("mousemove",_e),N.removeEventListener("mouseleave",ge),P&&clearTimeout(P),s.remove()}}}function vt(r,i,e,t,s,n=!1){const o=t?t.split(",").map(Number).filter(p=>!isNaN(p)&&p>0):void 0,a={...o?{speedPresets:o}:{},audioLocked:n},c=yt(r,s,a);return c.updateMuted(i),c.updateVolume(e),c}function Ce(r,i,e){return i?(e||(e=document.createElement("img"),e.className="hfp-poster",r.appendChild(e)),e.src=i,e):(e==null||e.remove(),null)}function bt(r){return r.composedPath().some(i=>i instanceof HTMLElement&&i.classList.contains("hfp-controls"))}let V=null;function wt(r,i){if(typeof CSSStyleSheet<"u")try{V||(V=new CSSStyleSheet,V.replaceSync(i)),r.adoptedStyleSheets=[V];return}catch{}const e=document.createElement("style");e.textContent=i,r.appendChild(e)}function At(){const r=document.createElement("div");r.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",r.appendChild(i),{container:r,iframe:i}}function St(r,i,e,t){const s=r.offsetWidth,n=r.offsetHeight;if(s===0||n===0)return!1;const o=Math.min(s/e,n/t);return i.style.width=`${e}px`,i.style.height=`${t}px`,i.style.transform=`translate(-50%, -50%) scale(${o})`,!0}const Rt=100,Et=.001;function Tt(r,i,e){if(e.end<=0)return!1;const t=e.shown<e.end&&i>0?i+Et:0;return r+t>=e.end}class Ct{constructor(i){l(this,"_raf",null);l(this,"_lastUpdateMs",0);l(this,"_tick",null);this._callbacks=i}start(i,e,t,s,n){this.stop();let o=null,a=0,c=0;const p=()=>{if(s()){this._raf=null;return}let u;try{u=i.time()}catch{this._raf=null;return}const y=t(),m=n();m.end>0&&(u=Math.min(u,m.end));const f=o===null?0:u-o;f!==0&&(c=Math.min(f,a),a=f),o=u;const g=Tt(u,c,m);g&&(u=m.shown);const _=performance.now();if((_-this._lastUpdateMs>Rt||g)&&(this._lastUpdateMs=_,this._callbacks.onTimeUpdate(u,y)),g){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{i.pause(),m.shown<m.end&&i.seek(m.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(p)};this._tick=p,this._raf=requestAnimationFrame(p)}poll(){this._raf===null||!this._tick||(cancelAnimationFrame(this._raf),this._tick())}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function Pt(r){const i=Array.from(r.querySelectorAll("[data-composition-id]"));if(i.length===0)return r.body?[r.body]:[];const e=[];for(const t of i)Mt(t)||e.push(t);return Dt(r),e}function Dt(r){const i=r.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 s of e)s.closest("[data-composition-id]")||t.push(s);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 Mt(r){let i=r.parentElement;for(;i;){if(i.hasAttribute("data-composition-id"))return!0;i=i.parentElement}return!1}const Lt=.05,kt=2;class xt{constructor(i){l(this,"_entries",[]);l(this,"_mediaObserver");l(this,"_playbackErrorPosted",!1);l(this,"_audioOwner","runtime");l(this,"_urlAudioEntry",null);l(this,"_urlAudioSrc",null);l(this,"_dispatchEvent");l(this,"_getMuted");l(this,"_getVolume");l(this,"_getPlaybackRate");l(this,"_getCurrentTime");l(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();for(const e of this._entries)e!==this._urlAudioEntry&&(e.el.src="");this._entries=this._urlAudioEntry?[this._urlAudioEntry]:[],this._urlAudioSrc&&!this._urlAudioEntry&&(this._urlAudioEntry=this._createEntry(this._urlAudioSrc,"audio",0,1/0)),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=ye(i.source);i.start=e.start??0,i.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(i,e){return qe(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 s of this._entries){if(this._refreshEntryBounds(s),!this._gateEntryPlayback(s,i))continue;const n=i-s.start;Math.abs(s.el.currentTime-n)>Lt?(s.driftSamples+=1,(t||s.driftSamples>=kt)&&(s.el.currentTime=n,s.driftSamples=0)):s.driftSamples=0}}promoteToParentProxy(i,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",i)for(const s of i.querySelectorAll("video, audio"))w(s)&&(s.muted=!0);for(const s of[...this._entries])this._repointToSource(s);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=i,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,s,n){if(this._urlTaken(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 a=this._getPlaybackRate();a!==1&&(o.playbackRate=a);const c={el:o,start:t,duration:s,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=ye(i),s=t.start??0,n=t.duration??Number.POSITIVE_INFINITY,o=i.tagName==="VIDEO"?"video":"audio",a=this._createEntry(e,o,s,n,i);a&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(a))}_followIframeMediaSrc(i){const e=this._entries.find(t=>t.source===i);if(!e)return this._adoptIframeMedia(i);this._audioOwner!=="parent"||!this._repointToSource(e)||(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(e))}_urlTaken(i,e){return this._entries.some(t=>t===e||t.source&&!t.source.isConnected?!1:(t.source&&this._resolveIframeMediaSrc(t.source)||t.el.src)===i)}_repointToSource(i){const e=i.source?this._resolveIframeMediaSrc(i.source):null;return!e||i.el.src===e?!1:this._urlTaken(e,i)?(this._removeEntry(i),!1):(i.el.src=e,i.el.load(),!0)}_detachIframeMedia(i){const e=this._entries.find(t=>t.source===i);e&&this._removeEntry(e)}_removeEntry(i){i.el.pause(),i.el.src="",this._entries.splice(this._entries.indexOf(i),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==="src"){const a=o.target;w(a)&&a.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(a);continue}if(o.type==="attributes"&&o.attributeName==="preload"){const a=o.target;w(a)&&a.matches("audio[data-start], video[data-start]")&&(a.preload==="auto"?this._adoptIframeMedia(a):this._detachIframeMedia(a));continue}for(const a of o.addedNodes){if(!ve(a))continue;const c=[];w(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)w(u)&&c.push(u);for(const u of c)this._adoptIframeMedia(u)}for(const a of o.removedNodes){if(!ve(a))continue;const c=[];w(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)w(u)&&c.push(u);for(const u of c)this._detachIframeMedia(u)}}}),t={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},s=Pt(i);for(const n of s)e.observe(n,t);this._mediaObserver=e}}function Pe(r,i,e){if(r===null&&i===null)return{range:null,clamped:!1};const t=r??0,s=i!==null&&e>0&&i>e,n=s?e:i,o=n??(e>0?e:1/0);return!(t>=0)||!(o>t)?{range:null,clamped:!0}:{range:{start:t,end:n},clamped:s}}function ie(r,i,e){const t=r.end??i;return t<i?Be(r.start,t,e):t}function De(r,i,e,t){return r<i.start||r>=ie(i,e,t)}const It=100;function Ot(r,i){return typeof r.currentTime=="number"&&Number.isFinite(r.currentTime)?r.currentTime:(r.frame??0)/i}function Fe(r,i,e){return e<=0?!1:r.ended===!0?!0:r.ended===!1&&!r.isPlaying?!1:i>=e}function Ft(r,i,e,t,s,n){const{duration:o}=e;if(!s){const a=Fe(r,i,o);return{start:0,shownAtEnd:o,atEnd:a,stopRuntime:!1,entering:!1}}if(r.ownsRange){const a=t&&r.ended===!0&&!r.isPlaying;return{start:s.start,shownAtEnd:i,atEnd:a,stopRuntime:!1,entering:!1}}return Nt(r,i,e,t,s,n)}function Nt(r,i,e,t,s,n){const o=s.end??e.duration,a=e.enteringRange===!0&&(i<s.start||i>=o);return{start:s.start,shownAtEnd:ie(s,e.duration,n),atEnd:t&&!a&&Fe(r,i,o),stopRuntime:r.isPlaying,entering:a}}function Vt(r,i,e,t){var A;const s=Ot(r,i),n=!e.paused,o=n||r.isPlaying,a=(A=t.getPlayRange)==null?void 0:A.call(t),c=Ft(r,s,e,o,a,i),{atEnd:p,start:u}=c,y=e.duration>0?Math.min(s,e.duration):s,m=p?c.shownAtEnd:y,f=!r.isPlaying,g=p&&o;if(g&&t.getLoop())return t.media.audioOwner==="parent"&&t.media.pauseAll(),t.seek(u),t.play(),{...e,currentTime:u,paused:!1,enteringRange:!0};const _={...e,currentTime:m,paused:f,enteringRange:c.entering};t.media.audioOwner==="parent"&&(n&&f?t.media.pauseAll():!n&&!f&&t.media.playAll(),t.media.mirrorTime(m));const b=performance.now(),E=f!==e.paused;return(b-e.lastUpdateMs>It||E)&&(_.lastUpdateMs=b,t.updateControlsTime(m,e.duration),t.updateControlsPlaying(!f),t.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:m}}))),g&&(c.stopRuntime&&t.seek(m),t.media.audioOwner==="parent"&&t.media.pauseAll(),_.paused=!0,t.updateControlsPlaying(!1),t.dispatchEvent(new Event("ended"))),_}function Ht(r){return Array.isArray(r)?r.filter(i=>typeof i=="object"&&i!==null&&typeof i.id=="string"&&typeof i.start=="number"&&typeof i.duration=="number"):[]}function Ut(r,i,e){var o,a,c,p,u,y;if(r.source!==i)return;const t=r.data;if(!t||t.source!=="hf-preview")return;const s=Ge(t);if(s.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:s.code,receivedVersion:s.receivedVersion}}));return}(o=e.setRuntimeFps)==null||o.call(e,s.fps);const n=s.status==="supported"&&s.metadata.capabilities.includes("play-range");if((a=e.setRuntimeOwnsPlayRange)==null||a.call(e,n),t.type==="shader-transition-state"){const m=t.state&&typeof t.state=="object"?t.state:{};e.shaderLoader.update(m,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:t.compositionId,state:m}}));return}if(t.type==="ready"){e.onRuntimeReady();return}if(t.type==="assets-ready"){(c=e.onRuntimeAssetsReady)==null||c.call(e,t.timedOut===!0);return}if(t.type==="runtime-data-error"){(p=e.onRuntimeDataError)==null||p.call(e,t.channel,t.requestId,t.message);return}if(t.type==="runtime-data-applied"){(u=e.onRuntimeDataApplied)==null||u.call(e,t.channel,t.requestId);return}if(t.type==="state"){e.setPlaybackState(Vt({frame:t.frame??0,currentTime:t.currentTime,ended:typeof t.ended=="boolean"?t.ended:void 0,isPlaying:!!t.isPlaying,ownsRange:n},s.fps,e.getPlaybackState(),e));return}if(t.type==="media-autoplay-blocked"){if(((y=e.shouldPromoteMediaAutoplayFallback)==null?void 0:y.call(e))===!1)return;let m=null;try{m=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(m,(f,g)=>e.media.mirrorTime(f,g)),e.sendControl("set-media-output-muted",{muted:!0});return}if(t.type==="timeline"&&t.durationInFrames>0){const m=Number(t.durationSeconds),f=Number(t.durationInFrames),g=Number.isFinite(m)&&m>0?m:f/s.fps;if(Number.isFinite(t.compositionWidth)&&t.compositionWidth>0&&Number.isFinite(t.compositionHeight)&&t.compositionHeight>0&&e.setCompositionSize(t.compositionWidth,t.compositionHeight),Number.isFinite(g)&&g>0){const _=e.getPlaybackState();e.setPlaybackState({..._,duration:g}),e.updateControlsTime(_.currentTime,g),e.onRuntimeTimelineReady(g,typeof t.assetsReady=="boolean"?t.assetsReady:void 0)}e.setScenes(Ht(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 Wt(r,i){return r.includes(i)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}const zt=new Set([">"," "," ",`
473
- `,"\r","\f"]);function G(r,i){const e=r.toLowerCase(),t=`<${i}`;let s=0;for(;s<e.length;){const n=e.indexOf(t,s);if(n<0)return null;const o=e[n+t.length];if(zt.has(o)){const a=e.indexOf(">",n+t.length);return a<0?null:{index:n,end:a+1}}s=n+t.length}return null}function $t(r,i){if(!r||Wt(r,i))return r;const e=`<script src="${i}"><\/script>`,t=G(r,"head");if(t)return r.slice(0,t.end)+e+r.slice(t.end);const s=G(r,"body");if(s)return r.slice(0,s.index)+e+r.slice(s.index);const n=G(r,"html");return n?r.slice(0,n.end)+e+r.slice(n.end):e+r}const C="shader-capture-scale",k="shader-loading",J="runtime-src",Me="__hf_shader_capture_scale",Le="__hf_shader_loading",z=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function se(r){if(r===null)return null;const i=Number(r);return!Number.isFinite(i)||i<=0?null:String(Math.min(1,Math.max(.25,i)))}function jt(r){if(r===null||r.trim()==="")return"composition";const i=r.trim().toLowerCase();return i==="none"||i==="false"||i==="0"||i==="off"?"none":i==="player"||i==="true"||i==="1"||i==="on"?"player":"composition"}function ke(r,i){return r.filter(e=>e!==""&&e.split("=")[0]!==i)}function qt(r,i,e){const t=r.indexOf("#"),s=t>=0?r.slice(0,t):r,n=t>=0?r.slice(t):"",o=s.indexOf("?"),a=o>=0?s.slice(0,o):s,c=o>=0?s.slice(o+1):"";let p=ke(c.split("&"),Me);p=ke(p,Le),i!==null&&p.push(`${Me}=${encodeURIComponent(i)}`),e!=="composition"&&p.push(`${Le}=${encodeURIComponent(e)}`);const u=p.join("&");return`${a}${u?`?${u}`:""}${n}`}function Bt(r,i,e){if(i===null&&e==="composition")return r;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 s=`<script data-hyperframes-player-shader-options>${t.join("")}<\/script>`;return/<head\b[^>]*>/i.test(r)?r.replace(/<head\b[^>]*>/i,n=>`${n}${s}`):/<html\b[^>]*>/i.test(r)?r.replace(/<html\b[^>]*>/i,n=>`${n}${s}`):`${s}${r}`}function q(r){return jt(r.getAttribute(k))}function Gt(r){return Number(se(r.getAttribute(C))??"1")}function Yt(r,i){return qt(i,se(r.getAttribute(C)),q(r))}function H(r,i){return $t(Bt(i,se(r.getAttribute(C)),q(r)),Xt(r))}function Xt(r){var e;const i=(e=r.getAttribute(J))==null?void 0:e.trim();if(!i)return W;try{const t=new URL(i,document.baseURI),s=t.protocol==="http:"||t.protocol==="https:",n=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]";return s&&(n||t.origin===location.origin)?t.href:W}catch{return W}}function Zt(){const r=document.createElement("div");r.className="hfp-shader-loader",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.setAttribute("aria-label","Preparing scene transitions"),r.setAttribute("data-hyperframes-ignore",""),r.draggable=!1;const i=f=>{f.preventDefault(),f.stopPropagation()};for(const f of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(f,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 s=document.createElement("div");s.className="hfp-shader-loader-title";const n=document.createElement("span");n.className="hfp-shader-loader-title-text",n.textContent=z[0],s.appendChild(n);const o=document.createElement("div");o.className="hfp-shader-loader-detail",o.textContent="Rendering animated scene samples for shader transitions.";const a=document.createElement("div");a.className="hfp-shader-loader-track",a.setAttribute("aria-hidden","true");const c=document.createElement("div");c.className="hfp-shader-loader-fill",a.appendChild(c);const p=document.createElement("div");p.className="hfp-shader-loader-progress";const u=f=>{const g=document.createElement("div");g.className="hfp-shader-loader-row";const _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=f;const b=document.createElement("span");return b.className="hfp-shader-loader-value",g.appendChild(_),g.appendChild(b),p.appendChild(g),{row:g,label:_,value:b}},y=u("transition"),m=u("transition frame");return e.appendChild(t),e.appendChild(s),e.appendChild(o),e.appendChild(a),e.appendChild(p),r.appendChild(e),{root:r,fill:c,title:n,detail:o,transitionValue:y.value,transitionRow:y.row,frameLabel:m.label,frameValue:m.value,frameRow:m.row}}const Kt=420;function U(r,i,e){i.textContent=e,r.style.visibility=e?"visible":"hidden"}class Qt{constructor(i){l(this,"_el");l(this,"_hideTimeout",null);l(this,"_hiddenCallbacks",[]);l(this,"_drawingAssets",!1);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())}whenHidden(i){const e=this._el.root.classList;e.contains("hfp-visible")||e.contains("hfp-hiding")?this._hiddenCallbacks.push(i):i()}_flushHidden(){const i=this._hiddenCallbacks;this._hiddenCallbacks=[];for(const e of i)e()}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._drawingAssets=!1,this._flushHidden(),this._el.fill.style.transform="scaleX(0)",U(this._el.transitionRow,this._el.transitionValue,""),U(this._el.frameRow,this._el.frameValue,"")}update(i,e){const t=e==="player"&&i.loading&&!i.ready;if(this._drawingAssets&&!t)return;if(e!=="player"){this.reset();return}if(i.ready||!i.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions"),this._drawingAssets=!1;const s=typeof i.progress=="number"&&Number.isFinite(i.progress)?i.progress:0,n=typeof i.total=="number"&&Number.isFinite(i.total)?i.total:0,o=n>0?Math.min(1,Math.max(0,s/n)):0,a=Math.min(z.length-1,Math.floor(o*z.length));this._el.title.textContent=z[a]||"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(${o})`;const c=i.currentTransition!==void 0&&i.transitionTotal!==void 0?`${i.currentTransition}/${i.transitionTotal}`:n>0?`${s}/${n}`:"",p=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",U(this._el.transitionRow,this._el.transitionValue,c),U(this._el.frameRow,this._el.frameValue,p),this._el.root.setAttribute("aria-valuenow",String(Math.round(o*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._drawingAssets=!0,this.show()}hideAssetsLoading(){this._drawingAssets&&this.hide()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._hiddenCallbacks=[]}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null,this._flushHidden()},Kt)}}function Jt(r){return(r==null?void 0:r.trim().toLowerCase().startsWith("video/"))??!1}function ei(r){const i=document.createElement("video");i.className="hfp-video",i.playsInline=!0,i.preload="metadata";const e=new AbortController,{signal:t}=e;return i.addEventListener("loadedmetadata",()=>r.onMetadata(i),{signal:t}),i.addEventListener("durationchange",()=>r.onDurationChange(i),{signal:t}),i.addEventListener("resize",()=>r.onResize(i),{signal:t}),i.addEventListener("play",()=>r.onPlay(i),{signal:t}),i.addEventListener("pause",()=>r.onPause(i),{signal:t}),i.addEventListener("timeupdate",()=>r.onTimeUpdate(),{signal:t}),i.addEventListener("error",()=>{var n,o;return r.onError(((n=i.error)==null?void 0:n.message)||"Video failed to load",((o=i.error)==null?void 0:o.code)??null)},{signal:t}),{video:i,adapter:{duration:()=>i.duration,time:()=>i.currentTime,seek:n=>{i.currentTime=n},play:()=>i.play().catch(n=>{t.aborted||r.onPlayRejected(n)}),pause:()=>i.pause(),timeScale:n=>{i.defaultPlaybackRate=n,i.playbackRate=n}},destroy:()=>{e.abort(),i.pause(),i.removeAttribute("src"),i.load(),i.remove()}}}const ti=.1,ii=5,Y="sandbox-origin",xe=1e4,X=8e3,Z="assets-loading",D="assets-loading-ui",K="low-power-idle",Ie="disable-click-to-play",M="range-start",L="range-end",si=150;function Q(r){return!Number.isFinite(r)||r<=0?1:Math.max(ti,Math.min(ii,r))}class ri extends HTMLElement{constructor(){super();l(this,"shadow");l(this,"container");l(this,"iframe");l(this,"posterEl",null);l(this,"controlsApi",null);l(this,"resizeObserver");l(this,"shaderLoader");l(this,"probe");l(this,"_ready",!1);l(this,"_readyDocument",null);l(this,"_connected",!1);l(this,"_assetsReady",!1);l(this,"_painted",!1);l(this,"_pendingPlay",!1);l(this,"_assetsGeneration",0);l(this,"_assetsLoadingShowTimer",null);l(this,"_currentTime",0);l(this,"_duration",0);l(this,"_paused",!0);l(this,"_scrubbing",!1);l(this,"_lastUpdateMs",0);l(this,"_volume",1);l(this,"_compositionWidth",1920);l(this,"_compositionHeight",1080);l(this,"_rescaleWarned",!1);l(this,"_directTimelineAdapter",null);l(this,"_directTimelineClock");l(this,"_parentTickRaf",null);l(this,"_media");l(this,"_scenes",[]);l(this,"_runtimeFps",30);l(this,"_runtimeBridgeReady",!1);l(this,"_runtimeAssetsReadyGeneration",-1);l(this,"_runtimeData",new Map);l(this,"_runtimeDataRequestId",0);l(this,"_pendingRuntimeData",new Map);l(this,"_afterUpdate",null);l(this,"_videoSource",null);l(this,"_runtimeOwnsPlayRange",!1);l(this,"_enteringRange",!1);l(this,"_rangeClampReported","");this.shadow=this.attachShadow({mode:"open"}),wt(this.shadow,pt),{container:this.container,iframe:this.iframe}=At(),this.shadow.appendChild(this.container);const e=Zt();this.shadow.appendChild(e.root),this.shaderLoader=new Qt(e),this._media=new xt({dispatchEvent:t=>this._emit(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Ct({onTimeUpdate:(t,s)=>{var n;this._currentTime=t,(n=this.controlsApi)==null||n.updateTime(t,s),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:t}}))},getLoop:()=>this.loop,restart:()=>{var t;this.seek(((t=this._playRange())==null?void 0:t.start)??0),this.play()},onPaused:()=>{var t;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(t=this.controlsApi)==null||t.updatePlaying(!1),this._emit(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new ct(this.iframe,{onReady:t=>this._onProbeReady(t),onError:t=>this._emit(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{this.disableClickToPlay||bt(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),this.iframe.addEventListener("load",this._onIframeLoad)}static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src","type",Y,J,C,k,D,K,M,L]}connectedCallback(){this._connected=!0,this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=Ce(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=H(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this._connected=!1,this._teardownVideo(),this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),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._pendingPlay=!1,this._abandonComposition("Player disconnected before runtime data was applied")}attributeChangedCallback(e,t,s){var n,o,a,c,p;switch(e){case"src":if(!this.isConnected)break;s&&this._navigateSrc(s);break;case"type":{const u=this.getAttribute("src");if(!this.isConnected||u===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(u);break}case"srcdoc":if(!this.isConnected)break;if(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),s!==null)this._pauseForVideoSwitch(),this._teardownVideo(),this.iframe.srcdoc=H(this,s);else{this.iframe.removeAttribute("srcdoc");const u=this.getAttribute("src");u!==null&&this._wantsVideo()&&this._navigateSrc(u)}break;case Y:this._applySandboxOriginPolicy(this.isConnected&&t!==s);break;case"width":this._setCompositionSize(j(s)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,j(s)??1080);break;case"controls":s!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=Ce(this.shadow,s,this.posterEl);break;case"playback-rate":{const u=Q(parseFloat(s||"1"));this._media.updatePlaybackRate(u),this._sendControl("set-playback-rate",{playbackRate:u}),(a=(o=this._directTimelineAdapter)==null?void 0:o.timeScale)==null||a.call(o,u),(c=this.controlsApi)==null||c.updateSpeed(u),this._emit(new Event("ratechange"));break}case"muted":this._handleMutedChange(s);break;case"audio-locked":this._applyAudioLock(s!==null);break;case"volume":{const u=Math.max(0,Math.min(1,parseFloat(s||"1")));this._volume=u,this._syncVideoAudio(),this._media.updateVolume(u),this._sendControl("set-volume",{volume:u}),(p=this.controlsApi)==null||p.updateVolume(u),this._emit(new Event("volumechange"));break}case"audio-src":s?this._media.setupFromUrl(s):this._media.teardownUrlAudio();break;case D:s==="none"&&this.shaderLoader.hideAssetsLoading();break;case K:this._sendControl("set-idle-heartbeat",{slow:s!==null});break;case M:case L:this._applyPlayRange(!0);break;case C:case k:case J:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(Y)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){if(this._videoSource)return;this._abandonComposition("Sandbox policy changed before runtime data was applied");const e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=H(this,e);return}const t=this.getAttribute("src");t===null?this.iframe.src="about:blank":this._loadSrc(t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){this._play(!0)}_play(e){var o,a;if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,(o=this.posterEl)==null||o.remove(),this.posterEl=null;const t=this._ready?this._playRange():null;t?De(this._currentTime,t,this._duration,this._runtimeFps)&&(this.seek(t.start),this._enteringRange=!0):this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const s=this._tryDirectTimelinePlay();let n=!1;this._sendDisplayScale(),s||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,n=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),(a=this.controlsApi)==null||a.updatePlaying(!0),!n&&e&&this._emit(new Event("play")),s&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused,()=>this._clockStop())}pause(){var e;this._pendingPlay=!1,this._tryDirectTimelinePause()?this._showPausedVideoTime():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._emit(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){var t,s;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),(s=this.controlsApi)==null||s.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 s=structuredClone(t);this._runtimeData.set(e,s),this._deliverRuntimeData(e,s)}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 compositionWidth(){return this._compositionWidth}get compositionHeight(){return this._compositionHeight}get paused(){return this._paused}get ready(){return this._ready}get assetsReady(){return this._assetsReady}get painted(){return this._painted}get playbackRate(){return Q(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(Q(e)))}get shaderCaptureScale(){return Gt(this)}set shaderCaptureScale(e){this.setAttribute(C,String(e))}get shaderLoading(){return q(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(k):this.setAttribute(k,e)}get assetsLoadingUi(){return this.getAttribute(D)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(D,"none"):this.removeAttribute(D)}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._syncVideoAudio(),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(t=this.controlsApi)==null||t.updateMuted(e!==null),this._emit(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 disableClickToPlay(){return this.hasAttribute(Ie)}set disableClickToPlay(e){this.toggleAttribute(Ie,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(M)}set rangeStart(e){this._writeSeconds(M,e)}get rangeEnd(){return this._readSeconds(L)}set rangeEnd(e){this._writeSeconds(L,e)}_readSeconds(e){const t=this.getAttribute(e);return t===null?null:Number(t)}_writeSeconds(e,t){t==null?this.removeAttribute(e):this.setAttribute(e,String(t))}_hasPlayRange(){return this.hasAttribute(M)||this.hasAttribute(L)}_playRange(){return Pe(this.rangeStart,this.rangeEnd,this._duration).range}_sendPlayRange(e){const t=(e==null?void 0:e.end)??null;this._sendControl("set-play-range",{startSeconds:(e==null?void 0:e.start)??null,endSeconds:t})}_applyPlayRange(e){const{range:t,clamped:s}=Pe(this.rangeStart,this.rangeEnd,this._duration);this._sendPlayRange(t),this._ready&&(this._reportRangeClamp(t,s),t&&e&&!this._pendingPlay&&this._moveIntoPlayRange(t))}_reportRangeClamp(e,t){const s=t?`${this.rangeStart},${this.rangeEnd},${this._duration}`:"";if(s===this._rangeClampReported||(this._rangeClampReported=s,!t))return;const n={rangeStart:(e==null?void 0:e.start)??null,rangeEnd:(e==null?void 0:e.end)??null};this._emit(new CustomEvent("rangeclamped",{detail:{...n,duration:this._duration}}))}_moveIntoPlayRange(e){De(this._currentTime,e,this._duration,this._runtimeFps)&&(this._paused?this.seek(e.start):this._jumpWhilePlaying(e.start))}_jumpWhilePlaying(e){this._directTimelineAdapter?(this._directTimelineAdapter.seek(e,!1),this._currentTime=e):this._runtimeOwnsPlayRange||(this.seek(e),this._enteringRange=!0,this._play(!1))}_clockStop(){const e=this._playRange(),t=(e==null?void 0:e.end)??this._duration;if(!e)return{end:t,shown:t};const s=ie(e,this._duration,this._runtimeFps);return{end:t,shown:s<t?(s+t)/2:s}}_sendControl(e,t={}){try{const s=this.iframe.contentWindow;return s?(s.postMessage({...t,source:"hf-parent",type:"control",action:e,...Ye(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,"Composition iframe is unavailable"),!1)}catch(s){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,s instanceof Error?s.message:String(s)),!1}}_deliverRuntimeData(e,t){if(!this.isConnected||!this._runtimeBridgeReady)return;const s=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,t,s)||this._sendControl("set-runtime-data",{channel:e,payload:t,requestId:s})}_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,s){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,s),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,t){var s;try{const n=(s=this.iframe.contentWindow)==null?void 0:s.__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 s=this._runtimeDataRequestId,n=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,s,`Runtime data delivery timed out after ${xe}ms`)},xe);return this._pendingRuntimeData.set(e,{requestId:s,timeoutId:n}),s}_resolveRuntimeDataDelivery(e,t){const s=this._takeRuntimeDataDelivery(e,t);s&&this._emit(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:s.requestId}}))}_rejectRuntimeDataDelivery(e,t,s){const n=this._takeRuntimeDataDelivery(e,t);n&&this._emit(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:n.requestId,message:typeof s=="string"?s:String(s)}}))}_takeRuntimeDataDelivery(e,t){if(typeof e!="string"||typeof t!="number"||!Number.isSafeInteger(t))return null;const s=this._pendingRuntimeData.get(e);return!s||s.requestId!==t?null:(window.clearTimeout(s.timeoutId),this._pendingRuntimeData.delete(e),s)}_rejectAllRuntimeDataDeliveries(e){for(const[t,s]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(t,s.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){const t=this._getSameOriginIframeDocument();if(t)for(const s of t.querySelectorAll("video, audio"))w(s)&&(s.muted=e||s.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()}),this._sendControl("set-idle-heartbeat",{slow:this.hasAttribute(K)}),this._sendDisplayScale()}_sendDisplayScale(){const e=Xe(this.iframe);e&&this._sendControl("set-display-scale",{scale:e})}_reloadShaderOptions(){if(!this._videoSource){if(this._abandonComposition("Shader options changed before runtime data was applied"),this.hasAttribute("srcdoc")){this.iframe.srcdoc=H(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")||"")}}_navigateSrc(e){this._pendingPlay=!1,this._pauseForVideoSwitch(),this._abandonComposition("Composition navigated before runtime data was applied"),this._loadSrc(e)}_wantsVideo(){return Jt(this.getAttribute("type"))&&!this.hasAttribute("srcdoc")}_pauseForVideoSwitch(){var e;!this._videoSource&&!this._wantsVideo()||(this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1))}_loadSrc(e){if(this._wantsVideo()){this._loadVideo(e);return}this._teardownVideo(),this.iframe.src=Yt(this,e)}_loadVideo(e){var n,o;this._videoSource||(this._videoSource=ei({onMetadata:a=>this._applyThenEmit(()=>this._onVideoReady(a)),onDurationChange:a=>this._applyTimelineDuration(a.duration),onResize:a=>this._applyVideoSize(a),onPlay:a=>{!a.paused&&this._paused&&this.play()},onPause:a=>{a.paused&&!a.ended&&!this._paused&&this.pause()},onTimeUpdate:()=>{document.hidden&&this._playRange()&&this._directTimelineClock.poll()},onError:(a,c)=>{this._paused||this.pause(),this._emit(new CustomEvent("error",{detail:{message:a,code:c}}))},onPlayRejected:a=>this._onVideoPlayRejected(a)}),this.container.appendChild(this._videoSource.video),this.iframe.hidden=!0,this.iframe.src="about:blank"),this.probe.stop();const{video:t,adapter:s}=this._videoSource;this._directTimelineAdapter=s,this._currentTime=0,this._duration=0,(n=this.controlsApi)==null||n.updateTime(0,0),this._syncVideoAudio(),(o=s.timeScale)==null||o.call(s,this.playbackRate),t.src=e}_teardownVideo(){this._videoSource&&(this._videoSource.destroy(),this._videoSource=null,this.iframe.hidden=!1)}_syncVideoAudio(){this._videoSource&&(this._videoSource.video.muted=this.muted,this._videoSource.video.volume=this._volume)}_onVideoReady(e){this._applyTimelineDuration(e.duration),this._applyVideoSize(e),this._ready=!0,this._dispatchReady(),this._waitForAssetsReady(null),this._afterEvents(()=>{this.hasAttribute("autoplay")&&this._paused&&this.play()})}_applyTimelineDuration(e){var t;!Number.isFinite(e)||e<=0||(this._setDuration(e),(t=this.controlsApi)==null||t.updateTime(this._currentTime,e))}_applyVideoSize(e){e.videoWidth>0&&e.videoHeight>0&&this._setCompositionSize(e.videoWidth,e.videoHeight)}_onVideoPlayRejected(e){e instanceof DOMException&&e.name==="NotAllowedError"&&(this._paused||this.pause(),this._emit(new CustomEvent("playbackerror",{detail:{source:"video",error:e}})))}_trySyncSeek(e){if(this._videoSource)return!1;try{const t=this.iframe.contentWindow,s=t==null?void 0:t.__player;return typeof(s==null?void 0:s.seek)!="function"?!1:(s.seek.call(s,e),!0)}catch{return!1}}_withDirectTimeline(e){const t=this._videoSource?null:this.probe.resolveDirectTimelineAdapter(),s=t||this._directTimelineAdapter;if(!s)return!1;try{return e(s),t&&t!==this._directTimelineAdapter&&this._applyTimelineDuration(t.duration()),this._directTimelineAdapter=s,!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())}_showPausedVideoTime(){var e;this._videoSource&&(this._currentTime=this._videoSource.video.currentTime,(e=this.controlsApi)==null||e.updateTime(this._currentTime,this._duration),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}})))}_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){this._videoSource||this.probe.failed||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){Ut(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs,enteringRange:this._enteringRange}),setPlaybackState:({currentTime:t,duration:s,paused:n,lastUpdateMs:o,enteringRange:a})=>{this._enteringRange=a===!0,this._currentTime=t,this._setDuration(s),this._paused=n,this._lastUpdateMs=o},getShaderLoadingMode:()=>q(this),shaderLoader:this.shaderLoader,setCompositionSize:(t,s)=>this._setCompositionSize(t,s),sendControl:(t,s)=>this._sendControl(t,s),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._hasPlayRange()&&this._sendPlayRange(this._playRange()),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(t,s)=>this._resolveRuntimeDataDelivery(t,s),onRuntimeDataError:(t,s,n)=>this._rejectRuntimeDataDelivery(t,s,n),onRuntimeTimelineReady:(t,s)=>this._onRuntimeTimelineReady(t,s),setRuntimeFps:t=>{this._runtimeFps=t},setRuntimeOwnsPlayRange:t=>{this._runtimeOwnsPlayRange=t},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:t=>{this._scenes=t,this._emit(new CustomEvent("scenes",{detail:{scenes:t}}))},updateControlsTime:(t,s)=>{var n;return(n=this.controlsApi)==null?void 0:n.updateTime(t,s)},updateControlsPlaying:t=>{var s;return(s=this.controlsApi)==null?void 0:s.updatePlaying(t)},dispatchEvent:t=>this._emit(t),seek:t=>this.seek(t),play:()=>this.play(),getLoop:()=>this.loop,getPlayRange:()=>this._playRange(),media:this._media})}_onRuntimeTimelineReady(e,t){var n;if(this._ready)return;this.probe.stop(),this._setDuration(e),this._directTimelineAdapter=null,this._ready=!0,(n=this.controlsApi)==null||n.updateTime(this._currentTime,e),this._dispatchReady();const s=this._getSameOriginIframeDocument();s&&this._media.setupFromIframe(s),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(s,t),this._playWhenWanted()}_onProbeReady(e){this._applyThenEmit(()=>this._applyProbeResult(e))}_applyProbeResult({duration:e,adapter:t,compositionSize:s}){var o;this._setDuration(e),this._directTimelineAdapter=t.kind==="direct-timeline"?t.timeline:null,s&&this._setCompositionSize(s.width,s.height),this._ready=!0,(o=this.controlsApi)==null||o.updateTime(0,e),this._dispatchReady();const n=this._getSameOriginIframeDocument();n&&this._media.setupFromIframe(n),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(n),this._playWhenWanted()}_waitForAssetsReady(e,t){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1;const s=++this._assetsGeneration;if(!e){t===!1?(this._runtimeAssetsReadyGeneration=s,this._startAssetsLoadingOverlayTimer(s),setTimeout(()=>this._settleAssetsReady(s),X)):this._settleAssetsReady(s);return}Ze(e,({timedOut:n})=>{s===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(s))},{timeoutMs:X}),this._assetsReady||this._startAssetsLoadingOverlayTimer(s)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(Z,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},si)}_hasPendingFirstFrameAssets(e){const{pendingMedia:t,pendingImages:s,fontsLoading:n}=be(e,{scope:we});return t.length>0||s.length>0||n}_warnStuckAssets(e){const{pendingMedia:t,pendingImages:s,fontsLoading:n}=be(e,{scope:we}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${X}ms — playing anyway`,{stuckMedia:t.map(a=>a.currentSrc||a.getAttribute("src")||`<${a.tagName.toLowerCase()}>`),stuckImages:s.map(a=>a.currentSrc||a.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(Z),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this.probe.stop(),this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._runtimeOwnsPlayRange=!1,this._enteringRange=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(Z),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_dispatchReady(){this._readyDocument=this._getSameOriginIframeDocument();const e={duration:this._duration,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight};this._emit(new CustomEvent("ready",{detail:e})),this._rescale(),this._rangeClampReported="",this._hasPlayRange()&&this._applyPlayRange(!0)}_setDuration(e){e!==this._duration&&(this._duration=e,this._ready&&(this._emit(new CustomEvent("durationchange",{detail:{duration:e}})),this._hasPlayRange()&&this._applyPlayRange(!1)))}_setCompositionSize(e,t){const s=e!==this._compositionWidth||t!==this._compositionHeight;if(this._compositionWidth=e,this._compositionHeight=t,this._rescale(),!s)return;const n={compositionWidth:e,compositionHeight:t};this._emit(new CustomEvent("resize",{detail:n}))}_applyThenEmit(e){if(this._afterUpdate){e();return}const t=[];this._afterUpdate=t;const s=[],n=o=>{try{o()}catch(a){s.push(a)}};n(e);for(const o of t)n(o);if(this._afterUpdate=null,s.length>0)throw s[0]}_afterEvents(e){this._afterUpdate?this._afterUpdate.push(e):e()}_playWhenWanted(){this._afterEvents(()=>{(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()})}_emit(e){this._afterEvents(()=>this.dispatchEvent(e))}_rescale(){const e=St(this,this.iframe,this._compositionWidth,this._compositionHeight);e&&this._sendDisplayScale(),!e&&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(){if(!this._connected||this._videoSource)return;const e=this._getSameOriginIframeDocument();if(this._ready&&e===this._readyDocument){e&&this._hasPendingFirstFrameAssets(e)&&this._waitForAssetsReady(e);return}this._ready=!1,this._invalidateAssetsWait(),this._releaseDocument(),this.probe.start()}_setupControls(){this.controlsApi||(this.controlsApi=vt(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,s)=>this._mirrorParentMediaTime(t,s)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}}customElements.get("hyperframes-player")||customElements.define("hyperframes-player",ri);export{ri as HyperframesPlayer,gt as SPEED_PRESETS,B as formatSpeed,Te as formatTime};
472
+ `,ft='<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>',_t='<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>',Re='<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>',Ee='<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>',gt='<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>',yt=[.25,.5,1,1.5,2,4];function B(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function Te(r){if(!Number.isFinite(r)||r<0)return"0:00";const i=Math.floor(r),e=Math.floor(i/60),t=i%60;return`${e}:${t.toString().padStart(2,"0")}`}function vt(r,i,e={}){const t=e.speedPresets??yt,s=document.createElement("div");s.className="hfp-controls",s.addEventListener("click",d=>{d.stopPropagation()});const n=document.createElement("button");n.className="hfp-play-btn",n.type="button",n.innerHTML=`<span class="hfp-ico hfp-ico-play">${ft}</span><span class="hfp-ico hfp-ico-pause">${_t}</span>`,n.setAttribute("aria-label","Play");const o=document.createElement("div");o.className="hfp-scrubber";const a=document.createElement("div");a.className="hfp-progress",a.style.width="0%",o.appendChild(a);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 u=document.createElement("button");u.className="hfp-speed-btn",u.type="button",u.textContent="1x",u.setAttribute("aria-label","Playback speed");const y=document.createElement("div");y.className="hfp-speed-menu",y.setAttribute("role","menu");for(const d of t){const h=document.createElement("button");h.className="hfp-speed-option",h.type="button",h.setAttribute("role","menuitem"),h.dataset.speed=String(d),h.textContent=B(d),d===1&&h.classList.add("hfp-active"),y.appendChild(h)}p.appendChild(y),p.appendChild(u);const m=document.createElement("div");m.className="hfp-volume-wrap";const f=document.createElement("button");f.className="hfp-mute-btn",f.type="button",f.innerHTML=Re,f.setAttribute("aria-label","Mute");const g=document.createElement("div");g.className="hfp-volume-slider-wrap";const _=document.createElement("div");_.className="hfp-volume-slider",_.setAttribute("role","slider"),_.setAttribute("aria-label","Volume"),_.setAttribute("aria-valuemin","0"),_.setAttribute("aria-valuemax","100"),_.setAttribute("aria-valuenow","100"),_.tabIndex=0;const b=document.createElement("div");b.className="hfp-volume-fill",b.style.width="100%",_.appendChild(b),g.appendChild(_),m.appendChild(g),m.appendChild(f),e.audioLocked&&(m.style.display="none"),s.appendChild(n),s.appendChild(o),s.appendChild(c),s.appendChild(m),s.appendChild(p),r.appendChild(s);let E=!1,A=!1,R=1,P=null;t.indexOf(1);const I=(d,h)=>d?gt:h===0||h<.5?Ee:Re;n.addEventListener("click",d=>{d.stopPropagation(),E?i.onPause():i.onPlay()}),f.addEventListener("click",d=>{d.stopPropagation(),i.onMuteToggle()});let T=!1;const O=d=>{const h=_.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-h.left)/h.width));R=v,b.style.width=`${v*100}%`,_.setAttribute("aria-valuenow",String(Math.round(v*100))),A&&v>0&&i.onMuteToggle(),f.innerHTML=I(A,v),i.onVolumeChange(v)};_.addEventListener("mousedown",d=>{d.stopPropagation(),T=!0,O(d.clientX)});const re=d=>{T&&O(d.clientX)},ne=()=>{T=!1};document.addEventListener("mousemove",re),document.addEventListener("mouseup",ne),_.addEventListener("touchstart",d=>{T=!0;const h=d.touches[0];h&&O(h.clientX)},{passive:!0});const oe=d=>{if(T){const h=d.touches[0];h&&O(h.clientX)}},ae=()=>{T=!1};document.addEventListener("touchmove",oe,{passive:!0}),document.addEventListener("touchend",ae);const de=.05;_.addEventListener("keydown",d=>{let h=R;if(d.key==="ArrowRight"||d.key==="ArrowUp")h=Math.min(1,R+de);else if(d.key==="ArrowLeft"||d.key==="ArrowDown")h=Math.max(0,R-de);else return;d.preventDefault(),d.stopPropagation(),R=h,b.style.width=`${h*100}%`,_.setAttribute("aria-valuenow",String(Math.round(h*100))),A&&h>0&&i.onMuteToggle(),f.innerHTML=I(A,h),i.onVolumeChange(h)});const le=d=>{for(const h of y.querySelectorAll(".hfp-speed-option"))h.classList.toggle("hfp-active",h.dataset.speed===String(d))};u.addEventListener("click",d=>{d.stopPropagation();const h=y.classList.toggle("hfp-open");u.setAttribute("aria-expanded",String(h))}),y.addEventListener("click",d=>{d.stopPropagation();const h=d.target.closest(".hfp-speed-option");if(!h)return;const v=parseFloat(h.dataset.speed);t.indexOf(v),u.textContent=B(v),le(v),y.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false"),i.onSpeedChange(v)});const ue=()=>{y.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false")};document.addEventListener("click",ue);const F=d=>{const h=o.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-h.left)/h.width));i.onSeek(v)};let S=!1;o.addEventListener("mousedown",d=>{var h;d.stopPropagation(),S=!0,(h=i.onScrubStart)==null||h.call(i),F(d.clientX)});const he=d=>{S&&F(d.clientX)},ce=()=>{var d;S&&(S=!1,(d=i.onScrubEnd)==null||d.call(i))};document.addEventListener("mousemove",he),document.addEventListener("mouseup",ce),o.addEventListener("touchstart",d=>{var v;S=!0,(v=i.onScrubStart)==null||v.call(i);const h=d.touches[0];h&&F(h.clientX)},{passive:!0});const pe=d=>{if(S){const h=d.touches[0];h&&F(h.clientX)}},me=()=>{var d;S&&(S=!1,(d=i.onScrubEnd)==null||d.call(i))};document.addEventListener("touchmove",pe,{passive:!0}),document.addEventListener("touchend",me);const fe=()=>{P&&clearTimeout(P),P=setTimeout(()=>{E&&s.classList.add("hfp-hidden")},3e3)},N=r instanceof ShadowRoot?r.host:r,_e=()=>{s.classList.remove("hfp-hidden"),fe()},ge=()=>{E&&s.classList.add("hfp-hidden")};return N.addEventListener("mousemove",_e),N.addEventListener("mouseleave",ge),{updateTime(d,h){const v=h>0?Math.min(d,h):d,Ve=h>0?v/h*100:0;a.style.width=`${Ve}%`,c.textContent=`${Te(v)} / ${Te(h)}`},updatePlaying(d){E=d,n.classList.toggle("hfp-playing",d),n.setAttribute("aria-label",d?"Pause":"Play"),d?fe():s.classList.remove("hfp-hidden")},updateSpeed(d){t.indexOf(d),u.textContent=B(d),le(d)},updateMuted(d){A=d,f.innerHTML=I(d,R),f.setAttribute("aria-label",d?"Unmute":"Mute")},updateVolume(d){R=d,b.style.width=`${d*100}%`,_.setAttribute("aria-valuenow",String(Math.round(d*100))),f.innerHTML=I(A,d)},setVolumeControlsHidden(d){m.style.display=d?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",ce),document.removeEventListener("touchmove",pe),document.removeEventListener("touchend",me),document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",ne),document.removeEventListener("touchmove",oe),document.removeEventListener("touchend",ae),document.removeEventListener("click",ue),N.removeEventListener("mousemove",_e),N.removeEventListener("mouseleave",ge),P&&clearTimeout(P),s.remove()}}}function bt(r,i,e,t,s,n=!1){const o=t?t.split(",").map(Number).filter(p=>!isNaN(p)&&p>0):void 0,a={...o?{speedPresets:o}:{},audioLocked:n},c=vt(r,s,a);return c.updateMuted(i),c.updateVolume(e),c}function Ce(r,i,e){return i?(e||(e=document.createElement("img"),e.className="hfp-poster",r.appendChild(e)),e.src=i,e):(e==null||e.remove(),null)}function wt(r){return r.composedPath().some(i=>i instanceof HTMLElement&&i.classList.contains("hfp-controls"))}let V=null;function At(r,i){if(typeof CSSStyleSheet<"u")try{V||(V=new CSSStyleSheet,V.replaceSync(i)),r.adoptedStyleSheets=[V];return}catch{}const e=document.createElement("style");e.textContent=i,r.appendChild(e)}function St(){const r=document.createElement("div");r.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",r.appendChild(i),{container:r,iframe:i}}function Rt(r,i,e,t){const s=r.offsetWidth,n=r.offsetHeight;if(s===0||n===0)return!1;const o=Math.min(s/e,n/t);return i.style.width=`${e}px`,i.style.height=`${t}px`,i.style.transform=`translate(-50%, -50%) scale(${o})`,!0}const Et=100,Tt=.001;function Ct(r,i,e){if(e.end<=0)return!1;const t=e.shown<e.end&&i>0?i+Tt:0;return r+t>=e.end}class Pt{constructor(i){l(this,"_raf",null);l(this,"_lastUpdateMs",0);l(this,"_tick",null);this._callbacks=i}start(i,e,t,s,n){this.stop();let o=null,a=0,c=0;const p=()=>{if(s()){this._raf=null;return}let u;try{u=i.time()}catch{this._raf=null;return}const y=t(),m=n();m.end>0&&(u=Math.min(u,m.end));const f=o===null?0:u-o;f!==0&&(c=Math.min(f,a),a=f),o=u;const g=Ct(u,c,m);g&&(u=m.shown);const _=performance.now();if((_-this._lastUpdateMs>Et||g)&&(this._lastUpdateMs=_,this._callbacks.onTimeUpdate(u,y)),g){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{i.pause(),m.shown<m.end&&i.seek(m.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(p)};this._tick=p,this._raf=requestAnimationFrame(p)}poll(){this._raf===null||!this._tick||(cancelAnimationFrame(this._raf),this._tick())}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function Dt(r){const i=Array.from(r.querySelectorAll("[data-composition-id]"));if(i.length===0)return r.body?[r.body]:[];const e=[];for(const t of i)Lt(t)||e.push(t);return Mt(r),e}function Mt(r){const i=r.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 s of e)s.closest("[data-composition-id]")||t.push(s);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 Lt(r){let i=r.parentElement;for(;i;){if(i.hasAttribute("data-composition-id"))return!0;i=i.parentElement}return!1}const kt=.05,xt=2;class It{constructor(i){l(this,"_entries",[]);l(this,"_mediaObserver");l(this,"_playbackErrorPosted",!1);l(this,"_audioOwner","runtime");l(this,"_urlAudioEntry",null);l(this,"_urlAudioSrc",null);l(this,"_dispatchEvent");l(this,"_getMuted");l(this,"_getVolume");l(this,"_getPlaybackRate");l(this,"_getCurrentTime");l(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();for(const e of this._entries)e!==this._urlAudioEntry&&(e.el.src="");this._entries=this._urlAudioEntry?[this._urlAudioEntry]:[],this._urlAudioSrc&&!this._urlAudioEntry&&(this._urlAudioEntry=this._createEntry(this._urlAudioSrc,"audio",0,1/0)),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=ye(i.source);i.start=e.start??0,i.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(i,e){return Be(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 s of this._entries){if(this._refreshEntryBounds(s),!this._gateEntryPlayback(s,i))continue;const n=i-s.start;Math.abs(s.el.currentTime-n)>kt?(s.driftSamples+=1,(t||s.driftSamples>=xt)&&(s.el.currentTime=n,s.driftSamples=0)):s.driftSamples=0}}promoteToParentProxy(i,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",i)for(const s of i.querySelectorAll("video, audio"))w(s)&&(s.muted=!0);for(const s of[...this._entries])this._repointToSource(s);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=i,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,s,n){if(this._urlTaken(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 a=this._getPlaybackRate();a!==1&&(o.playbackRate=a);const c={el:o,start:t,duration:s,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=ye(i),s=t.start??0,n=t.duration??Number.POSITIVE_INFINITY,o=i.tagName==="VIDEO"?"video":"audio",a=this._createEntry(e,o,s,n,i);a&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(a))}_followIframeMediaSrc(i){const e=this._entries.find(t=>t.source===i);if(!e)return this._adoptIframeMedia(i);this._audioOwner!=="parent"||!this._repointToSource(e)||(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(e))}_urlTaken(i,e){return this._entries.some(t=>t===e||t.source&&!t.source.isConnected?!1:(t.source&&this._resolveIframeMediaSrc(t.source)||t.el.src)===i)}_repointToSource(i){const e=i.source?this._resolveIframeMediaSrc(i.source):null;return!e||i.el.src===e?!1:this._urlTaken(e,i)?(this._removeEntry(i),!1):(i.el.src=e,i.el.load(),!0)}_detachIframeMedia(i){const e=this._entries.find(t=>t.source===i);e&&this._removeEntry(e)}_removeEntry(i){i.el.pause(),i.el.src="",this._entries.splice(this._entries.indexOf(i),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==="src"){const a=o.target;w(a)&&a.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(a);continue}if(o.type==="attributes"&&o.attributeName==="preload"){const a=o.target;w(a)&&a.matches("audio[data-start], video[data-start]")&&(a.preload==="auto"?this._adoptIframeMedia(a):this._detachIframeMedia(a));continue}for(const a of o.addedNodes){if(!ve(a))continue;const c=[];w(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)w(u)&&c.push(u);for(const u of c)this._adoptIframeMedia(u)}for(const a of o.removedNodes){if(!ve(a))continue;const c=[];w(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)w(u)&&c.push(u);for(const u of c)this._detachIframeMedia(u)}}}),t={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},s=Dt(i);for(const n of s)e.observe(n,t);this._mediaObserver=e}}function Pe(r,i,e){if(r===null&&i===null)return{range:null,clamped:!1};const t=r??0,s=i!==null&&e>0&&i>e,n=s?e:i,o=n??(e>0?e:1/0);return!(t>=0)||!(o>t)?{range:null,clamped:!0}:{range:{start:t,end:n},clamped:s}}function ie(r,i,e){const t=r.end??i;return t<i?Ge(r.start,t,e):t}function De(r,i,e,t){return r<i.start||r>=ie(i,e,t)}const Ot=100;function Ft(r,i){return typeof r.currentTime=="number"&&Number.isFinite(r.currentTime)?r.currentTime:(r.frame??0)/i}function Fe(r,i,e){return e<=0?!1:r.ended===!0?!0:r.ended===!1&&!r.isPlaying?!1:i>=e}function Nt(r,i,e,t,s,n){const{duration:o}=e;if(!s){const a=Fe(r,i,o);return{start:0,shownAtEnd:o,atEnd:a,stopRuntime:!1,entering:!1}}if(r.ownsRange){const a=t&&r.ended===!0&&!r.isPlaying;return{start:s.start,shownAtEnd:i,atEnd:a,stopRuntime:!1,entering:!1}}return Vt(r,i,e,t,s,n)}function Vt(r,i,e,t,s,n){const o=s.end??e.duration,a=e.enteringRange===!0&&(i<s.start||i>=o);return{start:s.start,shownAtEnd:ie(s,e.duration,n),atEnd:t&&!a&&Fe(r,i,o),stopRuntime:r.isPlaying,entering:a}}function Ht(r,i,e,t){var A;const s=Ft(r,i),n=!e.paused,o=n||r.isPlaying,a=(A=t.getPlayRange)==null?void 0:A.call(t),c=Nt(r,s,e,o,a,i),{atEnd:p,start:u}=c,y=e.duration>0?Math.min(s,e.duration):s,m=p?c.shownAtEnd:y,f=!r.isPlaying,g=p&&o;if(g&&t.getLoop())return t.media.audioOwner==="parent"&&t.media.pauseAll(),t.seek(u),t.play(),{...e,currentTime:u,paused:!1,enteringRange:!0};const _={...e,currentTime:m,paused:f,enteringRange:c.entering};t.media.audioOwner==="parent"&&(n&&f?t.media.pauseAll():!n&&!f&&t.media.playAll(),t.media.mirrorTime(m));const b=performance.now(),E=f!==e.paused;return(b-e.lastUpdateMs>Ot||E)&&(_.lastUpdateMs=b,t.updateControlsTime(m,e.duration),t.updateControlsPlaying(!f),t.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:m}}))),g&&(c.stopRuntime&&t.seek(m),t.media.audioOwner==="parent"&&t.media.pauseAll(),_.paused=!0,t.updateControlsPlaying(!1),t.dispatchEvent(new Event("ended"))),_}function Ut(r){return Array.isArray(r)?r.filter(i=>typeof i=="object"&&i!==null&&typeof i.id=="string"&&typeof i.start=="number"&&typeof i.duration=="number"):[]}function Wt(r,i,e){var o,a,c,p,u,y;if(r.source!==i)return;const t=r.data;if(!t||t.source!=="hf-preview")return;const s=Ye(t);if(s.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:s.code,receivedVersion:s.receivedVersion}}));return}(o=e.setRuntimeFps)==null||o.call(e,s.fps);const n=s.status==="supported"&&s.metadata.capabilities.includes("play-range");if((a=e.setRuntimeOwnsPlayRange)==null||a.call(e,n),t.type==="shader-transition-state"){const m=t.state&&typeof t.state=="object"?t.state:{};e.shaderLoader.update(m,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:t.compositionId,state:m}}));return}if(t.type==="ready"){e.onRuntimeReady();return}if(t.type==="assets-ready"){(c=e.onRuntimeAssetsReady)==null||c.call(e,t.timedOut===!0);return}if(t.type==="runtime-data-error"){(p=e.onRuntimeDataError)==null||p.call(e,t.channel,t.requestId,t.message);return}if(t.type==="runtime-data-applied"){(u=e.onRuntimeDataApplied)==null||u.call(e,t.channel,t.requestId);return}if(t.type==="state"){e.setPlaybackState(Ht({frame:t.frame??0,currentTime:t.currentTime,ended:typeof t.ended=="boolean"?t.ended:void 0,isPlaying:!!t.isPlaying,ownsRange:n},s.fps,e.getPlaybackState(),e));return}if(t.type==="media-autoplay-blocked"){if(((y=e.shouldPromoteMediaAutoplayFallback)==null?void 0:y.call(e))===!1)return;let m=null;try{m=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(m,(f,g)=>e.media.mirrorTime(f,g)),e.sendControl("set-media-output-muted",{muted:!0});return}if(t.type==="timeline"&&t.durationInFrames>0){const m=Number(t.durationSeconds),f=Number(t.durationInFrames),g=Number.isFinite(m)&&m>0?m:f/s.fps;if(Number.isFinite(t.compositionWidth)&&t.compositionWidth>0&&Number.isFinite(t.compositionHeight)&&t.compositionHeight>0&&e.setCompositionSize(t.compositionWidth,t.compositionHeight),Number.isFinite(g)&&g>0){const _=e.getPlaybackState();e.setPlaybackState({..._,duration:g}),e.updateControlsTime(_.currentTime,g),e.onRuntimeTimelineReady(g,typeof t.assetsReady=="boolean"?t.assetsReady:void 0)}e.setScenes(Ut(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 zt(r,i){return r.includes(i)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}const $t=new Set([">"," "," ",`
473
+ `,"\r","\f"]);function G(r,i){const e=r.toLowerCase(),t=`<${i}`;let s=0;for(;s<e.length;){const n=e.indexOf(t,s);if(n<0)return null;const o=e[n+t.length];if($t.has(o)){const a=e.indexOf(">",n+t.length);return a<0?null:{index:n,end:a+1}}s=n+t.length}return null}function jt(r,i){if(!r||zt(r,i))return r;const e=`<script src="${i}"><\/script>`,t=G(r,"head");if(t)return r.slice(0,t.end)+e+r.slice(t.end);const s=G(r,"body");if(s)return r.slice(0,s.index)+e+r.slice(s.index);const n=G(r,"html");return n?r.slice(0,n.end)+e+r.slice(n.end):e+r}const C="shader-capture-scale",k="shader-loading",J="runtime-src",Me="__hf_shader_capture_scale",Le="__hf_shader_loading",z=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function se(r){if(r===null)return null;const i=Number(r);return!Number.isFinite(i)||i<=0?null:String(Math.min(1,Math.max(.25,i)))}function qt(r){if(r===null||r.trim()==="")return"composition";const i=r.trim().toLowerCase();return i==="none"||i==="false"||i==="0"||i==="off"?"none":i==="player"||i==="true"||i==="1"||i==="on"?"player":"composition"}function ke(r,i){return r.filter(e=>e!==""&&e.split("=")[0]!==i)}function Bt(r,i,e){const t=r.indexOf("#"),s=t>=0?r.slice(0,t):r,n=t>=0?r.slice(t):"",o=s.indexOf("?"),a=o>=0?s.slice(0,o):s,c=o>=0?s.slice(o+1):"";let p=ke(c.split("&"),Me);p=ke(p,Le),i!==null&&p.push(`${Me}=${encodeURIComponent(i)}`),e!=="composition"&&p.push(`${Le}=${encodeURIComponent(e)}`);const u=p.join("&");return`${a}${u?`?${u}`:""}${n}`}function Gt(r,i,e){if(i===null&&e==="composition")return r;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 s=`<script data-hyperframes-player-shader-options>${t.join("")}<\/script>`;return/<head\b[^>]*>/i.test(r)?r.replace(/<head\b[^>]*>/i,n=>`${n}${s}`):/<html\b[^>]*>/i.test(r)?r.replace(/<html\b[^>]*>/i,n=>`${n}${s}`):`${s}${r}`}function q(r){return qt(r.getAttribute(k))}function Yt(r){return Number(se(r.getAttribute(C))??"1")}function Xt(r,i){return Bt(i,se(r.getAttribute(C)),q(r))}function H(r,i){return jt(Gt(i,se(r.getAttribute(C)),q(r)),Ne(r))}function Ne(r){var e;const i=(e=r.getAttribute(J))==null?void 0:e.trim();if(!i)return W;try{const t=new URL(i,document.baseURI),s=t.protocol==="http:"||t.protocol==="https:",n=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]";return s&&(n||t.origin===location.origin)?t.href:W}catch{return W}}function Zt(){const r=document.createElement("div");r.className="hfp-shader-loader",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.setAttribute("aria-label","Preparing scene transitions"),r.setAttribute("data-hyperframes-ignore",""),r.draggable=!1;const i=f=>{f.preventDefault(),f.stopPropagation()};for(const f of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(f,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 s=document.createElement("div");s.className="hfp-shader-loader-title";const n=document.createElement("span");n.className="hfp-shader-loader-title-text",n.textContent=z[0],s.appendChild(n);const o=document.createElement("div");o.className="hfp-shader-loader-detail",o.textContent="Rendering animated scene samples for shader transitions.";const a=document.createElement("div");a.className="hfp-shader-loader-track",a.setAttribute("aria-hidden","true");const c=document.createElement("div");c.className="hfp-shader-loader-fill",a.appendChild(c);const p=document.createElement("div");p.className="hfp-shader-loader-progress";const u=f=>{const g=document.createElement("div");g.className="hfp-shader-loader-row";const _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=f;const b=document.createElement("span");return b.className="hfp-shader-loader-value",g.appendChild(_),g.appendChild(b),p.appendChild(g),{row:g,label:_,value:b}},y=u("transition"),m=u("transition frame");return e.appendChild(t),e.appendChild(s),e.appendChild(o),e.appendChild(a),e.appendChild(p),r.appendChild(e),{root:r,fill:c,title:n,detail:o,transitionValue:y.value,transitionRow:y.row,frameLabel:m.label,frameValue:m.value,frameRow:m.row}}const Kt=420;function U(r,i,e){i.textContent=e,r.style.visibility=e?"visible":"hidden"}class Qt{constructor(i){l(this,"_el");l(this,"_hideTimeout",null);l(this,"_hiddenCallbacks",[]);l(this,"_drawingAssets",!1);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())}whenHidden(i){const e=this._el.root.classList;e.contains("hfp-visible")||e.contains("hfp-hiding")?this._hiddenCallbacks.push(i):i()}_flushHidden(){const i=this._hiddenCallbacks;this._hiddenCallbacks=[];for(const e of i)e()}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._drawingAssets=!1,this._flushHidden(),this._el.fill.style.transform="scaleX(0)",U(this._el.transitionRow,this._el.transitionValue,""),U(this._el.frameRow,this._el.frameValue,"")}update(i,e){const t=e==="player"&&i.loading&&!i.ready;if(this._drawingAssets&&!t)return;if(e!=="player"){this.reset();return}if(i.ready||!i.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions"),this._drawingAssets=!1;const s=typeof i.progress=="number"&&Number.isFinite(i.progress)?i.progress:0,n=typeof i.total=="number"&&Number.isFinite(i.total)?i.total:0,o=n>0?Math.min(1,Math.max(0,s/n)):0,a=Math.min(z.length-1,Math.floor(o*z.length));this._el.title.textContent=z[a]||"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(${o})`;const c=i.currentTransition!==void 0&&i.transitionTotal!==void 0?`${i.currentTransition}/${i.transitionTotal}`:n>0?`${s}/${n}`:"",p=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",U(this._el.transitionRow,this._el.transitionValue,c),U(this._el.frameRow,this._el.frameValue,p),this._el.root.setAttribute("aria-valuenow",String(Math.round(o*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._drawingAssets=!0,this.show()}hideAssetsLoading(){this._drawingAssets&&this.hide()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._hiddenCallbacks=[]}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null,this._flushHidden()},Kt)}}function Jt(r){return(r==null?void 0:r.trim().toLowerCase().startsWith("video/"))??!1}function ei(r){const i=document.createElement("video");i.className="hfp-video",i.playsInline=!0,i.preload="metadata";const e=new AbortController,{signal:t}=e;return i.addEventListener("loadedmetadata",()=>r.onMetadata(i),{signal:t}),i.addEventListener("durationchange",()=>r.onDurationChange(i),{signal:t}),i.addEventListener("resize",()=>r.onResize(i),{signal:t}),i.addEventListener("play",()=>r.onPlay(i),{signal:t}),i.addEventListener("pause",()=>r.onPause(i),{signal:t}),i.addEventListener("timeupdate",()=>r.onTimeUpdate(),{signal:t}),i.addEventListener("error",()=>{var n,o;return r.onError(((n=i.error)==null?void 0:n.message)||"Video failed to load",((o=i.error)==null?void 0:o.code)??null)},{signal:t}),{video:i,adapter:{duration:()=>i.duration,time:()=>i.currentTime,seek:n=>{i.currentTime=n},play:()=>i.play().catch(n=>{t.aborted||r.onPlayRejected(n)}),pause:()=>i.pause(),timeScale:n=>{i.defaultPlaybackRate=n,i.playbackRate=n}},destroy:()=>{e.abort(),i.pause(),i.removeAttribute("src"),i.load(),i.remove()}}}const ti=.1,ii=5,Y="sandbox-origin",xe=1e4,X=8e3,Z="assets-loading",D="assets-loading-ui",K="low-power-idle",Ie="disable-click-to-play",M="range-start",L="range-end",si=150;function Q(r){return!Number.isFinite(r)||r<=0?1:Math.max(ti,Math.min(ii,r))}class ri extends HTMLElement{constructor(){super();l(this,"shadow");l(this,"container");l(this,"iframe");l(this,"posterEl",null);l(this,"controlsApi",null);l(this,"resizeObserver");l(this,"shaderLoader");l(this,"probe");l(this,"_ready",!1);l(this,"_readyDocument",null);l(this,"_connected",!1);l(this,"_assetsReady",!1);l(this,"_painted",!1);l(this,"_pendingPlay",!1);l(this,"_assetsGeneration",0);l(this,"_assetsLoadingShowTimer",null);l(this,"_currentTime",0);l(this,"_duration",0);l(this,"_paused",!0);l(this,"_scrubbing",!1);l(this,"_lastUpdateMs",0);l(this,"_volume",1);l(this,"_compositionWidth",1920);l(this,"_compositionHeight",1080);l(this,"_rescaleWarned",!1);l(this,"_directTimelineAdapter",null);l(this,"_directTimelineClock");l(this,"_parentTickRaf",null);l(this,"_media");l(this,"_scenes",[]);l(this,"_runtimeFps",30);l(this,"_runtimeBridgeReady",!1);l(this,"_runtimeAssetsReadyGeneration",-1);l(this,"_runtimeData",new Map);l(this,"_runtimeDataRequestId",0);l(this,"_pendingRuntimeData",new Map);l(this,"_afterUpdate",null);l(this,"_videoSource",null);l(this,"_runtimeOwnsPlayRange",!1);l(this,"_enteringRange",!1);l(this,"_rangeClampReported","");this.shadow=this.attachShadow({mode:"open"}),At(this.shadow,mt),{container:this.container,iframe:this.iframe}=St(),this.shadow.appendChild(this.container);const e=Zt();this.shadow.appendChild(e.root),this.shaderLoader=new Qt(e),this._media=new It({dispatchEvent:t=>this._emit(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Pt({onTimeUpdate:(t,s)=>{var n;this._currentTime=t,(n=this.controlsApi)==null||n.updateTime(t,s),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:t}}))},getLoop:()=>this.loop,restart:()=>{var t;this.seek(((t=this._playRange())==null?void 0:t.start)??0),this.play()},onPaused:()=>{var t;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(t=this.controlsApi)==null||t.updatePlaying(!1),this._emit(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new pt(this.iframe,{resolveRuntimeUrl:()=>Ne(this),onReady:t=>this._onProbeReady(t),onError:t=>this._emit(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{this.disableClickToPlay||wt(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),this.iframe.addEventListener("load",this._onIframeLoad)}static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src","type",Y,J,C,k,D,K,M,L]}connectedCallback(){this._connected=!0,this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=Ce(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=H(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this._connected=!1,this._teardownVideo(),this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),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._pendingPlay=!1,this._abandonComposition("Player disconnected before runtime data was applied")}attributeChangedCallback(e,t,s){var n,o,a,c,p;switch(e){case"src":if(!this.isConnected)break;s&&this._navigateSrc(s);break;case"type":{const u=this.getAttribute("src");if(!this.isConnected||u===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(u);break}case"srcdoc":if(!this.isConnected)break;if(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),s!==null)this._pauseForVideoSwitch(),this._teardownVideo(),this.iframe.srcdoc=H(this,s);else{this.iframe.removeAttribute("srcdoc");const u=this.getAttribute("src");u!==null&&this._wantsVideo()&&this._navigateSrc(u)}break;case Y:this._applySandboxOriginPolicy(this.isConnected&&t!==s);break;case"width":this._setCompositionSize(j(s)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,j(s)??1080);break;case"controls":s!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=Ce(this.shadow,s,this.posterEl);break;case"playback-rate":{const u=Q(parseFloat(s||"1"));this._media.updatePlaybackRate(u),this._sendControl("set-playback-rate",{playbackRate:u}),(a=(o=this._directTimelineAdapter)==null?void 0:o.timeScale)==null||a.call(o,u),(c=this.controlsApi)==null||c.updateSpeed(u),this._emit(new Event("ratechange"));break}case"muted":this._handleMutedChange(s);break;case"audio-locked":this._applyAudioLock(s!==null);break;case"volume":{const u=Math.max(0,Math.min(1,parseFloat(s||"1")));this._volume=u,this._syncVideoAudio(),this._media.updateVolume(u),this._sendControl("set-volume",{volume:u}),(p=this.controlsApi)==null||p.updateVolume(u),this._emit(new Event("volumechange"));break}case"audio-src":s?this._media.setupFromUrl(s):this._media.teardownUrlAudio();break;case D:s==="none"&&this.shaderLoader.hideAssetsLoading();break;case K:this._sendControl("set-idle-heartbeat",{slow:s!==null});break;case M:case L:this._applyPlayRange(!0);break;case C:case k:case J:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(Y)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){if(this._videoSource)return;this._abandonComposition("Sandbox policy changed before runtime data was applied");const e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=H(this,e);return}const t=this.getAttribute("src");t===null?this.iframe.src="about:blank":this._loadSrc(t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){this._play(!0)}_play(e){var o,a;if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,(o=this.posterEl)==null||o.remove(),this.posterEl=null;const t=this._ready?this._playRange():null;t?De(this._currentTime,t,this._duration,this._runtimeFps)&&(this.seek(t.start),this._enteringRange=!0):this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const s=this._tryDirectTimelinePlay();let n=!1;this._sendDisplayScale(),s||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,n=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),(a=this.controlsApi)==null||a.updatePlaying(!0),!n&&e&&this._emit(new Event("play")),s&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused,()=>this._clockStop())}pause(){var e;this._pendingPlay=!1,this._tryDirectTimelinePause()?this._showPausedVideoTime():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._emit(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){var t,s;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),(s=this.controlsApi)==null||s.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 s=structuredClone(t);this._runtimeData.set(e,s),this._deliverRuntimeData(e,s)}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 compositionWidth(){return this._compositionWidth}get compositionHeight(){return this._compositionHeight}get paused(){return this._paused}get ready(){return this._ready}get assetsReady(){return this._assetsReady}get painted(){return this._painted}get playbackRate(){return Q(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(Q(e)))}get shaderCaptureScale(){return Yt(this)}set shaderCaptureScale(e){this.setAttribute(C,String(e))}get shaderLoading(){return q(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(k):this.setAttribute(k,e)}get assetsLoadingUi(){return this.getAttribute(D)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(D,"none"):this.removeAttribute(D)}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._syncVideoAudio(),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(t=this.controlsApi)==null||t.updateMuted(e!==null),this._emit(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 disableClickToPlay(){return this.hasAttribute(Ie)}set disableClickToPlay(e){this.toggleAttribute(Ie,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(M)}set rangeStart(e){this._writeSeconds(M,e)}get rangeEnd(){return this._readSeconds(L)}set rangeEnd(e){this._writeSeconds(L,e)}_readSeconds(e){const t=this.getAttribute(e);return t===null?null:Number(t)}_writeSeconds(e,t){t==null?this.removeAttribute(e):this.setAttribute(e,String(t))}_hasPlayRange(){return this.hasAttribute(M)||this.hasAttribute(L)}_playRange(){return Pe(this.rangeStart,this.rangeEnd,this._duration).range}_sendPlayRange(e){const t=(e==null?void 0:e.end)??null;this._sendControl("set-play-range",{startSeconds:(e==null?void 0:e.start)??null,endSeconds:t})}_applyPlayRange(e){const{range:t,clamped:s}=Pe(this.rangeStart,this.rangeEnd,this._duration);this._sendPlayRange(t),this._ready&&(this._reportRangeClamp(t,s),t&&e&&!this._pendingPlay&&this._moveIntoPlayRange(t))}_reportRangeClamp(e,t){const s=t?`${this.rangeStart},${this.rangeEnd},${this._duration}`:"";if(s===this._rangeClampReported||(this._rangeClampReported=s,!t))return;const n={rangeStart:(e==null?void 0:e.start)??null,rangeEnd:(e==null?void 0:e.end)??null};this._emit(new CustomEvent("rangeclamped",{detail:{...n,duration:this._duration}}))}_moveIntoPlayRange(e){De(this._currentTime,e,this._duration,this._runtimeFps)&&(this._paused?this.seek(e.start):this._jumpWhilePlaying(e.start))}_jumpWhilePlaying(e){this._directTimelineAdapter?(this._directTimelineAdapter.seek(e,!1),this._currentTime=e):this._runtimeOwnsPlayRange||(this.seek(e),this._enteringRange=!0,this._play(!1))}_clockStop(){const e=this._playRange(),t=(e==null?void 0:e.end)??this._duration;if(!e)return{end:t,shown:t};const s=ie(e,this._duration,this._runtimeFps);return{end:t,shown:s<t?(s+t)/2:s}}_sendControl(e,t={}){try{const s=this.iframe.contentWindow;return s?(s.postMessage({...t,source:"hf-parent",type:"control",action:e,...Xe(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,"Composition iframe is unavailable"),!1)}catch(s){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,s instanceof Error?s.message:String(s)),!1}}_deliverRuntimeData(e,t){if(!this.isConnected||!this._runtimeBridgeReady)return;const s=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,t,s)||this._sendControl("set-runtime-data",{channel:e,payload:t,requestId:s})}_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,s){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,s),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,t){var s;try{const n=(s=this.iframe.contentWindow)==null?void 0:s.__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 s=this._runtimeDataRequestId,n=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,s,`Runtime data delivery timed out after ${xe}ms`)},xe);return this._pendingRuntimeData.set(e,{requestId:s,timeoutId:n}),s}_resolveRuntimeDataDelivery(e,t){const s=this._takeRuntimeDataDelivery(e,t);s&&this._emit(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:s.requestId}}))}_rejectRuntimeDataDelivery(e,t,s){const n=this._takeRuntimeDataDelivery(e,t);n&&this._emit(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:n.requestId,message:typeof s=="string"?s:String(s)}}))}_takeRuntimeDataDelivery(e,t){if(typeof e!="string"||typeof t!="number"||!Number.isSafeInteger(t))return null;const s=this._pendingRuntimeData.get(e);return!s||s.requestId!==t?null:(window.clearTimeout(s.timeoutId),this._pendingRuntimeData.delete(e),s)}_rejectAllRuntimeDataDeliveries(e){for(const[t,s]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(t,s.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){const t=this._getSameOriginIframeDocument();if(t)for(const s of t.querySelectorAll("video, audio"))w(s)&&(s.muted=e||s.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()}),this._sendControl("set-idle-heartbeat",{slow:this.hasAttribute(K)}),this._sendDisplayScale()}_sendDisplayScale(){const e=Ze(this.iframe);e&&this._sendControl("set-display-scale",{scale:e})}_reloadShaderOptions(){if(!this._videoSource){if(this._abandonComposition("Shader options changed before runtime data was applied"),this.hasAttribute("srcdoc")){this.iframe.srcdoc=H(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")||"")}}_navigateSrc(e){this._pendingPlay=!1,this._pauseForVideoSwitch(),this._abandonComposition("Composition navigated before runtime data was applied"),this._loadSrc(e)}_wantsVideo(){return Jt(this.getAttribute("type"))&&!this.hasAttribute("srcdoc")}_pauseForVideoSwitch(){var e;!this._videoSource&&!this._wantsVideo()||(this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1))}_loadSrc(e){if(this._wantsVideo()){this._loadVideo(e);return}this._teardownVideo(),this.iframe.src=Xt(this,e)}_loadVideo(e){var n,o;this._videoSource||(this._videoSource=ei({onMetadata:a=>this._applyThenEmit(()=>this._onVideoReady(a)),onDurationChange:a=>this._applyTimelineDuration(a.duration),onResize:a=>this._applyVideoSize(a),onPlay:a=>{!a.paused&&this._paused&&this.play()},onPause:a=>{a.paused&&!a.ended&&!this._paused&&this.pause()},onTimeUpdate:()=>{document.hidden&&this._playRange()&&this._directTimelineClock.poll()},onError:(a,c)=>{this._paused||this.pause(),this._emit(new CustomEvent("error",{detail:{message:a,code:c}}))},onPlayRejected:a=>this._onVideoPlayRejected(a)}),this.container.appendChild(this._videoSource.video),this.iframe.hidden=!0,this.iframe.src="about:blank"),this.probe.stop();const{video:t,adapter:s}=this._videoSource;this._directTimelineAdapter=s,this._currentTime=0,this._duration=0,(n=this.controlsApi)==null||n.updateTime(0,0),this._syncVideoAudio(),(o=s.timeScale)==null||o.call(s,this.playbackRate),t.src=e}_teardownVideo(){this._videoSource&&(this._videoSource.destroy(),this._videoSource=null,this.iframe.hidden=!1)}_syncVideoAudio(){this._videoSource&&(this._videoSource.video.muted=this.muted,this._videoSource.video.volume=this._volume)}_onVideoReady(e){this._applyTimelineDuration(e.duration),this._applyVideoSize(e),this._ready=!0,this._dispatchReady(),this._waitForAssetsReady(null),this._afterEvents(()=>{this.hasAttribute("autoplay")&&this._paused&&this.play()})}_applyTimelineDuration(e){var t;!Number.isFinite(e)||e<=0||(this._setDuration(e),(t=this.controlsApi)==null||t.updateTime(this._currentTime,e))}_applyVideoSize(e){e.videoWidth>0&&e.videoHeight>0&&this._setCompositionSize(e.videoWidth,e.videoHeight)}_onVideoPlayRejected(e){e instanceof DOMException&&e.name==="NotAllowedError"&&(this._paused||this.pause(),this._emit(new CustomEvent("playbackerror",{detail:{source:"video",error:e}})))}_trySyncSeek(e){if(this._videoSource)return!1;try{const t=this.iframe.contentWindow,s=t==null?void 0:t.__player;return typeof(s==null?void 0:s.seek)!="function"?!1:(s.seek.call(s,e),!0)}catch{return!1}}_withDirectTimeline(e){const t=this._videoSource?null:this.probe.resolveDirectTimelineAdapter(),s=t||this._directTimelineAdapter;if(!s)return!1;try{return e(s),t&&t!==this._directTimelineAdapter&&this._applyTimelineDuration(t.duration()),this._directTimelineAdapter=s,!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())}_showPausedVideoTime(){var e;this._videoSource&&(this._currentTime=this._videoSource.video.currentTime,(e=this.controlsApi)==null||e.updateTime(this._currentTime,this._duration),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}})))}_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){this._videoSource||this.probe.failed||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){Wt(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs,enteringRange:this._enteringRange}),setPlaybackState:({currentTime:t,duration:s,paused:n,lastUpdateMs:o,enteringRange:a})=>{this._enteringRange=a===!0,this._currentTime=t,this._setDuration(s),this._paused=n,this._lastUpdateMs=o},getShaderLoadingMode:()=>q(this),shaderLoader:this.shaderLoader,setCompositionSize:(t,s)=>this._setCompositionSize(t,s),sendControl:(t,s)=>this._sendControl(t,s),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._hasPlayRange()&&this._sendPlayRange(this._playRange()),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(t,s)=>this._resolveRuntimeDataDelivery(t,s),onRuntimeDataError:(t,s,n)=>this._rejectRuntimeDataDelivery(t,s,n),onRuntimeTimelineReady:(t,s)=>this._onRuntimeTimelineReady(t,s),setRuntimeFps:t=>{this._runtimeFps=t},setRuntimeOwnsPlayRange:t=>{this._runtimeOwnsPlayRange=t},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:t=>{this._scenes=t,this._emit(new CustomEvent("scenes",{detail:{scenes:t}}))},updateControlsTime:(t,s)=>{var n;return(n=this.controlsApi)==null?void 0:n.updateTime(t,s)},updateControlsPlaying:t=>{var s;return(s=this.controlsApi)==null?void 0:s.updatePlaying(t)},dispatchEvent:t=>this._emit(t),seek:t=>this.seek(t),play:()=>this.play(),getLoop:()=>this.loop,getPlayRange:()=>this._playRange(),media:this._media})}_onRuntimeTimelineReady(e,t){var n;if(this._ready)return;this.probe.stop(),this._setDuration(e),this._directTimelineAdapter=null,this._ready=!0,(n=this.controlsApi)==null||n.updateTime(this._currentTime,e),this._dispatchReady();const s=this._getSameOriginIframeDocument();s&&this._media.setupFromIframe(s),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(s,t),this._playWhenWanted()}_onProbeReady(e){this._applyThenEmit(()=>this._applyProbeResult(e))}_applyProbeResult({duration:e,adapter:t,compositionSize:s}){var o;this._setDuration(e),this._directTimelineAdapter=t.kind==="direct-timeline"?t.timeline:null,s&&this._setCompositionSize(s.width,s.height),this._ready=!0,(o=this.controlsApi)==null||o.updateTime(0,e),this._dispatchReady();const n=this._getSameOriginIframeDocument();n&&this._media.setupFromIframe(n),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(n),this._playWhenWanted()}_waitForAssetsReady(e,t){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1;const s=++this._assetsGeneration;if(!e){t===!1?(this._runtimeAssetsReadyGeneration=s,this._startAssetsLoadingOverlayTimer(s),setTimeout(()=>this._settleAssetsReady(s),X)):this._settleAssetsReady(s);return}Ke(e,({timedOut:n})=>{s===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(s))},{timeoutMs:X}),this._assetsReady||this._startAssetsLoadingOverlayTimer(s)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(Z,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},si)}_hasPendingFirstFrameAssets(e){const{pendingMedia:t,pendingImages:s,fontsLoading:n}=be(e,{scope:we});return t.length>0||s.length>0||n}_warnStuckAssets(e){const{pendingMedia:t,pendingImages:s,fontsLoading:n}=be(e,{scope:we}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${X}ms — playing anyway`,{stuckMedia:t.map(a=>a.currentSrc||a.getAttribute("src")||`<${a.tagName.toLowerCase()}>`),stuckImages:s.map(a=>a.currentSrc||a.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(Z),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this.probe.stop(),this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._runtimeOwnsPlayRange=!1,this._enteringRange=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(Z),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_dispatchReady(){this._readyDocument=this._getSameOriginIframeDocument();const e={duration:this._duration,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight};this._emit(new CustomEvent("ready",{detail:e})),this._rescale(),this._rangeClampReported="",this._hasPlayRange()&&this._applyPlayRange(!0)}_setDuration(e){e!==this._duration&&(this._duration=e,this._ready&&(this._emit(new CustomEvent("durationchange",{detail:{duration:e}})),this._hasPlayRange()&&this._applyPlayRange(!1)))}_setCompositionSize(e,t){const s=e!==this._compositionWidth||t!==this._compositionHeight;if(this._compositionWidth=e,this._compositionHeight=t,this._rescale(),!s)return;const n={compositionWidth:e,compositionHeight:t};this._emit(new CustomEvent("resize",{detail:n}))}_applyThenEmit(e){if(this._afterUpdate){e();return}const t=[];this._afterUpdate=t;const s=[],n=o=>{try{o()}catch(a){s.push(a)}};n(e);for(const o of t)n(o);if(this._afterUpdate=null,s.length>0)throw s[0]}_afterEvents(e){this._afterUpdate?this._afterUpdate.push(e):e()}_playWhenWanted(){this._afterEvents(()=>{(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()})}_emit(e){this._afterEvents(()=>this.dispatchEvent(e))}_rescale(){const e=Rt(this,this.iframe,this._compositionWidth,this._compositionHeight);e&&this._sendDisplayScale(),!e&&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(){if(!this._connected||this._videoSource)return;const e=this._getSameOriginIframeDocument();if(this._ready&&e===this._readyDocument){e&&this._hasPendingFirstFrameAssets(e)&&this._waitForAssetsReady(e);return}this._ready=!1,this._invalidateAssetsWait(),this._releaseDocument(),this.probe.start()}_setupControls(){this.controlsApi||(this.controlsApi=bt(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,s)=>this._mirrorParentMediaTime(t,s)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}}customElements.get("hyperframes-player")||customElements.define("hyperframes-player",ri);export{ri as HyperframesPlayer,yt as SPEED_PRESETS,B as formatSpeed,Te as formatTime};
@@ -1,4 +1,4 @@
1
- import{n as Qi}from"./index-B-wffzRH.js";/*!
1
+ import{n as Qi}from"./index-J7jpL4pj.js";/*!
2
2
  * Copyright (c) 2026-present, Vanilagy and contributors
3
3
  *
4
4
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -1 +1 @@
1
- import{m as P}from"./index-B-wffzRH.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},m;function k(){if(m)return v;m=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var h=e[o+x]-t,_=r.some(function(g){if(g.interval===h)return g.count+=1});_||r.push({interval:h,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,w;function q(){return w||(w=1,p=k().default),p}var b=q();const A=P(b),D=j({__proto__:null,default:A},[b]);export{D as i};
1
+ import{m as P}from"./index-J7jpL4pj.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},m;function k(){if(m)return v;m=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var h=e[o+x]-t,_=r.some(function(g){if(g.interval===h)return g.count+=1});_||r.push({interval:h,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,w;function q(){return w||(w=1,p=k().default),p}var b=q();const A=P(b),D=j({__proto__:null,default:A},[b]);export{D as i};