hyperframes 0.8.207 → 0.8.208

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 (212) hide show
  1. package/dist/{add-LXFWHBE3.js → add-XMWRBMBR.js} +14 -13
  2. package/dist/{agentPromptGenerator-D2E62ZP5.js → agentPromptGenerator-4NJ252MR.js} +6 -2
  3. package/dist/{animatedGifPrep-VBPJZKFT.js → animatedGifPrep-6XURJIPV.js} +8 -7
  4. package/dist/api.js +19 -18
  5. package/dist/{asset-JX4RW3GO.js → asset-I5GGEOB2.js} +2 -2
  6. package/dist/{assetCataloger-JKKOPBCF.js → assetCataloger-YBPXUNUP.js} +10 -8
  7. package/dist/{audio-OXQ3L6DW.js → audio-GFJCHH5W.js} +410 -128
  8. package/dist/{auth-JAL7P7ZA.js → auth-QOA55RYR.js} +4 -4
  9. package/dist/{autoUpdate-MRI2AICE.js → autoUpdate-SPS4QPJU.js} +4 -4
  10. package/dist/{backgroundChecks-ORR46PBY.js → backgroundChecks-HRJO7YK7.js} +5 -5
  11. package/dist/backgroundChecksWorker.js +5 -5
  12. package/dist/{batchRender-IFZYPGIW.js → batchRender-FBP3RKUF.js} +5 -4
  13. package/dist/{beats-UDLOEW6U.js → beats-VNGJ7F6W.js} +21 -14
  14. package/dist/{benchmark-VTVDNKSO.js → benchmark-NZ3N3MIV.js} +10 -10
  15. package/dist/{browser-QJC4BL2Y.js → browser-BD5BKRJ5.js} +8 -8
  16. package/dist/{bundleWithLocalizedFonts-Z2JTBNDS.js → bundleWithLocalizedFonts-WXVNPAWD.js} +3 -3
  17. package/dist/{capture-GLM2ACPM.js → capture-CXWXKWS5.js} +62 -36
  18. package/dist/{capture-2P4JERSX.js → capture-LMJ4TQRL.js} +52 -17
  19. package/dist/{captureCompositionFrame-A2A5MGQB.js → captureCompositionFrame-ZKVCRYYU.js} +14 -13
  20. package/dist/{captureFile-RPUEOZO6.js → captureFile-VIVGKFY4.js} +2 -1
  21. package/dist/{catalog-5ZLVUQVJ.js → catalog-WRXQSCAU.js} +14 -13
  22. package/dist/{catch-up-FRMVYJHZ.js → catch-up-MDSPABFC.js} +6 -6
  23. package/dist/{check-WVY7SM7C.js → check-SIBBK5HA.js} +42 -41
  24. package/dist/{checkAudio-PLEQY3SZ.js → checkAudio-QQBR4HR7.js} +12 -11
  25. package/dist/{checkBrowser-XSZUA2DQ.js → checkBrowser-4EBJLLIH.js} +34 -33
  26. package/dist/{chunk-XDMZY3H7.js → chunk-3O2E4Q66.js} +15 -20
  27. package/dist/{chunk-HVOTYAS4.js → chunk-43MW4SY7.js} +2 -2
  28. package/dist/{chunk-TSTONNOD.js → chunk-4F5NRJ6M.js} +2 -2
  29. package/dist/{chunk-JQ32262N.js → chunk-4HT2L6W2.js} +1 -1
  30. package/dist/{chunk-63DP5CB2.js → chunk-4KG3ESVO.js} +4 -4
  31. package/dist/{chunk-LPI7HX4G.js → chunk-4LTBQEPD.js} +2 -2
  32. package/dist/{chunk-C6KE4AFW.js → chunk-56ANHX5U.js} +1 -1
  33. package/dist/{chunk-XULJBZ7K.js → chunk-5HB4JM7H.js} +2 -2
  34. package/dist/{chunk-PL36HK3U.js → chunk-6CWKORZO.js} +3 -3
  35. package/dist/{chunk-ZF3R2IPC.js → chunk-6DSYBW7Z.js} +1 -0
  36. package/dist/{chunk-T4JGFCXU.js → chunk-6JNSYFOH.js} +4 -4
  37. package/dist/{chunk-5PYRU5DT.js → chunk-6N7D2GUV.js} +15 -15
  38. package/dist/{chunk-WL263XM2.js → chunk-6PWQH77E.js} +1 -1
  39. package/dist/{chunk-UAT2UMTP.js → chunk-6WRN4WC6.js} +1 -1
  40. package/dist/{chunk-SXOD5J7T.js → chunk-7CPI2DWL.js} +1 -1
  41. package/dist/{chunk-UYPWH7PH.js → chunk-7PAK7LZ5.js} +11 -11
  42. package/dist/{chunk-YJK6HOL5.js → chunk-B5MPMIKQ.js} +2 -2
  43. package/dist/{chunk-KDHHPJOG.js → chunk-BKDQFOKK.js} +4 -4
  44. package/dist/{chunk-LCCYYTEK.js → chunk-BLCKQPBE.js} +1 -1
  45. package/dist/chunk-BQMAPNDA.js +4830 -0
  46. package/dist/{chunk-QE4WRS3N.js → chunk-CP225S5H.js} +3 -3
  47. package/dist/{chunk-I2TDHVFV.js → chunk-CSWCZA6V.js} +2 -2
  48. package/dist/{chunk-C53ZNJDZ.js → chunk-D2CE2J2A.js} +1 -1
  49. package/dist/{chunk-NSC5A4IR.js → chunk-DHQSDCWD.js} +6 -2
  50. package/dist/chunk-DROFHVQD.js +240 -0
  51. package/dist/{chunk-NHL5CMO2.js → chunk-DXACKQ3F.js} +3 -3
  52. package/dist/{chunk-IK4JY2LI.js → chunk-EGOXYG3M.js} +2 -2
  53. package/dist/{chunk-UKM3JYNB.js → chunk-ENRFKCI6.js} +3 -3
  54. package/dist/{chunk-NWGXTUYS.js → chunk-EQBDKYXR.js} +3 -30
  55. package/dist/{chunk-4UMPIPCQ.js → chunk-ERUQ3S6D.js} +2 -2
  56. package/dist/{chunk-T2EUWCJE.js → chunk-EU7MVORF.js} +13 -1
  57. package/dist/{chunk-CVZO6TFE.js → chunk-EYEEZXLI.js} +11 -11
  58. package/dist/{chunk-ZCJ5EGLU.js → chunk-FC4WT5FX.js} +79 -1
  59. package/dist/{chunk-GXUONASF.js → chunk-FFDYRJBE.js} +24 -1
  60. package/dist/{chunk-NJNC2DQV.js → chunk-G2A6RC5R.js} +52 -9
  61. package/dist/{chunk-HTIUNMTP.js → chunk-GDZA4ALG.js} +8 -2
  62. package/dist/{chunk-H3LQ5X6Q.js → chunk-GEO6THL3.js} +61 -30
  63. package/dist/{chunk-RPZNQV6D.js → chunk-GHSO62LK.js} +2 -2
  64. package/dist/{chunk-P2I4RLJE.js → chunk-HTZJNQYI.js} +1 -1
  65. package/dist/{chunk-XKW4Z7BU.js → chunk-HUKQW4YE.js} +1 -1
  66. package/dist/{chunk-QZ2JQ6O4.js → chunk-HZN7ICAF.js} +3 -3
  67. package/dist/{chunk-DJQZ7DEH.js → chunk-IIJVSCSH.js} +15 -15
  68. package/dist/{chunk-6KCFVLO6.js → chunk-IL2TMC6F.js} +1 -1
  69. package/dist/{chunk-ZYGIDXAK.js → chunk-J67FSI3Q.js} +104 -58
  70. package/dist/{chunk-5KBMYSF2.js → chunk-K4PHB3YQ.js} +7 -2
  71. package/dist/{chunk-HM7SUIQD.js → chunk-KTWGVEN6.js} +3 -3
  72. package/dist/{chunk-6IYIS2U7.js → chunk-LSMFOZ4F.js} +2 -2
  73. package/dist/{chunk-ELP5QZWL.js → chunk-M4QZFUMW.js} +1 -1
  74. package/dist/{chunk-EG3B2VWK.js → chunk-MBGM26P5.js} +16 -21
  75. package/dist/{chunk-LK6KPVX2.js → chunk-MPO25DQW.js} +291 -160
  76. package/dist/{chunk-DML6BD4K.js → chunk-MW2NQQ6Z.js} +2 -2
  77. package/dist/{chunk-MSHL6CF2.js → chunk-MYO77JWR.js} +1 -1
  78. package/dist/{chunk-PSX5SF2N.js → chunk-NEASABW6.js} +1 -1
  79. package/dist/{chunk-VH4PNYOS.js → chunk-NZ6G5YWZ.js} +2 -2
  80. package/dist/{chunk-LXP6XWJL.js → chunk-ORFRUZPB.js} +1 -1
  81. package/dist/{chunk-UUOIH4RW.js → chunk-OTXXDONS.js} +2 -2
  82. package/dist/{chunk-526VSRZ4.js → chunk-P7WGVXR7.js} +6 -6
  83. package/dist/{chunk-HA3V4XAF.js → chunk-PKVA6MPV.js} +1 -1
  84. package/dist/{chunk-QTWXVOZI.js → chunk-PSOAGSNO.js} +2 -2
  85. package/dist/{chunk-ID766OZB.js → chunk-PWEOSJ3E.js} +3 -3
  86. package/dist/{chunk-EHFZEKQM.js → chunk-Q43YUROE.js} +1 -1
  87. package/dist/{chunk-7PJ3AJB2.js → chunk-QP2MJYTJ.js} +1 -1
  88. package/dist/{chunk-7RWUY3BJ.js → chunk-QWBVPWUI.js} +1 -1
  89. package/dist/{chunk-IYZT62UR.js → chunk-S2OLTAEL.js} +2 -2
  90. package/dist/{chunk-U32PA6DI.js → chunk-S4KHJERB.js} +1 -1
  91. package/dist/{chunk-FEO7YW7V.js → chunk-SI7QCT2J.js} +6 -6
  92. package/dist/{chunk-6Z7XDUUJ.js → chunk-SKKQMW5X.js} +1 -1
  93. package/dist/{chunk-VAVDAOUA.js → chunk-TNTGGDSD.js} +1 -1
  94. package/dist/{chunk-EGRIVMCQ.js → chunk-U6KN6OIP.js} +2 -2
  95. package/dist/{chunk-IBZHSU2J.js → chunk-ULL3U6PV.js} +1 -1
  96. package/dist/{chunk-IW5P4KK7.js → chunk-VR3JLTZD.js} +3 -3
  97. package/dist/{chunk-6KOHY5EP.js → chunk-VS4SK7BN.js} +17 -11
  98. package/dist/{chunk-6N65ZMC5.js → chunk-VYRJAQGC.js} +1 -1
  99. package/dist/{chunk-JKE24AG7.js → chunk-WABB4LZS.js} +1 -1
  100. package/dist/{chunk-I3TYUQLB.js → chunk-WNMVC3IT.js} +1 -1
  101. package/dist/{chunk-MAUGXKSI.js → chunk-X6MCIK7L.js} +100 -13
  102. package/dist/chunk-XFMO3BEN.js +71 -0
  103. package/dist/{chunk-PUIG6DHT.js → chunk-XG3IZV62.js} +7 -7
  104. package/dist/{chunk-VBPNCOD7.js → chunk-XOFBXLMG.js} +2 -2
  105. package/dist/{chunk-FVAI7AHF.js → chunk-XUQYC5DD.js} +5 -5
  106. package/dist/chunk-Z5J67X44.js +40 -0
  107. package/dist/{chunk-XAGBSYIQ.js → chunk-Z5TGBEPJ.js} +1 -1
  108. package/dist/{chunk-7JAD4MEW.js → chunk-ZA5TNF4R.js} +1 -0
  109. package/dist/{clean-TL3IPJDN.js → clean-6GX7WAEC.js} +22 -21
  110. package/dist/cli.js +56 -56
  111. package/dist/{cloud-EYMRPJNY.js → cloud-6PFJKLNL.js} +4 -4
  112. package/dist/{cloudrun-TOJ36NLX.js → cloudrun-UGG3ZFH7.js} +6 -5
  113. package/dist/{compare-MP5EOW4D.js → compare-P4EBOP4B.js} +33 -32
  114. package/dist/{compiler-NOPVLJ2S.js → compiler-PG4RKX6K.js} +3 -3
  115. package/dist/{component-ASACDCZK.js → component-SQPMI3W7.js} +3 -3
  116. package/dist/{compositions-WKNZJY34.js → compositions-KRIHY3IY.js} +14 -13
  117. package/dist/{contactSheet-YOBPATEM.js → contactSheet-RYAE7Y5D.js} +3 -2
  118. package/dist/{delete-DQTFHP3G.js → delete-T5TO4SV6.js} +7 -7
  119. package/dist/{deploy-HHCFOUFM.js → deploy-AO6LQR5G.js} +6 -6
  120. package/dist/{dist-NQEYA4ZX.js → dist-23AAB5X2.js} +2 -2
  121. package/dist/{dist-L4Z4ZEYW.js → dist-6IMEDVMC.js} +1 -1
  122. package/dist/docker/Dockerfile.render +1 -1
  123. package/dist/{doctor-JDM65CP7.js → doctor-QBUJQ655.js} +16 -15
  124. package/dist/{events-RKRHRLJD.js → events-J7CESLKQ.js} +4 -4
  125. package/dist/{events-MBRNA3UF.js → events-SIZO7YHI.js} +5 -5
  126. package/dist/{feedback-LZWIWV5J.js → feedback-74WOJ5PN.js} +12 -12
  127. package/dist/{ffmpeg-4PZKSIGE.js → ffmpeg-AKUP6U2S.js} +10 -9
  128. package/dist/{figma-QFNYUT3F.js → figma-GGMYRR4Q.js} +3 -3
  129. package/dist/fontLocalizeCli.js +11 -10
  130. package/dist/{get-2B5ENJOH.js → get-PLKAI6JM.js} +7 -7
  131. package/dist/{gpuPolicy-E5FB2GFR.js → gpuPolicy-EYDAAPJF.js} +8 -7
  132. package/dist/{grade-compare-4GUAPJHE.js → grade-compare-UADJP4AV.js} +33 -32
  133. package/dist/{heifImagePrep-C2RYIEER.js → heifImagePrep-KDF3OPOK.js} +9 -8
  134. package/dist/{help-XGDAXV67.js → help-WSQQ555Q.js} +1 -1
  135. package/dist/{history-WNFF6HGU.js → history-VSQ2DQ3V.js} +9 -9
  136. package/dist/hyperframe.manifest.json +1 -1
  137. package/dist/hyperframe.runtime.iife.js +67 -67
  138. package/dist/hyperframes-player.global.js +3 -3
  139. package/dist/{info-BR2LKGJD.js → info-MOQ4LRC3.js} +9 -9
  140. package/dist/{init-P6UWPUY3.js → init-EONQSZJG.js} +32 -31
  141. package/dist/{inspect-MSRPF7ZO.js → inspect-OLCVLHOU.js} +32 -31
  142. package/dist/{installer-MPUQS3ZX.js → installer-GHISA75B.js} +4 -4
  143. package/dist/{keyframes-J6K66QTO.js → keyframes-DGQYCY24.js} +8 -8
  144. package/dist/{lambda-LJ2OSWFJ.js → lambda-AMMWF2YH.js} +14 -13
  145. package/dist/{layout-CDY65XGA.js → layout-R6CAPGRO.js} +32 -31
  146. package/dist/{lint-CAUNBGPX.js → lint-QZJEYPHD.js} +9 -9
  147. package/dist/{lintProject-ZTSX3AWT.js → lintProject-W3YVHAGP.js} +1 -1
  148. package/dist/{list-33BYQNRZ.js → list-KCJID4SP.js} +7 -7
  149. package/dist/localPage-V3HBGM3Z.js +27 -0
  150. package/dist/{login-5QMRKOHK.js → login-7HKBEPJS.js} +7 -7
  151. package/dist/{logout-JYFWWUGK.js → logout-3IID4KXD.js} +3 -3
  152. package/dist/{manager-3JOHHPVR.js → manager-6YSKJMVD.js} +11 -10
  153. package/dist/{manager-RMYSZ3KI.js → manager-Z7W4GQGF.js} +4 -4
  154. package/dist/{media-treatment-4WP22CFN.js → media-treatment-E3DL6LEZ.js} +25 -22
  155. package/dist/{models-HPWCHAZX.js → models-URWI7YEG.js} +15 -14
  156. package/dist/{motionShot-I7GDIROQ.js → motionShot-27IXMDJK.js} +18 -17
  157. package/dist/{normalize-audio-VTMXPSC7.js → normalize-audio-WGRLPR3P.js} +9 -9
  158. package/dist/{open-SAO7OQTT.js → open-LQ35PLEN.js} +13 -13
  159. package/dist/{parakeetRunner-ZYPBIA73.js → parakeetRunner-XASVIDTI.js} +16 -15
  160. package/dist/{pipeline-VNBMR6QU.js → pipeline-GA7QVCHS.js} +11 -10
  161. package/dist/{play-7VI6A7KN.js → play-RYZP77CI.js} +21 -21
  162. package/dist/{policies-GHVXA5PE.js → policies-PKLD4UW5.js} +1 -1
  163. package/dist/{preflight-VWV7L45J.js → preflight-HJFSJXXF.js} +12 -11
  164. package/dist/{present-CSJGYOFF.js → present-YBMLOWZV.js} +17 -17
  165. package/dist/{preview-B246ZTVO.js → preview-QIRKJCRV.js} +23 -22
  166. package/dist/{producer-WJLFDVQJ.js → producer-524FDOLX.js} +1 -1
  167. package/dist/{projectConfig-OMR46ZWQ.js → projectConfig-IDQN5ZRW.js} +6 -6
  168. package/dist/{publication-AA7NNYET.js → publication-3X3IGSDO.js} +2 -2
  169. package/dist/{publish-TJ4QVVSP.js → publish-2BF7K6HX.js} +13 -13
  170. package/dist/{refresh-USSFPJAU.js → refresh-3IRHJEQA.js} +3 -3
  171. package/dist/{remove-background-LQ2V7W7N.js → remove-background-EZBCEFT6.js} +12 -11
  172. package/dist/{render-E5QJG74D.js → render-EFUA2A6A.js} +6 -5
  173. package/dist/{render-JLTNZ36U.js → render-JFMTAXHD.js} +43 -41
  174. package/dist/{render-AWEEPG3F.js → render-TEEBI2UT.js} +30 -26
  175. package/dist/{render-batch-U4T4VSCM.js → render-batch-XTYNXVSW.js} +7 -6
  176. package/dist/renderSetupWorker.js +6 -6
  177. package/dist/{resolver-GXCTUKPV.js → resolver-FZS6TN6B.js} +4 -4
  178. package/dist/{screenshotCapture-X6OKIXCB.js → screenshotCapture-HOW4VSV6.js} +3 -2
  179. package/dist/{sherpa-4VZWVHWZ.js → sherpa-TQIAIKTH.js} +15 -14
  180. package/dist/skills/hyperframes/SKILL.md +1 -1
  181. package/dist/skills/hyperframes/references/format.md +1 -0
  182. package/dist/skills/hyperframes-cli/references/beats.md +2 -0
  183. package/dist/skills/media-use/references/grading.md +2 -0
  184. package/dist/skills/media-use/references/local.md +1 -0
  185. package/dist/{skills-WUKR7SUE.js → skills-S6ZG5KKH.js} +7 -7
  186. package/dist/{skillsUpdateCheck-YXRBY3JC.js → skillsUpdateCheck-XC7JQL3F.js} +5 -5
  187. package/dist/{snapshot-Q7S2FTNG.js → snapshot-ERYZIM32.js} +66 -47
  188. package/dist/{src-ZOXUSGAP.js → src-6XOMREMS.js} +7 -6
  189. package/dist/{src-CLAALR5W.js → src-OL6RHPE4.js} +10 -9
  190. package/dist/{staticProjectServer-DQ7PIDPA.js → staticProjectServer-JYDDGPAH.js} +16 -16
  191. package/dist/{status-LR7VXITS.js → status-DTP6ZYDU.js} +3 -3
  192. package/dist/studio/assets/{hyperframes-player-Cm5aBiKq.js → hyperframes-player-5dRdMVOq.js} +3 -3
  193. package/dist/studio/assets/{index-BF9YeBnC.js → index-Bu3mJUU2.js} +71 -71
  194. package/dist/studio/assets/{index-BrqAmMRt.js → index-ZqyQ91pm.js} +1 -1
  195. package/dist/studio/index.html +1 -1
  196. package/dist/{studio-api-NUE227JM.js → studio-api-GRU4SHKD.js} +9 -9
  197. package/dist/{studioServer-HVOKP4VI.js → studioServer-OYPBEI5B.js} +54 -53
  198. package/dist/{telemetry-IHU4HL3R.js → telemetry-6BPSGY5W.js} +2 -2
  199. package/dist/{telemetry-2Y5JXLDB.js → telemetry-CPYINR63.js} +5 -5
  200. package/dist/{timeline-WOQGXFRV.js → timeline-RGK5BMPD.js} +23 -22
  201. package/dist/{tokens-T3OHTWUC.js → tokens-EX4BOWRW.js} +2 -2
  202. package/dist/{transcribe-4U74P5TG.js → transcribe-MK367I6A.js} +14 -13
  203. package/dist/{transcribe-JZ3BO546.js → transcribe-RI52JMVW.js} +21 -20
  204. package/dist/{updateCheck-6EUAGAM4.js → updateCheck-BIEJKQI4.js} +4 -4
  205. package/dist/{upgrade-55K6F4MP.js → upgrade-ES3UUI7O.js} +4 -4
  206. package/dist/{urlDownloader-47JMOLNN.js → urlDownloader-XAGYSTAG.js} +7 -6
  207. package/dist/{validate-QBJ3SBS4.js → validate-A6GZHNEI.js} +26 -25
  208. package/dist/{video-3ZAUNAR3.js → video-OEMGR3MN.js} +10 -8
  209. package/dist/warmCheck.js +42 -41
  210. package/package.json +1 -1
  211. package/dist/chunk-BDJIQZN2.js +0 -4830
  212. package/dist/{destroy-SSPAKADI.js → destroy-CGAZIL2C.js} +4 -4
