@hyperframes/player 0.8.223 → 0.8.224

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
- "use strict";var $e=Object.defineProperty;var li=Object.getOwnPropertyDescriptor;var ui=Object.getOwnPropertyNames;var di=Object.prototype.hasOwnProperty;var ci=(n,e)=>{for(var t in e)$e(n,t,{get:e[t],enumerable:!0})},mi=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ui(e))!di.call(n,r)&&r!==t&&$e(n,r,{get:()=>e[r],enumerable:!(i=li(e,r))||i.enumerable});return n};var pi=n=>mi($e({},"__esModule",{value:!0}),n);var ao={};ci(ao,{HyperframesPlayer:()=>Be,SPEED_PRESETS:()=>ut,formatSpeed:()=>W,formatTime:()=>Ie});module.exports=pi(ao);var Pt=n=>n!==null&&Number.isFinite(n)&&n>0;function Ge(n){let e=n.clipEndsSeconds.filter(i=>i===null).length;if(Pt(n.authoredDurationSeconds))return{seconds:n.authoredDurationSeconds,source:"authored",pendingClips:e};let t=n.clipEndsSeconds.filter(Pt);return t.length>0?{seconds:Math.max(...t),source:"derived",pendingClips:e}:{seconds:null,source:"unresolved",pendingClips:e,reason:e>0?"every clip's length is still pending":"no authored duration and no clip with a length"}}var fi="http://www.w3.org/1999/xhtml";function Lt(n){return n!=null&&n.nodeType===1}function ze(n){return Lt(n)&&n.namespaceURI===fi}function je(n,e){return ze(n)&&n.localName===e}function hi(n){return je(n,"video")}function bi(n){return je(n,"audio")}function P(n){return hi(n)||bi(n)}function Nt(n){return je(n,"img")}function Se(n){if(n==null||n.trim()==="")return null;let e=Number.parseInt(n,10);return Number.isFinite(e)&&e>0?e:null}function Q(n=document){let e=n.querySelector('[data-composition-id][data-root="true"]');return ze(e)?e:n.querySelector("[data-composition-id]")}var G=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),po=Object.freeze([G.start,G.duration,G.trackIndex]),fo=Object.freeze([G.derivedEnd]),ho=Object.freeze([G.derivedEnd,G.legacyTrack]);function qe(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var Ot=n=>{let e=qe(n);return e!==null&&e>=0?e:null};function Ae(n){return Ot(n("data-playback-start"))??Ot(n("data-media-start"))??0}var ee=.1,te=10;function Ye(n){return Number.isFinite(n)&&n>0?Math.max(ee,Math.min(te,n)):1}function Ft(n,e=1){let t=Number.parseFloat(n("data-playback-rate")??"");return Ye(Number.isFinite(t)&&t>0?t:e)}function Xe(n){let e=qe(n("data-duration"));return e!==null&&e>0?e:null}function Ut(n,e){let t=Xe(n);if(t!==null)return t;let i=qe(n("data-end"));return i!==null?i-e:null}var gi=3;function Ke(n,e,t){return Number.isFinite(n)?Math.max(0,n-e)/Ye(t):null}function Ze(n){let{tag:e,authoredDurationSeconds:t,sourceDurationSeconds:i,mediaStartSeconds:r,playbackRate:o}=n;if(t!==null&&t>0)return{seconds:t,source:"authored"};if(e==="img")return{seconds:gi,source:"default"};if(i===null)return{seconds:null,source:"pending",reason:"source duration not yet probed"};let a=Ke(i,r,o);return a===null?{seconds:null,source:"pending",reason:"source reported a non-finite duration"}:{seconds:a,source:"media"}}var _i="data-fx-chain",go=_i.slice(5);var ne=(n="frequency",e="Frequency",t=1e3,i=20,r=2e4)=>({kind:"number",key:n,label:e,unit:"Hz",min:i,max:r,step:1,default:t,scale:"log",automatable:!0}),Je=(n=.707,e="Bandwidth: higher is narrower.")=>({kind:"number",key:"q",label:"Q",unit:"",min:.1,max:20,step:.01,default:n,scale:"log",automatable:!0,hint:e}),Ee=(n=-40,e=40,t=0)=>({kind:"number",key:"gain",label:"Gain",unit:"dB",min:n,max:e,step:.1,default:t,automatable:!0}),Ht={kind:"enum",key:"poles",label:"Slope",options:[{value:"1",label:"6 dB/oct"},{value:"2",label:"12 dB/oct"}],default:"2",hint:"Two poles is the usual biquad; one pole is gentler."},Vt=[{id:"gain",label:"Gain",group:"dynamics",description:"Raise or lower the whole signal. Automate it to duck under something else.",params:[Ee(-60,12,0)],web:"gain-node"},{id:"peaking",label:"Peaking EQ",group:"filter",description:"Boost or cut a band, leaving everything either side alone.",params:[ne("frequency","Frequency",1e3),Ee(-40,40,0),Je(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[ne("frequency","Frequency",200,20,2e3),Ee(-40,40,0)],web:"biquad-lowshelf"},{id:"highshelf",label:"High Shelf",group:"filter",description:"Lift or drop everything above the corner frequency.",params:[ne("frequency","Frequency",4e3,500,2e4),Ee(-40,40,0)],web:"biquad-highshelf"},{id:"highpass",label:"High-pass",group:"filter",description:"Remove low frequencies: the usual fix for rumble on a voice.",params:[ne("frequency","Cutoff",300,20,2e4),Je(.707),Ht],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies, which darkens or muffles a track.",params:[ne("frequency","Cutoff",8e3,100,2e4),Je(.707),Ht],web:"biquad-lowpass"},{id:"compressor",label:"Compressor",group:"dynamics",description:"Pull loud parts down so the quiet ones can come up.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-60,max:0,step:.5,default:-24,hint:"Level above which the compressor starts working."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:4},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:2e3,step:.1,default:20,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:250,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83,hint:"1 is a hard corner; higher eases into it."},{kind:"number",key:"makeup",label:"Makeup",unit:"dB",min:0,max:36,step:.1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1,hint:"Below 1 blends the dry signal back in."}],web:"worklet-compressor"},{id:"limiter",label:"Limiter",group:"dynamics",description:"Peak limiter that follows the signal's level. It has no lookahead, so a fast peak or an inter-sample peak can pass the ceiling; use the true-peak limiter for a delivery limit.",params:[{kind:"number",key:"limit",label:"Ceiling",unit:"dB",min:-24,max:0,step:.1,default:-1},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.1,max:80,step:.1,default:5},{kind:"number",key:"release",label:"Release",unit:"ms",min:1,max:8e3,step:1,default:50,scale:"log"},{kind:"number",key:"level_out",label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0}],web:"worklet-limiter"},{id:"truepeak",label:"True-peak limiter",group:"dynamics",description:"Lookahead limiter that holds a 4x estimate of the inter-sample peak at a dBTP ceiling; full-band noise can land up to about 1.7 dB above it. Adds lookahead plus about 0.3 ms of latency.",params:[{kind:"number",key:"ceiling",label:"Ceiling",unit:"dBTP",min:-24,max:0,step:.1,default:-1,hint:"Target true peak, measured on a 4x oversampled signal. Dense full-band sound can end up to about 1.7 dB above it."},{kind:"number",key:"lookahead",label:"Lookahead",unit:"ms",min:.5,max:10,step:.1,default:3,hint:"How far ahead the gain starts falling. Longer is smoother and adds the same latency."},{kind:"number",key:"release",label:"Release",unit:"ms",min:10,max:2e3,step:1,default:80,scale:"log"}],web:"worklet-truepeak"},{id:"gate",label:"Noise Gate",group:"dynamics",description:"Silence the track when it drops below the threshold.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-80,max:0,step:.5,default:-35},{kind:"number",key:"range",label:"Range",unit:"dB",min:-80,max:0,step:.5,default:-24,hint:"How far down the gate pulls when closed."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:10},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:9e3,step:.1,default:1,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:100,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83}],web:"worklet-gate"},{id:"saturate",label:"Saturation",group:"nonlinear",description:"Soft-clip the waveform for warmth or outright distortion.",params:[{kind:"enum",key:"type",label:"Curve",options:[{value:"tanh",label:"Tanh"},{value:"atan",label:"Arctan"},{value:"cubic",label:"Cubic"},{value:"exp",label:"Exponential"},{value:"alg",label:"Algebraic"},{value:"quintic",label:"Quintic"},{value:"sin",label:"Sine"},{value:"erf",label:"Error function"},{value:"hard",label:"Hard clip"}],default:"tanh"},{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-40,max:0,step:.1,default:-6},{kind:"number",key:"output",automatable:!0,label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0},{kind:"number",key:"oversample",label:"Oversample",unit:"x",min:1,max:8,step:1,default:4,hint:"Higher costs more but keeps aliasing down."}],web:"waveshaper"},{id:"bitcrush",label:"Bitcrush",group:"nonlinear",description:"Drop bit depth and sample rate for a lo-fi, digital sound.",params:[{kind:"number",key:"bits",label:"Bit depth",unit:"bit",min:1,max:32,step:.1,default:8},{kind:"number",key:"samples",label:"Sample hold",unit:"x",min:1,max:250,step:1,default:1,hint:"Repeats each sample N times, a crude downsample."},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-bitcrush"},{id:"pitchshift",label:"Pitch shift",group:"time",description:"Shifts pitch up or down without changing playback speed. Adds ~50 ms of latency.",params:[{kind:"number",key:"semitones",label:"Semitones",unit:"st",min:-12,max:12,step:1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-pitchshift"},{id:"delay",label:"Delay",group:"time",description:"Repeating echoes behind the dry signal.",params:[{kind:"number",key:"time",automatable:!0,label:"Time",unit:"ms",min:1,max:5e3,step:1,default:250,scale:"log"},{kind:"number",key:"feedback",automatable:!0,label:"Feedback",unit:"",min:.01,max:.95,step:.01,default:.35},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.4}],web:"delay-feedback"},{id:"chorus",label:"Chorus",group:"time",description:"Detuned copies of the signal for width and thickness.",params:[{kind:"number",key:"delay",automatable:!0,label:"Delay",unit:"ms",min:1,max:100,step:.1,default:7},{kind:"number",key:"depth",automatable:!0,label:"Depth",unit:"ms",min:0,max:10,step:.01,default:2},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.01,max:10,step:.01,default:1},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.5}],web:"chorus-lfo"},{id:"phaser",label:"Phaser",group:"time",description:"Sweeping notches moving through the spectrum.",params:[{kind:"number",key:"in_gain",automatable:!0,label:"Input",unit:"",min:0,max:1,step:.01,default:.4},{kind:"number",key:"out_gain",automatable:!0,label:"Output",unit:"",min:0,max:2,step:.01,default:.74},{kind:"number",key:"delay",label:"Delay",unit:"ms",min:.1,max:5,step:.1,default:3},{kind:"number",key:"decay",label:"Decay",unit:"",min:0,max:.99,step:.01,default:.4},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.1,max:2,step:.01,default:.5},{kind:"enum",key:"type",label:"Waveform",options:[{value:"0",label:"Triangular"},{value:"1",label:"Sinusoidal"}],default:"0"}],web:"allpass-phaser"},{id:"reverb",label:"Reverb",group:"time",description:"Room tail. Both ends convolve the same generated impulse, so preview matches render.",params:[{kind:"number",key:"size",label:"Room size",unit:"",min:.05,max:1,step:.01,default:.7},{kind:"number",key:"damping",label:"Damping",unit:"",min:0,max:1,step:.01,default:.5,hint:"Higher rolls the top off the tail faster."},{kind:"number",key:"wet",automatable:!0,label:"Wet",unit:"",min:0,max:1,step:.01,default:.35},{kind:"number",key:"dry",automatable:!0,label:"Dry",unit:"",min:0,max:1,step:.01,default:.7}],web:"convolver"}],_o=new Map(Vt.map(n=>[n.id,n]));var yo=Vt.map(n=>n.id);function yi(n){return 10**(n/20)}var Wt=yi(12);var Bt="data-automation",Co=Bt.slice(5),Qe=1,vi=512,L=class extends Error{constructor(e){super(e),this.name="AudioAutomationError"}},Te="volume",Re="rate";function $t(n){if(n===Te)return{kind:"volume"};if(n===Re)return{kind:"rate"};let e=n.split(".");if(e.length===3&&e[0]==="fx"&&e[1]===Si){let r=e[2];return r?{kind:"preset",presetId:r}:null}if(e.length!==3||e[0]!=="fx")return null;let[,t,i]=e;return!t||!i?null:{kind:"fx",nodeId:t,param:i}}var Si="preset";var Ai={min:0,max:Wt,step:.01,unit:"",label:"Volume",scale:"linear",default:1};var Ei={min:ee,max:te,step:.05,unit:"x",label:"Speed",scale:"log",default:1};function ie(n){if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"&&n.trim()!==""){let e=Number(n);return Number.isFinite(e)?e:null}return null}function Ti(n){let e=ie(n);return e===null||e===0?0:Math.min(1,Math.max(-1,e))}function Gt(n,e){let t=ie(n),i=ie(e);if(t===null||i===null)return null;let r=s=>Math.min(.999,Math.max(.001,s)),o=r(t),a=r(i);return Math.abs(o-a)<1e-6?null:{x:o,y:a}}function Ri(n){let e=Ti(n?.curve),t=Gt(n?.viaX,n?.viaY);return{...e?{curve:e}:{},...t?{viaX:t.x,viaY:t.y}:{}}}function xi(n,e){let t=ie(n?.t),i=ie(n?.v);if(t===null||i===null)return null;let r=e?Math.min(e.max,Math.max(e.min,i)):i;return{t:Math.max(0,t),v:r,...Ri(n)}}function wi(n,e){let t=n.map(r=>xi(r,e)).filter(r=>r!==null).sort((r,o)=>r.t-o.t),i=[];for(let r of t)i.length>0&&i[i.length-1].t===r.t?i[i.length-1]=r:i.push(r);return i.slice(0,vi)}function ki(n){let e=[];for(let t of n.lanes){if(!$t(t.target))continue;let i=t.target===Te?Ai:t.target===Re?Ei:null,r=wi(t.points??[],i);r.length>0&&e.push({target:t.target,points:r})}return{version:Qe,lanes:e}}function zt(n){let e;try{e=JSON.parse(n)}catch(r){throw new L(`Automation is not valid JSON: ${r.message}`)}if(typeof e!="object"||e===null)throw new L("Automation must be a JSON object.");let t=e;if(t.version!==Qe)throw new L(`Unsupported automation version: ${String(t.version)}`);if(!Array.isArray(t.lanes))throw new L("Automation is missing a `lanes` array.");let i=t.lanes.map((r,o)=>{if(typeof r!="object"||r===null)throw new L(`Lane ${o} is not an object.`);let a=r;if(typeof a.target!="string"||!$t(a.target))throw new L(`Lane ${o} has an unreadable target: ${String(a.target)}`);if(!Array.isArray(a.points))throw new L(`Lane ${o} is missing a \`points\` array.`);return{target:a.target,points:a.points}});return ki({version:Qe,lanes:i})}function Mi(n,e){return e?Math.pow(n,Math.pow(2,2*e)):n}function Ci(n,e){let t=n-.5,i=e-.5,r=.999,o=1e6,a=t>0?t/(r-n):t<0?-t/(n-(1-r)):0,s=i>0?i/(r-e):i<0?-i/(e-(1-r)):0,l=Math.min(o,Math.max(1,a,s));return{cx:n+t/l,cy:e+i/l,w:l}}function Ii(n,e,t){let{cx:i,cy:r,w:o}=Ci(e,t),a=2-2*o,s=n*a-1+2*o*i,l=-n*a-2*o*i,u=Di(s,l,n),c=1-u,h=c*c+2*o*u*c+u*u;return h>0?(2*o*r*u*c+u*u)/h:n}function Di(n,e,t){if(Math.abs(n)<1e-12)return Math.abs(e)<1e-12?t:-t/e;let i=Math.sqrt(Math.max(0,e*e-4*n*t)),r=(-e+i)/(2*n),o=(-e-i)/(2*n),a=s=>s>=-1e-9&&s<=1+1e-9;return a(r)?Math.min(1,Math.max(0,r)):a(o)?Math.min(1,Math.max(0,o)):t}function Pi(n,e){let t=Gt(e.viaX,e.viaY);return t?Ii(Math.min(1,Math.max(0,n)),t.x,t.y):Mi(n,e.curve)}function Li(n,e,t,i){return i==="log"&&n>0&&e>0?Math.exp(Math.log(n)+(Math.log(e)-Math.log(n))*t):n+(e-n)*t}function xe(n,e,t="linear"){let i=n.points;if(i.length===0)return 0;let r=i[0];if(e<=r.t)return r.v;let o=i[i.length-1];if(e>=o.t)return o.v;let a=0,s=i.length-1;for(;s-a>1;){let h=a+s>>1;i[h].t<=e?a=h:s=h}let l=i[a],u=i[s],c=u.t-l.t;return c<=0?u.v:Li(l.v,u.v,Pi((e-l.t)/c,l),t)}var we=new Map,Ni=64;function jt(n,e=Te){let t=`${e}\0${n}`,i=we.get(t);if(i!==void 0)return i;let r=null;try{r=zt(n).lanes.find(o=>o.target===e)??null}catch{r=null}return we.size>Ni&&we.clear(),we.set(t,r),r}var qt=48,Yt=new WeakMap;function Oi(n){let e=n.points,t=e[0].v,i=e[e.length-1].v,r=[0],o=[0],a=l=>{let u=r[r.length-1];if(l<=u)return;let c=xe(n,u,"log");r.push(l),o.push(o[o.length-1]+(c+xe(n,l,"log"))/2*(l-u))},s=Math.max(0,e[0].t);a(s);for(let l=1;l<e.length;l+=1){let u=e[l-1].t,c=e[l].t;if(!(c<=0))for(let h=1;h<=qt;h+=1)a(Math.max(u,0)+(c-u)*h/qt)}return{ts:Float64Array.from(r),ss:Float64Array.from(o),firstRate:t,lastRate:i}}function Fi(n){let e=Yt.get(n);return e||(e=Oi(n),Yt.set(n,e)),e}function Ui(n){return typeof n!="number"&&n.points.length>0}function Hi(n,e,t){let i=0,r=n.length-1;for(;r-i>1;){let o=i+r>>1;n[o]<=t?i=o:r=o}return e[i]+(e[r]-e[i])*(t-n[i])/(n[r]-n[i])}function Xt(n,e){if(typeof n=="number")return e/n;if(!Ui(n))return e;let{ts:t,ss:i,firstRate:r,lastRate:o}=Fi(n),a=t.length-1;return e<=0?e/r:e>=i[a]?t[a]+(e-i[a])/o:Hi(i,t,e)}function Vi(n){return n?jt(n,Re):null}function Kt(n,e){return Vi(n)??e}var Fo=[{id:"montage",label:"Montage",points:[[0,.9],[.15,.3],[.5,2.5],[.85,.3],[1,.9]]},{id:"hero",label:"Hero",points:[[0,1],[.25,1.6],[.5,.25],[.75,1.6],[1,1]]},{id:"bullet",label:"Bullet",points:[[0,3],[.4,3],[.5,.15],[.6,3],[1,3]]},{id:"jump-cut",label:"Jump cut",points:[[0,.5],[.24,.5],[.26,3],[.5,3],[.52,.5],[.74,.5],[.76,3],[1,3]]},{id:"flash-in",label:"Flash in",points:[[0,.3],[.6,.6],[1,5]]},{id:"flash-out",label:"Flash out",points:[[0,5],[.4,.6],[1,.3]]},{id:"ramp-in",label:"Ramp in",points:[[0,.5],[1,1]]},{id:"ramp-out",label:"Ramp out",points:[[0,1],[1,.5]]},{id:"slowmo-middle",label:"Slow-mo middle",points:[[0,1],[1/3,.35],[2/3,.35],[1,1]]}];var y=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),Ho=Object.freeze([y.start,y.duration,y.trackIndex]),Vo=Object.freeze([y.derivedEnd]),Wo=Object.freeze([y.derivedEnd,y.legacyTrack]);function N(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var Qt=/^[A-Za-z0-9_.:-]+$/;function en(n,e){let t=n.charCodeAt(e);return t>=48&&t<=57}function Zt(n,e){let t=e;for(;t>=0&&en(n,t);)t--;return t}function Wi(n,e){let t=e;for(;t>=0&&(n[t]??"").trim()==="";)t--;return t}function Bi(n){let e=n.length-1;if(!en(n,e))return null;let t=Zt(n,e);return n[t]==="."&&(t=Zt(n,t-1)),t+1}function $i(n){let e=Bi(n);if(e==null)return null;let t=Wi(n,e-1),i=n[t];if(i!=="+"&&i!=="-")return null;let r=n.slice(0,t).trim();if(!Qt.test(r))return null;let o=Number(n.slice(e));return Number.isFinite(o)?{refId:r,operator:i,magnitude:o}:null}function re(n){let e=(n??"").trim();if(!e)return null;let t=N(e);if(t!=null)return{kind:"absolute",value:t};if(Qt.test(e))return{kind:"reference",refId:e,offset:0};let i=$i(e);return i?{kind:"reference",refId:i.refId,offset:i.operator==="-"?-i.magnitude:i.magnitude}:null}function x(n,e,t,i){n.push({code:e,attribute:t,value:i})}function Gi(n,e,t,i){if(e==null||e.trim()==="")return t.defaultStart===void 0?0:t.defaultStart;if(!n)return x(i,"invalid-start",y.start,e),null;if(n.kind==="absolute")return Math.max(0,n.value);let r=t.resolveReferenceEnd?.(n.refId);return r==null||!Number.isFinite(r)?(x(i,"unresolved-start-reference",y.start,e),null):Math.max(0,r+n.offset)}var zi=1e-9;function ji(n,e){return Math.abs(n-e)<=zi}function qi(n,e,t){let i=N(n);if(i==null){x(t,"deprecated-end",y.derivedEnd,n),x(t,"invalid-end",y.derivedEnd,n);return}if(e==null){x(t,"deprecated-end",y.derivedEnd,n);return}ji(i,e)||(x(t,"deprecated-end",y.derivedEnd,n),x(t,"conflicting-end",y.derivedEnd,n))}function Yi(n,e,t){let i=N(n);return i==null||i<0?(x(t,"invalid-duration",y.duration,n),{duration:null,end:null,durationSource:"invalid"}):{duration:i,end:e==null?null:e+i,durationSource:"duration"}}function Xi(n,e,t){x(t,"deprecated-end",y.derivedEnd,n);let i=N(n);return i==null?(x(t,"invalid-end",y.derivedEnd,n),{duration:null,end:null,durationSource:"invalid"}):e==null?{duration:null,end:i,durationSource:"legacy-end"}:i<e?(x(t,"end-before-start",y.derivedEnd,n),{duration:null,end:null,durationSource:"invalid"}):{duration:i-e,end:i,durationSource:"legacy-end"}}function Ki(n,e,t){let i=n.getAttribute(y.duration),r=n.getAttribute(y.derivedEnd);if(i==null)return r==null?{duration:null,end:null,durationSource:"missing"}:Xi(r,e,t);let o=Yi(i,e,t);return r!=null&&qi(r,o.end,t),o}function Jt(n,e,t,i){let r=N(n);return r==null||!Number.isInteger(r)?(x(i,"invalid-track-index",e,n),{trackIndex:0,trackSource:"invalid"}):{trackIndex:r,trackSource:t}}function Zi(n,e){let t=n.getAttribute(y.trackIndex),i=n.getAttribute(y.legacyTrack);if(t==null&&i==null)return{trackIndex:0,trackSource:"default"};if(t==null&&i!=null)return x(e,"deprecated-layer",y.legacyTrack,i),Jt(i,y.legacyTrack,"legacy-layer",e);let r=Jt(t??"",y.trackIndex,"track-index",e);if(i==null)return r;x(e,"deprecated-layer",y.legacyTrack,i);let o=N(i);return o!=null&&o!==r.trackIndex&&x(e,"conflicting-layer",y.legacyTrack,i),r}function et(n,e={}){let t=[],i=n.getAttribute(y.start),r=re(i),o=Gi(r,i,e,t),a=Ki(n,o,t),s=Zi(n,t);return{startExpression:r,start:o,...a,...s,diagnostics:t}}function V(n){return N(n)}function tt(n){return Ft(e=>n.getAttribute(e),P(n)?n.defaultPlaybackRate:1)}function Ji(n){return Kt(n.getAttribute("data-automation"),tt(n))}function nt(n){return Ae(e=>n.getAttribute(e))}function oe(n,e){return Qi(e,nt(n),Ji(n))}function it(n){let e=Ze({tag:"video",authoredDurationSeconds:Xe(t=>n.getAttribute(t)),sourceDurationSeconds:Number.isFinite(n.duration)?n.duration:null,mediaStartSeconds:nt(n),playbackRate:tt(n)});return e.source==="media"?oe(n,n.duration):e.seconds}function ke(n,e=0){return!Nt(n)||!n.hasAttribute("data-start")&&!n.hasAttribute("data-track-index")?null:Ze({tag:"img",authoredDurationSeconds:Ut(t=>n.getAttribute(t),e),sourceDurationSeconds:null,mediaStartSeconds:0,playbackRate:1}).seconds}function Qi(n,e,t){return typeof t=="number"?Ke(n,e,t):Number.isFinite(n)?Xt(t,Math.max(0,n-e)):null}function tn(){return globalThis}function rt(n,e){if(typeof window>"u")return;let t=tn(),i=t.__hf?.onSwallowed;if(i)try{i({label:n,error:e})}catch(r){}(t.__hfDebug||t.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${n} swallowed:`,e)}var er=n=>n.paused?.()===!0?(n.startTime?.()??0)+(n.totalDuration?.()??0)/Math.abs(n.timeScale?.()||1):0;function ae(n){try{if(typeof n?.duration!="function")return null;let e=n.getChildren?.(!1,!1,!0),t=Array.isArray(e)?e:[],i=Math.max(Number(n.duration()),...t.map(er));return Number.isFinite(i)?i:null}catch(e){return rt("runtime.timelineDuration",e),null}}var nn="data-hf-authored-duration",rn="data-hf-authored-end";function se(n){if(n==null||typeof n=="string"&&n.trim()==="")return null;let e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:null}function Me(n){let e=se(n.start);if(e==null)return null;let t=Math.max(0,e),i=se(n.duration),r=se(n.authoredDuration),o=i!=null&&i>0?i:r!=null&&r>0?r:null;if(o!=null)return{start:t,duration:o,end:t+o};let a=se(n.end),s=se(n.authoredEnd),l=a!=null&&a>t?a:s!=null&&s>t?s:null;return{start:t,duration:l==null?null:l-t,end:l}}var z=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),na=Object.freeze([z.start,z.duration,z.trackIndex]),ia=Object.freeze([z.derivedEnd]),ra=Object.freeze([z.derivedEnd,z.legacyTrack]);function tr(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var on=n=>{let e=tr(n);return e!==null&&e>=0?e:null};function nr(n){return on(n("data-playback-start"))??on(n("data-media-start"))??0}var an="data-hf-media-start-basis";function sn(n){return n?.trim().toLowerCase()==="global"?"global":"local"}function ir(n){return sn(n.basis)==="global"?n.authoredStart:n.hostStart+n.authoredStart}function ln(n){return dn(n)?ir({authoredStart:n.authoredStart,hostStart:n.hostStart,basis:n.basis}):n.ordinaryStart()}function un(n){return dn(n)&&sn(n.basis)==="global"}function dn(n){return!n.hasAutoStart&&n.authoredStart!=null&&n.hostStart!==0}function ot(n){return nr(e=>n.getAttribute(e))}function cn(n,e){return n-ot(e)}function le(n){let e=n.timelineRegistry??{},t=n.includeAuthoredTimingAttrs??!1,i=n.documentRef??document,r=new WeakMap,o=new WeakMap,a=new Set,s=d=>(d.hasAttribute("data-composition-id")?d.parentElement:d)?.closest("[data-composition-id]")??null,l=(d,f)=>{let g=s(f);if(g){for(let k of g.querySelectorAll(`[id="${d}"]`))if(s(k)===g)return k}let R=i.getElementById(d);return R||(Array.from(i.querySelectorAll("[data-composition-id]")).find(k=>k.getAttribute("data-composition-id")===d)??null)},u=(d,f)=>t?d.getAttribute(f):null,c=d=>Me({start:0,duration:d.getAttribute("data-duration"),authoredDuration:u(d,"data-hf-authored-duration")})?.duration??Me({start:T(d,0),end:d.getAttribute("data-end"),authoredEnd:u(d,"data-hf-authored-end")})?.duration??null,h=d=>d!=null&&Number.isFinite(d)&&d>0?d:null,v=d=>{let f=d.getAttribute("data-composition-id");return f?h(ae(e[f])):null},b=d=>{let f=o.get(d);if(f!==void 0)return f;let g=c(d)??h(P(d)?oe(d,d.duration):null)??h(ke(d))??v(d);return o.set(d,g),g},S="[data-composition-src], [data-composition-id], [data-composition-file]",_=d=>d.matches(S),A=d=>!d.hasAttribute("data-composition-id")||re(d.getAttribute("data-start"))?null:d.parentElement?.closest(`[data-start], ${S}`)??null,C=(d,f)=>cn(T(d,f),A(d)??d),M=(d,f)=>{let g=d.hasAttribute("data-composition-id")?d.parentElement?.closest("[data-composition-id]"):d.closest("[data-composition-id]");return g?C(g,f):0},I=(d,f)=>{let g=re(d.getAttribute("data-start"));if(!g){let H=A(d);return H?T(H,f):f}if(g.kind==="absolute")return M(d,f)+Math.max(0,g.value);let R=l(g.refId,d);if(!R)return f;let k=T(R,0),ye=b(R)??0,ve=Math.min(0,M(d,0));return Math.max(ve,k+ye+g.offset)},T=(d,f)=>{let g=r.get(d);if(g!==void 0)return g??f;if(a.has(d))return f;a.add(d);try{let R=I(d,f);return r.set(d,R),R}finally{a.delete(d)}},U=d=>{let f=d.closest("[data-composition-id]");return{authoredStart:V(d.getAttribute("data-start")),hostStart:f?C(f,0):0,hasAutoStart:d.hasAttribute("data-hf-auto-start"),basis:d.getAttribute(an)}};return{resolveStartForElement:(d,f=0)=>T(d,Math.max(0,f)),resolveDurationForElement:d=>b(d),resolveMediaStartForElement:d=>{let f=U(d);return ln({...f,ordinaryStart:()=>T(d,f.hostStart)})},resolveHostStartForElement:d=>M(d,0),resolveHostSlotsForElement:d=>{let f=[];for(let g=d.parentElement;g;g=g.parentElement){if(!_(g)||A(g)||ot(g)<=0)continue;let R=T(g,0),k=c(g);f.push({start:R,end:k?R+k:1/0})}return f},isRootGlobalMediaStartForElement:d=>P(d)&&un(U(d))}}function mn(){return{capturedTimeline:null,isPlaying:!1,currentTime:0,deterministicAdapters:[],canonicalFps:30,bridgeMuted:!1,bridgeVolume:1,mediaOutputMuted:!1,nativeMediaSyncDisabled:!1,webAudioMediaDisabled:!1,mediaAutoplayBlockedPosted:!1,mediaForceSyncNextTick:!1,playbackRate:1,bridgeLastPostedFrame:-1,bridgeLastPostedAt:0,bridgeLastPostedPlaying:!1,bridgeLastPostedMuted:!1,bridgeMaxPostIntervalMs:80,controlBridgeHandler:null,beforeUnloadHandler:null,injectedCompStyles:[],injectedCompScripts:[],injectedCompLinks:[],cachedTimedMediaEls:[],cachedMediaClips:[],cachedVideoClips:[],cachedMediaTimelineDurationSeconds:0,tornDown:!1,transportClock:null,transportRafId:null}}var pn=7200,at=1/60,ue=n=>n!==null&&n>at?n:null;function rr(n){return{width:Se(n.getAttribute("data-width")),height:Se(n.getAttribute("data-height"))}}function or(n,e){let t=null;for(let i of n.querySelectorAll("video[data-start], audio[data-start]")){let r=e.mediaStart(i);if(!Number.isFinite(r))continue;let o=e.mediaDuration(i);if(o==null||o<=at)continue;let a=Math.max(0,r)+o;(!t||a>t.seconds)&&(t={seconds:a,element:i})}return t&&ue(t.seconds)!==null?t:null}function ar(n,e){return or(n,e)?.seconds??null}function sr(n,e){let t=[];for(let r of n.querySelectorAll("[data-composition-id][data-start]")){if(r.parentElement?.closest("[data-composition-id]")!==n)continue;let o=e.resolveStartForElement(r,0),a=e.resolveDurationForElement(r);!Number.isFinite(o)||a==null||a<=0||t.push(Math.max(0,o)+a)}let i=V(n.getAttribute("data-duration"));return ue(Ge({authoredDurationSeconds:null,clipEndsSeconds:[i,...t]}).seconds)}var lr=n=>n.hasAttribute("data-composition-id")||n.hasAttribute("data-composition-src");function ur(n,e,{unregisteredLottie:t}){let i=[];for(let o of n.querySelectorAll("[data-start]")){let a=e.resolveStartForElement(o,0);if(!Number.isFinite(a))continue;let s=e.resolveDurationForElement(o);s!=null?i.push(Math.max(0,a)+s):(P(o)||lr(o))&&i.push(null)}(t||n.querySelector("[data-lottie-src]"))&&i.push(null);let r=Ge({authoredDurationSeconds:null,clipEndsSeconds:i});return r.pendingClips>0?{...r,seconds:null,source:"unresolved",reason:"a clip's length is pending"}:r}function dr(n){return cr(n).seconds}function cr(n){if(n.declared!==null&&Number.isFinite(n.declared)&&n.declared>0)return{seconds:n.declared,from:"declared",floorIndex:null};let e=ue(n.timeline()),t=n.floors().map(h=>h??0),i=Math.max(0,...t),r=Number.isFinite(n.fallback)&&n.fallback>at?n.fallback:0,o=Math.max(i,r),s=e!==null&&e>=pn&&ue(o)!==null?null:e,l=i>=r,u=h=>({seconds:h,from:l?"floor":"fallback",floorIndex:l?t.indexOf(i):null});if(s!==null)return s>=o?{seconds:s,from:"timeline",floorIndex:null}:u(o);if(ue(i)!==null)return u(o);if(r>0)return{seconds:r,from:"fallback",floorIndex:null};let c=n.derived();return{seconds:c>0?c:0,from:"derived",floorIndex:null}}function fn(n){let e=Q(n);if(!e)return null;let t=le({timelineRegistry:{},includeAuthoredTimingAttrs:!0,documentRef:n}),i=dr({declared:V(e.getAttribute("data-duration")),timeline:()=>null,floors:()=>[ar(n,{mediaStart:t.resolveMediaStartForElement,mediaDuration:it}),sr(e,t)],fallback:0,derived:()=>ur(e,t,{unregisteredLottie:!1}).seconds??0});return{...rr(e),fps:mn().canonicalFps,durationSeconds:i}}var hn="hyperframes-studio-preview";var bn="__hfPreviewErrors";function gn(n){return n.hasRuntime||n.runtimeInjected?!1:!!(n.hasNestedCompositions||n.hasTimelines&&n.attempts>=5)}function j(n){return typeof n=="object"&&n!==null}function _n(n){return j(n)&&typeof n.getDuration=="function"}function yn(n){return j(n)&&typeof n.duration=="function"&&typeof n.time=="function"&&typeof n.seek=="function"&&typeof n.play=="function"&&typeof n.pause=="function"}var q="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.223/dist/hyperframe.runtime.iife.js";function de(n){if(n===null)return null;let e=Number.parseInt(n,10);return Number.isFinite(e)&&e>0?e:null}function mr(n){let e=n?.querySelector("[data-composition-id][data-width][data-height]")??n?.querySelector("[data-width][data-height]");if(!e)return null;let t=de(e.getAttribute("data-width")),i=de(e.getAttribute("data-height"));return t!==null&&i!==null?{width:t,height:i}:null}function pr(n){return Array.isArray(n)?n.find(e=>typeof e=="string"&&e.trim()!==""&&e!=="[object Event]")??null:null}var Ce=class{constructor(e,t){this._iframe=e;this._callbacks=t}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;_runtimeScript=null;_failure=null;get failed(){return this._failure!==null&&this._failure.document===this._iframe.contentDocument}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._failure=null,this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;let t=null;try{t=this._poll(e)}catch(i){i instanceof DOMException&&i.name==="SecurityError"||(t={kind:"error",message:i instanceof Error?i.message:String(i)})}t??=this._deadlineOutcome(e),t&&(this.stop(),t.kind==="error"?(this._failure={document:this._iframe.contentDocument},this._callbacks.onError(t.message)):this._callbacks.onReady(t.result))},200)}_deadlineOutcome(e){return e<40||this._callbacks.hostOwnsDeadline?.()?null:{kind:"error",message:"Composition timeline not found after 8s"}}_poll(e){let t=this._iframe.contentWindow;if(!t)return null;let i=pr(Reflect.get(t,bn));if(i!==null)return{kind:"error",message:i};let r=this._iframe.contentDocument,o=Reflect.get(t,"__timelines"),a=this.hasRuntimeBridge(t);if(gn({hasRuntime:a,hasTimelines:j(o)&&Object.keys(o).length>0,hasNestedCompositions:!!r?.querySelector("[data-composition-src]"),runtimeInjected:this._runtimeInjected,attempts:e}))return this._injectRuntime(),null;if(this._runtimeInjected&&!a)return null;let s=this._resolveReadyResult(t,r);return s?{kind:"ready",result:s}:null}_resolveReadyResult(e,t){let i=this._resolvePlaybackDurationAdapter(e)??{kind:"document",getDuration:()=>0},r=i.getDuration();if(!Number.isFinite(r)||r<=0){if(i.kind==="direct-timeline")return null;r=t?fn(t)?.durationSeconds??0:0}return r<=0?null:{duration:r,adapter:{...i,getDuration:()=>r},compositionSize:mr(t)}}stop(){this._runtimeScript&&(this._runtimeScript.onerror=null,this._runtimeScript=null),this.failed||(this._failure=null),this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return j(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=this._callbacks.resolveRuntimeUrl?.()??q,this._runtimeScript=t,t.onerror=()=>{this._runtimeScript!==t||this._iframe.contentDocument!==e||(this.stop(),this._failure={document:e},this._callbacks.onError("HyperFrames runtime failed to load from "+t.src))},(e.head||e.documentElement).appendChild(t),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let t=Reflect.get(e,"__timelines");if(!j(t))return null;let i=Object.keys(t);if(i.length===0)return null;let r=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=r&&r in t?r:i[i.length-1],a=t[o];return yn(a)?a:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(_n(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var vn=`
1
+ "use strict";var Ge=Object.defineProperty;var ui=Object.getOwnPropertyDescriptor;var di=Object.getOwnPropertyNames;var ci=Object.prototype.hasOwnProperty;var mi=(t,e)=>{for(var n in e)Ge(t,n,{get:e[n],enumerable:!0})},pi=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of di(e))!ci.call(t,r)&&r!==n&&Ge(t,r,{get:()=>e[r],enumerable:!(i=ui(e,r))||i.enumerable});return t};var fi=t=>pi(Ge({},"__esModule",{value:!0}),t);var so={};mi(so,{HyperframesPlayer:()=>$e,SPEED_PRESETS:()=>dt,formatSpeed:()=>W,formatTime:()=>Ie});module.exports=fi(so);var Lt=t=>t!==null&&Number.isFinite(t)&&t>0;function ze(t){let e=t.clipEndsSeconds.filter(i=>i===null).length;if(Lt(t.authoredDurationSeconds))return{seconds:t.authoredDurationSeconds,source:"authored",pendingClips:e};let n=t.clipEndsSeconds.filter(Lt);return n.length>0?{seconds:Math.max(...n),source:"derived",pendingClips:e}:{seconds:null,source:"unresolved",pendingClips:e,reason:e>0?"every clip's length is still pending":"no authored duration and no clip with a length"}}var hi="http://www.w3.org/1999/xhtml";function Nt(t){return t!=null&&t.nodeType===1}function je(t){return Nt(t)&&t.namespaceURI===hi}function qe(t,e){return je(t)&&t.localName===e}function bi(t){return qe(t,"video")}function gi(t){return qe(t,"audio")}function P(t){return bi(t)||gi(t)}function Ot(t){return qe(t,"img")}function Se(t){if(t==null||t.trim()==="")return null;let e=Number.parseInt(t,10);return Number.isFinite(e)&&e>0?e:null}function Q(t=document){let e=t.querySelector('[data-composition-id][data-root="true"]');return je(e)?e:t.querySelector("[data-composition-id]")}var G=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),fo=Object.freeze([G.start,G.duration,G.trackIndex]),ho=Object.freeze([G.derivedEnd]),bo=Object.freeze([G.derivedEnd,G.legacyTrack]);function Ye(t){if(t==null||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}var Ft=t=>{let e=Ye(t);return e!==null&&e>=0?e:null};function Ae(t){return Ft(t("data-playback-start"))??Ft(t("data-media-start"))??0}var ee=.1,te=10;function Xe(t){return Number.isFinite(t)&&t>0?Math.max(ee,Math.min(te,t)):1}function Ut(t,e=1){let n=Number.parseFloat(t("data-playback-rate")??"");return Xe(Number.isFinite(n)&&n>0?n:e)}function Ke(t){let e=Ye(t("data-duration"));return e!==null&&e>0?e:null}function Ht(t,e){let n=Ke(t);if(n!==null)return n;let i=Ye(t("data-end"));return i!==null?i-e:null}var _i=3;function Ze(t,e,n){return Number.isFinite(t)?Math.max(0,t-e)/Xe(n):null}function Je(t){let{tag:e,authoredDurationSeconds:n,sourceDurationSeconds:i,mediaStartSeconds:r,playbackRate:o}=t;if(n!==null&&n>0)return{seconds:n,source:"authored"};if(e==="img")return{seconds:_i,source:"default"};if(i===null)return{seconds:null,source:"pending",reason:"source duration not yet probed"};let a=Ze(i,r,o);return a===null?{seconds:null,source:"pending",reason:"source reported a non-finite duration"}:{seconds:a,source:"media"}}var yi="data-fx-chain",_o=yi.slice(5);var ne=(t="frequency",e="Frequency",n=1e3,i=20,r=2e4)=>({kind:"number",key:t,label:e,unit:"Hz",min:i,max:r,step:1,default:n,scale:"log",automatable:!0}),Qe=(t=.707,e="Bandwidth: higher is narrower.")=>({kind:"number",key:"q",label:"Q",unit:"",min:.1,max:20,step:.01,default:t,scale:"log",automatable:!0,hint:e}),Ee=(t=-40,e=40,n=0)=>({kind:"number",key:"gain",label:"Gain",unit:"dB",min:t,max:e,step:.1,default:n,automatable:!0}),Vt={kind:"enum",key:"poles",label:"Slope",options:[{value:"1",label:"6 dB/oct"},{value:"2",label:"12 dB/oct"}],default:"2",hint:"Two poles is the usual biquad; one pole is gentler."},Wt=[{id:"gain",label:"Gain",group:"dynamics",description:"Raise or lower the whole signal. Automate it to duck under something else.",params:[Ee(-60,12,0)],web:"gain-node"},{id:"peaking",label:"Peaking EQ",group:"filter",description:"Boost or cut a band, leaving everything either side alone.",params:[ne("frequency","Frequency",1e3),Ee(-40,40,0),Qe(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[ne("frequency","Frequency",200,20,2e3),Ee(-40,40,0)],web:"biquad-lowshelf"},{id:"highshelf",label:"High Shelf",group:"filter",description:"Lift or drop everything above the corner frequency.",params:[ne("frequency","Frequency",4e3,500,2e4),Ee(-40,40,0)],web:"biquad-highshelf"},{id:"highpass",label:"High-pass",group:"filter",description:"Remove low frequencies: the usual fix for rumble on a voice.",params:[ne("frequency","Cutoff",300,20,2e4),Qe(.707),Vt],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies, which darkens or muffles a track.",params:[ne("frequency","Cutoff",8e3,100,2e4),Qe(.707),Vt],web:"biquad-lowpass"},{id:"compressor",label:"Compressor",group:"dynamics",description:"Pull loud parts down so the quiet ones can come up.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-60,max:0,step:.5,default:-24,hint:"Level above which the compressor starts working."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:4},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:2e3,step:.1,default:20,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:250,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83,hint:"1 is a hard corner; higher eases into it."},{kind:"number",key:"makeup",label:"Makeup",unit:"dB",min:0,max:36,step:.1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1,hint:"Below 1 blends the dry signal back in."}],web:"worklet-compressor"},{id:"limiter",label:"Limiter",group:"dynamics",description:"Peak limiter that follows the signal's level. It has no lookahead, so a fast peak or an inter-sample peak can pass the ceiling; use the true-peak limiter for a delivery limit.",params:[{kind:"number",key:"limit",label:"Ceiling",unit:"dB",min:-24,max:0,step:.1,default:-1},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.1,max:80,step:.1,default:5},{kind:"number",key:"release",label:"Release",unit:"ms",min:1,max:8e3,step:1,default:50,scale:"log"},{kind:"number",key:"level_out",label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0}],web:"worklet-limiter"},{id:"truepeak",label:"True-peak limiter",group:"dynamics",description:"Lookahead limiter that holds a 4x estimate of the inter-sample peak at a dBTP ceiling; full-band noise can land up to about 1.7 dB above it. Adds lookahead plus about 0.3 ms of latency.",params:[{kind:"number",key:"ceiling",label:"Ceiling",unit:"dBTP",min:-24,max:0,step:.1,default:-1,hint:"Target true peak, measured on a 4x oversampled signal. Dense full-band sound can end up to about 1.7 dB above it."},{kind:"number",key:"lookahead",label:"Lookahead",unit:"ms",min:.5,max:10,step:.1,default:3,hint:"How far ahead the gain starts falling. Longer is smoother and adds the same latency."},{kind:"number",key:"release",label:"Release",unit:"ms",min:10,max:2e3,step:1,default:80,scale:"log"}],web:"worklet-truepeak"},{id:"gate",label:"Noise Gate",group:"dynamics",description:"Silence the track when it drops below the threshold.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-80,max:0,step:.5,default:-35},{kind:"number",key:"range",label:"Range",unit:"dB",min:-80,max:0,step:.5,default:-24,hint:"How far down the gate pulls when closed."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:10},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:9e3,step:.1,default:1,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:100,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83}],web:"worklet-gate"},{id:"saturate",label:"Saturation",group:"nonlinear",description:"Soft-clip the waveform for warmth or outright distortion.",params:[{kind:"enum",key:"type",label:"Curve",options:[{value:"tanh",label:"Tanh"},{value:"atan",label:"Arctan"},{value:"cubic",label:"Cubic"},{value:"exp",label:"Exponential"},{value:"alg",label:"Algebraic"},{value:"quintic",label:"Quintic"},{value:"sin",label:"Sine"},{value:"erf",label:"Error function"},{value:"hard",label:"Hard clip"}],default:"tanh"},{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-40,max:0,step:.1,default:-6},{kind:"number",key:"output",automatable:!0,label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0},{kind:"number",key:"oversample",label:"Oversample",unit:"x",min:1,max:8,step:1,default:4,hint:"Higher costs more but keeps aliasing down."}],web:"waveshaper"},{id:"bitcrush",label:"Bitcrush",group:"nonlinear",description:"Drop bit depth and sample rate for a lo-fi, digital sound.",params:[{kind:"number",key:"bits",label:"Bit depth",unit:"bit",min:1,max:32,step:.1,default:8},{kind:"number",key:"samples",label:"Sample hold",unit:"x",min:1,max:250,step:1,default:1,hint:"Repeats each sample N times, a crude downsample."},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-bitcrush"},{id:"pitchshift",label:"Pitch shift",group:"time",description:"Shifts pitch up or down without changing playback speed. Adds ~50 ms of latency.",params:[{kind:"number",key:"semitones",label:"Semitones",unit:"st",min:-12,max:12,step:1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-pitchshift"},{id:"delay",label:"Delay",group:"time",description:"Repeating echoes behind the dry signal.",params:[{kind:"number",key:"time",automatable:!0,label:"Time",unit:"ms",min:1,max:5e3,step:1,default:250,scale:"log"},{kind:"number",key:"feedback",automatable:!0,label:"Feedback",unit:"",min:.01,max:.95,step:.01,default:.35},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.4}],web:"delay-feedback"},{id:"chorus",label:"Chorus",group:"time",description:"Detuned copies of the signal for width and thickness.",params:[{kind:"number",key:"delay",automatable:!0,label:"Delay",unit:"ms",min:1,max:100,step:.1,default:7},{kind:"number",key:"depth",automatable:!0,label:"Depth",unit:"ms",min:0,max:10,step:.01,default:2},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.01,max:10,step:.01,default:1},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.5}],web:"chorus-lfo"},{id:"phaser",label:"Phaser",group:"time",description:"Sweeping notches moving through the spectrum.",params:[{kind:"number",key:"in_gain",automatable:!0,label:"Input",unit:"",min:0,max:1,step:.01,default:.4},{kind:"number",key:"out_gain",automatable:!0,label:"Output",unit:"",min:0,max:2,step:.01,default:.74},{kind:"number",key:"delay",label:"Delay",unit:"ms",min:.1,max:5,step:.1,default:3},{kind:"number",key:"decay",label:"Decay",unit:"",min:0,max:.99,step:.01,default:.4},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.1,max:2,step:.01,default:.5},{kind:"enum",key:"type",label:"Waveform",options:[{value:"0",label:"Triangular"},{value:"1",label:"Sinusoidal"}],default:"0"}],web:"allpass-phaser"},{id:"reverb",label:"Reverb",group:"time",description:"Room tail. Both ends convolve the same generated impulse, so preview matches render.",params:[{kind:"number",key:"size",label:"Room size",unit:"",min:.05,max:1,step:.01,default:.7},{kind:"number",key:"damping",label:"Damping",unit:"",min:0,max:1,step:.01,default:.5,hint:"Higher rolls the top off the tail faster."},{kind:"number",key:"wet",automatable:!0,label:"Wet",unit:"",min:0,max:1,step:.01,default:.35},{kind:"number",key:"dry",automatable:!0,label:"Dry",unit:"",min:0,max:1,step:.01,default:.7}],web:"convolver"}],yo=new Map(Wt.map(t=>[t.id,t]));var vo=Wt.map(t=>t.id);function vi(t){return 10**(t/20)}var Bt=vi(12);var $t="data-automation",Io=$t.slice(5),et=1,Si=512,L=class extends Error{constructor(e){super(e),this.name="AudioAutomationError"}},Te="volume",Re="rate";function Gt(t){if(t===Te)return{kind:"volume"};if(t===Re)return{kind:"rate"};let e=t.split(".");if(e.length===3&&e[0]==="fx"&&e[1]===Ai){let r=e[2];return r?{kind:"preset",presetId:r}:null}if(e.length!==3||e[0]!=="fx")return null;let[,n,i]=e;return!n||!i?null:{kind:"fx",nodeId:n,param:i}}var Ai="preset";var Ei={min:0,max:Bt,step:.01,unit:"",label:"Volume",scale:"linear",default:1};var Ti={min:ee,max:te,step:.05,unit:"x",label:"Speed",scale:"log",default:1};function ie(t){if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"&&t.trim()!==""){let e=Number(t);return Number.isFinite(e)?e:null}return null}function Ri(t){let e=ie(t);return e===null||e===0?0:Math.min(1,Math.max(-1,e))}function zt(t,e){let n=ie(t),i=ie(e);if(n===null||i===null)return null;let r=s=>Math.min(.999,Math.max(.001,s)),o=r(n),a=r(i);return Math.abs(o-a)<1e-6?null:{x:o,y:a}}function xi(t){let e=Ri(t?.curve),n=zt(t?.viaX,t?.viaY);return{...e?{curve:e}:{},...n?{viaX:n.x,viaY:n.y}:{}}}function wi(t,e){let n=ie(t?.t),i=ie(t?.v);if(n===null||i===null)return null;let r=e?Math.min(e.max,Math.max(e.min,i)):i;return{t:Math.max(0,n),v:r,...xi(t)}}function ki(t,e){let n=t.map(r=>wi(r,e)).filter(r=>r!==null).sort((r,o)=>r.t-o.t),i=[];for(let r of n)i.length>0&&i[i.length-1].t===r.t?i[i.length-1]=r:i.push(r);return i.slice(0,Si)}function Mi(t){let e=[];for(let n of t.lanes){if(!Gt(n.target))continue;let i=n.target===Te?Ei:n.target===Re?Ti:null,r=ki(n.points??[],i);r.length>0&&e.push({target:n.target,points:r})}return{version:et,lanes:e}}function jt(t){let e;try{e=JSON.parse(t)}catch(r){throw new L(`Automation is not valid JSON: ${r.message}`)}if(typeof e!="object"||e===null)throw new L("Automation must be a JSON object.");let n=e;if(n.version!==et)throw new L(`Unsupported automation version: ${String(n.version)}`);if(!Array.isArray(n.lanes))throw new L("Automation is missing a `lanes` array.");let i=n.lanes.map((r,o)=>{if(typeof r!="object"||r===null)throw new L(`Lane ${o} is not an object.`);let a=r;if(typeof a.target!="string"||!Gt(a.target))throw new L(`Lane ${o} has an unreadable target: ${String(a.target)}`);if(!Array.isArray(a.points))throw new L(`Lane ${o} is missing a \`points\` array.`);return{target:a.target,points:a.points}});return Mi({version:et,lanes:i})}function Ci(t,e){return e?Math.pow(t,Math.pow(2,2*e)):t}function Ii(t,e){let n=t-.5,i=e-.5,r=.999,o=1e6,a=n>0?n/(r-t):n<0?-n/(t-(1-r)):0,s=i>0?i/(r-e):i<0?-i/(e-(1-r)):0,l=Math.min(o,Math.max(1,a,s));return{cx:t+n/l,cy:e+i/l,w:l}}function Di(t,e,n){let{cx:i,cy:r,w:o}=Ii(e,n),a=2-2*o,s=t*a-1+2*o*i,l=-t*a-2*o*i,u=Pi(s,l,t),c=1-u,f=c*c+2*o*u*c+u*u;return f>0?(2*o*r*u*c+u*u)/f:t}function Pi(t,e,n){if(Math.abs(t)<1e-12)return Math.abs(e)<1e-12?n:-n/e;let i=Math.sqrt(Math.max(0,e*e-4*t*n)),r=(-e+i)/(2*t),o=(-e-i)/(2*t),a=s=>s>=-1e-9&&s<=1+1e-9;return a(r)?Math.min(1,Math.max(0,r)):a(o)?Math.min(1,Math.max(0,o)):n}function Li(t,e){let n=zt(e.viaX,e.viaY);return n?Di(Math.min(1,Math.max(0,t)),n.x,n.y):Ci(t,e.curve)}function Ni(t,e,n,i){return i==="log"&&t>0&&e>0?Math.exp(Math.log(t)+(Math.log(e)-Math.log(t))*n):t+(e-t)*n}function xe(t,e,n="linear"){let i=t.points;if(i.length===0)return 0;let r=i[0];if(e<=r.t)return r.v;let o=i[i.length-1];if(e>=o.t)return o.v;let a=0,s=i.length-1;for(;s-a>1;){let f=a+s>>1;i[f].t<=e?a=f:s=f}let l=i[a],u=i[s],c=u.t-l.t;return c<=0?u.v:Ni(l.v,u.v,Li((e-l.t)/c,l),n)}var we=new Map,Oi=64;function qt(t,e=Te){let n=`${e}\0${t}`,i=we.get(n);if(i!==void 0)return i;let r=null;try{r=jt(t).lanes.find(o=>o.target===e)??null}catch{r=null}return we.size>Oi&&we.clear(),we.set(n,r),r}var Yt=48,Xt=new WeakMap;function Fi(t){let e=t.points,n=e[0].v,i=e[e.length-1].v,r=[0],o=[0],a=l=>{let u=r[r.length-1];if(l<=u)return;let c=xe(t,u,"log");r.push(l),o.push(o[o.length-1]+(c+xe(t,l,"log"))/2*(l-u))},s=Math.max(0,e[0].t);a(s);for(let l=1;l<e.length;l+=1){let u=e[l-1].t,c=e[l].t;if(!(c<=0))for(let f=1;f<=Yt;f+=1)a(Math.max(u,0)+(c-u)*f/Yt)}return{ts:Float64Array.from(r),ss:Float64Array.from(o),firstRate:n,lastRate:i}}function Ui(t){let e=Xt.get(t);return e||(e=Fi(t),Xt.set(t,e)),e}function Hi(t){return typeof t!="number"&&t.points.length>0}function Vi(t,e,n){let i=0,r=t.length-1;for(;r-i>1;){let o=i+r>>1;t[o]<=n?i=o:r=o}return e[i]+(e[r]-e[i])*(n-t[i])/(t[r]-t[i])}function Kt(t,e){if(typeof t=="number")return e/t;if(!Hi(t))return e;let{ts:n,ss:i,firstRate:r,lastRate:o}=Ui(t),a=n.length-1;return e<=0?e/r:e>=i[a]?n[a]+(e-i[a])/o:Vi(i,n,e)}function Wi(t){return t?qt(t,Re):null}function Zt(t,e){return Wi(t)??e}var Uo=[{id:"montage",label:"Montage",points:[[0,.9],[.15,.3],[.5,2.5],[.85,.3],[1,.9]]},{id:"hero",label:"Hero",points:[[0,1],[.25,1.6],[.5,.25],[.75,1.6],[1,1]]},{id:"bullet",label:"Bullet",points:[[0,3],[.4,3],[.5,.15],[.6,3],[1,3]]},{id:"jump-cut",label:"Jump cut",points:[[0,.5],[.24,.5],[.26,3],[.5,3],[.52,.5],[.74,.5],[.76,3],[1,3]]},{id:"flash-in",label:"Flash in",points:[[0,.3],[.6,.6],[1,5]]},{id:"flash-out",label:"Flash out",points:[[0,5],[.4,.6],[1,.3]]},{id:"ramp-in",label:"Ramp in",points:[[0,.5],[1,1]]},{id:"ramp-out",label:"Ramp out",points:[[0,1],[1,.5]]},{id:"slowmo-middle",label:"Slow-mo middle",points:[[0,1],[1/3,.35],[2/3,.35],[1,1]]}];var y=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),Vo=Object.freeze([y.start,y.duration,y.trackIndex]),Wo=Object.freeze([y.derivedEnd]),Bo=Object.freeze([y.derivedEnd,y.legacyTrack]);function N(t){if(t==null||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}var en=/^[A-Za-z0-9_.:-]+$/;function tn(t,e){let n=t.charCodeAt(e);return n>=48&&n<=57}function Jt(t,e){let n=e;for(;n>=0&&tn(t,n);)n--;return n}function Bi(t,e){let n=e;for(;n>=0&&(t[n]??"").trim()==="";)n--;return n}function $i(t){let e=t.length-1;if(!tn(t,e))return null;let n=Jt(t,e);return t[n]==="."&&(n=Jt(t,n-1)),n+1}function Gi(t){let e=$i(t);if(e==null)return null;let n=Bi(t,e-1),i=t[n];if(i!=="+"&&i!=="-")return null;let r=t.slice(0,n).trim();if(!en.test(r))return null;let o=Number(t.slice(e));return Number.isFinite(o)?{refId:r,operator:i,magnitude:o}:null}function re(t){let e=(t??"").trim();if(!e)return null;let n=N(e);if(n!=null)return{kind:"absolute",value:n};if(en.test(e))return{kind:"reference",refId:e,offset:0};let i=Gi(e);return i?{kind:"reference",refId:i.refId,offset:i.operator==="-"?-i.magnitude:i.magnitude}:null}function x(t,e,n,i){t.push({code:e,attribute:n,value:i})}function zi(t,e,n,i){if(e==null||e.trim()==="")return n.defaultStart===void 0?0:n.defaultStart;if(!t)return x(i,"invalid-start",y.start,e),null;if(t.kind==="absolute")return Math.max(0,t.value);let r=n.resolveReferenceEnd?.(t.refId);return r==null||!Number.isFinite(r)?(x(i,"unresolved-start-reference",y.start,e),null):Math.max(0,r+t.offset)}var ji=1e-9;function qi(t,e){return Math.abs(t-e)<=ji}function Yi(t,e,n){let i=N(t);if(i==null){x(n,"deprecated-end",y.derivedEnd,t),x(n,"invalid-end",y.derivedEnd,t);return}if(e==null){x(n,"deprecated-end",y.derivedEnd,t);return}qi(i,e)||(x(n,"deprecated-end",y.derivedEnd,t),x(n,"conflicting-end",y.derivedEnd,t))}function Xi(t,e,n){let i=N(t);return i==null||i<0?(x(n,"invalid-duration",y.duration,t),{duration:null,end:null,durationSource:"invalid"}):{duration:i,end:e==null?null:e+i,durationSource:"duration"}}function Ki(t,e,n){x(n,"deprecated-end",y.derivedEnd,t);let i=N(t);return i==null?(x(n,"invalid-end",y.derivedEnd,t),{duration:null,end:null,durationSource:"invalid"}):e==null?{duration:null,end:i,durationSource:"legacy-end"}:i<e?(x(n,"end-before-start",y.derivedEnd,t),{duration:null,end:null,durationSource:"invalid"}):{duration:i-e,end:i,durationSource:"legacy-end"}}function Zi(t,e,n){let i=t.getAttribute(y.duration),r=t.getAttribute(y.derivedEnd);if(i==null)return r==null?{duration:null,end:null,durationSource:"missing"}:Ki(r,e,n);let o=Xi(i,e,n);return r!=null&&Yi(r,o.end,n),o}function Qt(t,e,n,i){let r=N(t);return r==null||!Number.isInteger(r)?(x(i,"invalid-track-index",e,t),{trackIndex:0,trackSource:"invalid"}):{trackIndex:r,trackSource:n}}function Ji(t,e){let n=t.getAttribute(y.trackIndex),i=t.getAttribute(y.legacyTrack);if(n==null&&i==null)return{trackIndex:0,trackSource:"default"};if(n==null&&i!=null)return x(e,"deprecated-layer",y.legacyTrack,i),Qt(i,y.legacyTrack,"legacy-layer",e);let r=Qt(n??"",y.trackIndex,"track-index",e);if(i==null)return r;x(e,"deprecated-layer",y.legacyTrack,i);let o=N(i);return o!=null&&o!==r.trackIndex&&x(e,"conflicting-layer",y.legacyTrack,i),r}function tt(t,e={}){let n=[],i=t.getAttribute(y.start),r=re(i),o=zi(r,i,e,n),a=Zi(t,o,n),s=Ji(t,n);return{startExpression:r,start:o,...a,...s,diagnostics:n}}function V(t){return N(t)}function nt(t){return Ut(e=>t.getAttribute(e),P(t)?t.defaultPlaybackRate:1)}function Qi(t){return Zt(t.getAttribute("data-automation"),nt(t))}function it(t){return Ae(e=>t.getAttribute(e))}function oe(t,e){return er(e,it(t),Qi(t))}function rt(t){let e=Je({tag:"video",authoredDurationSeconds:Ke(n=>t.getAttribute(n)),sourceDurationSeconds:Number.isFinite(t.duration)?t.duration:null,mediaStartSeconds:it(t),playbackRate:nt(t)});return e.source==="media"?oe(t,t.duration):e.seconds}function ke(t,e=0){return!Ot(t)||!t.hasAttribute("data-start")&&!t.hasAttribute("data-track-index")?null:Je({tag:"img",authoredDurationSeconds:Ht(n=>t.getAttribute(n),e),sourceDurationSeconds:null,mediaStartSeconds:0,playbackRate:1}).seconds}function er(t,e,n){return typeof n=="number"?Ze(t,e,n):Number.isFinite(t)?Kt(n,Math.max(0,t-e)):null}function nn(){return globalThis}function ot(t,e){if(typeof window>"u")return;let n=nn(),i=n.__hf?.onSwallowed;if(i)try{i({label:t,error:e})}catch(r){}(n.__hfDebug||n.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${t} swallowed:`,e)}var tr=t=>t.paused?.()===!0?(t.startTime?.()??0)+(t.totalDuration?.()??0)/Math.abs(t.timeScale?.()||1):0;function ae(t){try{if(typeof t?.duration!="function")return null;let e=t.getChildren?.(!1,!1,!0),n=Array.isArray(e)?e:[],i=Math.max(Number(t.duration()),...n.map(tr));return Number.isFinite(i)?i:null}catch(e){return ot("runtime.timelineDuration",e),null}}var rn="data-hf-authored-duration",on="data-hf-authored-end";function se(t){if(t==null||typeof t=="string"&&t.trim()==="")return null;let e=typeof t=="number"?t:Number(t);return Number.isFinite(e)?e:null}function Me(t){let e=se(t.start);if(e==null)return null;let n=Math.max(0,e),i=se(t.duration),r=se(t.authoredDuration),o=i!=null&&i>0?i:r!=null&&r>0?r:null;if(o!=null)return{start:n,duration:o,end:n+o};let a=se(t.end),s=se(t.authoredEnd),l=a!=null&&a>n?a:s!=null&&s>n?s:null;return{start:n,duration:l==null?null:l-n,end:l}}var z=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),ia=Object.freeze([z.start,z.duration,z.trackIndex]),ra=Object.freeze([z.derivedEnd]),oa=Object.freeze([z.derivedEnd,z.legacyTrack]);function nr(t){if(t==null||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}var an=t=>{let e=nr(t);return e!==null&&e>=0?e:null};function ir(t){return an(t("data-playback-start"))??an(t("data-media-start"))??0}var sn="data-hf-media-start-basis";function ln(t){return t?.trim().toLowerCase()==="global"?"global":"local"}function rr(t){return ln(t.basis)==="global"?t.authoredStart:t.hostStart+t.authoredStart}function un(t){return cn(t)?rr({authoredStart:t.authoredStart,hostStart:t.hostStart,basis:t.basis}):t.ordinaryStart()}function dn(t){return cn(t)&&ln(t.basis)==="global"}function cn(t){return!t.hasAutoStart&&t.authoredStart!=null&&t.hostStart!==0}function at(t){return ir(e=>t.getAttribute(e))}function mn(t,e){return t-at(e)}function le(t){let e=t.timelineRegistry??{},n=t.includeAuthoredTimingAttrs??!1,i=t.documentRef??document,r=new WeakMap,o=new WeakMap,a=new Set,s=d=>(d.hasAttribute("data-composition-id")?d.parentElement:d)?.closest("[data-composition-id]")??null,l=(d,h)=>{let g=s(h);if(g){for(let k of g.querySelectorAll(`[id="${d}"]`))if(s(k)===g)return k}let R=i.getElementById(d);return R||(Array.from(i.querySelectorAll("[data-composition-id]")).find(k=>k.getAttribute("data-composition-id")===d)??null)},u=(d,h)=>n?d.getAttribute(h):null,c=d=>Me({start:0,duration:d.getAttribute("data-duration"),authoredDuration:u(d,"data-hf-authored-duration")})?.duration??Me({start:T(d,0),end:d.getAttribute("data-end"),authoredEnd:u(d,"data-hf-authored-end")})?.duration??null,f=d=>d!=null&&Number.isFinite(d)&&d>0?d:null,v=d=>{let h=d.getAttribute("data-composition-id");return h?f(ae(e[h])):null},b=d=>{let h=o.get(d);if(h!==void 0)return h;let g=c(d)??f(P(d)?oe(d,d.duration):null)??f(ke(d))??v(d);return o.set(d,g),g},S="[data-composition-src], [data-composition-id], [data-composition-file]",_=d=>d.matches(S),A=d=>!d.hasAttribute("data-composition-id")||re(d.getAttribute("data-start"))?null:d.parentElement?.closest(`[data-start], ${S}`)??null,C=(d,h)=>mn(T(d,h),A(d)??d),M=(d,h)=>{let g=d.hasAttribute("data-composition-id")?d.parentElement?.closest("[data-composition-id]"):d.closest("[data-composition-id]");return g?C(g,h):0},I=(d,h)=>{let g=re(d.getAttribute("data-start"));if(!g){let H=A(d);return H?T(H,h):h}if(g.kind==="absolute")return M(d,h)+Math.max(0,g.value);let R=l(g.refId,d);if(!R)return h;let k=T(R,0),ye=b(R)??0,ve=Math.min(0,M(d,0));return Math.max(ve,k+ye+g.offset)},T=(d,h)=>{let g=r.get(d);if(g!==void 0)return g??h;if(a.has(d))return h;a.add(d);try{let R=I(d,h);return r.set(d,R),R}finally{a.delete(d)}},U=d=>{let h=d.closest("[data-composition-id]");return{authoredStart:V(d.getAttribute("data-start")),hostStart:h?C(h,0):0,hasAutoStart:d.hasAttribute("data-hf-auto-start"),basis:d.getAttribute(sn)}};return{resolveStartForElement:(d,h=0)=>T(d,Math.max(0,h)),resolveDurationForElement:d=>b(d),resolveMediaStartForElement:d=>{let h=U(d);return un({...h,ordinaryStart:()=>T(d,h.hostStart)})},resolveHostStartForElement:d=>M(d,0),resolveHostSlotsForElement:d=>{let h=[];for(let g=d.parentElement;g;g=g.parentElement){if(!_(g)||A(g)||at(g)<=0)continue;let R=T(g,0),k=c(g);h.push({start:R,end:k?R+k:1/0})}return h},isRootGlobalMediaStartForElement:d=>P(d)&&dn(U(d))}}function pn(){return{capturedTimeline:null,isPlaying:!1,currentTime:0,deterministicAdapters:[],canonicalFps:30,bridgeMuted:!1,bridgeVolume:1,mediaOutputMuted:!1,nativeMediaSyncDisabled:!1,webAudioMediaDisabled:!1,mediaAutoplayBlockedPosted:!1,mediaForceSyncNextTick:!1,playbackRate:1,bridgeLastPostedFrame:-1,bridgeLastPostedAt:0,bridgeLastPostedPlaying:!1,bridgeLastPostedMuted:!1,bridgeMaxPostIntervalMs:80,controlBridgeHandler:null,beforeUnloadHandler:null,injectedCompStyles:[],injectedCompScripts:[],injectedCompLinks:[],cachedTimedMediaEls:[],cachedMediaClips:[],cachedVideoClips:[],cachedMediaTimelineDurationSeconds:0,tornDown:!1,transportClock:null,transportRafId:null}}var fn=7200,st=1/60,ue=t=>t!==null&&t>st?t:null;function or(t){return{width:Se(t.getAttribute("data-width")),height:Se(t.getAttribute("data-height"))}}function ar(t,e){let n=null;for(let i of t.querySelectorAll("video[data-start], audio[data-start]")){let r=e.mediaStart(i);if(!Number.isFinite(r))continue;let o=e.mediaDuration(i);if(o==null||o<=st)continue;let a=Math.max(0,r)+o;(!n||a>n.seconds)&&(n={seconds:a,element:i})}return n&&ue(n.seconds)!==null?n:null}function sr(t,e){return ar(t,e)?.seconds??null}function lr(t,e){let n=[];for(let r of t.querySelectorAll("[data-composition-id][data-start]")){if(r.parentElement?.closest("[data-composition-id]")!==t)continue;let o=e.resolveStartForElement(r,0),a=e.resolveDurationForElement(r);!Number.isFinite(o)||a==null||a<=0||n.push(Math.max(0,o)+a)}let i=V(t.getAttribute("data-duration"));return ue(ze({authoredDurationSeconds:null,clipEndsSeconds:[i,...n]}).seconds)}var ur=t=>t.hasAttribute("data-composition-id")||t.hasAttribute("data-composition-src");function dr(t,e,{unregisteredLottie:n}){let i=[];for(let o of t.querySelectorAll("[data-start]")){let a=e.resolveStartForElement(o,0);if(!Number.isFinite(a))continue;let s=e.resolveDurationForElement(o);s!=null?i.push(Math.max(0,a)+s):(P(o)||ur(o))&&i.push(null)}(n||t.querySelector("[data-lottie-src]"))&&i.push(null);let r=ze({authoredDurationSeconds:null,clipEndsSeconds:i});return r.pendingClips>0?{...r,seconds:null,source:"unresolved",reason:"a clip's length is pending"}:r}function cr(t){return mr(t).seconds}function mr(t){if(t.declared!==null&&Number.isFinite(t.declared)&&t.declared>0)return{seconds:t.declared,from:"declared",floorIndex:null};let e=ue(t.timeline()),n=t.floors().map(f=>f??0),i=Math.max(0,...n),r=Number.isFinite(t.fallback)&&t.fallback>st?t.fallback:0,o=Math.max(i,r),s=e!==null&&e>=fn&&ue(o)!==null?null:e,l=i>=r,u=f=>({seconds:f,from:l?"floor":"fallback",floorIndex:l?n.indexOf(i):null});if(s!==null)return s>=o?{seconds:s,from:"timeline",floorIndex:null}:u(o);if(ue(i)!==null)return u(o);if(r>0)return{seconds:r,from:"fallback",floorIndex:null};let c=t.derived();return{seconds:c>0?c:0,from:"derived",floorIndex:null}}function hn(t){let e=Q(t);if(!e)return null;let n=le({timelineRegistry:{},includeAuthoredTimingAttrs:!0,documentRef:t}),i=cr({declared:V(e.getAttribute("data-duration")),timeline:()=>null,floors:()=>[sr(t,{mediaStart:n.resolveMediaStartForElement,mediaDuration:rt}),lr(e,n)],fallback:0,derived:()=>dr(e,n,{unregisteredLottie:!1}).seconds??0});return{...or(e),fps:pn().canonicalFps,durationSeconds:i}}var bn="hyperframes-studio-preview";var gn="__hfPreviewErrors";function _n(t){return t.hasRuntime||t.runtimeInjected?!1:!!(t.hasNestedCompositions||t.hasTimelines&&t.attempts>=5)}function j(t){return typeof t=="object"&&t!==null}function yn(t){return j(t)&&typeof t.getDuration=="function"}function vn(t){return j(t)&&typeof t.duration=="function"&&typeof t.time=="function"&&typeof t.seek=="function"&&typeof t.play=="function"&&typeof t.pause=="function"}var q="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.224/dist/hyperframe.runtime.iife.js";function de(t){if(t===null)return null;let e=Number.parseInt(t,10);return Number.isFinite(e)&&e>0?e:null}function pr(t){let e=t?.querySelector("[data-composition-id][data-width][data-height]")??t?.querySelector("[data-width][data-height]");if(!e)return null;let n=de(e.getAttribute("data-width")),i=de(e.getAttribute("data-height"));return n!==null&&i!==null?{width:n,height:i}:null}function fr(t){return Array.isArray(t)?t.find(e=>typeof e=="string"&&e.trim()!==""&&e!=="[object Event]")??null:null}var Ce=class{constructor(e,n){this._iframe=e;this._callbacks=n}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;_runtimeScript=null;_failure=null;get failed(){return this._failure!==null&&this._failure.document===this._iframe.contentDocument}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._failure=null,this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;let n=null;try{n=this._poll(e)}catch(i){i instanceof DOMException&&i.name==="SecurityError"||(n={kind:"error",message:i instanceof Error?i.message:String(i)})}n??=this._deadlineOutcome(e),n&&(this.stop(),n.kind==="error"?(this._failure={document:this._iframe.contentDocument},this._callbacks.onError(n.message)):this._callbacks.onReady(n.result))},200)}_deadlineOutcome(e){return e<40||this._callbacks.hostOwnsDeadline?.()?null:{kind:"error",message:"Composition timeline not found after 8s"}}_poll(e){let n=this._iframe.contentWindow;if(!n)return null;let i=fr(Reflect.get(n,gn));if(i!==null)return{kind:"error",message:i};let r=this._iframe.contentDocument,o=Reflect.get(n,"__timelines"),a=this.hasRuntimeBridge(n);if(_n({hasRuntime:a,hasTimelines:j(o)&&Object.keys(o).length>0,hasNestedCompositions:!!r?.querySelector("[data-composition-src]"),runtimeInjected:this._runtimeInjected,attempts:e}))return this._injectRuntime(),null;if(this._runtimeInjected&&!a)return null;let s=this._resolveReadyResult(n,r);return s?{kind:"ready",result:s}:null}_resolveReadyResult(e,n){let i=this._resolvePlaybackDurationAdapter(e)??{kind:"document",getDuration:()=>0},r=i.getDuration();if(!Number.isFinite(r)||r<=0){if(i.kind==="direct-timeline")return null;r=n?hn(n)?.durationSeconds??0:0}return r<=0?null:{duration:r,adapter:{...i,getDuration:()=>r},compositionSize:pr(n)}}stop(){this._runtimeScript&&(this._runtimeScript.onerror=null,this._runtimeScript=null),this.failed||(this._failure=null),this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return j(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let n=e.createElement("script");n.src=this._callbacks.resolveRuntimeUrl?.()??q,this._runtimeScript=n,n.onerror=()=>{this._runtimeScript!==n||this._iframe.contentDocument!==e||(this.stop(),this._failure={document:e},this._callbacks.onError("HyperFrames runtime failed to load from "+n.src))},(e.head||e.documentElement).appendChild(n),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let n=Reflect.get(e,"__timelines");if(!j(n))return null;let i=Object.keys(n);if(i.length===0)return null;let r=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=r&&r in n?r:i[i.length-1],a=n[o];return vn(a)?a:null}_resolvePlaybackDurationAdapter(e){let n=Reflect.get(e,"__player");if(yn(n))return{kind:"runtime",getDuration:()=>n.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var Sn=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -474,5 +474,5 @@
474
474
  background: var(--hfp-accent, #fff);
475
475
  pointer-events: none;
476
476
  }
477
- `,Sn='<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>',An='<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>',st='<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>',lt='<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>',En='<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>';var ut=[.25,.5,1,1.5,2,4];function W(n){return Number.isInteger(n)?`${n}x`:`${n}x`}function Ie(n){if(!Number.isFinite(n)||n<0)return"0:00";let e=Math.floor(n),t=Math.floor(e/60),i=e%60;return`${t}:${i.toString().padStart(2,"0")}`}function Tn(n,e,t={}){let i=t.speedPresets??ut,r=document.createElement("div");r.className="hfp-controls",r.addEventListener("click",m=>{m.stopPropagation()});let o=document.createElement("button");o.className="hfp-play-btn",o.type="button",o.innerHTML=`<span class="hfp-ico hfp-ico-play">${Sn}</span><span class="hfp-ico hfp-ico-pause">${An}</span>`,o.setAttribute("aria-label","Play");let a=document.createElement("div");a.className="hfp-scrubber";let s=document.createElement("div");s.className="hfp-progress",s.style.width="0%",a.appendChild(s);let l=document.createElement("span");l.className="hfp-time",l.textContent="0:00 / 0:00";let u=document.createElement("div");u.className="hfp-speed-wrap";let c=document.createElement("button");c.className="hfp-speed-btn",c.type="button",c.textContent="1x",c.setAttribute("aria-label","Playback speed: 1x");let h=document.createElement("div");h.className="hfp-speed-menu",h.setAttribute("role","menu");for(let m of i){let p=document.createElement("button");p.className="hfp-speed-option",p.type="button",p.setAttribute("role","menuitem"),p.dataset.speed=String(m),p.textContent=W(m),m===1&&p.classList.add("hfp-active"),h.appendChild(p)}u.appendChild(h),u.appendChild(c);let v=document.createElement("div");v.className="hfp-volume-wrap";let b=document.createElement("button");b.className="hfp-mute-btn",b.type="button",b.innerHTML=st,b.setAttribute("aria-label","Mute");let S=document.createElement("div");S.className="hfp-volume-slider-wrap";let _=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;let A=document.createElement("div");A.className="hfp-volume-fill",A.style.width="100%",_.appendChild(A),S.appendChild(_),v.appendChild(S),v.appendChild(b),t.audioLocked&&(v.style.display="none"),r.appendChild(o),r.appendChild(a),r.appendChild(l),r.appendChild(v),r.appendChild(u),n.appendChild(r);let C=!1,M=!1,I=1,T=null,U=i.indexOf(1);U===-1&&(U=0);let Z=(m,p)=>m?En:p===0?lt:p<.5?lt:st;o.addEventListener("click",m=>{m.stopPropagation(),C?e.onPause():e.onPlay()}),b.addEventListener("click",m=>{m.stopPropagation(),e.onMuteToggle()});let O=!1,J=m=>{let p=_.getBoundingClientRect(),E=Math.max(0,Math.min(1,(m-p.left)/p.width));I=E,A.style.width=`${E*100}%`,_.setAttribute("aria-valuenow",String(Math.round(E*100))),M&&E>0&&e.onMuteToggle(),b.innerHTML=Z(M,E),e.onVolumeChange(E)};_.addEventListener("mousedown",m=>{m.stopPropagation(),O=!0,J(m.clientX)});let d=m=>{O&&J(m.clientX)},f=()=>{O=!1};document.addEventListener("mousemove",d),document.addEventListener("mouseup",f),_.addEventListener("touchstart",m=>{O=!0;let p=m.touches[0];p&&J(p.clientX)},{passive:!0});let g=m=>{if(O){let p=m.touches[0];p&&J(p.clientX)}},R=()=>{O=!1};document.addEventListener("touchmove",g,{passive:!0}),document.addEventListener("touchend",R);let k=.05;_.addEventListener("keydown",m=>{let p=I;if(m.key==="ArrowRight"||m.key==="ArrowUp")p=Math.min(1,I+k);else if(m.key==="ArrowLeft"||m.key==="ArrowDown")p=Math.max(0,I-k);else return;m.preventDefault(),m.stopPropagation(),I=p,A.style.width=`${p*100}%`,_.setAttribute("aria-valuenow",String(Math.round(p*100))),M&&p>0&&e.onMuteToggle(),b.innerHTML=Z(M,p),e.onVolumeChange(p)});let ye=m=>{for(let p of h.querySelectorAll(".hfp-speed-option"))p.classList.toggle("hfp-active",p.dataset.speed===String(m))};c.addEventListener("click",m=>{m.stopPropagation();let p=h.classList.toggle("hfp-open");c.setAttribute("aria-expanded",String(p))}),h.addEventListener("click",m=>{m.stopPropagation();let p=m.target.closest(".hfp-speed-option");if(!p)return;let E=parseFloat(p.dataset.speed);U=i.indexOf(E),c.textContent=W(E),c.setAttribute("aria-label",`Playback speed: ${W(E)}`),ye(E),h.classList.remove("hfp-open"),c.setAttribute("aria-expanded","false"),e.onSpeedChange(E)});let ve=()=>{h.classList.remove("hfp-open"),c.setAttribute("aria-expanded","false")};document.addEventListener("click",ve);let H=m=>{let p=a.getBoundingClientRect(),E=Math.max(0,Math.min(1,(m-p.left)/p.width));e.onSeek(E)},D=!1;a.addEventListener("mousedown",m=>{m.stopPropagation(),D=!0,e.onScrubStart?.(),H(m.clientX)});let xt=m=>{D&&H(m.clientX)},wt=()=>{D&&(D=!1,e.onScrubEnd?.())};document.addEventListener("mousemove",xt),document.addEventListener("mouseup",wt),a.addEventListener("touchstart",m=>{D=!0,e.onScrubStart?.();let p=m.touches[0];p&&H(p.clientX)},{passive:!0});let kt=m=>{if(D){let p=m.touches[0];p&&H(p.clientX)}},Mt=()=>{D&&(D=!1,e.onScrubEnd?.())};document.addEventListener("touchmove",kt,{passive:!0}),document.addEventListener("touchend",Mt);let Ct=()=>C&&!D&&!O&&!r.querySelector(":focus-visible"),It=()=>{r.classList.remove("hfp-hidden"),T&&clearTimeout(T),T=setTimeout(()=>{Ct()&&r.classList.add("hfp-hidden")},3e3)},F=n instanceof ShadowRoot?n.host:n,$=()=>It(),Dt=()=>{Ct()&&r.classList.add("hfp-hidden")};return F.addEventListener("mousemove",$),F.addEventListener("keydown",$),F.addEventListener("focusin",$),F.addEventListener("mouseleave",Dt),{updateTime(m,p){let E=p>0?Math.min(m,p):m,si=p>0?E/p*100:0;s.style.width=`${si}%`,l.textContent=`${Ie(E)} / ${Ie(p)}`},updatePlaying(m){let p=m!==C;C=m,o.classList.toggle("hfp-playing",m),o.setAttribute("aria-label",m?"Pause":"Play"),m?p&&It():(T&&clearTimeout(T),r.classList.remove("hfp-hidden"))},updateSpeed(m){let p=i.indexOf(m);p!==-1&&(U=p),c.textContent=W(m),c.setAttribute("aria-label",`Playback speed: ${W(m)}`),ye(m)},updateMuted(m){M=m,b.innerHTML=Z(m,I),b.setAttribute("aria-label",m?"Unmute":"Mute")},updateVolume(m){I=m,A.style.width=`${m*100}%`,_.setAttribute("aria-valuenow",String(Math.round(m*100))),b.innerHTML=Z(M,m)},setVolumeControlsHidden(m){v.style.display=m?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",xt),document.removeEventListener("mouseup",wt),document.removeEventListener("touchmove",kt),document.removeEventListener("touchend",Mt),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",f),document.removeEventListener("touchmove",g),document.removeEventListener("touchend",R),document.removeEventListener("click",ve),F.removeEventListener("mousemove",$),F.removeEventListener("keydown",$),F.removeEventListener("focusin",$),F.removeEventListener("mouseleave",Dt),T&&clearTimeout(T),r.remove()}}}function Rn(n,e,t,i,r,o=!1){let a=i?i.split(",").map(Number).filter(u=>!isNaN(u)&&u>0):void 0,s={...a?{speedPresets:a}:{},audioLocked:o},l=Tn(n,r,s);return l.updateMuted(e),l.updateVolume(t),l}function dt(n,e,t){return e?(t||(t=document.createElement("img"),t.className="hfp-poster",n.appendChild(t)),t.src=e,t):(t?.remove(),null)}function xn(n){return n.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains("hfp-controls"))}var De=null;function wn(n,e){if(typeof CSSStyleSheet<"u")try{De||(De=new CSSStyleSheet,De.replaceSync(e)),n.adoptedStyleSheets=[De];return}catch{}let t=document.createElement("style");t.textContent=e,n.appendChild(t)}function kn(){let n=document.createElement("div");n.className="hfp-container";let e=document.createElement("iframe");return e.className="hfp-iframe",e.sandbox.add("allow-scripts","allow-same-origin"),e.allow="autoplay; fullscreen",e.referrerPolicy="no-referrer",e.title="HyperFrames Composition",n.appendChild(e),{container:n,iframe:e}}function Mn(n,e,t,i){let r=n.offsetWidth,o=n.offsetHeight;if(r===0||o===0)return!1;let a=Math.min(r/t,o/i);return e.style.width=`${t}px`,e.style.height=`${i}px`,e.style.transform=`translate(-50%, -50%) scale(${a})`,!0}function fr(n,e,t){if(t.end<=0)return!1;let i=t.shown<t.end&&e>0?e+.001:0;return n+i>=t.end}var Pe=class{constructor(e){this._callbacks=e}_callbacks;_raf=null;_lastUpdateMs=0;_tick=null;start(e,t,i,r,o){this.stop();let a=null,s=0,l=0,u=()=>{if(r()){this._raf=null;return}let c;try{c=e.time()}catch{this._raf=null;return}let h=i(),v=o();v.end>0&&(c=Math.min(c,v.end));let b=a===null?0:c-a;b!==0&&(l=Math.min(b,s),s=b),a=c;let S=fr(c,l,v);S&&(c=v.shown);let _=performance.now();if((_-this._lastUpdateMs>100||S)&&(this._lastUpdateMs=_,this._callbacks.onTimeUpdate(c,h)),S){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{e.pause(),v.shown<v.end&&e.seek(v.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(u)};this._tick=u,this._raf=requestAnimationFrame(u)}poll(){this._raf===null||!this._tick||(cancelAnimationFrame(this._raf),this._tick())}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}};function Cn(n){let e=Array.from(n.querySelectorAll("[data-composition-id]"));if(e.length===0)return n.body?[n.body]:[];let t=[];for(let i of e)br(i)||t.push(i);return hr(n),t}function hr(n){let e=n.body;if(!e||typeof console>"u"||typeof console.warn!="function")return;let t=e.querySelectorAll("audio[data-start], video[data-start]");if(t.length===0)return;let i=[];for(let r of t)r.closest("[data-composition-id]")||i.push(r);i.length!==0&&console.warn(`[hyperframes-player] selectMediaObserverTargets: composition hosts are present, but ${i.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.`,i)}function br(n){let e=n.parentElement;for(;e;){if(e.hasAttribute("data-composition-id"))return!0;e=e.parentElement}return!1}var gr=["backdrop-filter","clip-path","filter","mask","mask-border-source","mask-image","perspective","rotate","scale","transform","translate","-webkit-mask-image"],Xa=new Set([...gr,"contain","isolation","mask-border","mix-blend-mode","opacity"]);var In=n=>4*Number.EPSILON*Math.max(1,Math.abs(n));function Le(n,e){return!Number.isFinite(n)||!Number.isFinite(e)?n===e:Math.abs(n-e)<=In(Math.max(Math.abs(n),Math.abs(e)))}var Dn=(n,e)=>n>=e||Le(n,e),ct=(n,e,t)=>Dn(n,e)&&n<t&&!Le(n,t),_r=1e-6,Pn=(n,e,t,i)=>ct(n,e,t)||Dn(n,e)&&i>0&&t>=i-_r;function yr(n){return Number.isFinite(n)&&n>0?n:30}function vr(n){return Number.isFinite(n)&&n>0?n:0}function Ln(n,e){let t=yr(e),i=vr(n),r=i*t,o=Math.round(r);return Math.abs(r-o)<=.001?o/t:i}function Nn(n,e,t){return{start:Ln(n,t),end:Number.isFinite(e)?Ln(e,t):e}}var Sr=["seconds-time","rational-fps","seek-keep-playing","composition-manifest-v1","runtime-data","play-range"];function Ar(n,e){let t=Math.abs(n),i=Math.abs(e);for(;i!==0;){let r=t%i;t=i,i=r}return t||1}function Er(n){let e=Number.isFinite(n)&&n>0?n:30,t=Math.abs(e*1001-Math.round(e*1001))<1e-6,i=Number.isInteger(e)?1:t?1001:1e6,r=Math.round(e*i),o=Ar(r,i);return{numerator:r/o,denominator:i/o}}function On(n,e,t){return Math.max(n,(Math.ceil(e*t-1e-6)-1)/t)}function Tr(n){if(typeof n!="object"||n===null)return null;let e=n;return!Number.isFinite(e.numerator)||!Number.isFinite(e.denominator)||(e.numerator??0)<=0||(e.denominator??0)<=0?null:Number(e.numerator)/Number(e.denominator)}function mt(n){return{protocolVersion:1,capabilities:Sr,fps:Er(n)}}function Fn(n){let e=n.offsetWidth,t=n.getBoundingClientRect().width;return e>0&&t>0?t/e:null}function Rr(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function Un(n,e=30){if(typeof n!="object"||n===null)return{status:"legacy",fps:e};let t=n;if(t.protocolVersion===void 0)return{status:"legacy",fps:e};if(t.protocolVersion!==1)return{status:"unsupported",code:"unsupported_protocol_version",receivedVersion:t.protocolVersion};let i=Tr(t.fps);return i===null||!Rr(t.capabilities)?{status:"unsupported",code:"invalid_protocol_metadata",receivedVersion:t.protocolVersion}:{status:"supported",fps:i,metadata:t}}function xr(n,e){let t=n.tagName.toLowerCase();if(t==="script"||t==="style"||t==="link"||t==="meta")return null;let r=t==="video"||t==="audio"?e.resolver.resolveMediaStartForElement(n):e.resolver.resolveStartForElement(n,0),o=e.resolver.resolveDurationForElement(n),a=n.getAttribute("data-composition-id");if(a){let l=e.timelineRegistry[a],u=ae(l);!(n.hasAttribute("data-duration")||n.hasAttribute("data-end")||n.hasAttribute(nn)||n.hasAttribute(rn))&&(o==null||o<=0)&&u!=null&&u>0&&(o=u)}let s=a!==null&&n===Q(n.ownerDocument);return{start:r,end:!s&&o!=null&&o>0?r+o:Number.POSITIVE_INFINITY}}function Hn(n,e){let t=xr(n,e);if(!t)return!1;let i=e.exportRenderSeek?Nn(t.start,t.end,e.canonicalFps):t;return Pn(e.currentTime,i.start,i.end,e.compositionDuration)}var Y="first-frame",wr=3;function ce(n){let e=n.ownerDocument?.defaultView;return e&&n instanceof e.Element?!0:n instanceof Element}function w(n){if(!ce(n)||n.tagName!=="AUDIO"&&n.tagName!=="VIDEO")return!1;let e=n.ownerDocument?.defaultView;return e&&n instanceof e.HTMLMediaElement?!0:n instanceof HTMLMediaElement}function kr(n){return n.hasAttribute("data-start")||n.hasAttribute("data-track-index")}function Mr(n,e,t){let i=n;for(;i;){if(kr(i)&&!Hn(i,{currentTime:0,compositionDuration:Number.POSITIVE_INFINITY,canonicalFps:30,exportRenderSeek:!1,timelineRegistry:t,resolver:e}))return!1;i=i.parentElement}return!0}function Vn(n,e,t,i){return e==="all"?!0:Mr(n,t,i)}function Ne(n,{scope:e="all"}={}){let t=n.defaultView,i=le({documentRef:n,timelineRegistry:t?.__timelines,includeAuthoredTimingAttrs:!0}),r=n.querySelector(`meta[name="${hn}"]`)!==null,o=Array.from(n.querySelectorAll("video, audio")).filter(w).filter(l=>Vn(l,r&&l.preload!=="auto"?Y:e,i,t?.__timelines??{})).filter(l=>l.readyState<wr),a=Array.from(n.querySelectorAll("img")).filter(l=>Vn(l,l.getAttribute("loading")?.toLowerCase()==="lazy"?Y:e,i,t?.__timelines??{})).filter(l=>!l.complete),s=n.fonts?.status==="loading";return{pendingMedia:o,pendingImages:a,fontsLoading:s}}function Cr(n,{pendingMedia:e,pendingImages:t,fontsLoading:i},r){let o=e.map(l=>new Promise(u=>{if(l.error){u();return}let c=()=>{l.removeEventListener("canplay",c),l.removeEventListener("error",c),r.removeEventListener("abort",c),u()};l.addEventListener("canplay",c),l.addEventListener("error",c),r.addEventListener("abort",c,{once:!0})})),a=t.map(l=>l.decode?l.decode().catch(()=>{}):Promise.resolve()),s=i&&n.fonts?n.fonts.ready.then(()=>{}):Promise.resolve();return Promise.all([...o,...a,s]).then(()=>{})}function Ir(n,e,{scope:t="all"}={}){let i=Ne(n,{scope:t});return i.pendingMedia.length===0&&i.pendingImages.length===0&&!i.fontsLoading?null:Cr(n,i,e)}var Dr=50;function Pr(n,e){let t=n.defaultView;return!t||t.__renderReady||!t.__hf?null:new Promise(i=>{let r,o=()=>{r!==void 0&&clearTimeout(r),e.removeEventListener("abort",o),i()};if(e.aborted){o();return}e.addEventListener("abort",o,{once:!0});let a=()=>{if(t.__renderReady){o();return}r=setTimeout(a,Dr)};a()})}var Lr=50,Nr=1.5,Or=2,Fr=1500;function pt(n,e){return new Promise(t=>{if(e.aborted){t(-1);return}let i=0,r=()=>{n.cancelAnimationFrame?.(i),t(-1)};e.addEventListener("abort",r,{once:!0}),i=n.requestAnimationFrame(o=>{e.removeEventListener("abort",r),t(o)})})}function Ur(n,e){let t=n.defaultView;return t?(async()=>{let i=await pt(t,e);if(e.aborted)return;let r=await pt(t,e),o=r-i,a=0;for(;!e.aborted&&a<Or;){if(r-i>=Fr)return;let s=await pt(t,e);if(e.aborted)return;let l=s-r;o=Math.min(o,l),a=l<Lr||l<=o*Nr?a+1:0,r=s}})():null}var Hr=8e3;function Vr(n,e,t={}){let i=t.inputs??[(u,c)=>Ir(u,c,{scope:t.scope}),Pr,Ur],r=new AbortController,o=i.map(u=>u(n,r.signal)).filter(u=>u!==null);if(o.length===0){e({timedOut:!1});return}let a=t.timeoutMs??Hr,s,l=new Promise(u=>{s=setTimeout(()=>u("timed-out"),a)});Promise.race([Promise.all(o).then(()=>"done"),l]).then(u=>{clearTimeout(s),r.abort(),e({timedOut:u==="timed-out"})})}function Wn(n,e,t={}){Vr(n,e,{...t,scope:Y})}function ft(n,e,t){for(let i of e){let r=n.getAttribute(i);if(r===null||r.trim()==="")continue;let o=Number(r);if(Number.isFinite(o))return o}return t}function ht(n){return{start:ft(n,["data-start"],0),duration:ft(n,["data-duration"],0),mediaStart:Ae(e=>n.getAttribute(e)),playbackRate:ft(n,["data-playback-rate"],1)}}function Oe(n){return n+1e-5}function Bn(){let{userAgent:n,maxTouchPoints:e}=navigator;return/iP(hone|ad|od)/.test(n)||/Macintosh/.test(n)&&e>1}var Wr=[[.3,.25],[.1,.1]],Br=.01,$r=.1,Gr=.1,me=new WeakMap;function $n(n,e,t,i,r=n.tagName==="AUDIO"){let o=Math.abs(e);if(r&&i&&o>Gr)return me.delete(n),{rate:t,seek:!0};let a=Math.sign(e),s=me.get(n);if(o>.04)me.set(n,a);else if(s!==a||o<=Br)return me.delete(n),{rate:t,seek:!1};let l=Wr.find(([c])=>o>c)?.[1]??.03,u=r?Math.min(l,$r):l;return{rate:t*(1+a*u),seek:!1}}function Gn(n){me.delete(n)}var zr=.004,jr=1.5,Fe=class{_entries=[];_mediaObserver;_playbackErrorPosted=!1;_audioOwner="runtime";_urlAudioEntry=null;_urlAudioSrc=null;_dispatchEvent;_getMuted;_getVolume;_getPlaybackRate;_getCurrentTime;_isPaused;constructor(e){this._dispatchEvent=e.dispatchEvent,this._getMuted=e.getMuted,this._getVolume=e.getVolume,this._getPlaybackRate=e.getPlaybackRate,this._getCurrentTime=e.getCurrentTime,this._isPaused=e.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;let e=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll();for(let t of this._entries)t!==this._urlAudioEntry&&(t.el.src="");this._entries=this._urlAudioEntry?[this._urlAudioEntry]:[],this._urlAudioSrc&&!this._urlAudioEntry&&(this._urlAudioEntry=this._createEntry(this._urlAudioSrc,"audio",0,1/0)),this.teardownObserver(),e&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(let e of this._entries)e.el.pause(),e.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(e){for(let t of this._entries)t.el.muted=e}updateVolume(e){for(let t of this._entries)t.el.volume=e}updatePlaybackRate(e){for(let t of this._entries)t.el.playbackRate=e}_playEntry(e){e.el.src&&e.el.play().catch(t=>this._reportPlaybackError(t))}_playEntryIfActive(e){this._refreshEntryBounds(e),this._inWindow(e,this._getCurrentTime())&&this._playEntry(e)}_refreshEntryBounds(e){if(!e.source?.isConnected)return;let t=et(e.source);e.start=t.start??0,e.mediaStart=ht(e.source).mediaStart,e.duration=t.duration!=null&&t.duration>0?t.duration:Number.POSITIVE_INFINITY}_inWindow(e,t){return ct(t,e.start,e.start+e.duration)}_preseekUpcoming(e,t){let i=e.start-t;i<=0||i>jr||!e.el.paused||Math.abs(e.el.currentTime-e.mediaStart)>.04&&this._seekTo(e,e.mediaStart)}_seekTo(e,t,i=!1){let r=i?(e.seekLatency??0)*this._getPlaybackRate():0;e.seekIssuedAt=i?performance.now():void 0,e.el.currentTime=Oe(t+r)}_noteSeekLanded(e){if(e.seekIssuedAt===void 0)return;let t=(performance.now()-e.seekIssuedAt)/1e3;e.seekLatency=e.seekLatency===void 0?t:(e.seekLatency+t)/2,e.seekIssuedAt=void 0}_releaseSteering(e){Gn(e.el),e.lastOffset=void 0;let t=this._getPlaybackRate();e.el.playbackRate!==t&&(e.el.playbackRate=t)}_mediaTime(e,t){return t-e.start+e.mediaStart}_gateEntryPlayback(e,t){return this._inWindow(e,t)?(this._audioOwner==="parent"&&!this._isPaused()&&e.el.paused&&this._playEntry(e),!0):(e.el.paused||e.el.pause(),this._releaseSteering(e),!1)}playAll(){for(let e of this._entries)this._playEntryIfActive(e)}primeAll(){if(Bn())for(let e of this._entries)e.el.paused&&(e.el.play().catch(()=>{}),e.el.pause())}pauseAll(){for(let e of this._entries)e.el.pause()}stopAdoptedMedia(){for(let e of this._entries)e.source&&e.el.pause()}seekAll(e){for(let t of this._entries)this._refreshEntryBounds(t),this._inWindow(t,e)&&this._jumpTo(t,this._mediaTime(t,e))}scrubAll(e){for(let t of this._entries)this._refreshEntryBounds(t),this._inWindow(t,e)?(this._jumpTo(t,this._mediaTime(t,e)),this._playEntry(t)):t.el.paused||t.el.pause()}mirrorTime(e,t){let i=t?.force===!0;for(let r of this._entries){this._refreshEntryBounds(r),this._preseekUpcoming(r,e);let o=r.el.paused;if(!this._gateEntryPlayback(r,e))continue;let a=this._mediaTime(r,e),s=a-r.el.currentTime;if(i||o){Math.abs(s)>.04&&this._jumpTo(r,a);continue}this._steer(r,a,s)}}_steer(e,t,i){let r=e.lastOffset!==void 0&&Math.abs(i-e.lastOffset)<zr;e.lastOffset=i;let{rate:o,seek:a}=$n(e.el,i,this._getPlaybackRate(),r,!0);a?this._jumpTo(e,t,!0):Math.abs(e.el.playbackRate-o)>1e-6&&(e.el.playbackRate=o)}_jumpTo(e,t,i=!1){this._seekTo(e,t,i),this._releaseSteering(e)}promoteToParentProxy(e,t){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",e)for(let r of e.querySelectorAll("video, audio"))w(r)&&(r.muted=!0);for(let r of[...this._entries])this._repointToSource(r);let i=this._getCurrentTime();t?t(i,{force:!0}):this.mirrorTime(i,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(e){let t=e.querySelectorAll("audio[data-start], video[data-start]");for(let i of t)w(i)&&this._adoptIframeMedia(i);this._observeDynamicMedia(e)}setupFromUrl(e){if(this._urlAudioSrc===e&&this._urlAudioEntry)return;this.teardownUrlAudio();let t=this._createEntry(e,"audio",0,1/0);this._urlAudioEntry=t,this._urlAudioSrc=e,t&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){let e=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!e)return;e.el.pause(),e.el.src="";let t=this._entries.indexOf(e);t!==-1&&this._entries.splice(t,1)}teardownObserver(){this._mediaObserver?.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(e){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:e}})))}_createEntry(e,t,i,r,o){if(!o&&this._urlTaken(e))return null;let a=t==="video"?document.createElement("video"):new Audio;a.preload="auto";let s=o?.getAttribute("crossorigin");s!=null&&a.setAttribute("crossorigin",s),a.src=e,a.load(),a.muted=this._getMuted(),a.volume=this._getVolume();let l=this._getPlaybackRate();l!==1&&(a.playbackRate=l);let u={el:a,start:i,duration:r,mediaStart:o?ht(o).mediaStart:0,source:o};return a.addEventListener("seeked",()=>this._noteSeekLanded(u)),this._entries.push(u),u}_resolveIframeMediaSrc(e){let t=e.getAttribute("src")||e.querySelector("source")?.getAttribute("src");return t?new URL(t,e.ownerDocument.baseURI).href:null}_adoptIframeMedia(e){if(e.preload==="metadata"||e.preload==="none"||this._entries.some(l=>l.source===e)||e.tagName==="VIDEO"&&e.hasAttribute("muted"))return;let t=this._resolveIframeMediaSrc(e);if(!t)return;let i=et(e),r=i.start??0,o=i.duration??Number.POSITIVE_INFINITY,a=e.tagName==="VIDEO"?"video":"audio",s=this._createEntry(t,a,r,o,e);s&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(s))}_followIframeMediaSrc(e){let t=this._entries.find(i=>i.source===e);if(!t)return this._adoptIframeMedia(e);this._audioOwner!=="parent"||!this._repointToSource(t)||(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(t))}_urlTaken(e){return this._entries.some(t=>t.source&&!t.source.isConnected?!1:(t.source&&this._resolveIframeMediaSrc(t.source)||t.el.src)===e)}_repointToSource(e){let t=e.source?this._resolveIframeMediaSrc(e.source):null;return!t||e.el.src===t?!1:(e.el.src=t,e.el.load(),!0)}_detachIframeMedia(e){let t=this._entries.find(i=>i.source===e);t&&this._removeEntry(t)}_removeEntry(e){e.el.pause(),e.el.src="",this._entries.splice(this._entries.indexOf(e),1)}_observeDynamicMedia(e){if(this.teardownObserver(),typeof MutationObserver>"u"||!e.body)return;let t=new MutationObserver(o=>{for(let a of o){if(a.type==="attributes"&&a.attributeName==="src"){let s=a.target;w(s)&&s.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(s);continue}if(a.type==="attributes"&&a.attributeName==="preload"){let s=a.target;w(s)&&s.matches("audio[data-start], video[data-start]")&&(s.preload==="auto"?this._adoptIframeMedia(s):this._detachIframeMedia(s));continue}for(let s of a.addedNodes){if(!ce(s))continue;let l=[];w(s)&&s.matches("audio[data-start], video[data-start]")&&l.push(s);let u=s.querySelectorAll("audio[data-start], video[data-start]");for(let c of u)w(c)&&l.push(c);for(let c of l)this._adoptIframeMedia(c)}for(let s of a.removedNodes){if(!ce(s))continue;let l=[];w(s)&&s.matches("audio[data-start], video[data-start]")&&l.push(s);let u=s.querySelectorAll("audio[data-start], video[data-start]");for(let c of u)w(c)&&l.push(c);for(let c of l)this._detachIframeMedia(c)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},r=Cn(e);for(let o of r)t.observe(o,i);this._mediaObserver=t}};function bt(n,e,t){if(n===null&&e===null)return{range:null,clamped:!1};let i=n??0,r=e!==null&&t>0&&e>t,o=r?t:e,a=o??(t>0?t:1/0);return!(i>=0)||!(a>i)?{range:null,clamped:!0}:{range:{start:i,end:o},clamped:r}}function pe(n,e,t){let i=n.end??e;return i<e?On(n.start,i,t):i}function gt(n,e,t,i){return n<e.start||n>=pe(e,t,i)}var qr=100;function Yr(n,e){return typeof n.currentTime=="number"&&Number.isFinite(n.currentTime)?n.currentTime:(n.frame??0)/e}function jn(n,e,t){return t<=0?!1:n.ended===!0?!0:n.ended===!1&&!n.isPlaying?!1:e>=t}function Xr(n,e,t,i,r,o){let{duration:a}=t;if(!r){let s=jn(n,e,a);return{start:0,shownAtEnd:a,atEnd:s,stopRuntime:!1,entering:!1}}if(n.ownsRange){let s=i&&n.ended===!0&&!n.isPlaying;return{start:r.start,shownAtEnd:e,atEnd:s,stopRuntime:!1,entering:!1}}return Kr(n,e,t,i,r,o)}function Kr(n,e,t,i,r,o){let a=r.end??t.duration,s=t.enteringRange===!0&&(e<r.start||e>=a);return{start:r.start,shownAtEnd:pe(r,t.duration,o),atEnd:i&&!s&&jn(n,e,a),stopRuntime:n.isPlaying,entering:s}}function qn(n,e,t,i){let r=Yr(n,e),o=!t.paused,a=o||n.isPlaying,s=i.getPlayRange?.(),l=Xr(n,r,t,a,s,e),{atEnd:u,start:c}=l,h=t.duration>0?Math.min(r,t.duration):r,v=u?l.shownAtEnd:h,b=!n.isPlaying,S=u&&a;if(S&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(c),i.play(),{...t,currentTime:c,paused:!1,enteringRange:!0};let _={...t,currentTime:v,paused:b,enteringRange:l.entering};i.media.audioOwner==="parent"&&(o&&b?i.media.pauseAll():!o&&!b&&i.media.playAll(),i.media.mirrorTime(v));let A=performance.now(),C=b!==t.paused;return(A-t.lastUpdateMs>qr||C)&&(_.lastUpdateMs=A,i.updateControlsTime(v,t.duration),i.updateControlsPlaying(!b),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:v}}))),S&&(l.stopRuntime&&i.seek(v),i.media.audioOwner==="parent"&&i.media.pauseAll(),_.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),_}function Zr(n){return Array.isArray(n)?n.filter(e=>typeof e=="object"&&e!==null&&typeof e.id=="string"&&typeof e.start=="number"&&typeof e.duration=="number"):[]}function Yn(n,e,t){if(n.source!==e)return;let i=n.data;if(!i||i.source!=="hf-preview")return;let r=Un(i);if(r.status==="unsupported"){t.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:r.code,receivedVersion:r.receivedVersion}}));return}t.setRuntimeFps?.(r.fps);let o=r.status==="supported"&&r.metadata.capabilities.includes("play-range");if(t.setRuntimeOwnsPlayRange?.(o),i.type==="shader-transition-state"){let a=i.state&&typeof i.state=="object"?i.state:{};t.shaderLoader.update(a,t.getShaderLoadingMode()),t.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:a}}));return}if(i.type==="ready"){t.onRuntimeReady();return}if(i.type==="assets-ready"){t.onRuntimeAssetsReady?.(i.timedOut===!0);return}if(i.type==="runtime-data-error"){t.onRuntimeDataError?.(i.channel,i.requestId,i.message);return}if(i.type==="runtime-data-applied"){t.onRuntimeDataApplied?.(i.channel,i.requestId);return}if(i.type==="state"){t.setPlaybackState(qn({frame:i.frame??0,currentTime:i.currentTime,ended:typeof i.ended=="boolean"?i.ended:void 0,isPlaying:!!i.isPlaying,ownsRange:o},r.fps,t.getPlaybackState(),t)),t.setBuffering?.(i.buffering===!0);return}if(i.type==="media-autoplay-blocked"){if(t.shouldPromoteMediaAutoplayFallback?.()===!1)return;let a=null;try{a=t.getIframeDoc()}catch{}t.media.promoteToParentProxy(a,(s,l)=>t.media.mirrorTime(s,l)),t.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){let a=Number(i.durationSeconds),s=Number(i.durationInFrames),l=Number.isFinite(a)&&a>0?a:s/r.fps;if(Number.isFinite(i.compositionWidth)&&i.compositionWidth>0&&Number.isFinite(i.compositionHeight)&&i.compositionHeight>0&&t.setCompositionSize(i.compositionWidth,i.compositionHeight),Number.isFinite(l)&&l>0){let u=t.getPlaybackState();t.setPlaybackState({...u,duration:l}),t.updateControlsTime(u.currentTime,l),t.onRuntimeTimelineReady(l,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}t.setScenes(Zr(i.scenes));return}i.type==="stage-size"&&Number.isFinite(i.width)&&i.width>0&&Number.isFinite(i.height)&&i.height>0&&t.setCompositionSize(i.width,i.height)}function Jr(n,e){return n.includes(e)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(n)}var Qr=new Set([">"," "," ",`
478
- `,"\r","\f"]);function _t(n,e){let t=n.toLowerCase(),i=`<${e}`,r=0;for(;r<t.length;){let o=t.indexOf(i,r);if(o<0)return null;let a=t[o+i.length];if(Qr.has(a)){let s=t.indexOf(">",o+i.length);return s<0?null:{index:o,end:s+1}}r=o+i.length}return null}function Xn(n,e){if(!n||Jr(n,e))return n;let t=`<script src="${e}"></script>`,i=_t(n,"head");if(i)return n.slice(0,i.end)+t+n.slice(i.end);let r=_t(n,"body");if(r)return n.slice(0,r.index)+t+n.slice(r.index);let o=_t(n,"html");return o?n.slice(0,o.end)+t+n.slice(o.end):t+n}var B="shader-capture-scale",X="shader-loading",Ue="runtime-src",Kn="__hf_shader_capture_scale",Zn="__hf_shader_loading",K=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function yt(n){if(n===null)return null;let e=Number(n);return!Number.isFinite(e)||e<=0?null:String(Math.min(1,Math.max(.25,e)))}function eo(n){if(n===null||n.trim()==="")return"composition";let e=n.trim().toLowerCase();return e==="none"||e==="false"||e==="0"||e==="off"?"none":e==="player"||e==="true"||e==="1"||e==="on"?"player":"composition"}function Jn(n,e){return n.filter(t=>t!==""&&t.split("=")[0]!==e)}function to(n,e,t){let i=n.indexOf("#"),r=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i):"",a=r.indexOf("?"),s=a>=0?r.slice(0,a):r,l=a>=0?r.slice(a+1):"",u=Jn(l.split("&"),Kn);u=Jn(u,Zn),e!==null&&u.push(`${Kn}=${encodeURIComponent(e)}`),t!=="composition"&&u.push(`${Zn}=${encodeURIComponent(t)}`);let c=u.join("&");return`${s}${c?`?${c}`:""}${o}`}function no(n,e,t){if(e===null&&t==="composition")return n;let i=[];e!==null&&i.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(e)};`),t!=="composition"&&i.push(`window.__HF_SHADER_LOADING=${JSON.stringify(t)};`);let r=`<script data-hyperframes-player-shader-options>${i.join("")}</script>`;return/<head\b[^>]*>/i.test(n)?n.replace(/<head\b[^>]*>/i,o=>`${o}${r}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b[^>]*>/i,o=>`${o}${r}`):`${r}${n}`}function fe(n){return eo(n.getAttribute(X))}function Qn(n){return Number(yt(n.getAttribute(B))??"1")}function ei(n,e){return to(e,yt(n.getAttribute(B)),fe(n))}function he(n,e){return Xn(no(e,yt(n.getAttribute(B)),fe(n)),vt(n))}function vt(n){let e=n.getAttribute(Ue)?.trim();if(!e)return q;try{let t=new URL(e,document.baseURI),i=t.protocol==="http:"||t.protocol==="https:",r=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]";return i&&(r||t.origin===location.origin)?t.href:q}catch{return q}}function ti(){let n=document.createElement("div");n.className="hfp-shader-loader",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-label","Preparing scene transitions"),n.setAttribute("data-hyperframes-ignore",""),n.draggable=!1;let e=b=>{b.preventDefault(),b.stopPropagation()};for(let b of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])n.addEventListener(b,e,{capture:!0});let t=document.createElement("div");t.className="hfp-shader-loader-panel",t.draggable=!1;let i=document.createElement("div");i.className="hfp-shader-loader-mark",i.draggable=!1,i.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("");let r=document.createElement("div");r.className="hfp-shader-loader-title";let o=document.createElement("span");o.className="hfp-shader-loader-title-text",o.textContent=K[0]||"Preparing scene transitions",r.appendChild(o);let a=document.createElement("div");a.className="hfp-shader-loader-detail",a.textContent="Rendering animated scene samples for shader transitions.";let s=document.createElement("div");s.className="hfp-shader-loader-track",s.setAttribute("aria-hidden","true");let l=document.createElement("div");l.className="hfp-shader-loader-fill",s.appendChild(l);let u=document.createElement("div");u.className="hfp-shader-loader-progress";let c=b=>{let S=document.createElement("div");S.className="hfp-shader-loader-row";let _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=b;let A=document.createElement("span");return A.className="hfp-shader-loader-value",S.appendChild(_),S.appendChild(A),u.appendChild(S),{row:S,label:_,value:A}},h=c("transition"),v=c("transition frame");return t.appendChild(i),t.appendChild(r),t.appendChild(a),t.appendChild(s),t.appendChild(u),n.appendChild(t),{root:n,fill:l,title:o,detail:a,transitionValue:h.value,transitionRow:h.row,frameLabel:v.label,frameValue:v.value,frameRow:v.row}}var io=420;function He(n,e,t){e.textContent=t,n.style.visibility=t?"visible":"hidden"}var Ve=class{_el;_hideTimeout=null;_hiddenCallbacks=[];_drawingAssets=!1;constructor(e){this._el=e}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(e){let t=this._el.root.classList;t.contains("hfp-visible")||t.contains("hfp-hiding")?this._hiddenCallbacks.push(e):e()}_flushHidden(){let e=this._hiddenCallbacks;this._hiddenCallbacks=[];for(let t of e)t()}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)",He(this._el.transitionRow,this._el.transitionValue,""),He(this._el.frameRow,this._el.frameValue,"")}update(e,t){let i=t==="player"&&e.loading&&!e.ready;if(this._drawingAssets&&!i)return;if(t!=="player"){this.reset();return}if(e.ready||!e.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions"),this._drawingAssets=!1;let r=typeof e.progress=="number"&&Number.isFinite(e.progress)?e.progress:0,o=typeof e.total=="number"&&Number.isFinite(e.total)?e.total:0,a=o>0?Math.min(1,Math.max(0,r/o)):0,s=Math.min(K.length-1,Math.floor(a*K.length));this._el.title.textContent=K[s]||"Preparing scene transitions",this._el.detail.textContent=e.phase==="cached"?"Loading cached transition frames before playback.":e.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${a})`;let l=e.currentTransition!==void 0&&e.transitionTotal!==void 0?`${e.currentTransition}/${e.transitionTotal}`:o>0?`${r}/${o}`:"",u=e.transitionFrame!==void 0&&e.transitionFrames!==void 0?`${e.transitionFrame}/${e.transitionFrames}`:"";this._el.frameLabel.textContent=e.phase==="cached"?"cached transition frames":e.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",He(this._el.transitionRow,this._el.transitionValue,l),He(this._el.frameRow,this._el.frameValue,u),this._el.root.setAttribute("aria-valuenow",String(Math.round(a*100))),this.show()}showAssetsLoading(e="Loading assets",t="Waiting for images, video and fonts to finish loading."){this.reset(),this._el.title.textContent=e,this._el.detail.textContent=t,this._el.root.setAttribute("aria-label",e),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()},io)}};function ni(n){return n?.trim().toLowerCase().startsWith("video/")??!1}function ii(n){let e=document.createElement("video");e.className="hfp-video",e.playsInline=!0,e.preload="metadata";let t=new AbortController,{signal:i}=t;return e.addEventListener("loadedmetadata",()=>n.onMetadata(e),{signal:i}),e.addEventListener("durationchange",()=>n.onDurationChange(e),{signal:i}),e.addEventListener("resize",()=>n.onResize(e),{signal:i}),e.addEventListener("play",()=>n.onPlay(e),{signal:i}),e.addEventListener("pause",()=>n.onPause(e),{signal:i}),e.addEventListener("timeupdate",()=>n.onTimeUpdate(),{signal:i}),e.addEventListener("error",()=>n.onError(e.error?.message||"Video failed to load",e.error?.code??null),{signal:i}),{video:e,adapter:{duration:()=>e.duration,time:()=>e.currentTime,seek:o=>{e.currentTime=Oe(o)},play:()=>e.play().catch(o=>{i.aborted||n.onPlayRejected(o)}),pause:()=>e.pause(),timeScale:o=>{e.defaultPlaybackRate=o,e.playbackRate=o}},destroy:()=>{t.abort(),e.pause(),e.removeAttribute("src"),e.load(),e.remove()}}}var ro=.1,oo=5,St="sandbox-origin",ri=1e4,At=8e3,Et="assets-loading",be="assets-loading-ui",We="buffering",Tt="low-power-idle",oi="disable-click-to-play",ge="range-start",_e="range-end",ai=150;function Rt(n){return!Number.isFinite(n)||n<=0?1:Math.max(ro,Math.min(oo,n))}var Be=class extends HTMLElement{static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src","type",St,Ue,B,X,be,Tt,ge,_e]}shadow;container;sizer=document.createElement("div");iframe;posterEl=null;controlsApi=null;resizeObserver;shaderLoader;probe;_ready=!1;_readyDocument=null;_connected=!1;_assetsReady=!1;_painted=!1;_pendingPlay=!1;_assetsGeneration=0;_assetsLoadingShowTimer=null;_bufferingShowTimer=null;_currentTime=0;_duration=0;_paused=!0;_scrubbing=!1;_lastUpdateMs=0;_volume=1;_compositionWidth=1920;_compositionHeight=1080;_rescaleWarned=!1;_directTimelineAdapter=null;_directTimelineClock;_parentTickRaf=null;_media;_scenes=[];_runtimeFps=30;_runtimeBridgeReady=!1;_runtimeAssetsReadyGeneration=-1;_runtimeData=new Map;_runtimeDataRequestId=0;_pendingRuntimeData=new Map;_afterUpdate=null;_videoSource=null;_runtimeOwnsPlayRange=!1;_enteringRange=!1;_rangeClampReported="";constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),wn(this.shadow,vn),{container:this.container,iframe:this.iframe}=kn(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);let e=ti();this.shadow.appendChild(e.root),this.shaderLoader=new Ve(e),this._media=new Fe({dispatchEvent:t=>this._emit(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Pe({onTimeUpdate:(t,i)=>{this._currentTime=t,this.controlsApi?.updateTime(t,i),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:t}}))},getLoop:()=>this.loop,restart:()=>{this.seek(this._playRange()?.start??0),this.play()},onPaused:()=>{this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this._emit(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new Ce(this.iframe,{resolveRuntimeUrl:()=>vt(this),hostOwnsDeadline:()=>this.hasAttribute("no-load-timeout"),onReady:t=>this._onProbeReady(t),onError:t=>this._emit(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{this.disableClickToPlay||xn(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)}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=dt(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=he(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){this._connected=!1,this._teardownVideo(),this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),this.controlsApi?.destroy(),this.controlsApi=null,this._paused=!0,this._pendingPlay=!1,this._abandonComposition("Player disconnected before runtime data was applied")}attributeChangedCallback(e,t,i){switch(e){case"src":if(!this.isConnected)break;i&&this._navigateSrc(i);break;case"type":{let r=this.getAttribute("src");if(!this.isConnected||r===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(r);break}case"srcdoc":if(!this.isConnected)break;if(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),i!==null)this._pauseForVideoSwitch(),this._teardownVideo(),this.iframe.srcdoc=he(this,i);else{this.iframe.removeAttribute("srcdoc");let r=this.getAttribute("src");r!==null&&this._wantsVideo()&&this._navigateSrc(r)}break;case St:this._applySandboxOriginPolicy(this.isConnected&&t!==i);break;case"width":this._setCompositionSize(de(i)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,de(i)??1080);break;case"controls":i!==null?this._setupControls():(this.controlsApi?.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=dt(this.shadow,i,this.posterEl);break;case"playback-rate":{let r=Rt(parseFloat(i||"1"));this._media.updatePlaybackRate(r),this._sendControl("set-playback-rate",{playbackRate:r}),this._directTimelineAdapter?.timeScale?.(r),this.controlsApi?.updateSpeed(r),this._emit(new Event("ratechange"));break}case"muted":this._handleMutedChange(i);break;case"audio-locked":this._applyAudioLock(i!==null);break;case"volume":{let r=Math.max(0,Math.min(1,parseFloat(i||"1")));this._volume=r,this._syncVideoAudio(),this._media.updateVolume(r),this._sendControl("set-volume",{volume:r}),this.controlsApi?.updateVolume(r),this._emit(new Event("volumechange"));break}case"audio-src":i?this._media.setupFromUrl(i):this._media.teardownUrlAudio();break;case be:i==="none"&&this.shaderLoader.hideAssetsLoading();break;case Tt:this._sendControl("set-idle-heartbeat",{slow:i!==null});break;case ge:case _e:this._applyPlayRange(!0);break;case B:case X:case Ue:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(St)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){if(this._videoSource)return;this._abandonComposition("Sandbox policy changed before runtime data was applied");let e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=he(this,e);return}let t=this.getAttribute("src");t===null?this.iframe.src="about:blank":this._loadSrc(t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){this._play(!0)}_play(e){if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,this.posterEl?.remove(),this.posterEl=null;let t=this._ready?this._playRange():null;t?gt(this._currentTime,t,this._duration,this._runtimeFps)&&(this.seek(t.start),this._enteringRange=!0):this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;let i=this._tryDirectTimelinePlay(),r=!1;this._sendDisplayScale(),i||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,r=!0)),this._media.audioOwner==="parent"?this._media.playAll():this._media.primeAll(),this.controlsApi?.updatePlaying(!0),!r&&e&&this._emit(new Event("play")),i&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused,()=>this._clockStop())}pause(){this._pendingPlay=!1,this._tryDirectTimelinePause()?this._showPausedVideoTime():this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this._emit(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){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,this.controlsApi?.updatePlaying(!1),this.controlsApi?.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");let i=structuredClone(t);this._runtimeData.set(e,i),this._deliverRuntimeData(e,i)}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 Rt(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(Rt(e)))}get shaderCaptureScale(){return Qn(this)}set shaderCaptureScale(e){this.setAttribute(B,String(e))}get shaderLoading(){return fe(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(X):this.setAttribute(X,e)}get assetsLoadingUi(){return this.getAttribute(be)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(be,"none"):this.removeAttribute(be)}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;let 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){if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._syncVideoAudio(),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),this.controlsApi?.updateMuted(e!==null),this._emit(new Event("volumechange"))}_applyAudioLock(e){e&&(this.muted=!0),this.controlsApi?.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(oi)}set disableClickToPlay(e){this.toggleAttribute(oi,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(ge)}set rangeStart(e){this._writeSeconds(ge,e)}get rangeEnd(){return this._readSeconds(_e)}set rangeEnd(e){this._writeSeconds(_e,e)}_readSeconds(e){let t=this.getAttribute(e);return t===null?null:Number(t)}_writeSeconds(e,t){t==null?this.removeAttribute(e):this.setAttribute(e,String(t))}_hasPlayRange(){return this.hasAttribute(ge)||this.hasAttribute(_e)}_playRange(){return bt(this.rangeStart,this.rangeEnd,this._duration).range}_sendPlayRange(e){let t=e?.end??null;this._sendControl("set-play-range",{startSeconds:e?.start??null,endSeconds:t})}_applyPlayRange(e){let{range:t,clamped:i}=bt(this.rangeStart,this.rangeEnd,this._duration);this._sendPlayRange(t),this._ready&&(this._reportRangeClamp(t,i),t&&e&&!this._pendingPlay&&this._moveIntoPlayRange(t))}_reportRangeClamp(e,t){let i=t?`${this.rangeStart},${this.rangeEnd},${this._duration}`:"";if(i===this._rangeClampReported||(this._rangeClampReported=i,!t))return;let r={rangeStart:e?.start??null,rangeEnd:e?.end??null};this._emit(new CustomEvent("rangeclamped",{detail:{...r,duration:this._duration}}))}_moveIntoPlayRange(e){gt(this._currentTime,e,this._duration,this._runtimeFps)&&(this._paused?this.seek(e.start):this._jumpWhilePlaying(e.start))}_jumpWhilePlaying(e){this._directTimelineAdapter?(this._directTimelineAdapter.seek(e,!1),this._currentTime=e):this._runtimeOwnsPlayRange||(this.seek(e),this._enteringRange=!0,this._play(!1))}_clockStop(){let e=this._playRange(),t=e?.end??this._duration;if(!e)return{end:t,shown:t};let i=pe(e,this._duration,this._runtimeFps);return{end:t,shown:i<t?(i+t)/2:i}}_sendControl(e,t={}){try{let i=this.iframe.contentWindow;return i?(i.postMessage({...t,source:"hf-parent",type:"control",action:e,...mt(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,"Composition iframe is unavailable"),!1)}catch(i){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,i instanceof Error?i.message:String(i)),!1}}_deliverRuntimeData(e,t){if(!this.isConnected||!this._runtimeBridgeReady)return;let i=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,t,i)||this._sendControl("set-runtime-data",{channel:e,payload:t,requestId:i})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;let t=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,t)||this._sendControl("clear-runtime-data",{channel:e,requestId:t})}_trySetRuntimeDataDirect(e,t,i){try{let r=this.iframe.contentWindow?.__hyperframes;return typeof r?.setRuntimeData!="function"?!1:(r.setRuntimeData(e,t,i),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,t){try{let i=this.iframe.contentWindow?.__hyperframes;return typeof i?.clearRuntimeData!="function"?!1:(i.clearRuntimeData(e,t),!0)}catch{return!1}}_replayRuntimeData(){for(let[e,t]of this._runtimeData)this._deliverRuntimeData(e,t)}_beginRuntimeDataDelivery(e){let t=this._pendingRuntimeData.get(e);t&&window.clearTimeout(t.timeoutId),this._runtimeDataRequestId+=1;let i=this._runtimeDataRequestId,r=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,i,`Runtime data delivery timed out after ${ri}ms`)},ri);return this._pendingRuntimeData.set(e,{requestId:i,timeoutId:r}),i}_resolveRuntimeDataDelivery(e,t){let i=this._takeRuntimeDataDelivery(e,t);i&&this._emit(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:i.requestId}}))}_rejectRuntimeDataDelivery(e,t,i){let r=this._takeRuntimeDataDelivery(e,t);r&&this._emit(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:r.requestId,message:typeof i=="string"?i:String(i)}}))}_takeRuntimeDataDelivery(e,t){if(typeof e!="string"||typeof t!="number"||!Number.isSafeInteger(t))return null;let i=this._pendingRuntimeData.get(e);return!i||i.requestId!==t?null:(window.clearTimeout(i.timeoutId),this._pendingRuntimeData.delete(e),i)}_rejectAllRuntimeDataDeliveries(e){for(let[t,i]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(t,i.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){let t=this._getSameOriginIframeDocument();if(t)for(let i of t.querySelectorAll("video, audio"))w(i)&&(i.muted=e||i.defaultMuted)}_stopIframeMedia(){let e=this._getSameOriginIframeDocument();if(e)for(let 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(Tt)}),this._sendDisplayScale()}_sendDisplayScale(){let e=Fn(this.iframe);e&&this._sendControl("set-display-scale",{scale:e})}_reloadShaderOptions(){if(!this._videoSource){if(this._abandonComposition("Shader options changed before runtime data was applied"),this.hasAttribute("srcdoc")){this.iframe.srcdoc=he(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")||"")}}_navigateSrc(e){this._pendingPlay=!1,this._pauseForVideoSwitch(),this._abandonComposition("Composition navigated before runtime data was applied"),this._loadSrc(e)}_wantsVideo(){return ni(this.getAttribute("type"))&&!this.hasAttribute("srcdoc")}_pauseForVideoSwitch(){!this._videoSource&&!this._wantsVideo()||(this._paused=!0,this.controlsApi?.updatePlaying(!1))}_loadSrc(e){if(this._wantsVideo()){this._loadVideo(e);return}this._teardownVideo(),this.iframe.src=ei(this,e)}_loadVideo(e){this._videoSource||(this._videoSource=ii({onMetadata:r=>this._applyThenEmit(()=>this._onVideoReady(r)),onDurationChange:r=>this._applyTimelineDuration(r.duration),onResize:r=>this._applyVideoSize(r),onPlay:r=>{!r.paused&&this._paused&&this.play()},onPause:r=>{r.paused&&!r.ended&&!this._paused&&this.pause()},onTimeUpdate:()=>{document.hidden&&this._playRange()&&this._directTimelineClock.poll()},onError:(r,o)=>{this._paused||this.pause(),this._emit(new CustomEvent("error",{detail:{message:r,code:o}}))},onPlayRejected:r=>this._onVideoPlayRejected(r)}),this.container.appendChild(this._videoSource.video),this.iframe.hidden=!0,this.iframe.src="about:blank"),this.probe.stop();let{video:t,adapter:i}=this._videoSource;this._directTimelineAdapter=i,this._currentTime=0,this._duration=0,this.controlsApi?.updateTime(0,0),this._syncVideoAudio(),i.timeScale?.(this.playbackRate),t.src=e}_teardownVideo(){this._videoSource&&(this._videoSource.destroy(),this._videoSource=null,this.iframe.hidden=!1)}_syncVideoAudio(){this._videoSource&&(this._videoSource.video.muted=this.muted,this._videoSource.video.volume=this._volume)}_onVideoReady(e){this._applyTimelineDuration(e.duration),this._applyVideoSize(e),this._ready=!0,this._dispatchReady(),this._waitForAssetsReady(null),this._afterEvents(()=>{this.hasAttribute("autoplay")&&this._paused&&this.play()})}_applyTimelineDuration(e){!Number.isFinite(e)||e<=0||(this._setDuration(e),this.controlsApi?.updateTime(this._currentTime,e))}_applyVideoSize(e){e.videoWidth>0&&e.videoHeight>0&&this._setCompositionSize(e.videoWidth,e.videoHeight)}_onVideoPlayRejected(e){e instanceof DOMException&&e.name==="NotAllowedError"&&(this._paused||this.pause(),this._emit(new CustomEvent("playbackerror",{detail:{source:"video",error:e}})))}_trySyncSeek(e){if(this._videoSource)return!1;try{let i=this.iframe.contentWindow?.__player;return typeof i?.seek!="function"?!1:(i.seek.call(i,e),!0)}catch{return!1}}_withDirectTimeline(e){let t=this._videoSource?null:this.probe.resolveDirectTimelineAdapter(),i=t||this._directTimelineAdapter;if(!i)return!1;try{return e(i),t&&t!==this._directTimelineAdapter&&this._applyTimelineDuration(t.duration()),this._directTimelineAdapter=i,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(t=>{t.seek(e,!1),t.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>{e.play()})}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>{e.pause()})}_showPausedVideoTime(){this._videoSource&&(this._currentTime=this._videoSource.video.currentTime,this.controlsApi?.updateTime(this._currentTime,this._duration),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}})))}_startParentTickClock(){this._stopParentTickClock();let e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){this._videoSource||this.probe.failed||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){Yn(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs,enteringRange:this._enteringRange}),setPlaybackState:({currentTime:t,duration:i,paused:r,lastUpdateMs:o,enteringRange:a})=>{this._enteringRange=a===!0,this._currentTime=t,this._setDuration(i),this._paused=r,this._lastUpdateMs=o},getShaderLoadingMode:()=>fe(this),shaderLoader:this.shaderLoader,setCompositionSize:(t,i)=>this._setCompositionSize(t,i),sendControl:(t,i)=>this._sendControl(t,i),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._hasPlayRange()&&this._sendPlayRange(this._playRange()),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(t,i)=>this._resolveRuntimeDataDelivery(t,i),onRuntimeDataError:(t,i,r)=>this._rejectRuntimeDataDelivery(t,i,r),onRuntimeTimelineReady:(t,i)=>this._onRuntimeTimelineReady(t,i),setBuffering:t=>this._setBuffering(t),setRuntimeFps:t=>{this._runtimeFps=t},setRuntimeOwnsPlayRange:t=>{this._runtimeOwnsPlayRange=t},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:t=>{this._scenes=t,this._emit(new CustomEvent("scenes",{detail:{scenes:t}}))},updateControlsTime:(t,i)=>this.controlsApi?.updateTime(t,i),updateControlsPlaying:t=>this.controlsApi?.updatePlaying(t),dispatchEvent:t=>this._emit(t),seek:t=>this.seek(t),play:()=>this.play(),getLoop:()=>this.loop,getPlayRange:()=>this._playRange(),media:this._media})}_onRuntimeTimelineReady(e,t){if(this._ready)return;this.probe.stop(),this._setDuration(e),this._directTimelineAdapter=null,this._ready=!0,this.controlsApi?.updateTime(this._currentTime,e),this._dispatchReady();let i=this._getSameOriginIframeDocument();i&&this._media.setupFromIframe(i),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(i,t),this._playWhenWanted()}_onProbeReady(e){this._applyThenEmit(()=>this._applyProbeResult(e))}_applyProbeResult({duration:e,adapter:t,compositionSize:i}){this._setDuration(e),this._directTimelineAdapter=t.kind==="direct-timeline"?t.timeline:null,i&&this._setCompositionSize(i.width,i.height),this._ready=!0,this.controlsApi?.updateTime(0,e),this._dispatchReady();let r=this._getSameOriginIframeDocument();r&&this._media.setupFromIframe(r),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(r),this._playWhenWanted()}_waitForAssetsReady(e,t){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1;let i=++this._assetsGeneration;if(!e){t===!1?(this._runtimeAssetsReadyGeneration=i,this._startAssetsLoadingOverlayTimer(i),setTimeout(()=>this._settleAssetsReady(i),At)):this._settleAssetsReady(i);return}Wn(e,({timedOut:r})=>{i===this._assetsGeneration&&(r&&this._warnStuckAssets(e),this._settleAssetsReady(i))},{timeoutMs:At}),this._assetsReady||this._startAssetsLoadingOverlayTimer(i)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(Et,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},ai)}_setBuffering(e){if(e){if(this._bufferingShowTimer!==null||this.hasAttribute(We))return;this._bufferingShowTimer=setTimeout(()=>{this._bufferingShowTimer=null,this.setAttribute(We,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading("Buffering","")},ai);return}this._bufferingShowTimer!==null&&clearTimeout(this._bufferingShowTimer),this._bufferingShowTimer=null,this.hasAttribute(We)&&(this.removeAttribute(We),this.shaderLoader.hideAssetsLoading())}_hasPendingFirstFrameAssets(e){let{pendingMedia:t,pendingImages:i,fontsLoading:r}=Ne(e,{scope:Y});return t.length>0||i.length>0||r}_warnStuckAssets(e){let{pendingMedia:t,pendingImages:i,fontsLoading:r}=Ne(e,{scope:Y}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${At}ms, playing anyway`,{stuckMedia:t.map(a=>a.currentSrc||a.getAttribute("src")||`<${a.tagName.toLowerCase()}>`),stuckImages:i.map(a=>a.currentSrc||a.getAttribute("src")||"<img>"),fontsLoading:r,computeReady:o?.__renderReady===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(Et),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this.probe.stop(),this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._runtimeOwnsPlayRange=!1,this._enteringRange=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this._setBuffering(!1),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(Et),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_dispatchReady(){this._readyDocument=this._getSameOriginIframeDocument();let e={duration:this._duration,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight};this._emit(new CustomEvent("ready",{detail:e})),this._rescale(),this._rangeClampReported="",this._hasPlayRange()&&this._applyPlayRange(!0)}_setDuration(e){e!==this._duration&&(this._duration=e,this._ready&&(this._emit(new CustomEvent("durationchange",{detail:{duration:e}})),this._hasPlayRange()&&this._applyPlayRange(!1)))}_setCompositionSize(e,t){let i=e!==this._compositionWidth||t!==this._compositionHeight;if(this._compositionWidth=e,this._compositionHeight=t,this.sizer.style.aspectRatio=`${e} / ${t}`,this._rescale(),!i)return;let r={compositionWidth:e,compositionHeight:t};this._emit(new CustomEvent("resize",{detail:r}))}_applyThenEmit(e){if(this._afterUpdate){e();return}let t=[];this._afterUpdate=t;let i=[],r=o=>{try{o()}catch(a){i.push(a)}};r(e);for(let o of t)r(o);if(this._afterUpdate=null,i.length>0)throw i[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(){let e=Mn(this,this.iframe,this._compositionWidth,this._compositionHeight);e&&this._sendDisplayScale(),!e&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready: zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){if(!this._connected||this._videoSource)return;let 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=Rn(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=>{this.playbackRate=e},onMuteToggle:()=>{this.muted=!this.muted},onVolumeChange:e=>{this.volume=e}},this._isAudioLocked()),this.controlsApi.updateTime(this._currentTime,this._duration),this.controlsApi.updatePlaying(!this._paused),this.controlsApi.updateSpeed(this.playbackRate))}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,i)=>this._mirrorParentMediaTime(t,i)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}};customElements.get("hyperframes-player")||customElements.define("hyperframes-player",Be);0&&(module.exports={HyperframesPlayer,SPEED_PRESETS,formatSpeed,formatTime});
477
+ `,An='<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>',En='<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>',lt='<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>',ut='<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>',Tn='<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>';var dt=[.25,.5,1,1.5,2,4];function W(t){return Number.isInteger(t)?`${t}x`:`${t}x`}function Ie(t){if(!Number.isFinite(t)||t<0)return"0:00";let e=Math.floor(t),n=Math.floor(e/60),i=e%60;return`${n}:${i.toString().padStart(2,"0")}`}function Rn(t,e,n={}){let i=n.speedPresets??dt,r=document.createElement("div");r.className="hfp-controls",r.addEventListener("click",m=>{m.stopPropagation()});let o=document.createElement("button");o.className="hfp-play-btn",o.type="button",o.innerHTML=`<span class="hfp-ico hfp-ico-play">${An}</span><span class="hfp-ico hfp-ico-pause">${En}</span>`,o.setAttribute("aria-label","Play");let a=document.createElement("div");a.className="hfp-scrubber";let s=document.createElement("div");s.className="hfp-progress",s.style.width="0%",a.appendChild(s);let l=document.createElement("span");l.className="hfp-time",l.textContent="0:00 / 0:00";let u=document.createElement("div");u.className="hfp-speed-wrap";let c=document.createElement("button");c.className="hfp-speed-btn",c.type="button",c.textContent="1x",c.setAttribute("aria-label","Playback speed: 1x");let f=document.createElement("div");f.className="hfp-speed-menu",f.setAttribute("role","menu");for(let m of i){let p=document.createElement("button");p.className="hfp-speed-option",p.type="button",p.setAttribute("role","menuitem"),p.dataset.speed=String(m),p.textContent=W(m),m===1&&p.classList.add("hfp-active"),f.appendChild(p)}u.appendChild(f),u.appendChild(c);let v=document.createElement("div");v.className="hfp-volume-wrap";let b=document.createElement("button");b.className="hfp-mute-btn",b.type="button",b.innerHTML=lt,b.setAttribute("aria-label","Mute");let S=document.createElement("div");S.className="hfp-volume-slider-wrap";let _=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;let A=document.createElement("div");A.className="hfp-volume-fill",A.style.width="100%",_.appendChild(A),S.appendChild(_),v.appendChild(S),v.appendChild(b),n.audioLocked&&(v.style.display="none"),r.appendChild(o),r.appendChild(a),r.appendChild(l),r.appendChild(v),r.appendChild(u),t.appendChild(r);let C=!1,M=!1,I=1,T=null,U=i.indexOf(1);U===-1&&(U=0);let Z=(m,p)=>m?Tn:p===0?ut:p<.5?ut:lt;o.addEventListener("click",m=>{m.stopPropagation(),C?e.onPause():e.onPlay()}),b.addEventListener("click",m=>{m.stopPropagation(),e.onMuteToggle()});let O=!1,J=m=>{let p=_.getBoundingClientRect(),E=Math.max(0,Math.min(1,(m-p.left)/p.width));I=E,A.style.width=`${E*100}%`,_.setAttribute("aria-valuenow",String(Math.round(E*100))),M&&E>0&&e.onMuteToggle(),b.innerHTML=Z(M,E),e.onVolumeChange(E)};_.addEventListener("mousedown",m=>{m.stopPropagation(),O=!0,J(m.clientX)});let d=m=>{O&&J(m.clientX)},h=()=>{O=!1};document.addEventListener("mousemove",d),document.addEventListener("mouseup",h),_.addEventListener("touchstart",m=>{O=!0;let p=m.touches[0];p&&J(p.clientX)},{passive:!0});let g=m=>{if(O){let p=m.touches[0];p&&J(p.clientX)}},R=()=>{O=!1};document.addEventListener("touchmove",g,{passive:!0}),document.addEventListener("touchend",R);let k=.05;_.addEventListener("keydown",m=>{let p=I;if(m.key==="ArrowRight"||m.key==="ArrowUp")p=Math.min(1,I+k);else if(m.key==="ArrowLeft"||m.key==="ArrowDown")p=Math.max(0,I-k);else return;m.preventDefault(),m.stopPropagation(),I=p,A.style.width=`${p*100}%`,_.setAttribute("aria-valuenow",String(Math.round(p*100))),M&&p>0&&e.onMuteToggle(),b.innerHTML=Z(M,p),e.onVolumeChange(p)});let ye=m=>{for(let p of f.querySelectorAll(".hfp-speed-option"))p.classList.toggle("hfp-active",p.dataset.speed===String(m))};c.addEventListener("click",m=>{m.stopPropagation();let p=f.classList.toggle("hfp-open");c.setAttribute("aria-expanded",String(p))}),f.addEventListener("click",m=>{m.stopPropagation();let p=m.target.closest(".hfp-speed-option");if(!p)return;let E=parseFloat(p.dataset.speed);U=i.indexOf(E),c.textContent=W(E),c.setAttribute("aria-label",`Playback speed: ${W(E)}`),ye(E),f.classList.remove("hfp-open"),c.setAttribute("aria-expanded","false"),e.onSpeedChange(E)});let ve=()=>{f.classList.remove("hfp-open"),c.setAttribute("aria-expanded","false")};document.addEventListener("click",ve);let H=m=>{let p=a.getBoundingClientRect(),E=Math.max(0,Math.min(1,(m-p.left)/p.width));e.onSeek(E)},D=!1;a.addEventListener("mousedown",m=>{m.stopPropagation(),D=!0,e.onScrubStart?.(),H(m.clientX)});let wt=m=>{D&&H(m.clientX)},kt=()=>{D&&(D=!1,e.onScrubEnd?.())};document.addEventListener("mousemove",wt),document.addEventListener("mouseup",kt),a.addEventListener("touchstart",m=>{D=!0,e.onScrubStart?.();let p=m.touches[0];p&&H(p.clientX)},{passive:!0});let Mt=m=>{if(D){let p=m.touches[0];p&&H(p.clientX)}},Ct=()=>{D&&(D=!1,e.onScrubEnd?.())};document.addEventListener("touchmove",Mt,{passive:!0}),document.addEventListener("touchend",Ct);let It=()=>C&&!D&&!O&&!r.querySelector(":focus-visible"),Dt=()=>{r.classList.remove("hfp-hidden"),T&&clearTimeout(T),T=setTimeout(()=>{It()&&r.classList.add("hfp-hidden")},3e3)},F=t instanceof ShadowRoot?t.host:t,$=()=>Dt(),Pt=()=>{It()&&r.classList.add("hfp-hidden")};return F.addEventListener("mousemove",$),F.addEventListener("keydown",$),F.addEventListener("focusin",$),F.addEventListener("mouseleave",Pt),{updateTime(m,p){let E=p>0?Math.min(m,p):m,li=p>0?E/p*100:0;s.style.width=`${li}%`,l.textContent=`${Ie(E)} / ${Ie(p)}`},updatePlaying(m){let p=m!==C;C=m,o.classList.toggle("hfp-playing",m),o.setAttribute("aria-label",m?"Pause":"Play"),m?p&&Dt():(T&&clearTimeout(T),r.classList.remove("hfp-hidden"))},updateSpeed(m){let p=i.indexOf(m);p!==-1&&(U=p),c.textContent=W(m),c.setAttribute("aria-label",`Playback speed: ${W(m)}`),ye(m)},updateMuted(m){M=m,b.innerHTML=Z(m,I),b.setAttribute("aria-label",m?"Unmute":"Mute")},updateVolume(m){I=m,A.style.width=`${m*100}%`,_.setAttribute("aria-valuenow",String(Math.round(m*100))),b.innerHTML=Z(M,m)},setVolumeControlsHidden(m){v.style.display=m?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",wt),document.removeEventListener("mouseup",kt),document.removeEventListener("touchmove",Mt),document.removeEventListener("touchend",Ct),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",h),document.removeEventListener("touchmove",g),document.removeEventListener("touchend",R),document.removeEventListener("click",ve),F.removeEventListener("mousemove",$),F.removeEventListener("keydown",$),F.removeEventListener("focusin",$),F.removeEventListener("mouseleave",Pt),T&&clearTimeout(T),r.remove()}}}function xn(t,e,n,i,r,o=!1){let a=i?i.split(",").map(Number).filter(u=>!isNaN(u)&&u>0):void 0,s={...a?{speedPresets:a}:{},audioLocked:o},l=Rn(t,r,s);return l.updateMuted(e),l.updateVolume(n),l}function ct(t,e,n){return e?(n||(n=document.createElement("img"),n.className="hfp-poster",t.appendChild(n)),n.src=e,n):(n?.remove(),null)}function wn(t){return t.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains("hfp-controls"))}var De=null;function kn(t,e){if(typeof CSSStyleSheet<"u")try{De||(De=new CSSStyleSheet,De.replaceSync(e)),t.adoptedStyleSheets=[De];return}catch{}let n=document.createElement("style");n.textContent=e,t.appendChild(n)}function Mn(){let t=document.createElement("div");t.className="hfp-container";let e=document.createElement("iframe");return e.className="hfp-iframe",e.sandbox.add("allow-scripts","allow-same-origin"),e.allow="autoplay; fullscreen",e.referrerPolicy="no-referrer",e.title="HyperFrames Composition",t.appendChild(e),{container:t,iframe:e}}function Cn(t,e,n,i){let r=t.offsetWidth,o=t.offsetHeight;if(r===0||o===0)return!1;let a=Math.min(r/n,o/i);return e.style.width=`${n}px`,e.style.height=`${i}px`,e.style.transform=`translate(-50%, -50%) scale(${a})`,!0}function hr(t,e,n){if(n.end<=0)return!1;let i=n.shown<n.end&&e>0?e+.001:0;return t+i>=n.end}var Pe=class{constructor(e){this._callbacks=e}_callbacks;_raf=null;_lastUpdateMs=0;_tick=null;start(e,n,i,r,o){this.stop();let a=null,s=0,l=0,u=()=>{if(r()){this._raf=null;return}let c;try{c=e.time()}catch{this._raf=null;return}let f=i(),v=o();v.end>0&&(c=Math.min(c,v.end));let b=a===null?0:c-a;b!==0&&(l=Math.min(b,s),s=b),a=c;let S=hr(c,l,v);S&&(c=v.shown);let _=performance.now();if((_-this._lastUpdateMs>100||S)&&(this._lastUpdateMs=_,this._callbacks.onTimeUpdate(c,f)),S){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{e.pause(),v.shown<v.end&&e.seek(v.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(u)};this._tick=u,this._raf=requestAnimationFrame(u)}poll(){this._raf===null||!this._tick||(cancelAnimationFrame(this._raf),this._tick())}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}};function In(t){let e=Array.from(t.querySelectorAll("[data-composition-id]"));if(e.length===0)return t.body?[t.body]:[];let n=[];for(let i of e)gr(i)||n.push(i);return br(t),n}function br(t){let e=t.body;if(!e||typeof console>"u"||typeof console.warn!="function")return;let n=e.querySelectorAll("audio[data-start], video[data-start]");if(n.length===0)return;let i=[];for(let r of n)r.closest("[data-composition-id]")||i.push(r);i.length!==0&&console.warn(`[hyperframes-player] selectMediaObserverTargets: composition hosts are present, but ${i.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.`,i)}function gr(t){let e=t.parentElement;for(;e;){if(e.hasAttribute("data-composition-id"))return!0;e=e.parentElement}return!1}var _r=["backdrop-filter","clip-path","filter","mask","mask-border-source","mask-image","perspective","rotate","scale","transform","translate","-webkit-mask-image"],Ka=new Set([..._r,"contain","isolation","mask-border","mix-blend-mode","opacity"]);var Dn=t=>4*Number.EPSILON*Math.max(1,Math.abs(t));function Le(t,e){return!Number.isFinite(t)||!Number.isFinite(e)?t===e:Math.abs(t-e)<=Dn(Math.max(Math.abs(t),Math.abs(e)))}var Pn=(t,e)=>t>=e||Le(t,e),mt=(t,e,n)=>Pn(t,e)&&t<n&&!Le(t,n),yr=1e-6,Ln=(t,e,n,i)=>mt(t,e,n)||Pn(t,e)&&i>0&&n>=i-yr;function vr(t){return Number.isFinite(t)&&t>0?t:30}function Sr(t){return Number.isFinite(t)&&t>0?t:0}function Nn(t,e){let n=vr(e),i=Sr(t),r=i*n,o=Math.round(r);return Math.abs(r-o)<=.001?o/n:i}function On(t,e,n){return{start:Nn(t,n),end:Number.isFinite(e)?Nn(e,n):e}}var Ar=["seconds-time","rational-fps","seek-keep-playing","composition-manifest-v1","runtime-data","play-range"];function Er(t,e){let n=Math.abs(t),i=Math.abs(e);for(;i!==0;){let r=n%i;n=i,i=r}return n||1}function Tr(t){let e=Number.isFinite(t)&&t>0?t:30,n=Math.abs(e*1001-Math.round(e*1001))<1e-6,i=Number.isInteger(e)?1:n?1001:1e6,r=Math.round(e*i),o=Er(r,i);return{numerator:r/o,denominator:i/o}}function Fn(t,e,n){return Math.max(t,(Math.ceil(e*n-1e-6)-1)/n)}function Rr(t){if(typeof t!="object"||t===null)return null;let e=t;return!Number.isFinite(e.numerator)||!Number.isFinite(e.denominator)||(e.numerator??0)<=0||(e.denominator??0)<=0?null:Number(e.numerator)/Number(e.denominator)}function pt(t){return{protocolVersion:1,capabilities:Ar,fps:Tr(t)}}function Un(t){let e=t.offsetWidth,n=t.getBoundingClientRect().width;return e>0&&n>0?n/e:null}function xr(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Hn(t,e=30){if(typeof t!="object"||t===null)return{status:"legacy",fps:e};let n=t;if(n.protocolVersion===void 0)return{status:"legacy",fps:e};if(n.protocolVersion!==1)return{status:"unsupported",code:"unsupported_protocol_version",receivedVersion:n.protocolVersion};let i=Rr(n.fps);return i===null||!xr(n.capabilities)?{status:"unsupported",code:"invalid_protocol_metadata",receivedVersion:n.protocolVersion}:{status:"supported",fps:i,metadata:n}}function wr(t,e){let n=t.tagName.toLowerCase();if(n==="script"||n==="style"||n==="link"||n==="meta")return null;let r=n==="video"||n==="audio"?e.resolver.resolveMediaStartForElement(t):e.resolver.resolveStartForElement(t,0),o=e.resolver.resolveDurationForElement(t),a=t.getAttribute("data-composition-id");if(a){let l=e.timelineRegistry[a],u=ae(l);!(t.hasAttribute("data-duration")||t.hasAttribute("data-end")||t.hasAttribute(rn)||t.hasAttribute(on))&&(o==null||o<=0)&&u!=null&&u>0&&(o=u)}let s=a!==null&&t===Q(t.ownerDocument);return{start:r,end:!s&&o!=null&&o>0?r+o:Number.POSITIVE_INFINITY}}function Vn(t,e){let n=wr(t,e);if(!n)return!1;let i=e.exportRenderSeek?On(n.start,n.end,e.canonicalFps):n;return Ln(e.currentTime,i.start,i.end,e.compositionDuration)}var Y="first-frame",kr=3;function ce(t){let e=t.ownerDocument?.defaultView;return e&&t instanceof e.Element?!0:t instanceof Element}function w(t){if(!ce(t)||t.tagName!=="AUDIO"&&t.tagName!=="VIDEO")return!1;let e=t.ownerDocument?.defaultView;return e&&t instanceof e.HTMLMediaElement?!0:t instanceof HTMLMediaElement}function Mr(t){return t.hasAttribute("data-start")||t.hasAttribute("data-track-index")}function Cr(t,e,n){let i=t;for(;i;){if(Mr(i)&&!Vn(i,{currentTime:0,compositionDuration:Number.POSITIVE_INFINITY,canonicalFps:30,exportRenderSeek:!1,timelineRegistry:n,resolver:e}))return!1;i=i.parentElement}return!0}function Wn(t,e,n,i){return e==="all"?!0:Cr(t,n,i)}function Ne(t,{scope:e="all"}={}){let n=t.defaultView,i=le({documentRef:t,timelineRegistry:n?.__timelines,includeAuthoredTimingAttrs:!0}),r=t.querySelector(`meta[name="${bn}"]`)!==null,o=Array.from(t.querySelectorAll("video, audio")).filter(w).filter(l=>Wn(l,r&&l.preload!=="auto"?Y:e,i,n?.__timelines??{})).filter(l=>l.readyState<kr),a=Array.from(t.querySelectorAll("img")).filter(l=>Wn(l,l.getAttribute("loading")?.toLowerCase()==="lazy"?Y:e,i,n?.__timelines??{})).filter(l=>!l.complete),s=t.fonts?.status==="loading";return{pendingMedia:o,pendingImages:a,fontsLoading:s}}function Ir(t,{pendingMedia:e,pendingImages:n,fontsLoading:i},r){let o=e.map(l=>new Promise(u=>{if(l.error){u();return}let c=()=>{l.removeEventListener("canplay",c),l.removeEventListener("error",c),r.removeEventListener("abort",c),u()};l.addEventListener("canplay",c),l.addEventListener("error",c),r.addEventListener("abort",c,{once:!0})})),a=n.map(l=>l.decode?l.decode().catch(()=>{}):Promise.resolve()),s=i&&t.fonts?t.fonts.ready.then(()=>{}):Promise.resolve();return Promise.all([...o,...a,s]).then(()=>{})}function Dr(t,e,{scope:n="all"}={}){let i=Ne(t,{scope:n});return i.pendingMedia.length===0&&i.pendingImages.length===0&&!i.fontsLoading?null:Ir(t,i,e)}var Pr=50;function Lr(t,e){let n=t.defaultView;return!n||n.__renderReady||!n.__hf?null:new Promise(i=>{let r,o=()=>{r!==void 0&&clearTimeout(r),e.removeEventListener("abort",o),i()};if(e.aborted){o();return}e.addEventListener("abort",o,{once:!0});let a=()=>{if(n.__renderReady){o();return}r=setTimeout(a,Pr)};a()})}var Nr=50,Or=1.5,Fr=2,Ur=1500;function ft(t,e){return new Promise(n=>{if(e.aborted){n(-1);return}let i=0,r=()=>{t.cancelAnimationFrame?.(i),n(-1)};e.addEventListener("abort",r,{once:!0}),i=t.requestAnimationFrame(o=>{e.removeEventListener("abort",r),n(o)})})}function Hr(t,e){let n=t.defaultView;return n?(async()=>{let i=await ft(n,e);if(e.aborted)return;let r=await ft(n,e),o=r-i,a=0;for(;!e.aborted&&a<Fr;){if(r-i>=Ur)return;let s=await ft(n,e);if(e.aborted)return;let l=s-r;o=Math.min(o,l),a=l<Nr||l<=o*Or?a+1:0,r=s}})():null}var Vr=8e3;function Wr(t,e,n={}){let i=n.inputs??[(u,c)=>Dr(u,c,{scope:n.scope}),Lr,Hr],r=new AbortController,o=i.map(u=>u(t,r.signal)).filter(u=>u!==null);if(o.length===0){e({timedOut:!1});return}let a=n.timeoutMs??Vr,s,l=new Promise(u=>{s=setTimeout(()=>u("timed-out"),a)});Promise.race([Promise.all(o).then(()=>"done"),l]).then(u=>{clearTimeout(s),r.abort(),e({timedOut:u==="timed-out"})})}function Bn(t,e,n={}){Wr(t,e,{...n,scope:Y})}function ht(t,e,n){for(let i of e){let r=t.getAttribute(i);if(r===null||r.trim()==="")continue;let o=Number(r);if(Number.isFinite(o))return o}return n}function bt(t){return{start:ht(t,["data-start"],0),duration:ht(t,["data-duration"],0),mediaStart:Ae(e=>t.getAttribute(e)),playbackRate:ht(t,["data-playback-rate"],1)}}function Oe(t){return t+1e-5}function $n(){let{userAgent:t,maxTouchPoints:e}=navigator;return/iP(hone|ad|od)/.test(t)||/Macintosh/.test(t)&&e>1}var Br=[[.3,.25],[.1,.1]],$r=.01,Gr=.1,zr=.1,me=new WeakMap,Fe=new WeakSet;function Gn(t,e,n,i,r=t.tagName==="AUDIO"){let o=Math.abs(e);i&&o<=.04&&Fe.delete(t);let a=!Fe.has(t)||o>.5;if(r&&i&&o>zr&&a)return me.delete(t),Fe.add(t),{rate:n,seek:!0};let s=Math.sign(e),l=me.get(t);if(o>.04)me.set(t,s);else if(l!==s||o<=$r)return me.delete(t),{rate:n,seek:!1};let u=Br.find(([f])=>o>f)?.[1]??.03,c=r?Math.min(u,Gr):u;return{rate:n*(1+s*c),seek:!1}}function zn(t){me.delete(t),Fe.delete(t)}var jr=.004,qr=1.5,Ue=class{_entries=[];_mediaObserver;_playbackErrorPosted=!1;_audioOwner="runtime";_urlAudioEntry=null;_urlAudioSrc=null;_dispatchEvent;_getMuted;_getVolume;_getPlaybackRate;_getCurrentTime;_isPaused;constructor(e){this._dispatchEvent=e.dispatchEvent,this._getMuted=e.getMuted,this._getVolume=e.getVolume,this._getPlaybackRate=e.getPlaybackRate,this._getCurrentTime=e.getCurrentTime,this._isPaused=e.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;let e=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll();for(let n of this._entries)n!==this._urlAudioEntry&&(n.el.src="");this._entries=this._urlAudioEntry?[this._urlAudioEntry]:[],this._urlAudioSrc&&!this._urlAudioEntry&&(this._urlAudioEntry=this._createEntry(this._urlAudioSrc,"audio",0,1/0)),this.teardownObserver(),e&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(let e of this._entries)e.el.pause(),e.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(e){for(let n of this._entries)n.el.muted=e}updateVolume(e){for(let n of this._entries)n.el.volume=e}updatePlaybackRate(e){for(let n of this._entries)n.el.playbackRate=e}_playEntry(e){e.el.src&&e.el.play().catch(n=>this._reportPlaybackError(n))}_playEntryIfActive(e){this._refreshEntryBounds(e),this._inWindow(e,this._getCurrentTime())&&this._playEntry(e)}_refreshEntryBounds(e){if(!e.source?.isConnected)return;let n=tt(e.source);e.start=n.start??0,e.mediaStart=bt(e.source).mediaStart,e.duration=n.duration!=null&&n.duration>0?n.duration:Number.POSITIVE_INFINITY}_inWindow(e,n){return mt(n,e.start,e.start+e.duration)}_preseekUpcoming(e,n){let i=e.start-n;i<=0||i>qr||!e.el.paused||Math.abs(e.el.currentTime-e.mediaStart)>.04&&this._seekTo(e,e.mediaStart)}_seekTo(e,n,i=!1){let r=i?(e.seekLatency??0)*this._getPlaybackRate():0;e.seekIssuedAt=i?performance.now():void 0,e.el.currentTime=Oe(n+r)}_noteSeekLanded(e){if(e.seekIssuedAt===void 0)return;let n=(performance.now()-e.seekIssuedAt)/1e3;e.seekLatency=e.seekLatency===void 0?n:(e.seekLatency+n)/2,e.seekIssuedAt=void 0}_releaseSteering(e){zn(e.el),e.lastOffset=void 0;let n=this._getPlaybackRate();e.el.playbackRate!==n&&(e.el.playbackRate=n)}_mediaTime(e,n){return n-e.start+e.mediaStart}_gateEntryPlayback(e,n){return this._inWindow(e,n)?(this._audioOwner==="parent"&&!this._isPaused()&&e.el.paused&&this._playEntry(e),!0):(e.el.paused||e.el.pause(),this._releaseSteering(e),!1)}playAll(){for(let e of this._entries)this._playEntryIfActive(e)}primeAll(){if($n())for(let e of this._entries)e.el.paused&&(e.el.play().catch(()=>{}),e.el.pause())}pauseAll(){for(let e of this._entries)e.el.pause()}stopAdoptedMedia(){for(let e of this._entries)e.source&&e.el.pause()}seekAll(e){for(let n of this._entries)this._refreshEntryBounds(n),this._inWindow(n,e)&&this._jumpTo(n,this._mediaTime(n,e))}scrubAll(e){for(let n of this._entries)this._refreshEntryBounds(n),this._inWindow(n,e)?(this._jumpTo(n,this._mediaTime(n,e)),this._playEntry(n)):n.el.paused||n.el.pause()}mirrorTime(e,n){let i=n?.force===!0;for(let r of this._entries){this._refreshEntryBounds(r),this._preseekUpcoming(r,e);let o=r.el.paused;if(!this._gateEntryPlayback(r,e))continue;let a=this._mediaTime(r,e),s=a-r.el.currentTime;if(i||o){Math.abs(s)>.04&&this._jumpTo(r,a);continue}this._steer(r,a,s)}}_steer(e,n,i){let r=e.lastOffset!==void 0&&Math.abs(i-e.lastOffset)<jr;e.lastOffset=i;let{rate:o,seek:a}=Gn(e.el,i,this._getPlaybackRate(),r,!0);a?this._jumpTo(e,n,!0):Math.abs(e.el.playbackRate-o)>1e-6&&(e.el.playbackRate=o)}_jumpTo(e,n,i=!1){this._seekTo(e,n,i),this._releaseSteering(e)}promoteToParentProxy(e,n){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",e)for(let r of e.querySelectorAll("video, audio"))w(r)&&(r.muted=!0);for(let r of[...this._entries])this._repointToSource(r);let i=this._getCurrentTime();n?n(i,{force:!0}):this.mirrorTime(i,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(e){let n=e.querySelectorAll("audio[data-start], video[data-start]");for(let i of n)w(i)&&this._adoptIframeMedia(i);this._observeDynamicMedia(e)}setupFromUrl(e){if(this._urlAudioSrc===e&&this._urlAudioEntry)return;this.teardownUrlAudio();let n=this._createEntry(e,"audio",0,1/0);this._urlAudioEntry=n,this._urlAudioSrc=e,n&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){let e=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!e)return;e.el.pause(),e.el.src="";let n=this._entries.indexOf(e);n!==-1&&this._entries.splice(n,1)}teardownObserver(){this._mediaObserver?.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(e){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:e}})))}_createEntry(e,n,i,r,o){if(!o&&this._urlTaken(e))return null;let a=n==="video"?document.createElement("video"):new Audio;a.preload="auto";let s=o?.getAttribute("crossorigin");s!=null&&a.setAttribute("crossorigin",s),a.src=e,a.load(),a.muted=this._getMuted(),a.volume=this._getVolume();let l=this._getPlaybackRate();l!==1&&(a.playbackRate=l);let u={el:a,start:i,duration:r,mediaStart:o?bt(o).mediaStart:0,source:o};return a.addEventListener("seeked",()=>this._noteSeekLanded(u)),this._entries.push(u),u}_resolveIframeMediaSrc(e){let n=e.getAttribute("src")||e.querySelector("source")?.getAttribute("src");return n?new URL(n,e.ownerDocument.baseURI).href:null}_adoptIframeMedia(e){if(e.preload==="metadata"||e.preload==="none"||this._entries.some(l=>l.source===e)||e.tagName==="VIDEO"&&e.hasAttribute("muted"))return;let n=this._resolveIframeMediaSrc(e);if(!n)return;let i=tt(e),r=i.start??0,o=i.duration??Number.POSITIVE_INFINITY,a=e.tagName==="VIDEO"?"video":"audio",s=this._createEntry(n,a,r,o,e);s&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(s))}_followIframeMediaSrc(e){let n=this._entries.find(i=>i.source===e);if(!n)return this._adoptIframeMedia(e);this._audioOwner!=="parent"||!this._repointToSource(n)||(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(n))}_urlTaken(e){return this._entries.some(n=>n.source&&!n.source.isConnected?!1:(n.source&&this._resolveIframeMediaSrc(n.source)||n.el.src)===e)}_repointToSource(e){let n=e.source?this._resolveIframeMediaSrc(e.source):null;return!n||e.el.src===n?!1:(e.el.src=n,e.el.load(),!0)}_detachIframeMedia(e){let n=this._entries.find(i=>i.source===e);n&&this._removeEntry(n)}_removeEntry(e){e.el.pause(),e.el.src="",this._entries.splice(this._entries.indexOf(e),1)}_observeDynamicMedia(e){if(this.teardownObserver(),typeof MutationObserver>"u"||!e.body)return;let n=new MutationObserver(o=>{for(let a of o){if(a.type==="attributes"&&a.attributeName==="src"){let s=a.target;w(s)&&s.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(s);continue}if(a.type==="attributes"&&a.attributeName==="preload"){let s=a.target;w(s)&&s.matches("audio[data-start], video[data-start]")&&(s.preload==="auto"?this._adoptIframeMedia(s):this._detachIframeMedia(s));continue}for(let s of a.addedNodes){if(!ce(s))continue;let l=[];w(s)&&s.matches("audio[data-start], video[data-start]")&&l.push(s);let u=s.querySelectorAll("audio[data-start], video[data-start]");for(let c of u)w(c)&&l.push(c);for(let c of l)this._adoptIframeMedia(c)}for(let s of a.removedNodes){if(!ce(s))continue;let l=[];w(s)&&s.matches("audio[data-start], video[data-start]")&&l.push(s);let u=s.querySelectorAll("audio[data-start], video[data-start]");for(let c of u)w(c)&&l.push(c);for(let c of l)this._detachIframeMedia(c)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},r=In(e);for(let o of r)n.observe(o,i);this._mediaObserver=n}};function gt(t,e,n){if(t===null&&e===null)return{range:null,clamped:!1};let i=t??0,r=e!==null&&n>0&&e>n,o=r?n:e,a=o??(n>0?n:1/0);return!(i>=0)||!(a>i)?{range:null,clamped:!0}:{range:{start:i,end:o},clamped:r}}function pe(t,e,n){let i=t.end??e;return i<e?Fn(t.start,i,n):i}function _t(t,e,n,i){return t<e.start||t>=pe(e,n,i)}var Yr=100;function Xr(t,e){return typeof t.currentTime=="number"&&Number.isFinite(t.currentTime)?t.currentTime:(t.frame??0)/e}function qn(t,e,n){return n<=0?!1:t.ended===!0?!0:t.ended===!1&&!t.isPlaying?!1:e>=n}function Kr(t,e,n,i,r,o){let{duration:a}=n;if(!r){let s=qn(t,e,a);return{start:0,shownAtEnd:a,atEnd:s,stopRuntime:!1,entering:!1}}if(t.ownsRange){let s=i&&t.ended===!0&&!t.isPlaying;return{start:r.start,shownAtEnd:e,atEnd:s,stopRuntime:!1,entering:!1}}return Zr(t,e,n,i,r,o)}function Zr(t,e,n,i,r,o){let a=r.end??n.duration,s=n.enteringRange===!0&&(e<r.start||e>=a);return{start:r.start,shownAtEnd:pe(r,n.duration,o),atEnd:i&&!s&&qn(t,e,a),stopRuntime:t.isPlaying,entering:s}}function Yn(t,e,n,i){let r=Xr(t,e),o=!n.paused,a=o||t.isPlaying,s=i.getPlayRange?.(),l=Kr(t,r,n,a,s,e),{atEnd:u,start:c}=l,f=n.duration>0?Math.min(r,n.duration):r,v=u?l.shownAtEnd:f,b=!t.isPlaying,S=u&&a;if(S&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(c),i.play(),{...n,currentTime:c,paused:!1,enteringRange:!0};let _={...n,currentTime:v,paused:b,enteringRange:l.entering};i.media.audioOwner==="parent"&&(o&&b?i.media.pauseAll():!o&&!b&&i.media.playAll(),i.media.mirrorTime(v));let A=performance.now(),C=b!==n.paused;return(A-n.lastUpdateMs>Yr||C)&&(_.lastUpdateMs=A,i.updateControlsTime(v,n.duration),i.updateControlsPlaying(!b),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:v}}))),S&&(l.stopRuntime&&i.seek(v),i.media.audioOwner==="parent"&&i.media.pauseAll(),_.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),_}function Jr(t){return Array.isArray(t)?t.filter(e=>typeof e=="object"&&e!==null&&typeof e.id=="string"&&typeof e.start=="number"&&typeof e.duration=="number"):[]}function Xn(t,e,n){if(t.source!==e)return;let i=t.data;if(!i||i.source!=="hf-preview")return;let r=Hn(i);if(r.status==="unsupported"){n.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:r.code,receivedVersion:r.receivedVersion}}));return}n.setRuntimeFps?.(r.fps);let o=r.status==="supported"&&r.metadata.capabilities.includes("play-range");if(n.setRuntimeOwnsPlayRange?.(o),i.type==="shader-transition-state"){let a=i.state&&typeof i.state=="object"?i.state:{};n.shaderLoader.update(a,n.getShaderLoadingMode()),n.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:a}}));return}if(i.type==="ready"){n.onRuntimeReady();return}if(i.type==="assets-ready"){n.onRuntimeAssetsReady?.(i.timedOut===!0);return}if(i.type==="runtime-data-error"){n.onRuntimeDataError?.(i.channel,i.requestId,i.message);return}if(i.type==="runtime-data-applied"){n.onRuntimeDataApplied?.(i.channel,i.requestId);return}if(i.type==="state"){n.setPlaybackState(Yn({frame:i.frame??0,currentTime:i.currentTime,ended:typeof i.ended=="boolean"?i.ended:void 0,isPlaying:!!i.isPlaying,ownsRange:o},r.fps,n.getPlaybackState(),n)),n.setBuffering?.(i.buffering===!0);return}if(i.type==="media-autoplay-blocked"){if(n.shouldPromoteMediaAutoplayFallback?.()===!1)return;let a=null;try{a=n.getIframeDoc()}catch{}n.media.promoteToParentProxy(a,(s,l)=>n.media.mirrorTime(s,l)),n.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){let a=Number(i.durationSeconds),s=Number(i.durationInFrames),l=Number.isFinite(a)&&a>0?a:s/r.fps;if(Number.isFinite(i.compositionWidth)&&i.compositionWidth>0&&Number.isFinite(i.compositionHeight)&&i.compositionHeight>0&&n.setCompositionSize(i.compositionWidth,i.compositionHeight),Number.isFinite(l)&&l>0){let u=n.getPlaybackState();n.setPlaybackState({...u,duration:l}),n.updateControlsTime(u.currentTime,l),n.onRuntimeTimelineReady(l,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}n.setScenes(Jr(i.scenes));return}i.type==="stage-size"&&Number.isFinite(i.width)&&i.width>0&&Number.isFinite(i.height)&&i.height>0&&n.setCompositionSize(i.width,i.height)}function Qr(t,e){return t.includes(e)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(t)}var eo=new Set([">"," "," ",`
478
+ `,"\r","\f"]);function yt(t,e){let n=t.toLowerCase(),i=`<${e}`,r=0;for(;r<n.length;){let o=n.indexOf(i,r);if(o<0)return null;let a=n[o+i.length];if(eo.has(a)){let s=n.indexOf(">",o+i.length);return s<0?null:{index:o,end:s+1}}r=o+i.length}return null}function Kn(t,e){if(!t||Qr(t,e))return t;let n=`<script src="${e}"></script>`,i=yt(t,"head");if(i)return t.slice(0,i.end)+n+t.slice(i.end);let r=yt(t,"body");if(r)return t.slice(0,r.index)+n+t.slice(r.index);let o=yt(t,"html");return o?t.slice(0,o.end)+n+t.slice(o.end):n+t}var B="shader-capture-scale",X="shader-loading",He="runtime-src",Zn="__hf_shader_capture_scale",Jn="__hf_shader_loading",K=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function vt(t){if(t===null)return null;let e=Number(t);return!Number.isFinite(e)||e<=0?null:String(Math.min(1,Math.max(.25,e)))}function to(t){if(t===null||t.trim()==="")return"composition";let e=t.trim().toLowerCase();return e==="none"||e==="false"||e==="0"||e==="off"?"none":e==="player"||e==="true"||e==="1"||e==="on"?"player":"composition"}function Qn(t,e){return t.filter(n=>n!==""&&n.split("=")[0]!==e)}function no(t,e,n){let i=t.indexOf("#"),r=i>=0?t.slice(0,i):t,o=i>=0?t.slice(i):"",a=r.indexOf("?"),s=a>=0?r.slice(0,a):r,l=a>=0?r.slice(a+1):"",u=Qn(l.split("&"),Zn);u=Qn(u,Jn),e!==null&&u.push(`${Zn}=${encodeURIComponent(e)}`),n!=="composition"&&u.push(`${Jn}=${encodeURIComponent(n)}`);let c=u.join("&");return`${s}${c?`?${c}`:""}${o}`}function io(t,e,n){if(e===null&&n==="composition")return t;let i=[];e!==null&&i.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(e)};`),n!=="composition"&&i.push(`window.__HF_SHADER_LOADING=${JSON.stringify(n)};`);let r=`<script data-hyperframes-player-shader-options>${i.join("")}</script>`;return/<head\b[^>]*>/i.test(t)?t.replace(/<head\b[^>]*>/i,o=>`${o}${r}`):/<html\b[^>]*>/i.test(t)?t.replace(/<html\b[^>]*>/i,o=>`${o}${r}`):`${r}${t}`}function fe(t){return to(t.getAttribute(X))}function ei(t){return Number(vt(t.getAttribute(B))??"1")}function ti(t,e){return no(e,vt(t.getAttribute(B)),fe(t))}function he(t,e){return Kn(io(e,vt(t.getAttribute(B)),fe(t)),St(t))}function St(t){let e=t.getAttribute(He)?.trim();if(!e)return q;try{let n=new URL(e,document.baseURI),i=n.protocol==="http:"||n.protocol==="https:",r=n.hostname==="127.0.0.1"||n.hostname==="localhost"||n.hostname==="[::1]";return i&&(r||n.origin===location.origin)?n.href:q}catch{return q}}function ni(){let t=document.createElement("div");t.className="hfp-shader-loader",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-label","Preparing scene transitions"),t.setAttribute("data-hyperframes-ignore",""),t.draggable=!1;let e=b=>{b.preventDefault(),b.stopPropagation()};for(let b of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])t.addEventListener(b,e,{capture:!0});let n=document.createElement("div");n.className="hfp-shader-loader-panel",n.draggable=!1;let i=document.createElement("div");i.className="hfp-shader-loader-mark",i.draggable=!1,i.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("");let r=document.createElement("div");r.className="hfp-shader-loader-title";let o=document.createElement("span");o.className="hfp-shader-loader-title-text",o.textContent=K[0]||"Preparing scene transitions",r.appendChild(o);let a=document.createElement("div");a.className="hfp-shader-loader-detail",a.textContent="Rendering animated scene samples for shader transitions.";let s=document.createElement("div");s.className="hfp-shader-loader-track",s.setAttribute("aria-hidden","true");let l=document.createElement("div");l.className="hfp-shader-loader-fill",s.appendChild(l);let u=document.createElement("div");u.className="hfp-shader-loader-progress";let c=b=>{let S=document.createElement("div");S.className="hfp-shader-loader-row";let _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=b;let A=document.createElement("span");return A.className="hfp-shader-loader-value",S.appendChild(_),S.appendChild(A),u.appendChild(S),{row:S,label:_,value:A}},f=c("transition"),v=c("transition frame");return n.appendChild(i),n.appendChild(r),n.appendChild(a),n.appendChild(s),n.appendChild(u),t.appendChild(n),{root:t,fill:l,title:o,detail:a,transitionValue:f.value,transitionRow:f.row,frameLabel:v.label,frameValue:v.value,frameRow:v.row}}var ro=420;function Ve(t,e,n){e.textContent=n,t.style.visibility=n?"visible":"hidden"}var We=class{_el;_hideTimeout=null;_hiddenCallbacks=[];_drawingAssets=!1;constructor(e){this._el=e}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(e){let n=this._el.root.classList;n.contains("hfp-visible")||n.contains("hfp-hiding")?this._hiddenCallbacks.push(e):e()}_flushHidden(){let e=this._hiddenCallbacks;this._hiddenCallbacks=[];for(let n of e)n()}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)",Ve(this._el.transitionRow,this._el.transitionValue,""),Ve(this._el.frameRow,this._el.frameValue,"")}update(e,n){let i=n==="player"&&e.loading&&!e.ready;if(this._drawingAssets&&!i)return;if(n!=="player"){this.reset();return}if(e.ready||!e.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions"),this._drawingAssets=!1;let r=typeof e.progress=="number"&&Number.isFinite(e.progress)?e.progress:0,o=typeof e.total=="number"&&Number.isFinite(e.total)?e.total:0,a=o>0?Math.min(1,Math.max(0,r/o)):0,s=Math.min(K.length-1,Math.floor(a*K.length));this._el.title.textContent=K[s]||"Preparing scene transitions",this._el.detail.textContent=e.phase==="cached"?"Loading cached transition frames before playback.":e.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${a})`;let l=e.currentTransition!==void 0&&e.transitionTotal!==void 0?`${e.currentTransition}/${e.transitionTotal}`:o>0?`${r}/${o}`:"",u=e.transitionFrame!==void 0&&e.transitionFrames!==void 0?`${e.transitionFrame}/${e.transitionFrames}`:"";this._el.frameLabel.textContent=e.phase==="cached"?"cached transition frames":e.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",Ve(this._el.transitionRow,this._el.transitionValue,l),Ve(this._el.frameRow,this._el.frameValue,u),this._el.root.setAttribute("aria-valuenow",String(Math.round(a*100))),this.show()}showAssetsLoading(e="Loading assets",n="Waiting for images, video and fonts to finish loading."){this.reset(),this._el.title.textContent=e,this._el.detail.textContent=n,this._el.root.setAttribute("aria-label",e),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()},ro)}};function ii(t){return t?.trim().toLowerCase().startsWith("video/")??!1}function ri(t){let e=document.createElement("video");e.className="hfp-video",e.playsInline=!0,e.preload="metadata";let n=new AbortController,{signal:i}=n;return e.addEventListener("loadedmetadata",()=>t.onMetadata(e),{signal:i}),e.addEventListener("durationchange",()=>t.onDurationChange(e),{signal:i}),e.addEventListener("resize",()=>t.onResize(e),{signal:i}),e.addEventListener("play",()=>t.onPlay(e),{signal:i}),e.addEventListener("pause",()=>t.onPause(e),{signal:i}),e.addEventListener("timeupdate",()=>t.onTimeUpdate(),{signal:i}),e.addEventListener("error",()=>t.onError(e.error?.message||"Video failed to load",e.error?.code??null),{signal:i}),{video:e,adapter:{duration:()=>e.duration,time:()=>e.currentTime,seek:o=>{e.currentTime=Oe(o)},play:()=>e.play().catch(o=>{i.aborted||t.onPlayRejected(o)}),pause:()=>e.pause(),timeScale:o=>{e.defaultPlaybackRate=o,e.playbackRate=o}},destroy:()=>{n.abort(),e.pause(),e.removeAttribute("src"),e.load(),e.remove()}}}var oo=.1,ao=5,At="sandbox-origin",oi=1e4,Et=8e3,Tt="assets-loading",be="assets-loading-ui",Be="buffering",Rt="low-power-idle",ai="disable-click-to-play",ge="range-start",_e="range-end",si=150;function xt(t){return!Number.isFinite(t)||t<=0?1:Math.max(oo,Math.min(ao,t))}var $e=class extends HTMLElement{static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src","type",At,He,B,X,be,Rt,ge,_e]}shadow;container;sizer=document.createElement("div");iframe;posterEl=null;controlsApi=null;resizeObserver;shaderLoader;probe;_ready=!1;_readyDocument=null;_connected=!1;_assetsReady=!1;_painted=!1;_pendingPlay=!1;_assetsGeneration=0;_assetsLoadingShowTimer=null;_bufferingShowTimer=null;_currentTime=0;_duration=0;_paused=!0;_scrubbing=!1;_lastUpdateMs=0;_volume=1;_compositionWidth=1920;_compositionHeight=1080;_rescaleWarned=!1;_directTimelineAdapter=null;_directTimelineClock;_parentTickRaf=null;_media;_scenes=[];_runtimeFps=30;_runtimeBridgeReady=!1;_runtimeAssetsReadyGeneration=-1;_runtimeData=new Map;_runtimeDataRequestId=0;_pendingRuntimeData=new Map;_afterUpdate=null;_videoSource=null;_runtimeOwnsPlayRange=!1;_enteringRange=!1;_rangeClampReported="";constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),kn(this.shadow,Sn),{container:this.container,iframe:this.iframe}=Mn(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);let e=ni();this.shadow.appendChild(e.root),this.shaderLoader=new We(e),this._media=new Ue({dispatchEvent:n=>this._emit(n),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Pe({onTimeUpdate:(n,i)=>{this._currentTime=n,this.controlsApi?.updateTime(n,i),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:n}}))},getLoop:()=>this.loop,restart:()=>{this.seek(this._playRange()?.start??0),this.play()},onPaused:()=>{this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this._emit(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new Ce(this.iframe,{resolveRuntimeUrl:()=>St(this),hostOwnsDeadline:()=>this.hasAttribute("no-load-timeout"),onReady:n=>this._onProbeReady(n),onError:n=>this._emit(new CustomEvent("error",{detail:{message:n}}))}),this.addEventListener("click",n=>{this.disableClickToPlay||wn(n)||(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)}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=ct(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=he(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){this._connected=!1,this._teardownVideo(),this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),this.controlsApi?.destroy(),this.controlsApi=null,this._paused=!0,this._pendingPlay=!1,this._abandonComposition("Player disconnected before runtime data was applied")}attributeChangedCallback(e,n,i){switch(e){case"src":if(!this.isConnected)break;i&&this._navigateSrc(i);break;case"type":{let r=this.getAttribute("src");if(!this.isConnected||r===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(r);break}case"srcdoc":if(!this.isConnected)break;if(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),i!==null)this._pauseForVideoSwitch(),this._teardownVideo(),this.iframe.srcdoc=he(this,i);else{this.iframe.removeAttribute("srcdoc");let r=this.getAttribute("src");r!==null&&this._wantsVideo()&&this._navigateSrc(r)}break;case At:this._applySandboxOriginPolicy(this.isConnected&&n!==i);break;case"width":this._setCompositionSize(de(i)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,de(i)??1080);break;case"controls":i!==null?this._setupControls():(this.controlsApi?.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=ct(this.shadow,i,this.posterEl);break;case"playback-rate":{let r=xt(parseFloat(i||"1"));this._media.updatePlaybackRate(r),this._sendControl("set-playback-rate",{playbackRate:r}),this._directTimelineAdapter?.timeScale?.(r),this.controlsApi?.updateSpeed(r),this._emit(new Event("ratechange"));break}case"muted":this._handleMutedChange(i);break;case"audio-locked":this._applyAudioLock(i!==null);break;case"volume":{let r=Math.max(0,Math.min(1,parseFloat(i||"1")));this._volume=r,this._syncVideoAudio(),this._media.updateVolume(r),this._sendControl("set-volume",{volume:r}),this.controlsApi?.updateVolume(r),this._emit(new Event("volumechange"));break}case"audio-src":i?this._media.setupFromUrl(i):this._media.teardownUrlAudio();break;case be:i==="none"&&this.shaderLoader.hideAssetsLoading();break;case Rt:this._sendControl("set-idle-heartbeat",{slow:i!==null});break;case ge:case _e:this._applyPlayRange(!0);break;case B:case X:case He:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(At)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){if(this._videoSource)return;this._abandonComposition("Sandbox policy changed before runtime data was applied");let e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=he(this,e);return}let n=this.getAttribute("src");n===null?this.iframe.src="about:blank":this._loadSrc(n)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){this._play(!0)}_play(e){if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,this.posterEl?.remove(),this.posterEl=null;let n=this._ready?this._playRange():null;n?_t(this._currentTime,n,this._duration,this._runtimeFps)&&(this.seek(n.start),this._enteringRange=!0):this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;let i=this._tryDirectTimelinePlay(),r=!1;this._sendDisplayScale(),i||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,r=!0)),this._media.audioOwner==="parent"?this._media.playAll():this._media.primeAll(),this.controlsApi?.updatePlaying(!0),!r&&e&&this._emit(new Event("play")),i&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused,()=>this._clockStop())}pause(){this._pendingPlay=!1,this._tryDirectTimelinePause()?this._showPausedVideoTime():this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this._emit(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){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,this.controlsApi?.updatePlaying(!1),this.controlsApi?.updateTime(this._currentTime,this._duration)}setColorGrading(e,n){this._sendControl("set-color-grading",{target:e,grading:n})}clearColorGrading(e){this._sendControl("set-color-grading",{target:e,grading:null})}setColorGradingCompare(e,n){this._sendControl("set-color-grading-compare",{target:e,compare:n})}clearColorGradingCompare(e){this._sendControl("set-color-grading-compare",{target:e,compare:{enabled:!1}})}setRuntimeData(e,n){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");let i=structuredClone(n);this._runtimeData.set(e,i),this._deliverRuntimeData(e,i)}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 xt(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(xt(e)))}get shaderCaptureScale(){return ei(this)}set shaderCaptureScale(e){this.setAttribute(B,String(e))}get shaderLoading(){return fe(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(X):this.setAttribute(X,e)}get assetsLoadingUi(){return this.getAttribute(be)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(be,"none"):this.removeAttribute(be)}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;let 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){if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._syncVideoAudio(),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),this.controlsApi?.updateMuted(e!==null),this._emit(new Event("volumechange"))}_applyAudioLock(e){e&&(this.muted=!0),this.controlsApi?.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(ai)}set disableClickToPlay(e){this.toggleAttribute(ai,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(ge)}set rangeStart(e){this._writeSeconds(ge,e)}get rangeEnd(){return this._readSeconds(_e)}set rangeEnd(e){this._writeSeconds(_e,e)}_readSeconds(e){let n=this.getAttribute(e);return n===null?null:Number(n)}_writeSeconds(e,n){n==null?this.removeAttribute(e):this.setAttribute(e,String(n))}_hasPlayRange(){return this.hasAttribute(ge)||this.hasAttribute(_e)}_playRange(){return gt(this.rangeStart,this.rangeEnd,this._duration).range}_sendPlayRange(e){let n=e?.end??null;this._sendControl("set-play-range",{startSeconds:e?.start??null,endSeconds:n})}_applyPlayRange(e){let{range:n,clamped:i}=gt(this.rangeStart,this.rangeEnd,this._duration);this._sendPlayRange(n),this._ready&&(this._reportRangeClamp(n,i),n&&e&&!this._pendingPlay&&this._moveIntoPlayRange(n))}_reportRangeClamp(e,n){let i=n?`${this.rangeStart},${this.rangeEnd},${this._duration}`:"";if(i===this._rangeClampReported||(this._rangeClampReported=i,!n))return;let r={rangeStart:e?.start??null,rangeEnd:e?.end??null};this._emit(new CustomEvent("rangeclamped",{detail:{...r,duration:this._duration}}))}_moveIntoPlayRange(e){_t(this._currentTime,e,this._duration,this._runtimeFps)&&(this._paused?this.seek(e.start):this._jumpWhilePlaying(e.start))}_jumpWhilePlaying(e){this._directTimelineAdapter?(this._directTimelineAdapter.seek(e,!1),this._currentTime=e):this._runtimeOwnsPlayRange||(this.seek(e),this._enteringRange=!0,this._play(!1))}_clockStop(){let e=this._playRange(),n=e?.end??this._duration;if(!e)return{end:n,shown:n};let i=pe(e,this._duration,this._runtimeFps);return{end:n,shown:i<n?(i+n)/2:i}}_sendControl(e,n={}){try{let i=this.iframe.contentWindow;return i?(i.postMessage({...n,source:"hf-parent",type:"control",action:e,...pt(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(n.channel,n.requestId,"Composition iframe is unavailable"),!1)}catch(i){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(n.channel,n.requestId,i instanceof Error?i.message:String(i)),!1}}_deliverRuntimeData(e,n){if(!this.isConnected||!this._runtimeBridgeReady)return;let i=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,n,i)||this._sendControl("set-runtime-data",{channel:e,payload:n,requestId:i})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;let n=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,n)||this._sendControl("clear-runtime-data",{channel:e,requestId:n})}_trySetRuntimeDataDirect(e,n,i){try{let r=this.iframe.contentWindow?.__hyperframes;return typeof r?.setRuntimeData!="function"?!1:(r.setRuntimeData(e,n,i),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,n){try{let i=this.iframe.contentWindow?.__hyperframes;return typeof i?.clearRuntimeData!="function"?!1:(i.clearRuntimeData(e,n),!0)}catch{return!1}}_replayRuntimeData(){for(let[e,n]of this._runtimeData)this._deliverRuntimeData(e,n)}_beginRuntimeDataDelivery(e){let n=this._pendingRuntimeData.get(e);n&&window.clearTimeout(n.timeoutId),this._runtimeDataRequestId+=1;let i=this._runtimeDataRequestId,r=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,i,`Runtime data delivery timed out after ${oi}ms`)},oi);return this._pendingRuntimeData.set(e,{requestId:i,timeoutId:r}),i}_resolveRuntimeDataDelivery(e,n){let i=this._takeRuntimeDataDelivery(e,n);i&&this._emit(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:i.requestId}}))}_rejectRuntimeDataDelivery(e,n,i){let r=this._takeRuntimeDataDelivery(e,n);r&&this._emit(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:r.requestId,message:typeof i=="string"?i:String(i)}}))}_takeRuntimeDataDelivery(e,n){if(typeof e!="string"||typeof n!="number"||!Number.isSafeInteger(n))return null;let i=this._pendingRuntimeData.get(e);return!i||i.requestId!==n?null:(window.clearTimeout(i.timeoutId),this._pendingRuntimeData.delete(e),i)}_rejectAllRuntimeDataDeliveries(e){for(let[n,i]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(n,i.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){let n=this._getSameOriginIframeDocument();if(n)for(let i of n.querySelectorAll("video, audio"))w(i)&&(i.muted=e||i.defaultMuted)}_stopIframeMedia(){let e=this._getSameOriginIframeDocument();if(e)for(let n of e.querySelectorAll("video, audio"))w(n)&&n.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(Rt)}),this._sendDisplayScale()}_sendDisplayScale(){let e=Un(this.iframe);e&&this._sendControl("set-display-scale",{scale:e})}_reloadShaderOptions(){if(!this._videoSource){if(this._abandonComposition("Shader options changed before runtime data was applied"),this.hasAttribute("srcdoc")){this.iframe.srcdoc=he(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")||"")}}_navigateSrc(e){this._pendingPlay=!1,this._pauseForVideoSwitch(),this._abandonComposition("Composition navigated before runtime data was applied"),this._loadSrc(e)}_wantsVideo(){return ii(this.getAttribute("type"))&&!this.hasAttribute("srcdoc")}_pauseForVideoSwitch(){!this._videoSource&&!this._wantsVideo()||(this._paused=!0,this.controlsApi?.updatePlaying(!1))}_loadSrc(e){if(this._wantsVideo()){this._loadVideo(e);return}this._teardownVideo(),this.iframe.src=ti(this,e)}_loadVideo(e){this._videoSource||(this._videoSource=ri({onMetadata:r=>this._applyThenEmit(()=>this._onVideoReady(r)),onDurationChange:r=>this._applyTimelineDuration(r.duration),onResize:r=>this._applyVideoSize(r),onPlay:r=>{!r.paused&&this._paused&&this.play()},onPause:r=>{r.paused&&!r.ended&&!this._paused&&this.pause()},onTimeUpdate:()=>{document.hidden&&this._playRange()&&this._directTimelineClock.poll()},onError:(r,o)=>{this._paused||this.pause(),this._emit(new CustomEvent("error",{detail:{message:r,code:o}}))},onPlayRejected:r=>this._onVideoPlayRejected(r)}),this.container.appendChild(this._videoSource.video),this.iframe.hidden=!0,this.iframe.src="about:blank"),this.probe.stop();let{video:n,adapter:i}=this._videoSource;this._directTimelineAdapter=i,this._currentTime=0,this._duration=0,this.controlsApi?.updateTime(0,0),this._syncVideoAudio(),i.timeScale?.(this.playbackRate),n.src=e}_teardownVideo(){this._videoSource&&(this._videoSource.destroy(),this._videoSource=null,this.iframe.hidden=!1)}_syncVideoAudio(){this._videoSource&&(this._videoSource.video.muted=this.muted,this._videoSource.video.volume=this._volume)}_onVideoReady(e){this._applyTimelineDuration(e.duration),this._applyVideoSize(e),this._ready=!0,this._dispatchReady(),this._waitForAssetsReady(null),this._afterEvents(()=>{this.hasAttribute("autoplay")&&this._paused&&this.play()})}_applyTimelineDuration(e){!Number.isFinite(e)||e<=0||(this._setDuration(e),this.controlsApi?.updateTime(this._currentTime,e))}_applyVideoSize(e){e.videoWidth>0&&e.videoHeight>0&&this._setCompositionSize(e.videoWidth,e.videoHeight)}_onVideoPlayRejected(e){e instanceof DOMException&&e.name==="NotAllowedError"&&(this._paused||this.pause(),this._emit(new CustomEvent("playbackerror",{detail:{source:"video",error:e}})))}_trySyncSeek(e){if(this._videoSource)return!1;try{let i=this.iframe.contentWindow?.__player;return typeof i?.seek!="function"?!1:(i.seek.call(i,e),!0)}catch{return!1}}_withDirectTimeline(e){let n=this._videoSource?null:this.probe.resolveDirectTimelineAdapter(),i=n||this._directTimelineAdapter;if(!i)return!1;try{return e(i),n&&n!==this._directTimelineAdapter&&this._applyTimelineDuration(n.duration()),this._directTimelineAdapter=i,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(n=>{n.seek(e,!1),n.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>{e.play()})}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>{e.pause()})}_showPausedVideoTime(){this._videoSource&&(this._currentTime=this._videoSource.video.currentTime,this.controlsApi?.updateTime(this._currentTime,this._duration),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}})))}_startParentTickClock(){this._stopParentTickClock();let e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){this._videoSource||this.probe.failed||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){Xn(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs,enteringRange:this._enteringRange}),setPlaybackState:({currentTime:n,duration:i,paused:r,lastUpdateMs:o,enteringRange:a})=>{this._enteringRange=a===!0,this._currentTime=n,this._setDuration(i),this._paused=r,this._lastUpdateMs=o},getShaderLoadingMode:()=>fe(this),shaderLoader:this.shaderLoader,setCompositionSize:(n,i)=>this._setCompositionSize(n,i),sendControl:(n,i)=>this._sendControl(n,i),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._hasPlayRange()&&this._sendPlayRange(this._playRange()),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(n,i)=>this._resolveRuntimeDataDelivery(n,i),onRuntimeDataError:(n,i,r)=>this._rejectRuntimeDataDelivery(n,i,r),onRuntimeTimelineReady:(n,i)=>this._onRuntimeTimelineReady(n,i),setBuffering:n=>this._setBuffering(n),setRuntimeFps:n=>{this._runtimeFps=n},setRuntimeOwnsPlayRange:n=>{this._runtimeOwnsPlayRange=n},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:n=>{this._scenes=n,this._emit(new CustomEvent("scenes",{detail:{scenes:n}}))},updateControlsTime:(n,i)=>this.controlsApi?.updateTime(n,i),updateControlsPlaying:n=>this.controlsApi?.updatePlaying(n),dispatchEvent:n=>this._emit(n),seek:n=>this.seek(n),play:()=>this.play(),getLoop:()=>this.loop,getPlayRange:()=>this._playRange(),media:this._media})}_onRuntimeTimelineReady(e,n){if(this._ready)return;this.probe.stop(),this._setDuration(e),this._directTimelineAdapter=null,this._ready=!0,this.controlsApi?.updateTime(this._currentTime,e),this._dispatchReady();let i=this._getSameOriginIframeDocument();i&&this._media.setupFromIframe(i),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(i,n),this._playWhenWanted()}_onProbeReady(e){this._applyThenEmit(()=>this._applyProbeResult(e))}_applyProbeResult({duration:e,adapter:n,compositionSize:i}){this._setDuration(e),this._directTimelineAdapter=n.kind==="direct-timeline"?n.timeline:null,i&&this._setCompositionSize(i.width,i.height),this._ready=!0,this.controlsApi?.updateTime(0,e),this._dispatchReady();let r=this._getSameOriginIframeDocument();r&&this._media.setupFromIframe(r),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(r),this._playWhenWanted()}_waitForAssetsReady(e,n){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1;let i=++this._assetsGeneration;if(!e){n===!1?(this._runtimeAssetsReadyGeneration=i,this._startAssetsLoadingOverlayTimer(i),setTimeout(()=>this._settleAssetsReady(i),Et)):this._settleAssetsReady(i);return}Bn(e,({timedOut:r})=>{i===this._assetsGeneration&&(r&&this._warnStuckAssets(e),this._settleAssetsReady(i))},{timeoutMs:Et}),this._assetsReady||this._startAssetsLoadingOverlayTimer(i)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(Tt,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},si)}_setBuffering(e){if(e){if(this._bufferingShowTimer!==null||this.hasAttribute(Be))return;this._bufferingShowTimer=setTimeout(()=>{this._bufferingShowTimer=null,this.setAttribute(Be,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading("Buffering","")},si);return}this._bufferingShowTimer!==null&&clearTimeout(this._bufferingShowTimer),this._bufferingShowTimer=null,this.hasAttribute(Be)&&(this.removeAttribute(Be),this.shaderLoader.hideAssetsLoading())}_hasPendingFirstFrameAssets(e){let{pendingMedia:n,pendingImages:i,fontsLoading:r}=Ne(e,{scope:Y});return n.length>0||i.length>0||r}_warnStuckAssets(e){let{pendingMedia:n,pendingImages:i,fontsLoading:r}=Ne(e,{scope:Y}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${Et}ms, playing anyway`,{stuckMedia:n.map(a=>a.currentSrc||a.getAttribute("src")||`<${a.tagName.toLowerCase()}>`),stuckImages:i.map(a=>a.currentSrc||a.getAttribute("src")||"<img>"),fontsLoading:r,computeReady:o?.__renderReady===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(Tt),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this.probe.stop(),this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._runtimeOwnsPlayRange=!1,this._enteringRange=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this._setBuffering(!1),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(Tt),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_dispatchReady(){this._readyDocument=this._getSameOriginIframeDocument();let e={duration:this._duration,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight};this._emit(new CustomEvent("ready",{detail:e})),this._rescale(),this._rangeClampReported="",this._hasPlayRange()&&this._applyPlayRange(!0)}_setDuration(e){e!==this._duration&&(this._duration=e,this._ready&&(this._emit(new CustomEvent("durationchange",{detail:{duration:e}})),this._hasPlayRange()&&this._applyPlayRange(!1)))}_setCompositionSize(e,n){let i=e!==this._compositionWidth||n!==this._compositionHeight;if(this._compositionWidth=e,this._compositionHeight=n,this.sizer.style.aspectRatio=`${e} / ${n}`,this._rescale(),!i)return;let r={compositionWidth:e,compositionHeight:n};this._emit(new CustomEvent("resize",{detail:r}))}_applyThenEmit(e){if(this._afterUpdate){e();return}let n=[];this._afterUpdate=n;let i=[],r=o=>{try{o()}catch(a){i.push(a)}};r(e);for(let o of n)r(o);if(this._afterUpdate=null,i.length>0)throw i[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(){let e=Cn(this,this.iframe,this._compositionWidth,this._compositionHeight);e&&this._sendDisplayScale(),!e&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready: zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){if(!this._connected||this._videoSource)return;let 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=xn(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=>{this.playbackRate=e},onMuteToggle:()=>{this.muted=!this.muted},onVolumeChange:e=>{this.volume=e}},this._isAudioLocked()),this.controlsApi.updateTime(this._currentTime,this._duration),this.controlsApi.updatePlaying(!this._paused),this.controlsApi.updateSpeed(this.playbackRate))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,n){this._media.mirrorTime(e,n)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(n,i)=>this._mirrorParentMediaTime(n,i)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}};customElements.get("hyperframes-player")||customElements.define("hyperframes-player",$e);0&&(module.exports={HyperframesPlayer,SPEED_PRESETS,formatSpeed,formatTime});