hyperframes 0.8.41 → 0.8.42

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.
@@ -59553,6 +59553,19 @@ function getHdrEncoderColorParams(transfer, mastering = DEFAULT_HDR10_MASTERING)
59553
59553
  mastering
59554
59554
  };
59555
59555
  }
59556
+ function sanitizeHdrAutoPromotionAsset(asset) {
59557
+ return asset.split(/[\r\n?#]/, 1)[0] ?? "";
59558
+ }
59559
+ function findHdrAutoPromotion(sources) {
59560
+ const source = sources.find(({ colorSpace }) => isHdrColorSpace(colorSpace));
59561
+ return source ? {
59562
+ triggeringAsset: sanitizeHdrAutoPromotionAsset(source.asset),
59563
+ output: HDR_AUTO_PROMOTION_PIPELINE
59564
+ } : null;
59565
+ }
59566
+ function formatHdrAutoPromotionWarning(promotion) {
59567
+ return `[Render] HDR auto-promotion triggered by "${promotion.triggeringAsset}" \u2014 output: ${promotion.output.colorSpace} / ${promotion.output.codec}`;
59568
+ }
59556
59569
  function analyzeCompositionHdr(colorSpaces) {
59557
59570
  let hasPq = false;
59558
59571
  let hasHdr = false;
@@ -59565,7 +59578,7 @@ function analyzeCompositionHdr(colorSpaces) {
59565
59578
  const dominantTransfer = hasPq ? "pq" : "hlg";
59566
59579
  return { hasHdr: true, dominantTransfer };
59567
59580
  }
59568
- var DEFAULT_HDR10_MASTERING;
59581
+ var DEFAULT_HDR10_MASTERING, HDR_AUTO_PROMOTION_PIPELINE;
59569
59582
  var init_hdr = __esm({
59570
59583
  "../engine/src/utils/hdr.ts"() {
59571
59584
  "use strict";
@@ -59573,6 +59586,10 @@ var init_hdr = __esm({
59573
59586
  masterDisplay: "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)",
59574
59587
  maxCll: "1000,400"
59575
59588
  };
59589
+ HDR_AUTO_PROMOTION_PIPELINE = {
59590
+ colorSpace: "BT.2020",
59591
+ codec: "HEVC Main10"
59592
+ };
59576
59593
  }
59577
59594
  });
59578
59595
 
@@ -75181,6 +75198,9 @@ async function extractVideoFramesRange(videoPath, videoId, startTime, duration,
75181
75198
  if (options.sdrToHdrTransfer) {
75182
75199
  vfFilters.push(SDR_TO_HDR_COLORSPACE_FILTER);
75183
75200
  }
75201
+ if (options.toneMapHdrToSdr && isHdr && !isMacOS) {
75202
+ vfFilters.push(HDR_TO_SDR_TONEMAP_FILTER);
75203
+ }
75184
75204
  if (vfFilters.length > 0) args.push("-vf", vfFilters.join(","));
75185
75205
  if (!options.finalFrameOnly && metadata.isVFR) {
75186
75206
  args.push("-fps_mode", "cfr", "-r", ffmpegFps);
@@ -75471,6 +75491,7 @@ function supersetGroupingKey(work, fps) {
75471
75491
  String(fps),
75472
75492
  work.format,
75473
75493
  work.sdrToHdrTransfer ?? "",
75494
+ work.toneMapHdrToSdr ? HDR_TO_SDR_TRANSFORM_KEY : "",
75474
75495
  work.finalFrameOnly ? "final" : "range"
75475
75496
  ].join("\0");
75476
75497
  }
@@ -75802,6 +75823,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
75802
75823
  ...options,
75803
75824
  format: work.format,
75804
75825
  sdrToHdrTransfer: work.sdrToHdrTransfer,
75826
+ toneMapHdrToSdr: work.toneMapHdrToSdr,
75805
75827
  finalFrameOnly: work.finalFrameOnly
75806
75828
  };
75807
75829
  }
@@ -75821,6 +75843,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
75821
75843
  if (!keyInput) return { work };
75822
75844
  const transformParts = [
75823
75845
  work.sdrToHdrTransfer ? sdrToHdrTransformKey(work.sdrToHdrTransfer) : void 0,
75846
+ work.toneMapHdrToSdr ? HDR_TO_SDR_TRANSFORM_KEY : void 0,
75824
75847
  work.finalFrameOnly ? "final-frame" : void 0
75825
75848
  ].filter((part) => part !== void 0);
75826
75849
  const transform = transformParts.length > 0 ? transformParts.join("+") : void 0;
@@ -76001,8 +76024,9 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
76001
76024
  if (keyInput) keyInput.mediaStart = extractionMediaStart;
76002
76025
  const format = resolveFrameFormat(metadata, options.format);
76003
76026
  const sdrToHdrTransfer = sdrToHdrTransfers[index];
76027
+ const toneMapHdrToSdr = options.toneMapHdrToSdr === true && isHdrColorSpace(metadata.colorSpace);
76004
76028
  const finalFrameOnly = window3.finalFrameOnly === true;
76005
- const dedupeKey = `${videoPath}\0${extractionMediaStart}\0${videoDuration}\0${fpsKey}\0${format}\0${sdrToHdrTransfer ?? ""}\0${finalFrameOnly ? "final" : "range"}`;
76029
+ const dedupeKey = `${videoPath}\0${extractionMediaStart}\0${videoDuration}\0${fpsKey}\0${format}\0${sdrToHdrTransfer ?? ""}\0${toneMapHdrToSdr ? HDR_TO_SDR_TRANSFORM_KEY : ""}\0${finalFrameOnly ? "final" : "range"}`;
76006
76030
  return {
76007
76031
  work: {
76008
76032
  video,
@@ -76014,6 +76038,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
76014
76038
  finalFrameOnly,
76015
76039
  format,
76016
76040
  sdrToHdrTransfer,
76041
+ toneMapHdrToSdr,
76017
76042
  dedupeKey
76018
76043
  }
76019
76044
  };
@@ -76148,7 +76173,7 @@ function createFrameLookupTable(videos, extracted) {
76148
76173
  }
76149
76174
  return table;
76150
76175
  }
76151
- var VIDEO_FRAME_FORMATS, EXTRACT_CACHE_MIN_AGE_MS, GC_STALENESS_MS, SDR_TO_HDR_COLORSPACE_FILTER, VideoSourceExtractionError, TRANSIENT_FFMPEG_SPAWN_CODES, FINAL_FRAME_LOGICAL_DURATION_SECONDS, ALPHA_CAPABLE_CODECS, FrameLookupTable;
76176
+ var VIDEO_FRAME_FORMATS, EXTRACT_CACHE_MIN_AGE_MS, GC_STALENESS_MS, SDR_TO_HDR_COLORSPACE_FILTER, HDR_TO_SDR_TONEMAP_FILTER, HDR_TO_SDR_TRANSFORM_KEY, VideoSourceExtractionError, TRANSIENT_FFMPEG_SPAWN_CODES, FINAL_FRAME_LOGICAL_DURATION_SECONDS, ALPHA_CAPABLE_CODECS, FrameLookupTable;
76152
76177
  var init_videoFrameExtractor = __esm({
76153
76178
  "../engine/src/services/videoFrameExtractor.ts"() {
76154
76179
  "use strict";
@@ -76168,6 +76193,8 @@ var init_videoFrameExtractor = __esm({
76168
76193
  EXTRACT_CACHE_MIN_AGE_MS = 60 * 60 * 1e3;
76169
76194
  GC_STALENESS_MS = 24 * 60 * 60 * 1e3;
76170
76195
  SDR_TO_HDR_COLORSPACE_FILTER = "colorspace=all=bt2020:iall=bt709:range=tv";
76196
+ HDR_TO_SDR_TONEMAP_FILTER = "zscale=t=linear:npl=100,tonemap=hable:desat=0,zscale=p=bt709:t=bt709:m=bt709:r=tv";
76197
+ HDR_TO_SDR_TRANSFORM_KEY = "hdr2sdr-hable-bt709";
76171
76198
  VideoSourceExtractionError = class extends Error {
76172
76199
  constructor(kind, retryable, message, diagnostic = message) {
76173
76200
  super(message);
@@ -81893,6 +81920,7 @@ __export(src_exports, {
81893
81920
  FFMPEG_PATH_ENV: () => FFMPEG_PATH_ENV,
81894
81921
  FFPROBE_PATH_ENV: () => FFPROBE_PATH_ENV,
81895
81922
  FrameLookupTable: () => FrameLookupTable,
81923
+ HDR_AUTO_PROMOTION_PIPELINE: () => HDR_AUTO_PROMOTION_PIPELINE,
81896
81924
  LOW_MEMORY_TOTAL_MB_THRESHOLD: () => LOW_MEMORY_TOTAL_MB_THRESHOLD,
81897
81925
  MAX_VP9_CPU_USED: () => MAX_VP9_CPU_USED,
81898
81926
  MEDIA_VISUAL_STYLE_PROPERTIES: () => MEDIA_VISUAL_STYLE_PROPERTIES,
@@ -81977,9 +82005,11 @@ __export(src_exports, {
81977
82005
  extractVideoMetadata: () => extractVideoMetadata,
81978
82006
  extractionFrameCountForDuration: () => extractionFrameCountForDuration,
81979
82007
  fetchPublicHttpsText: () => fetchPublicHttpsText,
82008
+ findHdrAutoPromotion: () => findHdrAutoPromotion,
81980
82009
  fingerprintElementId: () => fingerprintElementId,
81981
82010
  float16ToPqRgb: () => float16ToPqRgb,
81982
82011
  formatFfmpegError: () => formatFfmpegError,
82012
+ formatHdrAutoPromotionWarning: () => formatHdrAutoPromotionWarning,
81983
82013
  getCapturePerfSummary: () => getCapturePerfSummary,
81984
82014
  getCdpSession: () => getCdpSession,
81985
82015
  getCgroupMemoryLimitMb: () => getCgroupMemoryLimitMb,
@@ -82061,6 +82091,7 @@ __export(src_exports, {
82061
82091
  safeDownloadUrlIdentity: () => safeDownloadUrlIdentity,
82062
82092
  safeVideoExtractionSourceIdentity: () => safeVideoExtractionSourceIdentity,
82063
82093
  sampleRgb48le: () => sampleRgb48le,
82094
+ sanitizeHdrAutoPromotionAsset: () => sanitizeHdrAutoPromotionAsset,
82064
82095
  scaleProtocolTimeoutForComposition: () => scaleProtocolTimeoutForComposition,
82065
82096
  selectVerifySampleIndicesForTask: () => selectVerifySampleIndicesForTask,
82066
82097
  shouldClampToScreenshotForConcreteGpu: () => shouldClampToScreenshotForConcreteGpu,
@@ -86777,6 +86808,10 @@ var ArtifactTransaction = class {
86777
86808
  }
86778
86809
  }
86779
86810
  };
86811
+ async function commitArtifactTransaction(transaction, assertNotAborted) {
86812
+ assertNotAborted();
86813
+ await transaction.commit();
86814
+ }
86780
86815
 
86781
86816
  // ../producer/src/services/render/capturePlan.ts
86782
86817
  function drawElementVerificationFailure(plan2, hasDiskFallbackHeadroom) {
@@ -86879,6 +86914,42 @@ function replanAfterFailure(plan2, failure) {
86879
86914
 
86880
86915
  // ../producer/src/services/render/hdrMode.ts
86881
86916
  init_src();
86917
+ function findRenderHdrAutoPromotionTrigger(input) {
86918
+ for (const extracted of input.extractionResult?.extracted ?? []) {
86919
+ if (!isHdrColorSpace(extracted.metadata.colorSpace)) continue;
86920
+ const source = input.videos.find(({ id }) => id === extracted.videoId)?.src;
86921
+ if (source) return source;
86922
+ }
86923
+ return input.images.find(({ id }) => input.nativeHdrImageIds.has(id))?.src;
86924
+ }
86925
+ function logHdrResolution(input, hdrMode, effectiveHdr, forcedHdrWithoutSources) {
86926
+ if (forcedHdrWithoutSources) {
86927
+ input.log.warn(
86928
+ "[Render] HDR forced by --hdr flag, but no HDR sources were detected \u2014 defaulting to HLG. SDR-only compositions may look perceptually wrong on HDR displays."
86929
+ );
86930
+ }
86931
+ if (!effectiveHdr) {
86932
+ input.log.info(
86933
+ hdrMode === "force-sdr" ? "[Render] SDR forced by --sdr flag" : "[Render] No HDR sources detected \u2014 rendering SDR"
86934
+ );
86935
+ return;
86936
+ }
86937
+ if (hdrMode === "auto") {
86938
+ input.log.warn(
86939
+ formatHdrAutoPromotionWarning({
86940
+ triggeringAsset: sanitizeHdrAutoPromotionAsset(
86941
+ input.autoPromotionTrigger ?? "an HDR-tagged asset"
86942
+ ),
86943
+ output: HDR_AUTO_PROMOTION_PIPELINE
86944
+ })
86945
+ );
86946
+ return;
86947
+ }
86948
+ const reason = forcedHdrWithoutSources ? "forced by --hdr flag (no HDR sources detected \u2014 defaulting to HLG)" : "forced by --hdr flag";
86949
+ input.log.info(
86950
+ `[Render] HDR ${reason} \u2014 output: ${effectiveHdr.transfer.toUpperCase()} (BT.2020, 10-bit H.265)`
86951
+ );
86952
+ }
86882
86953
  function resolveEffectiveHdrMode(input) {
86883
86954
  const hdrMode = input.hdrMode ?? "auto";
86884
86955
  const videoColorSpaces = (input.extractionResult?.extracted ?? []).map(
@@ -86907,26 +86978,7 @@ function resolveEffectiveHdrMode(input) {
86907
86978
  );
86908
86979
  effectiveHdr = void 0;
86909
86980
  }
86910
- if (forcedHdrWithoutSources) {
86911
- input.log.warn(
86912
- "[Render] HDR forced by --hdr flag, but no HDR sources were detected \u2014 defaulting to HLG. SDR-only compositions may look perceptually wrong on HDR displays."
86913
- );
86914
- }
86915
- if (effectiveHdr) {
86916
- let reason;
86917
- if (hdrMode === "force-hdr") {
86918
- reason = forcedHdrWithoutSources ? "forced by --hdr flag (no HDR sources detected \u2014 defaulting to HLG)" : "forced by --hdr flag";
86919
- } else {
86920
- reason = "auto-detected from source(s)";
86921
- }
86922
- input.log.info(
86923
- `[Render] HDR ${reason} \u2014 output: ${effectiveHdr.transfer.toUpperCase()} (BT.2020, 10-bit H.265)`
86924
- );
86925
- } else if (hdrMode === "force-sdr") {
86926
- input.log.info("[Render] SDR forced by --sdr flag");
86927
- } else {
86928
- input.log.info("[Render] No HDR sources detected \u2014 rendering SDR");
86929
- }
86981
+ logHdrResolution(input, hdrMode, effectiveHdr, forcedHdrWithoutSources);
86930
86982
  return effectiveHdr;
86931
86983
  }
86932
86984
 
@@ -92612,6 +92664,7 @@ async function runExtractVideosStage(input) {
92612
92664
  fps: job.config.fps,
92613
92665
  outputDir: join31(compiledDir, "__hyperframes_video_frames"),
92614
92666
  format: job.config.videoFrameFormat ?? "auto",
92667
+ toneMapHdrToSdr: job.config.hdrMode === "force-sdr",
92615
92668
  timelineEnd: composition.duration,
92616
92669
  maxTransientRetries: extractionPolicy.maxTransientRetries,
92617
92670
  collectProbeFailures: extractionPolicy.failureMode === "enforce"
@@ -96854,7 +96907,7 @@ function deVerifyFallbackTelemetry(err) {
96854
96907
  thresholdDb: roundDb(details?.verifyThresholdDb)
96855
96908
  };
96856
96909
  }
96857
- async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal) {
96910
+ async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
96858
96911
  const moduleDir = dirname19(fileURLToPath5(import.meta.url));
96859
96912
  const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve13(process.env.PRODUCER_RENDERS_DIR, "..") : resolve13(moduleDir, "../..");
96860
96913
  const debugDir = join43(producerRoot, ".debug");
@@ -96887,14 +96940,24 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
96887
96940
  workDir,
96888
96941
  logPath,
96889
96942
  pipelineStart,
96890
- execution
96943
+ execution,
96944
+ assertRenderActive
96891
96945
  });
96892
96946
  } finally {
96893
96947
  await execution.dispose();
96894
96948
  }
96895
96949
  }
96896
96950
  async function executeRenderPipeline(input) {
96897
- const { job, projectDir, outputPath, workDir, logPath, pipelineStart, execution } = input;
96951
+ const {
96952
+ job,
96953
+ projectDir,
96954
+ outputPath,
96955
+ workDir,
96956
+ logPath,
96957
+ pipelineStart,
96958
+ execution,
96959
+ assertRenderActive
96960
+ } = input;
96898
96961
  const log = execution.logger;
96899
96962
  const eventPublisher = execution.events;
96900
96963
  const onProgress = execution.onProgress;
@@ -97223,11 +97286,18 @@ async function executeRenderPipeline(input) {
97223
97286
  });
97224
97287
  if (failureToEnforce) throw failureToEnforce;
97225
97288
  assertVideoFrameCoverage(coverageReports, coverageThreshold);
97289
+ const autoPromotionTrigger = findRenderHdrAutoPromotionTrigger({
97290
+ extractionResult,
97291
+ videos: composition.videos,
97292
+ images: composition.images,
97293
+ nativeHdrImageIds
97294
+ });
97226
97295
  const effectiveHdr = resolveEffectiveHdrMode({
97227
97296
  hdrMode: job.config.hdrMode,
97228
97297
  outputFormat,
97229
97298
  extractionResult,
97230
97299
  imageColorSpaces,
97300
+ autoPromotionTrigger,
97231
97301
  log
97232
97302
  });
97233
97303
  observability.checkpoint("hdr_detection", "resolved", {
@@ -98248,7 +98318,10 @@ async function executeRenderPipeline(input) {
98248
98318
  copyFileSync6(stagedOutputPath, debugOutput);
98249
98319
  }
98250
98320
  }
98251
- await artifactTransaction.commit();
98321
+ await commitArtifactTransaction(artifactTransaction, () => {
98322
+ assertRenderActive?.();
98323
+ assertNotAborted();
98324
+ });
98252
98325
  job.outputPath = outputPath;
98253
98326
  updateJobStatus(job, "complete", "Render complete", 100, onProgress);
98254
98327
  await eventPublisher.flush();
@@ -99633,8 +99706,8 @@ async function runFontLocalize(io, localize) {
99633
99706
  }
99634
99707
 
99635
99708
  // src/version.ts
99636
- var VERSION = true ? "0.8.41" : "0.0.0-dev";
99637
- var PRODUCER_VERSION = true ? "0.8.41" : "0.0.0-dev";
99709
+ var VERSION = true ? "0.8.42" : "0.0.0-dev";
99710
+ var PRODUCER_VERSION = true ? "0.8.42" : "0.0.0-dev";
99638
99711
 
99639
99712
  // src/fontLocalizeCli.ts
99640
99713
  async function readStdin() {
@@ -1,4 +1,4 @@
1
- "use strict";var HyperframesPlayer=(()=>{var ee=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var it=Object.prototype.hasOwnProperty;var rt=(r,e)=>{for(var t in e)ee(r,t,{get:e[t],enumerable:!0})},nt=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tt(e))!it.call(r,n)&&n!==t&&ee(r,n,{get:()=>e[n],enumerable:!(i=et(e,n))||i.enumerable});return r};var ot=r=>nt(ee({},"__esModule",{value:!0}),r);var Ht={};rt(Ht,{HyperframesPlayer:()=>K,SPEED_PRESETS:()=>re,formatSpeed:()=>O,formatTime:()=>q});function we(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function P(r){return typeof r=="object"&&r!==null}function Ae(r){return P(r)&&typeof r.getDuration=="function"}function Ce(r){return P(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}var k="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.41/dist/hyperframe.runtime.iife.js";function N(r){if(r===null)return null;let e=Number.parseInt(r,10);return Number.isFinite(e)&&e>0?e:null}function at(r){let e=r?.querySelector("[data-composition-id][data-width][data-height]")??r?.querySelector("[data-width][data-height]");if(!e)return null;let t=N(e.getAttribute("data-width")),i=N(e.getAttribute("data-height"));return t!==null&&i!==null?{width:t,height:i}:null}var W=class{constructor(e,t){this._iframe=e;this._callbacks=t}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;try{let t=this._iframe.contentWindow;if(!t)return;let i=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(we({hasRuntime:i,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!i)return;let d=this._resolvePlaybackDurationAdapter(t);if(d&&d.getDuration()>0){this.stop();let s=at(this._iframe.contentDocument);this._callbacks.onReady({duration:d.getDuration(),adapter:d,compositionSize:s});return}}catch{}e>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return Reflect.get(e,"__hf")!==void 0||P(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=k,(e.head||e.documentElement).appendChild(t),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let t=Reflect.get(e,"__timelines");if(!P(t))return null;let i=Object.keys(t);if(i.length===0)return null;let n=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=n&&n in t?n:i[i.length-1],d=t[o];return Ce(d)?d:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(Ae(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var Re=`
1
+ "use strict";var HyperframesPlayer=(()=>{var ee=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var it=Object.prototype.hasOwnProperty;var rt=(r,e)=>{for(var t in e)ee(r,t,{get:e[t],enumerable:!0})},nt=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tt(e))!it.call(r,n)&&n!==t&&ee(r,n,{get:()=>e[n],enumerable:!(i=et(e,n))||i.enumerable});return r};var ot=r=>nt(ee({},"__esModule",{value:!0}),r);var Ht={};rt(Ht,{HyperframesPlayer:()=>K,SPEED_PRESETS:()=>re,formatSpeed:()=>O,formatTime:()=>q});function we(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function P(r){return typeof r=="object"&&r!==null}function Ae(r){return P(r)&&typeof r.getDuration=="function"}function Ce(r){return P(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}var k="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.42/dist/hyperframe.runtime.iife.js";function N(r){if(r===null)return null;let e=Number.parseInt(r,10);return Number.isFinite(e)&&e>0?e:null}function at(r){let e=r?.querySelector("[data-composition-id][data-width][data-height]")??r?.querySelector("[data-width][data-height]");if(!e)return null;let t=N(e.getAttribute("data-width")),i=N(e.getAttribute("data-height"));return t!==null&&i!==null?{width:t,height:i}:null}var W=class{constructor(e,t){this._iframe=e;this._callbacks=t}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;try{let t=this._iframe.contentWindow;if(!t)return;let i=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(we({hasRuntime:i,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!i)return;let d=this._resolvePlaybackDurationAdapter(t);if(d&&d.getDuration()>0){this.stop();let s=at(this._iframe.contentDocument);this._callbacks.onReady({duration:d.getDuration(),adapter:d,compositionSize:s});return}}catch{}e>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return Reflect.get(e,"__hf")!==void 0||P(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=k,(e.head||e.documentElement).appendChild(t),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let t=Reflect.get(e,"__timelines");if(!P(t))return null;let i=Object.keys(t);if(i.length===0)return null;let n=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=n&&n in t?n:i[i.length-1],d=t[o];return Ce(d)?d:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(Ae(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var Re=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;