@hyperframes/player 0.8.186 → 0.8.189

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 We=Object.defineProperty;var ei=Object.getOwnPropertyDescriptor;var ti=Object.getOwnPropertyNames;var ni=Object.prototype.hasOwnProperty;var ii=(t,e)=>{for(var n in e)We(t,n,{get:e[n],enumerable:!0})},ri=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ti(e))!ni.call(t,r)&&r!==n&&We(t,r,{get:()=>e[r],enumerable:!(i=ei(e,r))||i.enumerable});return t};var oi=t=>ri(We({},"__esModule",{value:!0}),t);var Jr={};ii(Jr,{HyperframesPlayer:()=>He,SPEED_PRESETS:()=>ut,formatSpeed:()=>se,formatTime:()=>Ce});module.exports=oi(Jr);var Ct=t=>t!==null&&Number.isFinite(t)&&t>0;function ve(t){let e=t.clipEndsSeconds.filter(i=>i===null).length;if(Ct(t.authoredDurationSeconds))return{seconds:t.authoredDurationSeconds,source:"authored",pendingClips:e};let n=t.clipEndsSeconds.filter(Ct);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 ai="http://www.w3.org/1999/xhtml";function Dt(t){return t!=null&&t.nodeType===1}function Ge(t){return Dt(t)&&t.namespaceURI===ai}function Be(t,e){return Ge(t)&&t.localName===e}function si(t){return Be(t,"video")}function ui(t){return Be(t,"audio")}function M(t){return si(t)||ui(t)}function $e(t){return Be(t,"img")}function Ae(t){if(t==null||t.trim()==="")return null;let e=Number.parseInt(t,10);return Number.isFinite(e)&&e>0?e:null}function Se(t=document){let e=t.querySelector('[data-composition-id][data-root="true"]');return Ge(e)?e:t.querySelector("[data-composition-id]")}var V=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),io=Object.freeze([V.start,V.duration,V.trackIndex]),ro=Object.freeze([V.derivedEnd]),oo=Object.freeze([V.derivedEnd,V.legacyTrack]);function ze(t){if(t==null||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}var Nt=t=>{let e=ze(t);return e!==null&&e>=0?e:null};function Pt(t){return Nt(t("data-playback-start"))??Nt(t("data-media-start"))??0}var K=.1,J=10;function je(t){return Number.isFinite(t)&&t>0?Math.max(K,Math.min(J,t)):1}function Lt(t,e=1){let n=Number.parseFloat(t("data-playback-rate")??"");return je(Number.isFinite(n)&&n>0?n:e)}function qe(t){let e=ze(t("data-duration"));return e!==null&&e>0?e:null}function Ot(t,e){let n=qe(t);if(n!==null)return n;let i=ze(t("data-end"));return i!==null?i-e:null}var li=3;function Ye(t,e,n){return Number.isFinite(t)?Math.max(0,t-e)/je(n):null}function Xe(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:li,source:"default"};if(i===null)return{seconds:null,source:"pending",reason:"source duration not yet probed"};let a=Ye(i,r,o);return a===null?{seconds:null,source:"pending",reason:"source reported a non-finite duration"}:{seconds:a,source:"media"}}var Vt="data-fx-chain",so=Vt.slice(5);var Z=(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}),Ke=(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}),Ft={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."},Ut=[{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:[Z("frequency","Frequency",1e3),Ee(-40,40,0),Ke(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[Z("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:[Z("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:[Z("frequency","Cutoff",300,20,2e4),Ke(.707),Ft],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies, which darkens or muffles a track.",params:[Z("frequency","Cutoff",8e3,100,2e4),Ke(.707),Ft],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"}],uo=new Map(Ut.map(t=>[t.id,t]));var lo=Ut.map(t=>t.id);function di(t){return 10**(t/20)}var Ht=di(12);var Ze="data-automation",yo=Ze.slice(5),Je=1,ci=512,I=class extends Error{constructor(e){super(e),this.name="AudioAutomationError"}},Te="volume",Re="rate";function Wt(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]===mi){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 mi="preset";var pi={min:0,max:Ht,step:.01,unit:"",label:"Volume",scale:"linear",default:1},fi={min:K,max:J,step:.05,unit:"x",label:"Speed",scale:"log",default:1};function Q(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 hi(t){let e=Q(t);return e===null||e===0?0:Math.min(1,Math.max(-1,e))}function Gt(t,e){let n=Q(t),i=Q(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 bi(t){let e=hi(t?.curve),n=Gt(t?.viaX,t?.viaY);return{...e?{curve:e}:{},...n?{viaX:n.x,viaY:n.y}:{}}}function gi(t,e){let n=Q(t?.t),i=Q(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,...bi(t)}}function _i(t,e){let n=t.map(r=>gi(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,ci)}function yi(t){let e=[];for(let n of t.lanes){if(!Wt(n.target))continue;let i=n.target===Te?pi:n.target===Re?fi:null,r=_i(n.points??[],i);r.length>0&&e.push({target:n.target,points:r})}return{version:Je,lanes:e}}function Bt(t){let e;try{e=JSON.parse(t)}catch(r){throw new I(`Automation is not valid JSON: ${r.message}`)}if(typeof e!="object"||e===null)throw new I("Automation must be a JSON object.");let n=e;if(n.version!==Je)throw new I(`Unsupported automation version: ${String(n.version)}`);if(!Array.isArray(n.lanes))throw new I("Automation is missing a `lanes` array.");let i=n.lanes.map((r,o)=>{if(typeof r!="object"||r===null)throw new I(`Lane ${o} is not an object.`);let a=r;if(typeof a.target!="string"||!Wt(a.target))throw new I(`Lane ${o} has an unreadable target: ${String(a.target)}`);if(!Array.isArray(a.points))throw new I(`Lane ${o} is missing a \`points\` array.`);return{target:a.target,points:a.points}});return yi({version:Je,lanes:i})}function vi(t,e){return e?Math.pow(t,Math.pow(2,2*e)):t}function Ai(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,u=Math.min(o,Math.max(1,a,s));return{cx:t+n/u,cy:e+i/u,w:u}}function Si(t,e,n){let{cx:i,cy:r,w:o}=Ai(e,n),a=2-2*o,s=t*a-1+2*o*i,u=-t*a-2*o*i,d=Ei(s,u,t),m=1-d,g=m*m+2*o*d*m+d*d;return g>0?(2*o*r*d*m+d*d)/g:t}function Ei(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 Ti(t,e){let n=Gt(e.viaX,e.viaY);return n?Si(Math.min(1,Math.max(0,t)),n.x,n.y):vi(t,e.curve)}function Ri(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 we(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 g=a+s>>1;i[g].t<=e?a=g:s=g}let u=i[a],d=i[s],m=d.t-u.t;return m<=0?d.v:Ri(u.v,d.v,Ti((e-u.t)/m,u),n)}var xe=new Map,wi=64;function $t(t,e=Te){let n=`${e}\0${t}`,i=xe.get(n);if(i!==void 0)return i;let r=null;try{r=Bt(t).lanes.find(o=>o.target===e)??null}catch{r=null}return xe.size>wi&&xe.clear(),xe.set(n,r),r}var zt=48,jt=new WeakMap;function xi(t){let e=t.points,n=e[0].v,i=e[e.length-1].v,r=[0],o=[0],a=u=>{let d=r[r.length-1];if(u<=d)return;let m=we(t,d,"log");r.push(u),o.push(o[o.length-1]+(m+we(t,u,"log"))/2*(u-d))},s=Math.max(0,e[0].t);a(s);for(let u=1;u<e.length;u+=1){let d=e[u-1].t,m=e[u].t;if(!(m<=0))for(let g=1;g<=zt;g+=1)a(Math.max(d,0)+(m-d)*g/zt)}return{ts:Float64Array.from(r),ss:Float64Array.from(o),firstRate:n,lastRate:i}}function ki(t){let e=jt.get(t);return e||(e=xi(t),jt.set(t,e)),e}function Mi(t){return typeof t!="number"&&t.points.length>0}function Ii(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 Qe(t,e){if(typeof t=="number")return e/t;if(!Mi(t))return e;let{ts:n,ss:i,firstRate:r,lastRate:o}=ki(t),a=n.length-1;return e<=0?e/r:e>=i[a]?n[a]+(e-i[a])/o:Ii(i,n,e)}function Ci(t){return t?$t(t,Re):null}function qt(t,e){return Ci(t)??e}var wo=[{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 v=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),ko=Object.freeze([v.start,v.duration,v.trackIndex]),Mo=Object.freeze([v.derivedEnd]),Io=Object.freeze([v.derivedEnd,v.legacyTrack]);function C(t){if(t==null||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}var Kt=/^[A-Za-z0-9_.:-]+$/;function Jt(t,e){let n=t.charCodeAt(e);return n>=48&&n<=57}function Yt(t,e){let n=e;for(;n>=0&&Jt(t,n);)n--;return n}function Di(t,e){let n=e;for(;n>=0&&(t[n]??"").trim()==="";)n--;return n}function Ni(t){let e=t.length-1;if(!Jt(t,e))return null;let n=Yt(t,e);return t[n]==="."&&(n=Yt(t,n-1)),n+1}function Pi(t){let e=Ni(t);if(e==null)return null;let n=Di(t,e-1),i=t[n];if(i!=="+"&&i!=="-")return null;let r=t.slice(0,n).trim();if(!Kt.test(r))return null;let o=Number(t.slice(e));return Number.isFinite(o)?{refId:r,operator:i,magnitude:o}:null}function ee(t){let e=(t??"").trim();if(!e)return null;let n=C(e);if(n!=null)return{kind:"absolute",value:n};if(Kt.test(e))return{kind:"reference",refId:e,offset:0};let i=Pi(e);return i?{kind:"reference",refId:i.refId,offset:i.operator==="-"?-i.magnitude:i.magnitude}:null}function T(t,e,n,i){t.push({code:e,attribute:n,value:i})}function Li(t,e,n,i){if(e==null||e.trim()==="")return n.defaultStart===void 0?0:n.defaultStart;if(!t)return T(i,"invalid-start",v.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)?(T(i,"unresolved-start-reference",v.start,e),null):Math.max(0,r+t.offset)}var Oi=1e-9;function Fi(t,e){return Math.abs(t-e)<=Oi}function Vi(t,e,n){let i=C(t);if(i==null){T(n,"deprecated-end",v.derivedEnd,t),T(n,"invalid-end",v.derivedEnd,t);return}if(e==null){T(n,"deprecated-end",v.derivedEnd,t);return}Fi(i,e)||(T(n,"deprecated-end",v.derivedEnd,t),T(n,"conflicting-end",v.derivedEnd,t))}function Ui(t,e,n){let i=C(t);return i==null||i<0?(T(n,"invalid-duration",v.duration,t),{duration:null,end:null,durationSource:"invalid"}):{duration:i,end:e==null?null:e+i,durationSource:"duration"}}function Hi(t,e,n){T(n,"deprecated-end",v.derivedEnd,t);let i=C(t);return i==null?(T(n,"invalid-end",v.derivedEnd,t),{duration:null,end:null,durationSource:"invalid"}):e==null?{duration:null,end:i,durationSource:"legacy-end"}:i<e?(T(n,"end-before-start",v.derivedEnd,t),{duration:null,end:null,durationSource:"invalid"}):{duration:i-e,end:i,durationSource:"legacy-end"}}function Wi(t,e,n){let i=t.getAttribute(v.duration),r=t.getAttribute(v.derivedEnd);if(i==null)return r==null?{duration:null,end:null,durationSource:"missing"}:Hi(r,e,n);let o=Ui(i,e,n);return r!=null&&Vi(r,o.end,n),o}function Xt(t,e,n,i){let r=C(t);return r==null||!Number.isInteger(r)?(T(i,"invalid-track-index",e,t),{trackIndex:0,trackSource:"invalid"}):{trackIndex:r,trackSource:n}}function Gi(t,e){let n=t.getAttribute(v.trackIndex),i=t.getAttribute(v.legacyTrack);if(n==null&&i==null)return{trackIndex:0,trackSource:"default"};if(n==null&&i!=null)return T(e,"deprecated-layer",v.legacyTrack,i),Xt(i,v.legacyTrack,"legacy-layer",e);let r=Xt(n??"",v.trackIndex,"track-index",e);if(i==null)return r;T(e,"deprecated-layer",v.legacyTrack,i);let o=C(i);return o!=null&&o!==r.trackIndex&&T(e,"conflicting-layer",v.legacyTrack,i),r}function et(t,e={}){let n=[],i=t.getAttribute(v.start),r=ee(i),o=Li(r,i,e,n),a=Wi(t,o,n),s=Gi(t,n);return{startExpression:r,start:o,...a,...s,diagnostics:n}}function P(t){return C(t)}function te(t){return Lt(e=>t.getAttribute(e),M(t)?t.defaultPlaybackRate:1)}function tt(t){return qt(t.getAttribute("data-automation"),te(t))}function nt(t){return Pt(e=>t.getAttribute(e))}function U(t,e){return Bi(e,nt(t),tt(t))}function it(t){let e=Xe({tag:"video",authoredDurationSeconds:qe(n=>t.getAttribute(n)),sourceDurationSeconds:Number.isFinite(t.duration)?t.duration:null,mediaStartSeconds:nt(t),playbackRate:te(t)});return e.source==="media"?U(t,t.duration):e.seconds}function ke(t,e=0){return!$e(t)||!t.hasAttribute("data-start")&&!t.hasAttribute("data-track-index")?null:Xe({tag:"img",authoredDurationSeconds:Ot(n=>t.getAttribute(n),e),sourceDurationSeconds:null,mediaStartSeconds:0,playbackRate:1}).seconds}function Bi(t,e,n){return typeof n=="number"?Ye(t,e,n):Number.isFinite(t)?Qe(n,Math.max(0,t-e)):null}function Zt(){return globalThis}function ne(t,e){if(typeof window>"u")return;let n=Zt(),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 $i=t=>t.paused?.()===!0?(t.startTime?.()??0)+(t.totalDuration?.()??0)/Math.abs(t.timeScale?.()||1):0;function ie(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($i));return Number.isFinite(i)?i:null}catch(e){return ne("runtime.timelineDuration",e),null}}var Qt="data-hf-authored-duration",en="data-hf-authored-end";function re(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=re(t.start);if(e==null)return null;let n=Math.max(0,e),i=re(t.duration),r=re(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=re(t.end),s=re(t.authoredEnd),u=a!=null&&a>n?a:s!=null&&s>n?s:null;return{start:n,duration:u==null?null:u-n,end:u}}var H=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),zo=Object.freeze([H.start,H.duration,H.trackIndex]),jo=Object.freeze([H.derivedEnd]),qo=Object.freeze([H.derivedEnd,H.legacyTrack]);function zi(t){if(t==null||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}var tn=t=>{let e=zi(t);return e!==null&&e>=0?e:null};function ji(t){return tn(t("data-playback-start"))??tn(t("data-media-start"))??0}var nn="data-hf-media-start-basis";function rn(t){return t?.trim().toLowerCase()==="global"?"global":"local"}function qi(t){return rn(t.basis)==="global"?t.authoredStart:t.hostStart+t.authoredStart}function on(t){return sn(t)?qi({authoredStart:t.authoredStart,hostStart:t.hostStart,basis:t.basis}):t.ordinaryStart()}function an(t){return sn(t)&&rn(t.basis)==="global"}function sn(t){return!t.hasAutoStart&&t.authoredStart!=null&&t.hostStart!==0}function rt(t){return ji(e=>t.getAttribute(e))}function un(t,e){return t-rt(e)}function W(t){let e=t.timelineRegistry??{},n=t.includeAuthoredTimingAttrs??!1,i=t.documentRef??document,r=new WeakMap,o=new WeakMap,a=new Set,s=l=>{let f=i.getElementById(l);return f||(Array.from(i.querySelectorAll("[data-composition-id]")).find(_=>_.getAttribute("data-composition-id")===l)??null)},u=(l,f)=>n?l.getAttribute(f):null,d=l=>Me({start:0,duration:l.getAttribute("data-duration"),authoredDuration:u(l,"data-hf-authored-duration")})?.duration??Me({start:R(l,0),end:l.getAttribute("data-end"),authoredEnd:u(l,"data-hf-authored-end")})?.duration??null,m=l=>l!=null&&Number.isFinite(l)&&l>0?l:null,g=l=>{let f=l.getAttribute("data-composition-id");return f?m(ie(e[f])):null},y=l=>{let f=o.get(l);if(f!==void 0)return f;let _=d(l)??m(M(l)?U(l,l.duration):null)??m(ke(l))??g(l);return o.set(l,_),_},h=l=>l.hasAttribute("data-composition-src")||l.hasAttribute("data-composition-id")||l.hasAttribute("data-composition-file"),A=l=>{let f=l.parentElement;return!f||!l.hasAttribute("data-composition-id")||ee(l.getAttribute("data-start"))?null:h(f)?f:null},b=(l,f)=>un(R(l,f),A(l)??l),S=(l,f)=>{let _=l.hasAttribute("data-composition-id")?l.parentElement?.closest("[data-composition-id]"):l.closest("[data-composition-id]");return _?b(_,f):0},D=(l,f)=>{let _=ee(l.getAttribute("data-start"));if(!_){let X=A(l);return X?R(X,f):f}if(_.kind==="absolute")return S(l,f)+Math.max(0,_.value);let x=s(_.refId);if(!x)return f;let L=R(x,0),be=y(x)??0,ge=Math.min(0,S(l,0));return Math.max(ge,L+be+_.offset)},R=(l,f)=>{let _=r.get(l);if(_!==void 0)return _??f;if(a.has(l))return f;a.add(l);try{let x=D(l,f);return r.set(l,x),x}finally{a.delete(l)}},k=l=>{let f=l.closest("[data-composition-id]");return{authoredStart:P(l.getAttribute("data-start")),hostStart:f?b(f,0):0,hasAutoStart:l.hasAttribute("data-hf-auto-start"),basis:l.getAttribute(nn)}};return{resolveStartForElement:(l,f=0)=>R(l,Math.max(0,f)),resolveDurationForElement:l=>y(l),resolveMediaStartForElement:l=>{let f=k(l);return on({...f,ordinaryStart:()=>R(l,f.hostStart)})},resolveHostStartForElement:l=>S(l,0),resolveHostSlotsForElement:l=>{let f=[];for(let _=l.parentElement;_;_=_.parentElement){if(!h(_)||A(_)||rt(_)<=0)continue;let x=R(_,0),L=d(_);f.push({start:x,end:L?x+L:1/0})}return f},isRootGlobalMediaStartForElement:l=>M(l)&&an(k(l))}}function ln(){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 dn=7200,ot=1/60,oe=t=>t!==null&&t>ot?t:null;function Yi(t){return{width:Ae(t.getAttribute("data-width")),height:Ae(t.getAttribute("data-height"))}}function Xi(t,e){let n=[];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);o==null||o<=ot||n.push(Math.max(0,r)+o)}return oe(ve({authoredDurationSeconds:null,clipEndsSeconds:n}).seconds)}function Ki(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=P(t.getAttribute("data-duration"));return oe(ve({authoredDurationSeconds:null,clipEndsSeconds:[i,...n]}).seconds)}var Ji=t=>t.hasAttribute("data-composition-id")||t.hasAttribute("data-composition-src");function Zi(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):(M(o)||Ji(o))&&i.push(null)}(n||t.querySelector("[data-lottie-src]"))&&i.push(null);let r=ve({authoredDurationSeconds:null,clipEndsSeconds:i});return r.pendingClips>0?{...r,seconds:null,source:"unresolved",reason:"a clip's length is pending"}:r}function Qi(t){if(t.declared!==null&&Number.isFinite(t.declared)&&t.declared>0)return t.declared;let e=oe(t.timeline()),n=Math.max(0,...t.floors().map(u=>u??0)),i=Number.isFinite(t.fallback)&&t.fallback>ot?t.fallback:0,r=Math.max(n,i),a=e!==null&&e>=dn&&oe(r)!==null?null:e,s;return a!==null?s=Math.max(a,r):oe(n)!==null?s=r:i>0?s=i:s=t.derived(),s>0?s:0}function cn(t){let e=Se(t);if(!e)return null;let n=W({timelineRegistry:{},includeAuthoredTimingAttrs:!0,documentRef:t}),i=Qi({declared:P(e.getAttribute("data-duration")),timeline:()=>null,floors:()=>[Xi(t,{mediaStart:n.resolveMediaStartForElement,mediaDuration:it}),Ki(e,n)],fallback:0,derived:()=>Zi(e,n,{unregisteredLottie:!1}).seconds??0});return{...Yi(e),fps:ln().canonicalFps,durationSeconds:i}}var mn="hyperframes-studio-preview";var pn="__hfPreviewErrors";function fn(t){return t.hasRuntime||t.runtimeInjected?!1:!!(t.hasNestedCompositions||t.hasTimelines&&t.attempts>=5)}function G(t){return typeof t=="object"&&t!==null}function hn(t){return G(t)&&typeof t.getDuration=="function"}function bn(t){return G(t)&&typeof t.duration=="function"&&typeof t.time=="function"&&typeof t.seek=="function"&&typeof t.play=="function"&&typeof t.pause=="function"}var B="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.186/dist/hyperframe.runtime.iife.js";function ae(t){if(t===null)return null;let e=Number.parseInt(t,10);return Number.isFinite(e)&&e>0?e:null}function er(t){let e=t?.querySelector("[data-composition-id][data-width][data-height]")??t?.querySelector("[data-width][data-height]");if(!e)return null;let n=ae(e.getAttribute("data-width")),i=ae(e.getAttribute("data-height"));return n!==null&&i!==null?{width:n,height:i}:null}function tr(t){return Array.isArray(t)?t.find(e=>typeof e=="string"&&e.trim()!==""&&e!=="[object Event]")??null:null}var Ie=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=tr(Reflect.get(n,pn));if(i!==null)return{kind:"error",message:i};let r=this._iframe.contentDocument,o=Reflect.get(n,"__timelines"),a=this.hasRuntimeBridge(n);if(fn({hasRuntime:a,hasTimelines:G(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?cn(n)?.durationSeconds??0:0}return r<=0?null:{duration:r,adapter:{...i,getDuration:()=>r},compositionSize:er(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 G(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?.()??B,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(!G(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 bn(a)?a:null}_resolvePlaybackDurationAdapter(e){let n=Reflect.get(e,"__player");if(hn(n))return{kind:"runtime",getDuration:()=>n.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var gn=`
1
+ "use strict";var Ge=Object.defineProperty;var ti=Object.getOwnPropertyDescriptor;var ni=Object.getOwnPropertyNames;var ii=Object.prototype.hasOwnProperty;var ri=(t,e)=>{for(var n in e)Ge(t,n,{get:e[n],enumerable:!0})},oi=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ni(e))!ii.call(t,r)&&r!==n&&Ge(t,r,{get:()=>e[r],enumerable:!(i=ti(e,r))||i.enumerable});return t};var ai=t=>oi(Ge({},"__esModule",{value:!0}),t);var Zr={};ri(Zr,{HyperframesPlayer:()=>He,SPEED_PRESETS:()=>ut,formatSpeed:()=>se,formatTime:()=>Ce});module.exports=ai(Zr);var Ct=t=>t!==null&&Number.isFinite(t)&&t>0;function ve(t){let e=t.clipEndsSeconds.filter(i=>i===null).length;if(Ct(t.authoredDurationSeconds))return{seconds:t.authoredDurationSeconds,source:"authored",pendingClips:e};let n=t.clipEndsSeconds.filter(Ct);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 si="http://www.w3.org/1999/xhtml";function Dt(t){return t!=null&&t.nodeType===1}function We(t){return Dt(t)&&t.namespaceURI===si}function Be(t,e){return We(t)&&t.localName===e}function ui(t){return Be(t,"video")}function li(t){return Be(t,"audio")}function M(t){return ui(t)||li(t)}function $e(t){return Be(t,"img")}function Ae(t){if(t==null||t.trim()==="")return null;let e=Number.parseInt(t,10);return Number.isFinite(e)&&e>0?e:null}function Se(t=document){let e=t.querySelector('[data-composition-id][data-root="true"]');return We(e)?e:t.querySelector("[data-composition-id]")}var V=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),ro=Object.freeze([V.start,V.duration,V.trackIndex]),oo=Object.freeze([V.derivedEnd]),ao=Object.freeze([V.derivedEnd,V.legacyTrack]);function ze(t){if(t==null||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}var Nt=t=>{let e=ze(t);return e!==null&&e>=0?e:null};function Pt(t){return Nt(t("data-playback-start"))??Nt(t("data-media-start"))??0}var K=.1,J=10;function je(t){return Number.isFinite(t)&&t>0?Math.max(K,Math.min(J,t)):1}function Lt(t,e=1){let n=Number.parseFloat(t("data-playback-rate")??"");return je(Number.isFinite(n)&&n>0?n:e)}function qe(t){let e=ze(t("data-duration"));return e!==null&&e>0?e:null}function Ot(t,e){let n=qe(t);if(n!==null)return n;let i=ze(t("data-end"));return i!==null?i-e:null}var di=3;function Ye(t,e,n){return Number.isFinite(t)?Math.max(0,t-e)/je(n):null}function Xe(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:di,source:"default"};if(i===null)return{seconds:null,source:"pending",reason:"source duration not yet probed"};let a=Ye(i,r,o);return a===null?{seconds:null,source:"pending",reason:"source reported a non-finite duration"}:{seconds:a,source:"media"}}var Vt="data-fx-chain",uo=Vt.slice(5);var Z=(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}),Ke=(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}),Ft={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."},Ut=[{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:[Z("frequency","Frequency",1e3),Ee(-40,40,0),Ke(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[Z("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:[Z("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:[Z("frequency","Cutoff",300,20,2e4),Ke(.707),Ft],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies, which darkens or muffles a track.",params:[Z("frequency","Cutoff",8e3,100,2e4),Ke(.707),Ft],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"}],lo=new Map(Ut.map(t=>[t.id,t]));var co=Ut.map(t=>t.id);function ci(t){return 10**(t/20)}var Ht=ci(12);var Ze="data-automation",vo=Ze.slice(5),Je=1,pi=512,I=class extends Error{constructor(e){super(e),this.name="AudioAutomationError"}},Te="volume",Re="rate";function Wt(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]===fi){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 fi="preset";var hi={min:0,max:Ht,step:.01,unit:"",label:"Volume",scale:"linear",default:1};var bi={min:K,max:J,step:.05,unit:"x",label:"Speed",scale:"log",default:1};function Q(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 gi(t){let e=Q(t);return e===null||e===0?0:Math.min(1,Math.max(-1,e))}function Bt(t,e){let n=Q(t),i=Q(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 _i(t){let e=gi(t?.curve),n=Bt(t?.viaX,t?.viaY);return{...e?{curve:e}:{},...n?{viaX:n.x,viaY:n.y}:{}}}function yi(t,e){let n=Q(t?.t),i=Q(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,..._i(t)}}function vi(t,e){let n=t.map(r=>yi(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,pi)}function Ai(t){let e=[];for(let n of t.lanes){if(!Wt(n.target))continue;let i=n.target===Te?hi:n.target===Re?bi:null,r=vi(n.points??[],i);r.length>0&&e.push({target:n.target,points:r})}return{version:Je,lanes:e}}function $t(t){let e;try{e=JSON.parse(t)}catch(r){throw new I(`Automation is not valid JSON: ${r.message}`)}if(typeof e!="object"||e===null)throw new I("Automation must be a JSON object.");let n=e;if(n.version!==Je)throw new I(`Unsupported automation version: ${String(n.version)}`);if(!Array.isArray(n.lanes))throw new I("Automation is missing a `lanes` array.");let i=n.lanes.map((r,o)=>{if(typeof r!="object"||r===null)throw new I(`Lane ${o} is not an object.`);let a=r;if(typeof a.target!="string"||!Wt(a.target))throw new I(`Lane ${o} has an unreadable target: ${String(a.target)}`);if(!Array.isArray(a.points))throw new I(`Lane ${o} is missing a \`points\` array.`);return{target:a.target,points:a.points}});return Ai({version:Je,lanes:i})}function Si(t,e){return e?Math.pow(t,Math.pow(2,2*e)):t}function Ei(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,u=Math.min(o,Math.max(1,a,s));return{cx:t+n/u,cy:e+i/u,w:u}}function Ti(t,e,n){let{cx:i,cy:r,w:o}=Ei(e,n),a=2-2*o,s=t*a-1+2*o*i,u=-t*a-2*o*i,d=Ri(s,u,t),m=1-d,g=m*m+2*o*d*m+d*d;return g>0?(2*o*r*d*m+d*d)/g:t}function Ri(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 xi(t,e){let n=Bt(e.viaX,e.viaY);return n?Ti(Math.min(1,Math.max(0,t)),n.x,n.y):Si(t,e.curve)}function wi(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 g=a+s>>1;i[g].t<=e?a=g:s=g}let u=i[a],d=i[s],m=d.t-u.t;return m<=0?d.v:wi(u.v,d.v,xi((e-u.t)/m,u),n)}var we=new Map,ki=64;function zt(t,e=Te){let n=`${e}\0${t}`,i=we.get(n);if(i!==void 0)return i;let r=null;try{r=$t(t).lanes.find(o=>o.target===e)??null}catch{r=null}return we.size>ki&&we.clear(),we.set(n,r),r}var jt=48,qt=new WeakMap;function Mi(t){let e=t.points,n=e[0].v,i=e[e.length-1].v,r=[0],o=[0],a=u=>{let d=r[r.length-1];if(u<=d)return;let m=xe(t,d,"log");r.push(u),o.push(o[o.length-1]+(m+xe(t,u,"log"))/2*(u-d))},s=Math.max(0,e[0].t);a(s);for(let u=1;u<e.length;u+=1){let d=e[u-1].t,m=e[u].t;if(!(m<=0))for(let g=1;g<=jt;g+=1)a(Math.max(d,0)+(m-d)*g/jt)}return{ts:Float64Array.from(r),ss:Float64Array.from(o),firstRate:n,lastRate:i}}function Ii(t){let e=qt.get(t);return e||(e=Mi(t),qt.set(t,e)),e}function Ci(t){return typeof t!="number"&&t.points.length>0}function Di(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 Qe(t,e){if(typeof t=="number")return e/t;if(!Ci(t))return e;let{ts:n,ss:i,firstRate:r,lastRate:o}=Ii(t),a=n.length-1;return e<=0?e/r:e>=i[a]?n[a]+(e-i[a])/o:Di(i,n,e)}function Ni(t){return t?zt(t,Re):null}function Yt(t,e){return Ni(t)??e}var wo=[{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 v=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),Mo=Object.freeze([v.start,v.duration,v.trackIndex]),Io=Object.freeze([v.derivedEnd]),Co=Object.freeze([v.derivedEnd,v.legacyTrack]);function C(t){if(t==null||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}var Jt=/^[A-Za-z0-9_.:-]+$/;function Zt(t,e){let n=t.charCodeAt(e);return n>=48&&n<=57}function Xt(t,e){let n=e;for(;n>=0&&Zt(t,n);)n--;return n}function Pi(t,e){let n=e;for(;n>=0&&(t[n]??"").trim()==="";)n--;return n}function Li(t){let e=t.length-1;if(!Zt(t,e))return null;let n=Xt(t,e);return t[n]==="."&&(n=Xt(t,n-1)),n+1}function Oi(t){let e=Li(t);if(e==null)return null;let n=Pi(t,e-1),i=t[n];if(i!=="+"&&i!=="-")return null;let r=t.slice(0,n).trim();if(!Jt.test(r))return null;let o=Number(t.slice(e));return Number.isFinite(o)?{refId:r,operator:i,magnitude:o}:null}function ee(t){let e=(t??"").trim();if(!e)return null;let n=C(e);if(n!=null)return{kind:"absolute",value:n};if(Jt.test(e))return{kind:"reference",refId:e,offset:0};let i=Oi(e);return i?{kind:"reference",refId:i.refId,offset:i.operator==="-"?-i.magnitude:i.magnitude}:null}function T(t,e,n,i){t.push({code:e,attribute:n,value:i})}function Fi(t,e,n,i){if(e==null||e.trim()==="")return n.defaultStart===void 0?0:n.defaultStart;if(!t)return T(i,"invalid-start",v.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)?(T(i,"unresolved-start-reference",v.start,e),null):Math.max(0,r+t.offset)}var Vi=1e-9;function Ui(t,e){return Math.abs(t-e)<=Vi}function Hi(t,e,n){let i=C(t);if(i==null){T(n,"deprecated-end",v.derivedEnd,t),T(n,"invalid-end",v.derivedEnd,t);return}if(e==null){T(n,"deprecated-end",v.derivedEnd,t);return}Ui(i,e)||(T(n,"deprecated-end",v.derivedEnd,t),T(n,"conflicting-end",v.derivedEnd,t))}function Gi(t,e,n){let i=C(t);return i==null||i<0?(T(n,"invalid-duration",v.duration,t),{duration:null,end:null,durationSource:"invalid"}):{duration:i,end:e==null?null:e+i,durationSource:"duration"}}function Wi(t,e,n){T(n,"deprecated-end",v.derivedEnd,t);let i=C(t);return i==null?(T(n,"invalid-end",v.derivedEnd,t),{duration:null,end:null,durationSource:"invalid"}):e==null?{duration:null,end:i,durationSource:"legacy-end"}:i<e?(T(n,"end-before-start",v.derivedEnd,t),{duration:null,end:null,durationSource:"invalid"}):{duration:i-e,end:i,durationSource:"legacy-end"}}function Bi(t,e,n){let i=t.getAttribute(v.duration),r=t.getAttribute(v.derivedEnd);if(i==null)return r==null?{duration:null,end:null,durationSource:"missing"}:Wi(r,e,n);let o=Gi(i,e,n);return r!=null&&Hi(r,o.end,n),o}function Kt(t,e,n,i){let r=C(t);return r==null||!Number.isInteger(r)?(T(i,"invalid-track-index",e,t),{trackIndex:0,trackSource:"invalid"}):{trackIndex:r,trackSource:n}}function $i(t,e){let n=t.getAttribute(v.trackIndex),i=t.getAttribute(v.legacyTrack);if(n==null&&i==null)return{trackIndex:0,trackSource:"default"};if(n==null&&i!=null)return T(e,"deprecated-layer",v.legacyTrack,i),Kt(i,v.legacyTrack,"legacy-layer",e);let r=Kt(n??"",v.trackIndex,"track-index",e);if(i==null)return r;T(e,"deprecated-layer",v.legacyTrack,i);let o=C(i);return o!=null&&o!==r.trackIndex&&T(e,"conflicting-layer",v.legacyTrack,i),r}function et(t,e={}){let n=[],i=t.getAttribute(v.start),r=ee(i),o=Fi(r,i,e,n),a=Bi(t,o,n),s=$i(t,n);return{startExpression:r,start:o,...a,...s,diagnostics:n}}function P(t){return C(t)}function te(t){return Lt(e=>t.getAttribute(e),M(t)?t.defaultPlaybackRate:1)}function tt(t){return Yt(t.getAttribute("data-automation"),te(t))}function nt(t){return Pt(e=>t.getAttribute(e))}function U(t,e){return zi(e,nt(t),tt(t))}function it(t){let e=Xe({tag:"video",authoredDurationSeconds:qe(n=>t.getAttribute(n)),sourceDurationSeconds:Number.isFinite(t.duration)?t.duration:null,mediaStartSeconds:nt(t),playbackRate:te(t)});return e.source==="media"?U(t,t.duration):e.seconds}function ke(t,e=0){return!$e(t)||!t.hasAttribute("data-start")&&!t.hasAttribute("data-track-index")?null:Xe({tag:"img",authoredDurationSeconds:Ot(n=>t.getAttribute(n),e),sourceDurationSeconds:null,mediaStartSeconds:0,playbackRate:1}).seconds}function zi(t,e,n){return typeof n=="number"?Ye(t,e,n):Number.isFinite(t)?Qe(n,Math.max(0,t-e)):null}function Qt(){return globalThis}function ne(t,e){if(typeof window>"u")return;let n=Qt(),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 ji=t=>t.paused?.()===!0?(t.startTime?.()??0)+(t.totalDuration?.()??0)/Math.abs(t.timeScale?.()||1):0;function ie(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(ji));return Number.isFinite(i)?i:null}catch(e){return ne("runtime.timelineDuration",e),null}}var en="data-hf-authored-duration",tn="data-hf-authored-end";function re(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=re(t.start);if(e==null)return null;let n=Math.max(0,e),i=re(t.duration),r=re(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=re(t.end),s=re(t.authoredEnd),u=a!=null&&a>n?a:s!=null&&s>n?s:null;return{start:n,duration:u==null?null:u-n,end:u}}var H=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),jo=Object.freeze([H.start,H.duration,H.trackIndex]),qo=Object.freeze([H.derivedEnd]),Yo=Object.freeze([H.derivedEnd,H.legacyTrack]);function qi(t){if(t==null||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}var nn=t=>{let e=qi(t);return e!==null&&e>=0?e:null};function Yi(t){return nn(t("data-playback-start"))??nn(t("data-media-start"))??0}var rn="data-hf-media-start-basis";function on(t){return t?.trim().toLowerCase()==="global"?"global":"local"}function Xi(t){return on(t.basis)==="global"?t.authoredStart:t.hostStart+t.authoredStart}function an(t){return un(t)?Xi({authoredStart:t.authoredStart,hostStart:t.hostStart,basis:t.basis}):t.ordinaryStart()}function sn(t){return un(t)&&on(t.basis)==="global"}function un(t){return!t.hasAutoStart&&t.authoredStart!=null&&t.hostStart!==0}function rt(t){return Yi(e=>t.getAttribute(e))}function ln(t,e){return t-rt(e)}function G(t){let e=t.timelineRegistry??{},n=t.includeAuthoredTimingAttrs??!1,i=t.documentRef??document,r=new WeakMap,o=new WeakMap,a=new Set,s=l=>{let f=i.getElementById(l);return f||(Array.from(i.querySelectorAll("[data-composition-id]")).find(_=>_.getAttribute("data-composition-id")===l)??null)},u=(l,f)=>n?l.getAttribute(f):null,d=l=>Me({start:0,duration:l.getAttribute("data-duration"),authoredDuration:u(l,"data-hf-authored-duration")})?.duration??Me({start:R(l,0),end:l.getAttribute("data-end"),authoredEnd:u(l,"data-hf-authored-end")})?.duration??null,m=l=>l!=null&&Number.isFinite(l)&&l>0?l:null,g=l=>{let f=l.getAttribute("data-composition-id");return f?m(ie(e[f])):null},y=l=>{let f=o.get(l);if(f!==void 0)return f;let _=d(l)??m(M(l)?U(l,l.duration):null)??m(ke(l))??g(l);return o.set(l,_),_},h=l=>l.hasAttribute("data-composition-src")||l.hasAttribute("data-composition-id")||l.hasAttribute("data-composition-file"),A=l=>{let f=l.parentElement;return!f||!l.hasAttribute("data-composition-id")||ee(l.getAttribute("data-start"))?null:h(f)?f:null},b=(l,f)=>ln(R(l,f),A(l)??l),S=(l,f)=>{let _=l.hasAttribute("data-composition-id")?l.parentElement?.closest("[data-composition-id]"):l.closest("[data-composition-id]");return _?b(_,f):0},D=(l,f)=>{let _=ee(l.getAttribute("data-start"));if(!_){let X=A(l);return X?R(X,f):f}if(_.kind==="absolute")return S(l,f)+Math.max(0,_.value);let w=s(_.refId);if(!w)return f;let L=R(w,0),be=y(w)??0,ge=Math.min(0,S(l,0));return Math.max(ge,L+be+_.offset)},R=(l,f)=>{let _=r.get(l);if(_!==void 0)return _??f;if(a.has(l))return f;a.add(l);try{let w=D(l,f);return r.set(l,w),w}finally{a.delete(l)}},k=l=>{let f=l.closest("[data-composition-id]");return{authoredStart:P(l.getAttribute("data-start")),hostStart:f?b(f,0):0,hasAutoStart:l.hasAttribute("data-hf-auto-start"),basis:l.getAttribute(rn)}};return{resolveStartForElement:(l,f=0)=>R(l,Math.max(0,f)),resolveDurationForElement:l=>y(l),resolveMediaStartForElement:l=>{let f=k(l);return an({...f,ordinaryStart:()=>R(l,f.hostStart)})},resolveHostStartForElement:l=>S(l,0),resolveHostSlotsForElement:l=>{let f=[];for(let _=l.parentElement;_;_=_.parentElement){if(!h(_)||A(_)||rt(_)<=0)continue;let w=R(_,0),L=d(_);f.push({start:w,end:L?w+L:1/0})}return f},isRootGlobalMediaStartForElement:l=>M(l)&&sn(k(l))}}function dn(){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 cn=7200,ot=1/60,oe=t=>t!==null&&t>ot?t:null;function Ki(t){return{width:Ae(t.getAttribute("data-width")),height:Ae(t.getAttribute("data-height"))}}function Ji(t,e){let n=[];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);o==null||o<=ot||n.push(Math.max(0,r)+o)}return oe(ve({authoredDurationSeconds:null,clipEndsSeconds:n}).seconds)}function Zi(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=P(t.getAttribute("data-duration"));return oe(ve({authoredDurationSeconds:null,clipEndsSeconds:[i,...n]}).seconds)}var Qi=t=>t.hasAttribute("data-composition-id")||t.hasAttribute("data-composition-src");function er(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):(M(o)||Qi(o))&&i.push(null)}(n||t.querySelector("[data-lottie-src]"))&&i.push(null);let r=ve({authoredDurationSeconds:null,clipEndsSeconds:i});return r.pendingClips>0?{...r,seconds:null,source:"unresolved",reason:"a clip's length is pending"}:r}function tr(t){if(t.declared!==null&&Number.isFinite(t.declared)&&t.declared>0)return t.declared;let e=oe(t.timeline()),n=Math.max(0,...t.floors().map(u=>u??0)),i=Number.isFinite(t.fallback)&&t.fallback>ot?t.fallback:0,r=Math.max(n,i),a=e!==null&&e>=cn&&oe(r)!==null?null:e,s;return a!==null?s=Math.max(a,r):oe(n)!==null?s=r:i>0?s=i:s=t.derived(),s>0?s:0}function mn(t){let e=Se(t);if(!e)return null;let n=G({timelineRegistry:{},includeAuthoredTimingAttrs:!0,documentRef:t}),i=tr({declared:P(e.getAttribute("data-duration")),timeline:()=>null,floors:()=>[Ji(t,{mediaStart:n.resolveMediaStartForElement,mediaDuration:it}),Zi(e,n)],fallback:0,derived:()=>er(e,n,{unregisteredLottie:!1}).seconds??0});return{...Ki(e),fps:dn().canonicalFps,durationSeconds:i}}var pn="hyperframes-studio-preview";var fn="__hfPreviewErrors";function hn(t){return t.hasRuntime||t.runtimeInjected?!1:!!(t.hasNestedCompositions||t.hasTimelines&&t.attempts>=5)}function W(t){return typeof t=="object"&&t!==null}function bn(t){return W(t)&&typeof t.getDuration=="function"}function gn(t){return W(t)&&typeof t.duration=="function"&&typeof t.time=="function"&&typeof t.seek=="function"&&typeof t.play=="function"&&typeof t.pause=="function"}var B="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.189/dist/hyperframe.runtime.iife.js";function ae(t){if(t===null)return null;let e=Number.parseInt(t,10);return Number.isFinite(e)&&e>0?e:null}function nr(t){let e=t?.querySelector("[data-composition-id][data-width][data-height]")??t?.querySelector("[data-width][data-height]");if(!e)return null;let n=ae(e.getAttribute("data-width")),i=ae(e.getAttribute("data-height"));return n!==null&&i!==null?{width:n,height:i}:null}function ir(t){return Array.isArray(t)?t.find(e=>typeof e=="string"&&e.trim()!==""&&e!=="[object Event]")??null:null}var Ie=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=ir(Reflect.get(n,fn));if(i!==null)return{kind:"error",message:i};let r=this._iframe.contentDocument,o=Reflect.get(n,"__timelines"),a=this.hasRuntimeBridge(n);if(hn({hasRuntime:a,hasTimelines:W(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?mn(n)?.durationSeconds??0:0}return r<=0?null:{duration:r,adapter:{...i,getDuration:()=>r},compositionSize:nr(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 W(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?.()??B,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(!W(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 gn(a)?a:null}_resolvePlaybackDurationAdapter(e){let n=Reflect.get(e,"__player");if(bn(n))return{kind:"runtime",getDuration:()=>n.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var _n=`
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
- `,_n='<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>',yn='<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>',at='<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>',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"/></svg>',vn='<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 se(t){return Number.isInteger(t)?`${t}x`:`${t}x`}function Ce(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 An(t,e,n={}){let i=n.speedPresets??ut,r=document.createElement("div");r.className="hfp-controls",r.addEventListener("click",c=>{c.stopPropagation()});let o=document.createElement("button");o.className="hfp-play-btn",o.type="button",o.innerHTML=`<span class="hfp-ico hfp-ico-play">${_n}</span><span class="hfp-ico hfp-ico-pause">${yn}</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 u=document.createElement("span");u.className="hfp-time",u.textContent="0:00 / 0:00";let d=document.createElement("div");d.className="hfp-speed-wrap";let m=document.createElement("button");m.className="hfp-speed-btn",m.type="button",m.textContent="1x",m.setAttribute("aria-label","Playback speed");let g=document.createElement("div");g.className="hfp-speed-menu",g.setAttribute("role","menu");for(let c of i){let p=document.createElement("button");p.className="hfp-speed-option",p.type="button",p.setAttribute("role","menuitem"),p.dataset.speed=String(c),p.textContent=se(c),c===1&&p.classList.add("hfp-active"),g.appendChild(p)}d.appendChild(g),d.appendChild(m);let y=document.createElement("div");y.className="hfp-volume-wrap";let h=document.createElement("button");h.className="hfp-mute-btn",h.type="button",h.innerHTML=at,h.setAttribute("aria-label","Mute");let A=document.createElement("div");A.className="hfp-volume-slider-wrap";let b=document.createElement("div");b.className="hfp-volume-slider",b.setAttribute("role","slider"),b.setAttribute("aria-label","Volume"),b.setAttribute("aria-valuemin","0"),b.setAttribute("aria-valuemax","100"),b.setAttribute("aria-valuenow","100"),b.tabIndex=0;let S=document.createElement("div");S.className="hfp-volume-fill",S.style.width="100%",b.appendChild(S),A.appendChild(b),y.appendChild(A),y.appendChild(h),n.audioLocked&&(y.style.display="none"),r.appendChild(o),r.appendChild(a),r.appendChild(u),r.appendChild(y),r.appendChild(d),t.appendChild(r);let D=!1,R=!1,k=1,F=null,q=i.indexOf(1);q===-1&&(q=0);let Y=(c,p)=>c?vn:p===0?st:p<.5?st:at;o.addEventListener("click",c=>{c.stopPropagation(),D?e.onPause():e.onPlay()}),h.addEventListener("click",c=>{c.stopPropagation(),e.onMuteToggle()});let l=!1,f=c=>{let p=b.getBoundingClientRect(),E=Math.max(0,Math.min(1,(c-p.left)/p.width));k=E,S.style.width=`${E*100}%`,b.setAttribute("aria-valuenow",String(Math.round(E*100))),R&&E>0&&e.onMuteToggle(),h.innerHTML=Y(R,E),e.onVolumeChange(E)};b.addEventListener("mousedown",c=>{c.stopPropagation(),l=!0,f(c.clientX)});let _=c=>{l&&f(c.clientX)},x=()=>{l=!1};document.addEventListener("mousemove",_),document.addEventListener("mouseup",x),b.addEventListener("touchstart",c=>{l=!0;let p=c.touches[0];p&&f(p.clientX)},{passive:!0});let L=c=>{if(l){let p=c.touches[0];p&&f(p.clientX)}},be=()=>{l=!1};document.addEventListener("touchmove",L,{passive:!0}),document.addEventListener("touchend",be);let ge=.05;b.addEventListener("keydown",c=>{let p=k;if(c.key==="ArrowRight"||c.key==="ArrowUp")p=Math.min(1,k+ge);else if(c.key==="ArrowLeft"||c.key==="ArrowDown")p=Math.max(0,k-ge);else return;c.preventDefault(),c.stopPropagation(),k=p,S.style.width=`${p*100}%`,b.setAttribute("aria-valuenow",String(Math.round(p*100))),R&&p>0&&e.onMuteToggle(),h.innerHTML=Y(R,p),e.onVolumeChange(p)});let X=c=>{for(let p of g.querySelectorAll(".hfp-speed-option"))p.classList.toggle("hfp-active",p.dataset.speed===String(c))};m.addEventListener("click",c=>{c.stopPropagation();let p=g.classList.toggle("hfp-open");m.setAttribute("aria-expanded",String(p))}),g.addEventListener("click",c=>{c.stopPropagation();let p=c.target.closest(".hfp-speed-option");if(!p)return;let E=parseFloat(p.dataset.speed);q=i.indexOf(E),m.textContent=se(E),X(E),g.classList.remove("hfp-open"),m.setAttribute("aria-expanded","false"),e.onSpeedChange(E)});let Et=()=>{g.classList.remove("hfp-open"),m.setAttribute("aria-expanded","false")};document.addEventListener("click",Et);let _e=c=>{let p=a.getBoundingClientRect(),E=Math.max(0,Math.min(1,(c-p.left)/p.width));e.onSeek(E)},N=!1;a.addEventListener("mousedown",c=>{c.stopPropagation(),N=!0,e.onScrubStart?.(),_e(c.clientX)});let Tt=c=>{N&&_e(c.clientX)},Rt=()=>{N&&(N=!1,e.onScrubEnd?.())};document.addEventListener("mousemove",Tt),document.addEventListener("mouseup",Rt),a.addEventListener("touchstart",c=>{N=!0,e.onScrubStart?.();let p=c.touches[0];p&&_e(p.clientX)},{passive:!0});let wt=c=>{if(N){let p=c.touches[0];p&&_e(p.clientX)}},xt=()=>{N&&(N=!1,e.onScrubEnd?.())};document.addEventListener("touchmove",wt,{passive:!0}),document.addEventListener("touchend",xt);let kt=()=>{F&&clearTimeout(F),F=setTimeout(()=>{D&&r.classList.add("hfp-hidden")},3e3)},ye=t instanceof ShadowRoot?t.host:t,Mt=()=>{r.classList.remove("hfp-hidden"),kt()},It=()=>{D&&r.classList.add("hfp-hidden")};return ye.addEventListener("mousemove",Mt),ye.addEventListener("mouseleave",It),{updateTime(c,p){let E=p>0?Math.min(c,p):c,Qn=p>0?E/p*100:0;s.style.width=`${Qn}%`,u.textContent=`${Ce(E)} / ${Ce(p)}`},updatePlaying(c){D=c,o.classList.toggle("hfp-playing",c),o.setAttribute("aria-label",c?"Pause":"Play"),c?kt():r.classList.remove("hfp-hidden")},updateSpeed(c){let p=i.indexOf(c);p!==-1&&(q=p),m.textContent=se(c),X(c)},updateMuted(c){R=c,h.innerHTML=Y(c,k),h.setAttribute("aria-label",c?"Unmute":"Mute")},updateVolume(c){k=c,S.style.width=`${c*100}%`,b.setAttribute("aria-valuenow",String(Math.round(c*100))),h.innerHTML=Y(R,c)},setVolumeControlsHidden(c){y.style.display=c?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",Tt),document.removeEventListener("mouseup",Rt),document.removeEventListener("touchmove",wt),document.removeEventListener("touchend",xt),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",x),document.removeEventListener("touchmove",L),document.removeEventListener("touchend",be),document.removeEventListener("click",Et),ye.removeEventListener("mousemove",Mt),ye.removeEventListener("mouseleave",It),F&&clearTimeout(F),r.remove()}}}function Sn(t,e,n,i,r,o=!1){let a=i?i.split(",").map(Number).filter(d=>!isNaN(d)&&d>0):void 0,s={...a?{speedPresets:a}:{},audioLocked:o},u=An(t,r,s);return u.updateMuted(e),u.updateVolume(n),u}function lt(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 En(t){return t.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains("hfp-controls"))}var De=null;function Tn(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 Rn(){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 wn(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 nr(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 Ne=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,u=0,d=()=>{if(r()){this._raf=null;return}let m;try{m=e.time()}catch{this._raf=null;return}let g=i(),y=o();y.end>0&&(m=Math.min(m,y.end));let h=a===null?0:m-a;h!==0&&(u=Math.min(h,s),s=h),a=m;let A=nr(m,u,y);A&&(m=y.shown);let b=performance.now();if((b-this._lastUpdateMs>100||A)&&(this._lastUpdateMs=b,this._callbacks.onTimeUpdate(m,g)),A){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{e.pause(),y.shown<y.end&&e.seek(y.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(d)};this._tick=d,this._raf=requestAnimationFrame(d)}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 xn(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)rr(i)||n.push(i);return ir(t),n}function ir(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 rr(t){let e=t.parentElement;for(;e;){if(e.hasAttribute("data-composition-id"))return!0;e=e.parentElement}return!1}var kn=t=>4*Number.EPSILON*Math.max(1,Math.abs(t));function ue(t,e){return!Number.isFinite(t)||!Number.isFinite(e)?t===e:Math.abs(t-e)<=kn(Math.max(Math.abs(t),Math.abs(e)))}var Mn=(t,e)=>t>=e||ue(t,e),Pe=(t,e,n)=>Mn(t,e)&&t<n&&!ue(t,n),or=1e-6,dt=(t,e,n,i)=>Pe(t,e,n)||Mn(t,e)&&i>0&&n>=i-or;var sr="data-fade-in",ur="data-fade-out",Ka=sr.slice(5),Ja=ur.slice(5),lr=Object.freeze({fadeIn:0,fadeOut:0});var In=':not([muted]):is(:not([data-has-audio]),[data-has-audio="true"])',Qa=`audio[data-start], video[data-start]${In}`;var Fs=1/16;var mr=["backdrop-filter","clip-path","filter","mask","mask-border-source","mask-image","perspective","rotate","scale","transform","translate","-webkit-mask-image"],Gs=new Set([...mr,"contain","isolation","mask-border","mix-blend-mode","opacity"]);function pr(t){return Number.isFinite(t)&&t>0?t:30}function fr(t){return Number.isFinite(t)&&t>0?t:0}function Cn(t,e){let n=pr(e),i=fr(t),r=i*n,o=Math.round(r);return Math.abs(r-o)<=.001?o/n:i}function Dn(t,e,n){return{start:Cn(t,n),end:Number.isFinite(e)?Cn(e,n):e}}var hr=["seconds-time","rational-fps","seek-keep-playing","composition-manifest-v1","runtime-data","play-range"];function br(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 gr(t){let e=Number.isFinite(t)&&t>0?t:30,n=Number.isInteger(e)?1:1e6,i=Math.round(e*n),r=br(i,n);return{numerator:i/r,denominator:n/r}}function Nn(t,e,n){return Math.max(t,(Math.ceil(e*n-1e-6)-1)/n)}function _r(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 ct(t){return{protocolVersion:1,capabilities:hr,fps:gr(t)}}function Pn(t){let e=t.offsetWidth,n=t.getBoundingClientRect().width;return e>0&&n>0?n/e:null}function yr(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Ln(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=_r(n.fps);return i===null||!yr(n.capabilities)?{status:"unsupported",code:"invalid_protocol_metadata",receivedVersion:n.protocolVersion}:{status:"supported",fps:i,metadata:n}}function vr(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 s=e.timelineRegistry[a],u=ie(s);!(t.hasAttribute("data-duration")||t.hasAttribute("data-end")||t.hasAttribute(Qt)||t.hasAttribute(en))&&(o==null||o<=0)&&u!=null&&u>0&&(o=u)}return{start:r,end:o!=null&&o>0?r+o:Number.POSITIVE_INFINITY}}function On(t,e){let n=vr(t,e);if(!n)return!1;let i=e.exportRenderSeek?Dn(n.start,n.end,e.canonicalFps):n;return dt(e.currentTime,i.start,i.end,e.compositionDuration)}var $="first-frame",Ar=3;function le(t){let e=t.ownerDocument?.defaultView;return e&&t instanceof e.Element?!0:t instanceof Element}function w(t){if(!le(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 Sr(t){return t.hasAttribute("data-start")||t.hasAttribute("data-track-index")}function Er(t,e,n){let i=t;for(;i;){if(Sr(i)&&!On(i,{currentTime:0,compositionDuration:Number.POSITIVE_INFINITY,canonicalFps:30,exportRenderSeek:!1,timelineRegistry:n,resolver:e}))return!1;i=i.parentElement}return!0}function Fn(t,e,n,i){return e==="all"?!0:Er(t,n,i)}function Le(t,{scope:e="all"}={}){let n=t.defaultView,i=W({documentRef:t,timelineRegistry:n?.__timelines,includeAuthoredTimingAttrs:!0}),r=t.querySelector(`meta[name="${mn}"]`)!==null,o=Array.from(t.querySelectorAll("video, audio")).filter(w).filter(u=>Fn(u,r&&u.preload!=="auto"?$:e,i,n?.__timelines??{})).filter(u=>u.readyState<Ar),a=Array.from(t.querySelectorAll("img")).filter(u=>Fn(u,u.getAttribute("loading")?.toLowerCase()==="lazy"?$:e,i,n?.__timelines??{})).filter(u=>!u.complete),s=t.fonts?.status==="loading";return{pendingMedia:o,pendingImages:a,fontsLoading:s}}function Tr(t,{pendingMedia:e,pendingImages:n,fontsLoading:i},r){let o=e.map(u=>new Promise(d=>{if(u.error){d();return}let m=()=>{u.removeEventListener("canplay",m),u.removeEventListener("error",m),r.removeEventListener("abort",m),d()};u.addEventListener("canplay",m),u.addEventListener("error",m),r.addEventListener("abort",m,{once:!0})})),a=n.map(u=>u.decode?u.decode().catch(()=>{}):Promise.resolve()),s=i&&t.fonts?t.fonts.ready.then(()=>{}):Promise.resolve();return Promise.all([...o,...a,s]).then(()=>{})}function Rr(t,e,{scope:n="all"}={}){let i=Le(t,{scope:n});return i.pendingMedia.length===0&&i.pendingImages.length===0&&!i.fontsLoading?null:Tr(t,i,e)}var wr=50;function xr(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,wr)};a()})}var kr=50,Mr=1.5,Ir=2,Cr=1500;function mt(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 Dr(t,e){let n=t.defaultView;return n?(async()=>{let i=await mt(n,e);if(e.aborted)return;let r=await mt(n,e),o=r-i,a=0;for(;!e.aborted&&a<Ir;){if(r-i>=Cr)return;let s=await mt(n,e);if(e.aborted)return;let u=s-r;o=Math.min(o,u),a=u<kr||u<=o*Mr?a+1:0,r=s}})():null}var Nr=8e3;function Pr(t,e,n={}){let i=n.inputs??[(d,m)=>Rr(d,m,{scope:n.scope}),xr,Dr],r=new AbortController,o=i.map(d=>d(t,r.signal)).filter(d=>d!==null);if(o.length===0){e({timedOut:!1});return}let a=n.timeoutMs??Nr,s,u=new Promise(d=>{s=setTimeout(()=>d("timed-out"),a)});Promise.race([Promise.all(o).then(()=>"done"),u]).then(d=>{clearTimeout(s),r.abort(),e({timedOut:d==="timed-out"})})}function Vn(t,e,n={}){Pr(t,e,{...n,scope:$})}var Lr=.05,Or=2,Oe=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=et(e.source);e.start=n.start??0,e.duration=n.duration!=null&&n.duration>0?n.duration:Number.POSITIVE_INFINITY}_inWindow(e,n){return Pe(n,e.start,e.start+e.duration)}_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(),e.driftSamples=0,!1)}playAll(){for(let e of this._entries)this._playEntryIfActive(e)}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)&&(n.el.currentTime=e-n.start)}scrubAll(e){for(let n of this._entries)this._refreshEntryBounds(n),this._inWindow(n,e)?(n.el.currentTime=e-n.start,this._playEntry(n)):n.el.paused||n.el.pause()}mirrorTime(e,n){let i=n?.force===!0;for(let r of this._entries){if(this._refreshEntryBounds(r),!this._gateEntryPlayback(r,e))continue;let o=e-r.start;Math.abs(r.el.currentTime-o)>Lr?(r.driftSamples+=1,(i||r.driftSamples>=Or)&&(r.el.currentTime=o,r.driftSamples=0)):r.driftSamples=0}}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(this._urlTaken(e))return null;let a=n==="video"?document.createElement("video"):new Audio;a.preload="auto",a.src=e,a.load(),a.muted=this._getMuted(),a.volume=this._getVolume();let s=this._getPlaybackRate();s!==1&&(a.playbackRate=s);let u={el:a,start:i,duration:r,driftSamples:0,source:o};return 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")return;let n=this._resolveIframeMediaSrc(e);if(!n)return;let i=et(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,n){return this._entries.some(i=>i===n||i.source&&!i.source.isConnected?!1:(i.source&&this._resolveIframeMediaSrc(i.source)||i.el.src)===e)}_repointToSource(e){let n=e.source?this._resolveIframeMediaSrc(e.source):null;return!n||e.el.src===n?!1:this._urlTaken(n,e)?(this._removeEntry(e),!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(!le(s))continue;let u=[];w(s)&&s.matches("audio[data-start], video[data-start]")&&u.push(s);let d=s.querySelectorAll("audio[data-start], video[data-start]");for(let m of d)w(m)&&u.push(m);for(let m of u)this._adoptIframeMedia(m)}for(let s of a.removedNodes){if(!le(s))continue;let u=[];w(s)&&s.matches("audio[data-start], video[data-start]")&&u.push(s);let d=s.querySelectorAll("audio[data-start], video[data-start]");for(let m of d)w(m)&&u.push(m);for(let m of u)this._detachIframeMedia(m)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},r=xn(e);for(let o of r)n.observe(o,i);this._mediaObserver=n}};function pt(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 de(t,e,n){let i=t.end??e;return i<e?Nn(t.start,i,n):i}function ft(t,e,n,i){return t<e.start||t>=de(e,n,i)}var Fr=100;function Vr(t,e){return typeof t.currentTime=="number"&&Number.isFinite(t.currentTime)?t.currentTime:(t.frame??0)/e}function Un(t,e,n){return n<=0?!1:t.ended===!0?!0:t.ended===!1&&!t.isPlaying?!1:e>=n}function Ur(t,e,n,i,r,o){let{duration:a}=n;if(!r){let s=Un(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 Hr(t,e,n,i,r,o)}function Hr(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:de(r,n.duration,o),atEnd:i&&!s&&Un(t,e,a),stopRuntime:t.isPlaying,entering:s}}function Hn(t,e,n,i){let r=Vr(t,e),o=!n.paused,a=o||t.isPlaying,s=i.getPlayRange?.(),u=Ur(t,r,n,a,s,e),{atEnd:d,start:m}=u,g=n.duration>0?Math.min(r,n.duration):r,y=d?u.shownAtEnd:g,h=!t.isPlaying,A=d&&a;if(A&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(m),i.play(),{...n,currentTime:m,paused:!1,enteringRange:!0};let b={...n,currentTime:y,paused:h,enteringRange:u.entering};i.media.audioOwner==="parent"&&(o&&h?i.media.pauseAll():!o&&!h&&i.media.playAll(),i.media.mirrorTime(y));let S=performance.now(),D=h!==n.paused;return(S-n.lastUpdateMs>Fr||D)&&(b.lastUpdateMs=S,i.updateControlsTime(y,n.duration),i.updateControlsPlaying(!h),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:y}}))),A&&(u.stopRuntime&&i.seek(y),i.media.audioOwner==="parent"&&i.media.pauseAll(),b.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),b}function Wr(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 Wn(t,e,n){if(t.source!==e)return;let i=t.data;if(!i||i.source!=="hf-preview")return;let r=Ln(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(Hn({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));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,u)=>n.media.mirrorTime(s,u)),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),u=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(u)&&u>0){let d=n.getPlaybackState();n.setPlaybackState({...d,duration:u}),n.updateControlsTime(d.currentTime,u),n.onRuntimeTimelineReady(u,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}n.setScenes(Wr(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 Gr(t,e){return t.includes(e)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(t)}var Br=new Set([">"," "," ",`
478
- `,"\r","\f"]);function ht(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(Br.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 Gn(t,e){if(!t||Gr(t,e))return t;let n=`<script src="${e}"></script>`,i=ht(t,"head");if(i)return t.slice(0,i.end)+n+t.slice(i.end);let r=ht(t,"body");if(r)return t.slice(0,r.index)+n+t.slice(r.index);let o=ht(t,"html");return o?t.slice(0,o.end)+n+t.slice(o.end):n+t}var O="shader-capture-scale",z="shader-loading",Fe="runtime-src",Bn="__hf_shader_capture_scale",$n="__hf_shader_loading",j=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function bt(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 $r(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 zn(t,e){return t.filter(n=>n!==""&&n.split("=")[0]!==e)}function zr(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,u=a>=0?r.slice(a+1):"",d=zn(u.split("&"),Bn);d=zn(d,$n),e!==null&&d.push(`${Bn}=${encodeURIComponent(e)}`),n!=="composition"&&d.push(`${$n}=${encodeURIComponent(n)}`);let m=d.join("&");return`${s}${m?`?${m}`:""}${o}`}function jr(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 ce(t){return $r(t.getAttribute(z))}function jn(t){return Number(bt(t.getAttribute(O))??"1")}function qn(t,e){return zr(e,bt(t.getAttribute(O)),ce(t))}function me(t,e){return Gn(jr(e,bt(t.getAttribute(O)),ce(t)),gt(t))}function gt(t){let e=t.getAttribute(Fe)?.trim();if(!e)return B;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:B}catch{return B}}function Yn(){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=h=>{h.preventDefault(),h.stopPropagation()};for(let h of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])t.addEventListener(h,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=j[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 u=document.createElement("div");u.className="hfp-shader-loader-fill",s.appendChild(u);let d=document.createElement("div");d.className="hfp-shader-loader-progress";let m=h=>{let A=document.createElement("div");A.className="hfp-shader-loader-row";let b=document.createElement("span");b.className="hfp-shader-loader-label",b.textContent=h;let S=document.createElement("span");return S.className="hfp-shader-loader-value",A.appendChild(b),A.appendChild(S),d.appendChild(A),{row:A,label:b,value:S}},g=m("transition"),y=m("transition frame");return n.appendChild(i),n.appendChild(r),n.appendChild(a),n.appendChild(s),n.appendChild(d),t.appendChild(n),{root:t,fill:u,title:o,detail:a,transitionValue:g.value,transitionRow:g.row,frameLabel:y.label,frameValue:y.value,frameRow:y.row}}var qr=420;function Ve(t,e,n){e.textContent=n,t.style.visibility=n?"visible":"hidden"}var Ue=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(j.length-1,Math.floor(a*j.length));this._el.title.textContent=j[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 u=e.currentTransition!==void 0&&e.transitionTotal!==void 0?`${e.currentTransition}/${e.transitionTotal}`:o>0?`${r}/${o}`:"",d=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,u),Ve(this._el.frameRow,this._el.frameValue,d),this._el.root.setAttribute("aria-valuenow",String(Math.round(a*100))),this.show()}showAssetsLoading(){this.reset(),this._el.title.textContent="Loading assets",this._el.detail.textContent="Waiting for images, video and fonts to finish loading.",this._el.root.setAttribute("aria-label","Loading assets"),this._drawingAssets=!0,this.show()}hideAssetsLoading(){this._drawingAssets&&this.hide()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._hiddenCallbacks=[]}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null,this._flushHidden()},qr)}};function Xn(t){return t?.trim().toLowerCase().startsWith("video/")??!1}function Kn(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=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 Yr=.1,Xr=5,_t="sandbox-origin",Jn=1e4,yt=8e3,vt="assets-loading",pe="assets-loading-ui",At="low-power-idle",Zn="disable-click-to-play",fe="range-start",he="range-end",Kr=150;function St(t){return!Number.isFinite(t)||t<=0?1:Math.max(Yr,Math.min(Xr,t))}var He=class extends HTMLElement{static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src","type",_t,Fe,O,z,pe,At,fe,he]}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;_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"}),Tn(this.shadow,gn),{container:this.container,iframe:this.iframe}=Rn(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);let e=Yn();this.shadow.appendChild(e.root),this.shaderLoader=new Ue(e),this._media=new Oe({dispatchEvent:n=>this._emit(n),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Ne({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 Ie(this.iframe,{resolveRuntimeUrl:()=>gt(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||En(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=lt(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=me(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=me(this,i);else{this.iframe.removeAttribute("srcdoc");let r=this.getAttribute("src");r!==null&&this._wantsVideo()&&this._navigateSrc(r)}break;case _t:this._applySandboxOriginPolicy(this.isConnected&&n!==i);break;case"width":this._setCompositionSize(ae(i)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,ae(i)??1080);break;case"controls":i!==null?this._setupControls():(this.controlsApi?.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=lt(this.shadow,i,this.posterEl);break;case"playback-rate":{let r=St(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 pe:i==="none"&&this.shaderLoader.hideAssetsLoading();break;case At:this._sendControl("set-idle-heartbeat",{slow:i!==null});break;case fe:case he:this._applyPlayRange(!0);break;case O:case z:case Fe:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(_t)?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=me(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?ft(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.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 St(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(St(e)))}get shaderCaptureScale(){return jn(this)}set shaderCaptureScale(e){this.setAttribute(O,String(e))}get shaderLoading(){return ce(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(z):this.setAttribute(z,e)}get assetsLoadingUi(){return this.getAttribute(pe)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(pe,"none"):this.removeAttribute(pe)}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(Zn)}set disableClickToPlay(e){this.toggleAttribute(Zn,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(fe)}set rangeStart(e){this._writeSeconds(fe,e)}get rangeEnd(){return this._readSeconds(he)}set rangeEnd(e){this._writeSeconds(he,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(fe)||this.hasAttribute(he)}_playRange(){return pt(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}=pt(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){ft(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=de(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,...ct(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 ${Jn}ms`)},Jn);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(At)}),this._sendDisplayScale()}_sendDisplayScale(){let e=Pn(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=me(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 Xn(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=qn(this,e)}_loadVideo(e){this._videoSource||(this._videoSource=Kn({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){Wn(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:()=>ce(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),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),yt)):this._settleAssetsReady(i);return}Vn(e,({timedOut:r})=>{i===this._assetsGeneration&&(r&&this._warnStuckAssets(e),this._settleAssetsReady(i))},{timeoutMs:yt}),this._assetsReady||this._startAssetsLoadingOverlayTimer(i)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(vt,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},Kr)}_hasPendingFirstFrameAssets(e){let{pendingMedia:n,pendingImages:i,fontsLoading:r}=Le(e,{scope:$});return n.length>0||i.length>0||r}_warnStuckAssets(e){let{pendingMedia:n,pendingImages:i,fontsLoading:r}=Le(e,{scope:$}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${yt}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(vt),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this.probe.stop(),this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._runtimeOwnsPlayRange=!1,this._enteringRange=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(vt),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=wn(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=Sn(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()))}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",He);0&&(module.exports={HyperframesPlayer,SPEED_PRESETS,formatSpeed,formatTime});
477
+ `,yn='<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>',vn='<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>',at='<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>',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"/></svg>',An='<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 se(t){return Number.isInteger(t)?`${t}x`:`${t}x`}function Ce(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 Sn(t,e,n={}){let i=n.speedPresets??ut,r=document.createElement("div");r.className="hfp-controls",r.addEventListener("click",c=>{c.stopPropagation()});let o=document.createElement("button");o.className="hfp-play-btn",o.type="button",o.innerHTML=`<span class="hfp-ico hfp-ico-play">${yn}</span><span class="hfp-ico hfp-ico-pause">${vn}</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 u=document.createElement("span");u.className="hfp-time",u.textContent="0:00 / 0:00";let d=document.createElement("div");d.className="hfp-speed-wrap";let m=document.createElement("button");m.className="hfp-speed-btn",m.type="button",m.textContent="1x",m.setAttribute("aria-label","Playback speed");let g=document.createElement("div");g.className="hfp-speed-menu",g.setAttribute("role","menu");for(let c of i){let p=document.createElement("button");p.className="hfp-speed-option",p.type="button",p.setAttribute("role","menuitem"),p.dataset.speed=String(c),p.textContent=se(c),c===1&&p.classList.add("hfp-active"),g.appendChild(p)}d.appendChild(g),d.appendChild(m);let y=document.createElement("div");y.className="hfp-volume-wrap";let h=document.createElement("button");h.className="hfp-mute-btn",h.type="button",h.innerHTML=at,h.setAttribute("aria-label","Mute");let A=document.createElement("div");A.className="hfp-volume-slider-wrap";let b=document.createElement("div");b.className="hfp-volume-slider",b.setAttribute("role","slider"),b.setAttribute("aria-label","Volume"),b.setAttribute("aria-valuemin","0"),b.setAttribute("aria-valuemax","100"),b.setAttribute("aria-valuenow","100"),b.tabIndex=0;let S=document.createElement("div");S.className="hfp-volume-fill",S.style.width="100%",b.appendChild(S),A.appendChild(b),y.appendChild(A),y.appendChild(h),n.audioLocked&&(y.style.display="none"),r.appendChild(o),r.appendChild(a),r.appendChild(u),r.appendChild(y),r.appendChild(d),t.appendChild(r);let D=!1,R=!1,k=1,F=null,q=i.indexOf(1);q===-1&&(q=0);let Y=(c,p)=>c?An:p===0?st:p<.5?st:at;o.addEventListener("click",c=>{c.stopPropagation(),D?e.onPause():e.onPlay()}),h.addEventListener("click",c=>{c.stopPropagation(),e.onMuteToggle()});let l=!1,f=c=>{let p=b.getBoundingClientRect(),E=Math.max(0,Math.min(1,(c-p.left)/p.width));k=E,S.style.width=`${E*100}%`,b.setAttribute("aria-valuenow",String(Math.round(E*100))),R&&E>0&&e.onMuteToggle(),h.innerHTML=Y(R,E),e.onVolumeChange(E)};b.addEventListener("mousedown",c=>{c.stopPropagation(),l=!0,f(c.clientX)});let _=c=>{l&&f(c.clientX)},w=()=>{l=!1};document.addEventListener("mousemove",_),document.addEventListener("mouseup",w),b.addEventListener("touchstart",c=>{l=!0;let p=c.touches[0];p&&f(p.clientX)},{passive:!0});let L=c=>{if(l){let p=c.touches[0];p&&f(p.clientX)}},be=()=>{l=!1};document.addEventListener("touchmove",L,{passive:!0}),document.addEventListener("touchend",be);let ge=.05;b.addEventListener("keydown",c=>{let p=k;if(c.key==="ArrowRight"||c.key==="ArrowUp")p=Math.min(1,k+ge);else if(c.key==="ArrowLeft"||c.key==="ArrowDown")p=Math.max(0,k-ge);else return;c.preventDefault(),c.stopPropagation(),k=p,S.style.width=`${p*100}%`,b.setAttribute("aria-valuenow",String(Math.round(p*100))),R&&p>0&&e.onMuteToggle(),h.innerHTML=Y(R,p),e.onVolumeChange(p)});let X=c=>{for(let p of g.querySelectorAll(".hfp-speed-option"))p.classList.toggle("hfp-active",p.dataset.speed===String(c))};m.addEventListener("click",c=>{c.stopPropagation();let p=g.classList.toggle("hfp-open");m.setAttribute("aria-expanded",String(p))}),g.addEventListener("click",c=>{c.stopPropagation();let p=c.target.closest(".hfp-speed-option");if(!p)return;let E=parseFloat(p.dataset.speed);q=i.indexOf(E),m.textContent=se(E),X(E),g.classList.remove("hfp-open"),m.setAttribute("aria-expanded","false"),e.onSpeedChange(E)});let Et=()=>{g.classList.remove("hfp-open"),m.setAttribute("aria-expanded","false")};document.addEventListener("click",Et);let _e=c=>{let p=a.getBoundingClientRect(),E=Math.max(0,Math.min(1,(c-p.left)/p.width));e.onSeek(E)},N=!1;a.addEventListener("mousedown",c=>{c.stopPropagation(),N=!0,e.onScrubStart?.(),_e(c.clientX)});let Tt=c=>{N&&_e(c.clientX)},Rt=()=>{N&&(N=!1,e.onScrubEnd?.())};document.addEventListener("mousemove",Tt),document.addEventListener("mouseup",Rt),a.addEventListener("touchstart",c=>{N=!0,e.onScrubStart?.();let p=c.touches[0];p&&_e(p.clientX)},{passive:!0});let xt=c=>{if(N){let p=c.touches[0];p&&_e(p.clientX)}},wt=()=>{N&&(N=!1,e.onScrubEnd?.())};document.addEventListener("touchmove",xt,{passive:!0}),document.addEventListener("touchend",wt);let kt=()=>{F&&clearTimeout(F),F=setTimeout(()=>{D&&r.classList.add("hfp-hidden")},3e3)},ye=t instanceof ShadowRoot?t.host:t,Mt=()=>{r.classList.remove("hfp-hidden"),kt()},It=()=>{D&&r.classList.add("hfp-hidden")};return ye.addEventListener("mousemove",Mt),ye.addEventListener("mouseleave",It),{updateTime(c,p){let E=p>0?Math.min(c,p):c,ei=p>0?E/p*100:0;s.style.width=`${ei}%`,u.textContent=`${Ce(E)} / ${Ce(p)}`},updatePlaying(c){D=c,o.classList.toggle("hfp-playing",c),o.setAttribute("aria-label",c?"Pause":"Play"),c?kt():r.classList.remove("hfp-hidden")},updateSpeed(c){let p=i.indexOf(c);p!==-1&&(q=p),m.textContent=se(c),X(c)},updateMuted(c){R=c,h.innerHTML=Y(c,k),h.setAttribute("aria-label",c?"Unmute":"Mute")},updateVolume(c){k=c,S.style.width=`${c*100}%`,b.setAttribute("aria-valuenow",String(Math.round(c*100))),h.innerHTML=Y(R,c)},setVolumeControlsHidden(c){y.style.display=c?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",Tt),document.removeEventListener("mouseup",Rt),document.removeEventListener("touchmove",xt),document.removeEventListener("touchend",wt),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",w),document.removeEventListener("touchmove",L),document.removeEventListener("touchend",be),document.removeEventListener("click",Et),ye.removeEventListener("mousemove",Mt),ye.removeEventListener("mouseleave",It),F&&clearTimeout(F),r.remove()}}}function En(t,e,n,i,r,o=!1){let a=i?i.split(",").map(Number).filter(d=>!isNaN(d)&&d>0):void 0,s={...a?{speedPresets:a}:{},audioLocked:o},u=Sn(t,r,s);return u.updateMuted(e),u.updateVolume(n),u}function lt(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 Tn(t){return t.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains("hfp-controls"))}var De=null;function Rn(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 xn(){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 wn(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 rr(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 Ne=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,u=0,d=()=>{if(r()){this._raf=null;return}let m;try{m=e.time()}catch{this._raf=null;return}let g=i(),y=o();y.end>0&&(m=Math.min(m,y.end));let h=a===null?0:m-a;h!==0&&(u=Math.min(h,s),s=h),a=m;let A=rr(m,u,y);A&&(m=y.shown);let b=performance.now();if((b-this._lastUpdateMs>100||A)&&(this._lastUpdateMs=b,this._callbacks.onTimeUpdate(m,g)),A){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{e.pause(),y.shown<y.end&&e.seek(y.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(d)};this._tick=d,this._raf=requestAnimationFrame(d)}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 kn(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)ar(i)||n.push(i);return or(t),n}function or(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 ar(t){let e=t.parentElement;for(;e;){if(e.hasAttribute("data-composition-id"))return!0;e=e.parentElement}return!1}var Mn=t=>4*Number.EPSILON*Math.max(1,Math.abs(t));function ue(t,e){return!Number.isFinite(t)||!Number.isFinite(e)?t===e:Math.abs(t-e)<=Mn(Math.max(Math.abs(t),Math.abs(e)))}var In=(t,e)=>t>=e||ue(t,e),Pe=(t,e,n)=>In(t,e)&&t<n&&!ue(t,n),sr=1e-6,dt=(t,e,n,i)=>Pe(t,e,n)||In(t,e)&&i>0&&n>=i-sr;var ur="data-fade-in",lr="data-fade-out",Ja=ur.slice(5),Za=lr.slice(5),dr=Object.freeze({fadeIn:0,fadeOut:0});var Cn=':not([muted]):is(:not([data-has-audio]),[data-has-audio="true"])',es=`audio[data-start], video[data-start]${Cn}`;var Us=1/16;var pr=["backdrop-filter","clip-path","filter","mask","mask-border-source","mask-image","perspective","rotate","scale","transform","translate","-webkit-mask-image"],$s=new Set([...pr,"contain","isolation","mask-border","mix-blend-mode","opacity"]);function fr(t){return Number.isFinite(t)&&t>0?t:30}function hr(t){return Number.isFinite(t)&&t>0?t:0}function Dn(t,e){let n=fr(e),i=hr(t),r=i*n,o=Math.round(r);return Math.abs(r-o)<=.001?o/n:i}function Nn(t,e,n){return{start:Dn(t,n),end:Number.isFinite(e)?Dn(e,n):e}}var br=["seconds-time","rational-fps","seek-keep-playing","composition-manifest-v1","runtime-data","play-range"];function gr(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 _r(t){let e=Number.isFinite(t)&&t>0?t:30,n=Number.isInteger(e)?1:1e6,i=Math.round(e*n),r=gr(i,n);return{numerator:i/r,denominator:n/r}}function Pn(t,e,n){return Math.max(t,(Math.ceil(e*n-1e-6)-1)/n)}function yr(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 ct(t){return{protocolVersion:1,capabilities:br,fps:_r(t)}}function Ln(t){let e=t.offsetWidth,n=t.getBoundingClientRect().width;return e>0&&n>0?n/e:null}function vr(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function On(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=yr(n.fps);return i===null||!vr(n.capabilities)?{status:"unsupported",code:"invalid_protocol_metadata",receivedVersion:n.protocolVersion}:{status:"supported",fps:i,metadata:n}}function Ar(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 s=e.timelineRegistry[a],u=ie(s);!(t.hasAttribute("data-duration")||t.hasAttribute("data-end")||t.hasAttribute(en)||t.hasAttribute(tn))&&(o==null||o<=0)&&u!=null&&u>0&&(o=u)}return{start:r,end:o!=null&&o>0?r+o:Number.POSITIVE_INFINITY}}function Fn(t,e){let n=Ar(t,e);if(!n)return!1;let i=e.exportRenderSeek?Nn(n.start,n.end,e.canonicalFps):n;return dt(e.currentTime,i.start,i.end,e.compositionDuration)}var $="first-frame",Sr=3;function le(t){let e=t.ownerDocument?.defaultView;return e&&t instanceof e.Element?!0:t instanceof Element}function x(t){if(!le(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 Er(t){return t.hasAttribute("data-start")||t.hasAttribute("data-track-index")}function Tr(t,e,n){let i=t;for(;i;){if(Er(i)&&!Fn(i,{currentTime:0,compositionDuration:Number.POSITIVE_INFINITY,canonicalFps:30,exportRenderSeek:!1,timelineRegistry:n,resolver:e}))return!1;i=i.parentElement}return!0}function Vn(t,e,n,i){return e==="all"?!0:Tr(t,n,i)}function Le(t,{scope:e="all"}={}){let n=t.defaultView,i=G({documentRef:t,timelineRegistry:n?.__timelines,includeAuthoredTimingAttrs:!0}),r=t.querySelector(`meta[name="${pn}"]`)!==null,o=Array.from(t.querySelectorAll("video, audio")).filter(x).filter(u=>Vn(u,r&&u.preload!=="auto"?$:e,i,n?.__timelines??{})).filter(u=>u.readyState<Sr),a=Array.from(t.querySelectorAll("img")).filter(u=>Vn(u,u.getAttribute("loading")?.toLowerCase()==="lazy"?$:e,i,n?.__timelines??{})).filter(u=>!u.complete),s=t.fonts?.status==="loading";return{pendingMedia:o,pendingImages:a,fontsLoading:s}}function Rr(t,{pendingMedia:e,pendingImages:n,fontsLoading:i},r){let o=e.map(u=>new Promise(d=>{if(u.error){d();return}let m=()=>{u.removeEventListener("canplay",m),u.removeEventListener("error",m),r.removeEventListener("abort",m),d()};u.addEventListener("canplay",m),u.addEventListener("error",m),r.addEventListener("abort",m,{once:!0})})),a=n.map(u=>u.decode?u.decode().catch(()=>{}):Promise.resolve()),s=i&&t.fonts?t.fonts.ready.then(()=>{}):Promise.resolve();return Promise.all([...o,...a,s]).then(()=>{})}function xr(t,e,{scope:n="all"}={}){let i=Le(t,{scope:n});return i.pendingMedia.length===0&&i.pendingImages.length===0&&!i.fontsLoading?null:Rr(t,i,e)}var wr=50;function kr(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,wr)};a()})}var Mr=50,Ir=1.5,Cr=2,Dr=1500;function mt(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 Nr(t,e){let n=t.defaultView;return n?(async()=>{let i=await mt(n,e);if(e.aborted)return;let r=await mt(n,e),o=r-i,a=0;for(;!e.aborted&&a<Cr;){if(r-i>=Dr)return;let s=await mt(n,e);if(e.aborted)return;let u=s-r;o=Math.min(o,u),a=u<Mr||u<=o*Ir?a+1:0,r=s}})():null}var Pr=8e3;function Lr(t,e,n={}){let i=n.inputs??[(d,m)=>xr(d,m,{scope:n.scope}),kr,Nr],r=new AbortController,o=i.map(d=>d(t,r.signal)).filter(d=>d!==null);if(o.length===0){e({timedOut:!1});return}let a=n.timeoutMs??Pr,s,u=new Promise(d=>{s=setTimeout(()=>d("timed-out"),a)});Promise.race([Promise.all(o).then(()=>"done"),u]).then(d=>{clearTimeout(s),r.abort(),e({timedOut:d==="timed-out"})})}function Un(t,e,n={}){Lr(t,e,{...n,scope:$})}var Or=.05,Fr=2,Oe=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=et(e.source);e.start=n.start??0,e.duration=n.duration!=null&&n.duration>0?n.duration:Number.POSITIVE_INFINITY}_inWindow(e,n){return Pe(n,e.start,e.start+e.duration)}_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(),e.driftSamples=0,!1)}playAll(){for(let e of this._entries)this._playEntryIfActive(e)}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)&&(n.el.currentTime=e-n.start)}scrubAll(e){for(let n of this._entries)this._refreshEntryBounds(n),this._inWindow(n,e)?(n.el.currentTime=e-n.start,this._playEntry(n)):n.el.paused||n.el.pause()}mirrorTime(e,n){let i=n?.force===!0;for(let r of this._entries){if(this._refreshEntryBounds(r),!this._gateEntryPlayback(r,e))continue;let o=e-r.start;Math.abs(r.el.currentTime-o)>Or?(r.driftSamples+=1,(i||r.driftSamples>=Fr)&&(r.el.currentTime=o,r.driftSamples=0)):r.driftSamples=0}}promoteToParentProxy(e,n){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",e)for(let r of e.querySelectorAll("video, audio"))x(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)x(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(this._urlTaken(e))return null;let a=n==="video"?document.createElement("video"):new Audio;a.preload="auto",a.src=e,a.load(),a.muted=this._getMuted(),a.volume=this._getVolume();let s=this._getPlaybackRate();s!==1&&(a.playbackRate=s);let u={el:a,start:i,duration:r,driftSamples:0,source:o};return 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")return;let n=this._resolveIframeMediaSrc(e);if(!n)return;let i=et(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,n){return this._entries.some(i=>i===n||i.source&&!i.source.isConnected?!1:(i.source&&this._resolveIframeMediaSrc(i.source)||i.el.src)===e)}_repointToSource(e){let n=e.source?this._resolveIframeMediaSrc(e.source):null;return!n||e.el.src===n?!1:this._urlTaken(n,e)?(this._removeEntry(e),!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;x(s)&&s.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(s);continue}if(a.type==="attributes"&&a.attributeName==="preload"){let s=a.target;x(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(!le(s))continue;let u=[];x(s)&&s.matches("audio[data-start], video[data-start]")&&u.push(s);let d=s.querySelectorAll("audio[data-start], video[data-start]");for(let m of d)x(m)&&u.push(m);for(let m of u)this._adoptIframeMedia(m)}for(let s of a.removedNodes){if(!le(s))continue;let u=[];x(s)&&s.matches("audio[data-start], video[data-start]")&&u.push(s);let d=s.querySelectorAll("audio[data-start], video[data-start]");for(let m of d)x(m)&&u.push(m);for(let m of u)this._detachIframeMedia(m)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},r=kn(e);for(let o of r)n.observe(o,i);this._mediaObserver=n}};function pt(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 de(t,e,n){let i=t.end??e;return i<e?Pn(t.start,i,n):i}function ft(t,e,n,i){return t<e.start||t>=de(e,n,i)}var Vr=100;function Ur(t,e){return typeof t.currentTime=="number"&&Number.isFinite(t.currentTime)?t.currentTime:(t.frame??0)/e}function Hn(t,e,n){return n<=0?!1:t.ended===!0?!0:t.ended===!1&&!t.isPlaying?!1:e>=n}function Hr(t,e,n,i,r,o){let{duration:a}=n;if(!r){let s=Hn(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 Gr(t,e,n,i,r,o)}function Gr(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:de(r,n.duration,o),atEnd:i&&!s&&Hn(t,e,a),stopRuntime:t.isPlaying,entering:s}}function Gn(t,e,n,i){let r=Ur(t,e),o=!n.paused,a=o||t.isPlaying,s=i.getPlayRange?.(),u=Hr(t,r,n,a,s,e),{atEnd:d,start:m}=u,g=n.duration>0?Math.min(r,n.duration):r,y=d?u.shownAtEnd:g,h=!t.isPlaying,A=d&&a;if(A&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(m),i.play(),{...n,currentTime:m,paused:!1,enteringRange:!0};let b={...n,currentTime:y,paused:h,enteringRange:u.entering};i.media.audioOwner==="parent"&&(o&&h?i.media.pauseAll():!o&&!h&&i.media.playAll(),i.media.mirrorTime(y));let S=performance.now(),D=h!==n.paused;return(S-n.lastUpdateMs>Vr||D)&&(b.lastUpdateMs=S,i.updateControlsTime(y,n.duration),i.updateControlsPlaying(!h),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:y}}))),A&&(u.stopRuntime&&i.seek(y),i.media.audioOwner==="parent"&&i.media.pauseAll(),b.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),b}function Wr(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 Wn(t,e,n){if(t.source!==e)return;let i=t.data;if(!i||i.source!=="hf-preview")return;let r=On(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(Gn({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));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,u)=>n.media.mirrorTime(s,u)),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),u=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(u)&&u>0){let d=n.getPlaybackState();n.setPlaybackState({...d,duration:u}),n.updateControlsTime(d.currentTime,u),n.onRuntimeTimelineReady(u,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}n.setScenes(Wr(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 Br(t,e){return t.includes(e)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(t)}var $r=new Set([">"," "," ",`
478
+ `,"\r","\f"]);function ht(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($r.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 Bn(t,e){if(!t||Br(t,e))return t;let n=`<script src="${e}"></script>`,i=ht(t,"head");if(i)return t.slice(0,i.end)+n+t.slice(i.end);let r=ht(t,"body");if(r)return t.slice(0,r.index)+n+t.slice(r.index);let o=ht(t,"html");return o?t.slice(0,o.end)+n+t.slice(o.end):n+t}var O="shader-capture-scale",z="shader-loading",Fe="runtime-src",$n="__hf_shader_capture_scale",zn="__hf_shader_loading",j=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function bt(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 zr(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 jn(t,e){return t.filter(n=>n!==""&&n.split("=")[0]!==e)}function jr(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,u=a>=0?r.slice(a+1):"",d=jn(u.split("&"),$n);d=jn(d,zn),e!==null&&d.push(`${$n}=${encodeURIComponent(e)}`),n!=="composition"&&d.push(`${zn}=${encodeURIComponent(n)}`);let m=d.join("&");return`${s}${m?`?${m}`:""}${o}`}function qr(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 ce(t){return zr(t.getAttribute(z))}function qn(t){return Number(bt(t.getAttribute(O))??"1")}function Yn(t,e){return jr(e,bt(t.getAttribute(O)),ce(t))}function me(t,e){return Bn(qr(e,bt(t.getAttribute(O)),ce(t)),gt(t))}function gt(t){let e=t.getAttribute(Fe)?.trim();if(!e)return B;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:B}catch{return B}}function Xn(){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=h=>{h.preventDefault(),h.stopPropagation()};for(let h of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])t.addEventListener(h,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=j[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 u=document.createElement("div");u.className="hfp-shader-loader-fill",s.appendChild(u);let d=document.createElement("div");d.className="hfp-shader-loader-progress";let m=h=>{let A=document.createElement("div");A.className="hfp-shader-loader-row";let b=document.createElement("span");b.className="hfp-shader-loader-label",b.textContent=h;let S=document.createElement("span");return S.className="hfp-shader-loader-value",A.appendChild(b),A.appendChild(S),d.appendChild(A),{row:A,label:b,value:S}},g=m("transition"),y=m("transition frame");return n.appendChild(i),n.appendChild(r),n.appendChild(a),n.appendChild(s),n.appendChild(d),t.appendChild(n),{root:t,fill:u,title:o,detail:a,transitionValue:g.value,transitionRow:g.row,frameLabel:y.label,frameValue:y.value,frameRow:y.row}}var Yr=420;function Ve(t,e,n){e.textContent=n,t.style.visibility=n?"visible":"hidden"}var Ue=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(j.length-1,Math.floor(a*j.length));this._el.title.textContent=j[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 u=e.currentTransition!==void 0&&e.transitionTotal!==void 0?`${e.currentTransition}/${e.transitionTotal}`:o>0?`${r}/${o}`:"",d=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,u),Ve(this._el.frameRow,this._el.frameValue,d),this._el.root.setAttribute("aria-valuenow",String(Math.round(a*100))),this.show()}showAssetsLoading(){this.reset(),this._el.title.textContent="Loading assets",this._el.detail.textContent="Waiting for images, video and fonts to finish loading.",this._el.root.setAttribute("aria-label","Loading assets"),this._drawingAssets=!0,this.show()}hideAssetsLoading(){this._drawingAssets&&this.hide()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._hiddenCallbacks=[]}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null,this._flushHidden()},Yr)}};function Kn(t){return t?.trim().toLowerCase().startsWith("video/")??!1}function Jn(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=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 Xr=.1,Kr=5,_t="sandbox-origin",Zn=1e4,yt=8e3,vt="assets-loading",pe="assets-loading-ui",At="low-power-idle",Qn="disable-click-to-play",fe="range-start",he="range-end",Jr=150;function St(t){return!Number.isFinite(t)||t<=0?1:Math.max(Xr,Math.min(Kr,t))}var He=class extends HTMLElement{static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src","type",_t,Fe,O,z,pe,At,fe,he]}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;_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"}),Rn(this.shadow,_n),{container:this.container,iframe:this.iframe}=xn(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);let e=Xn();this.shadow.appendChild(e.root),this.shaderLoader=new Ue(e),this._media=new Oe({dispatchEvent:n=>this._emit(n),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Ne({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 Ie(this.iframe,{resolveRuntimeUrl:()=>gt(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||Tn(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=lt(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=me(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=me(this,i);else{this.iframe.removeAttribute("srcdoc");let r=this.getAttribute("src");r!==null&&this._wantsVideo()&&this._navigateSrc(r)}break;case _t:this._applySandboxOriginPolicy(this.isConnected&&n!==i);break;case"width":this._setCompositionSize(ae(i)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,ae(i)??1080);break;case"controls":i!==null?this._setupControls():(this.controlsApi?.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=lt(this.shadow,i,this.posterEl);break;case"playback-rate":{let r=St(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 pe:i==="none"&&this.shaderLoader.hideAssetsLoading();break;case At:this._sendControl("set-idle-heartbeat",{slow:i!==null});break;case fe:case he:this._applyPlayRange(!0);break;case O:case z:case Fe:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(_t)?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=me(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?ft(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.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 St(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(St(e)))}get shaderCaptureScale(){return qn(this)}set shaderCaptureScale(e){this.setAttribute(O,String(e))}get shaderLoading(){return ce(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(z):this.setAttribute(z,e)}get assetsLoadingUi(){return this.getAttribute(pe)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(pe,"none"):this.removeAttribute(pe)}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(Qn)}set disableClickToPlay(e){this.toggleAttribute(Qn,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(fe)}set rangeStart(e){this._writeSeconds(fe,e)}get rangeEnd(){return this._readSeconds(he)}set rangeEnd(e){this._writeSeconds(he,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(fe)||this.hasAttribute(he)}_playRange(){return pt(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}=pt(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){ft(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=de(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,...ct(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 ${Zn}ms`)},Zn);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"))x(i)&&(i.muted=e||i.defaultMuted)}_stopIframeMedia(){let e=this._getSameOriginIframeDocument();if(e)for(let n of e.querySelectorAll("video, audio"))x(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(At)}),this._sendDisplayScale()}_sendDisplayScale(){let e=Ln(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=me(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 Kn(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=Yn(this,e)}_loadVideo(e){this._videoSource||(this._videoSource=Jn({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){Wn(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:()=>ce(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),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),yt)):this._settleAssetsReady(i);return}Un(e,({timedOut:r})=>{i===this._assetsGeneration&&(r&&this._warnStuckAssets(e),this._settleAssetsReady(i))},{timeoutMs:yt}),this._assetsReady||this._startAssetsLoadingOverlayTimer(i)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(vt,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},Jr)}_hasPendingFirstFrameAssets(e){let{pendingMedia:n,pendingImages:i,fontsLoading:r}=Le(e,{scope:$});return n.length>0||i.length>0||r}_warnStuckAssets(e){let{pendingMedia:n,pendingImages:i,fontsLoading:r}=Le(e,{scope:$}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${yt}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(vt),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this.probe.stop(),this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._runtimeOwnsPlayRange=!1,this._enteringRange=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(vt),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=wn(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=En(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()))}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",He);0&&(module.exports={HyperframesPlayer,SPEED_PRESETS,formatSpeed,formatTime});