hyperframes 0.7.98 → 0.7.99

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.7.98" : "0.0.0-dev";
53
+ VERSION = true ? "0.7.99" : "0.0.0-dev";
54
54
  }
55
55
  });
56
56
 
@@ -137341,6 +137341,63 @@ async function readErrorMessage(response, fallback) {
137341
137341
  const text2 = await response.text().catch(() => "");
137342
137342
  return text2.trim() ? `${fallback}: ${text2.trim().slice(0, 180)}` : fallback;
137343
137343
  }
137344
+ function systemErrorMetadata(value) {
137345
+ if (!isRecord8(value)) return [];
137346
+ const metadata = [];
137347
+ if (typeof value["code"] === "string") metadata.push(value["code"]);
137348
+ if (typeof value["syscall"] === "string") metadata.push(`syscall=${value["syscall"]}`);
137349
+ if (typeof value["errno"] === "string" || typeof value["errno"] === "number") {
137350
+ metadata.push(`errno=${value["errno"]}`);
137351
+ }
137352
+ return metadata;
137353
+ }
137354
+ function redactUrlQuery(message) {
137355
+ return message.replace(/(https?:\/\/[^\s?]+)\?[^\s]+/gu, "$1?[redacted]");
137356
+ }
137357
+ function proxySupportHint() {
137358
+ const proxyConfigured = ["HTTPS_PROXY", "HTTP_PROXY", "https_proxy", "http_proxy"].some(
137359
+ (key2) => Boolean(process.env[key2]?.trim())
137360
+ );
137361
+ const proxyEnabled = process.env["NODE_USE_ENV_PROXY"] === "1" || process.execArgv.includes("--use-env-proxy") || process.env["NODE_OPTIONS"]?.split(/\s+/u).includes("--use-env-proxy") === true;
137362
+ if (!proxyConfigured || proxyEnabled) return "";
137363
+ return ". Proxy variables are set but ignored by Node fetch; if this network requires them, retry with NODE_USE_ENV_PROXY=1 (Node 22.21+)";
137364
+ }
137365
+ function describeFetchFailure(error) {
137366
+ const message = error instanceof Error ? error.message : String(error);
137367
+ const cause = error instanceof Error ? error.cause : void 0;
137368
+ const causeMessage = cause instanceof Error ? cause.message : "";
137369
+ const metadata = [...systemErrorMetadata(cause), ...systemErrorMetadata(error)].filter(
137370
+ (value, index, all) => all.indexOf(value) === index
137371
+ );
137372
+ const distinctCauseMessage = causeMessage && causeMessage !== message ? causeMessage : "";
137373
+ const detail = [metadata.join(", "), distinctCauseMessage].filter(Boolean).join(": ");
137374
+ return `${redactUrlQuery(message)}${detail ? ` (${redactUrlQuery(detail)})` : ""}${proxySupportHint()}`;
137375
+ }
137376
+ function isRequestTimeout(error) {
137377
+ return error instanceof DOMException && (error.name === "TimeoutError" || error.name === "AbortError");
137378
+ }
137379
+ function waitBeforePublishRetry() {
137380
+ return new Promise((resolve77) => setTimeout(resolve77, PUBLISH_RETRY_DELAY_MS));
137381
+ }
137382
+ async function fetchForPublish(input2, createInit, failureStage, attempts = 1) {
137383
+ if (attempts < 1) throw new RangeError("Publish fetch attempts must be at least 1");
137384
+ let lastError;
137385
+ let attemptsMade = 0;
137386
+ for (let attempt = 1; attempt <= attempts; attempt += 1) {
137387
+ attemptsMade = attempt;
137388
+ try {
137389
+ return await fetch(input2, createInit());
137390
+ } catch (error) {
137391
+ lastError = error;
137392
+ if (isRequestTimeout(error) || attempt === attempts) break;
137393
+ await waitBeforePublishRetry();
137394
+ }
137395
+ }
137396
+ const attemptDetail = attemptsMade > 1 ? ` after ${attemptsMade} attempts` : "";
137397
+ throw new Error(`${failureStage}${attemptDetail}: ${describeFetchFailure(lastError)}`, {
137398
+ cause: lastError instanceof Error ? lastError : void 0
137399
+ });
137400
+ }
137344
137401
  function uploadTimeoutMs(byteLength) {
137345
137402
  return Math.max(
137346
137403
  PUBLISH_UPLOAD_MIN_TIMEOUT_MS,
@@ -137541,12 +137598,16 @@ async function publishProjectArchiveDirect(apiBaseUrl2, title, archive, isPublic
137541
137598
  ...authHeaders,
137542
137599
  heygen_route: "canary"
137543
137600
  };
137544
- const response = await fetch(`${apiBaseUrl2}/v1/hyperframes/projects/publish`, {
137545
- method: "POST",
137546
- body,
137547
- headers,
137548
- signal: AbortSignal.timeout(uploadTimeoutMs(archive.buffer.byteLength))
137549
- });
137601
+ const response = await fetchForPublish(
137602
+ `${apiBaseUrl2}/v1/hyperframes/projects/publish`,
137603
+ () => ({
137604
+ method: "POST",
137605
+ body,
137606
+ headers,
137607
+ signal: AbortSignal.timeout(uploadTimeoutMs(archive.buffer.byteLength))
137608
+ }),
137609
+ "Failed to publish project"
137610
+ );
137550
137611
  const payload = await readJson(response);
137551
137612
  const publishedProject = parsePublishedProjectResponse(payload);
137552
137613
  if (!response.ok || !publishedProject) {
@@ -137556,34 +137617,44 @@ async function publishProjectArchiveDirect(apiBaseUrl2, title, archive, isPublic
137556
137617
  }
137557
137618
  async function uploadArchiveToPresignedUrl(stagedUpload, archive) {
137558
137619
  const presignedUrlTtlMs = stagedUpload.expiresInSeconds * 1e3 - PUBLISH_METADATA_TIMEOUT_MS;
137559
- const s3Response = await fetch(stagedUpload.uploadUrl, {
137560
- method: "PUT",
137561
- body: new Blob([archiveArrayBuffer(archive)], { type: stagedUpload.contentType }),
137562
- headers: stagedUpload.uploadHeaders,
137563
- signal: AbortSignal.timeout(
137564
- Math.min(uploadTimeoutMs(archive.buffer.byteLength), presignedUrlTtlMs)
137565
- )
137566
- });
137620
+ const s3Response = await fetchForPublish(
137621
+ stagedUpload.uploadUrl,
137622
+ () => ({
137623
+ method: "PUT",
137624
+ body: new Blob([archiveArrayBuffer(archive)], { type: stagedUpload.contentType }),
137625
+ headers: stagedUpload.uploadHeaders,
137626
+ signal: AbortSignal.timeout(
137627
+ Math.min(uploadTimeoutMs(archive.buffer.byteLength), presignedUrlTtlMs)
137628
+ )
137629
+ }),
137630
+ "Failed to upload project archive",
137631
+ PUBLISH_TRANSPORT_ATTEMPTS
137632
+ );
137567
137633
  if (!s3Response.ok) {
137568
137634
  throw new Error(await readErrorMessage(s3Response, "Failed to upload project archive"));
137569
137635
  }
137570
137636
  }
137571
137637
  async function publishProjectArchiveStaged(apiBaseUrl2, title, archive, isPublic, authHeaders, projectId) {
137572
137638
  const fileName = `${title}.zip`;
137573
- const uploadResponse = await fetch(`${apiBaseUrl2}/v1/hyperframes/projects/publish/upload`, {
137574
- method: "POST",
137575
- body: JSON.stringify({
137576
- file_name: fileName,
137577
- content_type: PUBLISH_CONTENT_TYPE,
137578
- content_length: archive.buffer.byteLength
137639
+ const uploadResponse = await fetchForPublish(
137640
+ `${apiBaseUrl2}/v1/hyperframes/projects/publish/upload`,
137641
+ () => ({
137642
+ method: "POST",
137643
+ body: JSON.stringify({
137644
+ file_name: fileName,
137645
+ content_type: PUBLISH_CONTENT_TYPE,
137646
+ content_length: archive.buffer.byteLength
137647
+ }),
137648
+ headers: {
137649
+ ...authHeaders,
137650
+ "content-type": "application/json",
137651
+ heygen_route: "canary"
137652
+ },
137653
+ signal: AbortSignal.timeout(PUBLISH_METADATA_TIMEOUT_MS)
137579
137654
  }),
137580
- headers: {
137581
- ...authHeaders,
137582
- "content-type": "application/json",
137583
- heygen_route: "canary"
137584
- },
137585
- signal: AbortSignal.timeout(PUBLISH_METADATA_TIMEOUT_MS)
137586
- });
137655
+ "Failed to prepare project upload",
137656
+ PUBLISH_TRANSPORT_ATTEMPTS
137657
+ );
137587
137658
  if (uploadResponse.status === 404 || uploadResponse.status === 405) {
137588
137659
  return null;
137589
137660
  }
@@ -137593,22 +137664,26 @@ async function publishProjectArchiveStaged(apiBaseUrl2, title, archive, isPublic
137593
137664
  throw new Error(await readErrorMessage(uploadResponse, "Failed to prepare project upload"));
137594
137665
  }
137595
137666
  await uploadArchiveToPresignedUrl(stagedUpload, archive);
137596
- const completeResponse = await fetch(`${apiBaseUrl2}/v1/hyperframes/projects/publish/complete`, {
137597
- method: "POST",
137598
- body: JSON.stringify({
137599
- upload_key: stagedUpload.uploadKey,
137600
- file_name: fileName,
137601
- title,
137602
- ...isPublic ? { is_public: true } : {},
137603
- ...projectId ? { project_id: projectId } : {}
137667
+ const completeResponse = await fetchForPublish(
137668
+ `${apiBaseUrl2}/v1/hyperframes/projects/publish/complete`,
137669
+ () => ({
137670
+ method: "POST",
137671
+ body: JSON.stringify({
137672
+ upload_key: stagedUpload.uploadKey,
137673
+ file_name: fileName,
137674
+ title,
137675
+ ...isPublic ? { is_public: true } : {},
137676
+ ...projectId ? { project_id: projectId } : {}
137677
+ }),
137678
+ headers: {
137679
+ ...authHeaders,
137680
+ "content-type": "application/json",
137681
+ heygen_route: "canary"
137682
+ },
137683
+ signal: AbortSignal.timeout(uploadTimeoutMs(archive.buffer.byteLength))
137604
137684
  }),
137605
- headers: {
137606
- ...authHeaders,
137607
- "content-type": "application/json",
137608
- heygen_route: "canary"
137609
- },
137610
- signal: AbortSignal.timeout(uploadTimeoutMs(archive.buffer.byteLength))
137611
- });
137685
+ "Failed to finalize project publish"
137686
+ );
137612
137687
  const completePayload = await readJson(completeResponse);
137613
137688
  const publishedProject = parsePublishedProjectResponse(completePayload);
137614
137689
  if (!completeResponse.ok || !publishedProject) {
@@ -137646,7 +137721,7 @@ async function publishProjectArchive(projectDir, opts = {}) {
137646
137721
  }
137647
137722
  return result;
137648
137723
  }
137649
- var IGNORED_DIRS, IGNORED_FILES, HYPERFRAMES_IGNORE_FILE, DEFAULT_PROJECT_IGNORE, PUBLISH_CONTENT_TYPE, PUBLISH_METADATA_TIMEOUT_MS, PUBLISH_UPLOAD_MIN_TIMEOUT_MS, PUBLISH_UPLOAD_BYTES_PER_SECOND, EXT_ASSETS_PREFIX;
137724
+ var IGNORED_DIRS, IGNORED_FILES, HYPERFRAMES_IGNORE_FILE, DEFAULT_PROJECT_IGNORE, PUBLISH_CONTENT_TYPE, PUBLISH_METADATA_TIMEOUT_MS, PUBLISH_UPLOAD_MIN_TIMEOUT_MS, PUBLISH_TRANSPORT_ATTEMPTS, PUBLISH_RETRY_DELAY_MS, PUBLISH_UPLOAD_BYTES_PER_SECOND, EXT_ASSETS_PREFIX;
137650
137725
  var init_publishProject = __esm({
137651
137726
  "src/utils/publishProject.ts"() {
137652
137727
  "use strict";
@@ -137662,6 +137737,8 @@ var init_publishProject = __esm({
137662
137737
  PUBLISH_CONTENT_TYPE = "application/zip";
137663
137738
  PUBLISH_METADATA_TIMEOUT_MS = 3e4;
137664
137739
  PUBLISH_UPLOAD_MIN_TIMEOUT_MS = 12e4;
137740
+ PUBLISH_TRANSPORT_ATTEMPTS = 2;
137741
+ PUBLISH_RETRY_DELAY_MS = 200;
137665
137742
  PUBLISH_UPLOAD_BYTES_PER_SECOND = 5e5;
137666
137743
  EXT_ASSETS_PREFIX = "_ext";
137667
137744
  }
@@ -1,4 +1,4 @@
1
- "use strict";var HyperframesPlayer=(()=>{var J=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Xe=(i,e)=>{for(var t in e)J(i,t,{get:e[t],enumerable:!0})},Ze=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qe(e))!Ye.call(i,n)&&n!==t&&J(i,n,{get:()=>e[n],enumerable:!(r=Ge(e,n))||r.enumerable});return i};var Qe=i=>Ze(J({},"__esModule",{value:!0}),i);var Lt={};Xe(Lt,{HyperframesPlayer:()=>Q,SPEED_PRESETS:()=>te,formatSpeed:()=>N,formatTime:()=>$});function ye(i){return i.hasRuntime||i.runtimeInjected?!1:!!(i.hasNestedCompositions||i.hasTimelines&&i.attempts>=5)}function I(i){return typeof i=="object"&&i!==null}function Ee(i){return I(i)&&typeof i.getDuration=="function"}function Se(i){return I(i)&&typeof i.duration=="function"&&typeof i.time=="function"&&typeof i.seek=="function"&&typeof i.play=="function"&&typeof i.pause=="function"}var Je="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.7.98/dist/hyperframe.runtime.iife.js";function D(i){if(i===null)return null;let e=Number.parseInt(i,10);return Number.isFinite(e)&&e>0?e:null}function Ke(i){let e=i?.querySelector("[data-composition-id][data-width][data-height]")??i?.querySelector("[data-width][data-height]");if(!e)return null;let t=D(e.getAttribute("data-width")),r=D(e.getAttribute("data-height"));return t!==null&&r!==null?{width:t,height:r}:null}var j=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 r=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(ye({hasRuntime:r,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;let s=this._resolvePlaybackDurationAdapter(t);if(s&&s.getDuration()>0){this.stop();let l=Ke(this._iframe.contentDocument);this._callbacks.onReady({duration:s.getDuration(),adapter:s,compositionSize:l});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||I(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=Je,(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(!I(t))return null;let r=Object.keys(t);if(r.length===0)return null;let n=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=n&&n in t?n:r[r.length-1],s=t[o];return Se(s)?s:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(Ee(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let r=this._resolveDirectTimelineAdapterFromWindow(e);return r?{kind:"direct-timeline",timeline:r,getDuration:()=>r.duration()}:null}};var Te=`
1
+ "use strict";var HyperframesPlayer=(()=>{var J=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Xe=(i,e)=>{for(var t in e)J(i,t,{get:e[t],enumerable:!0})},Ze=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qe(e))!Ye.call(i,n)&&n!==t&&J(i,n,{get:()=>e[n],enumerable:!(r=Ge(e,n))||r.enumerable});return i};var Qe=i=>Ze(J({},"__esModule",{value:!0}),i);var Lt={};Xe(Lt,{HyperframesPlayer:()=>Q,SPEED_PRESETS:()=>te,formatSpeed:()=>N,formatTime:()=>$});function ye(i){return i.hasRuntime||i.runtimeInjected?!1:!!(i.hasNestedCompositions||i.hasTimelines&&i.attempts>=5)}function I(i){return typeof i=="object"&&i!==null}function Ee(i){return I(i)&&typeof i.getDuration=="function"}function Se(i){return I(i)&&typeof i.duration=="function"&&typeof i.time=="function"&&typeof i.seek=="function"&&typeof i.play=="function"&&typeof i.pause=="function"}var Je="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.7.99/dist/hyperframe.runtime.iife.js";function D(i){if(i===null)return null;let e=Number.parseInt(i,10);return Number.isFinite(e)&&e>0?e:null}function Ke(i){let e=i?.querySelector("[data-composition-id][data-width][data-height]")??i?.querySelector("[data-width][data-height]");if(!e)return null;let t=D(e.getAttribute("data-width")),r=D(e.getAttribute("data-height"));return t!==null&&r!==null?{width:t,height:r}:null}var j=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 r=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(ye({hasRuntime:r,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;let s=this._resolvePlaybackDurationAdapter(t);if(s&&s.getDuration()>0){this.stop();let l=Ke(this._iframe.contentDocument);this._callbacks.onReady({duration:s.getDuration(),adapter:s,compositionSize:l});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||I(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=Je,(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(!I(t))return null;let r=Object.keys(t);if(r.length===0)return null;let n=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=n&&n in t?n:r[r.length-1],s=t[o];return Se(s)?s:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(Ee(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let r=this._resolveDirectTimelineAdapterFromWindow(e);return r?{kind:"direct-timeline",timeline:r,getDuration:()=>r.duration()}:null}};var Te=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -1,4 +1,4 @@
1
- var ce=Object.defineProperty;var pe=(r,t,e)=>t in r?ce(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>pe(r,typeof t!="symbol"?t+"":t,e);import{r as ne,i as me,a as fe}from"./index-jdiZjBHE.js";function _e(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function ge(r){return F(r)&&typeof r.getDuration=="function"}function ye(r){return F(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function ve(r){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(r))throw new Error(`Invalid HyperFrames runtime version: ${r}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${r}/dist/hyperframe.runtime.iife.js`}const be=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:ve("0.0.0-dev");function H(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function we(r){const t=(r==null?void 0:r.querySelector("[data-composition-id][data-width][data-height]"))??(r==null?void 0:r.querySelector("[data-width][data-height]"));if(!t)return null;const e=H(t.getAttribute("data-width")),i=H(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}class Ae{constructor(t,e){c(this,"_interval",null);c(this,"_runtimeInjected",!1);this._iframe=t,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let t=0;this._interval=setInterval(()=>{var e;t++;try{const i=this._iframe.contentWindow;if(!i)return;const s=!!(i.__hf||i.__player),o=!!(i.__timelines&&Object.keys(i.__timelines).length>0),d=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(_e({hasRuntime:s,hasTimelines:o,hasNestedCompositions:d,runtimeInjected:this._runtimeInjected,attempts:t})){this._injectRuntime();return}if(this._runtimeInjected&&!s)return;const a=this._resolvePlaybackDurationAdapter(i);if(a&&a.getDuration()>0){this.stop();const h=we(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:h});return}}catch{}t>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const t=this._iframe.contentWindow;return t?this._resolveDirectTimelineAdapterFromWindow(t):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(t){return this._resolveDirectTimelineAdapterFromWindow(t)}hasRuntimeBridge(t){return Reflect.get(t,"__hf")!==void 0||F(Reflect.get(t,"__player"))}_injectRuntime(){var t,e;this._runtimeInjected=!0;try{const i=this._iframe.contentDocument;if(!i)return;const s=i.createElement("script");s.src=be,(i.head||i.documentElement).appendChild(s),(e=(t=this._callbacks).onRuntimeInjected)==null||e.call(t)}catch{}}_resolveDirectTimelineAdapterFromWindow(t){var a,h;if(this.hasRuntimeBridge(t))return null;const e=Reflect.get(t,"__timelines");if(!F(e))return null;const i=Object.keys(e);if(i.length===0)return null;const s=(h=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:h.getAttribute("data-composition-id"),o=s&&s in e?s:i[i.length-1],d=e[o];return ye(d)?d:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ge(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const Ee=`
1
+ var ce=Object.defineProperty;var pe=(r,t,e)=>t in r?ce(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>pe(r,typeof t!="symbol"?t+"":t,e);import{r as ne,i as me,a as fe}from"./index-DMSqmZM6.js";function _e(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function ge(r){return F(r)&&typeof r.getDuration=="function"}function ye(r){return F(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function ve(r){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(r))throw new Error(`Invalid HyperFrames runtime version: ${r}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${r}/dist/hyperframe.runtime.iife.js`}const be=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:ve("0.0.0-dev");function H(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function we(r){const t=(r==null?void 0:r.querySelector("[data-composition-id][data-width][data-height]"))??(r==null?void 0:r.querySelector("[data-width][data-height]"));if(!t)return null;const e=H(t.getAttribute("data-width")),i=H(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}class Ae{constructor(t,e){c(this,"_interval",null);c(this,"_runtimeInjected",!1);this._iframe=t,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let t=0;this._interval=setInterval(()=>{var e;t++;try{const i=this._iframe.contentWindow;if(!i)return;const s=!!(i.__hf||i.__player),o=!!(i.__timelines&&Object.keys(i.__timelines).length>0),d=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(_e({hasRuntime:s,hasTimelines:o,hasNestedCompositions:d,runtimeInjected:this._runtimeInjected,attempts:t})){this._injectRuntime();return}if(this._runtimeInjected&&!s)return;const a=this._resolvePlaybackDurationAdapter(i);if(a&&a.getDuration()>0){this.stop();const h=we(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:h});return}}catch{}t>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const t=this._iframe.contentWindow;return t?this._resolveDirectTimelineAdapterFromWindow(t):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(t){return this._resolveDirectTimelineAdapterFromWindow(t)}hasRuntimeBridge(t){return Reflect.get(t,"__hf")!==void 0||F(Reflect.get(t,"__player"))}_injectRuntime(){var t,e;this._runtimeInjected=!0;try{const i=this._iframe.contentDocument;if(!i)return;const s=i.createElement("script");s.src=be,(i.head||i.documentElement).appendChild(s),(e=(t=this._callbacks).onRuntimeInjected)==null||e.call(t)}catch{}}_resolveDirectTimelineAdapterFromWindow(t){var a,h;if(this.hasRuntimeBridge(t))return null;const e=Reflect.get(t,"__timelines");if(!F(e))return null;const i=Object.keys(e);if(i.length===0)return null;const s=(h=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:h.getAttribute("data-composition-id"),o=s&&s in e?s:i[i.length-1],d=e[o];return ye(d)?d:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ge(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const Ee=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -1 +1 @@
1
- import{g as P}from"./index-jdiZjBHE.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-DMSqmZM6.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};