@hyperframes/studio 0.7.60 → 0.7.61

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 (47) hide show
  1. package/dist/assets/hyperframes-player-Xvx2hkrc.js +459 -0
  2. package/dist/assets/{index-cH6NfVV_.js → index-2mxh_HSy.js} +177 -177
  3. package/dist/assets/{index-D6etaey-.js → index-BCpoiv9S.js} +1 -1
  4. package/dist/assets/index-BhWig0mx.css +1 -0
  5. package/dist/assets/{index-Dh_WhagG.js → index-D-uFclFj.js} +1 -1
  6. package/dist/index.html +2 -2
  7. package/dist/index.js +1202 -673
  8. package/dist/index.js.map +1 -1
  9. package/package.json +7 -7
  10. package/src/App.tsx +3 -8
  11. package/src/components/DesignPanelPromoteProvider.tsx +27 -1
  12. package/src/components/StudioHeader.tsx +2 -3
  13. package/src/components/StudioRightPanel.tsx +34 -26
  14. package/src/components/editor/PromotableControl.tsx +4 -2
  15. package/src/components/editor/PropertyPanel.tsx +151 -149
  16. package/src/components/editor/PropertyPanelFlat.tsx +44 -42
  17. package/src/components/editor/manualEditingAvailability.test.ts +6 -6
  18. package/src/components/editor/manualEditingAvailability.ts +5 -3
  19. package/src/components/editor/propertyPanelFlatPrimitives.test.tsx +10 -0
  20. package/src/components/editor/propertyPanelFlatPrimitives.tsx +1 -0
  21. package/src/components/editor/propertyPanelFlatStyleHelpers.ts +0 -13
  22. package/src/components/editor/propertyPanelFlatStyleSections.test.tsx +21 -9
  23. package/src/components/editor/propertyPanelFlatStyleSections.tsx +15 -32
  24. package/src/components/editor/propertyPanelFlatTextSection.tsx +2 -2
  25. package/src/components/editor/propertyPanelInputCoverage.test.tsx +14 -0
  26. package/src/components/editor/propertyPanelPrimitives.tsx +9 -1
  27. package/src/components/storyboard/AgentChatMessageButton.test.tsx +47 -0
  28. package/src/components/storyboard/AgentChatMessageButton.tsx +45 -0
  29. package/src/components/storyboard/StoryboardFrameFocus.tsx +189 -66
  30. package/src/components/storyboard/StoryboardLoaded.tsx +121 -23
  31. package/src/components/storyboard/StoryboardReviewGuide.tsx +300 -0
  32. package/src/components/storyboard/StoryboardViewModeGuard.test.tsx +170 -0
  33. package/src/components/storyboard/storyboardReviewStage.test.ts +40 -0
  34. package/src/components/storyboard/storyboardReviewStage.ts +45 -0
  35. package/src/components/storyboard/useFrameComments.ts +22 -6
  36. package/src/contexts/ViewModeContext.tsx +60 -7
  37. package/src/hooks/useAddAssetAtPlayhead.test.ts +44 -0
  38. package/src/hooks/useAddAssetAtPlayhead.ts +21 -0
  39. package/src/hooks/useSlideshowTabState.test.ts +96 -0
  40. package/src/hooks/useSlideshowTabState.ts +61 -0
  41. package/src/player/lib/playbackTypes.ts +7 -0
  42. package/src/player/lib/runtimeProtocol.test.ts +6 -1
  43. package/src/player/lib/timelineDOM.ts +8 -11
  44. package/src/player/lib/timelineIframeHelpers.ts +153 -107
  45. package/dist/assets/hyperframes-player-3XTTaVNf.js +0 -459
  46. package/dist/assets/index-DXbu6IPT.css +0 -1
  47. package/src/components/editor/propertyPanelFlatStyleHelpers.test.ts +0 -23