@@ -1,4 +1,4 @@
1
- var Ve=Object.defineProperty;var Ue=(r,t,e)=>t in r?Ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var l=(r,t,e)=>Ue(r,typeof t!="symbol"?t+"":t,e);import{S as He,r as We,a as ye,b as ve,i as ze,c as A,d as be,p as $e,e as je,f as Be,g as qe,s as Ge,h as Ae,F as we}from"./index-BF9YeBnC.js";const Ye=1e-5;function Ie(r){return r+Ye}const ee=.04,Xe=.03,Ke=[[.3,.25],[.1,.1]],Ze=.01,Je=.1,Qe=.1,O=new WeakMap;function et(r,t,e,i,s=r.tagName==="AUDIO"){var u;const n=Math.abs(t);if(s&&i&&n>Qe)return O.delete(r),{rate:e,seek:!0};const o=Math.sign(t),a=O.get(r);if(n>ee)O.set(r,o);else if(a!==o||n<=Ze)return O.delete(r),{rate:e,seek:!1};const c=((u=Ke.find(([y])=>n>y))==null?void 0:u[1])??Xe,p=s?Math.min(c,Je):c;return{rate:e*(1+o*p),seek:!1}}function tt(r){O.delete(r)}function it(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function st(r){return F(r)&&typeof r.getDuration=="function"}function rt(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 nt(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 j=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:nt("0.0.0-dev");function q(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function ot(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=q(t.getAttribute("data-width")),i=q(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}function at(r){return Array.isArray(r)?r.find(t=>typeof t=="string"&&t.trim()!==""&&t!=="[object Event]")??null:null}class dt{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=at(Reflect.get(e,He));if(i!==null)return{kind:"error",message:i};const s=this._iframe.contentDocument,n=Reflect.get(e,"__timelines"),o=this.hasRuntimeBridge(e);if(it({hasRuntime:o,hasTimelines:F(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=We(e))==null?void 0:n.durationSeconds)??0:0}return s<=0?null:{duration:s,adapter:{...i,getDuration:()=>s},compositionSize:ot(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 F(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))??j,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(!F(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 rt(o)?o:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(st(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const lt=`
1
+ var Ve=Object.defineProperty;var Ue=(r,t,e)=>t in r?Ve(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var l=(r,t,e)=>Ue(r,typeof t!="symbol"?t+"":t,e);import{S as He,r as We,a as ye,b as ve,i as ze,c as A,d as be,p as $e,e as je,f as Be,g as qe,s as Ge,h as Ae,F as we}from"./index-Bu3mJUU2.js";function Ye(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function Xe(r){return F(r)&&typeof r.getDuration=="function"}function Ke(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 Ze(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 j=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Ze("0.0.0-dev");function q(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function Je(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=q(t.getAttribute("data-width")),i=q(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}function Qe(r){return Array.isArray(r)?r.find(t=>typeof t=="string"&&t.trim()!==""&&t!=="[object Event]")??null:null}class et{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=Qe(Reflect.get(e,He));if(i!==null)return{kind:"error",message:i};const s=this._iframe.contentDocument,n=Reflect.get(e,"__timelines"),o=this.hasRuntimeBridge(e);if(Ye({hasRuntime:o,hasTimelines:F(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=We(e))==null?void 0:n.durationSeconds)??0:0}return s<=0?null:{duration:s,adapter:{...i,getDuration:()=>s},compositionSize:Je(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 F(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))??j,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(!F(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 Ke(o)?o:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(Xe(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const tt=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -474,5 +474,5 @@ var Ve=Object.defineProperty;var Ue=(r,t,e)=>t in r?Ve(r,t,{enumerable:!0,config
474
474
  background: var(--hfp-accent, #fff);
475
475
  pointer-events: none;
476
476
  }
477
- `,ut='<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>',ht='<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>',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"/><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>',Ee='<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>',ct='<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>',pt=[.25,.5,1,1.5,2,4];function k(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function Te(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 mt(r,t,e={}){const i=e.speedPresets??pt,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">${ut}</span><span class="hfp-ico hfp-ico-pause">${ht}</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 u=document.createElement("button");u.className="hfp-speed-btn",u.type="button",u.textContent="1x",u.setAttribute("aria-label","Playback speed: 1x");const y=document.createElement("div");y.className="hfp-speed-menu",y.setAttribute("role","menu");for(const d of i){const h=document.createElement("button");h.className="hfp-speed-option",h.type="button",h.setAttribute("role","menuitem"),h.dataset.speed=String(d),h.textContent=k(d),d===1&&h.classList.add("hfp-active"),y.appendChild(h)}p.appendChild(y),p.appendChild(u);const m=document.createElement("div");m.className="hfp-volume-wrap";const f=document.createElement("button");f.className="hfp-mute-btn",f.type="button",f.innerHTML=Se,f.setAttribute("aria-label","Mute");const g=document.createElement("div");g.className="hfp-volume-slider-wrap";const _=document.createElement("div");_.className="hfp-volume-slider",_.setAttribute("role","slider"),_.setAttribute("aria-label","Volume"),_.setAttribute("aria-valuemin","0"),_.setAttribute("aria-valuemax","100"),_.setAttribute("aria-valuenow","100"),_.tabIndex=0;const b=document.createElement("div");b.className="hfp-volume-fill",b.style.width="100%",_.appendChild(b),g.appendChild(_),m.appendChild(g),m.appendChild(f),e.audioLocked&&(m.style.display="none"),s.appendChild(n),s.appendChild(o),s.appendChild(c),s.appendChild(m),s.appendChild(p),r.appendChild(s);let P=!1,w=!1,T=1,R=null;i.indexOf(1);const V=(d,h)=>d?ct:h===0||h<.5?Ee:Se;n.addEventListener("click",d=>{d.stopPropagation(),P?t.onPause():t.onPlay()}),f.addEventListener("click",d=>{d.stopPropagation(),t.onMuteToggle()});let C=!1;const U=d=>{const h=_.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-h.left)/h.width));T=v,b.style.width=`${v*100}%`,_.setAttribute("aria-valuenow",String(Math.round(v*100))),w&&v>0&&t.onMuteToggle(),f.innerHTML=V(w,v),t.onVolumeChange(v)};_.addEventListener("mousedown",d=>{d.stopPropagation(),C=!0,U(d.clientX)});const re=d=>{C&&U(d.clientX)},ne=()=>{C=!1};document.addEventListener("mousemove",re),document.addEventListener("mouseup",ne),_.addEventListener("touchstart",d=>{C=!0;const h=d.touches[0];h&&U(h.clientX)},{passive:!0});const oe=d=>{if(C){const h=d.touches[0];h&&U(h.clientX)}},ae=()=>{C=!1};document.addEventListener("touchmove",oe,{passive:!0}),document.addEventListener("touchend",ae);const de=.05;_.addEventListener("keydown",d=>{let h=T;if(d.key==="ArrowRight"||d.key==="ArrowUp")h=Math.min(1,T+de);else if(d.key==="ArrowLeft"||d.key==="ArrowDown")h=Math.max(0,T-de);else return;d.preventDefault(),d.stopPropagation(),T=h,b.style.width=`${h*100}%`,_.setAttribute("aria-valuenow",String(Math.round(h*100))),w&&h>0&&t.onMuteToggle(),f.innerHTML=V(w,h),t.onVolumeChange(h)});const le=d=>{for(const h of y.querySelectorAll(".hfp-speed-option"))h.classList.toggle("hfp-active",h.dataset.speed===String(d))};u.addEventListener("click",d=>{d.stopPropagation();const h=y.classList.toggle("hfp-open");u.setAttribute("aria-expanded",String(h))}),y.addEventListener("click",d=>{d.stopPropagation();const h=d.target.closest(".hfp-speed-option");if(!h)return;const v=parseFloat(h.dataset.speed);i.indexOf(v),u.textContent=k(v),u.setAttribute("aria-label",`Playback speed: ${k(v)}`),le(v),y.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false"),t.onSpeedChange(v)});const ue=()=>{y.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false")};document.addEventListener("click",ue);const H=d=>{const h=o.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-h.left)/h.width));t.onSeek(v)};let S=!1;o.addEventListener("mousedown",d=>{var h;d.stopPropagation(),S=!0,(h=t.onScrubStart)==null||h.call(t),H(d.clientX)});const he=d=>{S&&H(d.clientX)},ce=()=>{var d;S&&(S=!1,(d=t.onScrubEnd)==null||d.call(t))};document.addEventListener("mousemove",he),document.addEventListener("mouseup",ce),o.addEventListener("touchstart",d=>{var v;S=!0,(v=t.onScrubStart)==null||v.call(t);const h=d.touches[0];h&&H(h.clientX)},{passive:!0});const pe=d=>{if(S){const h=d.touches[0];h&&H(h.clientX)}},me=()=>{var d;S&&(S=!1,(d=t.onScrubEnd)==null||d.call(t))};document.addEventListener("touchmove",pe,{passive:!0}),document.addEventListener("touchend",me);const fe=()=>P&&!S&&!C&&!s.querySelector(":focus-visible"),_e=()=>{s.classList.remove("hfp-hidden"),R&&clearTimeout(R),R=setTimeout(()=>{fe()&&s.classList.add("hfp-hidden")},3e3)},E=r instanceof ShadowRoot?r.host:r,L=()=>_e(),ge=()=>{fe()&&s.classList.add("hfp-hidden")};return E.addEventListener("mousemove",L),E.addEventListener("keydown",L),E.addEventListener("focusin",L),E.addEventListener("mouseleave",ge),{updateTime(d,h){const v=h>0?Math.min(d,h):d,Fe=h>0?v/h*100:0;a.style.width=`${Fe}%`,c.textContent=`${Te(v)} / ${Te(h)}`},updatePlaying(d){const h=d!==P;P=d,n.classList.toggle("hfp-playing",d),n.setAttribute("aria-label",d?"Pause":"Play"),d?h&&_e():(R&&clearTimeout(R),s.classList.remove("hfp-hidden"))},updateSpeed(d){i.indexOf(d),u.textContent=k(d),u.setAttribute("aria-label",`Playback speed: ${k(d)}`),le(d)},updateMuted(d){w=d,f.innerHTML=V(d,T),f.setAttribute("aria-label",d?"Unmute":"Mute")},updateVolume(d){T=d,b.style.width=`${d*100}%`,_.setAttribute("aria-valuenow",String(Math.round(d*100))),f.innerHTML=V(w,d)},setVolumeControlsHidden(d){m.style.display=d?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",ce),document.removeEventListener("touchmove",pe),document.removeEventListener("touchend",me),document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",ne),document.removeEventListener("touchmove",oe),document.removeEventListener("touchend",ae),document.removeEventListener("click",ue),E.removeEventListener("mousemove",L),E.removeEventListener("keydown",L),E.removeEventListener("focusin",L),E.removeEventListener("mouseleave",ge),R&&clearTimeout(R),s.remove()}}}function ft(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=mt(r,s,a);return c.updateMuted(t),c.updateVolume(e),c}function Re(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 _t(r){return r.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("hfp-controls"))}let W=null;function gt(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 yt(){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 vt(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 bt=100,At=.001;function wt(r,t,e){if(e.end<=0)return!1;const i=e.shown<e.end&&t>0?t+At:0;return r+i>=e.end}class St{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 u;try{u=t.time()}catch{this._raf=null;return}const y=i(),m=n();m.end>0&&(u=Math.min(u,m.end));const f=o===null?0:u-o;f!==0&&(c=Math.min(f,a),a=f),o=u;const g=wt(u,c,m);g&&(u=m.shown);const _=performance.now();if((_-this._lastUpdateMs>bt||g)&&(this._lastUpdateMs=_,this._callbacks.onTimeUpdate(u,y)),g){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{t.pause(),m.shown<m.end&&t.seek(m.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(p)};this._tick=p,this._raf=requestAnimationFrame(p)}poll(){this._raf===null||!this._tick||(cancelAnimationFrame(this._raf),this._tick())}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function Et(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)Rt(i)||e.push(i);return Tt(r),e}function Tt(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 Rt(r){let t=r.parentElement;for(;t;){if(t.hasAttribute("data-composition-id"))return!0;t=t.parentElement}return!1}const Ct=.004,Pt=1.5;class Lt{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=ye(t.source);t.start=e.start??0,t.mediaStart=ve(t.source).mediaStart,t.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(t,e){return ze(e,t.start,t.start+t.duration)}_preseekUpcoming(t,e){const i=t.start-e;i<=0||i>Pt||!t.el.paused||Math.abs(t.el.currentTime-t.mediaStart)>ee&&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=Ie(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){tt(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)}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)>ee&&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)<Ct;t.lastOffset=i;const{rate:n,seek:o}=et(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"))A(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)A(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?ve(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=ye(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;A(a)&&a.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(a);continue}if(o.type==="attributes"&&o.attributeName==="preload"){const a=o.target;A(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(!be(a))continue;const c=[];A(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)A(u)&&c.push(u);for(const u of c)this._adoptIframeMedia(u)}for(const a of o.removedNodes){if(!be(a))continue;const c=[];A(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)A(u)&&c.push(u);for(const u of c)this._detachIframeMedia(u)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},s=Et(t);for(const n of s)e.observe(n,i);this._mediaObserver=e}}function Ce(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 ie(r,t,e){const i=r.end??t;return i<t?$e(r.start,i,e):i}function Pe(r,t,e,i){return r<t.start||r>=ie(t,e,i)}const Dt=100;function kt(r,t){return typeof r.currentTime=="number"&&Number.isFinite(r.currentTime)?r.currentTime:(r.frame??0)/t}function Oe(r,t,e){return e<=0?!1:r.ended===!0?!0:r.ended===!1&&!r.isPlaying?!1:t>=e}function Mt(r,t,e,i,s,n){const{duration:o}=e;if(!s){const a=Oe(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 xt(r,t,e,i,s,n)}function xt(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:ie(s,e.duration,n),atEnd:i&&!a&&Oe(r,t,o),stopRuntime:r.isPlaying,entering:a}}function It(r,t,e,i){var w;const s=kt(r,t),n=!e.paused,o=n||r.isPlaying,a=(w=i.getPlayRange)==null?void 0:w.call(i),c=Mt(r,s,e,o,a,t),{atEnd:p,start:u}=c,y=e.duration>0?Math.min(s,e.duration):s,m=p?c.shownAtEnd:y,f=!r.isPlaying,g=p&&o;if(g&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(u),i.play(),{...e,currentTime:u,paused:!1,enteringRange:!0};const _={...e,currentTime:m,paused:f,enteringRange:c.entering};i.media.audioOwner==="parent"&&(n&&f?i.media.pauseAll():!n&&!f&&i.media.playAll(),i.media.mirrorTime(m));const b=performance.now(),P=f!==e.paused;return(b-e.lastUpdateMs>Dt||P)&&(_.lastUpdateMs=b,i.updateControlsTime(m,e.duration),i.updateControlsPlaying(!f),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:m}}))),g&&(c.stopRuntime&&i.seek(m),i.media.audioOwner==="parent"&&i.media.pauseAll(),_.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),_}function Ot(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 Nt(r,t,e){var o,a,c,p,u,y;if(r.source!==t)return;const i=r.data;if(!i||i.source!=="hf-preview")return;const s=je(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"){(u=e.onRuntimeDataApplied)==null||u.call(e,i.channel,i.requestId);return}if(i.type==="state"){e.setPlaybackState(It({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));return}if(i.type==="media-autoplay-blocked"){if(((y=e.shouldPromoteMediaAutoplayFallback)==null?void 0:y.call(e))===!1)return;let m=null;try{m=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(m,(f,g)=>e.media.mirrorTime(f,g)),e.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){const m=Number(i.durationSeconds),f=Number(i.durationInFrames),g=Number.isFinite(m)&&m>0?m:f/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(g)&&g>0){const _=e.getPlaybackState();e.setPlaybackState({..._,duration:g}),e.updateControlsTime(_.currentTime,g),e.onRuntimeTimelineReady(g,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}e.setScenes(Ot(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 Ft(r,t){return r.includes(t)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}const Vt=new Set([">"," "," ",`
478
- `,"\r","\f"]);function Y(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(Vt.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 Ut(r,t){if(!r||Ft(r,t))return r;const e=`<script src="${t}"><\/script>`,i=Y(r,"head");if(i)return r.slice(0,i.end)+e+r.slice(i.end);const s=Y(r,"body");if(s)return r.slice(0,s.index)+e+r.slice(s.index);const n=Y(r,"html");return n?r.slice(0,n.end)+e+r.slice(n.end):e+r}const D="shader-capture-scale",N="shader-loading",te="runtime-src",Le="__hf_shader_capture_scale",De="__hf_shader_loading",B=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function se(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 Ht(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 ke(r,t){return r.filter(e=>e!==""&&e.split("=")[0]!==t)}function Wt(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=ke(c.split("&"),Le);p=ke(p,De),t!==null&&p.push(`${Le}=${encodeURIComponent(t)}`),e!=="composition"&&p.push(`${De}=${encodeURIComponent(e)}`);const u=p.join("&");return`${a}${u?`?${u}`:""}${n}`}function zt(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 G(r){return Ht(r.getAttribute(N))}function $t(r){return Number(se(r.getAttribute(D))??"1")}function jt(r,t){return Wt(t,se(r.getAttribute(D)),G(r))}function z(r,t){return Ut(zt(t,se(r.getAttribute(D)),G(r)),Ne(r))}function Ne(r){var e;const t=(e=r.getAttribute(te))==null?void 0:e.trim();if(!t)return j;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:j}catch{return j}}function Bt(){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=f=>{f.preventDefault(),f.stopPropagation()};for(const f of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(f,t,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const i=document.createElement("div");i.className="hfp-shader-loader-mark",i.draggable=!1,i.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");const s=document.createElement("div");s.className="hfp-shader-loader-title";const n=document.createElement("span");n.className="hfp-shader-loader-title-text",n.textContent=B[0],s.appendChild(n);const o=document.createElement("div");o.className="hfp-shader-loader-detail",o.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 c=document.createElement("div");c.className="hfp-shader-loader-fill",a.appendChild(c);const p=document.createElement("div");p.className="hfp-shader-loader-progress";const u=f=>{const g=document.createElement("div");g.className="hfp-shader-loader-row";const _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=f;const b=document.createElement("span");return b.className="hfp-shader-loader-value",g.appendChild(_),g.appendChild(b),p.appendChild(g),{row:g,label:_,value:b}},y=u("transition"),m=u("transition frame");return e.appendChild(i),e.appendChild(s),e.appendChild(o),e.appendChild(a),e.appendChild(p),r.appendChild(e),{root:r,fill:c,title:n,detail:o,transitionValue:y.value,transitionRow:y.row,frameLabel:m.label,frameValue:m.value,frameRow:m.row}}const qt=420;function $(r,t,e){t.textContent=e,r.style.visibility=e?"visible":"hidden"}class Gt{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._flushHidden(),this._el.fill.style.transform="scaleX(0)",$(this._el.transitionRow,this._el.transitionValue,""),$(this._el.frameRow,this._el.frameValue,"")}update(t,e){const i=e==="player"&&t.loading&&!t.ready;if(this._drawingAssets&&!i)return;if(e!=="player"){this.reset();return}if(t.ready||!t.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions"),this._drawingAssets=!1;const s=typeof t.progress=="number"&&Number.isFinite(t.progress)?t.progress:0,n=typeof t.total=="number"&&Number.isFinite(t.total)?t.total:0,o=n>0?Math.min(1,Math.max(0,s/n)):0,a=Math.min(B.length-1,Math.floor(o*B.length));this._el.title.textContent=B[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",$(this._el.transitionRow,this._el.transitionValue,c),$(this._el.frameRow,this._el.frameValue,p),this._el.root.setAttribute("aria-valuenow",String(Math.round(o*100))),this.show()}showAssetsLoading(){this.reset(),this._el.title.textContent="Loading assets",this._el.detail.textContent="Waiting for images, video and fonts to finish loading.",this._el.root.setAttribute("aria-label","Loading assets"),this._drawingAssets=!0,this.show()}hideAssetsLoading(){this._drawingAssets&&this.hide()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._hiddenCallbacks=[]}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null,this._flushHidden()},qt)}}function Yt(r){return(r==null?void 0:r.trim().toLowerCase().startsWith("video/"))??!1}function Xt(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=Ie(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 Kt=.1,Zt=5,X="sandbox-origin",Me=1e4,K=8e3,Z="assets-loading",M="assets-loading-ui",J="low-power-idle",xe="disable-click-to-play",x="range-start",I="range-end",Jt=150;function Q(r){return!Number.isFinite(r)||r<=0?1:Math.max(Kt,Math.min(Zt,r))}class Qt 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,"_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"}),gt(this.shadow,lt),{container:this.container,iframe:this.iframe}=yt(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);const e=Bt();this.shadow.appendChild(e.root),this.shaderLoader=new Gt(e),this._media=new Lt({dispatchEvent:i=>this._emit(i),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new St({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 dt(this.iframe,{resolveRuntimeUrl:()=>Ne(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||_t(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",X,te,D,N,M,J,x,I]}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=Re(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=z(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._navigateSrc(s);break;case"type":{const u=this.getAttribute("src");if(!this.isConnected||u===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(u);break}case"srcdoc":if(!this.isConnected)break;if(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),s!==null)this._pauseForVideoSwitch(),this._teardownVideo(),this.iframe.srcdoc=z(this,s);else{this.iframe.removeAttribute("srcdoc");const u=this.getAttribute("src");u!==null&&this._wantsVideo()&&this._navigateSrc(u)}break;case X:this._applySandboxOriginPolicy(this.isConnected&&i!==s);break;case"width":this._setCompositionSize(q(s)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,q(s)??1080);break;case"controls":s!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=Re(this.shadow,s,this.posterEl);break;case"playback-rate":{const u=Q(parseFloat(s||"1"));this._media.updatePlaybackRate(u),this._sendControl("set-playback-rate",{playbackRate:u}),(a=(o=this._directTimelineAdapter)==null?void 0:o.timeScale)==null||a.call(o,u),(c=this.controlsApi)==null||c.updateSpeed(u),this._emit(new Event("ratechange"));break}case"muted":this._handleMutedChange(s);break;case"audio-locked":this._applyAudioLock(s!==null);break;case"volume":{const u=Math.max(0,Math.min(1,parseFloat(s||"1")));this._volume=u,this._syncVideoAudio(),this._media.updateVolume(u),this._sendControl("set-volume",{volume:u}),(p=this.controlsApi)==null||p.updateVolume(u),this._emit(new Event("volumechange"));break}case"audio-src":s?this._media.setupFromUrl(s):this._media.teardownUrlAudio();break;case M:s==="none"&&this.shaderLoader.hideAssetsLoading();break;case J:this._sendControl("set-idle-heartbeat",{slow:s!==null});break;case x:case I:this._applyPlayRange(!0);break;case D:case N:case te:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(X)?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=z(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?Pe(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(),(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 Q(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(Q(e)))}get shaderCaptureScale(){return $t(this)}set shaderCaptureScale(e){this.setAttribute(D,String(e))}get shaderLoading(){return G(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(N):this.setAttribute(N,e)}get assetsLoadingUi(){return this.getAttribute(M)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(M,"none"):this.removeAttribute(M)}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(xe)}set disableClickToPlay(e){this.toggleAttribute(xe,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(x)}set rangeStart(e){this._writeSeconds(x,e)}get rangeEnd(){return this._readSeconds(I)}set rangeEnd(e){this._writeSeconds(I,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(x)||this.hasAttribute(I)}_playRange(){return Ce(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}=Ce(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){Pe(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=ie(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,...Be(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 ${Me}ms`)},Me);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"))A(s)&&(s.muted=e||s.defaultMuted)}_stopIframeMedia(){const e=this._getSameOriginIframeDocument();if(e)for(const i of e.querySelectorAll("video, audio"))A(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(J)}),this._sendDisplayScale()}_sendDisplayScale(){const e=qe(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=z(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 Yt(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=jt(this,e)}_loadVideo(e){var n,o;this._videoSource||(this._videoSource=Xt({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),i.src=e}_teardownVideo(){this._videoSource&&(this._videoSource.destroy(),this._videoSource=null,this.iframe.hidden=!1)}_syncVideoAudio(){this._videoSource&&(this._videoSource.video.muted=this.muted,this._videoSource.video.volume=this._volume)}_onVideoReady(e){this._applyTimelineDuration(e.duration),this._applyVideoSize(e),this._ready=!0,this._dispatchReady(),this._waitForAssetsReady(null),this._afterEvents(()=>{this.hasAttribute("autoplay")&&this._paused&&this.play()})}_applyTimelineDuration(e){var i;!Number.isFinite(e)||e<=0||(this._setDuration(e),(i=this.controlsApi)==null||i.updateTime(this._currentTime,e))}_applyVideoSize(e){e.videoWidth>0&&e.videoHeight>0&&this._setCompositionSize(e.videoWidth,e.videoHeight)}_onVideoPlayRejected(e){e instanceof DOMException&&e.name==="NotAllowedError"&&(this._paused||this.pause(),this._emit(new CustomEvent("playbackerror",{detail:{source:"video",error:e}})))}_trySyncSeek(e){if(this._videoSource)return!1;try{const i=this.iframe.contentWindow,s=i==null?void 0:i.__player;return typeof(s==null?void 0:s.seek)!="function"?!1:(s.seek.call(s,e),!0)}catch{return!1}}_withDirectTimeline(e){const i=this._videoSource?null:this.probe.resolveDirectTimelineAdapter(),s=i||this._directTimelineAdapter;if(!s)return!1;try{return e(s),i&&i!==this._directTimelineAdapter&&this._applyTimelineDuration(i.duration()),this._directTimelineAdapter=s,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(i=>{i.seek(e,!1),i.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>void e.play())}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>void e.pause())}_showPausedVideoTime(){var e;this._videoSource&&(this._currentTime=this._videoSource.video.currentTime,(e=this.controlsApi)==null||e.updateTime(this._currentTime,this._duration),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}})))}_startParentTickClock(){this._stopParentTickClock();const e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){this._videoSource||this.probe.failed||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){Nt(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:()=>G(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),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),K)):this._settleAssetsReady(s);return}Ge(e,({timedOut:n})=>{s===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(s))},{timeoutMs:K}),this._assetsReady||this._startAssetsLoadingOverlayTimer(s)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(Z,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},Jt)}_hasPendingFirstFrameAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=Ae(e,{scope:we});return i.length>0||s.length>0||n}_warnStuckAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=Ae(e,{scope:we}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${K}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(Z),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this.probe.stop(),this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._runtimeOwnsPlayRange=!1,this._enteringRange=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(Z),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=vt(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=ft(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",Qt);export{Qt as HyperframesPlayer,pt as SPEED_PRESETS,k as formatSpeed,Te as formatTime};
477
+ `,it='<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>',st='<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>',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"/><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>',Ee='<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>',rt='<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>',nt=[.25,.5,1,1.5,2,4];function k(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function Te(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 ot(r,t,e={}){const i=e.speedPresets??nt,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">${it}</span><span class="hfp-ico hfp-ico-pause">${st}</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 u=document.createElement("button");u.className="hfp-speed-btn",u.type="button",u.textContent="1x",u.setAttribute("aria-label","Playback speed: 1x");const y=document.createElement("div");y.className="hfp-speed-menu",y.setAttribute("role","menu");for(const d of i){const h=document.createElement("button");h.className="hfp-speed-option",h.type="button",h.setAttribute("role","menuitem"),h.dataset.speed=String(d),h.textContent=k(d),d===1&&h.classList.add("hfp-active"),y.appendChild(h)}p.appendChild(y),p.appendChild(u);const m=document.createElement("div");m.className="hfp-volume-wrap";const f=document.createElement("button");f.className="hfp-mute-btn",f.type="button",f.innerHTML=Se,f.setAttribute("aria-label","Mute");const g=document.createElement("div");g.className="hfp-volume-slider-wrap";const _=document.createElement("div");_.className="hfp-volume-slider",_.setAttribute("role","slider"),_.setAttribute("aria-label","Volume"),_.setAttribute("aria-valuemin","0"),_.setAttribute("aria-valuemax","100"),_.setAttribute("aria-valuenow","100"),_.tabIndex=0;const b=document.createElement("div");b.className="hfp-volume-fill",b.style.width="100%",_.appendChild(b),g.appendChild(_),m.appendChild(g),m.appendChild(f),e.audioLocked&&(m.style.display="none"),s.appendChild(n),s.appendChild(o),s.appendChild(c),s.appendChild(m),s.appendChild(p),r.appendChild(s);let P=!1,w=!1,T=1,R=null;i.indexOf(1);const V=(d,h)=>d?rt:h===0||h<.5?Ee:Se;n.addEventListener("click",d=>{d.stopPropagation(),P?t.onPause():t.onPlay()}),f.addEventListener("click",d=>{d.stopPropagation(),t.onMuteToggle()});let C=!1;const U=d=>{const h=_.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-h.left)/h.width));T=v,b.style.width=`${v*100}%`,_.setAttribute("aria-valuenow",String(Math.round(v*100))),w&&v>0&&t.onMuteToggle(),f.innerHTML=V(w,v),t.onVolumeChange(v)};_.addEventListener("mousedown",d=>{d.stopPropagation(),C=!0,U(d.clientX)});const re=d=>{C&&U(d.clientX)},ne=()=>{C=!1};document.addEventListener("mousemove",re),document.addEventListener("mouseup",ne),_.addEventListener("touchstart",d=>{C=!0;const h=d.touches[0];h&&U(h.clientX)},{passive:!0});const oe=d=>{if(C){const h=d.touches[0];h&&U(h.clientX)}},ae=()=>{C=!1};document.addEventListener("touchmove",oe,{passive:!0}),document.addEventListener("touchend",ae);const de=.05;_.addEventListener("keydown",d=>{let h=T;if(d.key==="ArrowRight"||d.key==="ArrowUp")h=Math.min(1,T+de);else if(d.key==="ArrowLeft"||d.key==="ArrowDown")h=Math.max(0,T-de);else return;d.preventDefault(),d.stopPropagation(),T=h,b.style.width=`${h*100}%`,_.setAttribute("aria-valuenow",String(Math.round(h*100))),w&&h>0&&t.onMuteToggle(),f.innerHTML=V(w,h),t.onVolumeChange(h)});const le=d=>{for(const h of y.querySelectorAll(".hfp-speed-option"))h.classList.toggle("hfp-active",h.dataset.speed===String(d))};u.addEventListener("click",d=>{d.stopPropagation();const h=y.classList.toggle("hfp-open");u.setAttribute("aria-expanded",String(h))}),y.addEventListener("click",d=>{d.stopPropagation();const h=d.target.closest(".hfp-speed-option");if(!h)return;const v=parseFloat(h.dataset.speed);i.indexOf(v),u.textContent=k(v),u.setAttribute("aria-label",`Playback speed: ${k(v)}`),le(v),y.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false"),t.onSpeedChange(v)});const ue=()=>{y.classList.remove("hfp-open"),u.setAttribute("aria-expanded","false")};document.addEventListener("click",ue);const H=d=>{const h=o.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-h.left)/h.width));t.onSeek(v)};let S=!1;o.addEventListener("mousedown",d=>{var h;d.stopPropagation(),S=!0,(h=t.onScrubStart)==null||h.call(t),H(d.clientX)});const he=d=>{S&&H(d.clientX)},ce=()=>{var d;S&&(S=!1,(d=t.onScrubEnd)==null||d.call(t))};document.addEventListener("mousemove",he),document.addEventListener("mouseup",ce),o.addEventListener("touchstart",d=>{var v;S=!0,(v=t.onScrubStart)==null||v.call(t);const h=d.touches[0];h&&H(h.clientX)},{passive:!0});const pe=d=>{if(S){const h=d.touches[0];h&&H(h.clientX)}},me=()=>{var d;S&&(S=!1,(d=t.onScrubEnd)==null||d.call(t))};document.addEventListener("touchmove",pe,{passive:!0}),document.addEventListener("touchend",me);const fe=()=>P&&!S&&!C&&!s.querySelector(":focus-visible"),_e=()=>{s.classList.remove("hfp-hidden"),R&&clearTimeout(R),R=setTimeout(()=>{fe()&&s.classList.add("hfp-hidden")},3e3)},E=r instanceof ShadowRoot?r.host:r,L=()=>_e(),ge=()=>{fe()&&s.classList.add("hfp-hidden")};return E.addEventListener("mousemove",L),E.addEventListener("keydown",L),E.addEventListener("focusin",L),E.addEventListener("mouseleave",ge),{updateTime(d,h){const v=h>0?Math.min(d,h):d,Fe=h>0?v/h*100:0;a.style.width=`${Fe}%`,c.textContent=`${Te(v)} / ${Te(h)}`},updatePlaying(d){const h=d!==P;P=d,n.classList.toggle("hfp-playing",d),n.setAttribute("aria-label",d?"Pause":"Play"),d?h&&_e():(R&&clearTimeout(R),s.classList.remove("hfp-hidden"))},updateSpeed(d){i.indexOf(d),u.textContent=k(d),u.setAttribute("aria-label",`Playback speed: ${k(d)}`),le(d)},updateMuted(d){w=d,f.innerHTML=V(d,T),f.setAttribute("aria-label",d?"Unmute":"Mute")},updateVolume(d){T=d,b.style.width=`${d*100}%`,_.setAttribute("aria-valuenow",String(Math.round(d*100))),f.innerHTML=V(w,d)},setVolumeControlsHidden(d){m.style.display=d?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",ce),document.removeEventListener("touchmove",pe),document.removeEventListener("touchend",me),document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",ne),document.removeEventListener("touchmove",oe),document.removeEventListener("touchend",ae),document.removeEventListener("click",ue),E.removeEventListener("mousemove",L),E.removeEventListener("keydown",L),E.removeEventListener("focusin",L),E.removeEventListener("mouseleave",ge),R&&clearTimeout(R),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=ot(r,s,a);return c.updateMuted(t),c.updateVolume(e),c}function Re(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 dt(r){return r.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("hfp-controls"))}let W=null;function lt(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 ut(){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 ht(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 ct=100,pt=.001;function mt(r,t,e){if(e.end<=0)return!1;const i=e.shown<e.end&&t>0?t+pt:0;return r+i>=e.end}class ft{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 u;try{u=t.time()}catch{this._raf=null;return}const y=i(),m=n();m.end>0&&(u=Math.min(u,m.end));const f=o===null?0:u-o;f!==0&&(c=Math.min(f,a),a=f),o=u;const g=mt(u,c,m);g&&(u=m.shown);const _=performance.now();if((_-this._lastUpdateMs>ct||g)&&(this._lastUpdateMs=_,this._callbacks.onTimeUpdate(u,y)),g){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{t.pause(),m.shown<m.end&&t.seek(m.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(p)};this._tick=p,this._raf=requestAnimationFrame(p)}poll(){this._raf===null||!this._tick||(cancelAnimationFrame(this._raf),this._tick())}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function _t(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)yt(i)||e.push(i);return gt(r),e}function gt(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 yt(r){let t=r.parentElement;for(;t;){if(t.hasAttribute("data-composition-id"))return!0;t=t.parentElement}return!1}const vt=1e-5;function Ie(r){return r+vt}const ee=.04,bt=.03,At=[[.3,.25],[.1,.1]],wt=.01,St=.1,Et=.1,O=new WeakMap;function Tt(r,t,e,i,s=r.tagName==="AUDIO"){var u;const n=Math.abs(t);if(s&&i&&n>Et)return O.delete(r),{rate:e,seek:!0};const o=Math.sign(t),a=O.get(r);if(n>ee)O.set(r,o);else if(a!==o||n<=wt)return O.delete(r),{rate:e,seek:!1};const c=((u=At.find(([y])=>n>y))==null?void 0:u[1])??bt,p=s?Math.min(c,St):c;return{rate:e*(1+o*p),seek:!1}}function Rt(r){O.delete(r)}const Ct=.004,Pt=1.5;class Lt{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=ye(t.source);t.start=e.start??0,t.mediaStart=ve(t.source).mediaStart,t.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(t,e){return ze(e,t.start,t.start+t.duration)}_preseekUpcoming(t,e){const i=t.start-e;i<=0||i>Pt||!t.el.paused||Math.abs(t.el.currentTime-t.mediaStart)>ee&&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=Ie(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){Rt(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)}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)>ee&&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)<Ct;t.lastOffset=i;const{rate:n,seek:o}=Tt(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"))A(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)A(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?ve(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=ye(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;A(a)&&a.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(a);continue}if(o.type==="attributes"&&o.attributeName==="preload"){const a=o.target;A(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(!be(a))continue;const c=[];A(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)A(u)&&c.push(u);for(const u of c)this._adoptIframeMedia(u)}for(const a of o.removedNodes){if(!be(a))continue;const c=[];A(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const u of p)A(u)&&c.push(u);for(const u of c)this._detachIframeMedia(u)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},s=_t(t);for(const n of s)e.observe(n,i);this._mediaObserver=e}}function Ce(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 ie(r,t,e){const i=r.end??t;return i<t?$e(r.start,i,e):i}function Pe(r,t,e,i){return r<t.start||r>=ie(t,e,i)}const Dt=100;function kt(r,t){return typeof r.currentTime=="number"&&Number.isFinite(r.currentTime)?r.currentTime:(r.frame??0)/t}function Oe(r,t,e){return e<=0?!1:r.ended===!0?!0:r.ended===!1&&!r.isPlaying?!1:t>=e}function Mt(r,t,e,i,s,n){const{duration:o}=e;if(!s){const a=Oe(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 xt(r,t,e,i,s,n)}function xt(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:ie(s,e.duration,n),atEnd:i&&!a&&Oe(r,t,o),stopRuntime:r.isPlaying,entering:a}}function It(r,t,e,i){var w;const s=kt(r,t),n=!e.paused,o=n||r.isPlaying,a=(w=i.getPlayRange)==null?void 0:w.call(i),c=Mt(r,s,e,o,a,t),{atEnd:p,start:u}=c,y=e.duration>0?Math.min(s,e.duration):s,m=p?c.shownAtEnd:y,f=!r.isPlaying,g=p&&o;if(g&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(u),i.play(),{...e,currentTime:u,paused:!1,enteringRange:!0};const _={...e,currentTime:m,paused:f,enteringRange:c.entering};i.media.audioOwner==="parent"&&(n&&f?i.media.pauseAll():!n&&!f&&i.media.playAll(),i.media.mirrorTime(m));const b=performance.now(),P=f!==e.paused;return(b-e.lastUpdateMs>Dt||P)&&(_.lastUpdateMs=b,i.updateControlsTime(m,e.duration),i.updateControlsPlaying(!f),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:m}}))),g&&(c.stopRuntime&&i.seek(m),i.media.audioOwner==="parent"&&i.media.pauseAll(),_.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),_}function Ot(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 Nt(r,t,e){var o,a,c,p,u,y;if(r.source!==t)return;const i=r.data;if(!i||i.source!=="hf-preview")return;const s=je(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"){(u=e.onRuntimeDataApplied)==null||u.call(e,i.channel,i.requestId);return}if(i.type==="state"){e.setPlaybackState(It({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));return}if(i.type==="media-autoplay-blocked"){if(((y=e.shouldPromoteMediaAutoplayFallback)==null?void 0:y.call(e))===!1)return;let m=null;try{m=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(m,(f,g)=>e.media.mirrorTime(f,g)),e.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){const m=Number(i.durationSeconds),f=Number(i.durationInFrames),g=Number.isFinite(m)&&m>0?m:f/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(g)&&g>0){const _=e.getPlaybackState();e.setPlaybackState({..._,duration:g}),e.updateControlsTime(_.currentTime,g),e.onRuntimeTimelineReady(g,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}e.setScenes(Ot(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 Ft(r,t){return r.includes(t)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}const Vt=new Set([">"," "," ",`
478
+ `,"\r","\f"]);function Y(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(Vt.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 Ut(r,t){if(!r||Ft(r,t))return r;const e=`<script src="${t}"><\/script>`,i=Y(r,"head");if(i)return r.slice(0,i.end)+e+r.slice(i.end);const s=Y(r,"body");if(s)return r.slice(0,s.index)+e+r.slice(s.index);const n=Y(r,"html");return n?r.slice(0,n.end)+e+r.slice(n.end):e+r}const D="shader-capture-scale",N="shader-loading",te="runtime-src",Le="__hf_shader_capture_scale",De="__hf_shader_loading",B=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function se(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 Ht(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 ke(r,t){return r.filter(e=>e!==""&&e.split("=")[0]!==t)}function Wt(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=ke(c.split("&"),Le);p=ke(p,De),t!==null&&p.push(`${Le}=${encodeURIComponent(t)}`),e!=="composition"&&p.push(`${De}=${encodeURIComponent(e)}`);const u=p.join("&");return`${a}${u?`?${u}`:""}${n}`}function zt(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 G(r){return Ht(r.getAttribute(N))}function $t(r){return Number(se(r.getAttribute(D))??"1")}function jt(r,t){return Wt(t,se(r.getAttribute(D)),G(r))}function z(r,t){return Ut(zt(t,se(r.getAttribute(D)),G(r)),Ne(r))}function Ne(r){var e;const t=(e=r.getAttribute(te))==null?void 0:e.trim();if(!t)return j;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:j}catch{return j}}function Bt(){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=f=>{f.preventDefault(),f.stopPropagation()};for(const f of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(f,t,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const i=document.createElement("div");i.className="hfp-shader-loader-mark",i.draggable=!1,i.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");const s=document.createElement("div");s.className="hfp-shader-loader-title";const n=document.createElement("span");n.className="hfp-shader-loader-title-text",n.textContent=B[0],s.appendChild(n);const o=document.createElement("div");o.className="hfp-shader-loader-detail",o.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 c=document.createElement("div");c.className="hfp-shader-loader-fill",a.appendChild(c);const p=document.createElement("div");p.className="hfp-shader-loader-progress";const u=f=>{const g=document.createElement("div");g.className="hfp-shader-loader-row";const _=document.createElement("span");_.className="hfp-shader-loader-label",_.textContent=f;const b=document.createElement("span");return b.className="hfp-shader-loader-value",g.appendChild(_),g.appendChild(b),p.appendChild(g),{row:g,label:_,value:b}},y=u("transition"),m=u("transition frame");return e.appendChild(i),e.appendChild(s),e.appendChild(o),e.appendChild(a),e.appendChild(p),r.appendChild(e),{root:r,fill:c,title:n,detail:o,transitionValue:y.value,transitionRow:y.row,frameLabel:m.label,frameValue:m.value,frameRow:m.row}}const qt=420;function $(r,t,e){t.textContent=e,r.style.visibility=e?"visible":"hidden"}class Gt{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._flushHidden(),this._el.fill.style.transform="scaleX(0)",$(this._el.transitionRow,this._el.transitionValue,""),$(this._el.frameRow,this._el.frameValue,"")}update(t,e){const i=e==="player"&&t.loading&&!t.ready;if(this._drawingAssets&&!i)return;if(e!=="player"){this.reset();return}if(t.ready||!t.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions"),this._drawingAssets=!1;const s=typeof t.progress=="number"&&Number.isFinite(t.progress)?t.progress:0,n=typeof t.total=="number"&&Number.isFinite(t.total)?t.total:0,o=n>0?Math.min(1,Math.max(0,s/n)):0,a=Math.min(B.length-1,Math.floor(o*B.length));this._el.title.textContent=B[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",$(this._el.transitionRow,this._el.transitionValue,c),$(this._el.frameRow,this._el.frameValue,p),this._el.root.setAttribute("aria-valuenow",String(Math.round(o*100))),this.show()}showAssetsLoading(){this.reset(),this._el.title.textContent="Loading assets",this._el.detail.textContent="Waiting for images, video and fonts to finish loading.",this._el.root.setAttribute("aria-label","Loading assets"),this._drawingAssets=!0,this.show()}hideAssetsLoading(){this._drawingAssets&&this.hide()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._hiddenCallbacks=[]}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null,this._flushHidden()},qt)}}function Yt(r){return(r==null?void 0:r.trim().toLowerCase().startsWith("video/"))??!1}function Xt(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=Ie(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 Kt=.1,Zt=5,X="sandbox-origin",Me=1e4,K=8e3,Z="assets-loading",M="assets-loading-ui",J="low-power-idle",xe="disable-click-to-play",x="range-start",I="range-end",Jt=150;function Q(r){return!Number.isFinite(r)||r<=0?1:Math.max(Kt,Math.min(Zt,r))}class Qt 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,"_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"}),lt(this.shadow,tt),{container:this.container,iframe:this.iframe}=ut(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);const e=Bt();this.shadow.appendChild(e.root),this.shaderLoader=new Gt(e),this._media=new Lt({dispatchEvent:i=>this._emit(i),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new ft({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 et(this.iframe,{resolveRuntimeUrl:()=>Ne(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||dt(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",X,te,D,N,M,J,x,I]}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=Re(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=z(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._navigateSrc(s);break;case"type":{const u=this.getAttribute("src");if(!this.isConnected||u===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(u);break}case"srcdoc":if(!this.isConnected)break;if(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),s!==null)this._pauseForVideoSwitch(),this._teardownVideo(),this.iframe.srcdoc=z(this,s);else{this.iframe.removeAttribute("srcdoc");const u=this.getAttribute("src");u!==null&&this._wantsVideo()&&this._navigateSrc(u)}break;case X:this._applySandboxOriginPolicy(this.isConnected&&i!==s);break;case"width":this._setCompositionSize(q(s)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,q(s)??1080);break;case"controls":s!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=Re(this.shadow,s,this.posterEl);break;case"playback-rate":{const u=Q(parseFloat(s||"1"));this._media.updatePlaybackRate(u),this._sendControl("set-playback-rate",{playbackRate:u}),(a=(o=this._directTimelineAdapter)==null?void 0:o.timeScale)==null||a.call(o,u),(c=this.controlsApi)==null||c.updateSpeed(u),this._emit(new Event("ratechange"));break}case"muted":this._handleMutedChange(s);break;case"audio-locked":this._applyAudioLock(s!==null);break;case"volume":{const u=Math.max(0,Math.min(1,parseFloat(s||"1")));this._volume=u,this._syncVideoAudio(),this._media.updateVolume(u),this._sendControl("set-volume",{volume:u}),(p=this.controlsApi)==null||p.updateVolume(u),this._emit(new Event("volumechange"));break}case"audio-src":s?this._media.setupFromUrl(s):this._media.teardownUrlAudio();break;case M:s==="none"&&this.shaderLoader.hideAssetsLoading();break;case J:this._sendControl("set-idle-heartbeat",{slow:s!==null});break;case x:case I:this._applyPlayRange(!0);break;case D:case N:case te:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(X)?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=z(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?Pe(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(),(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 Q(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(Q(e)))}get shaderCaptureScale(){return $t(this)}set shaderCaptureScale(e){this.setAttribute(D,String(e))}get shaderLoading(){return G(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(N):this.setAttribute(N,e)}get assetsLoadingUi(){return this.getAttribute(M)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(M,"none"):this.removeAttribute(M)}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(xe)}set disableClickToPlay(e){this.toggleAttribute(xe,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(x)}set rangeStart(e){this._writeSeconds(x,e)}get rangeEnd(){return this._readSeconds(I)}set rangeEnd(e){this._writeSeconds(I,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(x)||this.hasAttribute(I)}_playRange(){return Ce(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}=Ce(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){Pe(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=ie(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,...Be(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 ${Me}ms`)},Me);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"))A(s)&&(s.muted=e||s.defaultMuted)}_stopIframeMedia(){const e=this._getSameOriginIframeDocument();if(e)for(const i of e.querySelectorAll("video, audio"))A(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(J)}),this._sendDisplayScale()}_sendDisplayScale(){const e=qe(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=z(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 Yt(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=jt(this,e)}_loadVideo(e){var n,o;this._videoSource||(this._videoSource=Xt({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),i.src=e}_teardownVideo(){this._videoSource&&(this._videoSource.destroy(),this._videoSource=null,this.iframe.hidden=!1)}_syncVideoAudio(){this._videoSource&&(this._videoSource.video.muted=this.muted,this._videoSource.video.volume=this._volume)}_onVideoReady(e){this._applyTimelineDuration(e.duration),this._applyVideoSize(e),this._ready=!0,this._dispatchReady(),this._waitForAssetsReady(null),this._afterEvents(()=>{this.hasAttribute("autoplay")&&this._paused&&this.play()})}_applyTimelineDuration(e){var i;!Number.isFinite(e)||e<=0||(this._setDuration(e),(i=this.controlsApi)==null||i.updateTime(this._currentTime,e))}_applyVideoSize(e){e.videoWidth>0&&e.videoHeight>0&&this._setCompositionSize(e.videoWidth,e.videoHeight)}_onVideoPlayRejected(e){e instanceof DOMException&&e.name==="NotAllowedError"&&(this._paused||this.pause(),this._emit(new CustomEvent("playbackerror",{detail:{source:"video",error:e}})))}_trySyncSeek(e){if(this._videoSource)return!1;try{const i=this.iframe.contentWindow,s=i==null?void 0:i.__player;return typeof(s==null?void 0:s.seek)!="function"?!1:(s.seek.call(s,e),!0)}catch{return!1}}_withDirectTimeline(e){const i=this._videoSource?null:this.probe.resolveDirectTimelineAdapter(),s=i||this._directTimelineAdapter;if(!s)return!1;try{return e(s),i&&i!==this._directTimelineAdapter&&this._applyTimelineDuration(i.duration()),this._directTimelineAdapter=s,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(i=>{i.seek(e,!1),i.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>void e.play())}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>void e.pause())}_showPausedVideoTime(){var e;this._videoSource&&(this._currentTime=this._videoSource.video.currentTime,(e=this.controlsApi)==null||e.updateTime(this._currentTime,this._duration),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}})))}_startParentTickClock(){this._stopParentTickClock();const e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){this._videoSource||this.probe.failed||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){Nt(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:()=>G(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),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),K)):this._settleAssetsReady(s);return}Ge(e,({timedOut:n})=>{s===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(s))},{timeoutMs:K}),this._assetsReady||this._startAssetsLoadingOverlayTimer(s)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(Z,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},Jt)}_hasPendingFirstFrameAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=Ae(e,{scope:we});return i.length>0||s.length>0||n}_warnStuckAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=Ae(e,{scope:we}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${K}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(Z),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this.probe.stop(),this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._runtimeOwnsPlayRange=!1,this._enteringRange=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(Z),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=ht(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",Qt);export{Qt as HyperframesPlayer,nt as SPEED_PRESETS,k as formatSpeed,Te as formatTime};