hyperframes 0.8.23 → 0.8.24

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.
package/dist/cli.js CHANGED
@@ -50,7 +50,7 @@ var VERSION;
50
50
  var init_version = __esm({
51
51
  "src/version.ts"() {
52
52
  "use strict";
53
- VERSION = true ? "0.8.23" : "0.0.0-dev";
53
+ VERSION = true ? "0.8.24" : "0.0.0-dev";
54
54
  }
55
55
  });
56
56
 
@@ -73411,7 +73411,22 @@ async function downloadWithRetry(url, localPath, timeoutMs, signal, onTransientR
73411
73411
  return await runDownloadAttempt(url, localPath, timeoutMs, attempt + 1, options, signal);
73412
73412
  } catch (error) {
73413
73413
  const classified = classifyDownloadFailure(error);
73414
- if (!classified.locallyRetryable || attempt >= maxTransientRetries) throw classified;
73414
+ if (!classified.locallyRetryable || attempt >= maxTransientRetries) {
73415
+ const identity2 = safeDownloadUrlIdentity(url);
73416
+ throw new UrlDownloadError(
73417
+ classified.kind,
73418
+ classified.retryable,
73419
+ classified.message,
73420
+ classified.status,
73421
+ {
73422
+ ...classified.telemetry,
73423
+ urlFingerprint: identity2.urlFingerprint,
73424
+ initialHost: identity2.host,
73425
+ attempt: attempt + 1
73426
+ },
73427
+ classified.locallyRetryable
73428
+ );
73429
+ }
73415
73430
  if (classified.retryable) onTransientRetry?.(classified);
73416
73431
  const identity = safeDownloadUrlIdentity(url);
73417
73432
  emitDownloadTelemetry(options, {
@@ -87249,6 +87264,37 @@ function extractionFrameCountForDuration(durationSeconds, fps, isVFR) {
87249
87264
  function sdrToHdrTransformKey(transfer) {
87250
87265
  return `sdr2hdr-${transfer}`;
87251
87266
  }
87267
+ function safeVideoExtractionSourceIdentity(source) {
87268
+ if (!isHttpUrl(source)) return null;
87269
+ const identity = safeDownloadUrlIdentity(source);
87270
+ return {
87271
+ sourceFingerprint: `sha256:${identity.urlFingerprint}`,
87272
+ host: identity.host ?? "other"
87273
+ };
87274
+ }
87275
+ function downloadStatusClass(error) {
87276
+ const status = error.status ?? error.telemetry?.status;
87277
+ if (typeof status === "number" && status >= 400 && status < 500) return "http_4xx";
87278
+ if (typeof status === "number" && status >= 500 && status < 600) return "http_5xx";
87279
+ if (error.kind === "timeout") return "timeout";
87280
+ if (error.kind === "network") return "network";
87281
+ return "other";
87282
+ }
87283
+ function downloadFailureGroup(source, error) {
87284
+ const sourceIdentity = safeVideoExtractionSourceIdentity(source);
87285
+ const failureHost = error.telemetry?.finalHost ?? error.telemetry?.initialHost;
87286
+ const attempt = error.telemetry?.attempt;
87287
+ return {
87288
+ ...sourceIdentity ? { sourceFingerprint: sourceIdentity.sourceFingerprint } : {},
87289
+ ...failureHost ?? sourceIdentity?.host ? { host: failureHost ?? sourceIdentity?.host } : {},
87290
+ statusClass: downloadStatusClass(error),
87291
+ retry: {
87292
+ phase: "download",
87293
+ used: typeof attempt === "number" && attempt >= 2 ? 1 : 0,
87294
+ budget: 1
87295
+ }
87296
+ };
87297
+ }
87252
87298
  function isVideoSourceExtractionError(error) {
87253
87299
  return typeof error === "object" && error !== null && "hyperframesVideoSourceExtractionError" in error && error.hyperframesVideoSourceExtractionError === true;
87254
87300
  }
@@ -88040,6 +88086,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
88040
88086
  videoId: video.id,
88041
88087
  kind: classified.kind,
88042
88088
  retryable: classified.retryable,
88089
+ ...err instanceof UrlDownloadError ? { group: downloadFailureGroup(video.src, err) } : {},
88043
88090
  error: classified.diagnostic
88044
88091
  });
88045
88092
  }
@@ -93137,6 +93184,7 @@ __export(src_exports, {
93137
93184
  runFfmpeg: () => runFfmpeg,
93138
93185
  runVideoExtractionWithRetry: () => runVideoExtractionWithRetry,
93139
93186
  safeDownloadUrlIdentity: () => safeDownloadUrlIdentity,
93187
+ safeVideoExtractionSourceIdentity: () => safeVideoExtractionSourceIdentity,
93140
93188
  sampleRgb48le: () => sampleRgb48le,
93141
93189
  scaleProtocolTimeoutForComposition: () => scaleProtocolTimeoutForComposition,
93142
93190
  selectVerifySampleIndicesForTask: () => selectVerifySampleIndicesForTask,
@@ -125740,12 +125788,88 @@ var init_planValidation = __esm({
125740
125788
  }
125741
125789
  });
125742
125790
 
125791
+ // ../producer/src/services/render/extractionFailureMetadata.ts
125792
+ function stringOrEmpty(value) {
125793
+ return value === void 0 ? "" : value;
125794
+ }
125795
+ function retrySortTuple(retry) {
125796
+ return retry === void 0 ? ["", -1, -1] : [retry.phase, retry.used, retry.budget];
125797
+ }
125798
+ function extractionFailureGroupSortTuple(group) {
125799
+ const retry = retrySortTuple(group.retry);
125800
+ return [
125801
+ group.kind,
125802
+ stringOrEmpty(group.sourceFingerprint),
125803
+ stringOrEmpty(group.host),
125804
+ stringOrEmpty(group.statusClass),
125805
+ retry[0],
125806
+ retry[1],
125807
+ retry[2]
125808
+ ];
125809
+ }
125810
+ function compareExtractionFailureGroups(left, right) {
125811
+ const leftTuple = extractionFailureGroupSortTuple(left);
125812
+ const rightTuple = extractionFailureGroupSortTuple(right);
125813
+ for (let index = 0; index < leftTuple.length; index += 1) {
125814
+ const leftValue = leftTuple[index];
125815
+ const rightValue = rightTuple[index];
125816
+ if (leftValue < rightValue) return -1;
125817
+ if (leftValue > rightValue) return 1;
125818
+ }
125819
+ return 0;
125820
+ }
125821
+ function extractionFailureGroupIdentityKey(group) {
125822
+ return JSON.stringify(extractionFailureGroupSortTuple(group));
125823
+ }
125824
+ var init_extractionFailureMetadata = __esm({
125825
+ "../producer/src/services/render/extractionFailureMetadata.ts"() {
125826
+ "use strict";
125827
+ }
125828
+ });
125829
+
125743
125830
  // ../producer/src/services/render/stages/extractVideosStage.ts
125744
125831
  import { existsSync as existsSync51 } from "fs";
125745
125832
  import { join as join50 } from "path";
125746
125833
  function shouldCopyExtractedFrames(platform11) {
125747
125834
  return platform11 === "win32";
125748
125835
  }
125836
+ function buildExtractionFailureMetadata(inputs) {
125837
+ const kindCounts = /* @__PURE__ */ new Map();
125838
+ const grouped = /* @__PURE__ */ new Map();
125839
+ for (const input2 of inputs) {
125840
+ kindCounts.set(input2.kind, (kindCounts.get(input2.kind) ?? 0) + input2.affectedElementCount);
125841
+ const key2 = extractionFailureGroupIdentityKey(input2);
125842
+ const existing = grouped.get(key2);
125843
+ if (existing) {
125844
+ existing.affectedElementCount += input2.affectedElementCount;
125845
+ } else {
125846
+ grouped.set(key2, { ...input2 });
125847
+ }
125848
+ }
125849
+ const allGroups = [...grouped.values()].sort(compareExtractionFailureGroups);
125850
+ return {
125851
+ schemaVersion: 1,
125852
+ kindCounts: [...kindCounts].map(([kind, affectedElementCount]) => ({
125853
+ kind,
125854
+ affectedElementCount
125855
+ })).sort((a, b2) => a.kind < b2.kind ? -1 : a.kind > b2.kind ? 1 : 0),
125856
+ groups: allGroups.slice(0, MAX_EXTRACTION_FAILURE_GROUPS),
125857
+ omittedGroupCount: Math.max(0, allGroups.length - MAX_EXTRACTION_FAILURE_GROUPS)
125858
+ };
125859
+ }
125860
+ function extractionFailureMetadataFromResult(result) {
125861
+ return buildExtractionFailureMetadata(
125862
+ result.errors.map((failure) => ({
125863
+ kind: failure.kind ?? "internal",
125864
+ affectedElementCount: 1,
125865
+ ...failure.group
125866
+ }))
125867
+ );
125868
+ }
125869
+ function safeVideoExtractionSourceLogMetadata(source) {
125870
+ const identity = safeVideoExtractionSourceIdentity(source);
125871
+ return identity ? { sourceType: "remote", ...identity } : { sourceType: "local" };
125872
+ }
125749
125873
  function resolveVideoExtractionPolicy(env = process.env) {
125750
125874
  const rawMode = env.HF_VIDEO_EXTRACTION_FAILURE_MODE?.trim().toLowerCase();
125751
125875
  const failureMode = rawMode === "observe" || rawMode === "off" ? rawMode : "enforce";
@@ -125779,7 +125903,8 @@ function buildVideoExtractionStageError(result) {
125779
125903
  return new VideoExtractionStageError(
125780
125904
  retryable ? "VIDEO_EXTRACTION_FAILED" : "VIDEO_SOURCE_UNRENDERABLE",
125781
125905
  retryable,
125782
- failures
125906
+ failures,
125907
+ extractionFailureMetadataFromResult(result)
125783
125908
  );
125784
125909
  }
125785
125910
  function buildHdrProbeStageError(failures) {
@@ -125794,7 +125919,13 @@ function buildHdrProbeStageError(failures) {
125794
125919
  return new VideoExtractionStageError(
125795
125920
  retryable ? "VIDEO_EXTRACTION_FAILED" : "VIDEO_SOURCE_UNRENDERABLE",
125796
125921
  retryable,
125797
- summary
125922
+ summary,
125923
+ buildExtractionFailureMetadata(
125924
+ failures.map((failure) => ({
125925
+ kind: failure.kind,
125926
+ affectedElementCount: 1
125927
+ }))
125928
+ )
125798
125929
  );
125799
125930
  }
125800
125931
  function isHdrProbeFailure(failure) {
@@ -125921,7 +126052,10 @@ async function runExtractVideosStage(input2) {
125921
126052
  const totalVideos = composition.videos.length;
125922
126053
  for (let i2 = 0; i2 < totalVideos; i2++) {
125923
126054
  const v2 = composition.videos[i2];
125924
- log2?.info(`Extracting frames from video ${i2 + 1}/${totalVideos}: ${v2.src}`);
126055
+ log2?.info(
126056
+ `Extracting frames from video ${i2 + 1}/${totalVideos}`,
126057
+ safeVideoExtractionSourceLogMetadata(v2.src)
126058
+ );
125925
126059
  }
125926
126060
  extractionResult = await extractAllVideoFrames(
125927
126061
  composition.videos,
@@ -125993,7 +126127,7 @@ function appendAutoDetectedVideoAudio(composition, extracted) {
125993
126127
  existingAudioSrcs.add(video.src);
125994
126128
  }
125995
126129
  }
125996
- var VideoExtractionStageError;
126130
+ var MAX_EXTRACTION_FAILURE_GROUPS, VideoExtractionStageError;
125997
126131
  var init_extractVideosStage = __esm({
125998
126132
  "../producer/src/services/render/stages/extractVideosStage.ts"() {
125999
126133
  "use strict";
@@ -126001,19 +126135,35 @@ var init_extractVideosStage = __esm({
126001
126135
  init_renderOrchestrator();
126002
126136
  init_shared();
126003
126137
  init_encoderInterruption();
126138
+ init_extractionFailureMetadata();
126139
+ MAX_EXTRACTION_FAILURE_GROUPS = 8;
126004
126140
  VideoExtractionStageError = class extends Error {
126005
- constructor(code, retryable, failures) {
126141
+ constructor(code, retryable, failures, extractionFailure = buildExtractionFailureMetadata(
126142
+ failures.map((failure) => ({
126143
+ kind: failure.kind,
126144
+ affectedElementCount: failure.count
126145
+ }))
126146
+ )) {
126006
126147
  const total = failures.reduce((sum, failure) => sum + failure.count, 0);
126007
126148
  const breakdown = failures.map((failure) => `${failure.kind}=${failure.count}`).join(",");
126008
126149
  super(`Video extraction failed for ${total} source(s) [${code}; ${breakdown}]`);
126009
126150
  this.code = code;
126010
126151
  this.retryable = retryable;
126011
126152
  this.failures = failures;
126153
+ this.extractionFailure = extractionFailure;
126012
126154
  this.name = "VideoExtractionStageError";
126155
+ this.publicMetadata = { extractionFailure };
126013
126156
  }
126014
126157
  code;
126015
126158
  retryable;
126016
126159
  failures;
126160
+ extractionFailure;
126161
+ /**
126162
+ * Producer servers may expose this explicitly public, JSON-compatible data
126163
+ * without knowing its schema. Boundary adapters remain responsible for
126164
+ * validating and applying policy to it.
126165
+ */
126166
+ publicMetadata;
126017
126167
  };
126018
126168
  }
126019
126169
  });
@@ -132321,10 +132471,12 @@ function extractSafeRenderErrorMetadata(error) {
132321
132471
  if (!errorCode || typeof error !== "object" || error === null) return void 0;
132322
132472
  const owner = "owner" in error ? error.owner : void 0;
132323
132473
  const retryable = "retryable" in error ? error.retryable : void 0;
132474
+ const publicMetadata = "publicMetadata" in error ? error.publicMetadata : void 0;
132324
132475
  return {
132325
132476
  errorCode,
132326
132477
  errorOwner: owner === "user" || owner === "system" ? owner : void 0,
132327
- retryable: typeof retryable === "boolean" ? retryable : void 0
132478
+ retryable: typeof retryable === "boolean" ? retryable : void 0,
132479
+ ...isPlainObject4(publicMetadata) ? { errorMetadata: publicMetadata } : {}
132328
132480
  };
132329
132481
  }
132330
132482
  function parseServerFps(value) {
@@ -132646,6 +132798,7 @@ async function writeRenderStreamFailure(input2) {
132646
132798
  errorCode: safeError?.errorCode,
132647
132799
  errorOwner: safeError?.errorOwner,
132648
132800
  retryable: safeError?.retryable,
132801
+ errorMetadata: safeError?.errorMetadata,
132649
132802
  stage: job.currentStage,
132650
132803
  elapsedMs,
132651
132804
  errorDetails: job.errorDetails ?? null,
@@ -132771,6 +132924,7 @@ function createRenderHandlers(options = {}) {
132771
132924
  errorCode: safeError?.errorCode,
132772
132925
  errorOwner: safeError?.errorOwner,
132773
132926
  retryable: safeError?.retryable,
132927
+ errorMetadata: safeError?.errorMetadata,
132774
132928
  stage: job.currentStage,
132775
132929
  durationMs,
132776
132930
  errorDetails: job.errorDetails ?? null
@@ -62903,7 +62903,22 @@ async function downloadWithRetry(url, localPath, timeoutMs, signal, onTransientR
62903
62903
  return await runDownloadAttempt(url, localPath, timeoutMs, attempt + 1, options, signal);
62904
62904
  } catch (error) {
62905
62905
  const classified = classifyDownloadFailure(error);
62906
- if (!classified.locallyRetryable || attempt >= maxTransientRetries) throw classified;
62906
+ if (!classified.locallyRetryable || attempt >= maxTransientRetries) {
62907
+ const identity2 = safeDownloadUrlIdentity(url);
62908
+ throw new UrlDownloadError(
62909
+ classified.kind,
62910
+ classified.retryable,
62911
+ classified.message,
62912
+ classified.status,
62913
+ {
62914
+ ...classified.telemetry,
62915
+ urlFingerprint: identity2.urlFingerprint,
62916
+ initialHost: identity2.host,
62917
+ attempt: attempt + 1
62918
+ },
62919
+ classified.locallyRetryable
62920
+ );
62921
+ }
62907
62922
  if (classified.retryable) onTransientRetry?.(classified);
62908
62923
  const identity = safeDownloadUrlIdentity(url);
62909
62924
  emitDownloadTelemetry(options, {
@@ -74981,6 +74996,37 @@ function extractionFrameCountForDuration(durationSeconds, fps, isVFR) {
74981
74996
  function sdrToHdrTransformKey(transfer) {
74982
74997
  return `sdr2hdr-${transfer}`;
74983
74998
  }
74999
+ function safeVideoExtractionSourceIdentity(source) {
75000
+ if (!isHttpUrl(source)) return null;
75001
+ const identity = safeDownloadUrlIdentity(source);
75002
+ return {
75003
+ sourceFingerprint: `sha256:${identity.urlFingerprint}`,
75004
+ host: identity.host ?? "other"
75005
+ };
75006
+ }
75007
+ function downloadStatusClass(error) {
75008
+ const status = error.status ?? error.telemetry?.status;
75009
+ if (typeof status === "number" && status >= 400 && status < 500) return "http_4xx";
75010
+ if (typeof status === "number" && status >= 500 && status < 600) return "http_5xx";
75011
+ if (error.kind === "timeout") return "timeout";
75012
+ if (error.kind === "network") return "network";
75013
+ return "other";
75014
+ }
75015
+ function downloadFailureGroup(source, error) {
75016
+ const sourceIdentity = safeVideoExtractionSourceIdentity(source);
75017
+ const failureHost = error.telemetry?.finalHost ?? error.telemetry?.initialHost;
75018
+ const attempt = error.telemetry?.attempt;
75019
+ return {
75020
+ ...sourceIdentity ? { sourceFingerprint: sourceIdentity.sourceFingerprint } : {},
75021
+ ...failureHost ?? sourceIdentity?.host ? { host: failureHost ?? sourceIdentity?.host } : {},
75022
+ statusClass: downloadStatusClass(error),
75023
+ retry: {
75024
+ phase: "download",
75025
+ used: typeof attempt === "number" && attempt >= 2 ? 1 : 0,
75026
+ budget: 1
75027
+ }
75028
+ };
75029
+ }
74984
75030
  function isVideoSourceExtractionError(error) {
74985
75031
  return typeof error === "object" && error !== null && "hyperframesVideoSourceExtractionError" in error && error.hyperframesVideoSourceExtractionError === true;
74986
75032
  }
@@ -75772,6 +75818,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
75772
75818
  videoId: video.id,
75773
75819
  kind: classified.kind,
75774
75820
  retryable: classified.retryable,
75821
+ ...err instanceof UrlDownloadError ? { group: downloadFailureGroup(video.src, err) } : {},
75775
75822
  error: classified.diagnostic
75776
75823
  });
75777
75824
  }
@@ -80869,6 +80916,7 @@ __export(src_exports, {
80869
80916
  runFfmpeg: () => runFfmpeg,
80870
80917
  runVideoExtractionWithRetry: () => runVideoExtractionWithRetry,
80871
80918
  safeDownloadUrlIdentity: () => safeDownloadUrlIdentity,
80919
+ safeVideoExtractionSourceIdentity: () => safeVideoExtractionSourceIdentity,
80872
80920
  sampleRgb48le: () => sampleRgb48le,
80873
80921
  scaleProtocolTimeoutForComposition: () => scaleProtocolTimeoutForComposition,
80874
80922
  selectVerifySampleIndicesForTask: () => selectVerifySampleIndicesForTask,
@@ -90808,9 +90856,83 @@ function validateRenderDuration(input) {
90808
90856
  init_src();
90809
90857
  import { existsSync as existsSync26 } from "fs";
90810
90858
  import { join as join30 } from "path";
90859
+
90860
+ // ../producer/src/services/render/extractionFailureMetadata.ts
90861
+ function stringOrEmpty(value) {
90862
+ return value === void 0 ? "" : value;
90863
+ }
90864
+ function retrySortTuple(retry) {
90865
+ return retry === void 0 ? ["", -1, -1] : [retry.phase, retry.used, retry.budget];
90866
+ }
90867
+ function extractionFailureGroupSortTuple(group) {
90868
+ const retry = retrySortTuple(group.retry);
90869
+ return [
90870
+ group.kind,
90871
+ stringOrEmpty(group.sourceFingerprint),
90872
+ stringOrEmpty(group.host),
90873
+ stringOrEmpty(group.statusClass),
90874
+ retry[0],
90875
+ retry[1],
90876
+ retry[2]
90877
+ ];
90878
+ }
90879
+ function compareExtractionFailureGroups(left, right) {
90880
+ const leftTuple = extractionFailureGroupSortTuple(left);
90881
+ const rightTuple = extractionFailureGroupSortTuple(right);
90882
+ for (let index = 0; index < leftTuple.length; index += 1) {
90883
+ const leftValue = leftTuple[index];
90884
+ const rightValue = rightTuple[index];
90885
+ if (leftValue < rightValue) return -1;
90886
+ if (leftValue > rightValue) return 1;
90887
+ }
90888
+ return 0;
90889
+ }
90890
+ function extractionFailureGroupIdentityKey(group) {
90891
+ return JSON.stringify(extractionFailureGroupSortTuple(group));
90892
+ }
90893
+
90894
+ // ../producer/src/services/render/stages/extractVideosStage.ts
90811
90895
  function shouldCopyExtractedFrames(platform3) {
90812
90896
  return platform3 === "win32";
90813
90897
  }
90898
+ var MAX_EXTRACTION_FAILURE_GROUPS = 8;
90899
+ function buildExtractionFailureMetadata(inputs) {
90900
+ const kindCounts = /* @__PURE__ */ new Map();
90901
+ const grouped = /* @__PURE__ */ new Map();
90902
+ for (const input of inputs) {
90903
+ kindCounts.set(input.kind, (kindCounts.get(input.kind) ?? 0) + input.affectedElementCount);
90904
+ const key2 = extractionFailureGroupIdentityKey(input);
90905
+ const existing = grouped.get(key2);
90906
+ if (existing) {
90907
+ existing.affectedElementCount += input.affectedElementCount;
90908
+ } else {
90909
+ grouped.set(key2, { ...input });
90910
+ }
90911
+ }
90912
+ const allGroups = [...grouped.values()].sort(compareExtractionFailureGroups);
90913
+ return {
90914
+ schemaVersion: 1,
90915
+ kindCounts: [...kindCounts].map(([kind, affectedElementCount]) => ({
90916
+ kind,
90917
+ affectedElementCount
90918
+ })).sort((a, b) => a.kind < b.kind ? -1 : a.kind > b.kind ? 1 : 0),
90919
+ groups: allGroups.slice(0, MAX_EXTRACTION_FAILURE_GROUPS),
90920
+ omittedGroupCount: Math.max(0, allGroups.length - MAX_EXTRACTION_FAILURE_GROUPS)
90921
+ };
90922
+ }
90923
+ function extractionFailureMetadataFromResult(result) {
90924
+ return buildExtractionFailureMetadata(
90925
+ result.errors.map((failure) => ({
90926
+ kind: failure.kind ?? "internal",
90927
+ affectedElementCount: 1,
90928
+ ...failure.group
90929
+ }))
90930
+ );
90931
+ }
90932
+ function safeVideoExtractionSourceLogMetadata(source) {
90933
+ const identity = safeVideoExtractionSourceIdentity(source);
90934
+ return identity ? { sourceType: "remote", ...identity } : { sourceType: "local" };
90935
+ }
90814
90936
  function resolveVideoExtractionPolicy(env = process.env) {
90815
90937
  const rawMode = env.HF_VIDEO_EXTRACTION_FAILURE_MODE?.trim().toLowerCase();
90816
90938
  const failureMode = rawMode === "observe" || rawMode === "off" ? rawMode : "enforce";
@@ -90818,18 +90940,32 @@ function resolveVideoExtractionPolicy(env = process.env) {
90818
90940
  return { failureMode, maxTransientRetries };
90819
90941
  }
90820
90942
  var VideoExtractionStageError = class extends Error {
90821
- constructor(code, retryable, failures) {
90943
+ constructor(code, retryable, failures, extractionFailure = buildExtractionFailureMetadata(
90944
+ failures.map((failure) => ({
90945
+ kind: failure.kind,
90946
+ affectedElementCount: failure.count
90947
+ }))
90948
+ )) {
90822
90949
  const total = failures.reduce((sum, failure) => sum + failure.count, 0);
90823
90950
  const breakdown = failures.map((failure) => `${failure.kind}=${failure.count}`).join(",");
90824
90951
  super(`Video extraction failed for ${total} source(s) [${code}; ${breakdown}]`);
90825
90952
  this.code = code;
90826
90953
  this.retryable = retryable;
90827
90954
  this.failures = failures;
90955
+ this.extractionFailure = extractionFailure;
90828
90956
  this.name = "VideoExtractionStageError";
90957
+ this.publicMetadata = { extractionFailure };
90829
90958
  }
90830
90959
  code;
90831
90960
  retryable;
90832
90961
  failures;
90962
+ extractionFailure;
90963
+ /**
90964
+ * Producer servers may expose this explicitly public, JSON-compatible data
90965
+ * without knowing its schema. Boundary adapters remain responsible for
90966
+ * validating and applying policy to it.
90967
+ */
90968
+ publicMetadata;
90833
90969
  };
90834
90970
  function throwIfEncoderInterrupted(result) {
90835
90971
  const interrupted = result.errors.find((failure) => failure.kind === "external_interruption");
@@ -90853,7 +90989,8 @@ function buildVideoExtractionStageError(result) {
90853
90989
  return new VideoExtractionStageError(
90854
90990
  retryable ? "VIDEO_EXTRACTION_FAILED" : "VIDEO_SOURCE_UNRENDERABLE",
90855
90991
  retryable,
90856
- failures
90992
+ failures,
90993
+ extractionFailureMetadataFromResult(result)
90857
90994
  );
90858
90995
  }
90859
90996
  function buildHdrProbeStageError(failures) {
@@ -90868,7 +91005,13 @@ function buildHdrProbeStageError(failures) {
90868
91005
  return new VideoExtractionStageError(
90869
91006
  retryable ? "VIDEO_EXTRACTION_FAILED" : "VIDEO_SOURCE_UNRENDERABLE",
90870
91007
  retryable,
90871
- summary
91008
+ summary,
91009
+ buildExtractionFailureMetadata(
91010
+ failures.map((failure) => ({
91011
+ kind: failure.kind,
91012
+ affectedElementCount: 1
91013
+ }))
91014
+ )
90872
91015
  );
90873
91016
  }
90874
91017
  function isHdrProbeFailure(failure) {
@@ -90995,7 +91138,10 @@ async function runExtractVideosStage(input) {
90995
91138
  const totalVideos = composition.videos.length;
90996
91139
  for (let i = 0; i < totalVideos; i++) {
90997
91140
  const v = composition.videos[i];
90998
- log?.info(`Extracting frames from video ${i + 1}/${totalVideos}: ${v.src}`);
91141
+ log?.info(
91142
+ `Extracting frames from video ${i + 1}/${totalVideos}`,
91143
+ safeVideoExtractionSourceLogMetadata(v.src)
91144
+ );
90999
91145
  }
91000
91146
  extractionResult = await extractAllVideoFrames(
91001
91147
  composition.videos,
@@ -96941,10 +97087,12 @@ function extractSafeRenderErrorMetadata(error) {
96941
97087
  if (!errorCode || typeof error !== "object" || error === null) return void 0;
96942
97088
  const owner = "owner" in error ? error.owner : void 0;
96943
97089
  const retryable = "retryable" in error ? error.retryable : void 0;
97090
+ const publicMetadata = "publicMetadata" in error ? error.publicMetadata : void 0;
96944
97091
  return {
96945
97092
  errorCode,
96946
97093
  errorOwner: owner === "user" || owner === "system" ? owner : void 0,
96947
- retryable: typeof retryable === "boolean" ? retryable : void 0
97094
+ retryable: typeof retryable === "boolean" ? retryable : void 0,
97095
+ ...isPlainObject3(publicMetadata) ? { errorMetadata: publicMetadata } : {}
96948
97096
  };
96949
97097
  }
96950
97098
  function parseServerFps(value) {
@@ -97266,6 +97414,7 @@ async function writeRenderStreamFailure(input) {
97266
97414
  errorCode: safeError?.errorCode,
97267
97415
  errorOwner: safeError?.errorOwner,
97268
97416
  retryable: safeError?.retryable,
97417
+ errorMetadata: safeError?.errorMetadata,
97269
97418
  stage: job.currentStage,
97270
97419
  elapsedMs,
97271
97420
  errorDetails: job.errorDetails ?? null,
@@ -97391,6 +97540,7 @@ function createRenderHandlers(options = {}) {
97391
97540
  errorCode: safeError?.errorCode,
97392
97541
  errorOwner: safeError?.errorOwner,
97393
97542
  retryable: safeError?.retryable,
97543
+ errorMetadata: safeError?.errorMetadata,
97394
97544
  stage: job.currentStage,
97395
97545
  durationMs,
97396
97546
  errorDetails: job.errorDetails ?? null
@@ -97748,8 +97898,8 @@ async function runFontLocalize(io, localize) {
97748
97898
  }
97749
97899
 
97750
97900
  // src/version.ts
97751
- var VERSION = true ? "0.8.23" : "0.0.0-dev";
97752
- var PRODUCER_VERSION = true ? "0.8.23" : "0.0.0-dev";
97901
+ var VERSION = true ? "0.8.24" : "0.0.0-dev";
97902
+ var PRODUCER_VERSION = true ? "0.8.24" : "0.0.0-dev";
97753
97903
 
97754
97904
  // src/fontLocalizeCli.ts
97755
97905
  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.23/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.24/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;
@@ -1,4 +1,4 @@
1
- var ve=Object.defineProperty;var be=(n,i,e)=>i in n?ve(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var u=(n,i,e)=>be(n,typeof i!="symbol"?i+"":i,e);import{r as le,i as we,a as Ae}from"./index-Tiu74FPg.js";function Ee(n){return n.hasRuntime||n.runtimeInjected?!1:!!(n.hasNestedCompositions||n.hasTimelines&&n.attempts>=5)}function V(n){return typeof n=="object"&&n!==null}function Ce(n){return V(n)&&typeof n.getDuration=="function"}function Te(n){return V(n)&&typeof n.duration=="function"&&typeof n.time=="function"&&typeof n.seek=="function"&&typeof n.play=="function"&&typeof n.pause=="function"}function Se(n){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(n))throw new Error(`Invalid HyperFrames runtime version: ${n}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${n}/dist/hyperframe.runtime.iife.js`}const H=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Se("0.0.0-dev");function $(n){if(n===null)return null;const i=Number.parseInt(n,10);return Number.isFinite(i)&&i>0?i:null}function Re(n){const i=(n==null?void 0:n.querySelector("[data-composition-id][data-width][data-height]"))??(n==null?void 0:n.querySelector("[data-width][data-height]"));if(!i)return null;const e=$(i.getAttribute("data-width")),t=$(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}class xe{constructor(i,e){u(this,"_interval",null);u(this,"_runtimeInjected",!1);this._iframe=i,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{var e;i++;try{const t=this._iframe.contentWindow;if(!t)return;const r=!!(t.__hf||t.__player),s=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(Ee({hasRuntime:r,hasTimelines:s,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:i})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;const d=this._resolvePlaybackDurationAdapter(t);if(d&&d.getDuration()>0){this.stop();const p=Re(this._iframe.contentDocument);this._callbacks.onReady({duration:d.getDuration(),adapter:d,compositionSize:p});return}}catch{}i>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const i=this._iframe.contentWindow;return i?this._resolveDirectTimelineAdapterFromWindow(i):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(i){return this._resolveDirectTimelineAdapterFromWindow(i)}hasRuntimeBridge(i){return Reflect.get(i,"__hf")!==void 0||V(Reflect.get(i,"__player"))}_injectRuntime(){var i,e;this._runtimeInjected=!0;try{const t=this._iframe.contentDocument;if(!t)return;const r=t.createElement("script");r.src=H,(t.head||t.documentElement).appendChild(r),(e=(i=this._callbacks).onRuntimeInjected)==null||e.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(i){var d,p;if(this.hasRuntimeBridge(i))return null;const e=Reflect.get(i,"__timelines");if(!V(e))return null;const t=Object.keys(e);if(t.length===0)return null;const r=(p=(d=this._iframe.contentDocument)==null?void 0:d.querySelector("[data-composition-id]"))==null?void 0:p.getAttribute("data-composition-id"),s=r&&r in e?r:t[t.length-1],o=e[s];return Te(o)?o:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(Ce(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const Me=`
1
+ var ve=Object.defineProperty;var be=(n,i,e)=>i in n?ve(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var u=(n,i,e)=>be(n,typeof i!="symbol"?i+"":i,e);import{r as le,i as we,a as Ae}from"./index-Bq3M0sjr.js";function Ee(n){return n.hasRuntime||n.runtimeInjected?!1:!!(n.hasNestedCompositions||n.hasTimelines&&n.attempts>=5)}function V(n){return typeof n=="object"&&n!==null}function Ce(n){return V(n)&&typeof n.getDuration=="function"}function Te(n){return V(n)&&typeof n.duration=="function"&&typeof n.time=="function"&&typeof n.seek=="function"&&typeof n.play=="function"&&typeof n.pause=="function"}function Se(n){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(n))throw new Error(`Invalid HyperFrames runtime version: ${n}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${n}/dist/hyperframe.runtime.iife.js`}const H=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Se("0.0.0-dev");function $(n){if(n===null)return null;const i=Number.parseInt(n,10);return Number.isFinite(i)&&i>0?i:null}function Re(n){const i=(n==null?void 0:n.querySelector("[data-composition-id][data-width][data-height]"))??(n==null?void 0:n.querySelector("[data-width][data-height]"));if(!i)return null;const e=$(i.getAttribute("data-width")),t=$(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}class xe{constructor(i,e){u(this,"_interval",null);u(this,"_runtimeInjected",!1);this._iframe=i,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{var e;i++;try{const t=this._iframe.contentWindow;if(!t)return;const r=!!(t.__hf||t.__player),s=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(Ee({hasRuntime:r,hasTimelines:s,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:i})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;const d=this._resolvePlaybackDurationAdapter(t);if(d&&d.getDuration()>0){this.stop();const p=Re(this._iframe.contentDocument);this._callbacks.onReady({duration:d.getDuration(),adapter:d,compositionSize:p});return}}catch{}i>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const i=this._iframe.contentWindow;return i?this._resolveDirectTimelineAdapterFromWindow(i):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(i){return this._resolveDirectTimelineAdapterFromWindow(i)}hasRuntimeBridge(i){return Reflect.get(i,"__hf")!==void 0||V(Reflect.get(i,"__player"))}_injectRuntime(){var i,e;this._runtimeInjected=!0;try{const t=this._iframe.contentDocument;if(!t)return;const r=t.createElement("script");r.src=H,(t.head||t.documentElement).appendChild(r),(e=(i=this._callbacks).onRuntimeInjected)==null||e.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(i){var d,p;if(this.hasRuntimeBridge(i))return null;const e=Reflect.get(i,"__timelines");if(!V(e))return null;const t=Object.keys(e);if(t.length===0)return null;const r=(p=(d=this._iframe.contentDocument)==null?void 0:d.querySelector("[data-composition-id]"))==null?void 0:p.getAttribute("data-composition-id"),s=r&&r in e?r:t[t.length-1],o=e[s];return Te(o)?o:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(Ce(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const Me=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -1 +1 @@
1
- import{g as P}from"./index-Tiu74FPg.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
1
+ import{g as P}from"./index-Bq3M0sjr.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};