@@ -0,0 +1,459 @@
1
+ var ce=Object.defineProperty;var pe=(r,t,e)=>t in r?ce(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>pe(r,typeof t!="symbol"?t+"":t,e);import{r as ne,i as me,a as fe}from"./index-2mxh_HSy.js";function _e(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function ge(r){return F(r)&&typeof r.getDuration=="function"}function ye(r){return F(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function ve(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 be=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:ve("0.0.0-dev");function H(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function we(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=H(t.getAttribute("data-width")),i=H(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}class Ae{constructor(t,e){c(this,"_interval",null);c(this,"_runtimeInjected",!1);this._iframe=t,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let t=0;this._interval=setInterval(()=>{var e;t++;try{const i=this._iframe.contentWindow;if(!i)return;const s=!!(i.__hf||i.__player),o=!!(i.__timelines&&Object.keys(i.__timelines).length>0),d=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(_e({hasRuntime:s,hasTimelines:o,hasNestedCompositions:d,runtimeInjected:this._runtimeInjected,attempts:t})){this._injectRuntime();return}if(this._runtimeInjected&&!s)return;const a=this._resolvePlaybackDurationAdapter(i);if(a&&a.getDuration()>0){this.stop();const h=we(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:h});return}}catch{}t>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const t=this._iframe.contentWindow;return t?this._resolveDirectTimelineAdapterFromWindow(t):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(t){return this._resolveDirectTimelineAdapterFromWindow(t)}hasRuntimeBridge(t){return Reflect.get(t,"__hf")!==void 0||F(Reflect.get(t,"__player"))}_injectRuntime(){var t,e;this._runtimeInjected=!0;try{const i=this._iframe.contentDocument;if(!i)return;const s=i.createElement("script");s.src=be,(i.head||i.documentElement).appendChild(s),(e=(t=this._callbacks).onRuntimeInjected)==null||e.call(t)}catch{}}_resolveDirectTimelineAdapterFromWindow(t){var a,h;if(this.hasRuntimeBridge(t))return null;const e=Reflect.get(t,"__timelines");if(!F(e))return null;const i=Object.keys(e);if(i.length===0)return null;const s=(h=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:h.getAttribute("data-composition-id"),o=s&&s in e?s:i[i.length-1],d=e[o];return ye(d)?d:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ge(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const Ee=`
2
+ :host {
3
+ display: block;
4
+ position: relative;
5
+ overflow: hidden;
6
+ background: #000;
7
+ contain: layout style;
8
+ }
9
+
10
+ .hfp-container {
11
+ position: absolute;
12
+ inset: 0;
13
+ overflow: hidden;
14
+ pointer-events: none;
15
+ }
16
+
17
+
18
+ .hfp-iframe {
19
+ position: absolute;
20
+ top: 50%;
21
+ left: 50%;
22
+ border: none;
23
+ pointer-events: none;
24
+ }
25
+
26
+ /* Opt-in: an interactive composition (e.g. a live slideshow/app with playable
27
+ media or controls) — let pointer events reach the iframe content. */
28
+ :host([interactive]) .hfp-container,
29
+ :host([interactive]) .hfp-iframe {
30
+ pointer-events: auto;
31
+ }
32
+
33
+ .hfp-poster {
34
+ position: absolute;
35
+ inset: 0;
36
+ object-fit: contain;
37
+ z-index: 1;
38
+ pointer-events: none;
39
+ }
40
+
41
+ .hfp-shader-loader {
42
+ position: absolute;
43
+ inset: 0;
44
+ z-index: 20;
45
+ display: grid;
46
+ place-items: center;
47
+ visibility: hidden;
48
+ opacity: 0;
49
+ pointer-events: none;
50
+ background: #030504;
51
+ color: #f4f7fb;
52
+ cursor: default;
53
+ user-select: none;
54
+ -webkit-user-select: none;
55
+ transition: opacity 420ms ease-out, visibility 420ms ease-out;
56
+ }
57
+
58
+ .hfp-shader-loader.hfp-visible,
59
+ .hfp-shader-loader.hfp-hiding {
60
+ visibility: visible;
61
+ }
62
+
63
+ .hfp-shader-loader.hfp-visible {
64
+ opacity: 1;
65
+ pointer-events: auto;
66
+ }
67
+
68
+ .hfp-shader-loader.hfp-hiding {
69
+ opacity: 0;
70
+ pointer-events: none;
71
+ }
72
+
73
+ .hfp-shader-loader-panel {
74
+ display: grid;
75
+ grid-template-rows: 86px 40px 26px 12px 44px;
76
+ justify-items: center;
77
+ align-items: center;
78
+ gap: 8px;
79
+ width: min(620px, 82%);
80
+ text-align: center;
81
+ font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
82
+ }
83
+
84
+ .hfp-shader-loader-mark {
85
+ width: 86px;
86
+ height: 86px;
87
+ display: grid;
88
+ place-items: center;
89
+ overflow: visible;
90
+ }
91
+
92
+ .hfp-shader-loader-mark svg {
93
+ display: block;
94
+ overflow: visible;
95
+ filter: drop-shadow(0 0 5px rgba(79, 219, 94, 0.16));
96
+ pointer-events: none;
97
+ }
98
+
99
+ .hfp-shader-loader-title {
100
+ width: 100%;
101
+ height: 40px;
102
+ overflow: hidden;
103
+ white-space: nowrap;
104
+ text-overflow: ellipsis;
105
+ font-size: 26px;
106
+ line-height: 40px;
107
+ font-weight: 700;
108
+ letter-spacing: 0;
109
+ }
110
+
111
+ .hfp-shader-loader-title-text {
112
+ color: transparent;
113
+ background: linear-gradient(
114
+ 90deg,
115
+ rgba(244, 247, 251, 0.84) 0%,
116
+ #ffffff 42%,
117
+ #80efe4 52%,
118
+ #ffffff 62%,
119
+ rgba(244, 247, 251, 0.84) 100%
120
+ );
121
+ background-size: 220% 100%;
122
+ -webkit-background-clip: text;
123
+ background-clip: text;
124
+ animation: hfp-shader-loader-sheen 1.9s linear infinite;
125
+ }
126
+
127
+ .hfp-shader-loader-detail {
128
+ width: 100%;
129
+ height: 26px;
130
+ overflow: hidden;
131
+ white-space: nowrap;
132
+ text-overflow: ellipsis;
133
+ color: rgba(244, 247, 251, 0.62);
134
+ font-size: 15px;
135
+ line-height: 26px;
136
+ font-weight: 500;
137
+ }
138
+
139
+ .hfp-shader-loader-track {
140
+ width: min(360px, 100%);
141
+ height: 8px;
142
+ overflow: hidden;
143
+ border-radius: 999px;
144
+ background: rgba(255, 255, 255, 0.1);
145
+ }
146
+
147
+ .hfp-shader-loader-fill {
148
+ width: 100%;
149
+ height: 100%;
150
+ border-radius: inherit;
151
+ background: linear-gradient(90deg, #06e3fa, #4fdb5e);
152
+ transform: scaleX(0);
153
+ transform-origin: left center;
154
+ transition: transform 160ms ease;
155
+ }
156
+
157
+ .hfp-shader-loader-progress {
158
+ width: min(420px, 100%);
159
+ height: 44px;
160
+ display: grid;
161
+ grid-template-rows: repeat(2, 22px);
162
+ color: rgba(244, 247, 251, 0.48);
163
+ font: 600 13px/22px "IBM Plex Mono", "SF Mono", "Fira Code", "Courier New", monospace;
164
+ font-variant-numeric: tabular-nums;
165
+ }
166
+
167
+ .hfp-shader-loader-row {
168
+ display: grid;
169
+ grid-template-columns: minmax(0, 1fr) 74px;
170
+ align-items: center;
171
+ column-gap: 20px;
172
+ width: 100%;
173
+ white-space: nowrap;
174
+ }
175
+
176
+ .hfp-shader-loader-label {
177
+ min-width: 0;
178
+ overflow: hidden;
179
+ text-align: left;
180
+ text-overflow: ellipsis;
181
+ }
182
+
183
+ .hfp-shader-loader-value {
184
+ text-align: right;
185
+ }
186
+
187
+ @keyframes hfp-shader-loader-sheen {
188
+ from {
189
+ background-position: 140% 0;
190
+ }
191
+ to {
192
+ background-position: -140% 0;
193
+ }
194
+ }
195
+
196
+ /* ── Theming via CSS custom properties ──
197
+ *
198
+ * Override from outside the shadow DOM:
199
+ * hyperframes-player {
200
+ * --hfp-controls-bg: linear-gradient(transparent, rgba(0,0,0,0.9));
201
+ * --hfp-accent: #ff6b6b;
202
+ * --hfp-font: "Inter", sans-serif;
203
+ * }
204
+ */
205
+
206
+ .hfp-controls {
207
+ position: absolute;
208
+ bottom: 0;
209
+ left: 0;
210
+ right: 0;
211
+ display: flex;
212
+ align-items: center;
213
+ gap: var(--hfp-controls-gap, 12px);
214
+ padding: var(--hfp-controls-padding, 8px 16px);
215
+ background: var(--hfp-controls-bg, linear-gradient(transparent, rgba(0, 0, 0, 0.7)));
216
+ color: var(--hfp-color, #fff);
217
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
218
+ font-size: var(--hfp-font-size, 13px);
219
+ z-index: 10;
220
+ pointer-events: auto;
221
+ opacity: 1;
222
+ transition: opacity 0.3s ease;
223
+ user-select: none;
224
+ }
225
+
226
+ .hfp-controls.hfp-hidden {
227
+ opacity: 0;
228
+ pointer-events: none;
229
+ }
230
+
231
+ .hfp-play-btn {
232
+ position: relative;
233
+ background: none;
234
+ border: none;
235
+ color: var(--hfp-color, #fff);
236
+ cursor: pointer;
237
+ padding: 8px;
238
+ display: flex;
239
+ align-items: center;
240
+ justify-content: center;
241
+ width: 40px;
242
+ height: 40px;
243
+ flex-shrink: 0;
244
+ z-index: 10;
245
+ }
246
+
247
+ .hfp-play-btn:hover {
248
+ opacity: 0.8;
249
+ }
250
+
251
+ /* Stacked play/pause glyphs that crossfade-morph on toggle (rotate + scale). */
252
+ .hfp-play-btn .hfp-ico {
253
+ position: absolute;
254
+ display: flex;
255
+ align-items: center;
256
+ justify-content: center;
257
+ transition:
258
+ opacity 200ms ease,
259
+ transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
260
+ }
261
+ .hfp-play-btn .hfp-ico-play {
262
+ opacity: 1;
263
+ transform: rotate(0) scale(1);
264
+ }
265
+ .hfp-play-btn .hfp-ico-pause {
266
+ opacity: 0;
267
+ transform: rotate(-90deg) scale(0.4);
268
+ }
269
+ .hfp-play-btn.hfp-playing .hfp-ico-play {
270
+ opacity: 0;
271
+ transform: rotate(90deg) scale(0.4);
272
+ }
273
+ .hfp-play-btn.hfp-playing .hfp-ico-pause {
274
+ opacity: 1;
275
+ transform: rotate(0) scale(1);
276
+ }
277
+ @media (prefers-reduced-motion: reduce) {
278
+ .hfp-play-btn .hfp-ico {
279
+ transition-duration: 0ms;
280
+ transform: none;
281
+ }
282
+ }
283
+
284
+ .hfp-play-btn svg,
285
+ .hfp-play-btn svg * {
286
+ pointer-events: none;
287
+ }
288
+
289
+ .hfp-scrubber {
290
+ flex: 1;
291
+ min-width: 0;
292
+ height: var(--hfp-scrubber-height, 4px);
293
+ background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
294
+ border-radius: var(--hfp-scrubber-radius, 2px);
295
+ cursor: pointer;
296
+ position: relative;
297
+ overflow: hidden;
298
+ }
299
+
300
+ .hfp-scrubber:hover {
301
+ height: var(--hfp-scrubber-height-hover, 6px);
302
+ }
303
+
304
+ .hfp-progress {
305
+ position: absolute;
306
+ top: 0;
307
+ left: 0;
308
+ height: 100%;
309
+ background: var(--hfp-accent, #fff);
310
+ pointer-events: none;
311
+ }
312
+
313
+ .hfp-time {
314
+ flex-shrink: 0;
315
+ font-variant-numeric: tabular-nums;
316
+ opacity: 0.9;
317
+ }
318
+
319
+ .hfp-speed-wrap {
320
+ position: relative;
321
+ flex-shrink: 0;
322
+ }
323
+
324
+ .hfp-speed-btn {
325
+ background: var(--hfp-speed-btn-bg, rgba(255, 255, 255, 0.15));
326
+ border: none;
327
+ border-radius: var(--hfp-speed-btn-radius, 4px);
328
+ color: var(--hfp-color, #fff);
329
+ cursor: pointer;
330
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
331
+ font-size: 12px;
332
+ font-variant-numeric: tabular-nums;
333
+ font-weight: 600;
334
+ padding: 4px 8px;
335
+ min-width: 40px;
336
+ text-align: center;
337
+ transition: background 0.15s ease;
338
+ }
339
+
340
+ .hfp-speed-btn:hover {
341
+ background: var(--hfp-speed-btn-bg-hover, rgba(255, 255, 255, 0.3));
342
+ }
343
+
344
+ .hfp-speed-menu {
345
+ position: absolute;
346
+ bottom: calc(100% + 8px);
347
+ right: 0;
348
+ background: var(--hfp-menu-bg, rgba(20, 20, 20, 0.95));
349
+ backdrop-filter: blur(12px);
350
+ -webkit-backdrop-filter: blur(12px);
351
+ border: 1px solid var(--hfp-menu-border, rgba(255, 255, 255, 0.1));
352
+ border-radius: var(--hfp-menu-radius, 8px);
353
+ padding: 4px;
354
+ display: flex;
355
+ flex-direction: column;
356
+ gap: 2px;
357
+ min-width: 80px;
358
+ opacity: 0;
359
+ visibility: hidden;
360
+ transform: translateY(4px);
361
+ transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
362
+ box-shadow: var(--hfp-menu-shadow, 0 8px 24px rgba(0, 0, 0, 0.4));
363
+ }
364
+
365
+ .hfp-speed-menu.hfp-open {
366
+ opacity: 1;
367
+ visibility: visible;
368
+ transform: translateY(0);
369
+ }
370
+
371
+ .hfp-speed-option {
372
+ background: none;
373
+ border: none;
374
+ border-radius: 4px;
375
+ color: var(--hfp-menu-color, rgba(255, 255, 255, 0.7));
376
+ cursor: pointer;
377
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
378
+ font-size: 13px;
379
+ font-variant-numeric: tabular-nums;
380
+ padding: 6px 12px;
381
+ text-align: left;
382
+ transition: background 0.1s ease, color 0.1s ease;
383
+ white-space: nowrap;
384
+ }
385
+
386
+ .hfp-speed-option:hover {
387
+ background: var(--hfp-menu-hover-bg, rgba(255, 255, 255, 0.1));
388
+ color: var(--hfp-color, #fff);
389
+ }
390
+
391
+ .hfp-speed-option.hfp-active {
392
+ color: var(--hfp-accent, #fff);
393
+ font-weight: 600;
394
+ }
395
+
396
+ .hfp-volume-wrap {
397
+ position: relative;
398
+ flex-shrink: 0;
399
+ display: flex;
400
+ align-items: center;
401
+ gap: 0;
402
+ }
403
+
404
+ .hfp-mute-btn {
405
+ background: none;
406
+ border: none;
407
+ color: var(--hfp-color, #fff);
408
+ cursor: pointer;
409
+ padding: 4px;
410
+ display: flex;
411
+ align-items: center;
412
+ justify-content: center;
413
+ width: 32px;
414
+ height: 32px;
415
+ flex-shrink: 0;
416
+ }
417
+
418
+ .hfp-mute-btn:hover {
419
+ opacity: 0.8;
420
+ }
421
+
422
+ .hfp-mute-btn svg,
423
+ .hfp-mute-btn svg * {
424
+ pointer-events: none;
425
+ }
426
+
427
+ .hfp-volume-slider-wrap {
428
+ width: 0;
429
+ overflow: hidden;
430
+ transition: width 0.2s ease;
431
+ display: flex;
432
+ align-items: center;
433
+ }
434
+
435
+ .hfp-volume-wrap:hover .hfp-volume-slider-wrap {
436
+ width: 64px;
437
+ }
438
+
439
+ .hfp-volume-slider {
440
+ width: 56px;
441
+ height: var(--hfp-scrubber-height, 4px);
442
+ background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
443
+ border-radius: var(--hfp-scrubber-radius, 2px);
444
+ cursor: pointer;
445
+ position: relative;
446
+ overflow: hidden;
447
+ margin-left: 4px;
448
+ margin-right: 4px;
449
+ }
450
+
451
+ .hfp-volume-fill {
452
+ position: absolute;
453
+ top: 0;
454
+ left: 0;
455
+ height: 100%;
456
+ background: var(--hfp-accent, #fff);
457
+ pointer-events: none;
458
+ }
459
+ `,Ce='<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>',Te='<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>',oe='<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>',ae='<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>',Se='<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>',Me=[.25,.5,1,1.5,2,4];function U(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function de(r){if(!Number.isFinite(r)||r<0)return"0:00";const t=Math.floor(r),e=Math.floor(t/60),i=t%60;return`${e}:${i.toString().padStart(2,"0")}`}function xe(r,t,e={}){const i=e.speedPresets??Me,s=document.createElement("div");s.className="hfp-controls",s.addEventListener("click",n=>{n.stopPropagation()});const o=document.createElement("button");o.className="hfp-play-btn",o.type="button",o.innerHTML=`<span class="hfp-ico hfp-ico-play">${Ce}</span><span class="hfp-ico hfp-ico-pause">${Te}</span>`,o.setAttribute("aria-label","Play");const d=document.createElement("div");d.className="hfp-scrubber";const a=document.createElement("div");a.className="hfp-progress",a.style.width="0%",d.appendChild(a);const h=document.createElement("span");h.className="hfp-time",h.textContent="0:00 / 0:00";const p=document.createElement("div");p.className="hfp-speed-wrap";const u=document.createElement("button");u.className="hfp-speed-btn",u.type="button",u.textContent="1x",u.setAttribute("aria-label","Playback speed");const g=document.createElement("div");g.className="hfp-speed-menu",g.setAttribute("role","menu");for(const n of i){const l=document.createElement("button");l.className="hfp-speed-option",l.type="button",l.setAttribute("role","menuitem"),l.dataset.speed=String(n),l.textContent=U(n),n===1&&l.classList.add("hfp-active"),g.appendChild(l)}p.appendChild(g),p.appendChild(u);const y=document.createElement("div");y.className="hfp-volume-wrap";const _=document.createElement("button");_.className="hfp-mute-btn",_.type="button",_.innerHTML=oe,_.setAttribute("aria-label","Mute");const b=document.createElement("div");b.className="hfp-volume-slider-wrap";const m=document.createElement("div");m.className="hfp-volume-slider",m.setAttribute("role","slider"),m.setAttribute("aria-label","Volume"),m.setAttribute("aria-valuemin","0"),m.setAttribute("aria-valuemax","100"),m.setAttribute("aria-valuenow","100"),m.tabIndex=0;const v=document.createElement("div");v.className="hfp-volume-fill",v.style.width="100%",m.appendChild(v),b.appendChild(m),y.appendChild(b),y.appendChild(_),e.audioLocked&&(y.style.display="none"),s.appendChild(o),s.appendChild(d),s.appendChild(h),s.appendChild(y),s.appendChild(p),r.appendChild(s);let k=!1,C=!1,E=1,M=null;i.indexOf(1);const P=(n,l)=>n?Se:l===0||l<.5?ae:oe;o.addEventListener("click",n=>{n.stopPropagation(),k?t.onPause():t.onPlay()}),_.addEventListener("click",n=>{n.stopPropagation(),t.onMuteToggle()});let T=!1;const R=n=>{const l=m.getBoundingClientRect(),f=Math.max(0,Math.min(1,(n-l.left)/l.width));E=f,v.style.width=`${f*100}%`,m.setAttribute("aria-valuenow",String(Math.round(f*100))),C&&f>0&&t.onMuteToggle(),_.innerHTML=P(C,f),t.onVolumeChange(f)};m.addEventListener("mousedown",n=>{n.stopPropagation(),T=!0,R(n.clientX)});const B=n=>{T&&R(n.clientX)},q=()=>{T=!1};document.addEventListener("mousemove",B),document.addEventListener("mouseup",q),m.addEventListener("touchstart",n=>{T=!0;const l=n.touches[0];l&&R(l.clientX)},{passive:!0});const G=n=>{if(T){const l=n.touches[0];l&&R(l.clientX)}},X=()=>{T=!1};document.addEventListener("touchmove",G,{passive:!0}),document.addEventListener("touchend",X);const Y=.05;m.addEventListener("keydown",n=>{let l=E;if(n.key==="ArrowRight"||n.key==="ArrowUp")l=Math.min(1,E+Y);else if(n.key==="ArrowLeft"||n.key==="ArrowDown")l=Math.max(0,E-Y);else return;n.preventDefault(),n.stopPropagation(),E=l,v.style.width=`${l*100}%`,m.setAttribute("aria-valuenow",String(Math.round(l*100))),C&&l>0&&t.onMuteToggle(),_.innerHTML=P(C,l),t.onVolumeChange(l)});const Z=n=>{for(const l of g.querySelectorAll(".hfp-speed-option"))l.classList.toggle("hfp-active",l.dataset.speed===String(n))};u.addEventListener("click",n=>{n.stopPropagation();const l=g.classList.toggle("hfp-open");u.setAttribute("aria-expanded",String(l))}),g.addEventListener("click",n=>{n.stopPropagation();const l=n.target.closest(".hfp-speed-option");if(!l)return;const f=parseFloat(l.dataset.speed);i.indexOf(f),u.textContent=U(f),Z(f),g.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false"),t.onSpeedChange(f)});const Q=()=>{g.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false")};document.addEventListener("click",Q);const I=n=>{const l=d.getBoundingClientRect(),f=Math.max(0,Math.min(1,(n-l.left)/l.width));t.onSeek(f)};let A=!1;d.addEventListener("mousedown",n=>{var l;n.stopPropagation(),A=!0,(l=t.onScrubStart)==null||l.call(t),I(n.clientX)});const J=n=>{A&&I(n.clientX)},K=()=>{var n;A&&(A=!1,(n=t.onScrubEnd)==null||n.call(t))};document.addEventListener("mousemove",J),document.addEventListener("mouseup",K),d.addEventListener("touchstart",n=>{var f;A=!0,(f=t.onScrubStart)==null||f.call(t);const l=n.touches[0];l&&I(l.clientX)},{passive:!0});const ee=n=>{if(A){const l=n.touches[0];l&&I(l.clientX)}},te=()=>{var n;A&&(A=!1,(n=t.onScrubEnd)==null||n.call(t))};document.addEventListener("touchmove",ee,{passive:!0}),document.addEventListener("touchend",te);const ie=()=>{M&&clearTimeout(M),M=setTimeout(()=>{k&&s.classList.add("hfp-hidden")},3e3)},N=r instanceof ShadowRoot?r.host:r,re=()=>{s.classList.remove("hfp-hidden"),ie()},se=()=>{k&&s.classList.add("hfp-hidden")};return N.addEventListener("mousemove",re),N.addEventListener("mouseleave",se),{updateTime(n,l){const f=l>0?Math.min(n,l):n,ue=l>0?f/l*100:0;a.style.width=`${ue}%`,h.textContent=`${de(f)} / ${de(l)}`},updatePlaying(n){k=n,o.classList.toggle("hfp-playing",n),o.setAttribute("aria-label",n?"Pause":"Play"),n?ie():s.classList.remove("hfp-hidden")},updateSpeed(n){i.indexOf(n),u.textContent=U(n),Z(n)},updateMuted(n){C=n,_.innerHTML=P(n,E),_.setAttribute("aria-label",n?"Unmute":"Mute")},updateVolume(n){E=n,v.style.width=`${n*100}%`,m.setAttribute("aria-valuenow",String(Math.round(n*100))),_.innerHTML=P(C,n)},setVolumeControlsHidden(n){y.style.display=n?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",K),document.removeEventListener("touchmove",ee),document.removeEventListener("touchend",te),document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",q),document.removeEventListener("touchmove",G),document.removeEventListener("touchend",X),document.removeEventListener("click",Q),N.removeEventListener("mousemove",re),N.removeEventListener("mouseleave",se),M&&clearTimeout(M),s.remove()}}}function Le(r,t,e,i,s,o=!1){const d=i?i.split(",").map(Number).filter(p=>!isNaN(p)&&p>0):void 0,a={...d?{speedPresets:d}:{},audioLocked:o},h=xe(r,s,a);return h.updateMuted(t),h.updateVolume(e),h}function le(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 ke(r){return r.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("hfp-controls"))}let O=null;function Pe(r,t){if(typeof CSSStyleSheet<"u")try{O||(O=new CSSStyleSheet,O.replaceSync(t)),r.adoptedStyleSheets=[O];return}catch{}const e=document.createElement("style");e.textContent=t,r.appendChild(e)}function Re(){const r=document.createElement("div");r.className="hfp-container";const t=document.createElement("iframe");return t.className="hfp-iframe",t.sandbox.add("allow-scripts","allow-same-origin"),t.allow="autoplay; fullscreen",t.referrerPolicy="no-referrer",t.title="HyperFrames Composition",r.appendChild(t),{container:r,iframe:t}}function Ie(r,t,e,i){const s=r.offsetWidth,o=r.offsetHeight;if(s===0||o===0)return!1;const d=Math.min(s/e,o/i);return t.style.width=`${e}px`,t.style.height=`${i}px`,t.style.transform=`translate(-50%, -50%) scale(${d})`,!0}const Ne=100;class Oe{constructor(t){c(this,"_raf",null);c(this,"_lastUpdateMs",0);this._callbacks=t}start(t,e,i,s){this.stop();const o=()=>{if(s()){this._raf=null;return}let d;try{d=t.time()}catch{this._raf=null;return}const a=i();a>0&&(d=Math.min(d,a));const h=a>0&&d>=a,p=performance.now();if((p-this._lastUpdateMs>Ne||h)&&(this._lastUpdateMs=p,this._callbacks.onTimeUpdate(d,a)),h){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{t.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(o)};this._raf=requestAnimationFrame(o)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function De(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)He(i)||e.push(i);return Fe(r),e}function Fe(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 He(r){let t=r.parentElement;for(;t;){if(t.hasAttribute("data-composition-id"))return!0;t=t.parentElement}return!1}function j(r){var e;const t=(e=r.ownerDocument)==null?void 0:e.defaultView;return t&&r instanceof t.Element?!0:r instanceof Element}function w(r){var e;if(!j(r)||r.tagName!=="AUDIO"&&r.tagName!=="VIDEO")return!1;const t=(e=r.ownerDocument)==null?void 0:e.defaultView;return t&&r instanceof t.HTMLMediaElement?!0:r instanceof HTMLMediaElement}const Ue=.05,Ve=2;class $e{constructor(t){c(this,"_entries",[]);c(this,"_mediaObserver");c(this,"_playbackErrorPosted",!1);c(this,"_audioOwner","runtime");c(this,"_urlAudioEntry",null);c(this,"_urlAudioSrc",null);c(this,"_dispatchEvent");c(this,"_getMuted");c(this,"_getVolume");c(this,"_getPlaybackRate");c(this,"_getCurrentTime");c(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(),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);const e=this._getCurrentTime()-t.start;e<0||e>=t.duration||this._playEntry(t)}_refreshEntryBounds(t){var i;if(!((i=t.source)!=null&&i.isConnected))return;const e=ne(t.source);t.start=e.start??0,t.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_gateEntryPlayback(t,e){return e<0||e>=t.duration?(t.el.paused||t.el.pause(),t.driftSamples=0,!1):(this._audioOwner==="parent"&&!this._isPaused()&&t.el.paused&&this._playEntry(t),!0)}playAll(){for(const t of this._entries)this._playEntryIfActive(t)}pauseAll(){for(const t of this._entries)t.el.pause()}stopAdoptedMedia(){for(const t of this._entries)t.source&&t.el.pause()}seekAll(t){for(const e of this._entries){this._refreshEntryBounds(e);const i=t-e.start;i>=0&&i<e.duration&&(e.el.currentTime=i)}}scrubAll(t){for(const e of this._entries){this._refreshEntryBounds(e);const i=t-e.start;i>=0&&i<e.duration?(e.el.currentTime=i,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);const o=t-s.start;this._gateEntryPlayback(s,o)&&(Math.abs(s.el.currentTime-o)>Ue?(s.driftSamples+=1,(i||s.driftSamples>=Ve)&&(s.el.currentTime=o,s.driftSamples=0)):s.driftSamples=0)}}promoteToParentProxy(t,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",t)for(const s of t.querySelectorAll("video, audio"))w(s)&&(s.muted=!0);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=e?t:null,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,o){if(this._entries.some(p=>p.el.src===t))return null;const d=e==="video"?document.createElement("video"):new Audio;d.preload="auto",d.src=t,d.load(),d.muted=this._getMuted(),d.volume=this._getVolume();const a=this._getPlaybackRate();a!==1&&(d.playbackRate=a);const h={el:d,start:i,duration:s,driftSamples:0,source:o};return this._entries.push(h),h}_resolveIframeMediaSrc(t){var i;const e=t.getAttribute("src")||((i=t.querySelector("source"))==null?void 0:i.getAttribute("src"));return e?new URL(e,t.ownerDocument.baseURI).href:null}_adoptIframeMedia(t){if(t.preload==="metadata"||t.preload==="none")return;const e=this._resolveIframeMediaSrc(t);if(!e)return;const i=ne(t),s=i.start??0,o=i.duration??Number.POSITIVE_INFINITY,d=t.tagName==="VIDEO"?"video":"audio",a=this._createEntry(e,d,s,o,t);a&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(a))}_detachIframeMedia(t){const e=this._resolveIframeMediaSrc(t);if(!e)return;const i=this._entries.findIndex(o=>o.el.src===e);if(i===-1)return;const s=this._entries[i];s.el.pause(),s.el.src="",this._entries.splice(i,1)}_observeDynamicMedia(t){if(this.teardownObserver(),typeof MutationObserver>"u"||!t.body)return;const e=new MutationObserver(o=>{for(const d of o){if(d.type==="attributes"&&d.attributeName==="preload"){const a=d.target;w(a)&&a.matches("audio[data-start], video[data-start]")&&a.preload==="auto"&&this._adoptIframeMedia(a);continue}for(const a of d.addedNodes){if(!j(a))continue;const h=[];w(a)&&a.matches("audio[data-start], video[data-start]")&&h.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)w(u)&&h.push(u);for(const u of h)this._adoptIframeMedia(u)}for(const a of d.removedNodes){if(!j(a))continue;const h=[];w(a)&&a.matches("audio[data-start], video[data-start]")&&h.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)w(u)&&h.push(u);for(const u of h)this._detachIframeMedia(u)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload"]},s=De(t);for(const o of s)e.observe(o,i);this._mediaObserver=e}}const ze=100;function je(r,t,e,i){const s=(r.frame??0)/t,o=e.duration>0?Math.min(s,e.duration):s,d=!e.paused,a=!r.isPlaying,h=e.duration>0&&o>=e.duration&&(d||r.isPlaying);if(h&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(0),i.play(),{...e,currentTime:o,paused:!1};const p={...e,currentTime:o,paused:a};i.media.audioOwner==="parent"&&(d&&a?i.media.pauseAll():!d&&!a&&i.media.playAll(),i.media.mirrorTime(o));const u=performance.now(),g=a!==e.paused;return(u-e.lastUpdateMs>ze||g)&&(p.lastUpdateMs=u,i.updateControlsTime(o,e.duration),i.updateControlsPlaying(!a),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:o}}))),h&&(i.media.audioOwner==="parent"&&i.media.pauseAll(),p.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),p}function We(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 Be(r,t,e){var o,d;if(r.source!==t)return;const i=r.data;if(!i||i.source!=="hf-preview")return;const s=me(i);if(s.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:s.code,receivedVersion:s.receivedVersion}}));return}if((o=e.setRuntimeFps)==null||o.call(e,s.fps),i.type==="shader-transition-state"){const a=i.state&&typeof i.state=="object"?i.state:{};e.shaderLoader.update(a,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:a}}));return}if(i.type==="ready"){e.onRuntimeReady();return}if(i.type==="state"){e.setPlaybackState(je({frame:i.frame??0,isPlaying:!!i.isPlaying},s.fps,e.getPlaybackState(),e));return}if(i.type==="media-autoplay-blocked"){if(((d=e.shouldPromoteMediaAutoplayFallback)==null?void 0:d.call(e))===!1)return;let a=null;try{a=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(a,(h,p)=>e.media.mirrorTime(h,p)),e.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){const a=Number(i.durationSeconds),h=Number(i.durationInFrames),p=Number.isFinite(a)&&a>0?a:h/s.fps;if(Number.isFinite(p)&&p>0){const u=e.getPlaybackState();e.setPlaybackState({...u,duration:p}),e.updateControlsTime(u.currentTime,p),e.onRuntimeTimelineReady(p)}Number.isFinite(i.compositionWidth)&&i.compositionWidth>0&&Number.isFinite(i.compositionHeight)&&i.compositionHeight>0&&e.setCompositionSize(i.compositionWidth,i.compositionHeight),e.setScenes(We(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)}const S="shader-capture-scale",x="shader-loading",qe="__hf_shader_capture_scale",Ge="__hf_shader_loading",D=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function W(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 Xe(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 he(r,t,e){e===null?r.delete(t):r.set(t,e)}function Ye(r,t,e){const i=r.indexOf("#"),s=i>=0?r.slice(0,i):r,o=i>=0?r.slice(i):"",d=s.indexOf("?"),a=d>=0?s.slice(0,d):s,h=d>=0?s.slice(d+1):"",p=new URLSearchParams(h);he(p,qe,t),he(p,Ge,e==="composition"?null:e);const u=p.toString();return`${a}${u?`?${u}`:""}${o}`}function Ze(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,o=>`${o}${s}`):/<html\b[^>]*>/i.test(r)?r.replace(/<html\b[^>]*>/i,o=>`${o}${s}`):`${s}${r}`}function L(r){return Xe(r.getAttribute(x))}function Qe(r){return Number(W(r.getAttribute(S))??"1")}function V(r,t){return Ye(t,W(r.getAttribute(S)),L(r))}function $(r,t){return Ze(t,W(r.getAttribute(S)),L(r))}function Je(){const r=document.createElement("div");r.className="hfp-shader-loader",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.setAttribute("aria-label","Preparing scene transitions"),r.setAttribute("data-hyperframes-ignore",""),r.draggable=!1;const t=_=>{_.preventDefault(),_.stopPropagation()};for(const _ of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(_,t,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const i=document.createElement("div");i.className="hfp-shader-loader-mark",i.draggable=!1,i.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");const s=document.createElement("div");s.className="hfp-shader-loader-title";const o=document.createElement("span");o.className="hfp-shader-loader-title-text",o.textContent=D[0],s.appendChild(o);const d=document.createElement("div");d.className="hfp-shader-loader-detail",d.textContent="Rendering animated scene samples for shader transitions.";const a=document.createElement("div");a.className="hfp-shader-loader-track",a.setAttribute("aria-hidden","true");const h=document.createElement("div");h.className="hfp-shader-loader-fill",a.appendChild(h);const p=document.createElement("div");p.className="hfp-shader-loader-progress";const u=_=>{const b=document.createElement("div");b.className="hfp-shader-loader-row";const m=document.createElement("span");m.className="hfp-shader-loader-label",m.textContent=_;const v=document.createElement("span");return v.className="hfp-shader-loader-value",b.appendChild(m),b.appendChild(v),p.appendChild(b),{row:b,label:m,value:v}},g=u("transition"),y=u("transition frame");return e.appendChild(i),e.appendChild(s),e.appendChild(d),e.appendChild(a),e.appendChild(p),r.appendChild(e),{root:r,fill:h,title:o,detail:d,transitionValue:g.value,frameLabel:y.label,frameValue:y.value,frameRow:y.row}}const Ke=420;class et{constructor(t){c(this,"_el");c(this,"_hideTimeout",null);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())}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._el.fill.style.transform="scaleX(0)",this._el.transitionValue.textContent="",this._el.frameValue.textContent="",this._el.frameRow.style.visibility="hidden"}update(t,e){if(e!=="player"){this.reset();return}if(t.ready||!t.loading){this.hide();return}const i=typeof t.progress=="number"&&Number.isFinite(t.progress)?t.progress:0,s=typeof t.total=="number"&&Number.isFinite(t.total)?t.total:0,o=s>0?Math.min(1,Math.max(0,i/s)):0,d=Math.min(D.length-1,Math.floor(o*D.length));this._el.title.textContent=D[d]||"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})`,this._el.transitionValue.textContent=t.currentTransition!==void 0&&t.transitionTotal!==void 0?`${t.currentTransition}/${t.transitionTotal}`:s>0?`${i}/${s}`:"";const a=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",this._el.frameValue.textContent=a,this._el.frameRow.style.visibility=a?"visible":"hidden",this._el.root.setAttribute("aria-valuenow",String(Math.round(o*100))),this.show()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null)}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null},Ke)}}const tt=.1,it=5;function z(r){return!Number.isFinite(r)||r<=0?1:Math.max(tt,Math.min(it,r))}class rt extends HTMLElement{constructor(){super();c(this,"shadow");c(this,"container");c(this,"iframe");c(this,"posterEl",null);c(this,"controlsApi",null);c(this,"resizeObserver");c(this,"shaderLoader");c(this,"probe");c(this,"_ready",!1);c(this,"_currentTime",0);c(this,"_duration",0);c(this,"_paused",!0);c(this,"_scrubbing",!1);c(this,"_lastUpdateMs",0);c(this,"_volume",1);c(this,"_compositionWidth",1920);c(this,"_compositionHeight",1080);c(this,"_rescaleWarned",!1);c(this,"_directTimelineAdapter",null);c(this,"_directTimelineClock");c(this,"_parentTickRaf",null);c(this,"_media");c(this,"_scenes",[]);c(this,"_runtimeFps",30);this.shadow=this.attachShadow({mode:"open"}),Pe(this.shadow,Ee),{container:this.container,iframe:this.iframe}=Re(),this.shadow.appendChild(this.container);const e=Je();this.shadow.appendChild(e.root),this.shaderLoader=new et(e),this._media=new $e({dispatchEvent:i=>this.dispatchEvent(i),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Oe({onTimeUpdate:(i,s)=>{var o;this._currentTime=i,(o=this.controlsApi)==null||o.updateTime(i,s),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:i}}))},getLoop:()=>this.loop,restart:()=>{this.seek(0),this.play()},onPaused:()=>{var i;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(i=this.controlsApi)==null||i.updatePlaying(!1),this.dispatchEvent(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new Ae(this.iframe,{onReady:i=>this._onProbeReady(i),onError:i=>this.dispatchEvent(new CustomEvent("error",{detail:{message:i}}))}),this.addEventListener("click",i=>{ke(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)}static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src",S,x]}connectedCallback(){this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.iframe.addEventListener("load",this._onIframeLoad),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=le(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.iframe.src=V(this,this.getAttribute("src"))),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.iframe.removeEventListener("load",this._onIframeLoad),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._ready=!1}attributeChangedCallback(e,i,s){var o,d,a,h,p;switch(e){case"src":s&&(this._ready=!1,this.iframe.src=V(this,s));break;case"srcdoc":this._ready=!1,s!==null?this.iframe.srcdoc=$(this,s):this.iframe.removeAttribute("srcdoc");break;case"width":this._compositionWidth=H(s)??1920,this._rescale();break;case"height":this._compositionHeight=H(s)??1080,this._rescale();break;case"controls":s!==null?this._setupControls():((o=this.controlsApi)==null||o.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=le(this.shadow,s,this.posterEl);break;case"playback-rate":{const u=z(parseFloat(s||"1"));this._media.updatePlaybackRate(u),this._sendControl("set-playback-rate",{playbackRate:u}),(a=(d=this._directTimelineAdapter)==null?void 0:d.timeScale)==null||a.call(d,u),(h=this.controlsApi)==null||h.updateSpeed(u),this.dispatchEvent(new Event("ratechange"));break}case"muted":this._handleMutedChange(s);break;case"audio-locked":this._applyAudioLock(s!==null);break;case"volume":{const u=Math.max(0,Math.min(1,parseFloat(s||"1")));this._volume=u,this._media.updateVolume(u),this._sendControl("set-volume",{volume:u}),(p=this.controlsApi)==null||p.updateVolume(u),this.dispatchEvent(new Event("volumechange"));break}case"audio-src":s?this._media.setupFromUrl(s):this._media.teardownUrlAudio();break;case S:case x:this._reloadShaderOptions();break}}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){var i,s;(i=this.posterEl)==null||i.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const e=this._tryDirectTimelinePlay();e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter&&this._startParentTickClock()),this._media.audioOwner==="parent"&&this._media.playAll(),(s=this.controlsApi)==null||s.updatePlaying(!0),this.dispatchEvent(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){var e;this._tryDirectTimelinePause()||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.dispatchEvent(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){var i,s;!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}})}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get paused(){return this._paused}get ready(){return this._ready}get playbackRate(){return z(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(z(e)))}get shaderCaptureScale(){return Qe(this)}set shaderCaptureScale(e){this.setAttribute(S,String(e))}get shaderLoading(){return L(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(x):this.setAttribute(x,e)}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._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(i=this.controlsApi)==null||i.updateMuted(e!==null),this.dispatchEvent(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 loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_sendControl(e,i={}){var s;try{(s=this.iframe.contentWindow)==null||s.postMessage({...i,source:"hf-parent",type:"control",action:e,...fe(this._runtimeFps)},"*")}catch{}}_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()})}_reloadShaderOptions(){if(L(this)!=="player"&&this.shaderLoader.reset(),this.hasAttribute("srcdoc")){this.iframe.srcdoc=$(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&(this.iframe.src=V(this,this.getAttribute("src")||""))}_trySyncSeek(e){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._directTimelineAdapter||this.probe.resolveDirectTimelineAdapter();if(!i)return!1;try{return e(i),this._directTimelineAdapter=i,!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())}_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){Be(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:i,duration:s,paused:o,lastUpdateMs:d})=>{this._currentTime=i,this._duration=s,this._paused=o,this._lastUpdateMs=d},getShaderLoadingMode:()=>L(this),shaderLoader:this.shaderLoader,setCompositionSize:(i,s)=>{this._compositionWidth=i,this._compositionHeight=s,this._rescale()},sendControl:(i,s)=>this._sendControl(i,s),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>this._replayBridgeState(),onRuntimeTimelineReady:i=>this._onRuntimeTimelineReady(i),setRuntimeFps:i=>{this._runtimeFps=i},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:i=>{this._scenes=i,this.dispatchEvent(new CustomEvent("scenes",{detail:{scenes:i}}))},updateControlsTime:(i,s)=>{var o;return(o=this.controlsApi)==null?void 0:o.updateTime(i,s)},updateControlsPlaying:i=>{var s;return(s=this.controlsApi)==null?void 0:s.updatePlaying(i)},dispatchEvent:i=>this.dispatchEvent(i),seek:i=>this.seek(i),play:()=>this.play(),getLoop:()=>this.loop,media:this._media})}_onRuntimeTimelineReady(e){var s;if(this._ready)return;this.probe.stop(),this._duration=e,this._directTimelineAdapter=null,this._ready=!0,(s=this.controlsApi)==null||s.updateTime(this._currentTime,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),this._rescale();const i=this._getSameOriginIframeDocument();i&&this._media.setupFromIframe(i),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this.hasAttribute("autoplay")&&this.play()}_onProbeReady({duration:e,adapter:i,compositionSize:s}){var o;this._duration=e,this._directTimelineAdapter=i.kind==="direct-timeline"?i.timeline:null,this._ready=!0,(o=this.controlsApi)==null||o.updateTime(0,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),s&&(this._compositionWidth=s.width,this._compositionHeight=s.height,this._rescale());try{const d=this.iframe.contentDocument;d&&this._media.setupFromIframe(d)}catch{}this._setIframeMediaMuted(this.muted),this.hasAttribute("autoplay")&&this.play()}_rescale(){!Ie(this,this.iframe,this._compositionWidth,this._compositionHeight)&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready — zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){this._ready=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad(),this.probe.start()}_setupControls(){this.controlsApi||(this.controlsApi=Le(this.shadow,this.muted,this._volume,this.getAttribute("speed-presets"),{onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:e=>this.seek(e*this._duration),onScrubStart:()=>{this._scrubbing=!0},onScrubEnd:()=>{this._scrubbing=!1,this.seek(this._currentTime)},onSpeedChange:e=>void(this.playbackRate=e),onMuteToggle:()=>void(this.muted=!this.muted),onVolumeChange:e=>void(this.volume=e)},this._isAudioLocked()))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,i){this._media.mirrorTime(e,i)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(i,s)=>this._mirrorParentMediaTime(i,s)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}}customElements.get("hyperframes-player")||customElements.define("hyperframes-player",rt);export{rt as HyperframesPlayer,Me as SPEED_PRESETS,U as formatSpeed,de as formatTime};