hyperframes 0.8.83 → 0.8.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var Se=Object.defineProperty;var Le=(r,i,e)=>i in r?Se(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var l=(r,i,e)=>Le(r,typeof i!="symbol"?i+"":i,e);import{r as pe,i as De,a as w,b as me,c as Me,d as xe,s as Pe,e as fe,F as _e}from"./index-BYhK_KMc.js";function ke(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function $(r){return typeof r=="object"&&r!==null}function Ie(r){return $(r)&&typeof r.getDuration=="function"}function Oe(r){return $(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function Ne(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 U=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Ne("0.0.0-dev");function V(r){if(r===null)return null;const i=Number.parseInt(r,10);return Number.isFinite(i)&&i>0?i:null}function Fe(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=V(i.getAttribute("data-width")),t=V(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}class He{constructor(i,e){l(this,"_interval",null);l(this,"_runtimeInjected",!1);this._iframe=i,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{var e;i++;try{const t=this._iframe.contentWindow;if(!t)return;const s=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(ke({hasRuntime:s,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:i})){this._injectRuntime();return}if(this._runtimeInjected&&!s)return;const d=this._resolvePlaybackDurationAdapter(t);if(d&&d.getDuration()>0){this.stop();const c=Fe(this._iframe.contentDocument);this._callbacks.onReady({duration:d.getDuration(),adapter:d,compositionSize:c});return}}catch{}i>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const i=this._iframe.contentWindow;return i?this._resolveDirectTimelineAdapterFromWindow(i):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(i){return this._resolveDirectTimelineAdapterFromWindow(i)}hasRuntimeBridge(i){return Reflect.get(i,"__hf")!==void 0||$(Reflect.get(i,"__player"))}_injectRuntime(){var i,e;this._runtimeInjected=!0;try{const t=this._iframe.contentDocument;if(!t)return;const s=t.createElement("script");s.src=U,(t.head||t.documentElement).appendChild(s),(e=(i=this._callbacks).onRuntimeInjected)==null||e.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(i){var d,c;if(this.hasRuntimeBridge(i))return null;const e=Reflect.get(i,"__timelines");if(!$(e))return null;const t=Object.keys(e);if(t.length===0)return null;const s=(c=(d=this._iframe.contentDocument)==null?void 0:d.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 Oe(o)?o:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(Ie(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const Ue=`
1
+ var Re=Object.defineProperty;var Le=(r,i,e)=>i in r?Re(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var l=(r,i,e)=>Le(r,typeof i!="symbol"?i+"":i,e);import{r as pe,i as Me,a as v,b as me,c as De,d as xe,s as Pe,e as fe,F as _e}from"./index-ClLdmgua.js";function ke(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function $(r){return typeof r=="object"&&r!==null}function Ie(r){return $(r)&&typeof r.getDuration=="function"}function Oe(r){return $(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function Ne(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 U=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Ne("0.0.0-dev");function V(r){if(r===null)return null;const i=Number.parseInt(r,10);return Number.isFinite(i)&&i>0?i:null}function Fe(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=V(i.getAttribute("data-width")),t=V(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}class He{constructor(i,e){l(this,"_interval",null);l(this,"_runtimeInjected",!1);this._iframe=i,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{var e;i++;try{const t=this._iframe.contentWindow;if(!t)return;const s=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(ke({hasRuntime:s,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:i})){this._injectRuntime();return}if(this._runtimeInjected&&!s)return;const a=this._resolvePlaybackDurationAdapter(t);if(a&&a.getDuration()>0){this.stop();const c=Fe(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:c});return}}catch{}i>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const i=this._iframe.contentWindow;return i?this._resolveDirectTimelineAdapterFromWindow(i):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(i){return this._resolveDirectTimelineAdapterFromWindow(i)}hasRuntimeBridge(i){return Reflect.get(i,"__hf")!==void 0||$(Reflect.get(i,"__player"))}_injectRuntime(){var i,e;this._runtimeInjected=!0;try{const t=this._iframe.contentDocument;if(!t)return;const s=t.createElement("script");s.src=U,(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(!$(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 Oe(o)?o:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(Ie(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const Ue=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -460,5 +460,5 @@ var Se=Object.defineProperty;var Le=(r,i,e)=>i in r?Se(r,i,{enumerable:!0,config
460
460
  background: var(--hfp-accent, #fff);
461
461
  pointer-events: none;
462
462
  }
463
- `,We='<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>',$e='<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>',ge='<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>',ye='<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>',Ve='<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>',ze=[.25,.5,1,1.5,2,4];function j(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function be(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 je(r,i,e={}){const t=e.speedPresets??ze,s=document.createElement("div");s.className="hfp-controls",s.addEventListener("click",a=>{a.stopPropagation()});const n=document.createElement("button");n.className="hfp-play-btn",n.type="button",n.innerHTML=`<span class="hfp-ico hfp-ico-play">${We}</span><span class="hfp-ico hfp-ico-pause">${$e}</span>`,n.setAttribute("aria-label","Play");const o=document.createElement("div");o.className="hfp-scrubber";const d=document.createElement("div");d.className="hfp-progress",d.style.width="0%",o.appendChild(d);const c=document.createElement("span");c.className="hfp-time",c.textContent="0:00 / 0:00";const p=document.createElement("div");p.className="hfp-speed-wrap";const u=document.createElement("button");u.className="hfp-speed-btn",u.type="button",u.textContent="1x",u.setAttribute("aria-label","Playback speed");const g=document.createElement("div");g.className="hfp-speed-menu",g.setAttribute("role","menu");for(const a of t){const h=document.createElement("button");h.className="hfp-speed-option",h.type="button",h.setAttribute("role","menuitem"),h.dataset.speed=String(a),h.textContent=j(a),a===1&&h.classList.add("hfp-active"),g.appendChild(h)}p.appendChild(g),p.appendChild(u);const f=document.createElement("div");f.className="hfp-volume-wrap";const m=document.createElement("button");m.className="hfp-mute-btn",m.type="button",m.innerHTML=ge,m.setAttribute("aria-label","Mute");const v=document.createElement("div");v.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),v.appendChild(_),f.appendChild(v),f.appendChild(m),e.audioLocked&&(f.style.display="none"),s.appendChild(n),s.appendChild(o),s.appendChild(c),s.appendChild(f),s.appendChild(p),r.appendChild(s);let M=!1,E=!1,T=1,S=null;t.indexOf(1);const x=(a,h)=>a?Ve:h===0||h<.5?ye:ge;n.addEventListener("click",a=>{a.stopPropagation(),M?i.onPause():i.onPlay()}),m.addEventListener("click",a=>{a.stopPropagation(),i.onMuteToggle()});let C=!1;const P=a=>{const h=_.getBoundingClientRect(),y=Math.max(0,Math.min(1,(a-h.left)/h.width));T=y,b.style.width=`${y*100}%`,_.setAttribute("aria-valuenow",String(Math.round(y*100))),E&&y>0&&i.onMuteToggle(),m.innerHTML=x(E,y),i.onVolumeChange(y)};_.addEventListener("mousedown",a=>{a.stopPropagation(),C=!0,P(a.clientX)});const J=a=>{C&&P(a.clientX)},ee=()=>{C=!1};document.addEventListener("mousemove",J),document.addEventListener("mouseup",ee),_.addEventListener("touchstart",a=>{C=!0;const h=a.touches[0];h&&P(h.clientX)},{passive:!0});const te=a=>{if(C){const h=a.touches[0];h&&P(h.clientX)}},ie=()=>{C=!1};document.addEventListener("touchmove",te,{passive:!0}),document.addEventListener("touchend",ie);const se=.05;_.addEventListener("keydown",a=>{let h=T;if(a.key==="ArrowRight"||a.key==="ArrowUp")h=Math.min(1,T+se);else if(a.key==="ArrowLeft"||a.key==="ArrowDown")h=Math.max(0,T-se);else return;a.preventDefault(),a.stopPropagation(),T=h,b.style.width=`${h*100}%`,_.setAttribute("aria-valuenow",String(Math.round(h*100))),E&&h>0&&i.onMuteToggle(),m.innerHTML=x(E,h),i.onVolumeChange(h)});const re=a=>{for(const h of g.querySelectorAll(".hfp-speed-option"))h.classList.toggle("hfp-active",h.dataset.speed===String(a))};u.addEventListener("click",a=>{a.stopPropagation();const h=g.classList.toggle("hfp-open");u.setAttribute("aria-expanded",String(h))}),g.addEventListener("click",a=>{a.stopPropagation();const h=a.target.closest(".hfp-speed-option");if(!h)return;const y=parseFloat(h.dataset.speed);t.indexOf(y),u.textContent=j(y),re(y),g.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false"),i.onSpeedChange(y)});const ne=()=>{g.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false")};document.addEventListener("click",ne);const k=a=>{const h=o.getBoundingClientRect(),y=Math.max(0,Math.min(1,(a-h.left)/h.width));i.onSeek(y)};let A=!1;o.addEventListener("mousedown",a=>{var h;a.stopPropagation(),A=!0,(h=i.onScrubStart)==null||h.call(i),k(a.clientX)});const oe=a=>{A&&k(a.clientX)},ae=()=>{var a;A&&(A=!1,(a=i.onScrubEnd)==null||a.call(i))};document.addEventListener("mousemove",oe),document.addEventListener("mouseup",ae),o.addEventListener("touchstart",a=>{var y;A=!0,(y=i.onScrubStart)==null||y.call(i);const h=a.touches[0];h&&k(h.clientX)},{passive:!0});const de=a=>{if(A){const h=a.touches[0];h&&k(h.clientX)}},le=()=>{var a;A&&(A=!1,(a=i.onScrubEnd)==null||a.call(i))};document.addEventListener("touchmove",de,{passive:!0}),document.addEventListener("touchend",le);const he=()=>{S&&clearTimeout(S),S=setTimeout(()=>{M&&s.classList.add("hfp-hidden")},3e3)},I=r instanceof ShadowRoot?r.host:r,ue=()=>{s.classList.remove("hfp-hidden"),he()},ce=()=>{M&&s.classList.add("hfp-hidden")};return I.addEventListener("mousemove",ue),I.addEventListener("mouseleave",ce),{updateTime(a,h){const y=h>0?Math.min(a,h):a,Re=h>0?y/h*100:0;d.style.width=`${Re}%`,c.textContent=`${be(y)} / ${be(h)}`},updatePlaying(a){M=a,n.classList.toggle("hfp-playing",a),n.setAttribute("aria-label",a?"Pause":"Play"),a?he():s.classList.remove("hfp-hidden")},updateSpeed(a){t.indexOf(a),u.textContent=j(a),re(a)},updateMuted(a){E=a,m.innerHTML=x(a,T),m.setAttribute("aria-label",a?"Unmute":"Mute")},updateVolume(a){T=a,b.style.width=`${a*100}%`,_.setAttribute("aria-valuenow",String(Math.round(a*100))),m.innerHTML=x(E,a)},setVolumeControlsHidden(a){f.style.display=a?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",ae),document.removeEventListener("touchmove",de),document.removeEventListener("touchend",le),document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",ee),document.removeEventListener("touchmove",te),document.removeEventListener("touchend",ie),document.removeEventListener("click",ne),I.removeEventListener("mousemove",ue),I.removeEventListener("mouseleave",ce),S&&clearTimeout(S),s.remove()}}}function qe(r,i,e,t,s,n=!1){const o=t?t.split(",").map(Number).filter(p=>!isNaN(p)&&p>0):void 0,d={...o?{speedPresets:o}:{},audioLocked:n},c=je(r,s,d);return c.updateMuted(i),c.updateVolume(e),c}function ve(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 Be(r){return r.composedPath().some(i=>i instanceof HTMLElement&&i.classList.contains("hfp-controls"))}let O=null;function Ge(r,i){if(typeof CSSStyleSheet<"u")try{O||(O=new CSSStyleSheet,O.replaceSync(i)),r.adoptedStyleSheets=[O];return}catch{}const e=document.createElement("style");e.textContent=i,r.appendChild(e)}function Ye(){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 Xe(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 Ze=100;class Ke{constructor(i){l(this,"_raf",null);l(this,"_lastUpdateMs",0);this._callbacks=i}start(i,e,t,s){this.stop();const n=()=>{if(s()){this._raf=null;return}let o;try{o=i.time()}catch{this._raf=null;return}const d=t();d>0&&(o=Math.min(o,d));const c=d>0&&o>=d,p=performance.now();if((p-this._lastUpdateMs>Ze||c)&&(this._lastUpdateMs=p,this._callbacks.onTimeUpdate(o,d)),c){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{i.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(n)};this._raf=requestAnimationFrame(n)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function Qe(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)et(t)||e.push(t);return Je(r),e}function Je(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 et(r){let i=r.parentElement;for(;i;){if(i.hasAttribute("data-composition-id"))return!0;i=i.parentElement}return!1}const tt=.05,it=2;class st{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=pe(i.source);i.start=e.start??0,i.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(i,e){return De(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)>tt?(s.driftSamples+=1,(t||s.driftSamples>=it)&&(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);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._entries.some(p=>p.el.src===i))return null;const o=e==="video"?document.createElement("video"):new Audio;o.preload="auto",o.src=i,o.load(),o.muted=this._getMuted(),o.volume=this._getVolume();const d=this._getPlaybackRate();d!==1&&(o.playbackRate=d);const c={el:o,start:t,duration: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=pe(i),s=t.start??0,n=t.duration??Number.POSITIVE_INFINITY,o=i.tagName==="VIDEO"?"video":"audio",d=this._createEntry(e,o,s,n,i);d&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(d))}_detachIframeMedia(i){const e=this._resolveIframeMediaSrc(i);if(!e)return;const t=this._entries.findIndex(n=>n.el.src===e);if(t===-1)return;const s=this._entries[t];s.el.pause(),s.el.src="",this._entries.splice(t,1)}_observeDynamicMedia(i){if(this.teardownObserver(),typeof MutationObserver>"u"||!i.body)return;const e=new MutationObserver(n=>{for(const o of n){if(o.type==="attributes"&&o.attributeName==="preload"){const d=o.target;w(d)&&d.matches("audio[data-start], video[data-start]")&&d.preload==="auto"&&this._adoptIframeMedia(d);continue}for(const d of o.addedNodes){if(!me(d))continue;const c=[];w(d)&&d.matches("audio[data-start], video[data-start]")&&c.push(d);const p=d.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)w(u)&&c.push(u);for(const u of c)this._adoptIframeMedia(u)}for(const d of o.removedNodes){if(!me(d))continue;const c=[];w(d)&&d.matches("audio[data-start], video[data-start]")&&c.push(d);const p=d.querySelectorAll("audio[data-start], video[data-start]");for(const 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"]},s=Qe(i);for(const n of s)e.observe(n,t);this._mediaObserver=e}}const rt=100;function nt(r,i){return typeof r.currentTime=="number"&&Number.isFinite(r.currentTime)?r.currentTime:(r.frame??0)/i}function ot(r,i,e){return e<=0?!1:r.ended===!0?!0:r.ended===!1&&!r.isPlaying?!1:i>=e}function at(r,i,e,t){const s=nt(r,i),n=ot(r,s,e.duration),o=e.duration>0?Math.min(s,e.duration):s,d=n?e.duration:o,c=!e.paused,p=!r.isPlaying,u=n&&(c||r.isPlaying);if(u&&t.getLoop())return t.media.audioOwner==="parent"&&t.media.pauseAll(),t.seek(0),t.play(),{...e,currentTime:0,paused:!1};const g={...e,currentTime:d,paused:p};t.media.audioOwner==="parent"&&(c&&p?t.media.pauseAll():!c&&!p&&t.media.playAll(),t.media.mirrorTime(d));const f=performance.now(),m=p!==e.paused;return(f-e.lastUpdateMs>rt||m)&&(g.lastUpdateMs=f,t.updateControlsTime(d,e.duration),t.updateControlsPlaying(!p),t.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:d}}))),u&&(t.media.audioOwner==="parent"&&t.media.pauseAll(),g.paused=!0,t.updateControlsPlaying(!1),t.dispatchEvent(new Event("ended"))),g}function dt(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 lt(r,i,e){var n,o,d,c,p;if(r.source!==i)return;const t=r.data;if(!t||t.source!=="hf-preview")return;const s=Me(t);if(s.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:s.code,receivedVersion:s.receivedVersion}}));return}if((n=e.setRuntimeFps)==null||n.call(e,s.fps),t.type==="shader-transition-state"){const u=t.state&&typeof t.state=="object"?t.state:{};e.shaderLoader.update(u,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:t.compositionId,state:u}}));return}if(t.type==="ready"){e.onRuntimeReady();return}if(t.type==="assets-ready"){(o=e.onRuntimeAssetsReady)==null||o.call(e,t.timedOut===!0);return}if(t.type==="runtime-data-error"){(d=e.onRuntimeDataError)==null||d.call(e,t.channel,t.requestId,t.message);return}if(t.type==="runtime-data-applied"){(c=e.onRuntimeDataApplied)==null||c.call(e,t.channel,t.requestId);return}if(t.type==="state"){e.setPlaybackState(at({frame:t.frame??0,currentTime:t.currentTime,ended:typeof t.ended=="boolean"?t.ended:void 0,isPlaying:!!t.isPlaying},s.fps,e.getPlaybackState(),e));return}if(t.type==="media-autoplay-blocked"){if(((p=e.shouldPromoteMediaAutoplayFallback)==null?void 0:p.call(e))===!1)return;let u=null;try{u=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(u,(g,f)=>e.media.mirrorTime(g,f)),e.sendControl("set-media-output-muted",{muted:!0});return}if(t.type==="timeline"&&t.durationInFrames>0){const u=Number(t.durationSeconds),g=Number(t.durationInFrames),f=Number.isFinite(u)&&u>0?u:g/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(f)&&f>0){const m=e.getPlaybackState();e.setPlaybackState({...m,duration:f}),e.updateControlsTime(m.currentTime,f),e.onRuntimeTimelineReady(f,typeof t.assetsReady=="boolean"?t.assetsReady:void 0)}e.setScenes(dt(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 ht(r,i){return r.includes(i)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}const ut=new Set([">"," "," ",`
464
- `,"\r","\f"]);function q(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(ut.has(o)){const d=e.indexOf(">",n+t.length);return d<0?null:{index:n,end:d+1}}s=n+t.length}return null}function ct(r,i){if(!r||ht(r,i))return r;const e=`<script src="${i}"><\/script>`,t=q(r,"head");if(t)return r.slice(0,t.end)+e+r.slice(t.end);const s=q(r,"body");if(s)return r.slice(0,s.index)+e+r.slice(s.index);const n=q(r,"html");return n?r.slice(0,n.end)+e+r.slice(n.end):e+r}const R="shader-capture-scale",D="shader-loading",K="runtime-src",we="__hf_shader_capture_scale",Ae="__hf_shader_loading",W=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function Q(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 pt(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 Te(r,i){return r.filter(e=>e!==""&&e.split("=")[0]!==i)}function mt(r,i,e){const t=r.indexOf("#"),s=t>=0?r.slice(0,t):r,n=t>=0?r.slice(t):"",o=s.indexOf("?"),d=o>=0?s.slice(0,o):s,c=o>=0?s.slice(o+1):"";let p=Te(c.split("&"),we);p=Te(p,Ae),i!==null&&p.push(`${we}=${encodeURIComponent(i)}`),e!=="composition"&&p.push(`${Ae}=${encodeURIComponent(e)}`);const u=p.join("&");return`${d}${u?`?${u}`:""}${n}`}function ft(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 z(r){return pt(r.getAttribute(D))}function _t(r){return Number(Q(r.getAttribute(R))??"1")}function N(r,i){return mt(i,Q(r.getAttribute(R)),z(r))}function F(r,i){return ct(ft(i,Q(r.getAttribute(R)),z(r)),gt(r))}function gt(r){var e;const i=(e=r.getAttribute(K))==null?void 0:e.trim();if(!i)return U;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:U}catch{return U}}function yt(){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=m=>{m.preventDefault(),m.stopPropagation()};for(const m of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(m,i,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const t=document.createElement("div");t.className="hfp-shader-loader-mark",t.draggable=!1,t.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");const s=document.createElement("div");s.className="hfp-shader-loader-title";const n=document.createElement("span");n.className="hfp-shader-loader-title-text",n.textContent=W[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 d=document.createElement("div");d.className="hfp-shader-loader-track",d.setAttribute("aria-hidden","true");const c=document.createElement("div");c.className="hfp-shader-loader-fill",d.appendChild(c);const p=document.createElement("div");p.className="hfp-shader-loader-progress";const u=m=>{const v=document.createElement("div");v.className="hfp-shader-loader-row";const _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=m;const b=document.createElement("span");return b.className="hfp-shader-loader-value",v.appendChild(_),v.appendChild(b),p.appendChild(v),{row:v,label:_,value:b}},g=u("transition"),f=u("transition frame");return e.appendChild(t),e.appendChild(s),e.appendChild(o),e.appendChild(d),e.appendChild(p),r.appendChild(e),{root:r,fill:c,title:n,detail:o,transitionValue:g.value,transitionRow:g.row,frameLabel:f.label,frameValue:f.value,frameRow:f.row}}const bt=420;function H(r,i,e){i.textContent=e,r.style.visibility=e?"visible":"hidden"}class vt{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)",H(this._el.transitionRow,this._el.transitionValue,""),H(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,d=Math.min(W.length-1,Math.floor(o*W.length));this._el.title.textContent=W[d]||"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",H(this._el.transitionRow,this._el.transitionValue,c),H(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()},bt)}}const wt=.1,At=5,B="sandbox-origin",Ee=1e4,G=8e3,Y="assets-loading",L="assets-loading-ui",X="low-power-idle",Ce="disable-click-to-play",Tt=150;function Z(r){return!Number.isFinite(r)||r<=0?1:Math.max(wt,Math.min(At,r))}class Et 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);this.shadow=this.attachShadow({mode:"open"}),Ge(this.shadow,Ue),{container:this.container,iframe:this.iframe}=Ye(),this.shadow.appendChild(this.container);const e=yt();this.shadow.appendChild(e.root),this.shaderLoader=new vt(e),this._media=new st({dispatchEvent:t=>this._emit(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Ke({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:()=>{this.seek(0),this.play()},onPaused:()=>{var t;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(t=this.controlsApi)==null||t.updatePlaying(!1),this._emit(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new He(this.iframe,{onReady:t=>this._onProbeReady(t),onError:t=>this._emit(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{this.disableClickToPlay||Be(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",B,K,R,D,L,X]}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=ve(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=F(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&(this.iframe.src=N(this,this.getAttribute("src"))),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this._connected=!1,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,d,c,p;switch(e){case"src":if(!this.isConnected)break;s&&(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),this.iframe.src=N(this,s));break;case"srcdoc":if(!this.isConnected)break;this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),s!==null?this.iframe.srcdoc=F(this,s):this.iframe.removeAttribute("srcdoc");break;case B:this._applySandboxOriginPolicy(this.isConnected&&t!==s);break;case"width":this._setCompositionSize(V(s)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,V(s)??1080);break;case"controls":s!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=ve(this.shadow,s,this.posterEl);break;case"playback-rate":{const u=Z(parseFloat(s||"1"));this._media.updatePlaybackRate(u),this._sendControl("set-playback-rate",{playbackRate:u}),(d=(o=this._directTimelineAdapter)==null?void 0:o.timeScale)==null||d.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._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 L:s==="none"&&this.shaderLoader.hideAssetsLoading();break;case X:this._sendControl("set-idle-heartbeat",{slow:s!==null});break;case R:case D:case K:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(B)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){this._abandonComposition("Sandbox policy changed before runtime data was applied");const e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=F(this,e);return}const t=this.getAttribute("src");this.iframe.src=t===null?"about:blank":N(this,t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){var s,n;if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,(s=this.posterEl)==null||s.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const e=this._tryDirectTimelinePlay();let t=!1;e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,t=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),(n=this.controlsApi)==null||n.updatePlaying(!0),t||this._emit(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){var e;this._pendingPlay=!1,this._tryDirectTimelinePause()||this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1),this._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 Z(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(Z(e)))}get shaderCaptureScale(){return _t(this)}set shaderCaptureScale(e){this.setAttribute(R,String(e))}get shaderLoading(){return z(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(D):this.setAttribute(D,e)}get assetsLoadingUi(){return this.getAttribute(L)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(L,"none"):this.removeAttribute(L)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_isLockedHostEnvironment(){if(typeof navigator>"u")return!1;const e=navigator.userAgent||"";return/\bClaude\/\d/.test(e)&&/\bElectron\b/.test(e)}_isAudioLocked(){return this.hasAttribute("audio-locked")||this._isLockedHostEnvironment()}_isSlideshowPlayer(){return this.closest("hyperframes-slideshow")!==null}_handleMutedChange(e){var t;if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(t=this.controlsApi)==null||t.updateMuted(e!==null),this._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(Ce)}set disableClickToPlay(e){this.toggleAttribute(Ce,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_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 ${Ee}ms`)},Ee);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(X)})}_reloadShaderOptions(){if(this._abandonComposition("Shader options changed before runtime data was applied"),this.hasAttribute("srcdoc")){this.iframe.srcdoc=F(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&(this.iframe.src=N(this,this.getAttribute("src")||""))}_trySyncSeek(e){try{const t=this.iframe.contentWindow,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){var n;const t=this.probe.resolveDirectTimelineAdapter(),s=t||this._directTimelineAdapter;if(!s)return!1;try{if(e(s),t&&t!==this._directTimelineAdapter){const o=t.duration();Number.isFinite(o)&&o>0&&(this._setDuration(o),(n=this.controlsApi)==null||n.updateTime(this._currentTime,o))}return 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())}_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._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){lt(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:t,duration:s,paused:n,lastUpdateMs:o})=>{this._currentTime=t,this._setDuration(s),this._paused=n,this._lastUpdateMs=o},getShaderLoadingMode:()=>z(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._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},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,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),G)):this._settleAssetsReady(s);return}Pe(e,({timedOut:n})=>{s===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(s))},{timeoutMs:G}),this._assetsReady||this._startAssetsLoadingOverlayTimer(s)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(Y,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},Tt)}_hasPendingFirstFrameAssets(e){const{pendingMedia:t,pendingImages:s,fontsLoading:n}=fe(e,{scope:_e});return t.length>0||s.length>0||n}_warnStuckAssets(e){const{pendingMedia:t,pendingImages:s,fontsLoading:n}=fe(e,{scope:_e}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${G}ms — playing anyway`,{stuckMedia:t.map(d=>d.currentSrc||d.getAttribute("src")||`<${d.tagName.toLowerCase()}>`),stuckImages:s.map(d=>d.currentSrc||d.getAttribute("src")||"<img>"),fontsLoading:n,computeReady:(o==null?void 0:o.__renderReady)===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(Y),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._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){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(Y),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()}_setDuration(e){e!==this._duration&&(this._duration=e,this._ready&&this._emit(new CustomEvent("durationchange",{detail:{duration:e}})))}_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(d){s.push(d)}};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(){!Xe(this,this.iframe,this._compositionWidth,this._compositionHeight)&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready — zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){if(!this._connected)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=qe(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",Et);export{Et as HyperframesPlayer,ze as SPEED_PRESETS,j as formatSpeed,be as formatTime};
463
+ `,We='<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>',$e='<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>',ge='<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>',ye='<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>',Ve='<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>',ze=[.25,.5,1,1.5,2,4];function j(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function be(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 je(r,i,e={}){const t=e.speedPresets??ze,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">${We}</span><span class="hfp-ico hfp-ico-pause">${$e}</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 g=document.createElement("div");g.className="hfp-speed-menu",g.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=j(d),d===1&&h.classList.add("hfp-active"),g.appendChild(h)}p.appendChild(g),p.appendChild(u);const f=document.createElement("div");f.className="hfp-volume-wrap";const m=document.createElement("button");m.className="hfp-mute-btn",m.type="button",m.innerHTML=ge,m.setAttribute("aria-label","Mute");const w=document.createElement("div");w.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),w.appendChild(_),f.appendChild(w),f.appendChild(m),e.audioLocked&&(f.style.display="none"),s.appendChild(n),s.appendChild(o),s.appendChild(c),s.appendChild(f),s.appendChild(p),r.appendChild(s);let D=!1,E=!1,T=1,R=null;t.indexOf(1);const x=(d,h)=>d?Ve:h===0||h<.5?ye:ge;n.addEventListener("click",d=>{d.stopPropagation(),D?i.onPause():i.onPlay()}),m.addEventListener("click",d=>{d.stopPropagation(),i.onMuteToggle()});let C=!1;const P=d=>{const h=_.getBoundingClientRect(),y=Math.max(0,Math.min(1,(d-h.left)/h.width));T=y,b.style.width=`${y*100}%`,_.setAttribute("aria-valuenow",String(Math.round(y*100))),E&&y>0&&i.onMuteToggle(),m.innerHTML=x(E,y),i.onVolumeChange(y)};_.addEventListener("mousedown",d=>{d.stopPropagation(),C=!0,P(d.clientX)});const J=d=>{C&&P(d.clientX)},ee=()=>{C=!1};document.addEventListener("mousemove",J),document.addEventListener("mouseup",ee),_.addEventListener("touchstart",d=>{C=!0;const h=d.touches[0];h&&P(h.clientX)},{passive:!0});const te=d=>{if(C){const h=d.touches[0];h&&P(h.clientX)}},ie=()=>{C=!1};document.addEventListener("touchmove",te,{passive:!0}),document.addEventListener("touchend",ie);const se=.05;_.addEventListener("keydown",d=>{let h=T;if(d.key==="ArrowRight"||d.key==="ArrowUp")h=Math.min(1,T+se);else if(d.key==="ArrowLeft"||d.key==="ArrowDown")h=Math.max(0,T-se);else return;d.preventDefault(),d.stopPropagation(),T=h,b.style.width=`${h*100}%`,_.setAttribute("aria-valuenow",String(Math.round(h*100))),E&&h>0&&i.onMuteToggle(),m.innerHTML=x(E,h),i.onVolumeChange(h)});const re=d=>{for(const h of g.querySelectorAll(".hfp-speed-option"))h.classList.toggle("hfp-active",h.dataset.speed===String(d))};u.addEventListener("click",d=>{d.stopPropagation();const h=g.classList.toggle("hfp-open");u.setAttribute("aria-expanded",String(h))}),g.addEventListener("click",d=>{d.stopPropagation();const h=d.target.closest(".hfp-speed-option");if(!h)return;const y=parseFloat(h.dataset.speed);t.indexOf(y),u.textContent=j(y),re(y),g.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false"),i.onSpeedChange(y)});const ne=()=>{g.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false")};document.addEventListener("click",ne);const k=d=>{const h=o.getBoundingClientRect(),y=Math.max(0,Math.min(1,(d-h.left)/h.width));i.onSeek(y)};let A=!1;o.addEventListener("mousedown",d=>{var h;d.stopPropagation(),A=!0,(h=i.onScrubStart)==null||h.call(i),k(d.clientX)});const oe=d=>{A&&k(d.clientX)},ae=()=>{var d;A&&(A=!1,(d=i.onScrubEnd)==null||d.call(i))};document.addEventListener("mousemove",oe),document.addEventListener("mouseup",ae),o.addEventListener("touchstart",d=>{var y;A=!0,(y=i.onScrubStart)==null||y.call(i);const h=d.touches[0];h&&k(h.clientX)},{passive:!0});const de=d=>{if(A){const h=d.touches[0];h&&k(h.clientX)}},le=()=>{var d;A&&(A=!1,(d=i.onScrubEnd)==null||d.call(i))};document.addEventListener("touchmove",de,{passive:!0}),document.addEventListener("touchend",le);const he=()=>{R&&clearTimeout(R),R=setTimeout(()=>{D&&s.classList.add("hfp-hidden")},3e3)},I=r instanceof ShadowRoot?r.host:r,ue=()=>{s.classList.remove("hfp-hidden"),he()},ce=()=>{D&&s.classList.add("hfp-hidden")};return I.addEventListener("mousemove",ue),I.addEventListener("mouseleave",ce),{updateTime(d,h){const y=h>0?Math.min(d,h):d,Se=h>0?y/h*100:0;a.style.width=`${Se}%`,c.textContent=`${be(y)} / ${be(h)}`},updatePlaying(d){D=d,n.classList.toggle("hfp-playing",d),n.setAttribute("aria-label",d?"Pause":"Play"),d?he():s.classList.remove("hfp-hidden")},updateSpeed(d){t.indexOf(d),u.textContent=j(d),re(d)},updateMuted(d){E=d,m.innerHTML=x(d,T),m.setAttribute("aria-label",d?"Unmute":"Mute")},updateVolume(d){T=d,b.style.width=`${d*100}%`,_.setAttribute("aria-valuenow",String(Math.round(d*100))),m.innerHTML=x(E,d)},setVolumeControlsHidden(d){f.style.display=d?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",ae),document.removeEventListener("touchmove",de),document.removeEventListener("touchend",le),document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",ee),document.removeEventListener("touchmove",te),document.removeEventListener("touchend",ie),document.removeEventListener("click",ne),I.removeEventListener("mousemove",ue),I.removeEventListener("mouseleave",ce),R&&clearTimeout(R),s.remove()}}}function qe(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=je(r,s,a);return c.updateMuted(i),c.updateVolume(e),c}function ve(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 Be(r){return r.composedPath().some(i=>i instanceof HTMLElement&&i.classList.contains("hfp-controls"))}let O=null;function Ge(r,i){if(typeof CSSStyleSheet<"u")try{O||(O=new CSSStyleSheet,O.replaceSync(i)),r.adoptedStyleSheets=[O];return}catch{}const e=document.createElement("style");e.textContent=i,r.appendChild(e)}function Ye(){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 Xe(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 Ze=100;class Ke{constructor(i){l(this,"_raf",null);l(this,"_lastUpdateMs",0);this._callbacks=i}start(i,e,t,s){this.stop();const n=()=>{if(s()){this._raf=null;return}let o;try{o=i.time()}catch{this._raf=null;return}const a=t();a>0&&(o=Math.min(o,a));const c=a>0&&o>=a,p=performance.now();if((p-this._lastUpdateMs>Ze||c)&&(this._lastUpdateMs=p,this._callbacks.onTimeUpdate(o,a)),c){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{i.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(n)};this._raf=requestAnimationFrame(n)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function Qe(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)et(t)||e.push(t);return Je(r),e}function Je(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 et(r){let i=r.parentElement;for(;i;){if(i.hasAttribute("data-composition-id"))return!0;i=i.parentElement}return!1}const tt=.05,it=2;class st{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=pe(i.source);i.start=e.start??0,i.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(i,e){return Me(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)>tt?(s.driftSamples+=1,(t||s.driftSamples>=it)&&(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"))v(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)v(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=pe(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;v(a)&&a.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(a);continue}if(o.type==="attributes"&&o.attributeName==="preload"){const a=o.target;v(a)&&a.matches("audio[data-start], video[data-start]")&&a.preload==="auto"&&this._adoptIframeMedia(a);continue}for(const a of o.addedNodes){if(!me(a))continue;const c=[];v(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)v(u)&&c.push(u);for(const u of c)this._adoptIframeMedia(u)}for(const a of o.removedNodes){if(!me(a))continue;const c=[];v(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)v(u)&&c.push(u);for(const u of c)this._detachIframeMedia(u)}}}),t={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},s=Qe(i);for(const n of s)e.observe(n,t);this._mediaObserver=e}}const rt=100;function nt(r,i){return typeof r.currentTime=="number"&&Number.isFinite(r.currentTime)?r.currentTime:(r.frame??0)/i}function ot(r,i,e){return e<=0?!1:r.ended===!0?!0:r.ended===!1&&!r.isPlaying?!1:i>=e}function at(r,i,e,t){const s=nt(r,i),n=ot(r,s,e.duration),o=e.duration>0?Math.min(s,e.duration):s,a=n?e.duration:o,c=!e.paused,p=!r.isPlaying,u=n&&(c||r.isPlaying);if(u&&t.getLoop())return t.media.audioOwner==="parent"&&t.media.pauseAll(),t.seek(0),t.play(),{...e,currentTime:0,paused:!1};const g={...e,currentTime:a,paused:p};t.media.audioOwner==="parent"&&(c&&p?t.media.pauseAll():!c&&!p&&t.media.playAll(),t.media.mirrorTime(a));const f=performance.now(),m=p!==e.paused;return(f-e.lastUpdateMs>rt||m)&&(g.lastUpdateMs=f,t.updateControlsTime(a,e.duration),t.updateControlsPlaying(!p),t.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:a}}))),u&&(t.media.audioOwner==="parent"&&t.media.pauseAll(),g.paused=!0,t.updateControlsPlaying(!1),t.dispatchEvent(new Event("ended"))),g}function dt(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 lt(r,i,e){var n,o,a,c,p;if(r.source!==i)return;const t=r.data;if(!t||t.source!=="hf-preview")return;const s=De(t);if(s.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:s.code,receivedVersion:s.receivedVersion}}));return}if((n=e.setRuntimeFps)==null||n.call(e,s.fps),t.type==="shader-transition-state"){const u=t.state&&typeof t.state=="object"?t.state:{};e.shaderLoader.update(u,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:t.compositionId,state:u}}));return}if(t.type==="ready"){e.onRuntimeReady();return}if(t.type==="assets-ready"){(o=e.onRuntimeAssetsReady)==null||o.call(e,t.timedOut===!0);return}if(t.type==="runtime-data-error"){(a=e.onRuntimeDataError)==null||a.call(e,t.channel,t.requestId,t.message);return}if(t.type==="runtime-data-applied"){(c=e.onRuntimeDataApplied)==null||c.call(e,t.channel,t.requestId);return}if(t.type==="state"){e.setPlaybackState(at({frame:t.frame??0,currentTime:t.currentTime,ended:typeof t.ended=="boolean"?t.ended:void 0,isPlaying:!!t.isPlaying},s.fps,e.getPlaybackState(),e));return}if(t.type==="media-autoplay-blocked"){if(((p=e.shouldPromoteMediaAutoplayFallback)==null?void 0:p.call(e))===!1)return;let u=null;try{u=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(u,(g,f)=>e.media.mirrorTime(g,f)),e.sendControl("set-media-output-muted",{muted:!0});return}if(t.type==="timeline"&&t.durationInFrames>0){const u=Number(t.durationSeconds),g=Number(t.durationInFrames),f=Number.isFinite(u)&&u>0?u:g/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(f)&&f>0){const m=e.getPlaybackState();e.setPlaybackState({...m,duration:f}),e.updateControlsTime(m.currentTime,f),e.onRuntimeTimelineReady(f,typeof t.assetsReady=="boolean"?t.assetsReady:void 0)}e.setScenes(dt(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 ht(r,i){return r.includes(i)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}const ut=new Set([">"," "," ",`
464
+ `,"\r","\f"]);function q(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(ut.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 ct(r,i){if(!r||ht(r,i))return r;const e=`<script src="${i}"><\/script>`,t=q(r,"head");if(t)return r.slice(0,t.end)+e+r.slice(t.end);const s=q(r,"body");if(s)return r.slice(0,s.index)+e+r.slice(s.index);const n=q(r,"html");return n?r.slice(0,n.end)+e+r.slice(n.end):e+r}const S="shader-capture-scale",M="shader-loading",K="runtime-src",we="__hf_shader_capture_scale",Ae="__hf_shader_loading",W=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function Q(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 pt(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 Te(r,i){return r.filter(e=>e!==""&&e.split("=")[0]!==i)}function mt(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=Te(c.split("&"),we);p=Te(p,Ae),i!==null&&p.push(`${we}=${encodeURIComponent(i)}`),e!=="composition"&&p.push(`${Ae}=${encodeURIComponent(e)}`);const u=p.join("&");return`${a}${u?`?${u}`:""}${n}`}function ft(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 z(r){return pt(r.getAttribute(M))}function _t(r){return Number(Q(r.getAttribute(S))??"1")}function N(r,i){return mt(i,Q(r.getAttribute(S)),z(r))}function F(r,i){return ct(ft(i,Q(r.getAttribute(S)),z(r)),gt(r))}function gt(r){var e;const i=(e=r.getAttribute(K))==null?void 0:e.trim();if(!i)return U;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:U}catch{return U}}function yt(){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=m=>{m.preventDefault(),m.stopPropagation()};for(const m of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(m,i,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const t=document.createElement("div");t.className="hfp-shader-loader-mark",t.draggable=!1,t.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");const s=document.createElement("div");s.className="hfp-shader-loader-title";const n=document.createElement("span");n.className="hfp-shader-loader-title-text",n.textContent=W[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=m=>{const w=document.createElement("div");w.className="hfp-shader-loader-row";const _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=m;const b=document.createElement("span");return b.className="hfp-shader-loader-value",w.appendChild(_),w.appendChild(b),p.appendChild(w),{row:w,label:_,value:b}},g=u("transition"),f=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:g.value,transitionRow:g.row,frameLabel:f.label,frameValue:f.value,frameRow:f.row}}const bt=420;function H(r,i,e){i.textContent=e,r.style.visibility=e?"visible":"hidden"}class vt{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)",H(this._el.transitionRow,this._el.transitionValue,""),H(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(W.length-1,Math.floor(o*W.length));this._el.title.textContent=W[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",H(this._el.transitionRow,this._el.transitionValue,c),H(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()},bt)}}const wt=.1,At=5,B="sandbox-origin",Ee=1e4,G=8e3,Y="assets-loading",L="assets-loading-ui",X="low-power-idle",Ce="disable-click-to-play",Tt=150;function Z(r){return!Number.isFinite(r)||r<=0?1:Math.max(wt,Math.min(At,r))}class Et 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);this.shadow=this.attachShadow({mode:"open"}),Ge(this.shadow,Ue),{container:this.container,iframe:this.iframe}=Ye(),this.shadow.appendChild(this.container);const e=yt();this.shadow.appendChild(e.root),this.shaderLoader=new vt(e),this._media=new st({dispatchEvent:t=>this._emit(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Ke({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:()=>{this.seek(0),this.play()},onPaused:()=>{var t;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(t=this.controlsApi)==null||t.updatePlaying(!1),this._emit(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new He(this.iframe,{onReady:t=>this._onProbeReady(t),onError:t=>this._emit(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{this.disableClickToPlay||Be(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",B,K,S,M,L,X]}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=ve(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=F(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&(this.iframe.src=N(this,this.getAttribute("src"))),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this._connected=!1,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._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),this.iframe.src=N(this,s));break;case"srcdoc":if(!this.isConnected)break;this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),s!==null?this.iframe.srcdoc=F(this,s):this.iframe.removeAttribute("srcdoc");break;case B:this._applySandboxOriginPolicy(this.isConnected&&t!==s);break;case"width":this._setCompositionSize(V(s)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,V(s)??1080);break;case"controls":s!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=ve(this.shadow,s,this.posterEl);break;case"playback-rate":{const u=Z(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._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 L:s==="none"&&this.shaderLoader.hideAssetsLoading();break;case X:this._sendControl("set-idle-heartbeat",{slow:s!==null});break;case S:case M:case K:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(B)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){this._abandonComposition("Sandbox policy changed before runtime data was applied");const e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=F(this,e);return}const t=this.getAttribute("src");this.iframe.src=t===null?"about:blank":N(this,t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){var s,n;if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,(s=this.posterEl)==null||s.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const e=this._tryDirectTimelinePlay();let t=!1;e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,t=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),(n=this.controlsApi)==null||n.updatePlaying(!0),t||this._emit(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){var e;this._pendingPlay=!1,this._tryDirectTimelinePause()||this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1),this._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 Z(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(Z(e)))}get shaderCaptureScale(){return _t(this)}set shaderCaptureScale(e){this.setAttribute(S,String(e))}get shaderLoading(){return z(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(M):this.setAttribute(M,e)}get assetsLoadingUi(){return this.getAttribute(L)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(L,"none"):this.removeAttribute(L)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_isLockedHostEnvironment(){if(typeof navigator>"u")return!1;const e=navigator.userAgent||"";return/\bClaude\/\d/.test(e)&&/\bElectron\b/.test(e)}_isAudioLocked(){return this.hasAttribute("audio-locked")||this._isLockedHostEnvironment()}_isSlideshowPlayer(){return this.closest("hyperframes-slideshow")!==null}_handleMutedChange(e){var t;if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(t=this.controlsApi)==null||t.updateMuted(e!==null),this._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(Ce)}set disableClickToPlay(e){this.toggleAttribute(Ce,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_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 ${Ee}ms`)},Ee);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"))v(s)&&(s.muted=e||s.defaultMuted)}_stopIframeMedia(){const e=this._getSameOriginIframeDocument();if(e)for(const t of e.querySelectorAll("video, audio"))v(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(X)})}_reloadShaderOptions(){if(this._abandonComposition("Shader options changed before runtime data was applied"),this.hasAttribute("srcdoc")){this.iframe.srcdoc=F(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&(this.iframe.src=N(this,this.getAttribute("src")||""))}_trySyncSeek(e){try{const t=this.iframe.contentWindow,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){var n;const t=this.probe.resolveDirectTimelineAdapter(),s=t||this._directTimelineAdapter;if(!s)return!1;try{if(e(s),t&&t!==this._directTimelineAdapter){const o=t.duration();Number.isFinite(o)&&o>0&&(this._setDuration(o),(n=this.controlsApi)==null||n.updateTime(this._currentTime,o))}return 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())}_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._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){lt(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:t,duration:s,paused:n,lastUpdateMs:o})=>{this._currentTime=t,this._setDuration(s),this._paused=n,this._lastUpdateMs=o},getShaderLoadingMode:()=>z(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._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},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,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),G)):this._settleAssetsReady(s);return}Pe(e,({timedOut:n})=>{s===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(s))},{timeoutMs:G}),this._assetsReady||this._startAssetsLoadingOverlayTimer(s)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(Y,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},Tt)}_hasPendingFirstFrameAssets(e){const{pendingMedia:t,pendingImages:s,fontsLoading:n}=fe(e,{scope:_e});return t.length>0||s.length>0||n}_warnStuckAssets(e){const{pendingMedia:t,pendingImages:s,fontsLoading:n}=fe(e,{scope:_e}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${G}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(Y),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._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){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(Y),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()}_setDuration(e){e!==this._duration&&(this._duration=e,this._ready&&this._emit(new CustomEvent("durationchange",{detail:{duration:e}})))}_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(){!Xe(this,this.iframe,this._compositionWidth,this._compositionHeight)&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready — zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){if(!this._connected)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=qe(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",Et);export{Et as HyperframesPlayer,ze as SPEED_PRESETS,j as formatSpeed,be as formatTime};
@@ -1 +1 @@
1
- import{g as P}from"./index-BYhK_KMc.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={},w;function k(){if(w)return v;w=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 g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,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,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
1
+ import{g as P}from"./index-ClLdmgua.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={},w;function k(){if(w)return v;w=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 g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,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,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
@@ -1,4 +1,4 @@
1
- import{n as Qi}from"./index-BYhK_KMc.js";/*!
1
+ import{n as Qi}from"./index-ClLdmgua.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