@hyperframes/studio 0.9.64 → 0.9.66

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 (99) hide show
  1. package/dist/assets/hyperframes-player-VGx6ow_e.js +573 -0
  2. package/dist/assets/{index-CVmmHGol.js → index-B8Xt_Oyw.js} +190 -186
  3. package/dist/assets/{index-DN167Uqf.js → index-BH18TdX9.js} +1 -1
  4. package/dist/assets/{pausedVideoDecoder-C8rhpGPx.js → pausedVideoDecoder-Bx3fGNkU.js} +1 -1
  5. package/dist/{chunk-VDDEXNVX.js → chunk-ESTBKVCB.js} +8 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.html +1 -1
  8. package/dist/index.js +1580 -882
  9. package/dist/player.js +1 -1
  10. package/package.json +8 -8
  11. package/src/captions/components/CaptionOverlay.sealed.test.ts +2 -25
  12. package/src/captions/hooks/useCaptionSync.ts +4 -1
  13. package/src/components/editor/LayersPanel.opaque.test.ts +4 -29
  14. package/src/components/editor/MotionPathOverlay.sealed.test.tsx +85 -0
  15. package/src/components/editor/MotionPathOverlay.tsx +26 -12
  16. package/src/components/editor/domEditOverlayCrop.ts +78 -15
  17. package/src/components/editor/domEditOverlayCropFrameLift.test.ts +64 -0
  18. package/src/components/editor/domEditOverlayStartGesture.ts +0 -14
  19. package/src/components/editor/gestureUndoRevert.ts +3 -6
  20. package/src/components/editor/gsapMoveSealedPreview.test.ts +247 -0
  21. package/src/components/editor/manualEditsSnapshot.ts +2 -0
  22. package/src/components/editor/manualOffsetDrag.ts +13 -18
  23. package/src/components/editor/plainTranslate.test.ts +22 -1
  24. package/src/components/editor/plainTranslate.ts +8 -6
  25. package/src/components/editor/previewDrafts.test.ts +13 -39
  26. package/src/components/editor/previewDrafts.ts +4 -0
  27. package/src/components/editor/previewGestureStartRead.test.ts +59 -32
  28. package/src/components/editor/previewGestureStartRead.ts +9 -0
  29. package/src/components/editor/previewLayers.test.ts +3 -20
  30. package/src/components/editor/previewOverlayRects.test.ts +3 -20
  31. package/src/components/editor/previewPointerTargets.test.ts +3 -20
  32. package/src/components/editor/previewSelection.test.ts +51 -35
  33. package/src/components/editor/previewSelection.ts +18 -0
  34. package/src/components/editor/useColorGradingController.sealed.test.ts +5 -30
  35. package/src/components/editor/useMotionPathData.reply.test.ts +40 -0
  36. package/src/components/editor/useMotionPathData.sealed.test.ts +57 -0
  37. package/src/components/editor/useMotionPathData.test.tsx +1 -1
  38. package/src/components/editor/useMotionPathData.ts +83 -33
  39. package/src/components/nle/CompositionBreadcrumb.tsx +2 -5
  40. package/src/components/nle/NLEContext.drillDown.test.ts +85 -0
  41. package/src/components/nle/NLEContext.tsx +21 -23
  42. package/src/components/nle/NLEPreview.test.ts +18 -3
  43. package/src/components/nle/NLEPreview.tsx +10 -1
  44. package/src/components/nle/audioSealedPreview.test.ts +5 -32
  45. package/src/components/panels/motionBlurPanelModel.sealed.test.ts +30 -0
  46. package/src/components/panels/motionBlurPanelModel.ts +37 -7
  47. package/src/hooks/appHotkeysDispatch.ts +38 -1
  48. package/src/hooks/domEditCommits.sealed.test.ts +191 -0
  49. package/src/hooks/domStyleCommit.ts +18 -7
  50. package/src/hooks/draggedGsapPosition.ts +20 -0
  51. package/src/hooks/gsapEditOutcome.ts +3 -0
  52. package/src/hooks/gsapFrameSnapshot.test.ts +113 -0
  53. package/src/hooks/gsapFrameSnapshot.ts +246 -0
  54. package/src/hooks/gsapParsedTween.ts +16 -9
  55. package/src/hooks/gsapResizeIntercept.ts +7 -2
  56. package/src/hooks/gsapRuntimeBridge.ts +4 -0
  57. package/src/hooks/gsapRuntimeKeyframes.ts +23 -15
  58. package/src/hooks/gsapShared.ts +4 -0
  59. package/src/hooks/gsapSnapshotReply.ts +105 -0
  60. package/src/hooks/useAppHotkeys.previewForwarding.test.tsx +134 -0
  61. package/src/hooks/useAppHotkeys.ts +36 -1
  62. package/src/hooks/useDomEditAttributeCommits.ts +43 -19
  63. package/src/hooks/useDomEditCommits.test.tsx +1 -1
  64. package/src/hooks/useDomEditPreviewSync.test.ts +36 -1
  65. package/src/hooks/useDomEditPreviewSync.ts +3 -3
  66. package/src/hooks/useEditorSave.ts +2 -1
  67. package/src/hooks/useEnableKeyframes.sealed.test.ts +70 -0
  68. package/src/hooks/useEnableKeyframes.ts +9 -2
  69. package/src/hooks/useGsapTweenCache.ts +9 -3
  70. package/src/hooks/usePreviewPersistence.ts +18 -11
  71. package/src/hooks/useSdkSession.lifecycle.test.tsx +1 -0
  72. package/src/hooks/useSdkSession.ts +2 -0
  73. package/src/hooks/useSlideshowTabState.test.ts +47 -3
  74. package/src/hooks/useSlideshowTabState.ts +32 -16
  75. package/src/player/hooks/timelinePlayerTestHarness.ts +2 -1
  76. package/src/player/hooks/usePlaybackKeyboard.ts +1 -1
  77. package/src/player/hooks/useTimelineSyncCallbacks.sealed.test.ts +2 -29
  78. package/src/player/lib/previewChannel.test.ts +10 -0
  79. package/src/player/lib/previewChannel.ts +9 -0
  80. package/src/player/lib/previewElements.test.ts +34 -1
  81. package/src/player/lib/previewElements.ts +101 -18
  82. package/src/player/lib/sealedPreviewFrame.test-helpers.ts +38 -0
  83. package/src/player/lib/timelineIframeHelpers.ts +1 -1
  84. package/src/telemetry/client.ts +4 -2
  85. package/src/telemetry/eventShape.test.ts +189 -0
  86. package/src/telemetry/eventShape.ts +192 -0
  87. package/src/utils/blockInstaller.test.ts +82 -48
  88. package/src/utils/blockInstaller.ts +6 -14
  89. package/src/utils/domEditSaveQueue.test.ts +12 -2
  90. package/src/utils/domEditSaveQueue.ts +4 -4
  91. package/src/utils/previewCompositionSize.test.ts +61 -0
  92. package/src/utils/previewCompositionSize.ts +21 -1
  93. package/src/utils/sdkEditTransaction.ts +6 -2
  94. package/src/utils/sdkResolverShadow.ts +16 -15
  95. package/src/utils/studioSaveDiagnostics.test.ts +21 -3
  96. package/src/utils/studioSaveDiagnostics.ts +71 -6
  97. package/src/utils/studioTelemetry.ts +6 -1
  98. package/dist/assets/hyperframes-player-mSF_GvRs.js +0 -573
  99. package/src/components/editor/motionPathHome.ts +0 -75
