@hyperframes/studio 0.9.65 → 0.9.67

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.
Files changed (66) hide show
  1. package/dist/assets/hyperframes-player-DHYu0XuV.js +573 -0
  2. package/dist/assets/{index-tvLrzMBv.js → index-BBKHfua5.js} +180 -180
  3. package/dist/assets/{index-CAjz3b83.js → index-DqND4rHq.js} +1 -1
  4. package/dist/assets/{pausedVideoDecoder-xC5IGkfB.js → pausedVideoDecoder-B1FNXBMe.js} +1 -1
  5. package/dist/{chunk-VDDEXNVX.js → chunk-LR3VT3EF.js} +20 -0
  6. package/dist/index.html +1 -1
  7. package/dist/index.js +396 -160
  8. package/dist/player.js +1 -1
  9. package/package.json +8 -8
  10. package/src/captions/components/CaptionOverlay.sealed.test.ts +2 -25
  11. package/src/components/editor/LayersPanel.opaque.test.ts +4 -29
  12. package/src/components/editor/domEditOverlayCrop.ts +78 -15
  13. package/src/components/editor/domEditOverlayCropFrameLift.test.ts +64 -0
  14. package/src/components/editor/gsapLivePreview.sealed.test.ts +35 -0
  15. package/src/components/editor/gsapLivePreview.ts +6 -2
  16. package/src/components/editor/gsapMoveSealedPreview.test.ts +3 -23
  17. package/src/components/editor/previewDrafts.test.ts +13 -39
  18. package/src/components/editor/previewDrafts.ts +2 -0
  19. package/src/components/editor/previewGestureStartRead.test.ts +59 -21
  20. package/src/components/editor/previewGestureStartRead.ts +9 -0
  21. package/src/components/editor/previewLayers.test.ts +3 -20
  22. package/src/components/editor/previewOverlayRects.test.ts +3 -20
  23. package/src/components/editor/previewPointerTargets.test.ts +3 -20
  24. package/src/components/editor/previewSelection.test.ts +51 -35
  25. package/src/components/editor/previewSelection.ts +17 -0
  26. package/src/components/editor/useColorGradingController.sealed.test.ts +5 -30
  27. package/src/components/editor/useMotionPathData.sealed.test.ts +2 -29
  28. package/src/components/nle/NLEContext.drillDown.test.ts +85 -0
  29. package/src/components/nle/NLEContext.tsx +21 -23
  30. package/src/components/nle/NLEPreview.test.ts +18 -3
  31. package/src/components/nle/NLEPreview.tsx +10 -1
  32. package/src/components/nle/audioSealedPreview.test.ts +5 -32
  33. package/src/hooks/appHotkeysDispatch.ts +38 -1
  34. package/src/hooks/domEditCommits.sealed.test.ts +191 -0
  35. package/src/hooks/domStyleCommit.ts +18 -7
  36. package/src/hooks/gsapMutationClient.test.ts +32 -0
  37. package/src/hooks/gsapMutationClient.ts +6 -3
  38. package/src/hooks/gsapResizeIntercept.ts +7 -2
  39. package/src/hooks/timelineTimingSync.test.ts +1 -1
  40. package/src/hooks/useAppHotkeys.previewForwarding.test.tsx +134 -0
  41. package/src/hooks/useAppHotkeys.ts +36 -1
  42. package/src/hooks/useDomEditAttributeCommits.ts +43 -19
  43. package/src/hooks/useEnableKeyframes.sealed.test.ts +2 -29
  44. package/src/hooks/useFreezeFrame.test.ts +3 -2
  45. package/src/hooks/useFreezeFrame.ts +2 -2
  46. package/src/hooks/useGroupCommits.ts +7 -2
  47. package/src/hooks/useSlideshowTabState.test.ts +47 -3
  48. package/src/hooks/useSlideshowTabState.ts +32 -16
  49. package/src/player/hooks/timelinePlayerTestHarness.ts +2 -1
  50. package/src/player/hooks/usePlaybackKeyboard.ts +1 -1
  51. package/src/player/hooks/usePreviewFirstFrameTelemetry.sealed.test.ts +43 -0
  52. package/src/player/hooks/usePreviewFirstFrameTelemetry.ts +11 -7
  53. package/src/player/hooks/useTimelineSyncCallbacks.sealed.test.ts +39 -31
  54. package/src/player/hooks/useTimelineSyncCallbacks.ts +21 -11
  55. package/src/player/lib/previewChannel.test.ts +10 -0
  56. package/src/player/lib/previewChannel.ts +21 -0
  57. package/src/player/lib/previewElements.test.ts +34 -1
  58. package/src/player/lib/previewElements.ts +99 -16
  59. package/src/player/lib/sealedPreviewFrame.test-helpers.ts +38 -0
  60. package/src/player/lib/timelineIframeHelpers.ts +1 -1
  61. package/src/utils/blockInstaller.test.ts +82 -48
  62. package/src/utils/blockInstaller.ts +6 -14
  63. package/src/utils/previewCompositionSize.test.ts +61 -0
  64. package/src/utils/previewCompositionSize.ts +21 -1
  65. package/src/utils/studioSaveDiagnostics.ts +2 -0
  66. package/dist/assets/hyperframes-player-Dscc6yHD.js +0 -573
