@hyperframes/player 0.8.207 → 0.8.209
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var y="application/hyperframes-slideshow+json";function m(e="i"){let t=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s="[\\t\\n\\f\\r ]*";return new RegExp(`<script[^>]*type${s}=${s}["']${t}["'][^>]*>([\\s\\S]*?)<\\/script>`,e)}function w(e){let s=m("i").exec(e);if(!s||s[1]===void 0)return null;let i=s[1].trim();if(i.length===0)return null;let r=JSON.parse(i);if(!E(r))throw new Error("slideshow island is not a valid SlideshowManifest");return r}function h(e){return e===void 0||Array.isArray(e)&&e.every(t=>typeof t=="number")}function g(e){return e===void 0||typeof e=="boolean"}function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function S(e){return c(e)&&[e.x,e.y,e.w,e.h].every(t=>typeof t=="number"&&Number.isFinite(t))}function $(e){return c(e)&&typeof e.id=="string"&&typeof e.label=="string"&&typeof e.target=="string"&&(e.region===void 0||S(e.region))}function p(e){if(!c(e))return!1;let t=e;return!(typeof t.sceneId!="string"||!h(t.fragments)||t.hotspots!==void 0&&(!Array.isArray(t.hotspots)||!t.hotspots.every($))||!g(t.autoplay))}function A(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id=="string"&&typeof t.label=="string"&&Array.isArray(t.slides)&&t.slides.every(p)}function E(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return!(!Array.isArray(t.slides)||!t.slides.every(p)||t.slideSequences!==void 0&&(!Array.isArray(t.slideSequences)||!t.slideSequences.every(A)))}function b(e,t){return`slide "${e}" sets ${t==="startTime"?"endTime":"startTime"} but ${t} cannot be resolved (no scene "${e}")`}function I(e,t,s){let{startTime:i,endTime:r,sceneId:o}=e;if(i!==void 0&&r!==void 0)return{start:i,end:r};if(i===void 0&&r===void 0)return t?{start:t.start,end:t.start+t.duration}:(s.push(`slide references unresolved sceneId "${o}"`),{start:0,end:0});if(!t){let l=i===void 0?"startTime":"endTime";s.push(b(o,l));let d=i??r??0;return{start:d,end:d}}return{start:i??t.start,end:r??t.start+t.duration}}function T(e,t,s,i,r){for(let o of t)(o<s||o>i)&&r.push(`slide "${e}" fragment ${o} is outside range [${s}, ${i}]`)}function f(e,t,s){let i=t.get(e.sceneId),{start:r,end:o}=I(e,i,s);e.startTime!==void 0&&e.endTime!==void 0&&o<=r&&s.push(`slide "${e.sceneId}" has endTime (${o}) <= startTime (${r})`);let l=[...new Set(e.fragments??[])].sort((d,n)=>d-n);return T(e.sceneId,l,r,o,s),{...e,start:r,end:o,fragments:l,hotspots:e.hotspots??[]}}function v(e,t){let s=[],i=new Map(t.map(n=>[n.id,n])),r={};for(let n of e.slideSequences??[])Object.prototype.hasOwnProperty.call(r,n.id)&&s.push(`duplicate slideSequence id "${n.id}": only the last definition is kept`),r[n.id]={id:n.id,label:n.label,slides:n.slides.map(a=>f(a,i,s))};let o=e.slides.map(n=>f(n,i,s)),l=[...o,...Object.values(r).flatMap(n=>n.slides)];for(let n of l)for(let a of n.hotspots){let u=r[a.target];u?u.slides.length===0&&s.push(`hotspot "${a.id}" targets empty sequence "${a.target}"`):s.push(`hotspot "${a.id}" targets unknown sequence "${a.target}"`)}let d=[...o].sort((n,a)=>n.start-a.start);for(let n=1;n<d.length;n++){let a=d[n-1],u=d[n];a!==void 0&&u!==void 0&&u.start<a.end&&s.push(`main-line slides "${a.sceneId}" and "${u.sceneId}" overlap`)}return{resolved:{slides:o,sequences:r},errors:s}}function N(e){return e+1e-5}export{w as a,v as b,N as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Xe=Object.defineProperty;var mi=Object.getOwnPropertyDescriptor;var pi=Object.getOwnPropertyNames;var fi=Object.prototype.hasOwnProperty;var hi=(n,e)=>{for(var t in e)Xe(n,t,{get:e[t],enumerable:!0})},bi=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of pi(e))!fi.call(n,r)&&r!==t&&Xe(n,r,{get:()=>e[r],enumerable:!(i=mi(e,r))||i.enumerable});return n};var gi=n=>bi(Xe({},"__esModule",{value:!0}),n);var ho={};hi(ho,{HyperframesPlayer:()=>Ke,SPEED_PRESETS:()=>bt,formatSpeed:()=>W,formatTime:()=>Ve});module.exports=gi(ho);var Wt=n=>n!==null&&Number.isFinite(n)&&n>0;function xe(n){let e=n.clipEndsSeconds.filter(i=>i===null).length;if(Wt(n.authoredDurationSeconds))return{seconds:n.authoredDurationSeconds,source:"authored",pendingClips:e};let t=n.clipEndsSeconds.filter(Wt);return t.length>0?{seconds:Math.max(...t),source:"derived",pendingClips:e}:{seconds:null,source:"unresolved",pendingClips:e,reason:e>0?"every clip's length is still pending":"no authored duration and no clip with a length"}}var _i="http://www.w3.org/1999/xhtml";function Bt(n){return n!=null&&n.nodeType===1}function Ze(n){return Bt(n)&&n.namespaceURI===_i}function Je(n,e){return Ze(n)&&n.localName===e}function yi(n){return Je(n,"video")}function vi(n){return Je(n,"audio")}function I(n){return yi(n)||vi(n)}function Qe(n){return Je(n,"img")}function we(n){if(n==null||n.trim()==="")return null;let e=Number.parseInt(n,10);return Number.isFinite(e)&&e>0?e:null}function re(n=document){let e=n.querySelector('[data-composition-id][data-root="true"]');return Ze(e)?e:n.querySelector("[data-composition-id]")}var j=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),Ao=Object.freeze([j.start,j.duration,j.trackIndex]),Eo=Object.freeze([j.derivedEnd]),So=Object.freeze([j.derivedEnd,j.legacyTrack]);function et(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var Gt=n=>{let e=et(n);return e!==null&&e>=0?e:null};function ke(n){return Gt(n("data-playback-start"))??Gt(n("data-media-start"))??0}var oe=.1,ae=10;function tt(n){return Number.isFinite(n)&&n>0?Math.max(oe,Math.min(ae,n)):1}function jt(n,e=1){let t=Number.parseFloat(n("data-playback-rate")??"");return tt(Number.isFinite(t)&&t>0?t:e)}function nt(n){let e=et(n("data-duration"));return e!==null&&e>0?e:null}function zt(n,e){let t=nt(n);if(t!==null)return t;let i=et(n("data-end"));return i!==null?i-e:null}var Ai=3;function it(n,e,t){return Number.isFinite(n)?Math.max(0,n-e)/tt(t):null}function rt(n){let{tag:e,authoredDurationSeconds:t,sourceDurationSeconds:i,mediaStartSeconds:r,playbackRate:o}=n;if(t!==null&&t>0)return{seconds:t,source:"authored"};if(e==="img")return{seconds:Ai,source:"default"};if(i===null)return{seconds:null,source:"pending",reason:"source duration not yet probed"};let a=it(i,r,o);return a===null?{seconds:null,source:"pending",reason:"source reported a non-finite duration"}:{seconds:a,source:"media"}}var Yt="data-fx-chain",Ro=Yt.slice(5);var se=(n="frequency",e="Frequency",t=1e3,i=20,r=2e4)=>({kind:"number",key:n,label:e,unit:"Hz",min:i,max:r,step:1,default:t,scale:"log",automatable:!0}),ot=(n=.707,e="Bandwidth: higher is narrower.")=>({kind:"number",key:"q",label:"Q",unit:"",min:.1,max:20,step:.01,default:n,scale:"log",automatable:!0,hint:e}),Me=(n=-40,e=40,t=0)=>({kind:"number",key:"gain",label:"Gain",unit:"dB",min:n,max:e,step:.1,default:t,automatable:!0}),qt={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."},Kt=[{id:"gain",label:"Gain",group:"dynamics",description:"Raise or lower the whole signal. Automate it to duck under something else.",params:[Me(-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:[se("frequency","Frequency",1e3),Me(-40,40,0),ot(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[se("frequency","Frequency",200,20,2e3),Me(-40,40,0)],web:"biquad-lowshelf"},{id:"highshelf",label:"High Shelf",group:"filter",description:"Lift or drop everything above the corner frequency.",params:[se("frequency","Frequency",4e3,500,2e4),Me(-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:[se("frequency","Cutoff",300,20,2e4),ot(.707),qt],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies, which darkens or muffles a track.",params:[se("frequency","Cutoff",8e3,100,2e4),ot(.707),qt],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"}],xo=new Map(Kt.map(n=>[n.id,n]));var wo=Kt.map(n=>n.id);function Ei(n){return 10**(n/20)}var Xt=Ei(12);var st="data-automation",Oo=st.slice(5),at=1,Ti=512,P=class extends Error{constructor(e){super(e),this.name="AudioAutomationError"}},Ie="volume",Ce="rate";function Jt(n){if(n===Ie)return{kind:"volume"};if(n===Ce)return{kind:"rate"};let e=n.split(".");if(e.length===3&&e[0]==="fx"&&e[1]===Ri){let r=e[2];return r?{kind:"preset",presetId:r}:null}if(e.length!==3||e[0]!=="fx")return null;let[,t,i]=e;return!t||!i?null:{kind:"fx",nodeId:t,param:i}}var Ri="preset";var xi={min:0,max:Xt,step:.01,unit:"",label:"Volume",scale:"linear",default:1};var wi={min:oe,max:ae,step:.05,unit:"x",label:"Speed",scale:"log",default:1};function ue(n){if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"&&n.trim()!==""){let e=Number(n);return Number.isFinite(e)?e:null}return null}function ki(n){let e=ue(n);return e===null||e===0?0:Math.min(1,Math.max(-1,e))}function Qt(n,e){let t=ue(n),i=ue(e);if(t===null||i===null)return null;let r=s=>Math.min(.999,Math.max(.001,s)),o=r(t),a=r(i);return Math.abs(o-a)<1e-6?null:{x:o,y:a}}function Mi(n){let e=ki(n?.curve),t=Qt(n?.viaX,n?.viaY);return{...e?{curve:e}:{},...t?{viaX:t.x,viaY:t.y}:{}}}function Ii(n,e){let t=ue(n?.t),i=ue(n?.v);if(t===null||i===null)return null;let r=e?Math.min(e.max,Math.max(e.min,i)):i;return{t:Math.max(0,t),v:r,...Mi(n)}}function Ci(n,e){let t=n.map(r=>Ii(r,e)).filter(r=>r!==null).sort((r,o)=>r.t-o.t),i=[];for(let r of t)i.length>0&&i[i.length-1].t===r.t?i[i.length-1]=r:i.push(r);return i.slice(0,Ti)}function Di(n){let e=[];for(let t of n.lanes){if(!Jt(t.target))continue;let i=t.target===Ie?xi:t.target===Ce?wi:null,r=Ci(t.points??[],i);r.length>0&&e.push({target:t.target,points:r})}return{version:at,lanes:e}}function en(n){let e;try{e=JSON.parse(n)}catch(r){throw new P(`Automation is not valid JSON: ${r.message}`)}if(typeof e!="object"||e===null)throw new P("Automation must be a JSON object.");let t=e;if(t.version!==at)throw new P(`Unsupported automation version: ${String(t.version)}`);if(!Array.isArray(t.lanes))throw new P("Automation is missing a `lanes` array.");let i=t.lanes.map((r,o)=>{if(typeof r!="object"||r===null)throw new P(`Lane ${o} is not an object.`);let a=r;if(typeof a.target!="string"||!Jt(a.target))throw new P(`Lane ${o} has an unreadable target: ${String(a.target)}`);if(!Array.isArray(a.points))throw new P(`Lane ${o} is missing a \`points\` array.`);return{target:a.target,points:a.points}});return Di({version:at,lanes:i})}function Ni(n,e){return e?Math.pow(n,Math.pow(2,2*e)):n}function Pi(n,e){let t=n-.5,i=e-.5,r=.999,o=1e6,a=t>0?t/(r-n):t<0?-t/(n-(1-r)):0,s=i>0?i/(r-e):i<0?-i/(e-(1-r)):0,u=Math.min(o,Math.max(1,a,s));return{cx:n+t/u,cy:e+i/u,w:u}}function Li(n,e,t){let{cx:i,cy:r,w:o}=Pi(e,t),a=2-2*o,s=n*a-1+2*o*i,u=-n*a-2*o*i,d=Oi(s,u,n),m=1-d,h=m*m+2*o*d*m+d*d;return h>0?(2*o*r*d*m+d*d)/h:n}function Oi(n,e,t){if(Math.abs(n)<1e-12)return Math.abs(e)<1e-12?t:-t/e;let i=Math.sqrt(Math.max(0,e*e-4*n*t)),r=(-e+i)/(2*n),o=(-e-i)/(2*n),a=s=>s>=-1e-9&&s<=1+1e-9;return a(r)?Math.min(1,Math.max(0,r)):a(o)?Math.min(1,Math.max(0,o)):t}function Fi(n,e){let t=Qt(e.viaX,e.viaY);return t?Li(Math.min(1,Math.max(0,n)),t.x,t.y):Ni(n,e.curve)}function Ui(n,e,t,i){return i==="log"&&n>0&&e>0?Math.exp(Math.log(n)+(Math.log(e)-Math.log(n))*t):n+(e-n)*t}function De(n,e,t="linear"){let i=n.points;if(i.length===0)return 0;let r=i[0];if(e<=r.t)return r.v;let o=i[i.length-1];if(e>=o.t)return o.v;let a=0,s=i.length-1;for(;s-a>1;){let h=a+s>>1;i[h].t<=e?a=h:s=h}let u=i[a],d=i[s],m=d.t-u.t;return m<=0?d.v:Ui(u.v,d.v,Fi((e-u.t)/m,u),t)}var Ne=new Map,Vi=64;function tn(n,e=Ie){let t=`${e}\0${n}`,i=Ne.get(t);if(i!==void 0)return i;let r=null;try{r=en(n).lanes.find(o=>o.target===e)??null}catch{r=null}return Ne.size>Vi&&Ne.clear(),Ne.set(t,r),r}var nn=48,rn=new WeakMap;function Hi(n){let e=n.points,t=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=De(n,d,"log");r.push(u),o.push(o[o.length-1]+(m+De(n,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 h=1;h<=nn;h+=1)a(Math.max(d,0)+(m-d)*h/nn)}return{ts:Float64Array.from(r),ss:Float64Array.from(o),firstRate:t,lastRate:i}}function $i(n){let e=rn.get(n);return e||(e=Hi(n),rn.set(n,e)),e}function Wi(n){return typeof n!="number"&&n.points.length>0}function Bi(n,e,t){let i=0,r=n.length-1;for(;r-i>1;){let o=i+r>>1;n[o]<=t?i=o:r=o}return e[i]+(e[r]-e[i])*(t-n[i])/(n[r]-n[i])}function ut(n,e){if(typeof n=="number")return e/n;if(!Wi(n))return e;let{ts:t,ss:i,firstRate:r,lastRate:o}=$i(n),a=t.length-1;return e<=0?e/r:e>=i[a]?t[a]+(e-i[a])/o:Bi(i,t,e)}function Gi(n){return n?tn(n,Ce):null}function on(n,e){return Gi(n)??e}var Bo=[{id:"montage",label:"Montage",points:[[0,.9],[.15,.3],[.5,2.5],[.85,.3],[1,.9]]},{id:"hero",label:"Hero",points:[[0,1],[.25,1.6],[.5,.25],[.75,1.6],[1,1]]},{id:"bullet",label:"Bullet",points:[[0,3],[.4,3],[.5,.15],[.6,3],[1,3]]},{id:"jump-cut",label:"Jump cut",points:[[0,.5],[.24,.5],[.26,3],[.5,3],[.52,.5],[.74,.5],[.76,3],[1,3]]},{id:"flash-in",label:"Flash in",points:[[0,.3],[.6,.6],[1,5]]},{id:"flash-out",label:"Flash out",points:[[0,5],[.4,.6],[1,.3]]},{id:"ramp-in",label:"Ramp in",points:[[0,.5],[1,1]]},{id:"ramp-out",label:"Ramp out",points:[[0,1],[1,.5]]},{id:"slowmo-middle",label:"Slow-mo middle",points:[[0,1],[1/3,.35],[2/3,.35],[1,1]]}];var y=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),jo=Object.freeze([y.start,y.duration,y.trackIndex]),zo=Object.freeze([y.derivedEnd]),qo=Object.freeze([y.derivedEnd,y.legacyTrack]);function L(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var un=/^[A-Za-z0-9_.:-]+$/;function ln(n,e){let t=n.charCodeAt(e);return t>=48&&t<=57}function an(n,e){let t=e;for(;t>=0&&ln(n,t);)t--;return t}function ji(n,e){let t=e;for(;t>=0&&(n[t]??"").trim()==="";)t--;return t}function zi(n){let e=n.length-1;if(!ln(n,e))return null;let t=an(n,e);return n[t]==="."&&(t=an(n,t-1)),t+1}function qi(n){let e=zi(n);if(e==null)return null;let t=ji(n,e-1),i=n[t];if(i!=="+"&&i!=="-")return null;let r=n.slice(0,t).trim();if(!un.test(r))return null;let o=Number(n.slice(e));return Number.isFinite(o)?{refId:r,operator:i,magnitude:o}:null}function le(n){let e=(n??"").trim();if(!e)return null;let t=L(e);if(t!=null)return{kind:"absolute",value:t};if(un.test(e))return{kind:"reference",refId:e,offset:0};let i=qi(e);return i?{kind:"reference",refId:i.refId,offset:i.operator==="-"?-i.magnitude:i.magnitude}:null}function x(n,e,t,i){n.push({code:e,attribute:t,value:i})}function Yi(n,e,t,i){if(e==null||e.trim()==="")return t.defaultStart===void 0?0:t.defaultStart;if(!n)return x(i,"invalid-start",y.start,e),null;if(n.kind==="absolute")return Math.max(0,n.value);let r=t.resolveReferenceEnd?.(n.refId);return r==null||!Number.isFinite(r)?(x(i,"unresolved-start-reference",y.start,e),null):Math.max(0,r+n.offset)}var Ki=1e-9;function Xi(n,e){return Math.abs(n-e)<=Ki}function Zi(n,e,t){let i=L(n);if(i==null){x(t,"deprecated-end",y.derivedEnd,n),x(t,"invalid-end",y.derivedEnd,n);return}if(e==null){x(t,"deprecated-end",y.derivedEnd,n);return}Xi(i,e)||(x(t,"deprecated-end",y.derivedEnd,n),x(t,"conflicting-end",y.derivedEnd,n))}function Ji(n,e,t){let i=L(n);return i==null||i<0?(x(t,"invalid-duration",y.duration,n),{duration:null,end:null,durationSource:"invalid"}):{duration:i,end:e==null?null:e+i,durationSource:"duration"}}function Qi(n,e,t){x(t,"deprecated-end",y.derivedEnd,n);let i=L(n);return i==null?(x(t,"invalid-end",y.derivedEnd,n),{duration:null,end:null,durationSource:"invalid"}):e==null?{duration:null,end:i,durationSource:"legacy-end"}:i<e?(x(t,"end-before-start",y.derivedEnd,n),{duration:null,end:null,durationSource:"invalid"}):{duration:i-e,end:i,durationSource:"legacy-end"}}function er(n,e,t){let i=n.getAttribute(y.duration),r=n.getAttribute(y.derivedEnd);if(i==null)return r==null?{duration:null,end:null,durationSource:"missing"}:Qi(r,e,t);let o=Ji(i,e,t);return r!=null&&Zi(r,o.end,t),o}function sn(n,e,t,i){let r=L(n);return r==null||!Number.isInteger(r)?(x(i,"invalid-track-index",e,n),{trackIndex:0,trackSource:"invalid"}):{trackIndex:r,trackSource:t}}function tr(n,e){let t=n.getAttribute(y.trackIndex),i=n.getAttribute(y.legacyTrack);if(t==null&&i==null)return{trackIndex:0,trackSource:"default"};if(t==null&&i!=null)return x(e,"deprecated-layer",y.legacyTrack,i),sn(i,y.legacyTrack,"legacy-layer",e);let r=sn(t??"",y.trackIndex,"track-index",e);if(i==null)return r;x(e,"deprecated-layer",y.legacyTrack,i);let o=L(i);return o!=null&&o!==r.trackIndex&&x(e,"conflicting-layer",y.legacyTrack,i),r}function lt(n,e={}){let t=[],i=n.getAttribute(y.start),r=le(i),o=Yi(r,i,e,t),a=er(n,o,t),s=tr(n,t);return{startExpression:r,start:o,...a,...s,diagnostics:t}}function O(n){return L(n)}function de(n){return jt(e=>n.getAttribute(e),I(n)?n.defaultPlaybackRate:1)}function dt(n){return on(n.getAttribute("data-automation"),de(n))}function Pe(n){return ke(e=>n.getAttribute(e))}function z(n,e){return nr(e,Pe(n),dt(n))}function ct(n){let e=rt({tag:"video",authoredDurationSeconds:nt(t=>n.getAttribute(t)),sourceDurationSeconds:Number.isFinite(n.duration)?n.duration:null,mediaStartSeconds:Pe(n),playbackRate:de(n)});return e.source==="media"?z(n,n.duration):e.seconds}function Le(n,e=0){return!Qe(n)||!n.hasAttribute("data-start")&&!n.hasAttribute("data-track-index")?null:rt({tag:"img",authoredDurationSeconds:zt(t=>n.getAttribute(t),e),sourceDurationSeconds:null,mediaStartSeconds:0,playbackRate:1}).seconds}function nr(n,e,t){return typeof t=="number"?it(n,e,t):Number.isFinite(n)?ut(t,Math.max(0,n-e)):null}function dn(){return globalThis}function q(n,e){if(typeof window>"u")return;let t=dn(),i=t.__hf?.onSwallowed;if(i)try{i({label:n,error:e})}catch(r){}(t.__hfDebug||t.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${n} swallowed:`,e)}var ir=n=>n.paused?.()===!0?(n.startTime?.()??0)+(n.totalDuration?.()??0)/Math.abs(n.timeScale?.()||1):0;function ce(n){try{if(typeof n?.duration!="function")return null;let e=n.getChildren?.(!1,!1,!0),t=Array.isArray(e)?e:[],i=Math.max(Number(n.duration()),...t.map(ir));return Number.isFinite(i)?i:null}catch(e){return q("runtime.timelineDuration",e),null}}var cn="data-hf-authored-duration",mn="data-hf-authored-end";function me(n){if(n==null||typeof n=="string"&&n.trim()==="")return null;let e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:null}function Oe(n){let e=me(n.start);if(e==null)return null;let t=Math.max(0,e),i=me(n.duration),r=me(n.authoredDuration),o=i!=null&&i>0?i:r!=null&&r>0?r:null;if(o!=null)return{start:t,duration:o,end:t+o};let a=me(n.end),s=me(n.authoredEnd),u=a!=null&&a>t?a:s!=null&&s>t?s:null;return{start:t,duration:u==null?null:u-t,end:u}}var Y=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),ua=Object.freeze([Y.start,Y.duration,Y.trackIndex]),la=Object.freeze([Y.derivedEnd]),da=Object.freeze([Y.derivedEnd,Y.legacyTrack]);function rr(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var pn=n=>{let e=rr(n);return e!==null&&e>=0?e:null};function or(n){return pn(n("data-playback-start"))??pn(n("data-media-start"))??0}var fn="data-hf-media-start-basis";function hn(n){return n?.trim().toLowerCase()==="global"?"global":"local"}function ar(n){return hn(n.basis)==="global"?n.authoredStart:n.hostStart+n.authoredStart}function bn(n){return _n(n)?ar({authoredStart:n.authoredStart,hostStart:n.hostStart,basis:n.basis}):n.ordinaryStart()}function gn(n){return _n(n)&&hn(n.basis)==="global"}function _n(n){return!n.hasAutoStart&&n.authoredStart!=null&&n.hostStart!==0}function mt(n){return or(e=>n.getAttribute(e))}function yn(n,e){return n-mt(e)}function $(n){let e=n.timelineRegistry??{},t=n.includeAuthoredTimingAttrs??!1,i=n.documentRef??document,r=new WeakMap,o=new WeakMap,a=new Set,s=l=>(l.hasAttribute("data-composition-id")?l.parentElement:l)?.closest("[data-composition-id]")??null,u=(l,f)=>{let g=s(f);if(g){for(let k of g.querySelectorAll(`[id="${l}"]`))if(s(k)===g)return k}let R=i.getElementById(l);return R||(Array.from(i.querySelectorAll("[data-composition-id]")).find(k=>k.getAttribute("data-composition-id")===l)??null)},d=(l,f)=>t?l.getAttribute(f):null,m=l=>Oe({start:0,duration:l.getAttribute("data-duration"),authoredDuration:d(l,"data-hf-authored-duration")})?.duration??Oe({start:T(l,0),end:l.getAttribute("data-end"),authoredEnd:d(l,"data-hf-authored-end")})?.duration??null,h=l=>l!=null&&Number.isFinite(l)&&l>0?l:null,v=l=>{let f=l.getAttribute("data-composition-id");return f?h(ce(e[f])):null},b=l=>{let f=o.get(l);if(f!==void 0)return f;let g=m(l)??h(I(l)?z(l,l.duration):null)??h(Le(l))??v(l);return o.set(l,g),g},A="[data-composition-src], [data-composition-id], [data-composition-file]",_=l=>l.matches(A),E=l=>!l.hasAttribute("data-composition-id")||le(l.getAttribute("data-start"))?null:l.parentElement?.closest(`[data-start], ${A}`)??null,C=(l,f)=>yn(T(l,f),E(l)??l),M=(l,f)=>{let g=l.hasAttribute("data-composition-id")?l.parentElement?.closest("[data-composition-id]"):l.closest("[data-composition-id]");return g?C(g,f):0},D=(l,f)=>{let g=le(l.getAttribute("data-start"));if(!g){let H=E(l);return H?T(H,f):f}if(g.kind==="absolute")return M(l,f)+Math.max(0,g.value);let R=u(g.refId,l);if(!R)return f;let k=T(R,0),Te=b(R)??0,Re=Math.min(0,M(l,0));return Math.max(Re,k+Te+g.offset)},T=(l,f)=>{let g=r.get(l);if(g!==void 0)return g??f;if(a.has(l))return f;a.add(l);try{let R=D(l,f);return r.set(l,R),R}finally{a.delete(l)}},V=l=>{let f=l.closest("[data-composition-id]");return{authoredStart:O(l.getAttribute("data-start")),hostStart:f?C(f,0):0,hasAutoStart:l.hasAttribute("data-hf-auto-start"),basis:l.getAttribute(fn)}};return{resolveStartForElement:(l,f=0)=>T(l,Math.max(0,f)),resolveDurationForElement:l=>b(l),resolveMediaStartForElement:l=>{let f=V(l);return bn({...f,ordinaryStart:()=>T(l,f.hostStart)})},resolveHostStartForElement:l=>M(l,0),resolveHostSlotsForElement:l=>{let f=[];for(let g=l.parentElement;g;g=g.parentElement){if(!_(g)||E(g)||mt(g)<=0)continue;let R=T(g,0),k=m(g);f.push({start:R,end:k?R+k:1/0})}return f},isRootGlobalMediaStartForElement:l=>I(l)&&gn(V(l))}}function vn(){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 An=7200,pt=1/60,pe=n=>n!==null&&n>pt?n:null;function sr(n){return{width:we(n.getAttribute("data-width")),height:we(n.getAttribute("data-height"))}}function ur(n,e){let t=[];for(let i of n.querySelectorAll("video[data-start], audio[data-start]")){let r=e.mediaStart(i);if(!Number.isFinite(r))continue;let o=e.mediaDuration(i);o==null||o<=pt||t.push(Math.max(0,r)+o)}return pe(xe({authoredDurationSeconds:null,clipEndsSeconds:t}).seconds)}function lr(n,e){let t=[];for(let r of n.querySelectorAll("[data-composition-id][data-start]")){if(r.parentElement?.closest("[data-composition-id]")!==n)continue;let o=e.resolveStartForElement(r,0),a=e.resolveDurationForElement(r);!Number.isFinite(o)||a==null||a<=0||t.push(Math.max(0,o)+a)}let i=O(n.getAttribute("data-duration"));return pe(xe({authoredDurationSeconds:null,clipEndsSeconds:[i,...t]}).seconds)}var dr=n=>n.hasAttribute("data-composition-id")||n.hasAttribute("data-composition-src");function cr(n,e,{unregisteredLottie:t}){let i=[];for(let o of n.querySelectorAll("[data-start]")){let a=e.resolveStartForElement(o,0);if(!Number.isFinite(a))continue;let s=e.resolveDurationForElement(o);s!=null?i.push(Math.max(0,a)+s):(I(o)||dr(o))&&i.push(null)}(t||n.querySelector("[data-lottie-src]"))&&i.push(null);let r=xe({authoredDurationSeconds:null,clipEndsSeconds:i});return r.pendingClips>0?{...r,seconds:null,source:"unresolved",reason:"a clip's length is pending"}:r}function mr(n){if(n.declared!==null&&Number.isFinite(n.declared)&&n.declared>0)return n.declared;let e=pe(n.timeline()),t=Math.max(0,...n.floors().map(u=>u??0)),i=Number.isFinite(n.fallback)&&n.fallback>pt?n.fallback:0,r=Math.max(t,i),a=e!==null&&e>=An&&pe(r)!==null?null:e,s;return a!==null?s=Math.max(a,r):pe(t)!==null?s=r:i>0?s=i:s=n.derived(),s>0?s:0}function En(n){let e=re(n);if(!e)return null;let t=$({timelineRegistry:{},includeAuthoredTimingAttrs:!0,documentRef:n}),i=mr({declared:O(e.getAttribute("data-duration")),timeline:()=>null,floors:()=>[ur(n,{mediaStart:t.resolveMediaStartForElement,mediaDuration:ct}),lr(e,t)],fallback:0,derived:()=>cr(e,t,{unregisteredLottie:!1}).seconds??0});return{...sr(e),fps:vn().canonicalFps,durationSeconds:i}}var Fe="hyperframes-studio-preview";var Sn="data-hf-upcoming";var Tn="__hfPreviewErrors";var Rn="data-hf-autostamped",K="data-hf-clip-hidden";function xn(n){return n.hasRuntime||n.runtimeInjected?!1:!!(n.hasNestedCompositions||n.hasTimelines&&n.attempts>=5)}function X(n){return typeof n=="object"&&n!==null}function wn(n){return X(n)&&typeof n.getDuration=="function"}function kn(n){return X(n)&&typeof n.duration=="function"&&typeof n.time=="function"&&typeof n.seek=="function"&&typeof n.play=="function"&&typeof n.pause=="function"}var Z="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.207/dist/hyperframe.runtime.iife.js";function fe(n){if(n===null)return null;let e=Number.parseInt(n,10);return Number.isFinite(e)&&e>0?e:null}function pr(n){let e=n?.querySelector("[data-composition-id][data-width][data-height]")??n?.querySelector("[data-width][data-height]");if(!e)return null;let t=fe(e.getAttribute("data-width")),i=fe(e.getAttribute("data-height"));return t!==null&&i!==null?{width:t,height:i}:null}function fr(n){return Array.isArray(n)?n.find(e=>typeof e=="string"&&e.trim()!==""&&e!=="[object Event]")??null:null}var Ue=class{constructor(e,t){this._iframe=e;this._callbacks=t}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;_runtimeScript=null;_failure=null;get failed(){return this._failure!==null&&this._failure.document===this._iframe.contentDocument}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._failure=null,this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;let t=null;try{t=this._poll(e)}catch(i){i instanceof DOMException&&i.name==="SecurityError"||(t={kind:"error",message:i instanceof Error?i.message:String(i)})}t??=this._deadlineOutcome(e),t&&(this.stop(),t.kind==="error"?(this._failure={document:this._iframe.contentDocument},this._callbacks.onError(t.message)):this._callbacks.onReady(t.result))},200)}_deadlineOutcome(e){return e<40||this._callbacks.hostOwnsDeadline?.()?null:{kind:"error",message:"Composition timeline not found after 8s"}}_poll(e){let t=this._iframe.contentWindow;if(!t)return null;let i=fr(Reflect.get(t,Tn));if(i!==null)return{kind:"error",message:i};let r=this._iframe.contentDocument,o=Reflect.get(t,"__timelines"),a=this.hasRuntimeBridge(t);if(xn({hasRuntime:a,hasTimelines:X(o)&&Object.keys(o).length>0,hasNestedCompositions:!!r?.querySelector("[data-composition-src]"),runtimeInjected:this._runtimeInjected,attempts:e}))return this._injectRuntime(),null;if(this._runtimeInjected&&!a)return null;let s=this._resolveReadyResult(t,r);return s?{kind:"ready",result:s}:null}_resolveReadyResult(e,t){let i=this._resolvePlaybackDurationAdapter(e)??{kind:"document",getDuration:()=>0},r=i.getDuration();if(!Number.isFinite(r)||r<=0){if(i.kind==="direct-timeline")return null;r=t?En(t)?.durationSeconds??0:0}return r<=0?null:{duration:r,adapter:{...i,getDuration:()=>r},compositionSize:pr(t)}}stop(){this._runtimeScript&&(this._runtimeScript.onerror=null,this._runtimeScript=null),this.failed||(this._failure=null),this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return X(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=this._callbacks.resolveRuntimeUrl?.()??Z,this._runtimeScript=t,t.onerror=()=>{this._runtimeScript!==t||this._iframe.contentDocument!==e||(this.stop(),this._failure={document:e},this._callbacks.onError("HyperFrames runtime failed to load from "+t.src))},(e.head||e.documentElement).appendChild(t),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let t=Reflect.get(e,"__timelines");if(!X(t))return null;let i=Object.keys(t);if(i.length===0)return null;let r=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=r&&r in t?r:i[i.length-1],a=t[o];return kn(a)?a:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(wn(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var Mn=`
|
|
1
|
+
"use strict";var Be=Object.defineProperty;var oi=Object.getOwnPropertyDescriptor;var ai=Object.getOwnPropertyNames;var si=Object.prototype.hasOwnProperty;var li=(n,e)=>{for(var t in e)Be(n,t,{get:e[t],enumerable:!0})},ui=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ai(e))!si.call(n,r)&&r!==t&&Be(n,r,{get:()=>e[r],enumerable:!(i=oi(e,r))||i.enumerable});return n};var di=n=>ui(Be({},"__esModule",{value:!0}),n);var no={};li(no,{HyperframesPlayer:()=>$e,SPEED_PRESETS:()=>lt,formatSpeed:()=>W,formatTime:()=>De});module.exports=di(no);var Dt=n=>n!==null&&Number.isFinite(n)&&n>0;function Se(n){let e=n.clipEndsSeconds.filter(i=>i===null).length;if(Dt(n.authoredDurationSeconds))return{seconds:n.authoredDurationSeconds,source:"authored",pendingClips:e};let t=n.clipEndsSeconds.filter(Dt);return t.length>0?{seconds:Math.max(...t),source:"derived",pendingClips:e}:{seconds:null,source:"unresolved",pendingClips:e,reason:e>0?"every clip's length is still pending":"no authored duration and no clip with a length"}}var ci="http://www.w3.org/1999/xhtml";function Pt(n){return n!=null&&n.nodeType===1}function Ge(n){return Pt(n)&&n.namespaceURI===ci}function ze(n,e){return Ge(n)&&n.localName===e}function mi(n){return ze(n,"video")}function pi(n){return ze(n,"audio")}function P(n){return mi(n)||pi(n)}function Lt(n){return ze(n,"img")}function Ae(n){if(n==null||n.trim()==="")return null;let e=Number.parseInt(n,10);return Number.isFinite(e)&&e>0?e:null}function Q(n=document){let e=n.querySelector('[data-composition-id][data-root="true"]');return Ge(e)?e:n.querySelector("[data-composition-id]")}var G=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),lo=Object.freeze([G.start,G.duration,G.trackIndex]),uo=Object.freeze([G.derivedEnd]),co=Object.freeze([G.derivedEnd,G.legacyTrack]);function je(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var Nt=n=>{let e=je(n);return e!==null&&e>=0?e:null};function Ee(n){return Nt(n("data-playback-start"))??Nt(n("data-media-start"))??0}var ee=.1,te=10;function qe(n){return Number.isFinite(n)&&n>0?Math.max(ee,Math.min(te,n)):1}function Ot(n,e=1){let t=Number.parseFloat(n("data-playback-rate")??"");return qe(Number.isFinite(t)&&t>0?t:e)}function Ye(n){let e=je(n("data-duration"));return e!==null&&e>0?e:null}function Ft(n,e){let t=Ye(n);if(t!==null)return t;let i=je(n("data-end"));return i!==null?i-e:null}var hi=3;function Xe(n,e,t){return Number.isFinite(n)?Math.max(0,n-e)/qe(t):null}function Ke(n){let{tag:e,authoredDurationSeconds:t,sourceDurationSeconds:i,mediaStartSeconds:r,playbackRate:o}=n;if(t!==null&&t>0)return{seconds:t,source:"authored"};if(e==="img")return{seconds:hi,source:"default"};if(i===null)return{seconds:null,source:"pending",reason:"source duration not yet probed"};let a=Xe(i,r,o);return a===null?{seconds:null,source:"pending",reason:"source reported a non-finite duration"}:{seconds:a,source:"media"}}var fi="data-fx-chain",po=fi.slice(5);var ne=(n="frequency",e="Frequency",t=1e3,i=20,r=2e4)=>({kind:"number",key:n,label:e,unit:"Hz",min:i,max:r,step:1,default:t,scale:"log",automatable:!0}),Ze=(n=.707,e="Bandwidth: higher is narrower.")=>({kind:"number",key:"q",label:"Q",unit:"",min:.1,max:20,step:.01,default:n,scale:"log",automatable:!0,hint:e}),Te=(n=-40,e=40,t=0)=>({kind:"number",key:"gain",label:"Gain",unit:"dB",min:n,max:e,step:.1,default:t,automatable:!0}),Ut={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."},Ht=[{id:"gain",label:"Gain",group:"dynamics",description:"Raise or lower the whole signal. Automate it to duck under something else.",params:[Te(-60,12,0)],web:"gain-node"},{id:"peaking",label:"Peaking EQ",group:"filter",description:"Boost or cut a band, leaving everything either side alone.",params:[ne("frequency","Frequency",1e3),Te(-40,40,0),Ze(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[ne("frequency","Frequency",200,20,2e3),Te(-40,40,0)],web:"biquad-lowshelf"},{id:"highshelf",label:"High Shelf",group:"filter",description:"Lift or drop everything above the corner frequency.",params:[ne("frequency","Frequency",4e3,500,2e4),Te(-40,40,0)],web:"biquad-highshelf"},{id:"highpass",label:"High-pass",group:"filter",description:"Remove low frequencies: the usual fix for rumble on a voice.",params:[ne("frequency","Cutoff",300,20,2e4),Ze(.707),Ut],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies, which darkens or muffles a track.",params:[ne("frequency","Cutoff",8e3,100,2e4),Ze(.707),Ut],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"}],ho=new Map(Ht.map(n=>[n.id,n]));var fo=Ht.map(n=>n.id);function bi(n){return 10**(n/20)}var Vt=bi(12);var Wt="data-automation",xo=Wt.slice(5),Je=1,gi=512,L=class extends Error{constructor(e){super(e),this.name="AudioAutomationError"}},Re="volume",xe="rate";function $t(n){if(n===Re)return{kind:"volume"};if(n===xe)return{kind:"rate"};let e=n.split(".");if(e.length===3&&e[0]==="fx"&&e[1]===_i){let r=e[2];return r?{kind:"preset",presetId:r}:null}if(e.length!==3||e[0]!=="fx")return null;let[,t,i]=e;return!t||!i?null:{kind:"fx",nodeId:t,param:i}}var _i="preset";var yi={min:0,max:Vt,step:.01,unit:"",label:"Volume",scale:"linear",default:1};var vi={min:ee,max:te,step:.05,unit:"x",label:"Speed",scale:"log",default:1};function ie(n){if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"&&n.trim()!==""){let e=Number(n);return Number.isFinite(e)?e:null}return null}function Si(n){let e=ie(n);return e===null||e===0?0:Math.min(1,Math.max(-1,e))}function Bt(n,e){let t=ie(n),i=ie(e);if(t===null||i===null)return null;let r=s=>Math.min(.999,Math.max(.001,s)),o=r(t),a=r(i);return Math.abs(o-a)<1e-6?null:{x:o,y:a}}function Ai(n){let e=Si(n?.curve),t=Bt(n?.viaX,n?.viaY);return{...e?{curve:e}:{},...t?{viaX:t.x,viaY:t.y}:{}}}function Ei(n,e){let t=ie(n?.t),i=ie(n?.v);if(t===null||i===null)return null;let r=e?Math.min(e.max,Math.max(e.min,i)):i;return{t:Math.max(0,t),v:r,...Ai(n)}}function Ti(n,e){let t=n.map(r=>Ei(r,e)).filter(r=>r!==null).sort((r,o)=>r.t-o.t),i=[];for(let r of t)i.length>0&&i[i.length-1].t===r.t?i[i.length-1]=r:i.push(r);return i.slice(0,gi)}function Ri(n){let e=[];for(let t of n.lanes){if(!$t(t.target))continue;let i=t.target===Re?yi:t.target===xe?vi:null,r=Ti(t.points??[],i);r.length>0&&e.push({target:t.target,points:r})}return{version:Je,lanes:e}}function Gt(n){let e;try{e=JSON.parse(n)}catch(r){throw new L(`Automation is not valid JSON: ${r.message}`)}if(typeof e!="object"||e===null)throw new L("Automation must be a JSON object.");let t=e;if(t.version!==Je)throw new L(`Unsupported automation version: ${String(t.version)}`);if(!Array.isArray(t.lanes))throw new L("Automation is missing a `lanes` array.");let i=t.lanes.map((r,o)=>{if(typeof r!="object"||r===null)throw new L(`Lane ${o} is not an object.`);let a=r;if(typeof a.target!="string"||!$t(a.target))throw new L(`Lane ${o} has an unreadable target: ${String(a.target)}`);if(!Array.isArray(a.points))throw new L(`Lane ${o} is missing a \`points\` array.`);return{target:a.target,points:a.points}});return Ri({version:Je,lanes:i})}function xi(n,e){return e?Math.pow(n,Math.pow(2,2*e)):n}function wi(n,e){let t=n-.5,i=e-.5,r=.999,o=1e6,a=t>0?t/(r-n):t<0?-t/(n-(1-r)):0,s=i>0?i/(r-e):i<0?-i/(e-(1-r)):0,l=Math.min(o,Math.max(1,a,s));return{cx:n+t/l,cy:e+i/l,w:l}}function ki(n,e,t){let{cx:i,cy:r,w:o}=wi(e,t),a=2-2*o,s=n*a-1+2*o*i,l=-n*a-2*o*i,d=Mi(s,l,n),m=1-d,f=m*m+2*o*d*m+d*d;return f>0?(2*o*r*d*m+d*d)/f:n}function Mi(n,e,t){if(Math.abs(n)<1e-12)return Math.abs(e)<1e-12?t:-t/e;let i=Math.sqrt(Math.max(0,e*e-4*n*t)),r=(-e+i)/(2*n),o=(-e-i)/(2*n),a=s=>s>=-1e-9&&s<=1+1e-9;return a(r)?Math.min(1,Math.max(0,r)):a(o)?Math.min(1,Math.max(0,o)):t}function Ci(n,e){let t=Bt(e.viaX,e.viaY);return t?ki(Math.min(1,Math.max(0,n)),t.x,t.y):xi(n,e.curve)}function Ii(n,e,t,i){return i==="log"&&n>0&&e>0?Math.exp(Math.log(n)+(Math.log(e)-Math.log(n))*t):n+(e-n)*t}function we(n,e,t="linear"){let i=n.points;if(i.length===0)return 0;let r=i[0];if(e<=r.t)return r.v;let o=i[i.length-1];if(e>=o.t)return o.v;let a=0,s=i.length-1;for(;s-a>1;){let f=a+s>>1;i[f].t<=e?a=f:s=f}let l=i[a],d=i[s],m=d.t-l.t;return m<=0?d.v:Ii(l.v,d.v,Ci((e-l.t)/m,l),t)}var ke=new Map,Di=64;function zt(n,e=Re){let t=`${e}\0${n}`,i=ke.get(t);if(i!==void 0)return i;let r=null;try{r=Gt(n).lanes.find(o=>o.target===e)??null}catch{r=null}return ke.size>Di&&ke.clear(),ke.set(t,r),r}var jt=48,qt=new WeakMap;function Pi(n){let e=n.points,t=e[0].v,i=e[e.length-1].v,r=[0],o=[0],a=l=>{let d=r[r.length-1];if(l<=d)return;let m=we(n,d,"log");r.push(l),o.push(o[o.length-1]+(m+we(n,l,"log"))/2*(l-d))},s=Math.max(0,e[0].t);a(s);for(let l=1;l<e.length;l+=1){let d=e[l-1].t,m=e[l].t;if(!(m<=0))for(let f=1;f<=jt;f+=1)a(Math.max(d,0)+(m-d)*f/jt)}return{ts:Float64Array.from(r),ss:Float64Array.from(o),firstRate:t,lastRate:i}}function Li(n){let e=qt.get(n);return e||(e=Pi(n),qt.set(n,e)),e}function Ni(n){return typeof n!="number"&&n.points.length>0}function Oi(n,e,t){let i=0,r=n.length-1;for(;r-i>1;){let o=i+r>>1;n[o]<=t?i=o:r=o}return e[i]+(e[r]-e[i])*(t-n[i])/(n[r]-n[i])}function Yt(n,e){if(typeof n=="number")return e/n;if(!Ni(n))return e;let{ts:t,ss:i,firstRate:r,lastRate:o}=Li(n),a=t.length-1;return e<=0?e/r:e>=i[a]?t[a]+(e-i[a])/o:Oi(i,t,e)}function Fi(n){return n?zt(n,xe):null}function Xt(n,e){return Fi(n)??e}var Po=[{id:"montage",label:"Montage",points:[[0,.9],[.15,.3],[.5,2.5],[.85,.3],[1,.9]]},{id:"hero",label:"Hero",points:[[0,1],[.25,1.6],[.5,.25],[.75,1.6],[1,1]]},{id:"bullet",label:"Bullet",points:[[0,3],[.4,3],[.5,.15],[.6,3],[1,3]]},{id:"jump-cut",label:"Jump cut",points:[[0,.5],[.24,.5],[.26,3],[.5,3],[.52,.5],[.74,.5],[.76,3],[1,3]]},{id:"flash-in",label:"Flash in",points:[[0,.3],[.6,.6],[1,5]]},{id:"flash-out",label:"Flash out",points:[[0,5],[.4,.6],[1,.3]]},{id:"ramp-in",label:"Ramp in",points:[[0,.5],[1,1]]},{id:"ramp-out",label:"Ramp out",points:[[0,1],[1,.5]]},{id:"slowmo-middle",label:"Slow-mo middle",points:[[0,1],[1/3,.35],[2/3,.35],[1,1]]}];var y=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),No=Object.freeze([y.start,y.duration,y.trackIndex]),Oo=Object.freeze([y.derivedEnd]),Fo=Object.freeze([y.derivedEnd,y.legacyTrack]);function N(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var Jt=/^[A-Za-z0-9_.:-]+$/;function Qt(n,e){let t=n.charCodeAt(e);return t>=48&&t<=57}function Kt(n,e){let t=e;for(;t>=0&&Qt(n,t);)t--;return t}function Ui(n,e){let t=e;for(;t>=0&&(n[t]??"").trim()==="";)t--;return t}function Hi(n){let e=n.length-1;if(!Qt(n,e))return null;let t=Kt(n,e);return n[t]==="."&&(t=Kt(n,t-1)),t+1}function Vi(n){let e=Hi(n);if(e==null)return null;let t=Ui(n,e-1),i=n[t];if(i!=="+"&&i!=="-")return null;let r=n.slice(0,t).trim();if(!Jt.test(r))return null;let o=Number(n.slice(e));return Number.isFinite(o)?{refId:r,operator:i,magnitude:o}:null}function re(n){let e=(n??"").trim();if(!e)return null;let t=N(e);if(t!=null)return{kind:"absolute",value:t};if(Jt.test(e))return{kind:"reference",refId:e,offset:0};let i=Vi(e);return i?{kind:"reference",refId:i.refId,offset:i.operator==="-"?-i.magnitude:i.magnitude}:null}function x(n,e,t,i){n.push({code:e,attribute:t,value:i})}function Wi(n,e,t,i){if(e==null||e.trim()==="")return t.defaultStart===void 0?0:t.defaultStart;if(!n)return x(i,"invalid-start",y.start,e),null;if(n.kind==="absolute")return Math.max(0,n.value);let r=t.resolveReferenceEnd?.(n.refId);return r==null||!Number.isFinite(r)?(x(i,"unresolved-start-reference",y.start,e),null):Math.max(0,r+n.offset)}var $i=1e-9;function Bi(n,e){return Math.abs(n-e)<=$i}function Gi(n,e,t){let i=N(n);if(i==null){x(t,"deprecated-end",y.derivedEnd,n),x(t,"invalid-end",y.derivedEnd,n);return}if(e==null){x(t,"deprecated-end",y.derivedEnd,n);return}Bi(i,e)||(x(t,"deprecated-end",y.derivedEnd,n),x(t,"conflicting-end",y.derivedEnd,n))}function zi(n,e,t){let i=N(n);return i==null||i<0?(x(t,"invalid-duration",y.duration,n),{duration:null,end:null,durationSource:"invalid"}):{duration:i,end:e==null?null:e+i,durationSource:"duration"}}function ji(n,e,t){x(t,"deprecated-end",y.derivedEnd,n);let i=N(n);return i==null?(x(t,"invalid-end",y.derivedEnd,n),{duration:null,end:null,durationSource:"invalid"}):e==null?{duration:null,end:i,durationSource:"legacy-end"}:i<e?(x(t,"end-before-start",y.derivedEnd,n),{duration:null,end:null,durationSource:"invalid"}):{duration:i-e,end:i,durationSource:"legacy-end"}}function qi(n,e,t){let i=n.getAttribute(y.duration),r=n.getAttribute(y.derivedEnd);if(i==null)return r==null?{duration:null,end:null,durationSource:"missing"}:ji(r,e,t);let o=zi(i,e,t);return r!=null&&Gi(r,o.end,t),o}function Zt(n,e,t,i){let r=N(n);return r==null||!Number.isInteger(r)?(x(i,"invalid-track-index",e,n),{trackIndex:0,trackSource:"invalid"}):{trackIndex:r,trackSource:t}}function Yi(n,e){let t=n.getAttribute(y.trackIndex),i=n.getAttribute(y.legacyTrack);if(t==null&&i==null)return{trackIndex:0,trackSource:"default"};if(t==null&&i!=null)return x(e,"deprecated-layer",y.legacyTrack,i),Zt(i,y.legacyTrack,"legacy-layer",e);let r=Zt(t??"",y.trackIndex,"track-index",e);if(i==null)return r;x(e,"deprecated-layer",y.legacyTrack,i);let o=N(i);return o!=null&&o!==r.trackIndex&&x(e,"conflicting-layer",y.legacyTrack,i),r}function Qe(n,e={}){let t=[],i=n.getAttribute(y.start),r=re(i),o=Wi(r,i,e,t),a=qi(n,o,t),s=Yi(n,t);return{startExpression:r,start:o,...a,...s,diagnostics:t}}function V(n){return N(n)}function et(n){return Ot(e=>n.getAttribute(e),P(n)?n.defaultPlaybackRate:1)}function Xi(n){return Xt(n.getAttribute("data-automation"),et(n))}function tt(n){return Ee(e=>n.getAttribute(e))}function oe(n,e){return Ki(e,tt(n),Xi(n))}function nt(n){let e=Ke({tag:"video",authoredDurationSeconds:Ye(t=>n.getAttribute(t)),sourceDurationSeconds:Number.isFinite(n.duration)?n.duration:null,mediaStartSeconds:tt(n),playbackRate:et(n)});return e.source==="media"?oe(n,n.duration):e.seconds}function Me(n,e=0){return!Lt(n)||!n.hasAttribute("data-start")&&!n.hasAttribute("data-track-index")?null:Ke({tag:"img",authoredDurationSeconds:Ft(t=>n.getAttribute(t),e),sourceDurationSeconds:null,mediaStartSeconds:0,playbackRate:1}).seconds}function Ki(n,e,t){return typeof t=="number"?Xe(n,e,t):Number.isFinite(n)?Yt(t,Math.max(0,n-e)):null}function en(){return globalThis}function it(n,e){if(typeof window>"u")return;let t=en(),i=t.__hf?.onSwallowed;if(i)try{i({label:n,error:e})}catch(r){}(t.__hfDebug||t.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${n} swallowed:`,e)}var Zi=n=>n.paused?.()===!0?(n.startTime?.()??0)+(n.totalDuration?.()??0)/Math.abs(n.timeScale?.()||1):0;function ae(n){try{if(typeof n?.duration!="function")return null;let e=n.getChildren?.(!1,!1,!0),t=Array.isArray(e)?e:[],i=Math.max(Number(n.duration()),...t.map(Zi));return Number.isFinite(i)?i:null}catch(e){return it("runtime.timelineDuration",e),null}}var tn="data-hf-authored-duration",nn="data-hf-authored-end";function se(n){if(n==null||typeof n=="string"&&n.trim()==="")return null;let e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:null}function Ce(n){let e=se(n.start);if(e==null)return null;let t=Math.max(0,e),i=se(n.duration),r=se(n.authoredDuration),o=i!=null&&i>0?i:r!=null&&r>0?r:null;if(o!=null)return{start:t,duration:o,end:t+o};let a=se(n.end),s=se(n.authoredEnd),l=a!=null&&a>t?a:s!=null&&s>t?s:null;return{start:t,duration:l==null?null:l-t,end:l}}var z=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),Jo=Object.freeze([z.start,z.duration,z.trackIndex]),Qo=Object.freeze([z.derivedEnd]),ea=Object.freeze([z.derivedEnd,z.legacyTrack]);function Ji(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var rn=n=>{let e=Ji(n);return e!==null&&e>=0?e:null};function Qi(n){return rn(n("data-playback-start"))??rn(n("data-media-start"))??0}var on="data-hf-media-start-basis";function an(n){return n?.trim().toLowerCase()==="global"?"global":"local"}function er(n){return an(n.basis)==="global"?n.authoredStart:n.hostStart+n.authoredStart}function sn(n){return un(n)?er({authoredStart:n.authoredStart,hostStart:n.hostStart,basis:n.basis}):n.ordinaryStart()}function ln(n){return un(n)&&an(n.basis)==="global"}function un(n){return!n.hasAutoStart&&n.authoredStart!=null&&n.hostStart!==0}function rt(n){return Qi(e=>n.getAttribute(e))}function dn(n,e){return n-rt(e)}function le(n){let e=n.timelineRegistry??{},t=n.includeAuthoredTimingAttrs??!1,i=n.documentRef??document,r=new WeakMap,o=new WeakMap,a=new Set,s=u=>(u.hasAttribute("data-composition-id")?u.parentElement:u)?.closest("[data-composition-id]")??null,l=(u,h)=>{let g=s(h);if(g){for(let k of g.querySelectorAll(`[id="${u}"]`))if(s(k)===g)return k}let R=i.getElementById(u);return R||(Array.from(i.querySelectorAll("[data-composition-id]")).find(k=>k.getAttribute("data-composition-id")===u)??null)},d=(u,h)=>t?u.getAttribute(h):null,m=u=>Ce({start:0,duration:u.getAttribute("data-duration"),authoredDuration:d(u,"data-hf-authored-duration")})?.duration??Ce({start:T(u,0),end:u.getAttribute("data-end"),authoredEnd:d(u,"data-hf-authored-end")})?.duration??null,f=u=>u!=null&&Number.isFinite(u)&&u>0?u:null,v=u=>{let h=u.getAttribute("data-composition-id");return h?f(ae(e[h])):null},b=u=>{let h=o.get(u);if(h!==void 0)return h;let g=m(u)??f(P(u)?oe(u,u.duration):null)??f(Me(u))??v(u);return o.set(u,g),g},S="[data-composition-src], [data-composition-id], [data-composition-file]",_=u=>u.matches(S),A=u=>!u.hasAttribute("data-composition-id")||re(u.getAttribute("data-start"))?null:u.parentElement?.closest(`[data-start], ${S}`)??null,C=(u,h)=>dn(T(u,h),A(u)??u),M=(u,h)=>{let g=u.hasAttribute("data-composition-id")?u.parentElement?.closest("[data-composition-id]"):u.closest("[data-composition-id]");return g?C(g,h):0},I=(u,h)=>{let g=re(u.getAttribute("data-start"));if(!g){let H=A(u);return H?T(H,h):h}if(g.kind==="absolute")return M(u,h)+Math.max(0,g.value);let R=l(g.refId,u);if(!R)return h;let k=T(R,0),ye=b(R)??0,ve=Math.min(0,M(u,0));return Math.max(ve,k+ye+g.offset)},T=(u,h)=>{let g=r.get(u);if(g!==void 0)return g??h;if(a.has(u))return h;a.add(u);try{let R=I(u,h);return r.set(u,R),R}finally{a.delete(u)}},U=u=>{let h=u.closest("[data-composition-id]");return{authoredStart:V(u.getAttribute("data-start")),hostStart:h?C(h,0):0,hasAutoStart:u.hasAttribute("data-hf-auto-start"),basis:u.getAttribute(on)}};return{resolveStartForElement:(u,h=0)=>T(u,Math.max(0,h)),resolveDurationForElement:u=>b(u),resolveMediaStartForElement:u=>{let h=U(u);return sn({...h,ordinaryStart:()=>T(u,h.hostStart)})},resolveHostStartForElement:u=>M(u,0),resolveHostSlotsForElement:u=>{let h=[];for(let g=u.parentElement;g;g=g.parentElement){if(!_(g)||A(g)||rt(g)<=0)continue;let R=T(g,0),k=m(g);h.push({start:R,end:k?R+k:1/0})}return h},isRootGlobalMediaStartForElement:u=>P(u)&&ln(U(u))}}function cn(){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 mn=7200,ot=1/60,ue=n=>n!==null&&n>ot?n:null;function tr(n){return{width:Ae(n.getAttribute("data-width")),height:Ae(n.getAttribute("data-height"))}}function nr(n,e){let t=[];for(let i of n.querySelectorAll("video[data-start], audio[data-start]")){let r=e.mediaStart(i);if(!Number.isFinite(r))continue;let o=e.mediaDuration(i);o==null||o<=ot||t.push(Math.max(0,r)+o)}return ue(Se({authoredDurationSeconds:null,clipEndsSeconds:t}).seconds)}function ir(n,e){let t=[];for(let r of n.querySelectorAll("[data-composition-id][data-start]")){if(r.parentElement?.closest("[data-composition-id]")!==n)continue;let o=e.resolveStartForElement(r,0),a=e.resolveDurationForElement(r);!Number.isFinite(o)||a==null||a<=0||t.push(Math.max(0,o)+a)}let i=V(n.getAttribute("data-duration"));return ue(Se({authoredDurationSeconds:null,clipEndsSeconds:[i,...t]}).seconds)}var rr=n=>n.hasAttribute("data-composition-id")||n.hasAttribute("data-composition-src");function or(n,e,{unregisteredLottie:t}){let i=[];for(let o of n.querySelectorAll("[data-start]")){let a=e.resolveStartForElement(o,0);if(!Number.isFinite(a))continue;let s=e.resolveDurationForElement(o);s!=null?i.push(Math.max(0,a)+s):(P(o)||rr(o))&&i.push(null)}(t||n.querySelector("[data-lottie-src]"))&&i.push(null);let r=Se({authoredDurationSeconds:null,clipEndsSeconds:i});return r.pendingClips>0?{...r,seconds:null,source:"unresolved",reason:"a clip's length is pending"}:r}function ar(n){if(n.declared!==null&&Number.isFinite(n.declared)&&n.declared>0)return n.declared;let e=ue(n.timeline()),t=Math.max(0,...n.floors().map(l=>l??0)),i=Number.isFinite(n.fallback)&&n.fallback>ot?n.fallback:0,r=Math.max(t,i),a=e!==null&&e>=mn&&ue(r)!==null?null:e,s;return a!==null?s=Math.max(a,r):ue(t)!==null?s=r:i>0?s=i:s=n.derived(),s>0?s:0}function pn(n){let e=Q(n);if(!e)return null;let t=le({timelineRegistry:{},includeAuthoredTimingAttrs:!0,documentRef:n}),i=ar({declared:V(e.getAttribute("data-duration")),timeline:()=>null,floors:()=>[nr(n,{mediaStart:t.resolveMediaStartForElement,mediaDuration:nt}),ir(e,t)],fallback:0,derived:()=>or(e,t,{unregisteredLottie:!1}).seconds??0});return{...tr(e),fps:cn().canonicalFps,durationSeconds:i}}var hn="hyperframes-studio-preview";var fn="__hfPreviewErrors";function bn(n){return n.hasRuntime||n.runtimeInjected?!1:!!(n.hasNestedCompositions||n.hasTimelines&&n.attempts>=5)}function j(n){return typeof n=="object"&&n!==null}function gn(n){return j(n)&&typeof n.getDuration=="function"}function _n(n){return j(n)&&typeof n.duration=="function"&&typeof n.time=="function"&&typeof n.seek=="function"&&typeof n.play=="function"&&typeof n.pause=="function"}var q="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.209/dist/hyperframe.runtime.iife.js";function de(n){if(n===null)return null;let e=Number.parseInt(n,10);return Number.isFinite(e)&&e>0?e:null}function sr(n){let e=n?.querySelector("[data-composition-id][data-width][data-height]")??n?.querySelector("[data-width][data-height]");if(!e)return null;let t=de(e.getAttribute("data-width")),i=de(e.getAttribute("data-height"));return t!==null&&i!==null?{width:t,height:i}:null}function lr(n){return Array.isArray(n)?n.find(e=>typeof e=="string"&&e.trim()!==""&&e!=="[object Event]")??null:null}var Ie=class{constructor(e,t){this._iframe=e;this._callbacks=t}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;_runtimeScript=null;_failure=null;get failed(){return this._failure!==null&&this._failure.document===this._iframe.contentDocument}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._failure=null,this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;let t=null;try{t=this._poll(e)}catch(i){i instanceof DOMException&&i.name==="SecurityError"||(t={kind:"error",message:i instanceof Error?i.message:String(i)})}t??=this._deadlineOutcome(e),t&&(this.stop(),t.kind==="error"?(this._failure={document:this._iframe.contentDocument},this._callbacks.onError(t.message)):this._callbacks.onReady(t.result))},200)}_deadlineOutcome(e){return e<40||this._callbacks.hostOwnsDeadline?.()?null:{kind:"error",message:"Composition timeline not found after 8s"}}_poll(e){let t=this._iframe.contentWindow;if(!t)return null;let i=lr(Reflect.get(t,fn));if(i!==null)return{kind:"error",message:i};let r=this._iframe.contentDocument,o=Reflect.get(t,"__timelines"),a=this.hasRuntimeBridge(t);if(bn({hasRuntime:a,hasTimelines:j(o)&&Object.keys(o).length>0,hasNestedCompositions:!!r?.querySelector("[data-composition-src]"),runtimeInjected:this._runtimeInjected,attempts:e}))return this._injectRuntime(),null;if(this._runtimeInjected&&!a)return null;let s=this._resolveReadyResult(t,r);return s?{kind:"ready",result:s}:null}_resolveReadyResult(e,t){let i=this._resolvePlaybackDurationAdapter(e)??{kind:"document",getDuration:()=>0},r=i.getDuration();if(!Number.isFinite(r)||r<=0){if(i.kind==="direct-timeline")return null;r=t?pn(t)?.durationSeconds??0:0}return r<=0?null:{duration:r,adapter:{...i,getDuration:()=>r},compositionSize:sr(t)}}stop(){this._runtimeScript&&(this._runtimeScript.onerror=null,this._runtimeScript=null),this.failed||(this._failure=null),this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return j(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=this._callbacks.resolveRuntimeUrl?.()??q,this._runtimeScript=t,t.onerror=()=>{this._runtimeScript!==t||this._iframe.contentDocument!==e||(this.stop(),this._failure={document:e},this._callbacks.onError("HyperFrames runtime failed to load from "+t.src))},(e.head||e.documentElement).appendChild(t),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let t=Reflect.get(e,"__timelines");if(!j(t))return null;let i=Object.keys(t);if(i.length===0)return null;let r=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=r&&r in t?r:i[i.length-1],a=t[o];return _n(a)?a:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(gn(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var yn=`
|
|
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
|
-
`,In='<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>',Cn='<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>',ft='<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>',ht='<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>',Dn='<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 bt=[.25,.5,1,1.5,2,4];function W(n){return Number.isInteger(n)?`${n}x`:`${n}x`}function Ve(n){if(!Number.isFinite(n)||n<0)return"0:00";let e=Math.floor(n),t=Math.floor(e/60),i=e%60;return`${t}:${i.toString().padStart(2,"0")}`}function Nn(n,e,t={}){let i=t.speedPresets??bt,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">${In}</span><span class="hfp-ico hfp-ico-pause">${Cn}</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: 1x");let h=document.createElement("div");h.className="hfp-speed-menu",h.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=W(c),c===1&&p.classList.add("hfp-active"),h.appendChild(p)}d.appendChild(h),d.appendChild(m);let v=document.createElement("div");v.className="hfp-volume-wrap";let b=document.createElement("button");b.className="hfp-mute-btn",b.type="button",b.innerHTML=ft,b.setAttribute("aria-label","Mute");let A=document.createElement("div");A.className="hfp-volume-slider-wrap";let _=document.createElement("div");_.className="hfp-volume-slider",_.setAttribute("role","slider"),_.setAttribute("aria-label","Volume"),_.setAttribute("aria-valuemin","0"),_.setAttribute("aria-valuemax","100"),_.setAttribute("aria-valuenow","100"),_.tabIndex=0;let E=document.createElement("div");E.className="hfp-volume-fill",E.style.width="100%",_.appendChild(E),A.appendChild(_),v.appendChild(A),v.appendChild(b),t.audioLocked&&(v.style.display="none"),r.appendChild(o),r.appendChild(a),r.appendChild(u),r.appendChild(v),r.appendChild(d),n.appendChild(r);let C=!1,M=!1,D=1,T=null,V=i.indexOf(1);V===-1&&(V=0);let ne=(c,p)=>c?Dn:p===0?ht:p<.5?ht:ft;o.addEventListener("click",c=>{c.stopPropagation(),C?e.onPause():e.onPlay()}),b.addEventListener("click",c=>{c.stopPropagation(),e.onMuteToggle()});let F=!1,ie=c=>{let p=_.getBoundingClientRect(),S=Math.max(0,Math.min(1,(c-p.left)/p.width));D=S,E.style.width=`${S*100}%`,_.setAttribute("aria-valuenow",String(Math.round(S*100))),M&&S>0&&e.onMuteToggle(),b.innerHTML=ne(M,S),e.onVolumeChange(S)};_.addEventListener("mousedown",c=>{c.stopPropagation(),F=!0,ie(c.clientX)});let l=c=>{F&&ie(c.clientX)},f=()=>{F=!1};document.addEventListener("mousemove",l),document.addEventListener("mouseup",f),_.addEventListener("touchstart",c=>{F=!0;let p=c.touches[0];p&&ie(p.clientX)},{passive:!0});let g=c=>{if(F){let p=c.touches[0];p&&ie(p.clientX)}},R=()=>{F=!1};document.addEventListener("touchmove",g,{passive:!0}),document.addEventListener("touchend",R);let k=.05;_.addEventListener("keydown",c=>{let p=D;if(c.key==="ArrowRight"||c.key==="ArrowUp")p=Math.min(1,D+k);else if(c.key==="ArrowLeft"||c.key==="ArrowDown")p=Math.max(0,D-k);else return;c.preventDefault(),c.stopPropagation(),D=p,E.style.width=`${p*100}%`,_.setAttribute("aria-valuenow",String(Math.round(p*100))),M&&p>0&&e.onMuteToggle(),b.innerHTML=ne(M,p),e.onVolumeChange(p)});let Te=c=>{for(let p of h.querySelectorAll(".hfp-speed-option"))p.classList.toggle("hfp-active",p.dataset.speed===String(c))};m.addEventListener("click",c=>{c.stopPropagation();let p=h.classList.toggle("hfp-open");m.setAttribute("aria-expanded",String(p))}),h.addEventListener("click",c=>{c.stopPropagation();let p=c.target.closest(".hfp-speed-option");if(!p)return;let S=parseFloat(p.dataset.speed);V=i.indexOf(S),m.textContent=W(S),m.setAttribute("aria-label",`Playback speed: ${W(S)}`),Te(S),h.classList.remove("hfp-open"),m.setAttribute("aria-expanded","false"),e.onSpeedChange(S)});let Re=()=>{h.classList.remove("hfp-open"),m.setAttribute("aria-expanded","false")};document.addEventListener("click",Re);let H=c=>{let p=a.getBoundingClientRect(),S=Math.max(0,Math.min(1,(c-p.left)/p.width));e.onSeek(S)},N=!1;a.addEventListener("mousedown",c=>{c.stopPropagation(),N=!0,e.onScrubStart?.(),H(c.clientX)});let Lt=c=>{N&&H(c.clientX)},Ot=()=>{N&&(N=!1,e.onScrubEnd?.())};document.addEventListener("mousemove",Lt),document.addEventListener("mouseup",Ot),a.addEventListener("touchstart",c=>{N=!0,e.onScrubStart?.();let p=c.touches[0];p&&H(p.clientX)},{passive:!0});let Ft=c=>{if(N){let p=c.touches[0];p&&H(p.clientX)}},Ut=()=>{N&&(N=!1,e.onScrubEnd?.())};document.addEventListener("touchmove",Ft,{passive:!0}),document.addEventListener("touchend",Ut);let Vt=()=>C&&!N&&!F&&!r.querySelector(":focus-visible"),Ht=()=>{r.classList.remove("hfp-hidden"),T&&clearTimeout(T),T=setTimeout(()=>{Vt()&&r.classList.add("hfp-hidden")},3e3)},U=n instanceof ShadowRoot?n.host:n,G=()=>Ht(),$t=()=>{Vt()&&r.classList.add("hfp-hidden")};return U.addEventListener("mousemove",G),U.addEventListener("keydown",G),U.addEventListener("focusin",G),U.addEventListener("mouseleave",$t),{updateTime(c,p){let S=p>0?Math.min(c,p):c,ci=p>0?S/p*100:0;s.style.width=`${ci}%`,u.textContent=`${Ve(S)} / ${Ve(p)}`},updatePlaying(c){let p=c!==C;C=c,o.classList.toggle("hfp-playing",c),o.setAttribute("aria-label",c?"Pause":"Play"),c?p&&Ht():(T&&clearTimeout(T),r.classList.remove("hfp-hidden"))},updateSpeed(c){let p=i.indexOf(c);p!==-1&&(V=p),m.textContent=W(c),m.setAttribute("aria-label",`Playback speed: ${W(c)}`),Te(c)},updateMuted(c){M=c,b.innerHTML=ne(c,D),b.setAttribute("aria-label",c?"Unmute":"Mute")},updateVolume(c){D=c,E.style.width=`${c*100}%`,_.setAttribute("aria-valuenow",String(Math.round(c*100))),b.innerHTML=ne(M,c)},setVolumeControlsHidden(c){v.style.display=c?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",Lt),document.removeEventListener("mouseup",Ot),document.removeEventListener("touchmove",Ft),document.removeEventListener("touchend",Ut),document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",f),document.removeEventListener("touchmove",g),document.removeEventListener("touchend",R),document.removeEventListener("click",Re),U.removeEventListener("mousemove",G),U.removeEventListener("keydown",G),U.removeEventListener("focusin",G),U.removeEventListener("mouseleave",$t),T&&clearTimeout(T),r.remove()}}}function Pn(n,e,t,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=Nn(n,r,s);return u.updateMuted(e),u.updateVolume(t),u}function gt(n,e,t){return e?(t||(t=document.createElement("img"),t.className="hfp-poster",n.appendChild(t)),t.src=e,t):(t?.remove(),null)}function Ln(n){return n.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains("hfp-controls"))}var He=null;function On(n,e){if(typeof CSSStyleSheet<"u")try{He||(He=new CSSStyleSheet,He.replaceSync(e)),n.adoptedStyleSheets=[He];return}catch{}let t=document.createElement("style");t.textContent=e,n.appendChild(t)}function Fn(){let n=document.createElement("div");n.className="hfp-container";let e=document.createElement("iframe");return e.className="hfp-iframe",e.sandbox.add("allow-scripts","allow-same-origin"),e.allow="autoplay; fullscreen",e.referrerPolicy="no-referrer",e.title="HyperFrames Composition",n.appendChild(e),{container:n,iframe:e}}function Un(n,e,t,i){let r=n.offsetWidth,o=n.offsetHeight;if(r===0||o===0)return!1;let a=Math.min(r/t,o/i);return e.style.width=`${t}px`,e.style.height=`${i}px`,e.style.transform=`translate(-50%, -50%) scale(${a})`,!0}function hr(n,e,t){if(t.end<=0)return!1;let i=t.shown<t.end&&e>0?e+.001:0;return n+i>=t.end}var $e=class{constructor(e){this._callbacks=e}_callbacks;_raf=null;_lastUpdateMs=0;_tick=null;start(e,t,i,r,o){this.stop();let a=null,s=0,u=0,d=()=>{if(r()){this._raf=null;return}let m;try{m=e.time()}catch{this._raf=null;return}let h=i(),v=o();v.end>0&&(m=Math.min(m,v.end));let b=a===null?0:m-a;b!==0&&(u=Math.min(b,s),s=b),a=m;let A=hr(m,u,v);A&&(m=v.shown);let _=performance.now();if((_-this._lastUpdateMs>100||A)&&(this._lastUpdateMs=_,this._callbacks.onTimeUpdate(m,h)),A){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{e.pause(),v.shown<v.end&&e.seek(v.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(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 Vn(n){let e=Array.from(n.querySelectorAll("[data-composition-id]"));if(e.length===0)return n.body?[n.body]:[];let t=[];for(let i of e)gr(i)||t.push(i);return br(n),t}function br(n){let e=n.body;if(!e||typeof console>"u"||typeof console.warn!="function")return;let t=e.querySelectorAll("audio[data-start], video[data-start]");if(t.length===0)return;let i=[];for(let r of t)r.closest("[data-composition-id]")||i.push(r);i.length!==0&&console.warn(`[hyperframes-player] selectMediaObserverTargets: composition hosts are present, but ${i.length} body-level timed media element(s) sit outside every [data-composition-id] subtree and will not be observed. Move them inside a composition host or the parent-frame proxy will never adopt them.`,i)}function gr(n){let e=n.parentElement;for(;e;){if(e.hasAttribute("data-composition-id"))return!0;e=e.parentElement}return!1}var Hn=n=>4*Number.EPSILON*Math.max(1,Math.abs(n));function he(n,e){return!Number.isFinite(n)||!Number.isFinite(e)?n===e:Math.abs(n-e)<=Hn(Math.max(Math.abs(n),Math.abs(e)))}var $n=(n,e)=>n>=e||he(n,e),We=(n,e,t)=>$n(n,e)&&n<t&&!he(n,t),_r=1e-6,_t=(n,e,t,i)=>We(n,e,t)||$n(n,e)&&i>0&&t>=i-_r;function J(n){return n+1e-5}var yr="data-fade-in",vr="data-fade-out",fs=yr.slice(5),hs=vr.slice(5),Ar=Object.freeze({fadeIn:0,fadeOut:0});var Wn=':not([muted]):is(:not([data-has-audio]),[data-has-audio="true"])',gs=`audio[data-start], video[data-start]${Wn}`;var Sr=`[data-start]:not(video, audio, img, [${Sn}], [${Rn}])`,Us=`${Sr}[${K}]`,Vs=`meta[name="${Fe}"]`;var Hs=`[${K}][${K}]`,$s=`[${K}][style*="visibility: hidden"]`;var Tr=[[.3,.25],[.1,.1]],Rr=.01,xr=.1,wr=.1,be=new WeakMap;function yt(n,e,t,i,r=n.tagName==="AUDIO"){let o=Math.abs(e);if(r&&i&&o>wr)return be.delete(n),{rate:t,seek:!0};let a=Math.sign(e),s=be.get(n);if(o>.04)be.set(n,a);else if(s!==a||o<=Rr)return be.delete(n),{rate:t,seek:!1};let u=Tr.find(([m])=>o>m)?.[1]??.03,d=r?Math.min(u,xr):u;return{rate:t*(1+a*d),seek:!1}}function vt(n){be.delete(n)}var Mu=1/16;var Mr=["backdrop-filter","clip-path","filter","mask","mask-border-source","mask-image","perspective","rotate","scale","transform","translate","-webkit-mask-image"],Lu=new Set([...Mr,"contain","isolation","mask-border","mix-blend-mode","opacity"]);function Ir(n){return Number.isFinite(n)&&n>0?n:30}function Cr(n){return Number.isFinite(n)&&n>0?n:0}function Bn(n,e){let t=Ir(e),i=Cr(n),r=i*t,o=Math.round(r);return Math.abs(r-o)<=.001?o/t:i}function Gn(n,e,t){return{start:Bn(n,t),end:Number.isFinite(e)?Bn(e,t):e}}var Dr=["seconds-time","rational-fps","seek-keep-playing","composition-manifest-v1","runtime-data","play-range"];function Nr(n,e){let t=Math.abs(n),i=Math.abs(e);for(;i!==0;){let r=t%i;t=i,i=r}return t||1}function Pr(n){let e=Number.isFinite(n)&&n>0?n:30,t=Math.abs(e*1001-Math.round(e*1001))<1e-6,i=Number.isInteger(e)?1:t?1001:1e6,r=Math.round(e*i),o=Nr(r,i);return{numerator:r/o,denominator:i/o}}function jn(n,e,t){return Math.max(n,(Math.ceil(e*t-1e-6)-1)/t)}function Lr(n){if(typeof n!="object"||n===null)return null;let e=n;return!Number.isFinite(e.numerator)||!Number.isFinite(e.denominator)||(e.numerator??0)<=0||(e.denominator??0)<=0?null:Number(e.numerator)/Number(e.denominator)}function At(n){return{protocolVersion:1,capabilities:Dr,fps:Pr(n)}}function zn(n){let e=n.offsetWidth,t=n.getBoundingClientRect().width;return e>0&&t>0?t/e:null}function Or(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function qn(n,e=30){if(typeof n!="object"||n===null)return{status:"legacy",fps:e};let t=n;if(t.protocolVersion===void 0)return{status:"legacy",fps:e};if(t.protocolVersion!==1)return{status:"unsupported",code:"unsupported_protocol_version",receivedVersion:t.protocolVersion};let i=Lr(t.fps);return i===null||!Or(t.capabilities)?{status:"unsupported",code:"invalid_protocol_metadata",receivedVersion:t.protocolVersion}:{status:"supported",fps:i,metadata:t}}function Fr(n,e){let t=n.tagName.toLowerCase();if(t==="script"||t==="style"||t==="link"||t==="meta")return null;let r=t==="video"||t==="audio"?e.resolver.resolveMediaStartForElement(n):e.resolver.resolveStartForElement(n,0),o=e.resolver.resolveDurationForElement(n),a=n.getAttribute("data-composition-id");if(a){let u=e.timelineRegistry[a],d=ce(u);!(n.hasAttribute("data-duration")||n.hasAttribute("data-end")||n.hasAttribute(cn)||n.hasAttribute(mn))&&(o==null||o<=0)&&d!=null&&d>0&&(o=d)}let s=a!==null&&n===re(n.ownerDocument);return{start:r,end:!s&&o!=null&&o>0?r+o:Number.POSITIVE_INFINITY}}function Yn(n,e){let t=Fr(n,e);if(!t)return!1;let i=e.exportRenderSeek?Gn(t.start,t.end,e.canonicalFps):t;return _t(e.currentTime,i.start,i.end,e.compositionDuration)}var Q="first-frame",Ur=3;function ge(n){let e=n.ownerDocument?.defaultView;return e&&n instanceof e.Element?!0:n instanceof Element}function w(n){if(!ge(n)||n.tagName!=="AUDIO"&&n.tagName!=="VIDEO")return!1;let e=n.ownerDocument?.defaultView;return e&&n instanceof e.HTMLMediaElement?!0:n instanceof HTMLMediaElement}function Vr(n){return n.hasAttribute("data-start")||n.hasAttribute("data-track-index")}function Hr(n,e,t){let i=n;for(;i;){if(Vr(i)&&!Yn(i,{currentTime:0,compositionDuration:Number.POSITIVE_INFINITY,canonicalFps:30,exportRenderSeek:!1,timelineRegistry:t,resolver:e}))return!1;i=i.parentElement}return!0}function Kn(n,e,t,i){return e==="all"?!0:Hr(n,t,i)}function Ge(n,{scope:e="all"}={}){let t=n.defaultView,i=$({documentRef:n,timelineRegistry:t?.__timelines,includeAuthoredTimingAttrs:!0}),r=n.querySelector(`meta[name="${Fe}"]`)!==null,o=Array.from(n.querySelectorAll("video, audio")).filter(w).filter(u=>Kn(u,r&&u.preload!=="auto"?Q:e,i,t?.__timelines??{})).filter(u=>u.readyState<Ur),a=Array.from(n.querySelectorAll("img")).filter(u=>Kn(u,u.getAttribute("loading")?.toLowerCase()==="lazy"?Q:e,i,t?.__timelines??{})).filter(u=>!u.complete),s=n.fonts?.status==="loading";return{pendingMedia:o,pendingImages:a,fontsLoading:s}}function $r(n,{pendingMedia:e,pendingImages:t,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=t.map(u=>u.decode?u.decode().catch(()=>{}):Promise.resolve()),s=i&&n.fonts?n.fonts.ready.then(()=>{}):Promise.resolve();return Promise.all([...o,...a,s]).then(()=>{})}function Wr(n,e,{scope:t="all"}={}){let i=Ge(n,{scope:t});return i.pendingMedia.length===0&&i.pendingImages.length===0&&!i.fontsLoading?null:$r(n,i,e)}var Br=50;function Gr(n,e){let t=n.defaultView;return!t||t.__renderReady||!t.__hf?null:new Promise(i=>{let r,o=()=>{r!==void 0&&clearTimeout(r),e.removeEventListener("abort",o),i()};if(e.aborted){o();return}e.addEventListener("abort",o,{once:!0});let a=()=>{if(t.__renderReady){o();return}r=setTimeout(a,Br)};a()})}var jr=50,zr=1.5,qr=2,Yr=1500;function Et(n,e){return new Promise(t=>{if(e.aborted){t(-1);return}let i=0,r=()=>{n.cancelAnimationFrame?.(i),t(-1)};e.addEventListener("abort",r,{once:!0}),i=n.requestAnimationFrame(o=>{e.removeEventListener("abort",r),t(o)})})}function Kr(n,e){let t=n.defaultView;return t?(async()=>{let i=await Et(t,e);if(e.aborted)return;let r=await Et(t,e),o=r-i,a=0;for(;!e.aborted&&a<qr;){if(r-i>=Yr)return;let s=await Et(t,e);if(e.aborted)return;let u=s-r;o=Math.min(o,u),a=u<jr||u<=o*zr?a+1:0,r=s}})():null}var Xr=8e3;function Zr(n,e,t={}){let i=t.inputs??[(d,m)=>Wr(d,m,{scope:t.scope}),Gr,Kr],r=new AbortController,o=i.map(d=>d(n,r.signal)).filter(d=>d!==null);if(o.length===0){e({timedOut:!1});return}let a=t.timeoutMs??Xr,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 Xn(n,e,t={}){Zr(n,e,{...t,scope:Q})}function St(n,e,t){for(let i of e){let r=n.getAttribute(i);if(r===null||r.trim()==="")continue;let o=Number(r);if(Number.isFinite(o))return o}return t}function Tt(n){return{start:St(n,["data-start"],0),duration:St(n,["data-duration"],0),mediaStart:ke(e=>n.getAttribute(e)),playbackRate:St(n,["data-playback-rate"],1)}}var Jr=.004,Qr=1.5,je=class{_entries=[];_mediaObserver;_playbackErrorPosted=!1;_audioOwner="runtime";_urlAudioEntry=null;_urlAudioSrc=null;_dispatchEvent;_getMuted;_getVolume;_getPlaybackRate;_getCurrentTime;_isPaused;constructor(e){this._dispatchEvent=e.dispatchEvent,this._getMuted=e.getMuted,this._getVolume=e.getVolume,this._getPlaybackRate=e.getPlaybackRate,this._getCurrentTime=e.getCurrentTime,this._isPaused=e.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;let e=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll();for(let t of this._entries)t!==this._urlAudioEntry&&(t.el.src="");this._entries=this._urlAudioEntry?[this._urlAudioEntry]:[],this._urlAudioSrc&&!this._urlAudioEntry&&(this._urlAudioEntry=this._createEntry(this._urlAudioSrc,"audio",0,1/0)),this.teardownObserver(),e&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(let e of this._entries)e.el.pause(),e.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(e){for(let t of this._entries)t.el.muted=e}updateVolume(e){for(let t of this._entries)t.el.volume=e}updatePlaybackRate(e){for(let t of this._entries)t.el.playbackRate=e}_playEntry(e){e.el.src&&e.el.play().catch(t=>this._reportPlaybackError(t))}_playEntryIfActive(e){this._refreshEntryBounds(e),this._inWindow(e,this._getCurrentTime())&&this._playEntry(e)}_refreshEntryBounds(e){if(!e.source?.isConnected)return;let t=lt(e.source);e.start=t.start??0,e.mediaStart=Tt(e.source).mediaStart,e.duration=t.duration!=null&&t.duration>0?t.duration:Number.POSITIVE_INFINITY}_inWindow(e,t){return We(t,e.start,e.start+e.duration)}_preseekUpcoming(e,t){let i=e.start-t;i<=0||i>Qr||!e.el.paused||Math.abs(e.el.currentTime-e.mediaStart)>.04&&this._seekTo(e,e.mediaStart)}_seekTo(e,t,i=!1){let r=i?(e.seekLatency??0)*this._getPlaybackRate():0;e.seekIssuedAt=i?performance.now():void 0,e.el.currentTime=J(t+r)}_noteSeekLanded(e){if(e.seekIssuedAt===void 0)return;let t=(performance.now()-e.seekIssuedAt)/1e3;e.seekLatency=e.seekLatency===void 0?t:(e.seekLatency+t)/2,e.seekIssuedAt=void 0}_releaseSteering(e){vt(e.el),e.lastOffset=void 0;let t=this._getPlaybackRate();e.el.playbackRate!==t&&(e.el.playbackRate=t)}_mediaTime(e,t){return t-e.start+e.mediaStart}_gateEntryPlayback(e,t){return this._inWindow(e,t)?(this._audioOwner==="parent"&&!this._isPaused()&&e.el.paused&&this._playEntry(e),!0):(e.el.paused||e.el.pause(),this._releaseSteering(e),!1)}playAll(){for(let e of this._entries)this._playEntryIfActive(e)}pauseAll(){for(let e of this._entries)e.el.pause()}stopAdoptedMedia(){for(let e of this._entries)e.source&&e.el.pause()}seekAll(e){for(let t of this._entries)this._refreshEntryBounds(t),this._inWindow(t,e)&&this._jumpTo(t,this._mediaTime(t,e))}scrubAll(e){for(let t of this._entries)this._refreshEntryBounds(t),this._inWindow(t,e)?(this._jumpTo(t,this._mediaTime(t,e)),this._playEntry(t)):t.el.paused||t.el.pause()}mirrorTime(e,t){let i=t?.force===!0;for(let r of this._entries){this._refreshEntryBounds(r),this._preseekUpcoming(r,e);let o=r.el.paused;if(!this._gateEntryPlayback(r,e))continue;let a=this._mediaTime(r,e),s=a-r.el.currentTime;if(i||o){Math.abs(s)>.04&&this._jumpTo(r,a);continue}this._steer(r,a,s)}}_steer(e,t,i){let r=e.lastOffset!==void 0&&Math.abs(i-e.lastOffset)<Jr;e.lastOffset=i;let{rate:o,seek:a}=yt(e.el,i,this._getPlaybackRate(),r,!0);a?this._jumpTo(e,t,!0):Math.abs(e.el.playbackRate-o)>1e-6&&(e.el.playbackRate=o)}_jumpTo(e,t,i=!1){this._seekTo(e,t,i),this._releaseSteering(e)}promoteToParentProxy(e,t){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",e)for(let r of e.querySelectorAll("video, audio"))w(r)&&(r.muted=!0);for(let r of[...this._entries])this._repointToSource(r);let i=this._getCurrentTime();t?t(i,{force:!0}):this.mirrorTime(i,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(e){let t=e.querySelectorAll("audio[data-start], video[data-start]");for(let i of t)w(i)&&this._adoptIframeMedia(i);this._observeDynamicMedia(e)}setupFromUrl(e){if(this._urlAudioSrc===e&&this._urlAudioEntry)return;this.teardownUrlAudio();let t=this._createEntry(e,"audio",0,1/0);this._urlAudioEntry=t,this._urlAudioSrc=e,t&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){let e=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!e)return;e.el.pause(),e.el.src="";let t=this._entries.indexOf(e);t!==-1&&this._entries.splice(t,1)}teardownObserver(){this._mediaObserver?.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(e){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:e}})))}_createEntry(e,t,i,r,o){if(!o&&this._urlTaken(e))return null;let a=t==="video"?document.createElement("video"):new Audio;a.preload="auto";let s=o?.getAttribute("crossorigin");s!=null&&a.setAttribute("crossorigin",s),a.src=e,a.load(),a.muted=this._getMuted(),a.volume=this._getVolume();let u=this._getPlaybackRate();u!==1&&(a.playbackRate=u);let d={el:a,start:i,duration:r,mediaStart:o?Tt(o).mediaStart:0,source:o};return a.addEventListener("seeked",()=>this._noteSeekLanded(d)),this._entries.push(d),d}_resolveIframeMediaSrc(e){let t=e.getAttribute("src")||e.querySelector("source")?.getAttribute("src");return t?new URL(t,e.ownerDocument.baseURI).href:null}_adoptIframeMedia(e){if(e.preload==="metadata"||e.preload==="none"||this._entries.some(u=>u.source===e)||e.tagName==="VIDEO"&&e.hasAttribute("muted"))return;let t=this._resolveIframeMediaSrc(e);if(!t)return;let i=lt(e),r=i.start??0,o=i.duration??Number.POSITIVE_INFINITY,a=e.tagName==="VIDEO"?"video":"audio",s=this._createEntry(t,a,r,o,e);s&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(s))}_followIframeMediaSrc(e){let t=this._entries.find(i=>i.source===e);if(!t)return this._adoptIframeMedia(e);this._audioOwner!=="parent"||!this._repointToSource(t)||(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(t))}_urlTaken(e){return this._entries.some(t=>t.source&&!t.source.isConnected?!1:(t.source&&this._resolveIframeMediaSrc(t.source)||t.el.src)===e)}_repointToSource(e){let t=e.source?this._resolveIframeMediaSrc(e.source):null;return!t||e.el.src===t?!1:(e.el.src=t,e.el.load(),!0)}_detachIframeMedia(e){let t=this._entries.find(i=>i.source===e);t&&this._removeEntry(t)}_removeEntry(e){e.el.pause(),e.el.src="",this._entries.splice(this._entries.indexOf(e),1)}_observeDynamicMedia(e){if(this.teardownObserver(),typeof MutationObserver>"u"||!e.body)return;let t=new MutationObserver(o=>{for(let a of o){if(a.type==="attributes"&&a.attributeName==="src"){let s=a.target;w(s)&&s.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(s);continue}if(a.type==="attributes"&&a.attributeName==="preload"){let s=a.target;w(s)&&s.matches("audio[data-start], video[data-start]")&&(s.preload==="auto"?this._adoptIframeMedia(s):this._detachIframeMedia(s));continue}for(let s of a.addedNodes){if(!ge(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(!ge(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=Vn(e);for(let o of r)t.observe(o,i);this._mediaObserver=t}};function Rt(n,e,t){if(n===null&&e===null)return{range:null,clamped:!1};let i=n??0,r=e!==null&&t>0&&e>t,o=r?t:e,a=o??(t>0?t:1/0);return!(i>=0)||!(a>i)?{range:null,clamped:!0}:{range:{start:i,end:o},clamped:r}}function _e(n,e,t){let i=n.end??e;return i<e?jn(n.start,i,t):i}function xt(n,e,t,i){return n<e.start||n>=_e(e,t,i)}var eo=100;function to(n,e){return typeof n.currentTime=="number"&&Number.isFinite(n.currentTime)?n.currentTime:(n.frame??0)/e}function Zn(n,e,t){return t<=0?!1:n.ended===!0?!0:n.ended===!1&&!n.isPlaying?!1:e>=t}function no(n,e,t,i,r,o){let{duration:a}=t;if(!r){let s=Zn(n,e,a);return{start:0,shownAtEnd:a,atEnd:s,stopRuntime:!1,entering:!1}}if(n.ownsRange){let s=i&&n.ended===!0&&!n.isPlaying;return{start:r.start,shownAtEnd:e,atEnd:s,stopRuntime:!1,entering:!1}}return io(n,e,t,i,r,o)}function io(n,e,t,i,r,o){let a=r.end??t.duration,s=t.enteringRange===!0&&(e<r.start||e>=a);return{start:r.start,shownAtEnd:_e(r,t.duration,o),atEnd:i&&!s&&Zn(n,e,a),stopRuntime:n.isPlaying,entering:s}}function Jn(n,e,t,i){let r=to(n,e),o=!t.paused,a=o||n.isPlaying,s=i.getPlayRange?.(),u=no(n,r,t,a,s,e),{atEnd:d,start:m}=u,h=t.duration>0?Math.min(r,t.duration):r,v=d?u.shownAtEnd:h,b=!n.isPlaying,A=d&&a;if(A&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(m),i.play(),{...t,currentTime:m,paused:!1,enteringRange:!0};let _={...t,currentTime:v,paused:b,enteringRange:u.entering};i.media.audioOwner==="parent"&&(o&&b?i.media.pauseAll():!o&&!b&&i.media.playAll(),i.media.mirrorTime(v));let E=performance.now(),C=b!==t.paused;return(E-t.lastUpdateMs>eo||C)&&(_.lastUpdateMs=E,i.updateControlsTime(v,t.duration),i.updateControlsPlaying(!b),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:v}}))),A&&(u.stopRuntime&&i.seek(v),i.media.audioOwner==="parent"&&i.media.pauseAll(),_.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),_}function ro(n){return Array.isArray(n)?n.filter(e=>typeof e=="object"&&e!==null&&typeof e.id=="string"&&typeof e.start=="number"&&typeof e.duration=="number"):[]}function Qn(n,e,t){if(n.source!==e)return;let i=n.data;if(!i||i.source!=="hf-preview")return;let r=qn(i);if(r.status==="unsupported"){t.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:r.code,receivedVersion:r.receivedVersion}}));return}t.setRuntimeFps?.(r.fps);let o=r.status==="supported"&&r.metadata.capabilities.includes("play-range");if(t.setRuntimeOwnsPlayRange?.(o),i.type==="shader-transition-state"){let a=i.state&&typeof i.state=="object"?i.state:{};t.shaderLoader.update(a,t.getShaderLoadingMode()),t.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:a}}));return}if(i.type==="ready"){t.onRuntimeReady();return}if(i.type==="assets-ready"){t.onRuntimeAssetsReady?.(i.timedOut===!0);return}if(i.type==="runtime-data-error"){t.onRuntimeDataError?.(i.channel,i.requestId,i.message);return}if(i.type==="runtime-data-applied"){t.onRuntimeDataApplied?.(i.channel,i.requestId);return}if(i.type==="state"){t.setPlaybackState(Jn({frame:i.frame??0,currentTime:i.currentTime,ended:typeof i.ended=="boolean"?i.ended:void 0,isPlaying:!!i.isPlaying,ownsRange:o},r.fps,t.getPlaybackState(),t));return}if(i.type==="media-autoplay-blocked"){if(t.shouldPromoteMediaAutoplayFallback?.()===!1)return;let a=null;try{a=t.getIframeDoc()}catch{}t.media.promoteToParentProxy(a,(s,u)=>t.media.mirrorTime(s,u)),t.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){let a=Number(i.durationSeconds),s=Number(i.durationInFrames),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&&t.setCompositionSize(i.compositionWidth,i.compositionHeight),Number.isFinite(u)&&u>0){let d=t.getPlaybackState();t.setPlaybackState({...d,duration:u}),t.updateControlsTime(d.currentTime,u),t.onRuntimeTimelineReady(u,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}t.setScenes(ro(i.scenes));return}i.type==="stage-size"&&Number.isFinite(i.width)&&i.width>0&&Number.isFinite(i.height)&&i.height>0&&t.setCompositionSize(i.width,i.height)}function oo(n,e){return n.includes(e)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(n)}var ao=new Set([">"," "," ",`
|
|
478
|
-
`,"\r","\f"]);function wt(n,e){let t=n.toLowerCase(),i=`<${e}`,r=0;for(;r<t.length;){let o=t.indexOf(i,r);if(o<0)return null;let a=t[o+i.length];if(ao.has(a)){let s=t.indexOf(">",o+i.length);return s<0?null:{index:o,end:s+1}}r=o+i.length}return null}function ei(n,e){if(!n||oo(n,e))return n;let t=`<script src="${e}"></script>`,i=wt(n,"head");if(i)return n.slice(0,i.end)+t+n.slice(i.end);let r=wt(n,"body");if(r)return n.slice(0,r.index)+t+n.slice(r.index);let o=wt(n,"html");return o?n.slice(0,o.end)+t+n.slice(o.end):t+n}var B="shader-capture-scale",ee="shader-loading",ze="runtime-src",ti="__hf_shader_capture_scale",ni="__hf_shader_loading",te=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function kt(n){if(n===null)return null;let e=Number(n);return!Number.isFinite(e)||e<=0?null:String(Math.min(1,Math.max(.25,e)))}function so(n){if(n===null||n.trim()==="")return"composition";let e=n.trim().toLowerCase();return e==="none"||e==="false"||e==="0"||e==="off"?"none":e==="player"||e==="true"||e==="1"||e==="on"?"player":"composition"}function ii(n,e){return n.filter(t=>t!==""&&t.split("=")[0]!==e)}function uo(n,e,t){let i=n.indexOf("#"),r=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i):"",a=r.indexOf("?"),s=a>=0?r.slice(0,a):r,u=a>=0?r.slice(a+1):"",d=ii(u.split("&"),ti);d=ii(d,ni),e!==null&&d.push(`${ti}=${encodeURIComponent(e)}`),t!=="composition"&&d.push(`${ni}=${encodeURIComponent(t)}`);let m=d.join("&");return`${s}${m?`?${m}`:""}${o}`}function lo(n,e,t){if(e===null&&t==="composition")return n;let i=[];e!==null&&i.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(e)};`),t!=="composition"&&i.push(`window.__HF_SHADER_LOADING=${JSON.stringify(t)};`);let r=`<script data-hyperframes-player-shader-options>${i.join("")}</script>`;return/<head\b[^>]*>/i.test(n)?n.replace(/<head\b[^>]*>/i,o=>`${o}${r}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b[^>]*>/i,o=>`${o}${r}`):`${r}${n}`}function ye(n){return so(n.getAttribute(ee))}function ri(n){return Number(kt(n.getAttribute(B))??"1")}function oi(n,e){return uo(e,kt(n.getAttribute(B)),ye(n))}function ve(n,e){return ei(lo(e,kt(n.getAttribute(B)),ye(n)),Mt(n))}function Mt(n){let e=n.getAttribute(ze)?.trim();if(!e)return Z;try{let t=new URL(e,document.baseURI),i=t.protocol==="http:"||t.protocol==="https:",r=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]";return i&&(r||t.origin===location.origin)?t.href:Z}catch{return Z}}function ai(){let n=document.createElement("div");n.className="hfp-shader-loader",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-label","Preparing scene transitions"),n.setAttribute("data-hyperframes-ignore",""),n.draggable=!1;let e=b=>{b.preventDefault(),b.stopPropagation()};for(let b of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])n.addEventListener(b,e,{capture:!0});let t=document.createElement("div");t.className="hfp-shader-loader-panel",t.draggable=!1;let i=document.createElement("div");i.className="hfp-shader-loader-mark",i.draggable=!1,i.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");let r=document.createElement("div");r.className="hfp-shader-loader-title";let o=document.createElement("span");o.className="hfp-shader-loader-title-text",o.textContent=te[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=b=>{let A=document.createElement("div");A.className="hfp-shader-loader-row";let _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=b;let E=document.createElement("span");return E.className="hfp-shader-loader-value",A.appendChild(_),A.appendChild(E),d.appendChild(A),{row:A,label:_,value:E}},h=m("transition"),v=m("transition frame");return t.appendChild(i),t.appendChild(r),t.appendChild(a),t.appendChild(s),t.appendChild(d),n.appendChild(t),{root:n,fill:u,title:o,detail:a,transitionValue:h.value,transitionRow:h.row,frameLabel:v.label,frameValue:v.value,frameRow:v.row}}var co=420;function qe(n,e,t){e.textContent=t,n.style.visibility=t?"visible":"hidden"}var Ye=class{_el;_hideTimeout=null;_hiddenCallbacks=[];_drawingAssets=!1;constructor(e){this._el=e}show(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-hiding"),this._el.root.classList.add("hfp-visible")}hide(){if(this._el.root.classList.contains("hfp-hiding")){this._hideTimeout||this._scheduleCleanup();return}this._el.root.classList.contains("hfp-visible")&&(this._el.root.classList.add("hfp-hiding"),this._el.root.classList.remove("hfp-visible"),this._scheduleCleanup())}whenHidden(e){let t=this._el.root.classList;t.contains("hfp-visible")||t.contains("hfp-hiding")?this._hiddenCallbacks.push(e):e()}_flushHidden(){let e=this._hiddenCallbacks;this._hiddenCallbacks=[];for(let t of e)t()}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._drawingAssets=!1,this._flushHidden(),this._el.fill.style.transform="scaleX(0)",qe(this._el.transitionRow,this._el.transitionValue,""),qe(this._el.frameRow,this._el.frameValue,"")}update(e,t){let i=t==="player"&&e.loading&&!e.ready;if(this._drawingAssets&&!i)return;if(t!=="player"){this.reset();return}if(e.ready||!e.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions"),this._drawingAssets=!1;let r=typeof e.progress=="number"&&Number.isFinite(e.progress)?e.progress:0,o=typeof e.total=="number"&&Number.isFinite(e.total)?e.total:0,a=o>0?Math.min(1,Math.max(0,r/o)):0,s=Math.min(te.length-1,Math.floor(a*te.length));this._el.title.textContent=te[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",qe(this._el.transitionRow,this._el.transitionValue,u),qe(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()},co)}};function si(n){return n?.trim().toLowerCase().startsWith("video/")??!1}function ui(n){let e=document.createElement("video");e.className="hfp-video",e.playsInline=!0,e.preload="metadata";let t=new AbortController,{signal:i}=t;return e.addEventListener("loadedmetadata",()=>n.onMetadata(e),{signal:i}),e.addEventListener("durationchange",()=>n.onDurationChange(e),{signal:i}),e.addEventListener("resize",()=>n.onResize(e),{signal:i}),e.addEventListener("play",()=>n.onPlay(e),{signal:i}),e.addEventListener("pause",()=>n.onPause(e),{signal:i}),e.addEventListener("timeupdate",()=>n.onTimeUpdate(),{signal:i}),e.addEventListener("error",()=>n.onError(e.error?.message||"Video failed to load",e.error?.code??null),{signal:i}),{video:e,adapter:{duration:()=>e.duration,time:()=>e.currentTime,seek:o=>{e.currentTime=J(o)},play:()=>e.play().catch(o=>{i.aborted||n.onPlayRejected(o)}),pause:()=>e.pause(),timeScale:o=>{e.defaultPlaybackRate=o,e.playbackRate=o}},destroy:()=>{t.abort(),e.pause(),e.removeAttribute("src"),e.load(),e.remove()}}}var mo=.1,po=5,It="sandbox-origin",li=1e4,Ct=8e3,Dt="assets-loading",Ae="assets-loading-ui",Nt="low-power-idle",di="disable-click-to-play",Ee="range-start",Se="range-end",fo=150;function Pt(n){return!Number.isFinite(n)||n<=0?1:Math.max(mo,Math.min(po,n))}var Ke=class extends HTMLElement{static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src","type",It,ze,B,ee,Ae,Nt,Ee,Se]}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"}),On(this.shadow,Mn),{container:this.container,iframe:this.iframe}=Fn(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);let e=ai();this.shadow.appendChild(e.root),this.shaderLoader=new Ye(e),this._media=new je({dispatchEvent:t=>this._emit(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new $e({onTimeUpdate:(t,i)=>{this._currentTime=t,this.controlsApi?.updateTime(t,i),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:t}}))},getLoop:()=>this.loop,restart:()=>{this.seek(this._playRange()?.start??0),this.play()},onPaused:()=>{this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this._emit(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new Ue(this.iframe,{resolveRuntimeUrl:()=>Mt(this),hostOwnsDeadline:()=>this.hasAttribute("no-load-timeout"),onReady:t=>this._onProbeReady(t),onError:t=>this._emit(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{this.disableClickToPlay||Ln(t)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this),this.iframe.addEventListener("load",this._onIframeLoad)}connectedCallback(){this._connected=!0,this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=gt(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=ve(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){this._connected=!1,this._teardownVideo(),this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),this.controlsApi?.destroy(),this.controlsApi=null,this._paused=!0,this._pendingPlay=!1,this._abandonComposition("Player disconnected before runtime data was applied")}attributeChangedCallback(e,t,i){switch(e){case"src":if(!this.isConnected)break;i&&this._navigateSrc(i);break;case"type":{let r=this.getAttribute("src");if(!this.isConnected||r===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(r);break}case"srcdoc":if(!this.isConnected)break;if(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),i!==null)this._pauseForVideoSwitch(),this._teardownVideo(),this.iframe.srcdoc=ve(this,i);else{this.iframe.removeAttribute("srcdoc");let r=this.getAttribute("src");r!==null&&this._wantsVideo()&&this._navigateSrc(r)}break;case It:this._applySandboxOriginPolicy(this.isConnected&&t!==i);break;case"width":this._setCompositionSize(fe(i)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,fe(i)??1080);break;case"controls":i!==null?this._setupControls():(this.controlsApi?.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=gt(this.shadow,i,this.posterEl);break;case"playback-rate":{let r=Pt(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 Ae:i==="none"&&this.shaderLoader.hideAssetsLoading();break;case Nt:this._sendControl("set-idle-heartbeat",{slow:i!==null});break;case Ee:case Se:this._applyPlayRange(!0);break;case B:case ee:case ze:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(It)?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=ve(this,e);return}let t=this.getAttribute("src");t===null?this.iframe.src="about:blank":this._loadSrc(t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){this._play(!0)}_play(e){if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,this.posterEl?.remove(),this.posterEl=null;let t=this._ready?this._playRange():null;t?xt(this._currentTime,t,this._duration,this._runtimeFps)&&(this.seek(t.start),this._enteringRange=!0):this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;let i=this._tryDirectTimelinePlay(),r=!1;this._sendDisplayScale(),i||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,r=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),this.controlsApi?.updatePlaying(!0),!r&&e&&this._emit(new Event("play")),i&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused,()=>this._clockStop())}pause(){this._pendingPlay=!1,this._tryDirectTimelinePause()?this._showPausedVideoTime():this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this._emit(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){this._pendingPlay=!1,!this._trySyncSeek(e)&&!this._tryDirectTimelineSeek(e)&&this._sendControl("seek",{timeSeconds:e,frame:Math.round(e*this._runtimeFps)}),this._directTimelineClock.stop(),this._stopParentTickClock(),this._currentTime=e,this._media.audioOwner==="parent"&&(this._scrubbing?this._media.scrubAll(e):(this._media.pauseAll(),this._media.seekAll(e))),this._paused=!0,this.controlsApi?.updatePlaying(!1),this.controlsApi?.updateTime(this._currentTime,this._duration)}setColorGrading(e,t){this._sendControl("set-color-grading",{target:e,grading:t})}clearColorGrading(e){this._sendControl("set-color-grading",{target:e,grading:null})}setColorGradingCompare(e,t){this._sendControl("set-color-grading-compare",{target:e,compare:t})}clearColorGradingCompare(e){this._sendControl("set-color-grading-compare",{target:e,compare:{enabled:!1}})}setRuntimeData(e,t){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);if(typeof structuredClone!="function")throw new Error("HyperFrames runtime data requires structuredClone support; refusing an unverified payload");let i=structuredClone(t);this._runtimeData.set(e,i),this._deliverRuntimeData(e,i)}clearRuntimeData(e){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);this._runtimeData.delete(e),this._deliverRuntimeDataClear(e)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get compositionWidth(){return this._compositionWidth}get compositionHeight(){return this._compositionHeight}get paused(){return this._paused}get ready(){return this._ready}get assetsReady(){return this._assetsReady}get painted(){return this._painted}get playbackRate(){return Pt(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(Pt(e)))}get shaderCaptureScale(){return ri(this)}set shaderCaptureScale(e){this.setAttribute(B,String(e))}get shaderLoading(){return ye(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(ee):this.setAttribute(ee,e)}get assetsLoadingUi(){return this.getAttribute(Ae)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(Ae,"none"):this.removeAttribute(Ae)}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(di)}set disableClickToPlay(e){this.toggleAttribute(di,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(Ee)}set rangeStart(e){this._writeSeconds(Ee,e)}get rangeEnd(){return this._readSeconds(Se)}set rangeEnd(e){this._writeSeconds(Se,e)}_readSeconds(e){let t=this.getAttribute(e);return t===null?null:Number(t)}_writeSeconds(e,t){t==null?this.removeAttribute(e):this.setAttribute(e,String(t))}_hasPlayRange(){return this.hasAttribute(Ee)||this.hasAttribute(Se)}_playRange(){return Rt(this.rangeStart,this.rangeEnd,this._duration).range}_sendPlayRange(e){let t=e?.end??null;this._sendControl("set-play-range",{startSeconds:e?.start??null,endSeconds:t})}_applyPlayRange(e){let{range:t,clamped:i}=Rt(this.rangeStart,this.rangeEnd,this._duration);this._sendPlayRange(t),this._ready&&(this._reportRangeClamp(t,i),t&&e&&!this._pendingPlay&&this._moveIntoPlayRange(t))}_reportRangeClamp(e,t){let i=t?`${this.rangeStart},${this.rangeEnd},${this._duration}`:"";if(i===this._rangeClampReported||(this._rangeClampReported=i,!t))return;let r={rangeStart:e?.start??null,rangeEnd:e?.end??null};this._emit(new CustomEvent("rangeclamped",{detail:{...r,duration:this._duration}}))}_moveIntoPlayRange(e){xt(this._currentTime,e,this._duration,this._runtimeFps)&&(this._paused?this.seek(e.start):this._jumpWhilePlaying(e.start))}_jumpWhilePlaying(e){this._directTimelineAdapter?(this._directTimelineAdapter.seek(e,!1),this._currentTime=e):this._runtimeOwnsPlayRange||(this.seek(e),this._enteringRange=!0,this._play(!1))}_clockStop(){let e=this._playRange(),t=e?.end??this._duration;if(!e)return{end:t,shown:t};let i=_e(e,this._duration,this._runtimeFps);return{end:t,shown:i<t?(i+t)/2:i}}_sendControl(e,t={}){try{let i=this.iframe.contentWindow;return i?(i.postMessage({...t,source:"hf-parent",type:"control",action:e,...At(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,"Composition iframe is unavailable"),!1)}catch(i){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,i instanceof Error?i.message:String(i)),!1}}_deliverRuntimeData(e,t){if(!this.isConnected||!this._runtimeBridgeReady)return;let i=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,t,i)||this._sendControl("set-runtime-data",{channel:e,payload:t,requestId:i})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;let t=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,t)||this._sendControl("clear-runtime-data",{channel:e,requestId:t})}_trySetRuntimeDataDirect(e,t,i){try{let r=this.iframe.contentWindow?.__hyperframes;return typeof r?.setRuntimeData!="function"?!1:(r.setRuntimeData(e,t,i),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,t){try{let i=this.iframe.contentWindow?.__hyperframes;return typeof i?.clearRuntimeData!="function"?!1:(i.clearRuntimeData(e,t),!0)}catch{return!1}}_replayRuntimeData(){for(let[e,t]of this._runtimeData)this._deliverRuntimeData(e,t)}_beginRuntimeDataDelivery(e){let t=this._pendingRuntimeData.get(e);t&&window.clearTimeout(t.timeoutId),this._runtimeDataRequestId+=1;let i=this._runtimeDataRequestId,r=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,i,`Runtime data delivery timed out after ${li}ms`)},li);return this._pendingRuntimeData.set(e,{requestId:i,timeoutId:r}),i}_resolveRuntimeDataDelivery(e,t){let i=this._takeRuntimeDataDelivery(e,t);i&&this._emit(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:i.requestId}}))}_rejectRuntimeDataDelivery(e,t,i){let r=this._takeRuntimeDataDelivery(e,t);r&&this._emit(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:r.requestId,message:typeof i=="string"?i:String(i)}}))}_takeRuntimeDataDelivery(e,t){if(typeof e!="string"||typeof t!="number"||!Number.isSafeInteger(t))return null;let i=this._pendingRuntimeData.get(e);return!i||i.requestId!==t?null:(window.clearTimeout(i.timeoutId),this._pendingRuntimeData.delete(e),i)}_rejectAllRuntimeDataDeliveries(e){for(let[t,i]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(t,i.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){let t=this._getSameOriginIframeDocument();if(t)for(let i of t.querySelectorAll("video, audio"))w(i)&&(i.muted=e||i.defaultMuted)}_stopIframeMedia(){let e=this._getSameOriginIframeDocument();if(e)for(let t of e.querySelectorAll("video, audio"))w(t)&&t.pause()}_replayBridgeState(){this._sendControl("set-muted",{muted:this.muted}),this._sendControl("set-volume",{volume:this._volume}),this._sendControl("set-playback-rate",{playbackRate:this.playbackRate}),this._sendControl("set-native-media-sync-disabled",{disabled:this._isSlideshowPlayer()}),this._sendControl("set-web-audio-media-disabled",{disabled:this._isSlideshowPlayer()}),this._sendControl("set-idle-heartbeat",{slow:this.hasAttribute(Nt)}),this._sendDisplayScale()}_sendDisplayScale(){let e=zn(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=ve(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 si(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=oi(this,e)}_loadVideo(e){this._videoSource||(this._videoSource=ui({onMetadata:r=>this._applyThenEmit(()=>this._onVideoReady(r)),onDurationChange:r=>this._applyTimelineDuration(r.duration),onResize:r=>this._applyVideoSize(r),onPlay:r=>{!r.paused&&this._paused&&this.play()},onPause:r=>{r.paused&&!r.ended&&!this._paused&&this.pause()},onTimeUpdate:()=>{document.hidden&&this._playRange()&&this._directTimelineClock.poll()},onError:(r,o)=>{this._paused||this.pause(),this._emit(new CustomEvent("error",{detail:{message:r,code:o}}))},onPlayRejected:r=>this._onVideoPlayRejected(r)}),this.container.appendChild(this._videoSource.video),this.iframe.hidden=!0,this.iframe.src="about:blank"),this.probe.stop();let{video:t,adapter:i}=this._videoSource;this._directTimelineAdapter=i,this._currentTime=0,this._duration=0,this.controlsApi?.updateTime(0,0),this._syncVideoAudio(),i.timeScale?.(this.playbackRate),t.src=e}_teardownVideo(){this._videoSource&&(this._videoSource.destroy(),this._videoSource=null,this.iframe.hidden=!1)}_syncVideoAudio(){this._videoSource&&(this._videoSource.video.muted=this.muted,this._videoSource.video.volume=this._volume)}_onVideoReady(e){this._applyTimelineDuration(e.duration),this._applyVideoSize(e),this._ready=!0,this._dispatchReady(),this._waitForAssetsReady(null),this._afterEvents(()=>{this.hasAttribute("autoplay")&&this._paused&&this.play()})}_applyTimelineDuration(e){!Number.isFinite(e)||e<=0||(this._setDuration(e),this.controlsApi?.updateTime(this._currentTime,e))}_applyVideoSize(e){e.videoWidth>0&&e.videoHeight>0&&this._setCompositionSize(e.videoWidth,e.videoHeight)}_onVideoPlayRejected(e){e instanceof DOMException&&e.name==="NotAllowedError"&&(this._paused||this.pause(),this._emit(new CustomEvent("playbackerror",{detail:{source:"video",error:e}})))}_trySyncSeek(e){if(this._videoSource)return!1;try{let i=this.iframe.contentWindow?.__player;return typeof i?.seek!="function"?!1:(i.seek.call(i,e),!0)}catch{return!1}}_withDirectTimeline(e){let t=this._videoSource?null:this.probe.resolveDirectTimelineAdapter(),i=t||this._directTimelineAdapter;if(!i)return!1;try{return e(i),t&&t!==this._directTimelineAdapter&&this._applyTimelineDuration(t.duration()),this._directTimelineAdapter=i,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(t=>{t.seek(e,!1),t.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>{e.play()})}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>{e.pause()})}_showPausedVideoTime(){this._videoSource&&(this._currentTime=this._videoSource.video.currentTime,this.controlsApi?.updateTime(this._currentTime,this._duration),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}})))}_startParentTickClock(){this._stopParentTickClock();let e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){this._videoSource||this.probe.failed||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){Qn(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs,enteringRange:this._enteringRange}),setPlaybackState:({currentTime:t,duration:i,paused:r,lastUpdateMs:o,enteringRange:a})=>{this._enteringRange=a===!0,this._currentTime=t,this._setDuration(i),this._paused=r,this._lastUpdateMs=o},getShaderLoadingMode:()=>ye(this),shaderLoader:this.shaderLoader,setCompositionSize:(t,i)=>this._setCompositionSize(t,i),sendControl:(t,i)=>this._sendControl(t,i),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._hasPlayRange()&&this._sendPlayRange(this._playRange()),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(t,i)=>this._resolveRuntimeDataDelivery(t,i),onRuntimeDataError:(t,i,r)=>this._rejectRuntimeDataDelivery(t,i,r),onRuntimeTimelineReady:(t,i)=>this._onRuntimeTimelineReady(t,i),setRuntimeFps:t=>{this._runtimeFps=t},setRuntimeOwnsPlayRange:t=>{this._runtimeOwnsPlayRange=t},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:t=>{this._scenes=t,this._emit(new CustomEvent("scenes",{detail:{scenes:t}}))},updateControlsTime:(t,i)=>this.controlsApi?.updateTime(t,i),updateControlsPlaying:t=>this.controlsApi?.updatePlaying(t),dispatchEvent:t=>this._emit(t),seek:t=>this.seek(t),play:()=>this.play(),getLoop:()=>this.loop,getPlayRange:()=>this._playRange(),media:this._media})}_onRuntimeTimelineReady(e,t){if(this._ready)return;this.probe.stop(),this._setDuration(e),this._directTimelineAdapter=null,this._ready=!0,this.controlsApi?.updateTime(this._currentTime,e),this._dispatchReady();let i=this._getSameOriginIframeDocument();i&&this._media.setupFromIframe(i),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(i,t),this._playWhenWanted()}_onProbeReady(e){this._applyThenEmit(()=>this._applyProbeResult(e))}_applyProbeResult({duration:e,adapter:t,compositionSize:i}){this._setDuration(e),this._directTimelineAdapter=t.kind==="direct-timeline"?t.timeline:null,i&&this._setCompositionSize(i.width,i.height),this._ready=!0,this.controlsApi?.updateTime(0,e),this._dispatchReady();let r=this._getSameOriginIframeDocument();r&&this._media.setupFromIframe(r),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(r),this._playWhenWanted()}_waitForAssetsReady(e,t){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1;let i=++this._assetsGeneration;if(!e){t===!1?(this._runtimeAssetsReadyGeneration=i,this._startAssetsLoadingOverlayTimer(i),setTimeout(()=>this._settleAssetsReady(i),Ct)):this._settleAssetsReady(i);return}Xn(e,({timedOut:r})=>{i===this._assetsGeneration&&(r&&this._warnStuckAssets(e),this._settleAssetsReady(i))},{timeoutMs:Ct}),this._assetsReady||this._startAssetsLoadingOverlayTimer(i)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(Dt,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},fo)}_hasPendingFirstFrameAssets(e){let{pendingMedia:t,pendingImages:i,fontsLoading:r}=Ge(e,{scope:Q});return t.length>0||i.length>0||r}_warnStuckAssets(e){let{pendingMedia:t,pendingImages:i,fontsLoading:r}=Ge(e,{scope:Q}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${Ct}ms, playing anyway`,{stuckMedia:t.map(a=>a.currentSrc||a.getAttribute("src")||`<${a.tagName.toLowerCase()}>`),stuckImages:i.map(a=>a.currentSrc||a.getAttribute("src")||"<img>"),fontsLoading:r,computeReady:o?.__renderReady===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(Dt),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(Dt),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_dispatchReady(){this._readyDocument=this._getSameOriginIframeDocument();let e={duration:this._duration,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight};this._emit(new CustomEvent("ready",{detail:e})),this._rescale(),this._rangeClampReported="",this._hasPlayRange()&&this._applyPlayRange(!0)}_setDuration(e){e!==this._duration&&(this._duration=e,this._ready&&(this._emit(new CustomEvent("durationchange",{detail:{duration:e}})),this._hasPlayRange()&&this._applyPlayRange(!1)))}_setCompositionSize(e,t){let i=e!==this._compositionWidth||t!==this._compositionHeight;if(this._compositionWidth=e,this._compositionHeight=t,this.sizer.style.aspectRatio=`${e} / ${t}`,this._rescale(),!i)return;let r={compositionWidth:e,compositionHeight:t};this._emit(new CustomEvent("resize",{detail:r}))}_applyThenEmit(e){if(this._afterUpdate){e();return}let t=[];this._afterUpdate=t;let i=[],r=o=>{try{o()}catch(a){i.push(a)}};r(e);for(let o of t)r(o);if(this._afterUpdate=null,i.length>0)throw i[0]}_afterEvents(e){this._afterUpdate?this._afterUpdate.push(e):e()}_playWhenWanted(){this._afterEvents(()=>{(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()})}_emit(e){this._afterEvents(()=>this.dispatchEvent(e))}_rescale(){let e=Un(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=Pn(this.shadow,this.muted,this._volume,this.getAttribute("speed-presets"),{onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:e=>this.seek(e*this._duration),onScrubStart:()=>{this._scrubbing=!0},onScrubEnd:()=>{this._scrubbing=!1,this.seek(this._currentTime)},onSpeedChange:e=>{this.playbackRate=e},onMuteToggle:()=>{this.muted=!this.muted},onVolumeChange:e=>{this.volume=e}},this._isAudioLocked()),this.controlsApi.updateTime(this._currentTime,this._duration),this.controlsApi.updatePlaying(!this._paused),this.controlsApi.updateSpeed(this.playbackRate))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,t){this._media.mirrorTime(e,t)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(t,i)=>this._mirrorParentMediaTime(t,i)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}};customElements.get("hyperframes-player")||customElements.define("hyperframes-player",Ke);0&&(module.exports={HyperframesPlayer,SPEED_PRESETS,formatSpeed,formatTime});
|
|
477
|
+
`,vn='<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>',Sn='<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 lt=[.25,.5,1,1.5,2,4];function W(n){return Number.isInteger(n)?`${n}x`:`${n}x`}function De(n){if(!Number.isFinite(n)||n<0)return"0:00";let e=Math.floor(n),t=Math.floor(e/60),i=e%60;return`${t}:${i.toString().padStart(2,"0")}`}function En(n,e,t={}){let i=t.speedPresets??lt,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">${vn}</span><span class="hfp-ico hfp-ico-pause">${Sn}</span>`,o.setAttribute("aria-label","Play");let a=document.createElement("div");a.className="hfp-scrubber";let s=document.createElement("div");s.className="hfp-progress",s.style.width="0%",a.appendChild(s);let l=document.createElement("span");l.className="hfp-time",l.textContent="0:00 / 0:00";let 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: 1x");let f=document.createElement("div");f.className="hfp-speed-menu",f.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=W(c),c===1&&p.classList.add("hfp-active"),f.appendChild(p)}d.appendChild(f),d.appendChild(m);let v=document.createElement("div");v.className="hfp-volume-wrap";let b=document.createElement("button");b.className="hfp-mute-btn",b.type="button",b.innerHTML=at,b.setAttribute("aria-label","Mute");let S=document.createElement("div");S.className="hfp-volume-slider-wrap";let _=document.createElement("div");_.className="hfp-volume-slider",_.setAttribute("role","slider"),_.setAttribute("aria-label","Volume"),_.setAttribute("aria-valuemin","0"),_.setAttribute("aria-valuemax","100"),_.setAttribute("aria-valuenow","100"),_.tabIndex=0;let A=document.createElement("div");A.className="hfp-volume-fill",A.style.width="100%",_.appendChild(A),S.appendChild(_),v.appendChild(S),v.appendChild(b),t.audioLocked&&(v.style.display="none"),r.appendChild(o),r.appendChild(a),r.appendChild(l),r.appendChild(v),r.appendChild(d),n.appendChild(r);let C=!1,M=!1,I=1,T=null,U=i.indexOf(1);U===-1&&(U=0);let Z=(c,p)=>c?An:p===0?st:p<.5?st:at;o.addEventListener("click",c=>{c.stopPropagation(),C?e.onPause():e.onPlay()}),b.addEventListener("click",c=>{c.stopPropagation(),e.onMuteToggle()});let O=!1,J=c=>{let p=_.getBoundingClientRect(),E=Math.max(0,Math.min(1,(c-p.left)/p.width));I=E,A.style.width=`${E*100}%`,_.setAttribute("aria-valuenow",String(Math.round(E*100))),M&&E>0&&e.onMuteToggle(),b.innerHTML=Z(M,E),e.onVolumeChange(E)};_.addEventListener("mousedown",c=>{c.stopPropagation(),O=!0,J(c.clientX)});let u=c=>{O&&J(c.clientX)},h=()=>{O=!1};document.addEventListener("mousemove",u),document.addEventListener("mouseup",h),_.addEventListener("touchstart",c=>{O=!0;let p=c.touches[0];p&&J(p.clientX)},{passive:!0});let g=c=>{if(O){let p=c.touches[0];p&&J(p.clientX)}},R=()=>{O=!1};document.addEventListener("touchmove",g,{passive:!0}),document.addEventListener("touchend",R);let k=.05;_.addEventListener("keydown",c=>{let p=I;if(c.key==="ArrowRight"||c.key==="ArrowUp")p=Math.min(1,I+k);else if(c.key==="ArrowLeft"||c.key==="ArrowDown")p=Math.max(0,I-k);else return;c.preventDefault(),c.stopPropagation(),I=p,A.style.width=`${p*100}%`,_.setAttribute("aria-valuenow",String(Math.round(p*100))),M&&p>0&&e.onMuteToggle(),b.innerHTML=Z(M,p),e.onVolumeChange(p)});let ye=c=>{for(let p of f.querySelectorAll(".hfp-speed-option"))p.classList.toggle("hfp-active",p.dataset.speed===String(c))};m.addEventListener("click",c=>{c.stopPropagation();let p=f.classList.toggle("hfp-open");m.setAttribute("aria-expanded",String(p))}),f.addEventListener("click",c=>{c.stopPropagation();let p=c.target.closest(".hfp-speed-option");if(!p)return;let E=parseFloat(p.dataset.speed);U=i.indexOf(E),m.textContent=W(E),m.setAttribute("aria-label",`Playback speed: ${W(E)}`),ye(E),f.classList.remove("hfp-open"),m.setAttribute("aria-expanded","false"),e.onSpeedChange(E)});let ve=()=>{f.classList.remove("hfp-open"),m.setAttribute("aria-expanded","false")};document.addEventListener("click",ve);let H=c=>{let p=a.getBoundingClientRect(),E=Math.max(0,Math.min(1,(c-p.left)/p.width));e.onSeek(E)},D=!1;a.addEventListener("mousedown",c=>{c.stopPropagation(),D=!0,e.onScrubStart?.(),H(c.clientX)});let Rt=c=>{D&&H(c.clientX)},xt=()=>{D&&(D=!1,e.onScrubEnd?.())};document.addEventListener("mousemove",Rt),document.addEventListener("mouseup",xt),a.addEventListener("touchstart",c=>{D=!0,e.onScrubStart?.();let p=c.touches[0];p&&H(p.clientX)},{passive:!0});let wt=c=>{if(D){let p=c.touches[0];p&&H(p.clientX)}},kt=()=>{D&&(D=!1,e.onScrubEnd?.())};document.addEventListener("touchmove",wt,{passive:!0}),document.addEventListener("touchend",kt);let Mt=()=>C&&!D&&!O&&!r.querySelector(":focus-visible"),Ct=()=>{r.classList.remove("hfp-hidden"),T&&clearTimeout(T),T=setTimeout(()=>{Mt()&&r.classList.add("hfp-hidden")},3e3)},F=n instanceof ShadowRoot?n.host:n,B=()=>Ct(),It=()=>{Mt()&&r.classList.add("hfp-hidden")};return F.addEventListener("mousemove",B),F.addEventListener("keydown",B),F.addEventListener("focusin",B),F.addEventListener("mouseleave",It),{updateTime(c,p){let E=p>0?Math.min(c,p):c,ri=p>0?E/p*100:0;s.style.width=`${ri}%`,l.textContent=`${De(E)} / ${De(p)}`},updatePlaying(c){let p=c!==C;C=c,o.classList.toggle("hfp-playing",c),o.setAttribute("aria-label",c?"Pause":"Play"),c?p&&Ct():(T&&clearTimeout(T),r.classList.remove("hfp-hidden"))},updateSpeed(c){let p=i.indexOf(c);p!==-1&&(U=p),m.textContent=W(c),m.setAttribute("aria-label",`Playback speed: ${W(c)}`),ye(c)},updateMuted(c){M=c,b.innerHTML=Z(c,I),b.setAttribute("aria-label",c?"Unmute":"Mute")},updateVolume(c){I=c,A.style.width=`${c*100}%`,_.setAttribute("aria-valuenow",String(Math.round(c*100))),b.innerHTML=Z(M,c)},setVolumeControlsHidden(c){v.style.display=c?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",Rt),document.removeEventListener("mouseup",xt),document.removeEventListener("touchmove",wt),document.removeEventListener("touchend",kt),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h),document.removeEventListener("touchmove",g),document.removeEventListener("touchend",R),document.removeEventListener("click",ve),F.removeEventListener("mousemove",B),F.removeEventListener("keydown",B),F.removeEventListener("focusin",B),F.removeEventListener("mouseleave",It),T&&clearTimeout(T),r.remove()}}}function Tn(n,e,t,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},l=En(n,r,s);return l.updateMuted(e),l.updateVolume(t),l}function ut(n,e,t){return e?(t||(t=document.createElement("img"),t.className="hfp-poster",n.appendChild(t)),t.src=e,t):(t?.remove(),null)}function Rn(n){return n.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains("hfp-controls"))}var Pe=null;function xn(n,e){if(typeof CSSStyleSheet<"u")try{Pe||(Pe=new CSSStyleSheet,Pe.replaceSync(e)),n.adoptedStyleSheets=[Pe];return}catch{}let t=document.createElement("style");t.textContent=e,n.appendChild(t)}function wn(){let n=document.createElement("div");n.className="hfp-container";let e=document.createElement("iframe");return e.className="hfp-iframe",e.sandbox.add("allow-scripts","allow-same-origin"),e.allow="autoplay; fullscreen",e.referrerPolicy="no-referrer",e.title="HyperFrames Composition",n.appendChild(e),{container:n,iframe:e}}function kn(n,e,t,i){let r=n.offsetWidth,o=n.offsetHeight;if(r===0||o===0)return!1;let a=Math.min(r/t,o/i);return e.style.width=`${t}px`,e.style.height=`${i}px`,e.style.transform=`translate(-50%, -50%) scale(${a})`,!0}function ur(n,e,t){if(t.end<=0)return!1;let i=t.shown<t.end&&e>0?e+.001:0;return n+i>=t.end}var Le=class{constructor(e){this._callbacks=e}_callbacks;_raf=null;_lastUpdateMs=0;_tick=null;start(e,t,i,r,o){this.stop();let a=null,s=0,l=0,d=()=>{if(r()){this._raf=null;return}let m;try{m=e.time()}catch{this._raf=null;return}let f=i(),v=o();v.end>0&&(m=Math.min(m,v.end));let b=a===null?0:m-a;b!==0&&(l=Math.min(b,s),s=b),a=m;let S=ur(m,l,v);S&&(m=v.shown);let _=performance.now();if((_-this._lastUpdateMs>100||S)&&(this._lastUpdateMs=_,this._callbacks.onTimeUpdate(m,f)),S){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{e.pause(),v.shown<v.end&&e.seek(v.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(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 Mn(n){let e=Array.from(n.querySelectorAll("[data-composition-id]"));if(e.length===0)return n.body?[n.body]:[];let t=[];for(let i of e)cr(i)||t.push(i);return dr(n),t}function dr(n){let e=n.body;if(!e||typeof console>"u"||typeof console.warn!="function")return;let t=e.querySelectorAll("audio[data-start], video[data-start]");if(t.length===0)return;let i=[];for(let r of t)r.closest("[data-composition-id]")||i.push(r);i.length!==0&&console.warn(`[hyperframes-player] selectMediaObserverTargets: composition hosts are present, but ${i.length} body-level timed media element(s) sit outside every [data-composition-id] subtree and will not be observed. Move them inside a composition host or the parent-frame proxy will never adopt them.`,i)}function cr(n){let e=n.parentElement;for(;e;){if(e.hasAttribute("data-composition-id"))return!0;e=e.parentElement}return!1}var mr=["backdrop-filter","clip-path","filter","mask","mask-border-source","mask-image","perspective","rotate","scale","transform","translate","-webkit-mask-image"],za=new Set([...mr,"contain","isolation","mask-border","mix-blend-mode","opacity"]);var Cn=n=>4*Number.EPSILON*Math.max(1,Math.abs(n));function Ne(n,e){return!Number.isFinite(n)||!Number.isFinite(e)?n===e:Math.abs(n-e)<=Cn(Math.max(Math.abs(n),Math.abs(e)))}var In=(n,e)=>n>=e||Ne(n,e),dt=(n,e,t)=>In(n,e)&&n<t&&!Ne(n,t),pr=1e-6,Dn=(n,e,t,i)=>dt(n,e,t)||In(n,e)&&i>0&&t>=i-pr;function hr(n){return Number.isFinite(n)&&n>0?n:30}function fr(n){return Number.isFinite(n)&&n>0?n:0}function Pn(n,e){let t=hr(e),i=fr(n),r=i*t,o=Math.round(r);return Math.abs(r-o)<=.001?o/t:i}function Ln(n,e,t){return{start:Pn(n,t),end:Number.isFinite(e)?Pn(e,t):e}}var br=["seconds-time","rational-fps","seek-keep-playing","composition-manifest-v1","runtime-data","play-range"];function gr(n,e){let t=Math.abs(n),i=Math.abs(e);for(;i!==0;){let r=t%i;t=i,i=r}return t||1}function _r(n){let e=Number.isFinite(n)&&n>0?n:30,t=Math.abs(e*1001-Math.round(e*1001))<1e-6,i=Number.isInteger(e)?1:t?1001:1e6,r=Math.round(e*i),o=gr(r,i);return{numerator:r/o,denominator:i/o}}function Nn(n,e,t){return Math.max(n,(Math.ceil(e*t-1e-6)-1)/t)}function yr(n){if(typeof n!="object"||n===null)return null;let e=n;return!Number.isFinite(e.numerator)||!Number.isFinite(e.denominator)||(e.numerator??0)<=0||(e.denominator??0)<=0?null:Number(e.numerator)/Number(e.denominator)}function ct(n){return{protocolVersion:1,capabilities:br,fps:_r(n)}}function On(n){let e=n.offsetWidth,t=n.getBoundingClientRect().width;return e>0&&t>0?t/e:null}function vr(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function Fn(n,e=30){if(typeof n!="object"||n===null)return{status:"legacy",fps:e};let t=n;if(t.protocolVersion===void 0)return{status:"legacy",fps:e};if(t.protocolVersion!==1)return{status:"unsupported",code:"unsupported_protocol_version",receivedVersion:t.protocolVersion};let i=yr(t.fps);return i===null||!vr(t.capabilities)?{status:"unsupported",code:"invalid_protocol_metadata",receivedVersion:t.protocolVersion}:{status:"supported",fps:i,metadata:t}}function Sr(n,e){let t=n.tagName.toLowerCase();if(t==="script"||t==="style"||t==="link"||t==="meta")return null;let r=t==="video"||t==="audio"?e.resolver.resolveMediaStartForElement(n):e.resolver.resolveStartForElement(n,0),o=e.resolver.resolveDurationForElement(n),a=n.getAttribute("data-composition-id");if(a){let l=e.timelineRegistry[a],d=ae(l);!(n.hasAttribute("data-duration")||n.hasAttribute("data-end")||n.hasAttribute(tn)||n.hasAttribute(nn))&&(o==null||o<=0)&&d!=null&&d>0&&(o=d)}let s=a!==null&&n===Q(n.ownerDocument);return{start:r,end:!s&&o!=null&&o>0?r+o:Number.POSITIVE_INFINITY}}function Un(n,e){let t=Sr(n,e);if(!t)return!1;let i=e.exportRenderSeek?Ln(t.start,t.end,e.canonicalFps):t;return Dn(e.currentTime,i.start,i.end,e.compositionDuration)}var Y="first-frame",Ar=3;function ce(n){let e=n.ownerDocument?.defaultView;return e&&n instanceof e.Element?!0:n instanceof Element}function w(n){if(!ce(n)||n.tagName!=="AUDIO"&&n.tagName!=="VIDEO")return!1;let e=n.ownerDocument?.defaultView;return e&&n instanceof e.HTMLMediaElement?!0:n instanceof HTMLMediaElement}function Er(n){return n.hasAttribute("data-start")||n.hasAttribute("data-track-index")}function Tr(n,e,t){let i=n;for(;i;){if(Er(i)&&!Un(i,{currentTime:0,compositionDuration:Number.POSITIVE_INFINITY,canonicalFps:30,exportRenderSeek:!1,timelineRegistry:t,resolver:e}))return!1;i=i.parentElement}return!0}function Hn(n,e,t,i){return e==="all"?!0:Tr(n,t,i)}function Oe(n,{scope:e="all"}={}){let t=n.defaultView,i=le({documentRef:n,timelineRegistry:t?.__timelines,includeAuthoredTimingAttrs:!0}),r=n.querySelector(`meta[name="${hn}"]`)!==null,o=Array.from(n.querySelectorAll("video, audio")).filter(w).filter(l=>Hn(l,r&&l.preload!=="auto"?Y:e,i,t?.__timelines??{})).filter(l=>l.readyState<Ar),a=Array.from(n.querySelectorAll("img")).filter(l=>Hn(l,l.getAttribute("loading")?.toLowerCase()==="lazy"?Y:e,i,t?.__timelines??{})).filter(l=>!l.complete),s=n.fonts?.status==="loading";return{pendingMedia:o,pendingImages:a,fontsLoading:s}}function Rr(n,{pendingMedia:e,pendingImages:t,fontsLoading:i},r){let o=e.map(l=>new Promise(d=>{if(l.error){d();return}let m=()=>{l.removeEventListener("canplay",m),l.removeEventListener("error",m),r.removeEventListener("abort",m),d()};l.addEventListener("canplay",m),l.addEventListener("error",m),r.addEventListener("abort",m,{once:!0})})),a=t.map(l=>l.decode?l.decode().catch(()=>{}):Promise.resolve()),s=i&&n.fonts?n.fonts.ready.then(()=>{}):Promise.resolve();return Promise.all([...o,...a,s]).then(()=>{})}function xr(n,e,{scope:t="all"}={}){let i=Oe(n,{scope:t});return i.pendingMedia.length===0&&i.pendingImages.length===0&&!i.fontsLoading?null:Rr(n,i,e)}var wr=50;function kr(n,e){let t=n.defaultView;return!t||t.__renderReady||!t.__hf?null:new Promise(i=>{let r,o=()=>{r!==void 0&&clearTimeout(r),e.removeEventListener("abort",o),i()};if(e.aborted){o();return}e.addEventListener("abort",o,{once:!0});let a=()=>{if(t.__renderReady){o();return}r=setTimeout(a,wr)};a()})}var Mr=50,Cr=1.5,Ir=2,Dr=1500;function mt(n,e){return new Promise(t=>{if(e.aborted){t(-1);return}let i=0,r=()=>{n.cancelAnimationFrame?.(i),t(-1)};e.addEventListener("abort",r,{once:!0}),i=n.requestAnimationFrame(o=>{e.removeEventListener("abort",r),t(o)})})}function Pr(n,e){let t=n.defaultView;return t?(async()=>{let i=await mt(t,e);if(e.aborted)return;let r=await mt(t,e),o=r-i,a=0;for(;!e.aborted&&a<Ir;){if(r-i>=Dr)return;let s=await mt(t,e);if(e.aborted)return;let l=s-r;o=Math.min(o,l),a=l<Mr||l<=o*Cr?a+1:0,r=s}})():null}var Lr=8e3;function Nr(n,e,t={}){let i=t.inputs??[(d,m)=>xr(d,m,{scope:t.scope}),kr,Pr],r=new AbortController,o=i.map(d=>d(n,r.signal)).filter(d=>d!==null);if(o.length===0){e({timedOut:!1});return}let a=t.timeoutMs??Lr,s,l=new Promise(d=>{s=setTimeout(()=>d("timed-out"),a)});Promise.race([Promise.all(o).then(()=>"done"),l]).then(d=>{clearTimeout(s),r.abort(),e({timedOut:d==="timed-out"})})}function Vn(n,e,t={}){Nr(n,e,{...t,scope:Y})}function pt(n,e,t){for(let i of e){let r=n.getAttribute(i);if(r===null||r.trim()==="")continue;let o=Number(r);if(Number.isFinite(o))return o}return t}function ht(n){return{start:pt(n,["data-start"],0),duration:pt(n,["data-duration"],0),mediaStart:Ee(e=>n.getAttribute(e)),playbackRate:pt(n,["data-playback-rate"],1)}}function Fe(n){return n+1e-5}var Or=[[.3,.25],[.1,.1]],Fr=.01,Ur=.1,Hr=.1,me=new WeakMap;function Wn(n,e,t,i,r=n.tagName==="AUDIO"){let o=Math.abs(e);if(r&&i&&o>Hr)return me.delete(n),{rate:t,seek:!0};let a=Math.sign(e),s=me.get(n);if(o>.04)me.set(n,a);else if(s!==a||o<=Fr)return me.delete(n),{rate:t,seek:!1};let l=Or.find(([m])=>o>m)?.[1]??.03,d=r?Math.min(l,Ur):l;return{rate:t*(1+a*d),seek:!1}}function $n(n){me.delete(n)}var Vr=.004,Wr=1.5,Ue=class{_entries=[];_mediaObserver;_playbackErrorPosted=!1;_audioOwner="runtime";_urlAudioEntry=null;_urlAudioSrc=null;_dispatchEvent;_getMuted;_getVolume;_getPlaybackRate;_getCurrentTime;_isPaused;constructor(e){this._dispatchEvent=e.dispatchEvent,this._getMuted=e.getMuted,this._getVolume=e.getVolume,this._getPlaybackRate=e.getPlaybackRate,this._getCurrentTime=e.getCurrentTime,this._isPaused=e.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;let e=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll();for(let t of this._entries)t!==this._urlAudioEntry&&(t.el.src="");this._entries=this._urlAudioEntry?[this._urlAudioEntry]:[],this._urlAudioSrc&&!this._urlAudioEntry&&(this._urlAudioEntry=this._createEntry(this._urlAudioSrc,"audio",0,1/0)),this.teardownObserver(),e&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(let e of this._entries)e.el.pause(),e.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(e){for(let t of this._entries)t.el.muted=e}updateVolume(e){for(let t of this._entries)t.el.volume=e}updatePlaybackRate(e){for(let t of this._entries)t.el.playbackRate=e}_playEntry(e){e.el.src&&e.el.play().catch(t=>this._reportPlaybackError(t))}_playEntryIfActive(e){this._refreshEntryBounds(e),this._inWindow(e,this._getCurrentTime())&&this._playEntry(e)}_refreshEntryBounds(e){if(!e.source?.isConnected)return;let t=Qe(e.source);e.start=t.start??0,e.mediaStart=ht(e.source).mediaStart,e.duration=t.duration!=null&&t.duration>0?t.duration:Number.POSITIVE_INFINITY}_inWindow(e,t){return dt(t,e.start,e.start+e.duration)}_preseekUpcoming(e,t){let i=e.start-t;i<=0||i>Wr||!e.el.paused||Math.abs(e.el.currentTime-e.mediaStart)>.04&&this._seekTo(e,e.mediaStart)}_seekTo(e,t,i=!1){let r=i?(e.seekLatency??0)*this._getPlaybackRate():0;e.seekIssuedAt=i?performance.now():void 0,e.el.currentTime=Fe(t+r)}_noteSeekLanded(e){if(e.seekIssuedAt===void 0)return;let t=(performance.now()-e.seekIssuedAt)/1e3;e.seekLatency=e.seekLatency===void 0?t:(e.seekLatency+t)/2,e.seekIssuedAt=void 0}_releaseSteering(e){$n(e.el),e.lastOffset=void 0;let t=this._getPlaybackRate();e.el.playbackRate!==t&&(e.el.playbackRate=t)}_mediaTime(e,t){return t-e.start+e.mediaStart}_gateEntryPlayback(e,t){return this._inWindow(e,t)?(this._audioOwner==="parent"&&!this._isPaused()&&e.el.paused&&this._playEntry(e),!0):(e.el.paused||e.el.pause(),this._releaseSteering(e),!1)}playAll(){for(let e of this._entries)this._playEntryIfActive(e)}pauseAll(){for(let e of this._entries)e.el.pause()}stopAdoptedMedia(){for(let e of this._entries)e.source&&e.el.pause()}seekAll(e){for(let t of this._entries)this._refreshEntryBounds(t),this._inWindow(t,e)&&this._jumpTo(t,this._mediaTime(t,e))}scrubAll(e){for(let t of this._entries)this._refreshEntryBounds(t),this._inWindow(t,e)?(this._jumpTo(t,this._mediaTime(t,e)),this._playEntry(t)):t.el.paused||t.el.pause()}mirrorTime(e,t){let i=t?.force===!0;for(let r of this._entries){this._refreshEntryBounds(r),this._preseekUpcoming(r,e);let o=r.el.paused;if(!this._gateEntryPlayback(r,e))continue;let a=this._mediaTime(r,e),s=a-r.el.currentTime;if(i||o){Math.abs(s)>.04&&this._jumpTo(r,a);continue}this._steer(r,a,s)}}_steer(e,t,i){let r=e.lastOffset!==void 0&&Math.abs(i-e.lastOffset)<Vr;e.lastOffset=i;let{rate:o,seek:a}=Wn(e.el,i,this._getPlaybackRate(),r,!0);a?this._jumpTo(e,t,!0):Math.abs(e.el.playbackRate-o)>1e-6&&(e.el.playbackRate=o)}_jumpTo(e,t,i=!1){this._seekTo(e,t,i),this._releaseSteering(e)}promoteToParentProxy(e,t){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",e)for(let r of e.querySelectorAll("video, audio"))w(r)&&(r.muted=!0);for(let r of[...this._entries])this._repointToSource(r);let i=this._getCurrentTime();t?t(i,{force:!0}):this.mirrorTime(i,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(e){let t=e.querySelectorAll("audio[data-start], video[data-start]");for(let i of t)w(i)&&this._adoptIframeMedia(i);this._observeDynamicMedia(e)}setupFromUrl(e){if(this._urlAudioSrc===e&&this._urlAudioEntry)return;this.teardownUrlAudio();let t=this._createEntry(e,"audio",0,1/0);this._urlAudioEntry=t,this._urlAudioSrc=e,t&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){let e=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!e)return;e.el.pause(),e.el.src="";let t=this._entries.indexOf(e);t!==-1&&this._entries.splice(t,1)}teardownObserver(){this._mediaObserver?.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(e){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:e}})))}_createEntry(e,t,i,r,o){if(!o&&this._urlTaken(e))return null;let a=t==="video"?document.createElement("video"):new Audio;a.preload="auto";let s=o?.getAttribute("crossorigin");s!=null&&a.setAttribute("crossorigin",s),a.src=e,a.load(),a.muted=this._getMuted(),a.volume=this._getVolume();let l=this._getPlaybackRate();l!==1&&(a.playbackRate=l);let d={el:a,start:i,duration:r,mediaStart:o?ht(o).mediaStart:0,source:o};return a.addEventListener("seeked",()=>this._noteSeekLanded(d)),this._entries.push(d),d}_resolveIframeMediaSrc(e){let t=e.getAttribute("src")||e.querySelector("source")?.getAttribute("src");return t?new URL(t,e.ownerDocument.baseURI).href:null}_adoptIframeMedia(e){if(e.preload==="metadata"||e.preload==="none"||this._entries.some(l=>l.source===e)||e.tagName==="VIDEO"&&e.hasAttribute("muted"))return;let t=this._resolveIframeMediaSrc(e);if(!t)return;let i=Qe(e),r=i.start??0,o=i.duration??Number.POSITIVE_INFINITY,a=e.tagName==="VIDEO"?"video":"audio",s=this._createEntry(t,a,r,o,e);s&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(s))}_followIframeMediaSrc(e){let t=this._entries.find(i=>i.source===e);if(!t)return this._adoptIframeMedia(e);this._audioOwner!=="parent"||!this._repointToSource(t)||(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(t))}_urlTaken(e){return this._entries.some(t=>t.source&&!t.source.isConnected?!1:(t.source&&this._resolveIframeMediaSrc(t.source)||t.el.src)===e)}_repointToSource(e){let t=e.source?this._resolveIframeMediaSrc(e.source):null;return!t||e.el.src===t?!1:(e.el.src=t,e.el.load(),!0)}_detachIframeMedia(e){let t=this._entries.find(i=>i.source===e);t&&this._removeEntry(t)}_removeEntry(e){e.el.pause(),e.el.src="",this._entries.splice(this._entries.indexOf(e),1)}_observeDynamicMedia(e){if(this.teardownObserver(),typeof MutationObserver>"u"||!e.body)return;let t=new MutationObserver(o=>{for(let a of o){if(a.type==="attributes"&&a.attributeName==="src"){let s=a.target;w(s)&&s.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(s);continue}if(a.type==="attributes"&&a.attributeName==="preload"){let s=a.target;w(s)&&s.matches("audio[data-start], video[data-start]")&&(s.preload==="auto"?this._adoptIframeMedia(s):this._detachIframeMedia(s));continue}for(let s of a.addedNodes){if(!ce(s))continue;let l=[];w(s)&&s.matches("audio[data-start], video[data-start]")&&l.push(s);let d=s.querySelectorAll("audio[data-start], video[data-start]");for(let m of d)w(m)&&l.push(m);for(let m of l)this._adoptIframeMedia(m)}for(let s of a.removedNodes){if(!ce(s))continue;let l=[];w(s)&&s.matches("audio[data-start], video[data-start]")&&l.push(s);let d=s.querySelectorAll("audio[data-start], video[data-start]");for(let m of d)w(m)&&l.push(m);for(let m of l)this._detachIframeMedia(m)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},r=Mn(e);for(let o of r)t.observe(o,i);this._mediaObserver=t}};function ft(n,e,t){if(n===null&&e===null)return{range:null,clamped:!1};let i=n??0,r=e!==null&&t>0&&e>t,o=r?t:e,a=o??(t>0?t:1/0);return!(i>=0)||!(a>i)?{range:null,clamped:!0}:{range:{start:i,end:o},clamped:r}}function pe(n,e,t){let i=n.end??e;return i<e?Nn(n.start,i,t):i}function bt(n,e,t,i){return n<e.start||n>=pe(e,t,i)}var $r=100;function Br(n,e){return typeof n.currentTime=="number"&&Number.isFinite(n.currentTime)?n.currentTime:(n.frame??0)/e}function Gn(n,e,t){return t<=0?!1:n.ended===!0?!0:n.ended===!1&&!n.isPlaying?!1:e>=t}function Gr(n,e,t,i,r,o){let{duration:a}=t;if(!r){let s=Gn(n,e,a);return{start:0,shownAtEnd:a,atEnd:s,stopRuntime:!1,entering:!1}}if(n.ownsRange){let s=i&&n.ended===!0&&!n.isPlaying;return{start:r.start,shownAtEnd:e,atEnd:s,stopRuntime:!1,entering:!1}}return zr(n,e,t,i,r,o)}function zr(n,e,t,i,r,o){let a=r.end??t.duration,s=t.enteringRange===!0&&(e<r.start||e>=a);return{start:r.start,shownAtEnd:pe(r,t.duration,o),atEnd:i&&!s&&Gn(n,e,a),stopRuntime:n.isPlaying,entering:s}}function zn(n,e,t,i){let r=Br(n,e),o=!t.paused,a=o||n.isPlaying,s=i.getPlayRange?.(),l=Gr(n,r,t,a,s,e),{atEnd:d,start:m}=l,f=t.duration>0?Math.min(r,t.duration):r,v=d?l.shownAtEnd:f,b=!n.isPlaying,S=d&&a;if(S&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(m),i.play(),{...t,currentTime:m,paused:!1,enteringRange:!0};let _={...t,currentTime:v,paused:b,enteringRange:l.entering};i.media.audioOwner==="parent"&&(o&&b?i.media.pauseAll():!o&&!b&&i.media.playAll(),i.media.mirrorTime(v));let A=performance.now(),C=b!==t.paused;return(A-t.lastUpdateMs>$r||C)&&(_.lastUpdateMs=A,i.updateControlsTime(v,t.duration),i.updateControlsPlaying(!b),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:v}}))),S&&(l.stopRuntime&&i.seek(v),i.media.audioOwner==="parent"&&i.media.pauseAll(),_.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),_}function jr(n){return Array.isArray(n)?n.filter(e=>typeof e=="object"&&e!==null&&typeof e.id=="string"&&typeof e.start=="number"&&typeof e.duration=="number"):[]}function jn(n,e,t){if(n.source!==e)return;let i=n.data;if(!i||i.source!=="hf-preview")return;let r=Fn(i);if(r.status==="unsupported"){t.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:r.code,receivedVersion:r.receivedVersion}}));return}t.setRuntimeFps?.(r.fps);let o=r.status==="supported"&&r.metadata.capabilities.includes("play-range");if(t.setRuntimeOwnsPlayRange?.(o),i.type==="shader-transition-state"){let a=i.state&&typeof i.state=="object"?i.state:{};t.shaderLoader.update(a,t.getShaderLoadingMode()),t.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:a}}));return}if(i.type==="ready"){t.onRuntimeReady();return}if(i.type==="assets-ready"){t.onRuntimeAssetsReady?.(i.timedOut===!0);return}if(i.type==="runtime-data-error"){t.onRuntimeDataError?.(i.channel,i.requestId,i.message);return}if(i.type==="runtime-data-applied"){t.onRuntimeDataApplied?.(i.channel,i.requestId);return}if(i.type==="state"){t.setPlaybackState(zn({frame:i.frame??0,currentTime:i.currentTime,ended:typeof i.ended=="boolean"?i.ended:void 0,isPlaying:!!i.isPlaying,ownsRange:o},r.fps,t.getPlaybackState(),t));return}if(i.type==="media-autoplay-blocked"){if(t.shouldPromoteMediaAutoplayFallback?.()===!1)return;let a=null;try{a=t.getIframeDoc()}catch{}t.media.promoteToParentProxy(a,(s,l)=>t.media.mirrorTime(s,l)),t.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){let a=Number(i.durationSeconds),s=Number(i.durationInFrames),l=Number.isFinite(a)&&a>0?a:s/r.fps;if(Number.isFinite(i.compositionWidth)&&i.compositionWidth>0&&Number.isFinite(i.compositionHeight)&&i.compositionHeight>0&&t.setCompositionSize(i.compositionWidth,i.compositionHeight),Number.isFinite(l)&&l>0){let d=t.getPlaybackState();t.setPlaybackState({...d,duration:l}),t.updateControlsTime(d.currentTime,l),t.onRuntimeTimelineReady(l,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}t.setScenes(jr(i.scenes));return}i.type==="stage-size"&&Number.isFinite(i.width)&&i.width>0&&Number.isFinite(i.height)&&i.height>0&&t.setCompositionSize(i.width,i.height)}function qr(n,e){return n.includes(e)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(n)}var Yr=new Set([">"," "," ",`
|
|
478
|
+
`,"\r","\f"]);function gt(n,e){let t=n.toLowerCase(),i=`<${e}`,r=0;for(;r<t.length;){let o=t.indexOf(i,r);if(o<0)return null;let a=t[o+i.length];if(Yr.has(a)){let s=t.indexOf(">",o+i.length);return s<0?null:{index:o,end:s+1}}r=o+i.length}return null}function qn(n,e){if(!n||qr(n,e))return n;let t=`<script src="${e}"></script>`,i=gt(n,"head");if(i)return n.slice(0,i.end)+t+n.slice(i.end);let r=gt(n,"body");if(r)return n.slice(0,r.index)+t+n.slice(r.index);let o=gt(n,"html");return o?n.slice(0,o.end)+t+n.slice(o.end):t+n}var $="shader-capture-scale",X="shader-loading",He="runtime-src",Yn="__hf_shader_capture_scale",Xn="__hf_shader_loading",K=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function _t(n){if(n===null)return null;let e=Number(n);return!Number.isFinite(e)||e<=0?null:String(Math.min(1,Math.max(.25,e)))}function Xr(n){if(n===null||n.trim()==="")return"composition";let e=n.trim().toLowerCase();return e==="none"||e==="false"||e==="0"||e==="off"?"none":e==="player"||e==="true"||e==="1"||e==="on"?"player":"composition"}function Kn(n,e){return n.filter(t=>t!==""&&t.split("=")[0]!==e)}function Kr(n,e,t){let i=n.indexOf("#"),r=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i):"",a=r.indexOf("?"),s=a>=0?r.slice(0,a):r,l=a>=0?r.slice(a+1):"",d=Kn(l.split("&"),Yn);d=Kn(d,Xn),e!==null&&d.push(`${Yn}=${encodeURIComponent(e)}`),t!=="composition"&&d.push(`${Xn}=${encodeURIComponent(t)}`);let m=d.join("&");return`${s}${m?`?${m}`:""}${o}`}function Zr(n,e,t){if(e===null&&t==="composition")return n;let i=[];e!==null&&i.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(e)};`),t!=="composition"&&i.push(`window.__HF_SHADER_LOADING=${JSON.stringify(t)};`);let r=`<script data-hyperframes-player-shader-options>${i.join("")}</script>`;return/<head\b[^>]*>/i.test(n)?n.replace(/<head\b[^>]*>/i,o=>`${o}${r}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b[^>]*>/i,o=>`${o}${r}`):`${r}${n}`}function he(n){return Xr(n.getAttribute(X))}function Zn(n){return Number(_t(n.getAttribute($))??"1")}function Jn(n,e){return Kr(e,_t(n.getAttribute($)),he(n))}function fe(n,e){return qn(Zr(e,_t(n.getAttribute($)),he(n)),yt(n))}function yt(n){let e=n.getAttribute(He)?.trim();if(!e)return q;try{let t=new URL(e,document.baseURI),i=t.protocol==="http:"||t.protocol==="https:",r=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]";return i&&(r||t.origin===location.origin)?t.href:q}catch{return q}}function Qn(){let n=document.createElement("div");n.className="hfp-shader-loader",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-label","Preparing scene transitions"),n.setAttribute("data-hyperframes-ignore",""),n.draggable=!1;let e=b=>{b.preventDefault(),b.stopPropagation()};for(let b of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])n.addEventListener(b,e,{capture:!0});let t=document.createElement("div");t.className="hfp-shader-loader-panel",t.draggable=!1;let i=document.createElement("div");i.className="hfp-shader-loader-mark",i.draggable=!1,i.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");let r=document.createElement("div");r.className="hfp-shader-loader-title";let o=document.createElement("span");o.className="hfp-shader-loader-title-text",o.textContent=K[0]||"Preparing scene transitions",r.appendChild(o);let a=document.createElement("div");a.className="hfp-shader-loader-detail",a.textContent="Rendering animated scene samples for shader transitions.";let s=document.createElement("div");s.className="hfp-shader-loader-track",s.setAttribute("aria-hidden","true");let l=document.createElement("div");l.className="hfp-shader-loader-fill",s.appendChild(l);let d=document.createElement("div");d.className="hfp-shader-loader-progress";let m=b=>{let S=document.createElement("div");S.className="hfp-shader-loader-row";let _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=b;let A=document.createElement("span");return A.className="hfp-shader-loader-value",S.appendChild(_),S.appendChild(A),d.appendChild(S),{row:S,label:_,value:A}},f=m("transition"),v=m("transition frame");return t.appendChild(i),t.appendChild(r),t.appendChild(a),t.appendChild(s),t.appendChild(d),n.appendChild(t),{root:n,fill:l,title:o,detail:a,transitionValue:f.value,transitionRow:f.row,frameLabel:v.label,frameValue:v.value,frameRow:v.row}}var Jr=420;function Ve(n,e,t){e.textContent=t,n.style.visibility=t?"visible":"hidden"}var We=class{_el;_hideTimeout=null;_hiddenCallbacks=[];_drawingAssets=!1;constructor(e){this._el=e}show(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-hiding"),this._el.root.classList.add("hfp-visible")}hide(){if(this._el.root.classList.contains("hfp-hiding")){this._hideTimeout||this._scheduleCleanup();return}this._el.root.classList.contains("hfp-visible")&&(this._el.root.classList.add("hfp-hiding"),this._el.root.classList.remove("hfp-visible"),this._scheduleCleanup())}whenHidden(e){let t=this._el.root.classList;t.contains("hfp-visible")||t.contains("hfp-hiding")?this._hiddenCallbacks.push(e):e()}_flushHidden(){let e=this._hiddenCallbacks;this._hiddenCallbacks=[];for(let t of e)t()}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._drawingAssets=!1,this._flushHidden(),this._el.fill.style.transform="scaleX(0)",Ve(this._el.transitionRow,this._el.transitionValue,""),Ve(this._el.frameRow,this._el.frameValue,"")}update(e,t){let i=t==="player"&&e.loading&&!e.ready;if(this._drawingAssets&&!i)return;if(t!=="player"){this.reset();return}if(e.ready||!e.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions"),this._drawingAssets=!1;let r=typeof e.progress=="number"&&Number.isFinite(e.progress)?e.progress:0,o=typeof e.total=="number"&&Number.isFinite(e.total)?e.total:0,a=o>0?Math.min(1,Math.max(0,r/o)):0,s=Math.min(K.length-1,Math.floor(a*K.length));this._el.title.textContent=K[s]||"Preparing scene transitions",this._el.detail.textContent=e.phase==="cached"?"Loading cached transition frames before playback.":e.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${a})`;let l=e.currentTransition!==void 0&&e.transitionTotal!==void 0?`${e.currentTransition}/${e.transitionTotal}`:o>0?`${r}/${o}`:"",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,l),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()},Jr)}};function ei(n){return n?.trim().toLowerCase().startsWith("video/")??!1}function ti(n){let e=document.createElement("video");e.className="hfp-video",e.playsInline=!0,e.preload="metadata";let t=new AbortController,{signal:i}=t;return e.addEventListener("loadedmetadata",()=>n.onMetadata(e),{signal:i}),e.addEventListener("durationchange",()=>n.onDurationChange(e),{signal:i}),e.addEventListener("resize",()=>n.onResize(e),{signal:i}),e.addEventListener("play",()=>n.onPlay(e),{signal:i}),e.addEventListener("pause",()=>n.onPause(e),{signal:i}),e.addEventListener("timeupdate",()=>n.onTimeUpdate(),{signal:i}),e.addEventListener("error",()=>n.onError(e.error?.message||"Video failed to load",e.error?.code??null),{signal:i}),{video:e,adapter:{duration:()=>e.duration,time:()=>e.currentTime,seek:o=>{e.currentTime=Fe(o)},play:()=>e.play().catch(o=>{i.aborted||n.onPlayRejected(o)}),pause:()=>e.pause(),timeScale:o=>{e.defaultPlaybackRate=o,e.playbackRate=o}},destroy:()=>{t.abort(),e.pause(),e.removeAttribute("src"),e.load(),e.remove()}}}var Qr=.1,eo=5,vt="sandbox-origin",ni=1e4,St=8e3,At="assets-loading",be="assets-loading-ui",Et="low-power-idle",ii="disable-click-to-play",ge="range-start",_e="range-end",to=150;function Tt(n){return!Number.isFinite(n)||n<=0?1:Math.max(Qr,Math.min(eo,n))}var $e=class extends HTMLElement{static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src","type",vt,He,$,X,be,Et,ge,_e]}shadow;container;sizer=document.createElement("div");iframe;posterEl=null;controlsApi=null;resizeObserver;shaderLoader;probe;_ready=!1;_readyDocument=null;_connected=!1;_assetsReady=!1;_painted=!1;_pendingPlay=!1;_assetsGeneration=0;_assetsLoadingShowTimer=null;_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"}),xn(this.shadow,yn),{container:this.container,iframe:this.iframe}=wn(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);let e=Qn();this.shadow.appendChild(e.root),this.shaderLoader=new We(e),this._media=new Ue({dispatchEvent:t=>this._emit(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Le({onTimeUpdate:(t,i)=>{this._currentTime=t,this.controlsApi?.updateTime(t,i),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:t}}))},getLoop:()=>this.loop,restart:()=>{this.seek(this._playRange()?.start??0),this.play()},onPaused:()=>{this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this._emit(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new Ie(this.iframe,{resolveRuntimeUrl:()=>yt(this),hostOwnsDeadline:()=>this.hasAttribute("no-load-timeout"),onReady:t=>this._onProbeReady(t),onError:t=>this._emit(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{this.disableClickToPlay||Rn(t)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this),this.iframe.addEventListener("load",this._onIframeLoad)}connectedCallback(){this._connected=!0,this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=ut(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=fe(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){this._connected=!1,this._teardownVideo(),this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),this.controlsApi?.destroy(),this.controlsApi=null,this._paused=!0,this._pendingPlay=!1,this._abandonComposition("Player disconnected before runtime data was applied")}attributeChangedCallback(e,t,i){switch(e){case"src":if(!this.isConnected)break;i&&this._navigateSrc(i);break;case"type":{let r=this.getAttribute("src");if(!this.isConnected||r===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(r);break}case"srcdoc":if(!this.isConnected)break;if(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),i!==null)this._pauseForVideoSwitch(),this._teardownVideo(),this.iframe.srcdoc=fe(this,i);else{this.iframe.removeAttribute("srcdoc");let r=this.getAttribute("src");r!==null&&this._wantsVideo()&&this._navigateSrc(r)}break;case vt:this._applySandboxOriginPolicy(this.isConnected&&t!==i);break;case"width":this._setCompositionSize(de(i)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,de(i)??1080);break;case"controls":i!==null?this._setupControls():(this.controlsApi?.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=ut(this.shadow,i,this.posterEl);break;case"playback-rate":{let r=Tt(parseFloat(i||"1"));this._media.updatePlaybackRate(r),this._sendControl("set-playback-rate",{playbackRate:r}),this._directTimelineAdapter?.timeScale?.(r),this.controlsApi?.updateSpeed(r),this._emit(new Event("ratechange"));break}case"muted":this._handleMutedChange(i);break;case"audio-locked":this._applyAudioLock(i!==null);break;case"volume":{let r=Math.max(0,Math.min(1,parseFloat(i||"1")));this._volume=r,this._syncVideoAudio(),this._media.updateVolume(r),this._sendControl("set-volume",{volume:r}),this.controlsApi?.updateVolume(r),this._emit(new Event("volumechange"));break}case"audio-src":i?this._media.setupFromUrl(i):this._media.teardownUrlAudio();break;case be:i==="none"&&this.shaderLoader.hideAssetsLoading();break;case Et:this._sendControl("set-idle-heartbeat",{slow:i!==null});break;case ge:case _e:this._applyPlayRange(!0);break;case $:case X:case He:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(vt)?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=fe(this,e);return}let t=this.getAttribute("src");t===null?this.iframe.src="about:blank":this._loadSrc(t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){this._play(!0)}_play(e){if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,this.posterEl?.remove(),this.posterEl=null;let t=this._ready?this._playRange():null;t?bt(this._currentTime,t,this._duration,this._runtimeFps)&&(this.seek(t.start),this._enteringRange=!0):this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;let i=this._tryDirectTimelinePlay(),r=!1;this._sendDisplayScale(),i||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,r=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),this.controlsApi?.updatePlaying(!0),!r&&e&&this._emit(new Event("play")),i&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused,()=>this._clockStop())}pause(){this._pendingPlay=!1,this._tryDirectTimelinePause()?this._showPausedVideoTime():this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this._emit(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){this._pendingPlay=!1,!this._trySyncSeek(e)&&!this._tryDirectTimelineSeek(e)&&this._sendControl("seek",{timeSeconds:e,frame:Math.round(e*this._runtimeFps)}),this._directTimelineClock.stop(),this._stopParentTickClock(),this._currentTime=e,this._media.audioOwner==="parent"&&(this._scrubbing?this._media.scrubAll(e):(this._media.pauseAll(),this._media.seekAll(e))),this._paused=!0,this.controlsApi?.updatePlaying(!1),this.controlsApi?.updateTime(this._currentTime,this._duration)}setColorGrading(e,t){this._sendControl("set-color-grading",{target:e,grading:t})}clearColorGrading(e){this._sendControl("set-color-grading",{target:e,grading:null})}setColorGradingCompare(e,t){this._sendControl("set-color-grading-compare",{target:e,compare:t})}clearColorGradingCompare(e){this._sendControl("set-color-grading-compare",{target:e,compare:{enabled:!1}})}setRuntimeData(e,t){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);if(typeof structuredClone!="function")throw new Error("HyperFrames runtime data requires structuredClone support; refusing an unverified payload");let i=structuredClone(t);this._runtimeData.set(e,i),this._deliverRuntimeData(e,i)}clearRuntimeData(e){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);this._runtimeData.delete(e),this._deliverRuntimeDataClear(e)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get compositionWidth(){return this._compositionWidth}get compositionHeight(){return this._compositionHeight}get paused(){return this._paused}get ready(){return this._ready}get assetsReady(){return this._assetsReady}get painted(){return this._painted}get playbackRate(){return Tt(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(Tt(e)))}get shaderCaptureScale(){return Zn(this)}set shaderCaptureScale(e){this.setAttribute($,String(e))}get shaderLoading(){return he(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(X):this.setAttribute(X,e)}get assetsLoadingUi(){return this.getAttribute(be)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(be,"none"):this.removeAttribute(be)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_isLockedHostEnvironment(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||"";return/\bClaude\/\d/.test(e)&&/\bElectron\b/.test(e)}_isAudioLocked(){return this.hasAttribute("audio-locked")||this._isLockedHostEnvironment()}_isSlideshowPlayer(){return this.closest("hyperframes-slideshow")!==null}_handleMutedChange(e){if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._syncVideoAudio(),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),this.controlsApi?.updateMuted(e!==null),this._emit(new Event("volumechange"))}_applyAudioLock(e){e&&(this.muted=!0),this.controlsApi?.setVolumeControlsHidden(e)}get volume(){return this._volume}set volume(e){this.setAttribute("volume",String(Math.max(0,Math.min(1,e))))}get disableClickToPlay(){return this.hasAttribute(ii)}set disableClickToPlay(e){this.toggleAttribute(ii,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(ge)}set rangeStart(e){this._writeSeconds(ge,e)}get rangeEnd(){return this._readSeconds(_e)}set rangeEnd(e){this._writeSeconds(_e,e)}_readSeconds(e){let t=this.getAttribute(e);return t===null?null:Number(t)}_writeSeconds(e,t){t==null?this.removeAttribute(e):this.setAttribute(e,String(t))}_hasPlayRange(){return this.hasAttribute(ge)||this.hasAttribute(_e)}_playRange(){return ft(this.rangeStart,this.rangeEnd,this._duration).range}_sendPlayRange(e){let t=e?.end??null;this._sendControl("set-play-range",{startSeconds:e?.start??null,endSeconds:t})}_applyPlayRange(e){let{range:t,clamped:i}=ft(this.rangeStart,this.rangeEnd,this._duration);this._sendPlayRange(t),this._ready&&(this._reportRangeClamp(t,i),t&&e&&!this._pendingPlay&&this._moveIntoPlayRange(t))}_reportRangeClamp(e,t){let i=t?`${this.rangeStart},${this.rangeEnd},${this._duration}`:"";if(i===this._rangeClampReported||(this._rangeClampReported=i,!t))return;let r={rangeStart:e?.start??null,rangeEnd:e?.end??null};this._emit(new CustomEvent("rangeclamped",{detail:{...r,duration:this._duration}}))}_moveIntoPlayRange(e){bt(this._currentTime,e,this._duration,this._runtimeFps)&&(this._paused?this.seek(e.start):this._jumpWhilePlaying(e.start))}_jumpWhilePlaying(e){this._directTimelineAdapter?(this._directTimelineAdapter.seek(e,!1),this._currentTime=e):this._runtimeOwnsPlayRange||(this.seek(e),this._enteringRange=!0,this._play(!1))}_clockStop(){let e=this._playRange(),t=e?.end??this._duration;if(!e)return{end:t,shown:t};let i=pe(e,this._duration,this._runtimeFps);return{end:t,shown:i<t?(i+t)/2:i}}_sendControl(e,t={}){try{let i=this.iframe.contentWindow;return i?(i.postMessage({...t,source:"hf-parent",type:"control",action:e,...ct(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,"Composition iframe is unavailable"),!1)}catch(i){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,i instanceof Error?i.message:String(i)),!1}}_deliverRuntimeData(e,t){if(!this.isConnected||!this._runtimeBridgeReady)return;let i=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,t,i)||this._sendControl("set-runtime-data",{channel:e,payload:t,requestId:i})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;let t=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,t)||this._sendControl("clear-runtime-data",{channel:e,requestId:t})}_trySetRuntimeDataDirect(e,t,i){try{let r=this.iframe.contentWindow?.__hyperframes;return typeof r?.setRuntimeData!="function"?!1:(r.setRuntimeData(e,t,i),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,t){try{let i=this.iframe.contentWindow?.__hyperframes;return typeof i?.clearRuntimeData!="function"?!1:(i.clearRuntimeData(e,t),!0)}catch{return!1}}_replayRuntimeData(){for(let[e,t]of this._runtimeData)this._deliverRuntimeData(e,t)}_beginRuntimeDataDelivery(e){let t=this._pendingRuntimeData.get(e);t&&window.clearTimeout(t.timeoutId),this._runtimeDataRequestId+=1;let i=this._runtimeDataRequestId,r=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,i,`Runtime data delivery timed out after ${ni}ms`)},ni);return this._pendingRuntimeData.set(e,{requestId:i,timeoutId:r}),i}_resolveRuntimeDataDelivery(e,t){let i=this._takeRuntimeDataDelivery(e,t);i&&this._emit(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:i.requestId}}))}_rejectRuntimeDataDelivery(e,t,i){let r=this._takeRuntimeDataDelivery(e,t);r&&this._emit(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:r.requestId,message:typeof i=="string"?i:String(i)}}))}_takeRuntimeDataDelivery(e,t){if(typeof e!="string"||typeof t!="number"||!Number.isSafeInteger(t))return null;let i=this._pendingRuntimeData.get(e);return!i||i.requestId!==t?null:(window.clearTimeout(i.timeoutId),this._pendingRuntimeData.delete(e),i)}_rejectAllRuntimeDataDeliveries(e){for(let[t,i]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(t,i.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){let t=this._getSameOriginIframeDocument();if(t)for(let i of t.querySelectorAll("video, audio"))w(i)&&(i.muted=e||i.defaultMuted)}_stopIframeMedia(){let e=this._getSameOriginIframeDocument();if(e)for(let t of e.querySelectorAll("video, audio"))w(t)&&t.pause()}_replayBridgeState(){this._sendControl("set-muted",{muted:this.muted}),this._sendControl("set-volume",{volume:this._volume}),this._sendControl("set-playback-rate",{playbackRate:this.playbackRate}),this._sendControl("set-native-media-sync-disabled",{disabled:this._isSlideshowPlayer()}),this._sendControl("set-web-audio-media-disabled",{disabled:this._isSlideshowPlayer()}),this._sendControl("set-idle-heartbeat",{slow:this.hasAttribute(Et)}),this._sendDisplayScale()}_sendDisplayScale(){let e=On(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=fe(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 ei(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=Jn(this,e)}_loadVideo(e){this._videoSource||(this._videoSource=ti({onMetadata:r=>this._applyThenEmit(()=>this._onVideoReady(r)),onDurationChange:r=>this._applyTimelineDuration(r.duration),onResize:r=>this._applyVideoSize(r),onPlay:r=>{!r.paused&&this._paused&&this.play()},onPause:r=>{r.paused&&!r.ended&&!this._paused&&this.pause()},onTimeUpdate:()=>{document.hidden&&this._playRange()&&this._directTimelineClock.poll()},onError:(r,o)=>{this._paused||this.pause(),this._emit(new CustomEvent("error",{detail:{message:r,code:o}}))},onPlayRejected:r=>this._onVideoPlayRejected(r)}),this.container.appendChild(this._videoSource.video),this.iframe.hidden=!0,this.iframe.src="about:blank"),this.probe.stop();let{video:t,adapter:i}=this._videoSource;this._directTimelineAdapter=i,this._currentTime=0,this._duration=0,this.controlsApi?.updateTime(0,0),this._syncVideoAudio(),i.timeScale?.(this.playbackRate),t.src=e}_teardownVideo(){this._videoSource&&(this._videoSource.destroy(),this._videoSource=null,this.iframe.hidden=!1)}_syncVideoAudio(){this._videoSource&&(this._videoSource.video.muted=this.muted,this._videoSource.video.volume=this._volume)}_onVideoReady(e){this._applyTimelineDuration(e.duration),this._applyVideoSize(e),this._ready=!0,this._dispatchReady(),this._waitForAssetsReady(null),this._afterEvents(()=>{this.hasAttribute("autoplay")&&this._paused&&this.play()})}_applyTimelineDuration(e){!Number.isFinite(e)||e<=0||(this._setDuration(e),this.controlsApi?.updateTime(this._currentTime,e))}_applyVideoSize(e){e.videoWidth>0&&e.videoHeight>0&&this._setCompositionSize(e.videoWidth,e.videoHeight)}_onVideoPlayRejected(e){e instanceof DOMException&&e.name==="NotAllowedError"&&(this._paused||this.pause(),this._emit(new CustomEvent("playbackerror",{detail:{source:"video",error:e}})))}_trySyncSeek(e){if(this._videoSource)return!1;try{let i=this.iframe.contentWindow?.__player;return typeof i?.seek!="function"?!1:(i.seek.call(i,e),!0)}catch{return!1}}_withDirectTimeline(e){let t=this._videoSource?null:this.probe.resolveDirectTimelineAdapter(),i=t||this._directTimelineAdapter;if(!i)return!1;try{return e(i),t&&t!==this._directTimelineAdapter&&this._applyTimelineDuration(t.duration()),this._directTimelineAdapter=i,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(t=>{t.seek(e,!1),t.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>{e.play()})}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>{e.pause()})}_showPausedVideoTime(){this._videoSource&&(this._currentTime=this._videoSource.video.currentTime,this.controlsApi?.updateTime(this._currentTime,this._duration),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}})))}_startParentTickClock(){this._stopParentTickClock();let e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){this._videoSource||this.probe.failed||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){jn(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs,enteringRange:this._enteringRange}),setPlaybackState:({currentTime:t,duration:i,paused:r,lastUpdateMs:o,enteringRange:a})=>{this._enteringRange=a===!0,this._currentTime=t,this._setDuration(i),this._paused=r,this._lastUpdateMs=o},getShaderLoadingMode:()=>he(this),shaderLoader:this.shaderLoader,setCompositionSize:(t,i)=>this._setCompositionSize(t,i),sendControl:(t,i)=>this._sendControl(t,i),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._hasPlayRange()&&this._sendPlayRange(this._playRange()),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(t,i)=>this._resolveRuntimeDataDelivery(t,i),onRuntimeDataError:(t,i,r)=>this._rejectRuntimeDataDelivery(t,i,r),onRuntimeTimelineReady:(t,i)=>this._onRuntimeTimelineReady(t,i),setRuntimeFps:t=>{this._runtimeFps=t},setRuntimeOwnsPlayRange:t=>{this._runtimeOwnsPlayRange=t},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:t=>{this._scenes=t,this._emit(new CustomEvent("scenes",{detail:{scenes:t}}))},updateControlsTime:(t,i)=>this.controlsApi?.updateTime(t,i),updateControlsPlaying:t=>this.controlsApi?.updatePlaying(t),dispatchEvent:t=>this._emit(t),seek:t=>this.seek(t),play:()=>this.play(),getLoop:()=>this.loop,getPlayRange:()=>this._playRange(),media:this._media})}_onRuntimeTimelineReady(e,t){if(this._ready)return;this.probe.stop(),this._setDuration(e),this._directTimelineAdapter=null,this._ready=!0,this.controlsApi?.updateTime(this._currentTime,e),this._dispatchReady();let i=this._getSameOriginIframeDocument();i&&this._media.setupFromIframe(i),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(i,t),this._playWhenWanted()}_onProbeReady(e){this._applyThenEmit(()=>this._applyProbeResult(e))}_applyProbeResult({duration:e,adapter:t,compositionSize:i}){this._setDuration(e),this._directTimelineAdapter=t.kind==="direct-timeline"?t.timeline:null,i&&this._setCompositionSize(i.width,i.height),this._ready=!0,this.controlsApi?.updateTime(0,e),this._dispatchReady();let r=this._getSameOriginIframeDocument();r&&this._media.setupFromIframe(r),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(r),this._playWhenWanted()}_waitForAssetsReady(e,t){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1;let i=++this._assetsGeneration;if(!e){t===!1?(this._runtimeAssetsReadyGeneration=i,this._startAssetsLoadingOverlayTimer(i),setTimeout(()=>this._settleAssetsReady(i),St)):this._settleAssetsReady(i);return}Vn(e,({timedOut:r})=>{i===this._assetsGeneration&&(r&&this._warnStuckAssets(e),this._settleAssetsReady(i))},{timeoutMs:St}),this._assetsReady||this._startAssetsLoadingOverlayTimer(i)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(At,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},to)}_hasPendingFirstFrameAssets(e){let{pendingMedia:t,pendingImages:i,fontsLoading:r}=Oe(e,{scope:Y});return t.length>0||i.length>0||r}_warnStuckAssets(e){let{pendingMedia:t,pendingImages:i,fontsLoading:r}=Oe(e,{scope:Y}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${St}ms, playing anyway`,{stuckMedia:t.map(a=>a.currentSrc||a.getAttribute("src")||`<${a.tagName.toLowerCase()}>`),stuckImages:i.map(a=>a.currentSrc||a.getAttribute("src")||"<img>"),fontsLoading:r,computeReady:o?.__renderReady===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(At),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(At),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_dispatchReady(){this._readyDocument=this._getSameOriginIframeDocument();let e={duration:this._duration,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight};this._emit(new CustomEvent("ready",{detail:e})),this._rescale(),this._rangeClampReported="",this._hasPlayRange()&&this._applyPlayRange(!0)}_setDuration(e){e!==this._duration&&(this._duration=e,this._ready&&(this._emit(new CustomEvent("durationchange",{detail:{duration:e}})),this._hasPlayRange()&&this._applyPlayRange(!1)))}_setCompositionSize(e,t){let i=e!==this._compositionWidth||t!==this._compositionHeight;if(this._compositionWidth=e,this._compositionHeight=t,this.sizer.style.aspectRatio=`${e} / ${t}`,this._rescale(),!i)return;let r={compositionWidth:e,compositionHeight:t};this._emit(new CustomEvent("resize",{detail:r}))}_applyThenEmit(e){if(this._afterUpdate){e();return}let t=[];this._afterUpdate=t;let i=[],r=o=>{try{o()}catch(a){i.push(a)}};r(e);for(let o of t)r(o);if(this._afterUpdate=null,i.length>0)throw i[0]}_afterEvents(e){this._afterUpdate?this._afterUpdate.push(e):e()}_playWhenWanted(){this._afterEvents(()=>{(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()})}_emit(e){this._afterEvents(()=>this.dispatchEvent(e))}_rescale(){let e=kn(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=Tn(this.shadow,this.muted,this._volume,this.getAttribute("speed-presets"),{onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:e=>this.seek(e*this._duration),onScrubStart:()=>{this._scrubbing=!0},onScrubEnd:()=>{this._scrubbing=!1,this.seek(this._currentTime)},onSpeedChange:e=>{this.playbackRate=e},onMuteToggle:()=>{this.muted=!this.muted},onVolumeChange:e=>{this.volume=e}},this._isAudioLocked()),this.controlsApi.updateTime(this._currentTime,this._duration),this.controlsApi.updatePlaying(!this._paused),this.controlsApi.updateSpeed(this.playbackRate))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,t){this._media.mirrorTime(e,t)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(t,i)=>this._mirrorParentMediaTime(t,i)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}};customElements.get("hyperframes-player")||customElements.define("hyperframes-player",$e);0&&(module.exports={HyperframesPlayer,SPEED_PRESETS,formatSpeed,formatTime});
|