@@ -1,573 +0,0 @@
1
- var qe=Object.defineProperty;var Ge=(r,t,e)=>t in r?qe(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var l=(r,t,e)=>Ge(r,typeof t!="symbol"?t+"":t,e);import{S as Ye,r as Xe,P as Ke,i as Ze,a as Ae,b as we,c as Je,m as He,s as Qe,d as w,e as Se,p as et,f as tt,g as it,h as st,j as rt,k as Ee,F as Te}from"./index-CVmmHGol.js";function nt(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function V(r){return typeof r=="object"&&r!==null}function ot(r){return V(r)&&typeof r.getDuration=="function"}function at(r){return V(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function dt(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 q=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:dt("0.0.0-dev");function X(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function lt(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=X(t.getAttribute("data-width")),i=X(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}function ht(r){return Array.isArray(r)?r.find(t=>typeof t=="string"&&t.trim()!==""&&t!=="[object Event]")??null:null}class ut{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=ht(Reflect.get(e,Ye));if(i!==null)return{kind:"error",message:i};const s=this._iframe.contentDocument,n=Reflect.get(e,"__timelines"),o=this.hasRuntimeBridge(e);if(nt({hasRuntime:o,hasTimelines:V(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=Xe(e))==null?void 0:n.durationSeconds)??0:0}return s<=0?null:{duration:s,adapter:{...i,getDuration:()=>s},compositionSize:lt(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 V(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))??q,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(!V(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 at(o)?o:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ot(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const ct=`
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
- `,pt='<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>',ft='<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>',Re='<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>',Ce='<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>',mt='<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>',_t='<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>',gt='<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>',yt=[.25,.5,1,1.5,2,4];function x(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function Le(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 vt(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?gt:_t,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 bt(r,t,e={}){const i=e.speedPresets??yt,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">${pt}</span><span class="hfp-ico hfp-ico-pause">${ft}</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=x(d),d===1&&u.classList.add("hfp-active"),g.appendChild(u)}p.appendChild(g),p.appendChild(h);const _=document.createElement("div");_.className="hfp-volume-wrap";const m=document.createElement("button");m.className="hfp-mute-btn",m.type="button",m.innerHTML=Re,m.setAttribute("aria-label","Mute");const y=document.createElement("div");y.className="hfp-volume-slider-wrap";const f=document.createElement("div");f.className="hfp-volume-slider",f.setAttribute("role","slider"),f.setAttribute("aria-label","Volume"),f.setAttribute("aria-valuemin","0"),f.setAttribute("aria-valuemax","100"),f.setAttribute("aria-valuenow","100"),f.tabIndex=0;const b=document.createElement("div");b.className="hfp-volume-fill",b.style.width="100%",f.appendChild(b),y.appendChild(f),_.appendChild(y),_.appendChild(m),e.audioLocked&&(_.style.display="none"),s.appendChild(n),s.appendChild(o),s.appendChild(c),s.appendChild(_),s.appendChild(p),r.appendChild(s);let A=!1,S=!1,R=1,C=null;i.indexOf(1);const U=(d,u)=>d?mt:u===0||u<.5?Ce:Re;n.addEventListener("click",d=>{d.stopPropagation(),A?t.onPause():t.onPlay()}),m.addEventListener("click",d=>{d.stopPropagation(),t.onMuteToggle()});let L=!1;const H=d=>{const u=f.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-u.left)/u.width));R=v,b.style.width=`${v*100}%`,f.setAttribute("aria-valuenow",String(Math.round(v*100))),S&&v>0&&t.onMuteToggle(),m.innerHTML=U(S,v),t.onVolumeChange(v)};f.addEventListener("mousedown",d=>{d.stopPropagation(),L=!0,H(d.clientX)});const ae=d=>{L&&H(d.clientX)},de=()=>{L=!1};document.addEventListener("mousemove",ae),document.addEventListener("mouseup",de),f.addEventListener("touchstart",d=>{L=!0;const u=d.touches[0];u&&H(u.clientX)},{passive:!0});const le=d=>{if(L){const u=d.touches[0];u&&H(u.clientX)}},he=()=>{L=!1};document.addEventListener("touchmove",le,{passive:!0}),document.addEventListener("touchend",he);const ue=.05;f.addEventListener("keydown",d=>{let u=R;if(d.key==="ArrowRight"||d.key==="ArrowUp")u=Math.min(1,R+ue);else if(d.key==="ArrowLeft"||d.key==="ArrowDown")u=Math.max(0,R-ue);else return;d.preventDefault(),d.stopPropagation(),R=u,b.style.width=`${u*100}%`,f.setAttribute("aria-valuenow",String(Math.round(u*100))),S&&u>0&&t.onMuteToggle(),m.innerHTML=U(S,u),t.onVolumeChange(u)});const ce=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=x(v),h.setAttribute("aria-label",`Playback speed: ${x(v)}`),ce(v),g.classList.remove("hfp-open"),h.setAttribute("aria-expanded","false"),t.onSpeedChange(v)});const pe=()=>{g.classList.remove("hfp-open"),h.setAttribute("aria-expanded","false")};document.addEventListener("click",pe);const z=d=>{const u=o.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-u.left)/u.width));t.onSeek(v)};let E=!1;o.addEventListener("mousedown",d=>{var u;d.stopPropagation(),E=!0,(u=t.onScrubStart)==null||u.call(t),z(d.clientX)});const fe=d=>{E&&z(d.clientX)},me=()=>{var d;E&&(E=!1,(d=t.onScrubEnd)==null||d.call(t))};document.addEventListener("mousemove",fe),document.addEventListener("mouseup",me),o.addEventListener("touchstart",d=>{var v;E=!0,(v=t.onScrubStart)==null||v.call(t);const u=d.touches[0];u&&z(u.clientX)},{passive:!0});const _e=d=>{if(E){const u=d.touches[0];u&&z(u.clientX)}},ge=()=>{var d;E&&(E=!1,(d=t.onScrubEnd)==null||d.call(t))};document.addEventListener("touchmove",_e,{passive:!0}),document.addEventListener("touchend",ge);const ye=()=>A&&!E&&!L&&!s.querySelector(":focus-visible"),ve=()=>{s.classList.remove("hfp-hidden"),C&&clearTimeout(C),C=setTimeout(()=>{ye()&&s.classList.add("hfp-hidden")},3e3)},T=r instanceof ShadowRoot?r.host:r,M=vt(T);M&&s.appendChild(M.button);const k=()=>ve(),be=()=>{ye()&&s.classList.add("hfp-hidden")};return T.addEventListener("mousemove",k),T.addEventListener("keydown",k),T.addEventListener("focusin",k),T.addEventListener("mouseleave",be),{updateTime(d,u){const v=u>0?Math.min(d,u):d,je=u>0?v/u*100:0;a.style.width=`${je}%`,c.textContent=`${Le(v)} / ${Le(u)}`},updatePlaying(d){const u=d!==A;A=d,n.classList.toggle("hfp-playing",d),n.setAttribute("aria-label",d?"Pause":"Play"),d?u&&ve():(C&&clearTimeout(C),s.classList.remove("hfp-hidden"))},updateSpeed(d){i.indexOf(d),h.textContent=x(d),h.setAttribute("aria-label",`Playback speed: ${x(d)}`),ce(d)},updateMuted(d){S=d,m.innerHTML=U(d,R),m.setAttribute("aria-label",d?"Unmute":"Mute")},updateVolume(d){R=d,b.style.width=`${d*100}%`,f.setAttribute("aria-valuenow",String(Math.round(d*100))),m.innerHTML=U(S,d)},setVolumeControlsHidden(d){_.style.display=d?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",me),document.removeEventListener("touchmove",_e),document.removeEventListener("touchend",ge),document.removeEventListener("mousemove",ae),document.removeEventListener("mouseup",de),document.removeEventListener("touchmove",le),document.removeEventListener("touchend",he),document.removeEventListener("click",pe),T.removeEventListener("mousemove",k),T.removeEventListener("keydown",k),T.removeEventListener("focusin",k),T.removeEventListener("mouseleave",be),C&&clearTimeout(C),M==null||M.destroy(),s.remove()}}}function At(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=bt(r,s,a);return c.updateMuted(t),c.updateVolume(e),c}function ke(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 wt(r){return r.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("hfp-controls"))}let W=null;function St(r,t){if(typeof CSSStyleSheet<"u")try{W||(W=new CSSStyleSheet,W.replaceSync(t)),r.adoptedStyleSheets=[W];return}catch{}const e=document.createElement("style");e.textContent=t,r.appendChild(e)}function Et(){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(Ke,""),r.appendChild(t),{container:r,iframe:t}}function Tt(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 Rt=100,Ct=.001;function Lt(r,t,e){if(e.end<=0)return!1;const i=e.shown<e.end&&t>0?t+Ct:0;return r+i>=e.end}class kt{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(),_=n();_.end>0&&(h=Math.min(h,_.end));const m=o===null?0:h-o;m!==0&&(c=Math.min(m,a),a=m),o=h;const y=Lt(h,c,_);y&&(h=_.shown);const f=performance.now();if((f-this._lastUpdateMs>Rt||y)&&(this._lastUpdateMs=f,this._callbacks.onTimeUpdate(h,g)),y){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{t.pause(),_.shown<_.end&&t.seek(_.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 Pt(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)Mt(i)||e.push(i);return Dt(r),e}function Dt(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 Mt(r){let t=r.parentElement;for(;t;){if(t.hasAttribute("data-composition-id"))return!0;t=t.parentElement}return!1}const K=.04,xt=.5,It=.03,Ot=[[.3,.25],[.1,.1]],Nt=.01,Ft=.1,Vt=.1,Ut=.65,P=new WeakMap,G=new WeakSet;function Ht(r,t,e,i,s=r.tagName==="AUDIO"){var g;const n=Math.abs(t);if(s&&Ze())return P.delete(r),{rate:e,seek:i&&n>Ut};i&&n<=K&&G.delete(r);const o=!G.has(r)||n>xt;if(s&&i&&n>Vt&&o)return P.delete(r),G.add(r),{rate:e,seek:!0};const a=Math.sign(t),c=P.get(r);if(n>K)P.set(r,a);else if(c!==a||n<=Nt)return P.delete(r),{rate:e,seek:!1};const p=((g=Ot.find(([_])=>n>_))==null?void 0:g[1])??It,h=s?Math.min(p,Ft):p;return{rate:e*(1+a*h),seek:!1}}function zt(r){P.delete(r),G.delete(r)}const Wt=.004,$t=1.5;class Bt{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=Ae(t.source);t.start=e.start??0,t.mediaStart=we(t.source).mediaStart,t.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(t,e){return Je(e,t.start,t.start+t.duration)}_preseekUpcoming(t,e){const i=t.start-e;i<=0||i>$t||!t.el.paused||Math.abs(t.el.currentTime-t.mediaStart)>K&&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=He(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){zt(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(Qe())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)>K&&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)<Wt;t.lastOffset=i;const{rate:n,seek:o}=Ht(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"))w(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)w(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?we(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=Ae(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;w(a)&&a.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(a);continue}if(o.type==="attributes"&&o.attributeName==="preload"){const a=o.target;w(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(!Se(a))continue;const c=[];w(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)w(h)&&c.push(h);for(const h of c)this._adoptIframeMedia(h)}for(const a of o.removedNodes){if(!Se(a))continue;const c=[];w(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)w(h)&&c.push(h);for(const h of c)this._detachIframeMedia(h)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},s=Pt(t);for(const n of s)e.observe(n,i);this._mediaObserver=e}}function Pe(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 ne(r,t,e){const i=r.end??t;return i<t?et(r.start,i,e):i}function De(r,t,e,i){return r<t.start||r>=ne(t,e,i)}const jt=100;function qt(r,t){return typeof r.currentTime=="number"&&Number.isFinite(r.currentTime)?r.currentTime:(r.frame??0)/t}function ze(r,t,e){return e<=0?!1:r.ended===!0?!0:r.ended===!1&&!r.isPlaying?!1:t>=e}function Gt(r,t,e,i,s,n){const{duration:o}=e;if(!s){const a=ze(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 Yt(r,t,e,i,s,n)}function Yt(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:ne(s,e.duration,n),atEnd:i&&!a&&ze(r,t,o),stopRuntime:r.isPlaying,entering:a}}function Xt(r,t,e,i){var S;const s=qt(r,t),n=!e.paused,o=n||r.isPlaying,a=(S=i.getPlayRange)==null?void 0:S.call(i),c=Gt(r,s,e,o,a,t),{atEnd:p,start:h}=c,g=e.duration>0?Math.min(s,e.duration):s,_=p?c.shownAtEnd:g,m=!r.isPlaying,y=p&&o;if(y&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(h),i.play(),{...e,currentTime:h,paused:!1,enteringRange:!0};const f={...e,currentTime:_,paused:m,enteringRange:c.entering};i.media.audioOwner==="parent"&&(n&&m?i.media.pauseAll():!n&&!m&&i.media.playAll(),i.media.mirrorTime(_));const b=performance.now(),A=m!==e.paused;return(b-e.lastUpdateMs>jt||A)&&(f.lastUpdateMs=b,i.updateControlsTime(_,e.duration),i.updateControlsPlaying(!m),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:_}}))),y&&(c.stopRuntime&&i.seek(_),i.media.audioOwner==="parent"&&i.media.pauseAll(),f.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),f}function Kt(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 Zt(r,t,e){var o,a,c,p,h,g,_;if(r.source!==t)return;const i=r.data;if(!i||i.source!=="hf-preview")return;const s=tt(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 m=i.state&&typeof i.state=="object"?i.state:{};e.shaderLoader.update(m,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:m}}));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(Xt({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(((_=e.shouldPromoteMediaAutoplayFallback)==null?void 0:_.call(e))===!1)return;let m=null;try{m=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(m,(y,f)=>e.media.mirrorTime(y,f)),e.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){const m=Number(i.durationSeconds),y=Number(i.durationInFrames),f=Number.isFinite(m)&&m>0?m:y/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 b=e.getPlaybackState();e.setPlaybackState({...b,duration:f}),e.updateControlsTime(b.currentTime,f),e.onRuntimeTimelineReady(f,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}e.setScenes(Kt(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 Jt(r,t){return r.includes(t)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}const Qt=new Set([">"," "," ",`
573
- `,"\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 o=e[n+i.length];if(Qt.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 ei(r,t){if(!r||Jt(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 D="shader-capture-scale",F="shader-loading",re="runtime-src",Me="__hf_shader_capture_scale",xe="__hf_shader_loading",Y=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function oe(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 ti(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 Ie(r,t){return r.filter(e=>e!==""&&e.split("=")[0]!==t)}function ii(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=Ie(c.split("&"),Me);p=Ie(p,xe),t!==null&&p.push(`${Me}=${encodeURIComponent(t)}`),e!=="composition"&&p.push(`${xe}=${encodeURIComponent(e)}`);const h=p.join("&");return`${a}${h?`?${h}`:""}${n}`}function si(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 ti(r.getAttribute(F))}function ri(r){return Number(oe(r.getAttribute(D))??"1")}function ni(r,t){return ii(t,oe(r.getAttribute(D)),Z(r))}function $(r,t){return ei(si(t,oe(r.getAttribute(D)),Z(r)),We(r))}function We(r){var e;const t=(e=r.getAttribute(re))==null?void 0:e.trim();if(!t)return q;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:q}catch{return q}}const $e="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",Be="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",Oe=`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="${$e}"/><path d="${Be}"/></svg>`)}")`;function oi(){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=y=>{y.preventDefault(),y.stopPropagation()};for(const y of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(y,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="${$e}" fill="url(#hfp-shader-loader-grad-left)"/>`,`<path d="${Be}" 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-sheen",s.style.setProperty("mask-image",Oe),s.style.setProperty("-webkit-mask-image",Oe),i.appendChild(s);const n=document.createElement("div");n.className="hfp-shader-loader-title";const o=document.createElement("span");o.className="hfp-shader-loader-title-text",o.textContent=Y[0],n.appendChild(o);const a=document.createElement("div");a.className="hfp-shader-loader-detail",a.textContent="Rendering animated scene samples for shader transitions.";const c=document.createElement("div");c.className="hfp-shader-loader-track",c.setAttribute("aria-hidden","true");const p=document.createElement("div");p.className="hfp-shader-loader-fill",c.appendChild(p);const h=document.createElement("div");h.className="hfp-shader-loader-progress";const g=y=>{const f=document.createElement("div");f.className="hfp-shader-loader-row";const b=document.createElement("span");b.className="hfp-shader-loader-label",b.textContent=y;const A=document.createElement("span");return A.className="hfp-shader-loader-value",f.appendChild(b),f.appendChild(A),h.appendChild(f),{row:f,label:b,value:A}},_=g("transition"),m=g("transition frame");return e.appendChild(i),e.appendChild(n),e.appendChild(a),e.appendChild(c),e.appendChild(h),r.appendChild(e),{root:r,fill:p,title:o,detail:a,transitionValue:_.value,transitionRow:_.row,frameLabel:m.label,frameValue:m.value,frameRow:m.row}}const ai=420;function B(r,t,e){t.textContent=e,r.style.visibility=e?"visible":"hidden"}class di{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)",B(this._el.transitionRow,this._el.transitionValue,""),B(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(Y.length-1,Math.floor(o*Y.length));this._el.title.textContent=Y[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",B(this._el.transitionRow,this._el.transitionValue,c),B(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()},ai)}}function li(r){return(r==null?void 0:r.trim().toLowerCase().startsWith("video/"))??!1}function hi(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=He(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 ui=.1,ci=5,Q="sandbox-origin",Ne=1e4,ee=8e3,te="assets-loading",I="assets-loading-ui",j="buffering",ie="low-power-idle",Fe="disable-click-to-play",Ve="disable-fullscreen",O="range-start",N="range-end",Ue=150;function se(r){return!Number.isFinite(r)||r<=0?1:Math.max(ui,Math.min(ci,r))}class pi 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"}),St(this.shadow,ct),{container:this.container,iframe:this.iframe}=Et(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);const e=oi();this.shadow.appendChild(e.root),this.shaderLoader=new di(e),this._media=new Bt({dispatchEvent:i=>this._emit(i),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new kt({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 ut(this.iframe,{resolveRuntimeUrl:()=>We(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||wt(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,re,D,F,I,ie,O,N]}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=ke(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=$(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=$(this,s);else{this.iframe.removeAttribute("srcdoc");const h=this.getAttribute("src");h!==null&&this._wantsVideo()&&this._navigateSrc(h)}break;case Q:this._applySandboxOriginPolicy(this.isConnected&&i!==s);break;case"width":this._setCompositionSize(X(s)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,X(s)??1080);break;case"controls":s!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=ke(this.shadow,s,this.posterEl);break;case"playback-rate":{const h=se(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 I:s==="none"&&this.shaderLoader.hideAssetsLoading();break;case ie:this._sendControl("set-idle-heartbeat",{slow:s!==null});break;case O:case N:this._applyPlayRange(!0);break;case D:case F:case re: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=$(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?De(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){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 se(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(se(e)))}get shaderCaptureScale(){return ri(this)}set shaderCaptureScale(e){this.setAttribute(D,String(e))}get shaderLoading(){return Z(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(F):this.setAttribute(F,e)}get assetsLoadingUi(){return this.getAttribute(I)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(I,"none"):this.removeAttribute(I)}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(Fe)}set disableClickToPlay(e){this.toggleAttribute(Fe,e)}get disableFullscreen(){return this.hasAttribute(Ve)}set disableFullscreen(e){this.toggleAttribute(Ve,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(O)}set rangeStart(e){this._writeSeconds(O,e)}get rangeEnd(){return this._readSeconds(N)}set rangeEnd(e){this._writeSeconds(N,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(O)||this.hasAttribute(N)}_playRange(){return Pe(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}=Pe(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){De(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=ne(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,...it(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 ${Ne}ms`)},Ne);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"))w(s)&&(s.muted=e||s.defaultMuted)}_stopIframeMedia(){const e=this._getSameOriginIframeDocument();if(e)for(const i of e.querySelectorAll("video, audio"))w(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(ie)}),this._sendDisplayScale()}_sendDisplayScale(){const e=st(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=$(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 li(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=ni(this,e)}_loadVideo(e){var n,o;this._videoSource||(this._videoSource=hi({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){Zt(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:()=>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._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),ee)):this._settleAssetsReady(s);return}rt(e,({timedOut:n})=>{s===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(s))},{timeoutMs:ee}),this._assetsReady||this._startAssetsLoadingOverlayTimer(s)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(te,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},Ue)}_setBuffering(e){if(e){if(this._bufferingShowTimer!==null||this.hasAttribute(j))return;this._bufferingShowTimer=setTimeout(()=>{this._bufferingShowTimer=null,this.setAttribute(j,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading("Buffering","")},Ue);return}this._bufferingShowTimer!==null&&clearTimeout(this._bufferingShowTimer),this._bufferingShowTimer=null,this.hasAttribute(j)&&(this.removeAttribute(j),this.shaderLoader.hideAssetsLoading())}_hasPendingFirstFrameAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=Ee(e,{scope:Te});return i.length>0||s.length>0||n}_warnStuckAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=Ee(e,{scope:Te}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${ee}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(te),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(te),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=Tt(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=At(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",pi);export{pi as HyperframesPlayer,yt as SPEED_PRESETS,x as formatSpeed,Le as formatTime};