hyperframes 0.8.85 → 0.8.86

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,473 @@
1
+ var Ce=Object.defineProperty;var Re=(r,t,e)=>t in r?Ce(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var h=(r,t,e)=>Re(r,typeof t!="symbol"?t+"":t,e);import{r as ce,i as Le,a as b,b as pe,c as De,d as Me,s as Pe,e as me,F as fe}from"./index-d5DKK15Q.js";function xe(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function U(r){return typeof r=="object"&&r!==null}function ke(r){return U(r)&&typeof r.getDuration=="function"}function Ie(r){return U(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function Oe(r){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(r))throw new Error(`Invalid HyperFrames runtime version: ${r}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${r}/dist/hyperframe.runtime.iife.js`}const V=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Oe("0.0.0-dev");function W(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function Ne(r){const t=(r==null?void 0:r.querySelector("[data-composition-id][data-width][data-height]"))??(r==null?void 0:r.querySelector("[data-width][data-height]"));if(!t)return null;const e=W(t.getAttribute("data-width")),i=W(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}class Fe{constructor(t,e){h(this,"_interval",null);h(this,"_runtimeInjected",!1);this._iframe=t,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let t=0;this._interval=setInterval(()=>{var e;t++;try{const i=this._iframe.contentWindow;if(!i)return;const s=!!(i.__hf||i.__player),n=!!(i.__timelines&&Object.keys(i.__timelines).length>0),a=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(xe({hasRuntime:s,hasTimelines:n,hasNestedCompositions:a,runtimeInjected:this._runtimeInjected,attempts:t})){this._injectRuntime();return}if(this._runtimeInjected&&!s)return;const o=this._resolvePlaybackDurationAdapter(i);if(o&&o.getDuration()>0){this.stop();const c=Ne(this._iframe.contentDocument);this._callbacks.onReady({duration:o.getDuration(),adapter:o,compositionSize:c});return}}catch{}t>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const t=this._iframe.contentWindow;return t?this._resolveDirectTimelineAdapterFromWindow(t):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(t){return this._resolveDirectTimelineAdapterFromWindow(t)}hasRuntimeBridge(t){return Reflect.get(t,"__hf")!==void 0||U(Reflect.get(t,"__player"))}_injectRuntime(){var t,e;this._runtimeInjected=!0;try{const i=this._iframe.contentDocument;if(!i)return;const s=i.createElement("script");s.src=V,(i.head||i.documentElement).appendChild(s),(e=(t=this._callbacks).onRuntimeInjected)==null||e.call(t)}catch{}}_resolveDirectTimelineAdapterFromWindow(t){var o,c;if(this.hasRuntimeBridge(t))return null;const e=Reflect.get(t,"__timelines");if(!U(e))return null;const i=Object.keys(e);if(i.length===0)return null;const s=(c=(o=this._iframe.contentDocument)==null?void 0:o.querySelector("[data-composition-id]"))==null?void 0:c.getAttribute("data-composition-id"),n=s&&s in e?s:i[i.length-1],a=e[n];return Ie(a)?a:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ke(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const Ve=`
2
+ :host {
3
+ display: block;
4
+ position: relative;
5
+ overflow: hidden;
6
+ background: #000;
7
+ contain: layout style;
8
+ }
9
+
10
+ .hfp-container {
11
+ position: absolute;
12
+ inset: 0;
13
+ overflow: hidden;
14
+ pointer-events: none;
15
+ }
16
+
17
+
18
+ .hfp-iframe {
19
+ position: absolute;
20
+ top: 50%;
21
+ left: 50%;
22
+ border: none;
23
+ pointer-events: none;
24
+ }
25
+
26
+ /* Opt-in: an interactive composition (e.g. a live slideshow/app with playable
27
+ media or controls) — let pointer events reach the iframe content. */
28
+ :host([interactive]) .hfp-container,
29
+ :host([interactive]) .hfp-iframe {
30
+ pointer-events: auto;
31
+ }
32
+
33
+ .hfp-video {
34
+ position: absolute;
35
+ inset: 0;
36
+ width: 100%;
37
+ height: 100%;
38
+ object-fit: contain;
39
+ pointer-events: none;
40
+ }
41
+
42
+ .hfp-poster {
43
+ position: absolute;
44
+ inset: 0;
45
+ object-fit: contain;
46
+ z-index: 1;
47
+ pointer-events: none;
48
+ }
49
+
50
+ .hfp-shader-loader {
51
+ position: absolute;
52
+ inset: 0;
53
+ z-index: 20;
54
+ display: grid;
55
+ place-items: center;
56
+ visibility: hidden;
57
+ opacity: 0;
58
+ pointer-events: none;
59
+ background: #030504;
60
+ color: #f4f7fb;
61
+ cursor: default;
62
+ user-select: none;
63
+ -webkit-user-select: none;
64
+ transition: opacity 420ms ease-out, visibility 420ms ease-out;
65
+ }
66
+
67
+ .hfp-shader-loader.hfp-visible,
68
+ .hfp-shader-loader.hfp-hiding {
69
+ visibility: visible;
70
+ }
71
+
72
+ .hfp-shader-loader.hfp-visible {
73
+ opacity: 1;
74
+ pointer-events: auto;
75
+ }
76
+
77
+ .hfp-shader-loader.hfp-hiding {
78
+ opacity: 0;
79
+ pointer-events: none;
80
+ }
81
+
82
+ .hfp-shader-loader-panel {
83
+ display: grid;
84
+ grid-template-rows: 86px 40px 26px 12px 44px;
85
+ justify-items: center;
86
+ align-items: center;
87
+ gap: 8px;
88
+ width: min(620px, 82%);
89
+ text-align: center;
90
+ font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
91
+ }
92
+
93
+ .hfp-shader-loader-mark {
94
+ width: 86px;
95
+ height: 86px;
96
+ display: grid;
97
+ place-items: center;
98
+ overflow: visible;
99
+ }
100
+
101
+ .hfp-shader-loader-mark svg {
102
+ display: block;
103
+ overflow: visible;
104
+ filter: drop-shadow(0 0 5px rgba(79, 219, 94, 0.16));
105
+ pointer-events: none;
106
+ }
107
+
108
+ .hfp-shader-loader-title {
109
+ width: 100%;
110
+ height: 40px;
111
+ overflow: hidden;
112
+ white-space: nowrap;
113
+ text-overflow: ellipsis;
114
+ font-size: 26px;
115
+ line-height: 40px;
116
+ font-weight: 700;
117
+ letter-spacing: 0;
118
+ }
119
+
120
+ .hfp-shader-loader-title-text {
121
+ color: transparent;
122
+ background: linear-gradient(
123
+ 90deg,
124
+ rgba(244, 247, 251, 0.84) 0%,
125
+ #ffffff 42%,
126
+ #80efe4 52%,
127
+ #ffffff 62%,
128
+ rgba(244, 247, 251, 0.84) 100%
129
+ );
130
+ background-size: 220% 100%;
131
+ -webkit-background-clip: text;
132
+ background-clip: text;
133
+ animation: hfp-shader-loader-sheen 1.9s linear infinite;
134
+ }
135
+
136
+ .hfp-shader-loader:not(.hfp-visible):not(.hfp-hiding) .hfp-shader-loader-title-text {
137
+ animation-play-state: paused;
138
+ }
139
+
140
+ .hfp-shader-loader-detail {
141
+ width: 100%;
142
+ height: 26px;
143
+ overflow: hidden;
144
+ white-space: nowrap;
145
+ text-overflow: ellipsis;
146
+ color: rgba(244, 247, 251, 0.62);
147
+ font-size: 15px;
148
+ line-height: 26px;
149
+ font-weight: 500;
150
+ }
151
+
152
+ .hfp-shader-loader-track {
153
+ width: min(360px, 100%);
154
+ height: 8px;
155
+ overflow: hidden;
156
+ border-radius: 999px;
157
+ background: rgba(255, 255, 255, 0.1);
158
+ }
159
+
160
+ .hfp-shader-loader-fill {
161
+ width: 100%;
162
+ height: 100%;
163
+ border-radius: inherit;
164
+ background: linear-gradient(90deg, #06e3fa, #4fdb5e);
165
+ transform: scaleX(0);
166
+ transform-origin: left center;
167
+ transition: transform 160ms ease;
168
+ }
169
+
170
+ .hfp-shader-loader-progress {
171
+ width: min(420px, 100%);
172
+ height: 44px;
173
+ display: grid;
174
+ grid-template-rows: repeat(2, 22px);
175
+ color: rgba(244, 247, 251, 0.48);
176
+ font: 600 13px/22px "IBM Plex Mono", "SF Mono", "Fira Code", "Courier New", monospace;
177
+ font-variant-numeric: tabular-nums;
178
+ }
179
+
180
+ .hfp-shader-loader-row {
181
+ display: grid;
182
+ grid-template-columns: minmax(0, 1fr) 74px;
183
+ align-items: center;
184
+ column-gap: 20px;
185
+ width: 100%;
186
+ white-space: nowrap;
187
+ }
188
+
189
+ .hfp-shader-loader-label {
190
+ min-width: 0;
191
+ overflow: hidden;
192
+ text-align: left;
193
+ text-overflow: ellipsis;
194
+ }
195
+
196
+ .hfp-shader-loader-value {
197
+ text-align: right;
198
+ }
199
+
200
+ @keyframes hfp-shader-loader-sheen {
201
+ from {
202
+ background-position: 140% 0;
203
+ }
204
+ to {
205
+ background-position: -140% 0;
206
+ }
207
+ }
208
+
209
+ /* ── Theming via CSS custom properties ──
210
+ *
211
+ * Override from outside the shadow DOM:
212
+ * hyperframes-player {
213
+ * --hfp-controls-bg: linear-gradient(transparent, rgba(0,0,0,0.9));
214
+ * --hfp-accent: #ff6b6b;
215
+ * --hfp-font: "Inter", sans-serif;
216
+ * }
217
+ */
218
+
219
+ .hfp-controls {
220
+ position: absolute;
221
+ bottom: 0;
222
+ left: 0;
223
+ right: 0;
224
+ display: flex;
225
+ align-items: center;
226
+ gap: var(--hfp-controls-gap, 12px);
227
+ padding: var(--hfp-controls-padding, 8px 16px);
228
+ background: var(--hfp-controls-bg, linear-gradient(transparent, rgba(0, 0, 0, 0.7)));
229
+ color: var(--hfp-color, #fff);
230
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
231
+ font-size: var(--hfp-font-size, 13px);
232
+ z-index: 10;
233
+ pointer-events: auto;
234
+ opacity: 1;
235
+ transition: opacity 0.3s ease;
236
+ user-select: none;
237
+ }
238
+
239
+ .hfp-controls.hfp-hidden {
240
+ opacity: 0;
241
+ pointer-events: none;
242
+ }
243
+
244
+ .hfp-play-btn {
245
+ position: relative;
246
+ background: none;
247
+ border: none;
248
+ color: var(--hfp-color, #fff);
249
+ cursor: pointer;
250
+ padding: 8px;
251
+ display: flex;
252
+ align-items: center;
253
+ justify-content: center;
254
+ width: 40px;
255
+ height: 40px;
256
+ flex-shrink: 0;
257
+ z-index: 10;
258
+ }
259
+
260
+ .hfp-play-btn:hover {
261
+ opacity: 0.8;
262
+ }
263
+
264
+ /* Stacked play/pause glyphs that crossfade-morph on toggle (rotate + scale). */
265
+ .hfp-play-btn .hfp-ico {
266
+ position: absolute;
267
+ display: flex;
268
+ align-items: center;
269
+ justify-content: center;
270
+ transition:
271
+ opacity 200ms ease,
272
+ transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
273
+ }
274
+ .hfp-play-btn .hfp-ico-play {
275
+ opacity: 1;
276
+ transform: rotate(0) scale(1);
277
+ }
278
+ .hfp-play-btn .hfp-ico-pause {
279
+ opacity: 0;
280
+ transform: rotate(-90deg) scale(0.4);
281
+ }
282
+ .hfp-play-btn.hfp-playing .hfp-ico-play {
283
+ opacity: 0;
284
+ transform: rotate(90deg) scale(0.4);
285
+ }
286
+ .hfp-play-btn.hfp-playing .hfp-ico-pause {
287
+ opacity: 1;
288
+ transform: rotate(0) scale(1);
289
+ }
290
+ @media (prefers-reduced-motion: reduce) {
291
+ .hfp-play-btn .hfp-ico {
292
+ transition-duration: 0ms;
293
+ transform: none;
294
+ }
295
+ }
296
+
297
+ .hfp-play-btn svg,
298
+ .hfp-play-btn svg * {
299
+ pointer-events: none;
300
+ }
301
+
302
+ .hfp-scrubber {
303
+ flex: 1;
304
+ min-width: 0;
305
+ height: var(--hfp-scrubber-height, 4px);
306
+ background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
307
+ border-radius: var(--hfp-scrubber-radius, 2px);
308
+ cursor: pointer;
309
+ position: relative;
310
+ overflow: hidden;
311
+ }
312
+
313
+ .hfp-scrubber:hover {
314
+ height: var(--hfp-scrubber-height-hover, 6px);
315
+ }
316
+
317
+ .hfp-progress {
318
+ position: absolute;
319
+ top: 0;
320
+ left: 0;
321
+ height: 100%;
322
+ background: var(--hfp-accent, #fff);
323
+ pointer-events: none;
324
+ }
325
+
326
+ .hfp-time {
327
+ flex-shrink: 0;
328
+ font-variant-numeric: tabular-nums;
329
+ opacity: 0.9;
330
+ }
331
+
332
+ .hfp-speed-wrap {
333
+ position: relative;
334
+ flex-shrink: 0;
335
+ }
336
+
337
+ .hfp-speed-btn {
338
+ background: var(--hfp-speed-btn-bg, rgba(255, 255, 255, 0.15));
339
+ border: none;
340
+ border-radius: var(--hfp-speed-btn-radius, 4px);
341
+ color: var(--hfp-color, #fff);
342
+ cursor: pointer;
343
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
344
+ font-size: 12px;
345
+ font-variant-numeric: tabular-nums;
346
+ font-weight: 600;
347
+ padding: 4px 8px;
348
+ min-width: 40px;
349
+ text-align: center;
350
+ transition: background 0.15s ease;
351
+ }
352
+
353
+ .hfp-speed-btn:hover {
354
+ background: var(--hfp-speed-btn-bg-hover, rgba(255, 255, 255, 0.3));
355
+ }
356
+
357
+ .hfp-speed-menu {
358
+ position: absolute;
359
+ bottom: calc(100% + 8px);
360
+ right: 0;
361
+ background: var(--hfp-menu-bg, rgba(20, 20, 20, 0.95));
362
+ backdrop-filter: blur(12px);
363
+ -webkit-backdrop-filter: blur(12px);
364
+ border: 1px solid var(--hfp-menu-border, rgba(255, 255, 255, 0.1));
365
+ border-radius: var(--hfp-menu-radius, 8px);
366
+ padding: 4px;
367
+ display: flex;
368
+ flex-direction: column;
369
+ gap: 2px;
370
+ min-width: 80px;
371
+ opacity: 0;
372
+ visibility: hidden;
373
+ transform: translateY(4px);
374
+ transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
375
+ box-shadow: var(--hfp-menu-shadow, 0 8px 24px rgba(0, 0, 0, 0.4));
376
+ }
377
+
378
+ .hfp-speed-menu.hfp-open {
379
+ opacity: 1;
380
+ visibility: visible;
381
+ transform: translateY(0);
382
+ }
383
+
384
+ .hfp-speed-option {
385
+ background: none;
386
+ border: none;
387
+ border-radius: 4px;
388
+ color: var(--hfp-menu-color, rgba(255, 255, 255, 0.7));
389
+ cursor: pointer;
390
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
391
+ font-size: 13px;
392
+ font-variant-numeric: tabular-nums;
393
+ padding: 6px 12px;
394
+ text-align: left;
395
+ transition: background 0.1s ease, color 0.1s ease;
396
+ white-space: nowrap;
397
+ }
398
+
399
+ .hfp-speed-option:hover {
400
+ background: var(--hfp-menu-hover-bg, rgba(255, 255, 255, 0.1));
401
+ color: var(--hfp-color, #fff);
402
+ }
403
+
404
+ .hfp-speed-option.hfp-active {
405
+ color: var(--hfp-accent, #fff);
406
+ font-weight: 600;
407
+ }
408
+
409
+ .hfp-volume-wrap {
410
+ position: relative;
411
+ flex-shrink: 0;
412
+ display: flex;
413
+ align-items: center;
414
+ gap: 0;
415
+ }
416
+
417
+ .hfp-mute-btn {
418
+ background: none;
419
+ border: none;
420
+ color: var(--hfp-color, #fff);
421
+ cursor: pointer;
422
+ padding: 4px;
423
+ display: flex;
424
+ align-items: center;
425
+ justify-content: center;
426
+ width: 32px;
427
+ height: 32px;
428
+ flex-shrink: 0;
429
+ }
430
+
431
+ .hfp-mute-btn:hover {
432
+ opacity: 0.8;
433
+ }
434
+
435
+ .hfp-mute-btn svg,
436
+ .hfp-mute-btn svg * {
437
+ pointer-events: none;
438
+ }
439
+
440
+ .hfp-volume-slider-wrap {
441
+ width: 0;
442
+ overflow: hidden;
443
+ transition: width 0.2s ease;
444
+ display: flex;
445
+ align-items: center;
446
+ }
447
+
448
+ .hfp-volume-wrap:hover .hfp-volume-slider-wrap {
449
+ width: 64px;
450
+ }
451
+
452
+ .hfp-volume-slider {
453
+ width: 56px;
454
+ height: var(--hfp-scrubber-height, 4px);
455
+ background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
456
+ border-radius: var(--hfp-scrubber-radius, 2px);
457
+ cursor: pointer;
458
+ position: relative;
459
+ overflow: hidden;
460
+ margin-left: 4px;
461
+ margin-right: 4px;
462
+ }
463
+
464
+ .hfp-volume-fill {
465
+ position: absolute;
466
+ top: 0;
467
+ left: 0;
468
+ height: 100%;
469
+ background: var(--hfp-accent, #fff);
470
+ pointer-events: none;
471
+ }
472
+ `,He='<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>',Ue='<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>',_e='<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>',ge='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/></svg>',We='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z" opacity="0.3"/><line x1="18" y1="7" x2="14" y2="17" stroke="currentColor" stroke-width="2"/></svg>',ze=[.25,.5,1,1.5,2,4];function $(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function ye(r){if(!Number.isFinite(r)||r<0)return"0:00";const t=Math.floor(r),e=Math.floor(t/60),i=t%60;return`${e}:${i.toString().padStart(2,"0")}`}function $e(r,t,e={}){const i=e.speedPresets??ze,s=document.createElement("div");s.className="hfp-controls",s.addEventListener("click",d=>{d.stopPropagation()});const n=document.createElement("button");n.className="hfp-play-btn",n.type="button",n.innerHTML=`<span class="hfp-ico hfp-ico-play">${He}</span><span class="hfp-ico hfp-ico-pause">${Ue}</span>`,n.setAttribute("aria-label","Play");const a=document.createElement("div");a.className="hfp-scrubber";const o=document.createElement("div");o.className="hfp-progress",o.style.width="0%",a.appendChild(o);const c=document.createElement("span");c.className="hfp-time",c.textContent="0:00 / 0:00";const p=document.createElement("div");p.className="hfp-speed-wrap";const u=document.createElement("button");u.className="hfp-speed-btn",u.type="button",u.textContent="1x",u.setAttribute("aria-label","Playback speed");const g=document.createElement("div");g.className="hfp-speed-menu",g.setAttribute("role","menu");for(const d of i){const l=document.createElement("button");l.className="hfp-speed-option",l.type="button",l.setAttribute("role","menuitem"),l.dataset.speed=String(d),l.textContent=$(d),d===1&&l.classList.add("hfp-active"),g.appendChild(l)}p.appendChild(g),p.appendChild(u);const f=document.createElement("div");f.className="hfp-volume-wrap";const m=document.createElement("button");m.className="hfp-mute-btn",m.type="button",m.innerHTML=_e,m.setAttribute("aria-label","Mute");const w=document.createElement("div");w.className="hfp-volume-slider-wrap";const _=document.createElement("div");_.className="hfp-volume-slider",_.setAttribute("role","slider"),_.setAttribute("aria-label","Volume"),_.setAttribute("aria-valuemin","0"),_.setAttribute("aria-valuemax","100"),_.setAttribute("aria-valuenow","100"),_.tabIndex=0;const v=document.createElement("div");v.className="hfp-volume-fill",v.style.width="100%",_.appendChild(v),w.appendChild(_),f.appendChild(w),f.appendChild(m),e.audioLocked&&(f.style.display="none"),s.appendChild(n),s.appendChild(a),s.appendChild(c),s.appendChild(f),s.appendChild(p),r.appendChild(s);let M=!1,E=!1,T=1,R=null;i.indexOf(1);const P=(d,l)=>d?We:l===0||l<.5?ge:_e;n.addEventListener("click",d=>{d.stopPropagation(),M?t.onPause():t.onPlay()}),m.addEventListener("click",d=>{d.stopPropagation(),t.onMuteToggle()});let S=!1;const x=d=>{const l=_.getBoundingClientRect(),y=Math.max(0,Math.min(1,(d-l.left)/l.width));T=y,v.style.width=`${y*100}%`,_.setAttribute("aria-valuenow",String(Math.round(y*100))),E&&y>0&&t.onMuteToggle(),m.innerHTML=P(E,y),t.onVolumeChange(y)};_.addEventListener("mousedown",d=>{d.stopPropagation(),S=!0,x(d.clientX)});const Q=d=>{S&&x(d.clientX)},J=()=>{S=!1};document.addEventListener("mousemove",Q),document.addEventListener("mouseup",J),_.addEventListener("touchstart",d=>{S=!0;const l=d.touches[0];l&&x(l.clientX)},{passive:!0});const ee=d=>{if(S){const l=d.touches[0];l&&x(l.clientX)}},te=()=>{S=!1};document.addEventListener("touchmove",ee,{passive:!0}),document.addEventListener("touchend",te);const ie=.05;_.addEventListener("keydown",d=>{let l=T;if(d.key==="ArrowRight"||d.key==="ArrowUp")l=Math.min(1,T+ie);else if(d.key==="ArrowLeft"||d.key==="ArrowDown")l=Math.max(0,T-ie);else return;d.preventDefault(),d.stopPropagation(),T=l,v.style.width=`${l*100}%`,_.setAttribute("aria-valuenow",String(Math.round(l*100))),E&&l>0&&t.onMuteToggle(),m.innerHTML=P(E,l),t.onVolumeChange(l)});const se=d=>{for(const l of g.querySelectorAll(".hfp-speed-option"))l.classList.toggle("hfp-active",l.dataset.speed===String(d))};u.addEventListener("click",d=>{d.stopPropagation();const l=g.classList.toggle("hfp-open");u.setAttribute("aria-expanded",String(l))}),g.addEventListener("click",d=>{d.stopPropagation();const l=d.target.closest(".hfp-speed-option");if(!l)return;const y=parseFloat(l.dataset.speed);i.indexOf(y),u.textContent=$(y),se(y),g.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false"),t.onSpeedChange(y)});const re=()=>{g.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false")};document.addEventListener("click",re);const k=d=>{const l=a.getBoundingClientRect(),y=Math.max(0,Math.min(1,(d-l.left)/l.width));t.onSeek(y)};let A=!1;a.addEventListener("mousedown",d=>{var l;d.stopPropagation(),A=!0,(l=t.onScrubStart)==null||l.call(t),k(d.clientX)});const ne=d=>{A&&k(d.clientX)},oe=()=>{var d;A&&(A=!1,(d=t.onScrubEnd)==null||d.call(t))};document.addEventListener("mousemove",ne),document.addEventListener("mouseup",oe),a.addEventListener("touchstart",d=>{var y;A=!0,(y=t.onScrubStart)==null||y.call(t);const l=d.touches[0];l&&k(l.clientX)},{passive:!0});const ae=d=>{if(A){const l=d.touches[0];l&&k(l.clientX)}},de=()=>{var d;A&&(A=!1,(d=t.onScrubEnd)==null||d.call(t))};document.addEventListener("touchmove",ae,{passive:!0}),document.addEventListener("touchend",de);const he=()=>{R&&clearTimeout(R),R=setTimeout(()=>{M&&s.classList.add("hfp-hidden")},3e3)},I=r instanceof ShadowRoot?r.host:r,ue=()=>{s.classList.remove("hfp-hidden"),he()},le=()=>{M&&s.classList.add("hfp-hidden")};return I.addEventListener("mousemove",ue),I.addEventListener("mouseleave",le),{updateTime(d,l){const y=l>0?Math.min(d,l):d,Se=l>0?y/l*100:0;o.style.width=`${Se}%`,c.textContent=`${ye(y)} / ${ye(l)}`},updatePlaying(d){M=d,n.classList.toggle("hfp-playing",d),n.setAttribute("aria-label",d?"Pause":"Play"),d?he():s.classList.remove("hfp-hidden")},updateSpeed(d){i.indexOf(d),u.textContent=$(d),se(d)},updateMuted(d){E=d,m.innerHTML=P(d,T),m.setAttribute("aria-label",d?"Unmute":"Mute")},updateVolume(d){T=d,v.style.width=`${d*100}%`,_.setAttribute("aria-valuenow",String(Math.round(d*100))),m.innerHTML=P(E,d)},setVolumeControlsHidden(d){f.style.display=d?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",ne),document.removeEventListener("mouseup",oe),document.removeEventListener("touchmove",ae),document.removeEventListener("touchend",de),document.removeEventListener("mousemove",Q),document.removeEventListener("mouseup",J),document.removeEventListener("touchmove",ee),document.removeEventListener("touchend",te),document.removeEventListener("click",re),I.removeEventListener("mousemove",ue),I.removeEventListener("mouseleave",le),R&&clearTimeout(R),s.remove()}}}function je(r,t,e,i,s,n=!1){const a=i?i.split(",").map(Number).filter(p=>!isNaN(p)&&p>0):void 0,o={...a?{speedPresets:a}:{},audioLocked:n},c=$e(r,s,o);return c.updateMuted(t),c.updateVolume(e),c}function ve(r,t,e){return t?(e||(e=document.createElement("img"),e.className="hfp-poster",r.appendChild(e)),e.src=t,e):(e==null||e.remove(),null)}function qe(r){return r.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("hfp-controls"))}let O=null;function Be(r,t){if(typeof CSSStyleSheet<"u")try{O||(O=new CSSStyleSheet,O.replaceSync(t)),r.adoptedStyleSheets=[O];return}catch{}const e=document.createElement("style");e.textContent=t,r.appendChild(e)}function Ge(){const r=document.createElement("div");r.className="hfp-container";const t=document.createElement("iframe");return t.className="hfp-iframe",t.sandbox.add("allow-scripts","allow-same-origin"),t.allow="autoplay; fullscreen",t.referrerPolicy="no-referrer",t.title="HyperFrames Composition",r.appendChild(t),{container:r,iframe:t}}function Ye(r,t,e,i){const s=r.offsetWidth,n=r.offsetHeight;if(s===0||n===0)return!1;const a=Math.min(s/e,n/i);return t.style.width=`${e}px`,t.style.height=`${i}px`,t.style.transform=`translate(-50%, -50%) scale(${a})`,!0}const Xe=100;class Ze{constructor(t){h(this,"_raf",null);h(this,"_lastUpdateMs",0);this._callbacks=t}start(t,e,i,s){this.stop();const n=()=>{if(s()){this._raf=null;return}let a;try{a=t.time()}catch{this._raf=null;return}const o=i();o>0&&(a=Math.min(a,o));const c=o>0&&a>=o,p=performance.now();if((p-this._lastUpdateMs>Xe||c)&&(this._lastUpdateMs=p,this._callbacks.onTimeUpdate(a,o)),c){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{t.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(n)};this._raf=requestAnimationFrame(n)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function Ke(r){const t=Array.from(r.querySelectorAll("[data-composition-id]"));if(t.length===0)return r.body?[r.body]:[];const e=[];for(const i of t)Je(i)||e.push(i);return Qe(r),e}function Qe(r){const t=r.body;if(!t||typeof console>"u"||typeof console.warn!="function")return;const e=t.querySelectorAll("audio[data-start], video[data-start]");if(e.length===0)return;const i=[];for(const s of e)s.closest("[data-composition-id]")||i.push(s);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 Je(r){let t=r.parentElement;for(;t;){if(t.hasAttribute("data-composition-id"))return!0;t=t.parentElement}return!1}const et=.05,tt=2;class it{constructor(t){h(this,"_entries",[]);h(this,"_mediaObserver");h(this,"_playbackErrorPosted",!1);h(this,"_audioOwner","runtime");h(this,"_urlAudioEntry",null);h(this,"_urlAudioSrc",null);h(this,"_dispatchEvent");h(this,"_getMuted");h(this,"_getVolume");h(this,"_getPlaybackRate");h(this,"_getCurrentTime");h(this,"_isPaused");this._dispatchEvent=t.dispatchEvent,this._getMuted=t.getMuted,this._getVolume=t.getVolume,this._getPlaybackRate=t.getPlaybackRate,this._getCurrentTime=t.getCurrentTime,this._isPaused=t.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;const t=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll();for(const e of this._entries)e!==this._urlAudioEntry&&(e.el.src="");this._entries=this._urlAudioEntry?[this._urlAudioEntry]:[],this._urlAudioSrc&&!this._urlAudioEntry&&(this._urlAudioEntry=this._createEntry(this._urlAudioSrc,"audio",0,1/0)),this.teardownObserver(),t&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(const t of this._entries)t.el.pause(),t.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(t){for(const e of this._entries)e.el.muted=t}updateVolume(t){for(const e of this._entries)e.el.volume=t}updatePlaybackRate(t){for(const e of this._entries)e.el.playbackRate=t}_playEntry(t){t.el.src&&t.el.play().catch(e=>this._reportPlaybackError(e))}_playEntryIfActive(t){this._refreshEntryBounds(t),this._inWindow(t,this._getCurrentTime())&&this._playEntry(t)}_refreshEntryBounds(t){var i;if(!((i=t.source)!=null&&i.isConnected))return;const e=ce(t.source);t.start=e.start??0,t.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(t,e){return Le(e,t.start,t.start+t.duration)}_gateEntryPlayback(t,e){return this._inWindow(t,e)?(this._audioOwner==="parent"&&!this._isPaused()&&t.el.paused&&this._playEntry(t),!0):(t.el.paused||t.el.pause(),t.driftSamples=0,!1)}playAll(){for(const t of this._entries)this._playEntryIfActive(t)}pauseAll(){for(const t of this._entries)t.el.pause()}stopAdoptedMedia(){for(const t of this._entries)t.source&&t.el.pause()}seekAll(t){for(const e of this._entries)this._refreshEntryBounds(e),this._inWindow(e,t)&&(e.el.currentTime=t-e.start)}scrubAll(t){for(const e of this._entries)this._refreshEntryBounds(e),this._inWindow(e,t)?(e.el.currentTime=t-e.start,this._playEntry(e)):e.el.paused||e.el.pause()}mirrorTime(t,e){const i=(e==null?void 0:e.force)===!0;for(const s of this._entries){if(this._refreshEntryBounds(s),!this._gateEntryPlayback(s,t))continue;const n=t-s.start;Math.abs(s.el.currentTime-n)>et?(s.driftSamples+=1,(i||s.driftSamples>=tt)&&(s.el.currentTime=n,s.driftSamples=0)):s.driftSamples=0}}promoteToParentProxy(t,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",t)for(const s of t.querySelectorAll("video, audio"))b(s)&&(s.muted=!0);for(const s of[...this._entries])this._repointToSource(s);const i=this._getCurrentTime();e?e(i,{force:!0}):this.mirrorTime(i,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(t){const e=t.querySelectorAll("audio[data-start], video[data-start]");for(const i of e)b(i)&&this._adoptIframeMedia(i);this._observeDynamicMedia(t)}setupFromUrl(t){if(this._urlAudioSrc===t&&this._urlAudioEntry)return;this.teardownUrlAudio();const e=this._createEntry(t,"audio",0,1/0);this._urlAudioEntry=e,this._urlAudioSrc=t,e&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){const t=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!t)return;t.el.pause(),t.el.src="";const e=this._entries.indexOf(t);e!==-1&&this._entries.splice(e,1)}teardownObserver(){var t;(t=this._mediaObserver)==null||t.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(t){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:t}})))}_createEntry(t,e,i,s,n){if(this._urlTaken(t))return null;const a=e==="video"?document.createElement("video"):new Audio;a.preload="auto",a.src=t,a.load(),a.muted=this._getMuted(),a.volume=this._getVolume();const o=this._getPlaybackRate();o!==1&&(a.playbackRate=o);const c={el:a,start:i,duration:s,driftSamples:0,source:n};return this._entries.push(c),c}_resolveIframeMediaSrc(t){var i;const e=t.getAttribute("src")||((i=t.querySelector("source"))==null?void 0:i.getAttribute("src"));return e?new URL(e,t.ownerDocument.baseURI).href:null}_adoptIframeMedia(t){if(t.preload==="metadata"||t.preload==="none")return;const e=this._resolveIframeMediaSrc(t);if(!e)return;const i=ce(t),s=i.start??0,n=i.duration??Number.POSITIVE_INFINITY,a=t.tagName==="VIDEO"?"video":"audio",o=this._createEntry(e,a,s,n,t);o&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(o))}_followIframeMediaSrc(t){const e=this._entries.find(i=>i.source===t);if(!e)return this._adoptIframeMedia(t);this._audioOwner!=="parent"||!this._repointToSource(e)||(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(e))}_urlTaken(t,e){return this._entries.some(i=>i===e||i.source&&!i.source.isConnected?!1:(i.source&&this._resolveIframeMediaSrc(i.source)||i.el.src)===t)}_repointToSource(t){const e=t.source?this._resolveIframeMediaSrc(t.source):null;return!e||t.el.src===e?!1:this._urlTaken(e,t)?(this._removeEntry(t),!1):(t.el.src=e,t.el.load(),!0)}_detachIframeMedia(t){const e=this._entries.find(i=>i.source===t);e&&this._removeEntry(e)}_removeEntry(t){t.el.pause(),t.el.src="",this._entries.splice(this._entries.indexOf(t),1)}_observeDynamicMedia(t){if(this.teardownObserver(),typeof MutationObserver>"u"||!t.body)return;const e=new MutationObserver(n=>{for(const a of n){if(a.type==="attributes"&&a.attributeName==="src"){const o=a.target;b(o)&&o.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(o);continue}if(a.type==="attributes"&&a.attributeName==="preload"){const o=a.target;b(o)&&o.matches("audio[data-start], video[data-start]")&&o.preload==="auto"&&this._adoptIframeMedia(o);continue}for(const o of a.addedNodes){if(!pe(o))continue;const c=[];b(o)&&o.matches("audio[data-start], video[data-start]")&&c.push(o);const p=o.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)b(u)&&c.push(u);for(const u of c)this._adoptIframeMedia(u)}for(const o of a.removedNodes){if(!pe(o))continue;const c=[];b(o)&&o.matches("audio[data-start], video[data-start]")&&c.push(o);const p=o.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)b(u)&&c.push(u);for(const u of c)this._detachIframeMedia(u)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},s=Ke(t);for(const n of s)e.observe(n,i);this._mediaObserver=e}}const st=100;function rt(r,t){return typeof r.currentTime=="number"&&Number.isFinite(r.currentTime)?r.currentTime:(r.frame??0)/t}function nt(r,t,e){return e<=0?!1:r.ended===!0?!0:r.ended===!1&&!r.isPlaying?!1:t>=e}function ot(r,t,e,i){const s=rt(r,t),n=nt(r,s,e.duration),a=e.duration>0?Math.min(s,e.duration):s,o=n?e.duration:a,c=!e.paused,p=!r.isPlaying,u=n&&(c||r.isPlaying);if(u&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(0),i.play(),{...e,currentTime:0,paused:!1};const g={...e,currentTime:o,paused:p};i.media.audioOwner==="parent"&&(c&&p?i.media.pauseAll():!c&&!p&&i.media.playAll(),i.media.mirrorTime(o));const f=performance.now(),m=p!==e.paused;return(f-e.lastUpdateMs>st||m)&&(g.lastUpdateMs=f,i.updateControlsTime(o,e.duration),i.updateControlsPlaying(!p),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:o}}))),u&&(i.media.audioOwner==="parent"&&i.media.pauseAll(),g.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),g}function at(r){return Array.isArray(r)?r.filter(t=>typeof t=="object"&&t!==null&&typeof t.id=="string"&&typeof t.start=="number"&&typeof t.duration=="number"):[]}function dt(r,t,e){var n,a,o,c,p;if(r.source!==t)return;const i=r.data;if(!i||i.source!=="hf-preview")return;const s=De(i);if(s.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:s.code,receivedVersion:s.receivedVersion}}));return}if((n=e.setRuntimeFps)==null||n.call(e,s.fps),i.type==="shader-transition-state"){const u=i.state&&typeof i.state=="object"?i.state:{};e.shaderLoader.update(u,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:u}}));return}if(i.type==="ready"){e.onRuntimeReady();return}if(i.type==="assets-ready"){(a=e.onRuntimeAssetsReady)==null||a.call(e,i.timedOut===!0);return}if(i.type==="runtime-data-error"){(o=e.onRuntimeDataError)==null||o.call(e,i.channel,i.requestId,i.message);return}if(i.type==="runtime-data-applied"){(c=e.onRuntimeDataApplied)==null||c.call(e,i.channel,i.requestId);return}if(i.type==="state"){e.setPlaybackState(ot({frame:i.frame??0,currentTime:i.currentTime,ended:typeof i.ended=="boolean"?i.ended:void 0,isPlaying:!!i.isPlaying},s.fps,e.getPlaybackState(),e));return}if(i.type==="media-autoplay-blocked"){if(((p=e.shouldPromoteMediaAutoplayFallback)==null?void 0:p.call(e))===!1)return;let u=null;try{u=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(u,(g,f)=>e.media.mirrorTime(g,f)),e.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){const u=Number(i.durationSeconds),g=Number(i.durationInFrames),f=Number.isFinite(u)&&u>0?u:g/s.fps;if(Number.isFinite(i.compositionWidth)&&i.compositionWidth>0&&Number.isFinite(i.compositionHeight)&&i.compositionHeight>0&&e.setCompositionSize(i.compositionWidth,i.compositionHeight),Number.isFinite(f)&&f>0){const m=e.getPlaybackState();e.setPlaybackState({...m,duration:f}),e.updateControlsTime(m.currentTime,f),e.onRuntimeTimelineReady(f,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}e.setScenes(at(i.scenes));return}i.type==="stage-size"&&Number.isFinite(i.width)&&i.width>0&&Number.isFinite(i.height)&&i.height>0&&e.setCompositionSize(i.width,i.height)}function ht(r,t){return r.includes(t)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}const ut=new Set([">"," "," ",`
473
+ `,"\r","\f"]);function j(r,t){const e=r.toLowerCase(),i=`<${t}`;let s=0;for(;s<e.length;){const n=e.indexOf(i,s);if(n<0)return null;const a=e[n+i.length];if(ut.has(a)){const o=e.indexOf(">",n+i.length);return o<0?null:{index:n,end:o+1}}s=n+i.length}return null}function lt(r,t){if(!r||ht(r,t))return r;const e=`<script src="${t}"><\/script>`,i=j(r,"head");if(i)return r.slice(0,i.end)+e+r.slice(i.end);const s=j(r,"body");if(s)return r.slice(0,s.index)+e+r.slice(s.index);const n=j(r,"html");return n?r.slice(0,n.end)+e+r.slice(n.end):e+r}const C="shader-capture-scale",D="shader-loading",Z="runtime-src",be="__hf_shader_capture_scale",we="__hf_shader_loading",H=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function K(r){if(r===null)return null;const t=Number(r);return!Number.isFinite(t)||t<=0?null:String(Math.min(1,Math.max(.25,t)))}function ct(r){if(r===null||r.trim()==="")return"composition";const t=r.trim().toLowerCase();return t==="none"||t==="false"||t==="0"||t==="off"?"none":t==="player"||t==="true"||t==="1"||t==="on"?"player":"composition"}function Ae(r,t){return r.filter(e=>e!==""&&e.split("=")[0]!==t)}function pt(r,t,e){const i=r.indexOf("#"),s=i>=0?r.slice(0,i):r,n=i>=0?r.slice(i):"",a=s.indexOf("?"),o=a>=0?s.slice(0,a):s,c=a>=0?s.slice(a+1):"";let p=Ae(c.split("&"),be);p=Ae(p,we),t!==null&&p.push(`${be}=${encodeURIComponent(t)}`),e!=="composition"&&p.push(`${we}=${encodeURIComponent(e)}`);const u=p.join("&");return`${o}${u?`?${u}`:""}${n}`}function mt(r,t,e){if(t===null&&e==="composition")return r;const i=[];t!==null&&i.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(t)};`),e!=="composition"&&i.push(`window.__HF_SHADER_LOADING=${JSON.stringify(e)};`);const s=`<script data-hyperframes-player-shader-options>${i.join("")}<\/script>`;return/<head\b[^>]*>/i.test(r)?r.replace(/<head\b[^>]*>/i,n=>`${n}${s}`):/<html\b[^>]*>/i.test(r)?r.replace(/<html\b[^>]*>/i,n=>`${n}${s}`):`${s}${r}`}function z(r){return ct(r.getAttribute(D))}function ft(r){return Number(K(r.getAttribute(C))??"1")}function _t(r,t){return pt(t,K(r.getAttribute(C)),z(r))}function N(r,t){return lt(mt(t,K(r.getAttribute(C)),z(r)),gt(r))}function gt(r){var e;const t=(e=r.getAttribute(Z))==null?void 0:e.trim();if(!t)return V;try{const i=new URL(t,document.baseURI),s=i.protocol==="http:"||i.protocol==="https:",n=i.hostname==="127.0.0.1"||i.hostname==="localhost"||i.hostname==="[::1]";return s&&(n||i.origin===location.origin)?i.href:V}catch{return V}}function yt(){const r=document.createElement("div");r.className="hfp-shader-loader",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.setAttribute("aria-label","Preparing scene transitions"),r.setAttribute("data-hyperframes-ignore",""),r.draggable=!1;const t=m=>{m.preventDefault(),m.stopPropagation()};for(const m of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(m,t,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const 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("");const s=document.createElement("div");s.className="hfp-shader-loader-title";const n=document.createElement("span");n.className="hfp-shader-loader-title-text",n.textContent=H[0],s.appendChild(n);const a=document.createElement("div");a.className="hfp-shader-loader-detail",a.textContent="Rendering animated scene samples for shader transitions.";const o=document.createElement("div");o.className="hfp-shader-loader-track",o.setAttribute("aria-hidden","true");const c=document.createElement("div");c.className="hfp-shader-loader-fill",o.appendChild(c);const p=document.createElement("div");p.className="hfp-shader-loader-progress";const u=m=>{const w=document.createElement("div");w.className="hfp-shader-loader-row";const _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=m;const v=document.createElement("span");return v.className="hfp-shader-loader-value",w.appendChild(_),w.appendChild(v),p.appendChild(w),{row:w,label:_,value:v}},g=u("transition"),f=u("transition frame");return e.appendChild(i),e.appendChild(s),e.appendChild(a),e.appendChild(o),e.appendChild(p),r.appendChild(e),{root:r,fill:c,title:n,detail:a,transitionValue:g.value,transitionRow:g.row,frameLabel:f.label,frameValue:f.value,frameRow:f.row}}const vt=420;function F(r,t,e){t.textContent=e,r.style.visibility=e?"visible":"hidden"}class bt{constructor(t){h(this,"_el");h(this,"_hideTimeout",null);h(this,"_hiddenCallbacks",[]);h(this,"_drawingAssets",!1);this._el=t}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(t){const e=this._el.root.classList;e.contains("hfp-visible")||e.contains("hfp-hiding")?this._hiddenCallbacks.push(t):t()}_flushHidden(){const t=this._hiddenCallbacks;this._hiddenCallbacks=[];for(const e of t)e()}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._drawingAssets=!1,this._flushHidden(),this._el.fill.style.transform="scaleX(0)",F(this._el.transitionRow,this._el.transitionValue,""),F(this._el.frameRow,this._el.frameValue,"")}update(t,e){const i=e==="player"&&t.loading&&!t.ready;if(this._drawingAssets&&!i)return;if(e!=="player"){this.reset();return}if(t.ready||!t.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions"),this._drawingAssets=!1;const s=typeof t.progress=="number"&&Number.isFinite(t.progress)?t.progress:0,n=typeof t.total=="number"&&Number.isFinite(t.total)?t.total:0,a=n>0?Math.min(1,Math.max(0,s/n)):0,o=Math.min(H.length-1,Math.floor(a*H.length));this._el.title.textContent=H[o]||"Preparing scene transitions",this._el.detail.textContent=t.phase==="cached"?"Loading cached transition frames before playback.":t.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${a})`;const c=t.currentTransition!==void 0&&t.transitionTotal!==void 0?`${t.currentTransition}/${t.transitionTotal}`:n>0?`${s}/${n}`:"",p=t.transitionFrame!==void 0&&t.transitionFrames!==void 0?`${t.transitionFrame}/${t.transitionFrames}`:"";this._el.frameLabel.textContent=t.phase==="cached"?"cached transition frames":t.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",F(this._el.transitionRow,this._el.transitionValue,c),F(this._el.frameRow,this._el.frameValue,p),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()},vt)}}function wt(r){return(r==null?void 0:r.trim().toLowerCase().startsWith("video/"))??!1}function At(r){const t=document.createElement("video");t.className="hfp-video",t.playsInline=!0,t.preload="metadata";const e=new AbortController,{signal:i}=e;return t.addEventListener("loadedmetadata",()=>r.onMetadata(t),{signal:i}),t.addEventListener("durationchange",()=>r.onDurationChange(t),{signal:i}),t.addEventListener("resize",()=>r.onResize(t),{signal:i}),t.addEventListener("play",()=>r.onPlay(t),{signal:i}),t.addEventListener("pause",()=>r.onPause(t),{signal:i}),t.addEventListener("error",()=>{var n,a;return r.onError(((n=t.error)==null?void 0:n.message)||"Video failed to load",((a=t.error)==null?void 0:a.code)??null)},{signal:i}),{video:t,adapter:{duration:()=>t.duration,time:()=>t.currentTime,seek:n=>{t.currentTime=n},play:()=>t.play().catch(n=>{i.aborted||r.onPlayRejected(n)}),pause:()=>t.pause(),timeScale:n=>{t.defaultPlaybackRate=n,t.playbackRate=n}},destroy:()=>{e.abort(),t.pause(),t.removeAttribute("src"),t.load(),t.remove()}}}const Tt=.1,Et=5,q="sandbox-origin",Te=1e4,B=8e3,G="assets-loading",L="assets-loading-ui",Y="low-power-idle",Ee="disable-click-to-play",St=150;function X(r){return!Number.isFinite(r)||r<=0?1:Math.max(Tt,Math.min(Et,r))}class Ct extends HTMLElement{constructor(){super();h(this,"shadow");h(this,"container");h(this,"iframe");h(this,"posterEl",null);h(this,"controlsApi",null);h(this,"resizeObserver");h(this,"shaderLoader");h(this,"probe");h(this,"_ready",!1);h(this,"_readyDocument",null);h(this,"_connected",!1);h(this,"_assetsReady",!1);h(this,"_painted",!1);h(this,"_pendingPlay",!1);h(this,"_assetsGeneration",0);h(this,"_assetsLoadingShowTimer",null);h(this,"_currentTime",0);h(this,"_duration",0);h(this,"_paused",!0);h(this,"_scrubbing",!1);h(this,"_lastUpdateMs",0);h(this,"_volume",1);h(this,"_compositionWidth",1920);h(this,"_compositionHeight",1080);h(this,"_rescaleWarned",!1);h(this,"_directTimelineAdapter",null);h(this,"_directTimelineClock");h(this,"_parentTickRaf",null);h(this,"_media");h(this,"_scenes",[]);h(this,"_runtimeFps",30);h(this,"_runtimeBridgeReady",!1);h(this,"_runtimeAssetsReadyGeneration",-1);h(this,"_runtimeData",new Map);h(this,"_runtimeDataRequestId",0);h(this,"_pendingRuntimeData",new Map);h(this,"_afterUpdate",null);h(this,"_videoSource",null);this.shadow=this.attachShadow({mode:"open"}),Be(this.shadow,Ve),{container:this.container,iframe:this.iframe}=Ge(),this.shadow.appendChild(this.container);const e=yt();this.shadow.appendChild(e.root),this.shaderLoader=new bt(e),this._media=new it({dispatchEvent:i=>this._emit(i),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Ze({onTimeUpdate:(i,s)=>{var n;this._currentTime=i,(n=this.controlsApi)==null||n.updateTime(i,s),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:i}}))},getLoop:()=>this.loop,restart:()=>{this.seek(0),this.play()},onPaused:()=>{var i;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(i=this.controlsApi)==null||i.updatePlaying(!1),this._emit(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new Fe(this.iframe,{onReady:i=>this._onProbeReady(i),onError:i=>this._emit(new CustomEvent("error",{detail:{message:i}}))}),this.addEventListener("click",i=>{this.disableClickToPlay||qe(i)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this),this.iframe.addEventListener("load",this._onIframeLoad)}static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src","type",q,Z,C,D,L,Y]}connectedCallback(){this._connected=!0,this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=ve(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=N(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this._connected=!1,this._teardownVideo(),this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),(e=this.controlsApi)==null||e.destroy(),this.controlsApi=null,this._paused=!0,this._pendingPlay=!1,this._abandonComposition("Player disconnected before runtime data was applied")}attributeChangedCallback(e,i,s){var n,a,o,c,p;switch(e){case"src":if(!this.isConnected)break;s&&this._navigateSrc(s);break;case"type":{const u=this.getAttribute("src");if(!this.isConnected||u===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(u);break}case"srcdoc":if(!this.isConnected)break;if(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),s!==null)this._pauseForVideoSwitch(),this._teardownVideo(),this.iframe.srcdoc=N(this,s);else{this.iframe.removeAttribute("srcdoc");const u=this.getAttribute("src");u!==null&&this._wantsVideo()&&this._navigateSrc(u)}break;case q:this._applySandboxOriginPolicy(this.isConnected&&i!==s);break;case"width":this._setCompositionSize(W(s)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,W(s)??1080);break;case"controls":s!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=ve(this.shadow,s,this.posterEl);break;case"playback-rate":{const u=X(parseFloat(s||"1"));this._media.updatePlaybackRate(u),this._sendControl("set-playback-rate",{playbackRate:u}),(o=(a=this._directTimelineAdapter)==null?void 0:a.timeScale)==null||o.call(a,u),(c=this.controlsApi)==null||c.updateSpeed(u),this._emit(new Event("ratechange"));break}case"muted":this._handleMutedChange(s);break;case"audio-locked":this._applyAudioLock(s!==null);break;case"volume":{const u=Math.max(0,Math.min(1,parseFloat(s||"1")));this._volume=u,this._syncVideoAudio(),this._media.updateVolume(u),this._sendControl("set-volume",{volume:u}),(p=this.controlsApi)==null||p.updateVolume(u),this._emit(new Event("volumechange"));break}case"audio-src":s?this._media.setupFromUrl(s):this._media.teardownUrlAudio();break;case L:s==="none"&&this.shaderLoader.hideAssetsLoading();break;case Y:this._sendControl("set-idle-heartbeat",{slow:s!==null});break;case C:case D:case Z:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(q)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){if(this._videoSource)return;this._abandonComposition("Sandbox policy changed before runtime data was applied");const e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=N(this,e);return}const i=this.getAttribute("src");i===null?this.iframe.src="about:blank":this._loadSrc(i)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){var s,n;if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,(s=this.posterEl)==null||s.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const e=this._tryDirectTimelinePlay();let i=!1;e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,i=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),(n=this.controlsApi)==null||n.updatePlaying(!0),i||this._emit(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){var e;this._pendingPlay=!1,this._tryDirectTimelinePause()?this._showPausedVideoTime():this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1),this._emit(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){var i,s;this._pendingPlay=!1,!this._trySyncSeek(e)&&!this._tryDirectTimelineSeek(e)&&this._sendControl("seek",{timeSeconds:e,frame:Math.round(e*this._runtimeFps)}),this._directTimelineClock.stop(),this._stopParentTickClock(),this._currentTime=e,this._media.audioOwner==="parent"&&(this._scrubbing?this._media.scrubAll(e):(this._media.pauseAll(),this._media.seekAll(e))),this._paused=!0,(i=this.controlsApi)==null||i.updatePlaying(!1),(s=this.controlsApi)==null||s.updateTime(this._currentTime,this._duration)}setColorGrading(e,i){this._sendControl("set-color-grading",{target:e,grading:i})}clearColorGrading(e){this._sendControl("set-color-grading",{target:e,grading:null})}setColorGradingCompare(e,i){this._sendControl("set-color-grading-compare",{target:e,compare:i})}clearColorGradingCompare(e){this._sendControl("set-color-grading-compare",{target:e,compare:{enabled:!1}})}setRuntimeData(e,i){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);if(typeof structuredClone!="function")throw new Error("HyperFrames runtime data requires structuredClone support; refusing an unverified payload");const s=structuredClone(i);this._runtimeData.set(e,s),this._deliverRuntimeData(e,s)}clearRuntimeData(e){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);this._runtimeData.delete(e),this._deliverRuntimeDataClear(e)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get compositionWidth(){return this._compositionWidth}get compositionHeight(){return this._compositionHeight}get paused(){return this._paused}get ready(){return this._ready}get assetsReady(){return this._assetsReady}get painted(){return this._painted}get playbackRate(){return X(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(X(e)))}get shaderCaptureScale(){return ft(this)}set shaderCaptureScale(e){this.setAttribute(C,String(e))}get shaderLoading(){return z(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(D):this.setAttribute(D,e)}get assetsLoadingUi(){return this.getAttribute(L)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(L,"none"):this.removeAttribute(L)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_isLockedHostEnvironment(){if(typeof navigator>"u")return!1;const e=navigator.userAgent||"";return/\bClaude\/\d/.test(e)&&/\bElectron\b/.test(e)}_isAudioLocked(){return this.hasAttribute("audio-locked")||this._isLockedHostEnvironment()}_isSlideshowPlayer(){return this.closest("hyperframes-slideshow")!==null}_handleMutedChange(e){var i;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}),(i=this.controlsApi)==null||i.updateMuted(e!==null),this._emit(new Event("volumechange"))}_applyAudioLock(e){var i;e&&(this.muted=!0),(i=this.controlsApi)==null||i.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(Ee)}set disableClickToPlay(e){this.toggleAttribute(Ee,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_sendControl(e,i={}){try{const s=this.iframe.contentWindow;return s?(s.postMessage({...i,source:"hf-parent",type:"control",action:e,...Me(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(i.channel,i.requestId,"Composition iframe is unavailable"),!1)}catch(s){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(i.channel,i.requestId,s instanceof Error?s.message:String(s)),!1}}_deliverRuntimeData(e,i){if(!this.isConnected||!this._runtimeBridgeReady)return;const s=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,i,s)||this._sendControl("set-runtime-data",{channel:e,payload:i,requestId:s})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;const i=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,i)||this._sendControl("clear-runtime-data",{channel:e,requestId:i})}_trySetRuntimeDataDirect(e,i,s){var n;try{const a=(n=this.iframe.contentWindow)==null?void 0:n.__hyperframes;return typeof(a==null?void 0:a.setRuntimeData)!="function"?!1:(a.setRuntimeData(e,i,s),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,i){var s;try{const n=(s=this.iframe.contentWindow)==null?void 0:s.__hyperframes;return typeof(n==null?void 0:n.clearRuntimeData)!="function"?!1:(n.clearRuntimeData(e,i),!0)}catch{return!1}}_replayRuntimeData(){for(const[e,i]of this._runtimeData)this._deliverRuntimeData(e,i)}_beginRuntimeDataDelivery(e){const i=this._pendingRuntimeData.get(e);i&&window.clearTimeout(i.timeoutId),this._runtimeDataRequestId+=1;const s=this._runtimeDataRequestId,n=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,s,`Runtime data delivery timed out after ${Te}ms`)},Te);return this._pendingRuntimeData.set(e,{requestId:s,timeoutId:n}),s}_resolveRuntimeDataDelivery(e,i){const s=this._takeRuntimeDataDelivery(e,i);s&&this._emit(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:s.requestId}}))}_rejectRuntimeDataDelivery(e,i,s){const n=this._takeRuntimeDataDelivery(e,i);n&&this._emit(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:n.requestId,message:typeof s=="string"?s:String(s)}}))}_takeRuntimeDataDelivery(e,i){if(typeof e!="string"||typeof i!="number"||!Number.isSafeInteger(i))return null;const s=this._pendingRuntimeData.get(e);return!s||s.requestId!==i?null:(window.clearTimeout(s.timeoutId),this._pendingRuntimeData.delete(e),s)}_rejectAllRuntimeDataDeliveries(e){for(const[i,s]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(i,s.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){const i=this._getSameOriginIframeDocument();if(i)for(const s of i.querySelectorAll("video, audio"))b(s)&&(s.muted=e||s.defaultMuted)}_stopIframeMedia(){const e=this._getSameOriginIframeDocument();if(e)for(const i of e.querySelectorAll("video, audio"))b(i)&&i.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(Y)})}_reloadShaderOptions(){if(!this._videoSource){if(this._abandonComposition("Shader options changed before runtime data was applied"),this.hasAttribute("srcdoc")){this.iframe.srcdoc=N(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 wt(this.getAttribute("type"))&&!this.hasAttribute("srcdoc")}_pauseForVideoSwitch(){var e;!this._videoSource&&!this._wantsVideo()||(this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1))}_loadSrc(e){if(this._wantsVideo()){this._loadVideo(e);return}this._teardownVideo(),this.iframe.src=_t(this,e)}_loadVideo(e){var n,a;this._videoSource||(this._videoSource=At({onMetadata:o=>this._applyThenEmit(()=>this._onVideoReady(o)),onDurationChange:o=>this._applyTimelineDuration(o.duration),onResize:o=>this._applyVideoSize(o),onPlay:o=>{!o.paused&&this._paused&&this.play()},onPause:o=>{o.paused&&!o.ended&&!this._paused&&this.pause()},onError:(o,c)=>{this._paused||this.pause(),this._emit(new CustomEvent("error",{detail:{message:o,code:c}}))},onPlayRejected:o=>this._onVideoPlayRejected(o)}),this.container.appendChild(this._videoSource.video),this.iframe.hidden=!0,this.iframe.src="about:blank"),this.probe.stop();const{video:i,adapter:s}=this._videoSource;this._directTimelineAdapter=s,this._currentTime=0,this._duration=0,(n=this.controlsApi)==null||n.updateTime(0,0),this._syncVideoAudio(),(a=s.timeScale)==null||a.call(s,this.playbackRate),i.src=e}_teardownVideo(){this._videoSource&&(this._videoSource.destroy(),this._videoSource=null,this.iframe.hidden=!1)}_syncVideoAudio(){this._videoSource&&(this._videoSource.video.muted=this.muted,this._videoSource.video.volume=this._volume)}_onVideoReady(e){this._applyTimelineDuration(e.duration),this._applyVideoSize(e),this._ready=!0,this._dispatchReady(),this._waitForAssetsReady(null),this._afterEvents(()=>{this.hasAttribute("autoplay")&&this._paused&&this.play()})}_applyTimelineDuration(e){var i;!Number.isFinite(e)||e<=0||(this._setDuration(e),(i=this.controlsApi)==null||i.updateTime(this._currentTime,e))}_applyVideoSize(e){e.videoWidth>0&&e.videoHeight>0&&this._setCompositionSize(e.videoWidth,e.videoHeight)}_onVideoPlayRejected(e){e instanceof DOMException&&e.name==="NotAllowedError"&&(this._paused||this.pause(),this._emit(new CustomEvent("playbackerror",{detail:{source:"video",error:e}})))}_trySyncSeek(e){if(this._videoSource)return!1;try{const i=this.iframe.contentWindow,s=i==null?void 0:i.__player;return typeof(s==null?void 0:s.seek)!="function"?!1:(s.seek.call(s,e),!0)}catch{return!1}}_withDirectTimeline(e){const i=this._videoSource?null:this.probe.resolveDirectTimelineAdapter(),s=i||this._directTimelineAdapter;if(!s)return!1;try{return e(s),i&&i!==this._directTimelineAdapter&&this._applyTimelineDuration(i.duration()),this._directTimelineAdapter=s,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(i=>{i.seek(e,!1),i.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>void e.play())}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>void e.pause())}_showPausedVideoTime(){var e;this._videoSource&&(this._currentTime=this._videoSource.video.currentTime,(e=this.controlsApi)==null||e.updateTime(this._currentTime,this._duration),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}})))}_startParentTickClock(){this._stopParentTickClock();const e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){this._videoSource||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){dt(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:i,duration:s,paused:n,lastUpdateMs:a})=>{this._currentTime=i,this._setDuration(s),this._paused=n,this._lastUpdateMs=a},getShaderLoadingMode:()=>z(this),shaderLoader:this.shaderLoader,setCompositionSize:(i,s)=>this._setCompositionSize(i,s),sendControl:(i,s)=>this._sendControl(i,s),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(i,s)=>this._resolveRuntimeDataDelivery(i,s),onRuntimeDataError:(i,s,n)=>this._rejectRuntimeDataDelivery(i,s,n),onRuntimeTimelineReady:(i,s)=>this._onRuntimeTimelineReady(i,s),setRuntimeFps:i=>{this._runtimeFps=i},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:i=>{this._scenes=i,this._emit(new CustomEvent("scenes",{detail:{scenes:i}}))},updateControlsTime:(i,s)=>{var n;return(n=this.controlsApi)==null?void 0:n.updateTime(i,s)},updateControlsPlaying:i=>{var s;return(s=this.controlsApi)==null?void 0:s.updatePlaying(i)},dispatchEvent:i=>this._emit(i),seek:i=>this.seek(i),play:()=>this.play(),getLoop:()=>this.loop,media:this._media})}_onRuntimeTimelineReady(e,i){var n;if(this._ready)return;this.probe.stop(),this._setDuration(e),this._directTimelineAdapter=null,this._ready=!0,(n=this.controlsApi)==null||n.updateTime(this._currentTime,e),this._dispatchReady();const s=this._getSameOriginIframeDocument();s&&this._media.setupFromIframe(s),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(s,i),this._playWhenWanted()}_onProbeReady(e){this._applyThenEmit(()=>this._applyProbeResult(e))}_applyProbeResult({duration:e,adapter:i,compositionSize:s}){var a;this._setDuration(e),this._directTimelineAdapter=i.kind==="direct-timeline"?i.timeline:null,s&&this._setCompositionSize(s.width,s.height),this._ready=!0,(a=this.controlsApi)==null||a.updateTime(0,e),this._dispatchReady();const n=this._getSameOriginIframeDocument();n&&this._media.setupFromIframe(n),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(n),this._playWhenWanted()}_waitForAssetsReady(e,i){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1;const s=++this._assetsGeneration;if(!e){i===!1?(this._runtimeAssetsReadyGeneration=s,this._startAssetsLoadingOverlayTimer(s),setTimeout(()=>this._settleAssetsReady(s),B)):this._settleAssetsReady(s);return}Pe(e,({timedOut:n})=>{s===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(s))},{timeoutMs:B}),this._assetsReady||this._startAssetsLoadingOverlayTimer(s)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(G,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},St)}_hasPendingFirstFrameAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=me(e,{scope:fe});return i.length>0||s.length>0||n}_warnStuckAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=me(e,{scope:fe}),a=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${B}ms — playing anyway`,{stuckMedia:i.map(o=>o.currentSrc||o.getAttribute("src")||`<${o.tagName.toLowerCase()}>`),stuckImages:s.map(o=>o.currentSrc||o.getAttribute("src")||"<img>"),fontsLoading:n,computeReady:(a==null?void 0:a.__renderReady)===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(G),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(G),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_dispatchReady(){this._readyDocument=this._getSameOriginIframeDocument();const e={duration:this._duration,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight};this._emit(new CustomEvent("ready",{detail:e})),this._rescale()}_setDuration(e){e!==this._duration&&(this._duration=e,this._ready&&this._emit(new CustomEvent("durationchange",{detail:{duration:e}})))}_setCompositionSize(e,i){const s=e!==this._compositionWidth||i!==this._compositionHeight;if(this._compositionWidth=e,this._compositionHeight=i,this._rescale(),!s)return;const n={compositionWidth:e,compositionHeight:i};this._emit(new CustomEvent("resize",{detail:n}))}_applyThenEmit(e){if(this._afterUpdate){e();return}const i=[];this._afterUpdate=i;const s=[],n=a=>{try{a()}catch(o){s.push(o)}};n(e);for(const a of i)n(a);if(this._afterUpdate=null,s.length>0)throw s[0]}_afterEvents(e){this._afterUpdate?this._afterUpdate.push(e):e()}_playWhenWanted(){this._afterEvents(()=>{(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()})}_emit(e){this._afterEvents(()=>this.dispatchEvent(e))}_rescale(){!Ye(this,this.iframe,this._compositionWidth,this._compositionHeight)&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready — zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){if(!this._connected||this._videoSource)return;const e=this._getSameOriginIframeDocument();if(this._ready&&e===this._readyDocument){e&&this._hasPendingFirstFrameAssets(e)&&this._waitForAssetsReady(e);return}this._ready=!1,this._invalidateAssetsWait(),this._releaseDocument(),this.probe.start()}_setupControls(){this.controlsApi||(this.controlsApi=je(this.shadow,this.muted,this._volume,this.getAttribute("speed-presets"),{onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:e=>this.seek(e*this._duration),onScrubStart:()=>{this._scrubbing=!0},onScrubEnd:()=>{this._scrubbing=!1,this.seek(this._currentTime)},onSpeedChange:e=>void(this.playbackRate=e),onMuteToggle:()=>void(this.muted=!this.muted),onVolumeChange:e=>void(this.volume=e)},this._isAudioLocked()))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,i){this._media.mirrorTime(e,i)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(i,s)=>this._mirrorParentMediaTime(i,s)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}}customElements.get("hyperframes-player")||customElements.define("hyperframes-player",Ct);export{Ct as HyperframesPlayer,ze as SPEED_PRESETS,$ as formatSpeed,ye as formatTime};
@@ -1,4 +1,4 @@
1
- import{n as Qi}from"./index-ClLdmgua.js";/*!
1
+ import{n as Qi}from"./index-d5DKK15Q.js";/*!
2
2
  * Copyright (c) 2026-present, Vanilagy and contributors
3
3
  *
4
4
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -1 +1 @@
1
- import{g as P}from"./index-ClLdmgua.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
1
+ import{g as P}from"./index-d5DKK15Q.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};