@@ -0,0 +1,573 @@
1
+ var Xe=Object.defineProperty;var Ke=(r,t,e)=>t in r?Xe(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var l=(r,t,e)=>Ke(r,typeof t!="symbol"?t+"":t,e);import{S as Ze,r as Je,P as Qe,i as et,a as Re,b as Ce,c as tt,m as $e,s as it,d as S,e as ke,p as st,f as rt,g as nt,h as ot,j as at,k as Le,F as Pe}from"./index-BBKHfua5.js";function dt(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function H(r){return typeof r=="object"&&r!==null}function lt(r){return H(r)&&typeof r.getDuration=="function"}function ht(r){return H(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function ut(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 Y=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:ut("0.0.0-dev");function Z(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function ct(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=Z(t.getAttribute("data-width")),i=Z(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}function pt(r){return Array.isArray(r)?r.find(t=>typeof t=="string"&&t.trim()!==""&&t!=="[object Event]")??null:null}class ft{constructor(t,e){l(this,"_interval",null);l(this,"_runtimeInjected",!1);l(this,"_runtimeScript",null);l(this,"_failure",null);this._iframe=t,this._callbacks=e}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 t=0;this._interval=setInterval(()=>{t++;let e=null;try{e=this._poll(t)}catch(i){i instanceof DOMException&&i.name==="SecurityError"||(e={kind:"error",message:i instanceof Error?i.message:String(i)})}e??(e=this._deadlineOutcome(t)),e&&(this.stop(),e.kind==="error"?(this._failure={document:this._iframe.contentDocument},this._callbacks.onError(e.message)):this._callbacks.onReady(e.result))},200)}_deadlineOutcome(t){var e,i;return t<40||(i=(e=this._callbacks).hostOwnsDeadline)!=null&&i.call(e)?null:{kind:"error",message:"Composition timeline not found after 8s"}}_poll(t){const e=this._iframe.contentWindow;if(!e)return null;const i=pt(Reflect.get(e,Ze));if(i!==null)return{kind:"error",message:i};const s=this._iframe.contentDocument,n=Reflect.get(e,"__timelines"),o=this.hasRuntimeBridge(e);if(dt({hasRuntime:o,hasTimelines:H(n)&&Object.keys(n).length>0,hasNestedCompositions:!!(s!=null&&s.querySelector("[data-composition-src]")),runtimeInjected:this._runtimeInjected,attempts:t}))return this._injectRuntime(),null;if(this._runtimeInjected&&!o)return null;const a=this._resolveReadyResult(e,s);return a?{kind:"ready",result:a}:null}_resolveReadyResult(t,e){var n;const i=this._resolvePlaybackDurationAdapter(t)??{kind:"document",getDuration:()=>0};let s=i.getDuration();if(!Number.isFinite(s)||s<=0){if(i.kind==="direct-timeline")return null;s=e?((n=Je(e))==null?void 0:n.durationSeconds)??0:0}return s<=0?null:{duration:s,adapter:{...i,getDuration:()=>s},compositionSize:ct(e)}}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{const t=this._iframe.contentWindow;return t?this._resolveDirectTimelineAdapterFromWindow(t):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(t){return this._resolveDirectTimelineAdapterFromWindow(t)}hasRuntimeBridge(t){return H(Reflect.get(t,"__player"))}_injectRuntime(){var t,e,i,s;this._runtimeInjected=!0;try{const n=this._iframe.contentDocument;if(!n)return;const o=n.createElement("script");o.src=((e=(t=this._callbacks).resolveRuntimeUrl)==null?void 0:e.call(t))??Y,this._runtimeScript=o,o.onerror=()=>{this._runtimeScript!==o||this._iframe.contentDocument!==n||(this.stop(),this._failure={document:n},this._callbacks.onError("HyperFrames runtime failed to load from "+o.src))},(n.head||n.documentElement).appendChild(o),(s=(i=this._callbacks).onRuntimeInjected)==null||s.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(t){var a,c;if(this.hasRuntimeBridge(t))return null;const e=Reflect.get(t,"__timelines");if(!H(e))return null;const i=Object.keys(e);if(i.length===0)return null;const s=(c=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:c.getAttribute("data-composition-id"),n=s&&s in e?s:i[i.length-1],o=e[n];return ht(o)?o:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(lt(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const mt=`
2
+ :host {
3
+ display: block;
4
+ position: relative;
5
+ overflow: hidden;
6
+ background: #000;
7
+ contain: layout style;
8
+ }
9
+
10
+ /* The only in-flow child: with no height set, the player takes the composition's shape. */
11
+ .hfp-sizer {
12
+ aspect-ratio: 16 / 9;
13
+ }
14
+
15
+ .hfp-container {
16
+ position: absolute;
17
+ inset: 0;
18
+ overflow: hidden;
19
+ pointer-events: none;
20
+ }
21
+
22
+
23
+ .hfp-iframe {
24
+ position: absolute;
25
+ top: 50%;
26
+ left: 50%;
27
+ border: none;
28
+ pointer-events: none;
29
+ }
30
+
31
+ /* Opt-in: an interactive composition (e.g. a live slideshow/app with playable
32
+ media or controls): let pointer events reach the iframe content. */
33
+ :host([interactive]) .hfp-container,
34
+ :host([interactive]) .hfp-iframe {
35
+ pointer-events: auto;
36
+ }
37
+
38
+ .hfp-video {
39
+ position: absolute;
40
+ inset: 0;
41
+ width: 100%;
42
+ height: 100%;
43
+ object-fit: contain;
44
+ pointer-events: none;
45
+ }
46
+
47
+ .hfp-poster {
48
+ position: absolute;
49
+ inset: 0;
50
+ object-fit: contain;
51
+ z-index: 1;
52
+ pointer-events: none;
53
+ }
54
+
55
+ .hfp-shader-loader {
56
+ position: absolute;
57
+ inset: 0;
58
+ z-index: 20;
59
+ display: grid;
60
+ place-items: center;
61
+ visibility: hidden;
62
+ opacity: 0;
63
+ pointer-events: none;
64
+ background: #030504;
65
+ color: #f4f7fb;
66
+ cursor: default;
67
+ user-select: none;
68
+ -webkit-user-select: none;
69
+ transition: opacity 420ms ease-out, visibility 420ms ease-out;
70
+ }
71
+
72
+ .hfp-shader-loader.hfp-visible,
73
+ .hfp-shader-loader.hfp-hiding {
74
+ visibility: visible;
75
+ }
76
+
77
+ .hfp-shader-loader.hfp-visible {
78
+ opacity: 1;
79
+ pointer-events: auto;
80
+ }
81
+
82
+ .hfp-shader-loader.hfp-hiding {
83
+ opacity: 0;
84
+ pointer-events: none;
85
+ }
86
+
87
+ .hfp-shader-loader-panel {
88
+ display: grid;
89
+ grid-template-rows: 86px 40px 26px 12px 44px;
90
+ justify-items: center;
91
+ align-items: center;
92
+ gap: 8px;
93
+ width: min(620px, 82%);
94
+ text-align: center;
95
+ font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
96
+ }
97
+
98
+ .hfp-shader-loader-mark {
99
+ width: 86px;
100
+ height: 86px;
101
+ display: grid;
102
+ place-items: center;
103
+ overflow: visible;
104
+ }
105
+
106
+ .hfp-shader-loader-mark svg {
107
+ display: block;
108
+ overflow: visible;
109
+ filter: drop-shadow(0 0 5px rgba(79, 219, 94, 0.16));
110
+ pointer-events: none;
111
+ }
112
+
113
+ .hfp-shader-loader-title {
114
+ width: 100%;
115
+ height: 40px;
116
+ overflow: hidden;
117
+ white-space: nowrap;
118
+ text-overflow: ellipsis;
119
+ font-size: 26px;
120
+ line-height: 40px;
121
+ font-weight: 700;
122
+ letter-spacing: 0;
123
+ }
124
+
125
+ .hfp-shader-loader-title-text {
126
+ color: transparent;
127
+ background: linear-gradient(
128
+ 90deg,
129
+ rgba(244, 247, 251, 0.84) 0%,
130
+ #ffffff 42%,
131
+ #80efe4 52%,
132
+ #ffffff 62%,
133
+ rgba(244, 247, 251, 0.84) 100%
134
+ );
135
+ background-size: 220% 100%;
136
+ -webkit-background-clip: text;
137
+ background-clip: text;
138
+ animation: hfp-shader-loader-sheen 1.9s linear infinite;
139
+ }
140
+
141
+ .hfp-shader-loader:not(.hfp-visible):not(.hfp-hiding) .hfp-shader-loader-title-text {
142
+ animation-play-state: paused;
143
+ }
144
+
145
+ .hfp-shader-loader-detail {
146
+ width: 100%;
147
+ height: 26px;
148
+ overflow: hidden;
149
+ white-space: nowrap;
150
+ text-overflow: ellipsis;
151
+ color: rgba(244, 247, 251, 0.62);
152
+ font-size: 15px;
153
+ line-height: 26px;
154
+ font-weight: 500;
155
+ }
156
+
157
+ .hfp-shader-loader-track {
158
+ width: min(360px, 100%);
159
+ height: 8px;
160
+ overflow: hidden;
161
+ border-radius: 999px;
162
+ background: rgba(255, 255, 255, 0.1);
163
+ }
164
+
165
+ .hfp-shader-loader-fill {
166
+ width: 100%;
167
+ height: 100%;
168
+ border-radius: inherit;
169
+ background: linear-gradient(90deg, #06e3fa, #4fdb5e);
170
+ transform: scaleX(0);
171
+ transform-origin: left center;
172
+ transition: transform 160ms ease;
173
+ }
174
+
175
+ .hfp-shader-loader-progress {
176
+ width: min(420px, 100%);
177
+ height: 44px;
178
+ display: grid;
179
+ grid-template-rows: repeat(2, 22px);
180
+ color: rgba(244, 247, 251, 0.48);
181
+ font: 600 13px/22px "IBM Plex Mono", "SF Mono", "Fira Code", "Courier New", monospace;
182
+ font-variant-numeric: tabular-nums;
183
+ }
184
+
185
+ .hfp-shader-loader-row {
186
+ display: grid;
187
+ grid-template-columns: minmax(0, 1fr) 74px;
188
+ align-items: center;
189
+ column-gap: 20px;
190
+ width: 100%;
191
+ white-space: nowrap;
192
+ }
193
+
194
+ .hfp-shader-loader-label {
195
+ min-width: 0;
196
+ overflow: hidden;
197
+ text-align: left;
198
+ text-overflow: ellipsis;
199
+ }
200
+
201
+ .hfp-shader-loader-value {
202
+ text-align: right;
203
+ }
204
+
205
+ /* Loading assets and Buffering: the frame softly blurred, the mark alone over it with a light
206
+ passing over. filter, transform and opacity only, no backdrop-filter, which drops frames on
207
+ Safari; the frame is still while it waits, so the blur is painted once. */
208
+ .hfp-iframe,
209
+ .hfp-poster {
210
+ transition: filter 400ms ease-out;
211
+ }
212
+
213
+ :host([assets-loading]:not([assets-loading-ui="none"])) .hfp-iframe,
214
+ :host([assets-loading]:not([assets-loading-ui="none"])) .hfp-poster,
215
+ :host([buffering]:not([assets-loading-ui="none"])) .hfp-iframe,
216
+ :host([buffering]:not([assets-loading-ui="none"])) .hfp-poster {
217
+ filter: blur(6px) saturate(0.85);
218
+ transition-duration: 180ms;
219
+ }
220
+
221
+ .hfp-shader-loader.hfp-assets {
222
+ background: transparent;
223
+ }
224
+
225
+ .hfp-shader-loader.hfp-assets .hfp-shader-loader-panel {
226
+ grid-template-rows: auto;
227
+ width: auto;
228
+ }
229
+
230
+ .hfp-shader-loader.hfp-assets .hfp-shader-loader-title,
231
+ .hfp-shader-loader.hfp-assets .hfp-shader-loader-detail,
232
+ .hfp-shader-loader.hfp-assets .hfp-shader-loader-track,
233
+ .hfp-shader-loader.hfp-assets .hfp-shader-loader-progress {
234
+ display: none;
235
+ }
236
+
237
+ .hfp-shader-loader-mark {
238
+ position: relative;
239
+ }
240
+
241
+ .hfp-shader-loader-sheen {
242
+ display: none;
243
+ position: absolute;
244
+ inset: 0;
245
+ overflow: hidden;
246
+ mask-size: contain;
247
+ mask-repeat: no-repeat;
248
+ mask-position: center;
249
+ -webkit-mask-size: contain;
250
+ -webkit-mask-repeat: no-repeat;
251
+ -webkit-mask-position: center;
252
+ }
253
+
254
+ .hfp-shader-loader.hfp-assets .hfp-shader-loader-sheen {
255
+ display: block;
256
+ }
257
+
258
+ .hfp-shader-loader-sheen::before {
259
+ content: "";
260
+ position: absolute;
261
+ inset: 0 auto 0 -60%;
262
+ width: 60%;
263
+ background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.85), transparent);
264
+ animation: hfp-shader-loader-sweep 1700ms cubic-bezier(0.4, 0, 0.2, 1) infinite;
265
+ }
266
+
267
+ .hfp-shader-loader:not(.hfp-visible):not(.hfp-hiding) .hfp-shader-loader-sheen::before {
268
+ animation-play-state: paused;
269
+ }
270
+
271
+ @keyframes hfp-shader-loader-sweep {
272
+ 0% {
273
+ transform: translateX(0);
274
+ }
275
+ 55%,
276
+ 100% {
277
+ transform: translateX(280%);
278
+ }
279
+ }
280
+
281
+ @media (prefers-reduced-motion: reduce) {
282
+ .hfp-iframe,
283
+ .hfp-poster {
284
+ transition: none;
285
+ }
286
+
287
+ .hfp-shader-loader-sheen::before {
288
+ animation: none;
289
+ }
290
+ }
291
+
292
+ @keyframes hfp-shader-loader-sheen {
293
+ from {
294
+ background-position: 140% 0;
295
+ }
296
+ to {
297
+ background-position: -140% 0;
298
+ }
299
+ }
300
+
301
+ /* ── Theming via CSS custom properties ──
302
+ *
303
+ * Override from outside the shadow DOM:
304
+ * hyperframes-player {
305
+ * --hfp-controls-bg: linear-gradient(transparent, rgba(0,0,0,0.9));
306
+ * --hfp-accent: #ff6b6b;
307
+ * --hfp-font: "Inter", sans-serif;
308
+ * }
309
+ */
310
+
311
+ .hfp-controls {
312
+ position: absolute;
313
+ bottom: 0;
314
+ left: 0;
315
+ right: 0;
316
+ display: flex;
317
+ align-items: center;
318
+ gap: var(--hfp-controls-gap, 12px);
319
+ padding: var(--hfp-controls-padding, 8px 16px);
320
+ background: var(--hfp-controls-bg, linear-gradient(transparent, rgba(0, 0, 0, 0.7)));
321
+ color: var(--hfp-color, #fff);
322
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
323
+ font-size: var(--hfp-font-size, 13px);
324
+ z-index: 10;
325
+ pointer-events: auto;
326
+ opacity: 1;
327
+ transition: opacity 0.3s ease;
328
+ user-select: none;
329
+ }
330
+
331
+ .hfp-controls.hfp-hidden {
332
+ opacity: 0;
333
+ pointer-events: none;
334
+ }
335
+
336
+ .hfp-play-btn {
337
+ position: relative;
338
+ background: none;
339
+ border: none;
340
+ color: var(--hfp-color, #fff);
341
+ cursor: pointer;
342
+ padding: 8px;
343
+ display: flex;
344
+ align-items: center;
345
+ justify-content: center;
346
+ width: 40px;
347
+ height: 40px;
348
+ flex-shrink: 0;
349
+ z-index: 10;
350
+ }
351
+
352
+ .hfp-play-btn:hover {
353
+ opacity: 0.8;
354
+ }
355
+
356
+ /* Stacked play/pause glyphs that crossfade-morph on toggle (rotate + scale). */
357
+ .hfp-play-btn .hfp-ico {
358
+ position: absolute;
359
+ display: flex;
360
+ align-items: center;
361
+ justify-content: center;
362
+ transition:
363
+ opacity 200ms ease,
364
+ transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
365
+ }
366
+ .hfp-play-btn .hfp-ico-play {
367
+ opacity: 1;
368
+ transform: rotate(0) scale(1);
369
+ }
370
+ .hfp-play-btn .hfp-ico-pause {
371
+ opacity: 0;
372
+ transform: rotate(-90deg) scale(0.4);
373
+ }
374
+ .hfp-play-btn.hfp-playing .hfp-ico-play {
375
+ opacity: 0;
376
+ transform: rotate(90deg) scale(0.4);
377
+ }
378
+ .hfp-play-btn.hfp-playing .hfp-ico-pause {
379
+ opacity: 1;
380
+ transform: rotate(0) scale(1);
381
+ }
382
+ @media (prefers-reduced-motion: reduce) {
383
+ .hfp-play-btn .hfp-ico {
384
+ transition-duration: 0ms;
385
+ transform: none;
386
+ }
387
+ }
388
+
389
+ .hfp-play-btn svg,
390
+ .hfp-play-btn svg * {
391
+ pointer-events: none;
392
+ }
393
+
394
+ .hfp-scrubber {
395
+ flex: 1;
396
+ min-width: 0;
397
+ height: var(--hfp-scrubber-height, 4px);
398
+ background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
399
+ border-radius: var(--hfp-scrubber-radius, 2px);
400
+ cursor: pointer;
401
+ position: relative;
402
+ overflow: hidden;
403
+ }
404
+
405
+ .hfp-scrubber:hover {
406
+ height: var(--hfp-scrubber-height-hover, 6px);
407
+ }
408
+
409
+ .hfp-progress {
410
+ position: absolute;
411
+ top: 0;
412
+ left: 0;
413
+ height: 100%;
414
+ background: var(--hfp-accent, #fff);
415
+ pointer-events: none;
416
+ }
417
+
418
+ .hfp-time {
419
+ flex-shrink: 0;
420
+ font-variant-numeric: tabular-nums;
421
+ opacity: 0.9;
422
+ }
423
+
424
+ .hfp-speed-wrap {
425
+ position: relative;
426
+ flex-shrink: 0;
427
+ }
428
+
429
+ .hfp-speed-btn {
430
+ background: var(--hfp-speed-btn-bg, rgba(255, 255, 255, 0.15));
431
+ border: none;
432
+ border-radius: var(--hfp-speed-btn-radius, 4px);
433
+ color: var(--hfp-color, #fff);
434
+ cursor: pointer;
435
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
436
+ font-size: 12px;
437
+ font-variant-numeric: tabular-nums;
438
+ font-weight: 600;
439
+ padding: 4px 8px;
440
+ min-width: 40px;
441
+ text-align: center;
442
+ transition: background 0.15s ease;
443
+ }
444
+
445
+ .hfp-speed-btn:hover {
446
+ background: var(--hfp-speed-btn-bg-hover, rgba(255, 255, 255, 0.3));
447
+ }
448
+
449
+ .hfp-speed-menu {
450
+ position: absolute;
451
+ bottom: calc(100% + 8px);
452
+ right: 0;
453
+ background: var(--hfp-menu-bg, rgba(20, 20, 20, 0.95));
454
+ backdrop-filter: blur(12px);
455
+ -webkit-backdrop-filter: blur(12px);
456
+ border: 1px solid var(--hfp-menu-border, rgba(255, 255, 255, 0.1));
457
+ border-radius: var(--hfp-menu-radius, 8px);
458
+ padding: 4px;
459
+ display: flex;
460
+ flex-direction: column;
461
+ gap: 2px;
462
+ min-width: 80px;
463
+ opacity: 0;
464
+ visibility: hidden;
465
+ transform: translateY(4px);
466
+ transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
467
+ box-shadow: var(--hfp-menu-shadow, 0 8px 24px rgba(0, 0, 0, 0.4));
468
+ }
469
+
470
+ .hfp-speed-menu.hfp-open {
471
+ opacity: 1;
472
+ visibility: visible;
473
+ transform: translateY(0);
474
+ }
475
+
476
+ .hfp-speed-option {
477
+ background: none;
478
+ border: none;
479
+ border-radius: 4px;
480
+ color: var(--hfp-menu-color, rgba(255, 255, 255, 0.7));
481
+ cursor: pointer;
482
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
483
+ font-size: 13px;
484
+ font-variant-numeric: tabular-nums;
485
+ padding: 6px 12px;
486
+ text-align: left;
487
+ transition: background 0.1s ease, color 0.1s ease;
488
+ white-space: nowrap;
489
+ }
490
+
491
+ .hfp-speed-option:hover {
492
+ background: var(--hfp-menu-hover-bg, rgba(255, 255, 255, 0.1));
493
+ color: var(--hfp-color, #fff);
494
+ }
495
+
496
+ .hfp-speed-option.hfp-active {
497
+ color: var(--hfp-accent, #fff);
498
+ font-weight: 600;
499
+ }
500
+
501
+ .hfp-volume-wrap {
502
+ position: relative;
503
+ flex-shrink: 0;
504
+ display: flex;
505
+ align-items: center;
506
+ gap: 0;
507
+ }
508
+
509
+ .hfp-mute-btn,
510
+ .hfp-fullscreen-btn {
511
+ background: none;
512
+ border: none;
513
+ color: var(--hfp-color, #fff);
514
+ cursor: pointer;
515
+ padding: 4px;
516
+ display: flex;
517
+ align-items: center;
518
+ justify-content: center;
519
+ width: 32px;
520
+ height: 32px;
521
+ flex-shrink: 0;
522
+ }
523
+
524
+ .hfp-mute-btn:hover,
525
+ .hfp-fullscreen-btn:hover {
526
+ opacity: 0.8;
527
+ }
528
+
529
+ .hfp-mute-btn svg,
530
+ .hfp-mute-btn svg *,
531
+ .hfp-fullscreen-btn svg,
532
+ .hfp-fullscreen-btn svg * {
533
+ pointer-events: none;
534
+ }
535
+
536
+ :host([disable-fullscreen]) .hfp-fullscreen-btn {
537
+ display: none;
538
+ }
539
+
540
+ .hfp-volume-slider-wrap {
541
+ width: 0;
542
+ overflow: hidden;
543
+ transition: width 0.2s ease;
544
+ display: flex;
545
+ align-items: center;
546
+ }
547
+
548
+ .hfp-volume-wrap:hover .hfp-volume-slider-wrap {
549
+ width: 64px;
550
+ }
551
+
552
+ .hfp-volume-slider {
553
+ width: 56px;
554
+ height: var(--hfp-scrubber-height, 4px);
555
+ background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
556
+ border-radius: var(--hfp-scrubber-radius, 2px);
557
+ cursor: pointer;
558
+ position: relative;
559
+ overflow: hidden;
560
+ margin-left: 4px;
561
+ margin-right: 4px;
562
+ }
563
+
564
+ .hfp-volume-fill {
565
+ position: absolute;
566
+ top: 0;
567
+ left: 0;
568
+ height: 100%;
569
+ background: var(--hfp-accent, #fff);
570
+ pointer-events: none;
571
+ }
572
+ `,_t='<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>',gt='<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>',yt='<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>',vt='<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>',bt='<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>',wt='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg>',At='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/></svg>',St=[.25,.5,1,1.5,2,4];function O(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function De(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 ee(r,t){const e=document.createElement("slot");return e.name=r,e.innerHTML=t,e}function Et(r){if(!document.fullscreenEnabled)return null;const t=document.createElement("button");t.className="hfp-fullscreen-btn",t.type="button";const e=()=>{const i=r.matches(":fullscreen");t.innerHTML=i?At:wt,t.setAttribute("aria-label",i?"Exit full screen":"Full screen")};return t.addEventListener("click",i=>{i.stopPropagation(),(r.matches(":fullscreen")?document.exitFullscreen():r.requestFullscreen()).catch(()=>{})}),document.addEventListener("fullscreenchange",e),e(),{button:t,destroy:()=>document.removeEventListener("fullscreenchange",e)}}function Tt(r,t,e={}){const i=e.speedPresets??St,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"><slot name="play-icon">${_t}</slot></span><span class="hfp-ico hfp-ico-pause"><slot name="pause-icon">${gt}</slot></span>`,n.setAttribute("aria-label","Play");const o=document.createElement("div");o.className="hfp-scrubber";const a=document.createElement("div");a.className="hfp-progress",a.style.width="0%",o.appendChild(a);const c=document.createElement("span");c.className="hfp-time",c.textContent="0:00 / 0:00";const p=document.createElement("div");p.className="hfp-speed-wrap";const h=document.createElement("button");h.className="hfp-speed-btn",h.type="button",h.textContent="1x",h.setAttribute("aria-label","Playback speed: 1x");const g=document.createElement("div");g.className="hfp-speed-menu",g.setAttribute("role","menu");for(const d of i){const u=document.createElement("button");u.className="hfp-speed-option",u.type="button",u.setAttribute("role","menuitem"),u.dataset.speed=String(d),u.textContent=O(d),d===1&&u.classList.add("hfp-active"),g.appendChild(u)}p.appendChild(g),p.appendChild(h);const m=document.createElement("div");m.className="hfp-volume-wrap";const f=document.createElement("button");f.className="hfp-mute-btn",f.type="button",f.setAttribute("aria-label","Mute");const b={high:ee("volume-high-icon",yt),low:ee("volume-low-icon",vt),muted:ee("volume-muted-icon",bt)},_=(d,u)=>{const v=d?b.muted:u<.5?b.low:b.high;f.firstChild!==v&&f.replaceChildren(v)};_(!1,1);const w=document.createElement("div");w.className="hfp-volume-slider-wrap";const y=document.createElement("div");y.className="hfp-volume-slider",y.setAttribute("role","slider"),y.setAttribute("aria-label","Volume"),y.setAttribute("aria-valuemin","0"),y.setAttribute("aria-valuemax","100"),y.setAttribute("aria-valuenow","100"),y.tabIndex=0;const A=document.createElement("div");A.className="hfp-volume-fill",A.style.width="100%",y.appendChild(A),w.appendChild(y),m.appendChild(w),m.appendChild(f),e.audioLocked&&(m.style.display="none"),s.appendChild(n),s.appendChild(o),s.appendChild(c),s.appendChild(m),s.appendChild(p),r.appendChild(s);let x=!1,L=!1,R=1,C=null;i.indexOf(1),n.addEventListener("click",d=>{d.stopPropagation(),x?t.onPause():t.onPlay()}),f.addEventListener("click",d=>{d.stopPropagation(),t.onMuteToggle()});let k=!1;const z=d=>{const u=y.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-u.left)/u.width));R=v,A.style.width=`${v*100}%`,y.setAttribute("aria-valuenow",String(Math.round(v*100))),L&&v>0&&t.onMuteToggle(),_(L,v),t.onVolumeChange(v)};y.addEventListener("mousedown",d=>{d.stopPropagation(),k=!0,z(d.clientX)});const he=d=>{k&&z(d.clientX)},ue=()=>{k=!1};document.addEventListener("mousemove",he),document.addEventListener("mouseup",ue),y.addEventListener("touchstart",d=>{k=!0;const u=d.touches[0];u&&z(u.clientX)},{passive:!0});const ce=d=>{if(k){const u=d.touches[0];u&&z(u.clientX)}},pe=()=>{k=!1};document.addEventListener("touchmove",ce,{passive:!0}),document.addEventListener("touchend",pe);const fe=.05;y.addEventListener("keydown",d=>{let u=R;if(d.key==="ArrowRight"||d.key==="ArrowUp")u=Math.min(1,R+fe);else if(d.key==="ArrowLeft"||d.key==="ArrowDown")u=Math.max(0,R-fe);else return;d.preventDefault(),d.stopPropagation(),R=u,A.style.width=`${u*100}%`,y.setAttribute("aria-valuenow",String(Math.round(u*100))),L&&u>0&&t.onMuteToggle(),_(L,u),t.onVolumeChange(u)});const me=d=>{for(const u of g.querySelectorAll(".hfp-speed-option"))u.classList.toggle("hfp-active",u.dataset.speed===String(d))};h.addEventListener("click",d=>{d.stopPropagation();const u=g.classList.toggle("hfp-open");h.setAttribute("aria-expanded",String(u))}),g.addEventListener("click",d=>{d.stopPropagation();const u=d.target.closest(".hfp-speed-option");if(!u)return;const v=parseFloat(u.dataset.speed);i.indexOf(v),h.textContent=O(v),h.setAttribute("aria-label",`Playback speed: ${O(v)}`),me(v),g.classList.remove("hfp-open"),h.setAttribute("aria-expanded","false"),t.onSpeedChange(v)});const _e=()=>{g.classList.remove("hfp-open"),h.setAttribute("aria-expanded","false")};document.addEventListener("click",_e);const W=d=>{const u=o.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-u.left)/u.width));t.onSeek(v)};let T=!1,$=!1;const ge=()=>{var d;T=!0,$=x,$&&t.onPause(),(d=t.onScrubStart)==null||d.call(t)},ye=()=>{var d;T=!1,(d=t.onScrubEnd)==null||d.call(t),$&&t.onPlay()};o.addEventListener("mousedown",d=>{d.stopPropagation(),ge(),W(d.clientX)});const ve=d=>{T&&W(d.clientX)},be=()=>{T&&ye()};document.addEventListener("mousemove",ve),document.addEventListener("mouseup",be),o.addEventListener("touchstart",d=>{ge();const u=d.touches[0];u&&W(u.clientX)},{passive:!0});const we=d=>{if(T){const u=d.touches[0];u&&W(u.clientX)}},Ae=d=>{T&&(d.cancelable&&d.preventDefault(),ye())};document.addEventListener("touchmove",we,{passive:!0}),document.addEventListener("touchend",Ae);const Se=()=>x&&!T&&!k&&!s.querySelector(":focus-visible"),Ee=()=>{s.classList.remove("hfp-hidden"),C&&clearTimeout(C),C=setTimeout(()=>{Se()&&s.classList.add("hfp-hidden")},3e3)},E=r instanceof ShadowRoot?r.host:r,I=Et(E);I&&s.appendChild(I.button);const P=()=>Ee(),Te=()=>{Se()&&s.classList.add("hfp-hidden")};return E.addEventListener("mousemove",P),E.addEventListener("keydown",P),E.addEventListener("focusin",P),E.addEventListener("mouseleave",Te),{updateTime(d,u){const v=u>0?Math.min(d,u):d,Ye=u>0?v/u*100:0;a.style.width=`${Ye}%`,c.textContent=`${De(v)} / ${De(u)}`},updatePlaying(d){if(T&&$)return;const u=d!==x;x=d,n.classList.toggle("hfp-playing",d),n.setAttribute("aria-label",d?"Pause":"Play"),d?u&&Ee():(C&&clearTimeout(C),s.classList.remove("hfp-hidden"))},updateSpeed(d){i.indexOf(d),h.textContent=O(d),h.setAttribute("aria-label",`Playback speed: ${O(d)}`),me(d)},updateMuted(d){L=d,_(d,R),f.setAttribute("aria-label",d?"Unmute":"Mute")},updateVolume(d){R=d,A.style.width=`${d*100}%`,y.setAttribute("aria-valuenow",String(Math.round(d*100))),_(L,d)},setVolumeControlsHidden(d){m.style.display=d?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",ve),document.removeEventListener("mouseup",be),document.removeEventListener("touchmove",we),document.removeEventListener("touchend",Ae),document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",ue),document.removeEventListener("touchmove",ce),document.removeEventListener("touchend",pe),document.removeEventListener("click",_e),E.removeEventListener("mousemove",P),E.removeEventListener("keydown",P),E.removeEventListener("focusin",P),E.removeEventListener("mouseleave",Te),C&&clearTimeout(C),I==null||I.destroy(),s.remove()}}}function Rt(r,t,e,i,s,n=!1){const o=i?i.split(",").map(Number).filter(p=>!isNaN(p)&&p>0):void 0,a={...o?{speedPresets:o}:{},audioLocked:n},c=Tt(r,s,a);return c.updateMuted(t),c.updateVolume(e),c}function Me(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 Ct(r){return r.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("hfp-controls"))}let B=null;function kt(r,t){if(typeof CSSStyleSheet<"u")try{B||(B=new CSSStyleSheet,B.replaceSync(t)),r.adoptedStyleSheets=[B];return}catch{}const e=document.createElement("style");e.textContent=t,r.appendChild(e)}function Lt(){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="same-origin",t.title="HyperFrames Composition",t.setAttribute(Qe,""),r.appendChild(t),{container:r,iframe:t}}function Pt(r,t,e,i){const s=r.offsetWidth,n=r.offsetHeight;if(s===0||n===0)return!1;const o=Math.min(s/e,n/i);return t.style.width=`${e}px`,t.style.height=`${i}px`,t.style.transform=`translate(-50%, -50%) scale(${o})`,!0}const Dt=100,Mt=.001;function xt(r,t,e){if(e.end<=0)return!1;const i=e.shown<e.end&&t>0?t+Mt:0;return r+i>=e.end}class It{constructor(t){l(this,"_raf",null);l(this,"_lastUpdateMs",0);l(this,"_tick",null);this._callbacks=t}start(t,e,i,s,n){this.stop();let o=null,a=0,c=0;const p=()=>{if(s()){this._raf=null;return}let h;try{h=t.time()}catch{this._raf=null;return}const g=i(),m=n();m.end>0&&(h=Math.min(h,m.end));const f=o===null?0:h-o;f!==0&&(c=Math.min(f,a),a=f),o=h;const b=xt(h,c,m);b&&(h=m.shown);const _=performance.now();if((_-this._lastUpdateMs>Dt||b)&&(this._lastUpdateMs=_,this._callbacks.onTimeUpdate(h,g)),b){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{t.pause(),m.shown<m.end&&t.seek(m.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(p)};this._tick=p,this._raf=requestAnimationFrame(p)}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 Ot(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)Ft(i)||e.push(i);return Nt(r),e}function Nt(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 Ft(r){let t=r.parentElement;for(;t;){if(t.hasAttribute("data-composition-id"))return!0;t=t.parentElement}return!1}const J=.04,Vt=.5,Ut=.03,Ht=[[.3,.25],[.1,.1]],zt=.01,Wt=.1,$t=.1,Bt=.65,D=new WeakMap,X=new WeakSet;function jt(r,t,e,i,s=r.tagName==="AUDIO"){var g;const n=Math.abs(t);if(s&&et())return D.delete(r),{rate:e,seek:i&&n>Bt};i&&n<=J&&X.delete(r);const o=!X.has(r)||n>Vt;if(s&&i&&n>$t&&o)return D.delete(r),X.add(r),{rate:e,seek:!0};const a=Math.sign(t),c=D.get(r);if(n>J)D.set(r,a);else if(c!==a||n<=zt)return D.delete(r),{rate:e,seek:!1};const p=((g=Ht.find(([m])=>n>m))==null?void 0:g[1])??Ut,h=s?Math.min(p,Wt):p;return{rate:e*(1+a*h),seek:!1}}function qt(r){D.delete(r),X.delete(r)}const Gt=.004,Yt=1.5;class Xt{constructor(t){l(this,"_entries",[]);l(this,"_mediaObserver");l(this,"_playbackErrorPosted",!1);l(this,"_audioOwner","runtime");l(this,"_urlAudioEntry",null);l(this,"_urlAudioSrc",null);l(this,"_dispatchEvent");l(this,"_getMuted");l(this,"_getVolume");l(this,"_getPlaybackRate");l(this,"_getCurrentTime");l(this,"_isPaused");this._dispatchEvent=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=Re(t.source);t.start=e.start??0,t.mediaStart=Ce(t.source).mediaStart,t.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(t,e){return tt(e,t.start,t.start+t.duration)}_preseekUpcoming(t,e){const i=t.start-e;i<=0||i>Yt||!t.el.paused||Math.abs(t.el.currentTime-t.mediaStart)>J&&this._seekTo(t,t.mediaStart)}_seekTo(t,e,i=!1){const s=i?(t.seekLatency??0)*this._getPlaybackRate():0;t.seekIssuedAt=i?performance.now():void 0,t.el.currentTime=$e(e+s)}_noteSeekLanded(t){if(t.seekIssuedAt===void 0)return;const e=(performance.now()-t.seekIssuedAt)/1e3;t.seekLatency=t.seekLatency===void 0?e:(t.seekLatency+e)/2,t.seekIssuedAt=void 0}_releaseSteering(t){qt(t.el),t.lastOffset=void 0;const e=this._getPlaybackRate();t.el.playbackRate!==e&&(t.el.playbackRate=e)}_mediaTime(t,e){return e-t.start+t.mediaStart}_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(),this._releaseSteering(t),!1)}playAll(){for(const t of this._entries)this._playEntryIfActive(t)}primeAll(){if(it())for(const t of this._entries)t.el.paused&&(t.el.play().catch(()=>{}),t.el.pause())}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)&&this._jumpTo(e,this._mediaTime(e,t))}scrubAll(t){for(const e of this._entries)this._refreshEntryBounds(e),this._inWindow(e,t)?(this._jumpTo(e,this._mediaTime(e,t)),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){this._refreshEntryBounds(s),this._preseekUpcoming(s,t);const n=s.el.paused;if(!this._gateEntryPlayback(s,t))continue;const o=this._mediaTime(s,t),a=o-s.el.currentTime;if(i||n){Math.abs(a)>J&&this._jumpTo(s,o);continue}this._steer(s,o,a)}}_steer(t,e,i){const s=t.lastOffset!==void 0&&Math.abs(i-t.lastOffset)<Gt;t.lastOffset=i;const{rate:n,seek:o}=jt(t.el,i,this._getPlaybackRate(),s,!0);o?this._jumpTo(t,e,!0):Math.abs(t.el.playbackRate-n)>1e-6&&(t.el.playbackRate=n)}_jumpTo(t,e,i=!1){this._seekTo(t,e,i),this._releaseSteering(t)}promoteToParentProxy(t,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",t)for(const s of t.querySelectorAll("video, audio"))S(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)S(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(!n&&this._urlTaken(t))return null;const o=e==="video"?document.createElement("video"):new Audio;o.preload="auto";const a=n==null?void 0:n.getAttribute("crossorigin");a!=null&&o.setAttribute("crossorigin",a),o.src=t,o.load(),o.muted=this._getMuted(),o.volume=this._getVolume();const c=this._getPlaybackRate();c!==1&&(o.playbackRate=c);const p={el:o,start:i,duration:s,mediaStart:n?Ce(n).mediaStart:0,source:n};return o.addEventListener("seeked",()=>this._noteSeekLanded(p)),this._entries.push(p),p}_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"||this._entries.some(c=>c.source===t)||t.tagName==="VIDEO"&&t.hasAttribute("muted"))return;const e=this._resolveIframeMediaSrc(t);if(!e)return;const i=Re(t),s=i.start??0,n=i.duration??Number.POSITIVE_INFINITY,o=t.tagName==="VIDEO"?"video":"audio",a=this._createEntry(e,o,s,n,t);a&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(a))}_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){return this._entries.some(e=>e.source&&!e.source.isConnected?!1:(e.source&&this._resolveIframeMediaSrc(e.source)||e.el.src)===t)}_repointToSource(t){const e=t.source?this._resolveIframeMediaSrc(t.source):null;return!e||t.el.src===e?!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 o of n){if(o.type==="attributes"&&o.attributeName==="src"){const a=o.target;S(a)&&a.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(a);continue}if(o.type==="attributes"&&o.attributeName==="preload"){const a=o.target;S(a)&&a.matches("audio[data-start], video[data-start]")&&(a.preload==="auto"?this._adoptIframeMedia(a):this._detachIframeMedia(a));continue}for(const a of o.addedNodes){if(!ke(a))continue;const c=[];S(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const h of p)S(h)&&c.push(h);for(const h of c)this._adoptIframeMedia(h)}for(const a of o.removedNodes){if(!ke(a))continue;const c=[];S(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const h of p)S(h)&&c.push(h);for(const h of c)this._detachIframeMedia(h)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},s=Ot(t);for(const n of s)e.observe(n,i);this._mediaObserver=e}}function xe(r,t,e){if(r===null&&t===null)return{range:null,clamped:!1};const i=r??0,s=t!==null&&e>0&&t>e,n=s?e:t,o=n??(e>0?e:1/0);return!(i>=0)||!(o>i)?{range:null,clamped:!0}:{range:{start:i,end:n},clamped:s}}function de(r,t,e){const i=r.end??t;return i<t?st(r.start,i,e):i}function Ie(r,t,e,i){return r<t.start||r>=de(t,e,i)}const Kt=100;function Zt(r,t){return typeof r.currentTime=="number"&&Number.isFinite(r.currentTime)?r.currentTime:(r.frame??0)/t}function Be(r,t,e){return e<=0?!1:r.ended===!0?!0:r.ended===!1&&!r.isPlaying?!1:t>=e}function Jt(r,t,e,i,s,n){const{duration:o}=e;if(!s){const a=Be(r,t,o);return{start:0,shownAtEnd:o,atEnd:a,stopRuntime:!1,entering:!1}}if(r.ownsRange){const a=i&&r.ended===!0&&!r.isPlaying;return{start:s.start,shownAtEnd:t,atEnd:a,stopRuntime:!1,entering:!1}}return Qt(r,t,e,i,s,n)}function Qt(r,t,e,i,s,n){const o=s.end??e.duration,a=e.enteringRange===!0&&(t<s.start||t>=o);return{start:s.start,shownAtEnd:de(s,e.duration,n),atEnd:i&&!a&&Be(r,t,o),stopRuntime:r.isPlaying,entering:a}}function ei(r,t,e,i){var A;const s=Zt(r,t),n=!e.paused,o=n||r.isPlaying,a=(A=i.getPlayRange)==null?void 0:A.call(i),c=Jt(r,s,e,o,a,t),{atEnd:p,start:h}=c,g=e.duration>0?Math.min(s,e.duration):s,m=p?c.shownAtEnd:g,f=!r.isPlaying,b=p&&o;if(b&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(h),i.play(),{...e,currentTime:h,paused:!1,enteringRange:!0};const _={...e,currentTime:m,paused:f,enteringRange:c.entering};i.media.audioOwner==="parent"&&(n&&f?i.media.pauseAll():!n&&!f&&i.media.playAll(),i.media.mirrorTime(m));const w=performance.now(),y=f!==e.paused;return(w-e.lastUpdateMs>Kt||y)&&(_.lastUpdateMs=w,i.updateControlsTime(m,e.duration),i.updateControlsPlaying(!f),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:m}}))),b&&(c.stopRuntime&&i.seek(m),i.media.audioOwner==="parent"&&i.media.pauseAll(),_.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),_}function ti(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 ii(r,t,e){var o,a,c,p,h,g,m;if(r.source!==t)return;const i=r.data;if(!i||i.source!=="hf-preview")return;const s=rt(i);if(s.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:s.code,receivedVersion:s.receivedVersion}}));return}(o=e.setRuntimeFps)==null||o.call(e,s.fps);const n=s.status==="supported"&&s.metadata.capabilities.includes("play-range");if((a=e.setRuntimeOwnsPlayRange)==null||a.call(e,n),i.type==="shader-transition-state"){const f=i.state&&typeof i.state=="object"?i.state:{};e.shaderLoader.update(f,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:f}}));return}if(i.type==="ready"){e.onRuntimeReady();return}if(i.type==="assets-ready"){(c=e.onRuntimeAssetsReady)==null||c.call(e,i.timedOut===!0);return}if(i.type==="runtime-data-error"){(p=e.onRuntimeDataError)==null||p.call(e,i.channel,i.requestId,i.message);return}if(i.type==="runtime-data-applied"){(h=e.onRuntimeDataApplied)==null||h.call(e,i.channel,i.requestId);return}if(i.type==="state"){e.setPlaybackState(ei({frame:i.frame??0,currentTime:i.currentTime,ended:typeof i.ended=="boolean"?i.ended:void 0,isPlaying:!!i.isPlaying,ownsRange:n},s.fps,e.getPlaybackState(),e)),(g=e.setBuffering)==null||g.call(e,i.buffering===!0);return}if(i.type==="media-autoplay-blocked"){if(((m=e.shouldPromoteMediaAutoplayFallback)==null?void 0:m.call(e))===!1)return;let f=null;try{f=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(f,(b,_)=>e.media.mirrorTime(b,_)),e.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){const f=Number(i.durationSeconds),b=Number(i.durationInFrames),_=Number.isFinite(f)&&f>0?f:b/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(_)&&_>0){const w=e.getPlaybackState();e.setPlaybackState({...w,duration:_}),e.updateControlsTime(w.currentTime,_),e.onRuntimeTimelineReady(_,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}e.setScenes(ti(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 si(r,t){return r.includes(t)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}const ri=new Set([">"," "," ",`
573
+ `,"\r","\f"]);function te(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 o=e[n+i.length];if(ri.has(o)){const a=e.indexOf(">",n+i.length);return a<0?null:{index:n,end:a+1}}s=n+i.length}return null}function ni(r,t){if(!r||si(r,t))return r;const e=`<script src="${t}"><\/script>`,i=te(r,"head");if(i)return r.slice(0,i.end)+e+r.slice(i.end);const s=te(r,"body");if(s)return r.slice(0,s.index)+e+r.slice(s.index);const n=te(r,"html");return n?r.slice(0,n.end)+e+r.slice(n.end):e+r}const M="shader-capture-scale",U="shader-loading",ae="runtime-src",Oe="__hf_shader_capture_scale",Ne="__hf_shader_loading",K=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function le(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 oi(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 Fe(r,t){return r.filter(e=>e!==""&&e.split("=")[0]!==t)}function ai(r,t,e){const i=r.indexOf("#"),s=i>=0?r.slice(0,i):r,n=i>=0?r.slice(i):"",o=s.indexOf("?"),a=o>=0?s.slice(0,o):s,c=o>=0?s.slice(o+1):"";let p=Fe(c.split("&"),Oe);p=Fe(p,Ne),t!==null&&p.push(`${Oe}=${encodeURIComponent(t)}`),e!=="composition"&&p.push(`${Ne}=${encodeURIComponent(e)}`);const h=p.join("&");return`${a}${h?`?${h}`:""}${n}`}function di(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 Q(r){return oi(r.getAttribute(U))}function li(r){return Number(le(r.getAttribute(M))??"1")}function hi(r,t){return ai(t,le(r.getAttribute(M)),Q(r))}function j(r,t){return ni(di(t,le(r.getAttribute(M)),Q(r)),je(r))}function je(r){var e;const t=(e=r.getAttribute(ae))==null?void 0:e.trim();if(!t)return Y;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:Y}catch{return Y}}const qe="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",Ge="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",Ve=`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="${qe}"/><path d="${Ge}"/></svg>`)}")`;function ui(){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=_=>{_.preventDefault(),_.stopPropagation()};for(const _ of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(_,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;const s=document.createElement("slot");s.name="loading-mark",s.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">',`<path d="${qe}" fill="url(#hfp-shader-loader-grad-left)"/>`,`<path d="${Ge}" 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 n=document.createElement("div");n.className="hfp-shader-loader-sheen",n.style.setProperty("mask-image",Ve),n.style.setProperty("-webkit-mask-image",Ve),s.appendChild(n),i.appendChild(s);const o=document.createElement("div");o.className="hfp-shader-loader-title";const a=document.createElement("span");a.className="hfp-shader-loader-title-text",a.textContent=K[0],o.appendChild(a);const c=document.createElement("div");c.className="hfp-shader-loader-detail",c.textContent="Rendering animated scene samples for shader transitions.";const p=document.createElement("div");p.className="hfp-shader-loader-track",p.setAttribute("aria-hidden","true");const h=document.createElement("div");h.className="hfp-shader-loader-fill",p.appendChild(h);const g=document.createElement("div");g.className="hfp-shader-loader-progress";const m=_=>{const w=document.createElement("div");w.className="hfp-shader-loader-row";const y=document.createElement("span");y.className="hfp-shader-loader-label",y.textContent=_;const A=document.createElement("span");return A.className="hfp-shader-loader-value",w.appendChild(y),w.appendChild(A),g.appendChild(w),{row:w,label:y,value:A}},f=m("transition"),b=m("transition frame");return e.appendChild(i),e.appendChild(o),e.appendChild(c),e.appendChild(p),e.appendChild(g),r.appendChild(e),{root:r,fill:h,title:a,detail:c,transitionValue:f.value,transitionRow:f.row,frameLabel:b.label,frameValue:b.value,frameRow:b.row}}const ci=420;function q(r,t,e){t.textContent=e,r.style.visibility=e?"visible":"hidden"}class pi{constructor(t){l(this,"_el");l(this,"_hideTimeout",null);l(this,"_hiddenCallbacks",[]);l(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._el.root.classList.remove("hfp-assets"),this._flushHidden(),this._el.fill.style.transform="scaleX(0)",q(this._el.transitionRow,this._el.transitionValue,""),q(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,this._el.root.classList.remove("hfp-assets");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,o=n>0?Math.min(1,Math.max(0,s/n)):0,a=Math.min(K.length-1,Math.floor(o*K.length));this._el.title.textContent=K[a]||"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(${o})`;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",q(this._el.transitionRow,this._el.transitionValue,c),q(this._el.frameRow,this._el.frameValue,p),this._el.root.setAttribute("aria-valuenow",String(Math.round(o*100))),this.show()}showAssetsLoading(t="Loading assets",e="Waiting for images, video and fonts to finish loading."){this.reset(),this._el.title.textContent=t,this._el.detail.textContent=e,this._el.root.setAttribute("aria-label",t),this._drawingAssets=!0,this._el.root.classList.add("hfp-assets"),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()},ci)}}function fi(r){return(r==null?void 0:r.trim().toLowerCase().startsWith("video/"))??!1}function mi(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("timeupdate",()=>r.onTimeUpdate(),{signal:i}),t.addEventListener("error",()=>{var n,o;return r.onError(((n=t.error)==null?void 0:n.message)||"Video failed to load",((o=t.error)==null?void 0:o.code)??null)},{signal:i}),{video:t,adapter:{duration:()=>t.duration,time:()=>t.currentTime,seek:n=>{t.currentTime=$e(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 _i=.1,gi=5,ie="sandbox-origin",Ue=1e4,se=8e3,re="assets-loading",N="assets-loading-ui",G="buffering",ne="low-power-idle",He="disable-click-to-play",ze="disable-fullscreen",F="range-start",V="range-end",We=150;function oe(r){return!Number.isFinite(r)||r<=0?1:Math.max(_i,Math.min(gi,r))}class yi extends HTMLElement{constructor(){super();l(this,"shadow");l(this,"container");l(this,"sizer",document.createElement("div"));l(this,"iframe");l(this,"posterEl",null);l(this,"controlsApi",null);l(this,"resizeObserver");l(this,"shaderLoader");l(this,"probe");l(this,"_ready",!1);l(this,"_readyDocument",null);l(this,"_connected",!1);l(this,"_assetsReady",!1);l(this,"_painted",!1);l(this,"_pendingPlay",!1);l(this,"_assetsGeneration",0);l(this,"_assetsLoadingShowTimer",null);l(this,"_bufferingShowTimer",null);l(this,"_currentTime",0);l(this,"_duration",0);l(this,"_paused",!0);l(this,"_scrubbing",!1);l(this,"_lastUpdateMs",0);l(this,"_volume",1);l(this,"_compositionWidth",1920);l(this,"_compositionHeight",1080);l(this,"_rescaleWarned",!1);l(this,"_directTimelineAdapter",null);l(this,"_directTimelineClock");l(this,"_parentTickRaf",null);l(this,"_media");l(this,"_scenes",[]);l(this,"_runtimeFps",30);l(this,"_runtimeBridgeReady",!1);l(this,"_runtimeAssetsReadyGeneration",-1);l(this,"_runtimeData",new Map);l(this,"_runtimeDataRequestId",0);l(this,"_pendingRuntimeData",new Map);l(this,"_afterUpdate",null);l(this,"_videoSource",null);l(this,"_runtimeOwnsPlayRange",!1);l(this,"_enteringRange",!1);l(this,"_rangeClampReported","");this.shadow=this.attachShadow({mode:"open"}),kt(this.shadow,mt),{container:this.container,iframe:this.iframe}=Lt(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);const e=ui();this.shadow.appendChild(e.root),this.shaderLoader=new pi(e),this._media=new Xt({dispatchEvent:i=>this._emit(i),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new It({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:()=>{var i;this.seek(((i=this._playRange())==null?void 0:i.start)??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 ft(this.iframe,{resolveRuntimeUrl:()=>je(this),hostOwnsDeadline:()=>this.hasAttribute("no-load-timeout"),onReady:i=>this._onProbeReady(i),onError:i=>this._emit(new CustomEvent("error",{detail:{message:i}}))}),this.addEventListener("click",i=>{this.disableClickToPlay||Ct(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",ie,ae,M,U,N,ne,F,V]}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=Me(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=j(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,o,a,c,p;switch(e){case"src":if(!this.isConnected)break;(s||this._videoSource)&&this._navigateSrc(s??"");break;case"type":{const h=this.getAttribute("src");if(!this.isConnected||h===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(h);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=j(this,s);else{this.iframe.removeAttribute("srcdoc");const h=this.getAttribute("src");h!==null&&this._wantsVideo()&&this._navigateSrc(h)}break;case ie:this._applySandboxOriginPolicy(this.isConnected&&i!==s);break;case"width":this._setCompositionSize(Z(s)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,Z(s)??1080);break;case"controls":s!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=Me(this.shadow,s,this.posterEl);break;case"playback-rate":{const h=oe(parseFloat(s||"1"));this._media.updatePlaybackRate(h),this._sendControl("set-playback-rate",{playbackRate:h}),(a=(o=this._directTimelineAdapter)==null?void 0:o.timeScale)==null||a.call(o,h),(c=this.controlsApi)==null||c.updateSpeed(h),this._emit(new Event("ratechange"));break}case"muted":this._handleMutedChange(s);break;case"audio-locked":this._applyAudioLock(s!==null);break;case"volume":{const h=Math.max(0,Math.min(1,parseFloat(s||"1")));this._volume=h,this._syncVideoAudio(),this._media.updateVolume(h),this._sendControl("set-volume",{volume:h}),(p=this.controlsApi)==null||p.updateVolume(h),this._emit(new Event("volumechange"));break}case"audio-src":s?this._media.setupFromUrl(s):this._media.teardownUrlAudio();break;case N:s==="none"&&this.shaderLoader.hideAssetsLoading();break;case ne:this._sendControl("set-idle-heartbeat",{slow:s!==null});break;case F:case V:this._applyPlayRange(!0);break;case M:case U:case ae:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(ie)?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=j(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(){this._play(!0)}_play(e){var o,a;if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,(o=this.posterEl)==null||o.remove(),this.posterEl=null;const i=this._ready?this._playRange():null;i?Ie(this._currentTime,i,this._duration,this._runtimeFps)&&(this.seek(i.start),this._enteringRange=!0):this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const s=this._tryDirectTimelinePlay();let n=!1;this._sendDisplayScale(),s||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,n=!0)),this._media.audioOwner==="parent"?this._media.playAll():this._media.primeAll(),(a=this.controlsApi)==null||a.updatePlaying(!0),!n&&e&&this._emit(new Event("play")),s&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused,()=>this._clockStop())}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,i){var n,o;const s=(i==null?void 0:i.keepPlaying)===!0&&(!this._paused||this._pendingPlay);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,(n=this.controlsApi)==null||n.updatePlaying(!1),(o=this.controlsApi)==null||o.updateTime(this._currentTime,this._duration),s&&this._play(!1)}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 oe(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(oe(e)))}get shaderCaptureScale(){return li(this)}set shaderCaptureScale(e){this.setAttribute(M,String(e))}get shaderLoading(){return Q(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(U):this.setAttribute(U,e)}get assetsLoadingUi(){return this.getAttribute(N)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(N,"none"):this.removeAttribute(N)}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(He)}set disableClickToPlay(e){this.toggleAttribute(He,e)}get disableFullscreen(){return this.hasAttribute(ze)}set disableFullscreen(e){this.toggleAttribute(ze,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(F)}set rangeStart(e){this._writeSeconds(F,e)}get rangeEnd(){return this._readSeconds(V)}set rangeEnd(e){this._writeSeconds(V,e)}_readSeconds(e){const i=this.getAttribute(e);return i===null?null:Number(i)}_writeSeconds(e,i){i==null?this.removeAttribute(e):this.setAttribute(e,String(i))}_hasPlayRange(){return this.hasAttribute(F)||this.hasAttribute(V)}_playRange(){return xe(this.rangeStart,this.rangeEnd,this._duration).range}_sendPlayRange(e){const i=(e==null?void 0:e.end)??null;this._sendControl("set-play-range",{startSeconds:(e==null?void 0:e.start)??null,endSeconds:i})}_applyPlayRange(e){const{range:i,clamped:s}=xe(this.rangeStart,this.rangeEnd,this._duration);this._sendPlayRange(i),this._ready&&(this._reportRangeClamp(i,s),i&&e&&!this._pendingPlay&&this._moveIntoPlayRange(i))}_reportRangeClamp(e,i){const s=i?`${this.rangeStart},${this.rangeEnd},${this._duration}`:"";if(s===this._rangeClampReported||(this._rangeClampReported=s,!i))return;const n={rangeStart:(e==null?void 0:e.start)??null,rangeEnd:(e==null?void 0:e.end)??null};this._emit(new CustomEvent("rangeclamped",{detail:{...n,duration:this._duration}}))}_moveIntoPlayRange(e){Ie(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(){const e=this._playRange(),i=(e==null?void 0:e.end)??this._duration;if(!e)return{end:i,shown:i};const s=de(e,this._duration,this._runtimeFps);return{end:i,shown:s<i?(s+i)/2:s}}_sendControl(e,i={}){try{const s=this.iframe.contentWindow;return s?(s.postMessage({...i,source:"hf-parent",type:"control",action:e,...nt(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 o=(n=this.iframe.contentWindow)==null?void 0:n.__hyperframes;return typeof(o==null?void 0:o.setRuntimeData)!="function"?!1:(o.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 ${Ue}ms`)},Ue);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"))S(s)&&(s.muted=e||s.defaultMuted)}_stopIframeMedia(){const e=this._getSameOriginIframeDocument();if(e)for(const i of e.querySelectorAll("video, audio"))S(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(ne)}),this._sendDisplayScale()}_sendDisplayScale(){const e=ot(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=j(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 fi(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=hi(this,e)}_loadVideo(e){var n,o;this._videoSource||(this._videoSource=mi({onMetadata:a=>this._applyThenEmit(()=>this._onVideoReady(a)),onDurationChange:a=>this._applyTimelineDuration(a.duration),onResize:a=>this._applyVideoSize(a),onPlay:a=>{!a.paused&&this._paused&&this.play()},onPause:a=>{a.paused&&!a.ended&&!this._paused&&this.pause()},onTimeUpdate:()=>{document.hidden&&this._playRange()&&this._directTimelineClock.poll()},onError:(a,c)=>{this._paused||this.pause(),this._emit(new CustomEvent("error",{detail:{message:a,code:c}}))},onPlayRejected:a=>this._onVideoPlayRejected(a)}),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(),(o=s.timeScale)==null||o.call(s,this.playbackRate),e?i.src=e:(i.removeAttribute("src"),i.load())}_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.probe.failed||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){ii(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs,enteringRange:this._enteringRange}),setPlaybackState:({currentTime:i,duration:s,paused:n,lastUpdateMs:o,enteringRange:a})=>{this._enteringRange=a===!0,this._currentTime=i,this._setDuration(s),this._paused=n,this._lastUpdateMs=o},getShaderLoadingMode:()=>Q(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._hasPlayRange()&&this._sendPlayRange(this._playRange()),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),setBuffering:i=>this._setBuffering(i),setRuntimeFps:i=>{this._runtimeFps=i},setRuntimeOwnsPlayRange:i=>{this._runtimeOwnsPlayRange=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,getPlayRange:()=>this._playRange(),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 o;this._setDuration(e),this._directTimelineAdapter=i.kind==="direct-timeline"?i.timeline:null,s&&this._setCompositionSize(s.width,s.height),this._ready=!0,(o=this.controlsApi)==null||o.updateTime(0,e),this._dispatchReady();const n=this._getSameOriginIframeDocument();n&&this._media.setupFromIframe(n),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(n),this._playWhenWanted()}_waitForAssetsReady(e,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),se)):this._settleAssetsReady(s);return}at(e,({timedOut:n})=>{s===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(s))},{timeoutMs:se}),this._assetsReady||this._startAssetsLoadingOverlayTimer(s)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(re,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},We)}_setBuffering(e){if(e){if(this._bufferingShowTimer!==null||this.hasAttribute(G))return;this._bufferingShowTimer=setTimeout(()=>{this._bufferingShowTimer=null,this.setAttribute(G,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading("Buffering","")},We);return}this._bufferingShowTimer!==null&&clearTimeout(this._bufferingShowTimer),this._bufferingShowTimer=null,this.hasAttribute(G)&&(this.removeAttribute(G),this.shaderLoader.hideAssetsLoading())}_hasPendingFirstFrameAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=Le(e,{scope:Pe});return i.length>0||s.length>0||n}_warnStuckAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=Le(e,{scope:Pe}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${se}ms, playing anyway`,{stuckMedia:i.map(a=>a.currentSrc||a.getAttribute("src")||`<${a.tagName.toLowerCase()}>`),stuckImages:s.map(a=>a.currentSrc||a.getAttribute("src")||"<img>"),fontsLoading:n,computeReady:(o==null?void 0:o.__renderReady)===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(re),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this.probe.stop(),this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._runtimeOwnsPlayRange=!1,this._enteringRange=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this._setBuffering(!1),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(re),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(),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,i){const s=e!==this._compositionWidth||i!==this._compositionHeight;if(this._compositionWidth=e,this._compositionHeight=i,this.sizer.style.aspectRatio=`${e} / ${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=o=>{try{o()}catch(a){s.push(a)}};n(e);for(const o of i)n(o);if(this._afterUpdate=null,s.length>0)throw s[0]}_afterEvents(e){this._afterUpdate?this._afterUpdate.push(e):e()}_playWhenWanted(){this._afterEvents(()=>{(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()})}_emit(e){this._afterEvents(()=>this.dispatchEvent(e))}_rescale(){const e=Pt(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;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=Rt(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()),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,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",yi);export{yi as HyperframesPlayer,St as SPEED_PRESETS,O as formatSpeed,De as formatTime};