@shotstack/shotstack-studio 2.21.1 → 2.22.1

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.
@@ -580,7 +580,7 @@ class xx extends hx {
580
580
  this.uniformGroup.uniforms.uRevealFromRight = e ? 1 : 0;
581
581
  }
582
582
  }
583
- const mt = {
583
+ const pt = {
584
584
  // Playback
585
585
  PlaybackPlay: "playback:play",
586
586
  PlaybackPause: "playback:pause",
@@ -856,6 +856,11 @@ class nr extends Nx {
856
856
  clipId = null;
857
857
  /** True when the player's asset needs external resolution (e.g. alias caption awaiting transcription). */
858
858
  needsResolution = !1;
859
+ /**
860
+ * Why the asset couldn't be shown, or null. A failing player draws a placeholder and still
861
+ * resolves load() so the rest of the edit keeps loading; this is how the failure is reported.
862
+ */
863
+ loadError = null;
859
864
  edit;
860
865
  clipConfiguration;
861
866
  resolvedTiming;
@@ -905,8 +910,11 @@ class nr extends Nx {
905
910
  const y = [...d.in.brightnessKeyframes, ...d.out.brightnessKeyframes];
906
911
  y.length && (this.wipeBrightnessBuilder = new ha(y, e), this.wipeInFromRight = d.in.wipeFromRight, this.wipeOutFromRight = d.out.wipeFromRight, this.wipeOutStart = d.out.brightnessKeyframes[0]?.start ?? Number.POSITIVE_INFINITY);
907
912
  }
913
+ recordLoadError(e) {
914
+ this.loadError = e instanceof Error ? e.message : String(e);
915
+ }
908
916
  async load() {
909
- this.lumaWrapper?.destroyed && (this.lumaWrapper = new st.Container(), this.getContainer().addChild(this.lumaWrapper)), this.contentContainer?.destroyed && (this.contentContainer = new st.Container(), this.lumaWrapper.addChild(this.contentContainer)), this.getContainer().sortableChildren = !0, this.getContainer().cursor = "pointer", this.getContainer().eventMode = "static", this.getContainer().on?.("pointerdown", this.onPointerDown.bind(this));
917
+ this.loadError = null, this.lumaWrapper?.destroyed && (this.lumaWrapper = new st.Container(), this.getContainer().addChild(this.lumaWrapper)), this.contentContainer?.destroyed && (this.contentContainer = new st.Container(), this.lumaWrapper.addChild(this.contentContainer)), this.getContainer().sortableChildren = !0, this.getContainer().cursor = "pointer", this.getContainer().eventMode = "static", this.getContainer().on?.("pointerdown", this.onPointerDown.bind(this));
910
918
  }
911
919
  update(e, r) {
912
920
  this.applyPlayheadState();
@@ -8260,7 +8268,7 @@ var p9 = Ge({ "node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-e
8260
8268
  for (var Qe = 0; Qe < 3 * A; Qe++)
8261
8269
  se[Qe] = new a(0, 0), he[Qe] = new a(0, 0);
8262
8270
  for (; !vt; ) {
8263
- var we = 0, Mr, Re = [1 << 28, 1 << 28, 1 << 28], Xt = [0], Yt = [1, 1, 1], or = [0, 1, 0, 1, 0, 1], dr = [0], Ke, ke, Ie, Un, $i = null, Li = null, fn, Gr = null, pr, zr = 0, ur = null, Zi = 0, jn = 0, T = null, pt = 0, qt = 0, de = 0, ne, Le;
8271
+ var we = 0, Mr, Re = [1 << 28, 1 << 28, 1 << 28], Xt = [0], Yt = [1, 1, 1], or = [0, 1, 0, 1, 0, 1], dr = [0], Ke, ke, Ie, Un, $i = null, Li = null, fn, Gr = null, pr, zr = 0, ur = null, Zi = 0, jn = 0, T = null, mt = 0, qt = 0, de = 0, ne, Le;
8264
8272
  for (et = 0; et < 3; ++et)
8265
8273
  xt[et].codes = null, xt[et].htrees = null;
8266
8274
  yt.readMoreInput();
@@ -8295,7 +8303,7 @@ var p9 = Ge({ "node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-e
8295
8303
  if (we -= Hn, we <= 0) break;
8296
8304
  if (cr < 0) {
8297
8305
  var Ui;
8298
- if (yt.readMoreInput(), Re[2] === 0 && (jt(Yt[2], se, 2, Xt, or, dr, yt), Re[2] = ht(he, 2 * A, yt), jn = Xt[2] << b, T = jn), --Re[2], Ui = (lr > 4 ? 3 : lr - 2) & 255, pt = Gr[T + Ui], cr = j(xt[2].codes, xt[2].htrees[pt], yt), cr >= ke) {
8306
+ if (yt.readMoreInput(), Re[2] === 0 && (jt(Yt[2], se, 2, Xt, or, dr, yt), Re[2] = ht(he, 2 * A, yt), jn = Xt[2] << b, T = jn), --Re[2], Ui = (lr > 4 ? 3 : lr - 2) & 255, mt = Gr[T + Ui], cr = j(xt[2].codes, xt[2].htrees[mt], yt), cr >= ke) {
8299
8307
  var ji, qo, Wr;
8300
8308
  cr -= ke, qo = cr & Ie, cr >>= Ke, ji = (cr >> 1) + 1, Wr = (2 + (cr & 1) << ji) - 4, cr = ke + (Wr + yt.readBits(ji) << Ke) + qo;
8301
8309
  }
@@ -19757,7 +19765,7 @@ function _V() {
19757
19765
  pr && Zi === pr._level ? (pr._end = zr, pr._endsWithIsolInit = jn) : Gr.push(pr = { _start: zr, _end: zr, _level: Zi, _startsWithPDI: T, _endsWithIsolInit: jn });
19758
19766
  }
19759
19767
  }
19760
- for (var pt = [], qt = 0; qt < Gr.length; qt++) {
19768
+ for (var mt = [], qt = 0; qt < Gr.length; qt++) {
19761
19769
  var de = Gr[qt];
19762
19770
  if (!de._startsWithPDI || de._startsWithPDI && !se.has(de._start)) {
19763
19771
  for (var ne = [pr = de], Le = void 0; pr && pr._endsWithIsolInit && (Le = se.get(pr._end)) != null; )
@@ -19782,11 +19790,11 @@ function _V() {
19782
19790
  break;
19783
19791
  }
19784
19792
  }
19785
- pt.push({ _seqIndices: si, _sosType: Math.max(xa, Wn) % 2 ? B : L, _eosType: Math.max(cr, lr) % 2 ? B : L });
19793
+ mt.push({ _seqIndices: si, _sosType: Math.max(xa, Wn) % 2 ? B : L, _eosType: Math.max(cr, lr) % 2 ? B : L });
19786
19794
  }
19787
19795
  }
19788
- for (var Ui = 0; Ui < pt.length; Ui++) {
19789
- var gi = pt[Ui], Dt = gi._seqIndices, ji = gi._sosType, qo = gi._eosType, Wr = xt[Dt[0]] & 1 ? B : L;
19796
+ for (var Ui = 0; Ui < mt.length; Ui++) {
19797
+ var gi = mt[Ui], Dt = gi._seqIndices, ji = gi._sosType, qo = gi._eosType, Wr = xt[Dt[0]] & 1 ? B : L;
19790
19798
  if (Ft.get(W))
19791
19799
  for (var Yn = 0; Yn < Dt.length; Yn++) {
19792
19800
  var ds = Dt[Yn];
@@ -38451,7 +38459,7 @@ class Cl extends nr {
38451
38459
  emitCaptureFailed(e, r) {
38452
38460
  const n = e instanceof Error ? e.message : String(e);
38453
38461
  try {
38454
- this.edit.getInternalEvents().emit(mt.ClipCaptureFailed, {
38462
+ this.edit.getInternalEvents().emit(pt.ClipCaptureFailed, {
38455
38463
  clipId: this.clipId,
38456
38464
  assetType: "html5",
38457
38465
  error: n,
@@ -38463,7 +38471,7 @@ class Cl extends nr {
38463
38471
  }
38464
38472
  emitCaptureStarted() {
38465
38473
  try {
38466
- this.edit.getInternalEvents().emit(mt.ClipCaptureStarted, {
38474
+ this.edit.getInternalEvents().emit(pt.ClipCaptureStarted, {
38467
38475
  clipId: this.clipId,
38468
38476
  assetType: "html5"
38469
38477
  });
@@ -38473,7 +38481,7 @@ class Cl extends nr {
38473
38481
  }
38474
38482
  emitCaptureCompleted(e) {
38475
38483
  try {
38476
- this.edit.getInternalEvents().emit(mt.ClipCaptureCompleted, {
38484
+ this.edit.getInternalEvents().emit(pt.ClipCaptureCompleted, {
38477
38485
  clipId: this.clipId,
38478
38486
  assetType: "html5",
38479
38487
  frameCount: e
@@ -38749,8 +38757,8 @@ class e$ extends nr {
38749
38757
  await super.load();
38750
38758
  try {
38751
38759
  await this.loadTexture(), this.configureKeyframes();
38752
- } catch {
38753
- this.createFallbackGraphic();
38760
+ } catch (e) {
38761
+ this.recordLoadError(e), this.createFallbackGraphic();
38754
38762
  }
38755
38763
  }
38756
38764
  createFallbackGraphic() {
@@ -38774,11 +38782,11 @@ class e$ extends nr {
38774
38782
  }
38775
38783
  /** Reload the image asset when asset.src changes (e.g., merge field update) */
38776
38784
  async reloadAsset() {
38777
- this.disposeTexture(), this.clearPlaceholder();
38785
+ this.disposeTexture(), this.clearPlaceholder(), this.loadError = null;
38778
38786
  try {
38779
38787
  await this.loadTexture();
38780
- } catch {
38781
- this.createFallbackGraphic();
38788
+ } catch (e) {
38789
+ this.recordLoadError(e), this.createFallbackGraphic();
38782
38790
  }
38783
38791
  }
38784
38792
  async loadTexture() {
@@ -39103,8 +39111,8 @@ function S6(t, e, r) {
39103
39111
  }, s = ({ clipId: u, error: l }) => {
39104
39112
  u === e && r.setFailed(l);
39105
39113
  }, o = t.getInternalEvents();
39106
- return o.on(mt.ClipGenerationStarted, i), o.on(mt.ClipGenerationCompleted, a), o.on(mt.ClipGenerationFailed, s), () => {
39107
- o.off(mt.ClipGenerationStarted, i), o.off(mt.ClipGenerationCompleted, a), o.off(mt.ClipGenerationFailed, s);
39114
+ return o.on(pt.ClipGenerationStarted, i), o.on(pt.ClipGenerationCompleted, a), o.on(pt.ClipGenerationFailed, s), () => {
39115
+ o.off(pt.ClipGenerationStarted, i), o.off(pt.ClipGenerationCompleted, a), o.off(pt.ClipGenerationFailed, s);
39108
39116
  };
39109
39117
  }
39110
39118
  class _1 extends nr {
@@ -41780,6 +41788,7 @@ class qi extends nr {
41780
41788
  renderedWidth = 0;
41781
41789
  renderedHeight = 0;
41782
41790
  pendingRender = null;
41791
+ placeholder = null;
41783
41792
  constructor(e, r) {
41784
41793
  super(e, r, De.Svg);
41785
41794
  }
@@ -41802,27 +41811,36 @@ class qi extends nr {
41802
41811
  r !== e.src && (e = { ...e, src: r });
41803
41812
  }
41804
41813
  try {
41805
- if (!AL.safeParse(e).success) {
41806
- this.createFallbackGraphic();
41814
+ const r = AL.safeParse(e);
41815
+ if (!r.success) {
41816
+ this.recordLoadError(`Invalid svg asset: ${r.error.issues.map((n) => n.message).join("; ")}`), this.createFallbackGraphic();
41807
41817
  return;
41808
41818
  }
41809
41819
  await qi.initializeResvg(), await this.doRender(), this.configureKeyframes();
41810
41820
  } catch (r) {
41811
- console.error("Failed to render SVG asset:", r), this.createFallbackGraphic();
41821
+ console.error("Failed to render SVG asset:", r), this.recordLoadError(r), this.createFallbackGraphic();
41812
41822
  }
41813
41823
  }
41814
41824
  async reloadAsset() {
41815
- await this.rerenderAtCurrentDimensions();
41825
+ this.loadError = null;
41826
+ try {
41827
+ await this.rerenderAtCurrentDimensions();
41828
+ } catch (e) {
41829
+ console.error("Failed to render SVG asset:", e), this.recordLoadError(e), this.createFallbackGraphic();
41830
+ }
41816
41831
  }
41817
41832
  createFallbackGraphic() {
41818
- const e = this.clipConfiguration.width || this.edit.size.width, r = this.clipConfiguration.height || this.edit.size.height, n = Ho(e, r);
41819
- this.renderedWidth = e, this.renderedHeight = r, this.contentContainer.addChild(n), this.configureKeyframes();
41833
+ const e = this.clipConfiguration.width || this.edit.size.width, r = this.clipConfiguration.height || this.edit.size.height;
41834
+ this.clearPlaceholder(), this.placeholder = Ho(e, r), this.renderedWidth = e, this.renderedHeight = r, this.contentContainer.addChild(this.placeholder), this.configureKeyframes();
41835
+ }
41836
+ clearPlaceholder() {
41837
+ this.placeholder && (this.contentContainer.removeChild(this.placeholder), this.placeholder.destroy(), this.placeholder = null);
41820
41838
  }
41821
41839
  update(e, r) {
41822
41840
  super.update(e, r);
41823
41841
  }
41824
41842
  dispose() {
41825
- super.dispose(), this.pendingRender = null, this.sprite && (this.sprite.destroy(), this.sprite = null), this.texture && (this.texture.destroy(!0), this.texture = null);
41843
+ super.dispose(), this.pendingRender = null, this.placeholder = null, this.sprite && (this.sprite.destroy(), this.sprite = null), this.texture && (this.texture.destroy(!0), this.texture = null);
41826
41844
  }
41827
41845
  getSize() {
41828
41846
  return this.clipConfiguration.width && this.clipConfiguration.height ? {
@@ -41849,7 +41867,14 @@ class qi extends nr {
41849
41867
  this.rerenderAtCurrentDimensions();
41850
41868
  }
41851
41869
  async rerenderAtCurrentDimensions() {
41852
- this.pendingRender && await this.pendingRender, this.sprite && (this.contentContainer.removeChild(this.sprite), this.sprite.destroy(), this.sprite = null), this.texture && (this.texture.destroy(!0), this.texture = null), this.pendingRender = this.doRender(), await this.pendingRender, this.pendingRender = null;
41870
+ this.pendingRender && await this.pendingRender.catch(() => {
41871
+ }), this.sprite && (this.contentContainer.removeChild(this.sprite), this.sprite.destroy(), this.sprite = null), this.texture && (this.texture.destroy(!0), this.texture = null), this.pendingRender = this.doRender();
41872
+ try {
41873
+ await this.pendingRender;
41874
+ } finally {
41875
+ this.pendingRender = null;
41876
+ }
41877
+ this.clearPlaceholder();
41853
41878
  }
41854
41879
  async doRender() {
41855
41880
  const e = this.clipConfiguration.asset, r = this.clipConfiguration.width || this.edit.size.width, n = this.clipConfiguration.height || this.edit.size.height, i = await $I(e, {
@@ -42462,7 +42487,7 @@ class eZ extends nr {
42462
42487
  try {
42463
42488
  await this.loadVideo(), this.configureKeyframes();
42464
42489
  } catch (e) {
42465
- console.warn(`[VideoPlayer.load] FAILED clipId=${this.clipId}:`, e), this.createFallbackGraphic();
42490
+ console.warn(`[VideoPlayer.load] FAILED clipId=${this.clipId}:`, e), this.recordLoadError(e), this.createFallbackGraphic();
42466
42491
  } finally {
42467
42492
  this.skipVideoUpdate = !1;
42468
42493
  }
@@ -42493,11 +42518,11 @@ class eZ extends nr {
42493
42518
  }
42494
42519
  /** Reload the video asset when asset.src changes (e.g., merge field update) */
42495
42520
  async reloadAsset() {
42496
- this.skipVideoUpdate = !0, this.isPlaying = !1, this.syncTimer = 0, this.activeSyncTimer = 0;
42521
+ this.skipVideoUpdate = !0, this.isPlaying = !1, this.syncTimer = 0, this.activeSyncTimer = 0, this.loadError = null;
42497
42522
  try {
42498
42523
  this.disposeVideo(), this.clearPlaceholder(), await this.loadVideo();
42499
42524
  } catch (e) {
42500
- console.warn(`[VideoPlayer.reloadAsset] FAILED clipId=${this.clipId}:`, e), this.createFallbackGraphic();
42525
+ console.warn(`[VideoPlayer.reloadAsset] FAILED clipId=${this.clipId}:`, e), this.recordLoadError(e), this.createFallbackGraphic();
42501
42526
  } finally {
42502
42527
  this.skipVideoUpdate = !1;
42503
42528
  }
@@ -42682,12 +42707,12 @@ class Cp {
42682
42707
  if (!e) throw new Error("AddTrackCommand.execute: context is required");
42683
42708
  const r = e.getDocument();
42684
42709
  if (!r) throw new Error("AddTrackCommand.execute: document is required");
42685
- if (r.addTrack(this.trackIdx, this.preparedTrack), e.resolve(), e.updateDuration(), e.emitEvent(mt.TrackAdded, {
42710
+ if (r.addTrack(this.trackIdx, this.preparedTrack), e.resolve(), e.updateDuration(), e.emitEvent(pt.TrackAdded, {
42686
42711
  trackIndex: this.trackIdx,
42687
42712
  totalTracks: r.getTrackCount()
42688
42713
  }), this.preparedTrack)
42689
42714
  for (let n = 0; n < this.preparedTrack.clips.length; n += 1)
42690
- e.emitEvent(mt.ClipAdded, {
42715
+ e.emitEvent(pt.ClipAdded, {
42691
42716
  trackIndex: this.trackIdx,
42692
42717
  clipIndex: n
42693
42718
  });
@@ -42700,11 +42725,11 @@ class Cp {
42700
42725
  const i = r.getTrack(this.trackIdx)?.clips.length ?? 0;
42701
42726
  r.removeTrack(this.trackIdx), e.resolve(), e.updateDuration();
42702
42727
  for (let a = i - 1; a >= 0; a -= 1)
42703
- e.emitEvent(mt.ClipDeleted, {
42728
+ e.emitEvent(pt.ClipDeleted, {
42704
42729
  trackIndex: this.trackIdx,
42705
42730
  clipIndex: a
42706
42731
  });
42707
- return e.emitEvent(mt.TrackRemoved, { trackIndex: this.trackIdx }), ce();
42732
+ return e.emitEvent(pt.TrackRemoved, { trackIndex: this.trackIdx }), ce();
42708
42733
  }
42709
42734
  dispose() {
42710
42735
  }
@@ -42903,7 +42928,7 @@ class CZ {
42903
42928
  const n = e.documentAddClip(this.trackIdx, this.clip);
42904
42929
  this.addedClipId = n.id, this.convertedReferences && this.convertedReferences.size > 0 && Ep(r, this.convertedReferences), e.resolve(), e.updateDuration();
42905
42930
  const s = e.getDocumentTrack(this.trackIdx)?.clips?.findIndex((o) => o.id === this.addedClipId) ?? -1;
42906
- return e.emitEvent(mt.ClipAdded, {
42931
+ return e.emitEvent(pt.ClipAdded, {
42907
42932
  trackIndex: this.trackIdx,
42908
42933
  clipIndex: s
42909
42934
  }), ce();
@@ -42922,7 +42947,7 @@ class CZ {
42922
42947
  this.convertedReferences = Ap(r, e.getEditState(), s, u);
42923
42948
  }
42924
42949
  const o = e.getSelectedClip();
42925
- return o && o.clipId === this.addedClipId && (e.setSelectedClip(null), e.emitEvent(mt.SelectionCleared)), e.documentRemoveClip(this.trackIdx, a), e.resolve(), e.updateDuration(), e.emitEvent(mt.ClipDeleted, {
42950
+ return o && o.clipId === this.addedClipId && (e.setSelectedClip(null), e.emitEvent(pt.SelectionCleared)), e.documentRemoveClip(this.trackIdx, a), e.resolve(), e.updateDuration(), e.emitEvent(pt.ClipDeleted, {
42926
42951
  trackIndex: this.trackIdx,
42927
42952
  clipIndex: a
42928
42953
  }), ce();
@@ -42991,7 +43016,7 @@ class kp {
42991
43016
  a.add(`${this.trackIdx}:${s}`);
42992
43017
  this.convertedReferences = _Z(r, e.getEditState(), i, a);
42993
43018
  }
42994
- return r.removeTrack(this.trackIdx), e.resolve(), e.updateDuration(), e.emitEvent(mt.TrackRemoved, { trackIndex: this.trackIdx }), ce();
43019
+ return r.removeTrack(this.trackIdx), e.resolve(), e.updateDuration(), e.emitEvent(pt.TrackRemoved, { trackIndex: this.trackIdx }), ce();
42995
43020
  }
42996
43021
  undo(e) {
42997
43022
  if (!e) throw new Error("DeleteTrackCommand.undo: context is required");
@@ -43000,7 +43025,7 @@ class kp {
43000
43025
  r.addTrack(this.trackIdx);
43001
43026
  for (let n = 0; n < this.deletedClips.length; n += 1)
43002
43027
  r.addClip(this.trackIdx, this.deletedClips[n], n);
43003
- return this.convertedReferences && this.convertedReferences.size > 0 && Ep(r, this.convertedReferences), e.resolve(), e.updateDuration(), e.emitEvent(mt.TrackAdded, { trackIndex: this.trackIdx, totalTracks: r.getTrackCount() }), ce();
43028
+ return this.convertedReferences && this.convertedReferences.size > 0 && Ep(r, this.convertedReferences), e.resolve(), e.updateDuration(), e.emitEvent(pt.TrackAdded, { trackIndex: this.trackIdx, totalTracks: r.getTrackCount() }), ce();
43004
43029
  }
43005
43030
  dispose() {
43006
43031
  this.deletedClips = [], this.convertedReferences = void 0;
@@ -43037,9 +43062,9 @@ class j0 {
43037
43062
  }
43038
43063
  e.clearClipError(this.trackIdx, this.clipIdx);
43039
43064
  const a = e.getSelectedClip();
43040
- a && this.deletedClipId && a.clipId === this.deletedClipId && (e.setSelectedClip(null), e.emitEvent(mt.SelectionCleared)), e.documentRemoveClip(this.trackIdx, this.clipIdx);
43065
+ a && this.deletedClipId && a.clipId === this.deletedClipId && (e.setSelectedClip(null), e.emitEvent(pt.SelectionCleared)), e.documentRemoveClip(this.trackIdx, this.clipIdx);
43041
43066
  const s = r.getTrack(this.trackIdx);
43042
- return s && s.clips.length === 0 && (this.deleteTrackCommand = new kp(this.trackIdx), this.deleteTrackCommand.execute(e).status === "success" && (this.trackWasDeleted = !0)), e.resolve(), e.updateDuration(), e.emitEvent(mt.ClipDeleted, {
43067
+ return s && s.clips.length === 0 && (this.deleteTrackCommand = new kp(this.trackIdx), this.deleteTrackCommand.execute(e).status === "success" && (this.trackWasDeleted = !0)), e.resolve(), e.updateDuration(), e.emitEvent(pt.ClipDeleted, {
43043
43068
  trackIndex: this.trackIdx,
43044
43069
  clipIndex: this.clipIdx
43045
43070
  }), ce();
@@ -43051,10 +43076,10 @@ class j0 {
43051
43076
  if (!r) throw new Error("DeleteClipCommand.undo: no document");
43052
43077
  this.trackWasDeleted && r.addTrack(this.trackIdx);
43053
43078
  const i = e.documentAddClip(this.trackIdx, this.deletedClipConfig, this.clipIdx).id;
43054
- return i && this.storedBindings && this.storedBindings.size > 0 && r.setClipBindingsForClip(i, this.storedBindings), this.convertedReferences && this.convertedReferences.size > 0 && Ep(r, this.convertedReferences), e.resolve(), e.updateDuration(), this.trackWasDeleted && (e.emitEvent(mt.TrackAdded, {
43079
+ return i && this.storedBindings && this.storedBindings.size > 0 && r.setClipBindingsForClip(i, this.storedBindings), this.convertedReferences && this.convertedReferences.size > 0 && Ep(r, this.convertedReferences), e.resolve(), e.updateDuration(), this.trackWasDeleted && (e.emitEvent(pt.TrackAdded, {
43055
43080
  trackIndex: this.trackIdx,
43056
43081
  totalTracks: r.getTrackCount()
43057
- }), this.trackWasDeleted = !1), e.emitEvent(mt.ClipRestored, {
43082
+ }), this.trackWasDeleted = !1), e.emitEvent(pt.ClipRestored, {
43058
43083
  trackIndex: this.trackIdx,
43059
43084
  clipIndex: this.clipIdx
43060
43085
  }), ce();
@@ -43092,7 +43117,7 @@ class EZ {
43092
43117
  const s = r.getClip(this.effectiveToTrackIndex, this.newClipIndex);
43093
43118
  if (!this.previousDocClip || !s)
43094
43119
  throw new Error(`MoveClipCommand: document clip not found after mutation at ${this.effectiveToTrackIndex}/${this.newClipIndex}`);
43095
- e.emitEvent(mt.ClipUpdated, {
43120
+ e.emitEvent(pt.ClipUpdated, {
43096
43121
  previous: {
43097
43122
  clip: qe(this.previousDocClip),
43098
43123
  trackIndex: this.fromTrackIndex,
@@ -43105,7 +43130,7 @@ class EZ {
43105
43130
  }
43106
43131
  });
43107
43132
  const o = this.clipId ? e.getPlayerByClipId(this.clipId) : n;
43108
- return o && (e.setSelectedClip(o), e.emitEvent(mt.ClipSelected, {
43133
+ return o && (e.setSelectedClip(o), e.emitEvent(pt.ClipSelected, {
43109
43134
  clip: qe(s),
43110
43135
  trackIndex: this.effectiveToTrackIndex,
43111
43136
  clipIndex: this.newClipIndex
@@ -43124,7 +43149,7 @@ class EZ {
43124
43149
  start: this.originalStart
43125
43150
  }), e.resolve(), e.updateDuration(), this.fromTrackIndex !== this.effectiveToTrackIndex && e.propagateTimingChanges(this.effectiveToTrackIndex, this.newClipIndex - 1), e.propagateTimingChanges(this.fromTrackIndex, this.fromClipIndex);
43126
43151
  const a = r.getClip(this.fromTrackIndex, this.fromClipIndex);
43127
- this.previousDocClip && e.emitEvent(mt.ClipUpdated, {
43152
+ this.previousDocClip && e.emitEvent(pt.ClipUpdated, {
43128
43153
  previous: {
43129
43154
  clip: qe(i ?? this.previousDocClip),
43130
43155
  trackIndex: this.effectiveToTrackIndex,
@@ -43137,7 +43162,7 @@ class EZ {
43137
43162
  }
43138
43163
  });
43139
43164
  const s = e.getPlayerByClipId(this.clipId);
43140
- return s && a && (e.setSelectedClip(s), e.emitEvent(mt.ClipSelected, {
43165
+ return s && a && (e.setSelectedClip(s), e.emitEvent(pt.ClipSelected, {
43141
43166
  clip: qe(a),
43142
43167
  trackIndex: this.fromTrackIndex,
43143
43168
  clipIndex: this.fromClipIndex
@@ -43323,7 +43348,7 @@ class ku {
43323
43348
  const v = e.getDocumentClip(o, u);
43324
43349
  if (!this.previousDocClip || !v)
43325
43350
  throw new Error(`SetUpdatedClipCommand: document clip not found after mutation at ${o}/${u}`);
43326
- return e.emitEvent(mt.ClipUpdated, {
43351
+ return e.emitEvent(pt.ClipUpdated, {
43327
43352
  previous: { clip: qe(this.previousDocClip), trackIndex: o, clipIndex: u },
43328
43353
  current: { clip: qe(v), trackIndex: o, clipIndex: u }
43329
43354
  }), ce();
@@ -43349,7 +43374,7 @@ class ku {
43349
43374
  const h = e.getDocumentClip(a, s);
43350
43375
  if (!o || !h)
43351
43376
  throw new Error(`SetUpdatedClipCommand: document clip not found after undo at ${a}/${s}`);
43352
- return e.emitEvent(mt.ClipUpdated, {
43377
+ return e.emitEvent(pt.ClipUpdated, {
43353
43378
  previous: { clip: qe(o), trackIndex: a, clipIndex: s },
43354
43379
  current: { clip: qe(h), trackIndex: a, clipIndex: s }
43355
43380
  }), ce();
@@ -43384,7 +43409,7 @@ class TZ {
43384
43409
  }), e.updateDuration();
43385
43410
  const u = e.getDocumentClip(this.trackIndex, this.clipIndex);
43386
43411
  if (!u) throw new Error(`UpdateClipTimingCommand: document clip not found after mutation at ${this.trackIndex}/${this.clipIndex}`);
43387
- return e.emitEvent(mt.ClipUpdated, {
43412
+ return e.emitEvent(pt.ClipUpdated, {
43388
43413
  previous: { trackIndex: this.trackIndex, clipIndex: this.clipIndex, clip: qe(s) },
43389
43414
  current: { trackIndex: this.trackIndex, clipIndex: this.clipIndex, clip: qe(u) }
43390
43415
  }), e.propagateTimingChanges(this.trackIndex, this.clipIndex), ce();
@@ -43404,7 +43429,7 @@ class TZ {
43404
43429
  const s = e.getDocumentClip(this.trackIndex, this.clipIndex);
43405
43430
  if (!i || !s)
43406
43431
  throw new Error(`UpdateClipTimingCommand: document clip not found after undo at ${this.trackIndex}/${this.clipIndex}`);
43407
- return e.emitEvent(mt.ClipUpdated, {
43432
+ return e.emitEvent(pt.ClipUpdated, {
43408
43433
  previous: { trackIndex: this.trackIndex, clipIndex: this.clipIndex, clip: qe(i) },
43409
43434
  current: { trackIndex: this.trackIndex, clipIndex: this.clipIndex, clip: qe(s) }
43410
43435
  }), e.propagateTimingChanges(this.trackIndex, this.clipIndex), ce();
@@ -43436,7 +43461,7 @@ class PZ {
43436
43461
  const u = e.getDocumentClip(this.trackIndex, this.clipIndex);
43437
43462
  if (!this.previousDocClip || !u)
43438
43463
  throw new Error(`UpdateTextContentCommand: document clip not found after mutation at ${this.trackIndex}/${this.clipIndex}`);
43439
- return e.emitEvent(mt.ClipUpdated, {
43464
+ return e.emitEvent(pt.ClipUpdated, {
43440
43465
  previous: { clip: qe(this.previousDocClip), trackIndex: this.trackIndex, clipIndex: this.clipIndex },
43441
43466
  current: { clip: qe(u), trackIndex: this.trackIndex, clipIndex: this.clipIndex }
43442
43467
  }), ce();
@@ -43453,7 +43478,7 @@ class PZ {
43453
43478
  if (this.previousDocClip) {
43454
43479
  if (!n || !o)
43455
43480
  throw new Error(`UpdateTextContentCommand: document clip not found after undo at ${this.trackIndex}/${this.clipIndex}`);
43456
- e.emitEvent(mt.ClipUpdated, {
43481
+ e.emitEvent(pt.ClipUpdated, {
43457
43482
  previous: { clip: qe(n), trackIndex: this.trackIndex, clipIndex: this.clipIndex },
43458
43483
  current: { clip: qe(o), trackIndex: this.trackIndex, clipIndex: this.clipIndex }
43459
43484
  });
@@ -43597,10 +43622,10 @@ class VZ {
43597
43622
  }
43598
43623
  }
43599
43624
  setupEventListeners() {
43600
- this.events.on(ge.PlayerLoaded, this.onPlayerLoadedBound), this.events.on(mt.ClipUpdated, this.onClipChangedBound), this.events.on(ge.PlayerMovedBetweenTracks, this.onClipChangedBound);
43625
+ this.events.on(ge.PlayerLoaded, this.onPlayerLoadedBound), this.events.on(pt.ClipUpdated, this.onClipChangedBound), this.events.on(ge.PlayerMovedBetweenTracks, this.onClipChangedBound);
43601
43626
  }
43602
43627
  removeEventListeners() {
43603
- this.events.off(ge.PlayerLoaded, this.onPlayerLoadedBound), this.events.off(mt.ClipUpdated, this.onClipChangedBound), this.events.off(ge.PlayerMovedBetweenTracks, this.onClipChangedBound);
43628
+ this.events.off(ge.PlayerLoaded, this.onPlayerLoadedBound), this.events.off(pt.ClipUpdated, this.onClipChangedBound), this.events.off(ge.PlayerMovedBetweenTracks, this.onClipChangedBound);
43604
43629
  }
43605
43630
  processPendingMaskCleanup() {
43606
43631
  for (let e = this.pendingMaskCleanup.length - 1; e >= 0; e -= 1) {
@@ -43653,7 +43678,7 @@ class LZ {
43653
43678
  * @param options.silent If true, suppresses event emission (for command-based operations)
43654
43679
  */
43655
43680
  register(e, r) {
43656
- this.fields.set(e.name, e), r?.silent || this.events.emit(mt.MergeFieldChanged, { fields: this.getAll() });
43681
+ this.fields.set(e.name, e), r?.silent || this.events.emit(pt.MergeFieldChanged, { fields: this.getAll() });
43657
43682
  }
43658
43683
  /**
43659
43684
  * Remove a merge field by name.
@@ -43662,7 +43687,7 @@ class LZ {
43662
43687
  */
43663
43688
  remove(e, r) {
43664
43689
  const n = this.fields.delete(e);
43665
- return n && !r?.silent && this.events.emit(mt.MergeFieldChanged, { fields: this.getAll() }), n;
43690
+ return n && !r?.silent && this.events.emit(pt.MergeFieldChanged, { fields: this.getAll() }), n;
43666
43691
  }
43667
43692
  /** Get a merge field by name */
43668
43693
  get(e) {
@@ -43793,7 +43818,7 @@ class UZ {
43793
43818
  size: n
43794
43819
  }, delete i.output.resolution, delete i.output.aspectRatio);
43795
43820
  const a = this.edit.getDocument();
43796
- a?.setSize(n), a?.clearResolution(), a?.clearAspectRatio(), this.edit.updateCanvasForSize(), this.edit.getInternalEvents().emit(mt.OutputResized, n);
43821
+ a?.setSize(n), a?.clearResolution(), a?.clearAspectRatio(), this.edit.updateCanvasForSize(), this.edit.getInternalEvents().emit(pt.OutputResized, n);
43797
43822
  }
43798
43823
  getSize() {
43799
43824
  return this.edit.size;
@@ -43807,7 +43832,7 @@ class UZ {
43807
43832
  n && (n.output = {
43808
43833
  ...n.output,
43809
43834
  fps: r
43810
- }), this.edit.getDocument()?.setFps(r), this.edit.getInternalEvents().emit(mt.OutputFpsChanged, { fps: e });
43835
+ }), this.edit.getDocument()?.setFps(r), this.edit.getInternalEvents().emit(pt.OutputFpsChanged, { fps: e });
43811
43836
  }
43812
43837
  getFps() {
43813
43838
  return this.edit.getResolvedEdit()?.output?.fps ?? 30;
@@ -43818,7 +43843,7 @@ class UZ {
43818
43843
  n && (n.output = {
43819
43844
  ...n.output,
43820
43845
  format: r
43821
- }), this.edit.getDocument()?.setFormat(r), this.edit.getInternalEvents().emit(mt.OutputFormatChanged, { format: r });
43846
+ }), this.edit.getDocument()?.setFormat(r), this.edit.getInternalEvents().emit(pt.OutputFormatChanged, { format: r });
43822
43847
  }
43823
43848
  getFormat() {
43824
43849
  return this.edit.getResolvedEdit()?.output?.format ?? "mp4";
@@ -43829,7 +43854,7 @@ class UZ {
43829
43854
  n && (n.output = {
43830
43855
  ...n.output,
43831
43856
  destinations: r
43832
- }), this.edit.getInternalEvents().emit(mt.OutputDestinationsChanged, { destinations: r });
43857
+ }), this.edit.getInternalEvents().emit(pt.OutputDestinationsChanged, { destinations: r });
43833
43858
  }
43834
43859
  getDestinations() {
43835
43860
  return this.edit.getResolvedEdit()?.output?.destinations ?? [];
@@ -43842,7 +43867,7 @@ class UZ {
43842
43867
  resolution: r
43843
43868
  }, delete n.output.size);
43844
43869
  const s = this.edit.getDocument();
43845
- s?.setResolution(r), s?.clearSize(), this.edit.updateCanvasForSize(), this.edit.getInternalEvents().emit(mt.OutputResolutionChanged, { resolution: r }), this.edit.getInternalEvents().emit(mt.OutputResized, { width: a.width, height: a.height });
43870
+ s?.setResolution(r), s?.clearSize(), this.edit.updateCanvasForSize(), this.edit.getInternalEvents().emit(pt.OutputResolutionChanged, { resolution: r }), this.edit.getInternalEvents().emit(pt.OutputResized, { width: a.width, height: a.height });
43846
43871
  }
43847
43872
  getResolution() {
43848
43873
  return this.edit.getResolvedEdit()?.output?.resolution;
@@ -43854,7 +43879,7 @@ class UZ {
43854
43879
  n && (n.output = {
43855
43880
  ...n.output,
43856
43881
  aspectRatio: r
43857
- }), this.edit.getDocument()?.setAspectRatio(r), this.edit.getInternalEvents().emit(mt.OutputAspectRatioChanged, { aspectRatio: r });
43882
+ }), this.edit.getDocument()?.setAspectRatio(r), this.edit.getInternalEvents().emit(pt.OutputAspectRatioChanged, { aspectRatio: r });
43858
43883
  return;
43859
43884
  }
43860
43885
  const a = kl(i, r);
@@ -43863,7 +43888,7 @@ class UZ {
43863
43888
  aspectRatio: r
43864
43889
  }, delete n.output.size);
43865
43890
  const s = this.edit.getDocument();
43866
- s?.setAspectRatio(r), s?.clearSize(), this.edit.updateCanvasForSize(), this.edit.getInternalEvents().emit(mt.OutputAspectRatioChanged, { aspectRatio: r }), this.edit.getInternalEvents().emit(mt.OutputResized, { width: a.width, height: a.height });
43891
+ s?.setAspectRatio(r), s?.clearSize(), this.edit.updateCanvasForSize(), this.edit.getInternalEvents().emit(pt.OutputAspectRatioChanged, { aspectRatio: r }), this.edit.getInternalEvents().emit(pt.OutputResized, { width: a.width, height: a.height });
43867
43892
  }
43868
43893
  getAspectRatio() {
43869
43894
  return this.edit.getResolvedEdit()?.output?.aspectRatio;
@@ -43893,7 +43918,7 @@ class WZ {
43893
43918
  if (n) {
43894
43919
  this.selectedClip = n;
43895
43920
  const i = this.edit.getDocumentClip(e, r);
43896
- i && this.edit.getInternalEvents().emit(mt.ClipSelected, {
43921
+ i && this.edit.getInternalEvents().emit(pt.ClipSelected, {
43897
43922
  clip: qe(i),
43898
43923
  trackIndex: e,
43899
43924
  clipIndex: r
@@ -43911,7 +43936,7 @@ class WZ {
43911
43936
  * Clear the current selection.
43912
43937
  */
43913
43938
  clearSelection() {
43914
- this.selectedClip = null, this.edit.getInternalEvents().emit(mt.SelectionCleared);
43939
+ this.selectedClip = null, this.edit.getInternalEvents().emit(pt.SelectionCleared);
43915
43940
  }
43916
43941
  /**
43917
43942
  * Check if a specific clip is selected by indices.
@@ -43960,7 +43985,7 @@ class WZ {
43960
43985
  n && (this.copiedClip = {
43961
43986
  trackIndex: e,
43962
43987
  clipConfiguration: structuredClone(n)
43963
- }, this.edit.getInternalEvents().emit(mt.ClipCopied, { trackIndex: e, clipIndex: r }), GZ(aZ(n)).catch(() => {
43988
+ }, this.edit.getInternalEvents().emit(pt.ClipCopied, { trackIndex: e, clipIndex: r }), GZ(aZ(n)).catch(() => {
43964
43989
  }));
43965
43990
  }
43966
43991
  /**
@@ -44105,7 +44130,7 @@ class qZ {
44105
44130
  }), o.reconfigureAfterRestore());
44106
44131
  }
44107
44132
  }
44108
- this.edit.updateTotalDuration(), this.edit.getInternalEvents().emit(mt.TimelineUpdated, {
44133
+ this.edit.updateTotalDuration(), this.edit.getInternalEvents().emit(pt.TimelineUpdated, {
44109
44134
  current: this.edit.getEdit()
44110
44135
  });
44111
44136
  }
@@ -45145,16 +45170,16 @@ class iU {
45145
45170
  const a = this.edit.createPlayerFromAssetType(e);
45146
45171
  a.layer = n + 1, a.clipId = r, this.edit.registerPlayerByClipId(r, a), this.edit.addPlayerToTracksArray(n, a), this.edit.addPlayerToContainer(n, a);
45147
45172
  const s = e.asset?.type ?? "unknown", o = a.load().then(() => {
45148
- this.edit.getInternalEvents().emit(ge.PlayerLoaded, {
45173
+ a.loadError && this.reportLoadFailure(a, a.loadError), this.edit.getInternalEvents().emit(ge.PlayerLoaded, {
45149
45174
  player: a,
45150
45175
  trackIndex: n,
45151
45176
  clipIndex: i
45152
- }), Fu(e.asset) && this.edit.getInternalEvents().emit(mt.ClipUnresolved, {
45177
+ }), Fu(e.asset) && this.edit.getInternalEvents().emit(pt.ClipUnresolved, {
45153
45178
  trackIndex: n,
45154
45179
  clipIndex: i,
45155
45180
  assetType: s,
45156
45181
  clipId: r
45157
- }), a.needsResolution && this.edit.getInternalEvents().emit(mt.ClipUnresolved, {
45182
+ }), a.needsResolution && this.edit.getInternalEvents().emit(pt.ClipUnresolved, {
45158
45183
  trackIndex: n,
45159
45184
  clipIndex: i,
45160
45185
  assetType: s,
@@ -45162,7 +45187,7 @@ class iU {
45162
45187
  });
45163
45188
  }).catch((u) => {
45164
45189
  const l = u instanceof Error ? u.message : String(u);
45165
- this.edit.getInternalEvents().emit(mt.ClipLoadFailed, {
45190
+ this.edit.getInternalEvents().emit(pt.ClipLoadFailed, {
45166
45191
  trackIndex: n,
45167
45192
  clipIndex: i,
45168
45193
  error: l,
@@ -45205,6 +45230,16 @@ class iU {
45205
45230
  I1.has(s) || (i[s] !== void 0 ? n[s] = i[s] : delete n[s]);
45206
45231
  e.reconfigureAfterRestore();
45207
45232
  }
45233
+ /**
45234
+ * Announce a player that couldn't show its asset. Its position is looked up now, not when the
45235
+ * load started, because clips can move while an asset is still loading.
45236
+ */
45237
+ reportLoadFailure(e, r) {
45238
+ const n = this.edit.findClipIndices(e);
45239
+ if (!n) return;
45240
+ const i = e.clipConfiguration.asset?.type ?? "unknown";
45241
+ this.edit.getInternalEvents().emit(pt.ClipLoadFailed, { ...n, error: r, assetType: i });
45242
+ }
45208
45243
  /**
45209
45244
  * Check if asset properties changed (excluding type, which is handled separately).
45210
45245
  */
@@ -45225,9 +45260,9 @@ class iU {
45225
45260
  a = s !== o;
45226
45261
  }
45227
45262
  a && e.reloadAsset ? e.reloadAsset().then(() => {
45228
- e.reconfigureAfterRestore();
45263
+ e.reconfigureAfterRestore(), e.loadError && this.reportLoadFailure(e, e.loadError);
45229
45264
  }).catch((s) => {
45230
- console.error("Failed to reload asset:", s);
45265
+ console.error("Failed to reload asset:", s), this.reportLoadFailure(e, s instanceof Error ? s.message : String(s));
45231
45266
  }) : e.reconfigureAfterRestore();
45232
45267
  }
45233
45268
  /**
@@ -45611,9 +45646,9 @@ class En {
45611
45646
  ), this.playerReconciler = new iU(this), this.assetGenerator = new eU({
45612
45647
  getClipAsset: (i) => this.getResolvedClipById(i)?.asset,
45613
45648
  applyGeneratedSrc: (i, a) => this.applyGeneratedSrc(i, a),
45614
- emitStarted: (i) => this.internalEvents.emit(mt.ClipGenerationStarted, { clipId: i }),
45615
- emitCompleted: (i) => this.internalEvents.emit(mt.ClipGenerationCompleted, { clipId: i }),
45616
- emitFailed: (i, a) => this.internalEvents.emit(mt.ClipGenerationFailed, { clipId: i, error: a }),
45649
+ emitStarted: (i) => this.internalEvents.emit(pt.ClipGenerationStarted, { clipId: i }),
45650
+ emitCompleted: (i) => this.internalEvents.emit(pt.ClipGenerationCompleted, { clipId: i }),
45651
+ emitFailed: (i, a) => this.internalEvents.emit(pt.ClipGenerationFailed, { clipId: i, error: a }),
45617
45652
  emitStatusChanged: (i) => this.internalEvents.emit(ge.GenerationStatusChanged, { clipId: i })
45618
45653
  }), this.mergeFieldService = new LZ(this.internalEvents), this.outputSettings = new UZ(this), this.selectionManager = new WZ(this), this.timingManager = new qZ(this), this.setupIntentListeners(), this.setupGenerationListeners();
45619
45654
  }
@@ -45644,7 +45679,7 @@ class En {
45644
45679
  this.lumaMaskController.initialize(), await this.playerReconciler.reconcileInitial(s), this.normalizeLumaAttachments();
45645
45680
  for (const [o, u] of i)
45646
45681
  u.size > 0 && this.document.setClipBindingsForClip(o, u);
45647
- await this.timingManager.resolveAllTiming(), this.updateTotalDuration(), a.timeline.soundtrack && await this.loadSoundtrack(a.timeline.soundtrack), this.internalEvents.emit(mt.TimelineUpdated, { current: this.getEdit() }), this.emitEditChanged(e);
45682
+ await this.timingManager.resolveAllTiming(), this.updateTotalDuration(), a.timeline.soundtrack && await this.loadSoundtrack(a.timeline.soundtrack), this.internalEvents.emit(pt.TimelineUpdated, { current: this.getEdit() }), this.emitEditChanged(e);
45648
45683
  }
45649
45684
  /** @internal */
45650
45685
  getInternalEvents() {
@@ -45676,10 +45711,10 @@ class En {
45676
45711
  }), this.internalEvents.emit(ge.ViewportNeedsZoomToFit);
45677
45712
  }
45678
45713
  play() {
45679
- this.isPlaying = !0, this.playWallAnchorMs = performance.now(), this.playTimeAnchorSeconds = this.playbackTime, this.internalEvents.emit(mt.PlaybackPlay);
45714
+ this.isPlaying = !0, this.playWallAnchorMs = performance.now(), this.playTimeAnchorSeconds = this.playbackTime, this.internalEvents.emit(pt.PlaybackPlay);
45680
45715
  }
45681
45716
  pause() {
45682
- this.isPlaying = !1, this.internalEvents.emit(mt.PlaybackPause);
45717
+ this.isPlaying = !1, this.internalEvents.emit(pt.PlaybackPause);
45683
45718
  }
45684
45719
  seek(e) {
45685
45720
  this.playbackTime = Math.max(0, Math.min(e, this.totalDuration)), this.pause(), this.update(0, En.SEEK_ELAPSED_MARKER);
@@ -46021,12 +46056,15 @@ class En {
46021
46056
  * @internal
46022
46057
  */
46023
46058
  getClipError(e, r) {
46024
- const n = this.clipErrors.get(`${e}-${r}`);
46025
- if (n) return n;
46026
- const i = this.getResolvedClip(e, r)?.asset;
46027
- if (!i || !("src" in i) || typeof i.src != "string") return null;
46028
- const a = ss(i.src), s = this.getClipId(e, r), o = i.type === "video" && s ? `${s}:${a}` : a, u = this.assetLoader.loadTracker.registry[o];
46029
- return u?.status === "failed" ? { error: u.error ?? `Invalid source '${i.src}'.`, assetType: i.type } : null;
46059
+ const n = this.getPlayerClip(e, r);
46060
+ if (n?.loadError)
46061
+ return { error: n.loadError, assetType: n.clipConfiguration.asset?.type ?? "unknown" };
46062
+ const i = this.clipErrors.get(`${e}-${r}`);
46063
+ if (i) return i;
46064
+ const a = this.getResolvedClip(e, r)?.asset;
46065
+ if (!a || !("src" in a) || typeof a.src != "string") return null;
46066
+ const s = ss(a.src), o = this.getClipId(e, r), u = a.type === "video" && o ? `${o}:${s}` : s, l = this.assetLoader.loadTracker.registry[u];
46067
+ return l?.status === "failed" ? { error: l.error ?? `Invalid source '${a.src}'.`, assetType: a.type } : null;
46030
46068
  }
46031
46069
  /**
46032
46070
  * Clear the error for a deleted clip and shift indices for remaining errors.
@@ -46256,7 +46294,7 @@ class En {
46256
46294
  const e = this.commandHistory[this.commandIndex];
46257
46295
  if (!e.undo) return re("Command cannot be undone");
46258
46296
  const r = this.createCommandContext(), n = await Promise.resolve(e.undo(r));
46259
- return this.commandIndex -= 1, this.internalEvents.emit(mt.EditUndo, { command: e.name }), this.emitEditChanged(`undo:${e.name}`), n;
46297
+ return this.commandIndex -= 1, this.internalEvents.emit(pt.EditUndo, { command: e.name }), this.emitEditChanged(`undo:${e.name}`), n;
46260
46298
  });
46261
46299
  }
46262
46300
  /**
@@ -46269,7 +46307,7 @@ class En {
46269
46307
  return this.commandQueue.enqueue(async () => {
46270
46308
  if (this.commandIndex >= this.commandHistory.length - 1) return re("Nothing to redo");
46271
46309
  const e = this.commandIndex + 1, r = this.commandHistory[e], n = this.createCommandContext(), i = await Promise.resolve(r.execute(n));
46272
- return this.commandIndex = e, this.internalEvents.emit(mt.EditRedo, { command: r.name }), this.emitEditChanged(`redo:${r.name}`), i;
46310
+ return this.commandIndex = e, this.internalEvents.emit(pt.EditRedo, { command: r.name }), this.emitEditChanged(`redo:${r.name}`), i;
46273
46311
  });
46274
46312
  }
46275
46313
  /** True when there is a command to undo (the history pointer is not before the first command). */
@@ -46419,7 +46457,7 @@ class En {
46419
46457
  * @internal
46420
46458
  */
46421
46459
  emitEditChanged(e) {
46422
- this.isBatchingEvents || this.internalEvents.emit(mt.EditChanged, { source: e, timestamp: Date.now() });
46460
+ this.isBatchingEvents || this.internalEvents.emit(pt.EditChanged, { source: e, timestamp: Date.now() });
46423
46461
  }
46424
46462
  /**
46425
46463
  * Detects merge field placeholders in the raw edit before substitution.
@@ -46572,9 +46610,15 @@ class En {
46572
46610
  const a = this.document.getClipId(e, n);
46573
46611
  a && (r.clipId = a, this.playerByClipId.set(a, r));
46574
46612
  }
46575
- this.addPlayerToContainer(e, r), r.load().catch((i) => {
46613
+ this.addPlayerToContainer(e, r), r.load().then(() => {
46614
+ if (!r.loadError) return;
46615
+ const i = this.findClipIndices(r);
46616
+ if (!i) return;
46617
+ const a = r.clipConfiguration?.asset?.type ?? "unknown";
46618
+ this.internalEvents.emit(pt.ClipLoadFailed, { ...i, error: r.loadError, assetType: a });
46619
+ }).catch((i) => {
46576
46620
  const a = r.clipConfiguration?.asset?.type ?? "unknown", s = i instanceof Error ? i.message : String(i);
46577
- this.clipErrors.set(`${e}-${n}`, { error: s, assetType: a }), this.internalEvents.emit(mt.ClipLoadFailed, {
46621
+ this.clipErrors.set(`${e}-${n}`, { error: s, assetType: a }), this.internalEvents.emit(pt.ClipLoadFailed, {
46578
46622
  trackIndex: e,
46579
46623
  clipIndex: n,
46580
46624
  error: s,
@@ -46774,7 +46818,7 @@ class En {
46774
46818
  for (const i of n)
46775
46819
  e = Math.max(e, i.getEnd());
46776
46820
  const r = this.totalDuration;
46777
- this.totalDuration = e, r !== this.totalDuration && this.internalEvents.emit(mt.DurationChanged, { duration: this.totalDuration });
46821
+ this.totalDuration = e, r !== this.totalDuration && this.internalEvents.emit(pt.DurationChanged, { duration: this.totalDuration });
46778
46822
  }
46779
46823
  /** @internal */
46780
46824
  propagateTimingChanges(e, r) {
@@ -47102,7 +47146,7 @@ class En {
47102
47146
  width: this.size.width,
47103
47147
  height: this.size.height,
47104
47148
  backgroundColor: this.backgroundColor
47105
- }), this.internalEvents.emit(mt.TimelineBackgroundChanged, { color: e });
47149
+ }), this.internalEvents.emit(pt.TimelineBackgroundChanged, { color: e });
47106
47150
  }
47107
47151
  getTimelineBackground() {
47108
47152
  return this.backgroundColor;
@@ -47242,11 +47286,11 @@ class En {
47242
47286
  static DoubleClickThresholdMs = 500;
47243
47287
  // ─── Event Listeners ─────────────────────────────────────────────────────────
47244
47288
  static GenerationConfigTriggers = [
47245
- mt.ClipSelected,
47246
- mt.SelectionCleared,
47247
- mt.EditChanged,
47248
- mt.MergeFieldChanged,
47249
- mt.TimelineUpdated
47289
+ pt.ClipSelected,
47290
+ pt.SelectionCleared,
47291
+ pt.EditChanged,
47292
+ pt.MergeFieldChanged,
47293
+ pt.TimelineUpdated
47250
47294
  ];
47251
47295
  setupGenerationListeners() {
47252
47296
  this.internalEvents.on(ge.Resolved, this.onResolvedForGeneration);
@@ -47313,12 +47357,12 @@ class B1 {
47313
47357
  this.updateDocumentClip(e, n, !0);
47314
47358
  } else
47315
47359
  this.updateDocumentClip(e, this.storedNewValue, !1);
47316
- return e.resolve(), e.emitEvent(mt.MergeFieldChanged, { fields: r.getAll() }), ce();
47360
+ return e.resolve(), e.emitEvent(pt.MergeFieldChanged, { fields: r.getAll() }), ce();
47317
47361
  }
47318
47362
  async undo(e) {
47319
47363
  if (!e) throw new Error("SetMergeFieldCommand.undo: context is required");
47320
47364
  const r = e.getMergeFields();
47321
- return this.storedPreviousBinding ? e.setClipBinding(this.clipId, this.propertyPath, this.storedPreviousBinding) : e.removeClipBinding(this.clipId, this.propertyPath), this.previousFieldName && r.register({ name: this.previousFieldName, defaultValue: this.storedPreviousValue }, { silent: !0 }), this.storedPreviousBinding ? this.updateDocumentClip(e, this.storedPreviousBinding.placeholder, !0) : this.updateDocumentClip(e, this.storedPreviousValue, !1), e.resolve(), e.emitEvent(mt.MergeFieldChanged, { fields: r.getAll() }), ce();
47365
+ return this.storedPreviousBinding ? e.setClipBinding(this.clipId, this.propertyPath, this.storedPreviousBinding) : e.removeClipBinding(this.clipId, this.propertyPath), this.previousFieldName && r.register({ name: this.previousFieldName, defaultValue: this.storedPreviousValue }, { silent: !0 }), this.storedPreviousBinding ? this.updateDocumentClip(e, this.storedPreviousBinding.placeholder, !0) : this.updateDocumentClip(e, this.storedPreviousValue, !1), e.resolve(), e.emitEvent(pt.MergeFieldChanged, { fields: r.getAll() }), ce();
47322
47366
  }
47323
47367
  dispose() {
47324
47368
  this.storedPreviousBinding = void 0;
@@ -47398,7 +47442,7 @@ class GU extends En {
47398
47442
  this.mergeFieldService.register({ ...n, defaultValue: r }, { silent: !0 });
47399
47443
  for (const [, i] of this.getPlayerMap())
47400
47444
  this.updateMergeFieldBindings(i, e, r);
47401
- this.resolve(), this.getInternalEvents().emit(mt.TimelineUpdated, { current: this.getEdit() });
47445
+ this.resolve(), this.getInternalEvents().emit(pt.TimelineUpdated, { current: this.getEdit() });
47402
47446
  } finally {
47403
47447
  this.isUpdatingMergeFields = !1;
47404
47448
  }
@@ -47501,7 +47545,7 @@ class GU extends En {
47501
47545
  const o = this.getTemplateClipById(s);
47502
47546
  o && await this.restoreMergeFieldInClip(s, o, n, i);
47503
47547
  }
47504
- this.mergeFieldService.remove(e) || this.getInternalEvents().emit(mt.MergeFieldChanged, { fields: this.mergeFieldService.getAll() });
47548
+ this.mergeFieldService.remove(e) || this.getInternalEvents().emit(pt.MergeFieldChanged, { fields: this.mergeFieldService.getAll() });
47505
47549
  }
47506
47550
  // ─── Text Conversion API ───────────────────────────────────────────────────
47507
47551
  /**
@@ -48103,8 +48147,8 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48103
48147
  var r = (() => {
48104
48148
  var n = typeof document < "u" ? document.currentScript?.src : void 0;
48105
48149
  return async function(i = {}) {
48106
- var a, s = i, o = typeof window == "object", u = typeof WorkerGlobalScope < "u", l = typeof process == "object" && process.versions?.node && process.type != "renderer", c = (T, pt) => {
48107
- throw pt;
48150
+ var a, s = i, o = typeof window == "object", u = typeof WorkerGlobalScope < "u", l = typeof process == "object" && process.versions?.node && process.type != "renderer", c = (T, mt) => {
48151
+ throw mt;
48108
48152
  };
48109
48153
  typeof __filename < "u" ? n = __filename : u && (n = self.location.href);
48110
48154
  var h = "";
@@ -48116,14 +48160,14 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48116
48160
  var v = Kx("fs");
48117
48161
  h = __dirname + "/", y = (T) => {
48118
48162
  T = k(T) ? new URL(T) : T;
48119
- var pt = v.readFileSync(T);
48120
- return pt;
48121
- }, m = async (T, pt = !0) => {
48163
+ var mt = v.readFileSync(T);
48164
+ return mt;
48165
+ }, m = async (T, mt = !0) => {
48122
48166
  T = k(T) ? new URL(T) : T;
48123
- var qt = v.readFileSync(T, pt ? void 0 : "utf8");
48167
+ var qt = v.readFileSync(T, mt ? void 0 : "utf8");
48124
48168
  return qt;
48125
- }, process.argv.length > 1 && process.argv[1].replace(/\\/g, "/"), process.argv.slice(2), c = (T, pt) => {
48126
- throw process.exitCode = T, pt;
48169
+ }, process.argv.length > 1 && process.argv[1].replace(/\\/g, "/"), process.argv.slice(2), c = (T, mt) => {
48170
+ throw process.exitCode = T, mt;
48127
48171
  };
48128
48172
  } else if (o || u) {
48129
48173
  try {
@@ -48131,8 +48175,8 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48131
48175
  } catch {
48132
48176
  }
48133
48177
  u && (y = (T) => {
48134
- var pt = new XMLHttpRequest();
48135
- return pt.open("GET", T, !1), pt.responseType = "arraybuffer", pt.send(null), new Uint8Array(pt.response);
48178
+ var mt = new XMLHttpRequest();
48179
+ return mt.open("GET", T, !1), mt.responseType = "arraybuffer", mt.send(null), new Uint8Array(mt.response);
48136
48180
  }), m = async (T) => {
48137
48181
  if (k(T))
48138
48182
  return new Promise((qt, de) => {
@@ -48145,10 +48189,10 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48145
48189
  de(ne.status);
48146
48190
  }, ne.onerror = de, ne.send(null);
48147
48191
  });
48148
- var pt = await fetch(T, { credentials: "same-origin" });
48149
- if (pt.ok)
48150
- return pt.arrayBuffer();
48151
- throw new Error(pt.status + " : " + pt.url);
48192
+ var mt = await fetch(T, { credentials: "same-origin" });
48193
+ if (mt.ok)
48194
+ return mt.arrayBuffer();
48195
+ throw new Error(mt.status + " : " + mt.url);
48152
48196
  };
48153
48197
  }
48154
48198
  console.log.bind(console);
@@ -48178,14 +48222,14 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48178
48222
  }
48179
48223
  function ht(T) {
48180
48224
  if (j--, s.monitorRunDependencies?.(j), j == 0 && ft) {
48181
- var pt = ft;
48182
- ft = null, pt();
48225
+ var mt = ft;
48226
+ ft = null, mt();
48183
48227
  }
48184
48228
  }
48185
48229
  function W(T) {
48186
48230
  s.onAbort?.(T), T = "Aborted(" + T + ")", b(T), I = !0, T += ". Build with -sASSERTIONS for more info.";
48187
- var pt = new WebAssembly.RuntimeError(T);
48188
- throw _?.(pt), pt;
48231
+ var mt = new WebAssembly.RuntimeError(T);
48232
+ throw _?.(mt), mt;
48189
48233
  }
48190
48234
  var J;
48191
48235
  function rt() {
@@ -48201,29 +48245,29 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48201
48245
  async function Lt(T) {
48202
48246
  if (!C)
48203
48247
  try {
48204
- var pt = await m(T);
48205
- return new Uint8Array(pt);
48248
+ var mt = await m(T);
48249
+ return new Uint8Array(mt);
48206
48250
  } catch {
48207
48251
  }
48208
48252
  return St(T);
48209
48253
  }
48210
- async function jt(T, pt) {
48254
+ async function jt(T, mt) {
48211
48255
  try {
48212
- var qt = await Lt(T), de = await WebAssembly.instantiate(qt, pt);
48256
+ var qt = await Lt(T), de = await WebAssembly.instantiate(qt, mt);
48213
48257
  return de;
48214
48258
  } catch (ne) {
48215
48259
  b(`failed to asynchronously prepare wasm: ${ne}`), W(ne);
48216
48260
  }
48217
48261
  }
48218
- async function ue(T, pt, qt) {
48219
- if (!T && !k(pt) && !l)
48262
+ async function ue(T, mt, qt) {
48263
+ if (!T && !k(mt) && !l)
48220
48264
  try {
48221
- var de = fetch(pt, { credentials: "same-origin" }), ne = await WebAssembly.instantiateStreaming(de, qt);
48265
+ var de = fetch(mt, { credentials: "same-origin" }), ne = await WebAssembly.instantiateStreaming(de, qt);
48222
48266
  return ne;
48223
48267
  } catch (Le) {
48224
48268
  b(`wasm streaming compile failed: ${Le}`), b("falling back to ArrayBuffer instantiation");
48225
48269
  }
48226
- return jt(pt, qt);
48270
+ return jt(mt, qt);
48227
48271
  }
48228
48272
  function fe() {
48229
48273
  return { env: zr, wasi_snapshot_preview1: zr };
@@ -48233,7 +48277,7 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48233
48277
  return ur = Le.exports, s.wasmExports = ur, L = ur.memory, s.wasmMemory = L, N(), Yt = ur.__indirect_function_table, pr(ur), ht(), ur;
48234
48278
  }
48235
48279
  gt();
48236
- function pt(Le) {
48280
+ function mt(Le) {
48237
48281
  return T(Le.instance);
48238
48282
  }
48239
48283
  var qt = fe();
@@ -48244,12 +48288,12 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48244
48288
  });
48245
48289
  });
48246
48290
  J ?? (J = rt());
48247
- var de = await ue(C, J, qt), ne = pt(de);
48291
+ var de = await ue(C, J, qt), ne = mt(de);
48248
48292
  return ne;
48249
48293
  }
48250
48294
  class Ue {
48251
- constructor(pt) {
48252
- zt(this, "name", "ExitStatus"), this.message = `Program terminated with exit(${pt})`, this.status = pt;
48295
+ constructor(mt) {
48296
+ zt(this, "name", "ExitStatus"), this.message = `Program terminated with exit(${mt})`, this.status = mt;
48253
48297
  }
48254
48298
  }
48255
48299
  var le = (T) => {
@@ -48263,7 +48307,7 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48263
48307
  c(1, T);
48264
48308
  }, at = () => vt || bt > 0, wt = (T) => {
48265
48309
  A = T, at() || (s.onExit?.(T), I = !0), c(T, new Ue(T));
48266
- }, it = (T, pt) => {
48310
+ }, it = (T, mt) => {
48267
48311
  A = T, wt(T);
48268
48312
  }, Ht = it, Ft = () => {
48269
48313
  if (!at())
@@ -48276,29 +48320,29 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48276
48320
  if (!I)
48277
48321
  try {
48278
48322
  T(), Ft();
48279
- } catch (pt) {
48280
- X(pt);
48323
+ } catch (mt) {
48324
+ X(mt);
48281
48325
  }
48282
- }, xt = () => performance.now(), se = (T, pt) => {
48283
- if (Bt[T] && (clearTimeout(Bt[T].id), delete Bt[T]), !pt) return 0;
48326
+ }, xt = () => performance.now(), se = (T, mt) => {
48327
+ if (Bt[T] && (clearTimeout(Bt[T].id), delete Bt[T]), !mt) return 0;
48284
48328
  var qt = setTimeout(() => {
48285
48329
  delete Bt[T], Nt(() => Gr(T, xt()));
48286
- }, pt);
48287
- return Bt[T] = { id: qt, timeout_ms: pt }, 0;
48288
- }, he = () => 2147483648, yt = (T, pt) => Math.ceil(T / pt) * pt, Ve = (T) => {
48289
- var pt = L.buffer.byteLength, qt = (T - pt + 65535) / 65536 | 0;
48330
+ }, mt);
48331
+ return Bt[T] = { id: qt, timeout_ms: mt }, 0;
48332
+ }, he = () => 2147483648, yt = (T, mt) => Math.ceil(T / mt) * mt, Ve = (T) => {
48333
+ var mt = L.buffer.byteLength, qt = (T - mt + 65535) / 65536 | 0;
48290
48334
  try {
48291
48335
  return L.grow(qt), N(), 1;
48292
48336
  } catch {
48293
48337
  }
48294
48338
  }, Qe = (T) => {
48295
- var pt = B.length;
48339
+ var mt = B.length;
48296
48340
  T >>>= 0;
48297
48341
  var qt = he();
48298
48342
  if (T > qt)
48299
48343
  return !1;
48300
48344
  for (var de = 1; de <= 4; de *= 2) {
48301
- var ne = pt * (1 + 0.2 / de);
48345
+ var ne = mt * (1 + 0.2 / de);
48302
48346
  ne = Math.min(ne, T + 100663296);
48303
48347
  var Le = Math.min(qt, yt(Math.max(T, ne), 65536)), Vr = Ve(Le);
48304
48348
  if (Vr)
@@ -48306,21 +48350,21 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48306
48350
  }
48307
48351
  return !1;
48308
48352
  }, we = (T) => {
48309
- const pt = T.length;
48310
- return [pt % 128 | 128, pt >> 7, ...T];
48311
- }, Mr = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 }, Re = (T) => we(Array.from(T, (pt) => {
48312
- var qt = Mr[pt];
48353
+ const mt = T.length;
48354
+ return [mt % 128 | 128, mt >> 7, ...T];
48355
+ }, Mr = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 }, Re = (T) => we(Array.from(T, (mt) => {
48356
+ var qt = Mr[mt];
48313
48357
  return qt;
48314
- })), Xt = (T, pt) => {
48315
- var qt = Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0, 1, ...we([1, 96, ...Re(pt.slice(1)), ...Re(pt[0] === "v" ? "" : pt[0])]), 2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0), de = new WebAssembly.Module(qt), ne = new WebAssembly.Instance(de, { e: { f: T } }), Le = ne.exports.f;
48358
+ })), Xt = (T, mt) => {
48359
+ var qt = Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0, 1, ...we([1, 96, ...Re(mt.slice(1)), ...Re(mt[0] === "v" ? "" : mt[0])]), 2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0), de = new WebAssembly.Module(qt), ne = new WebAssembly.Instance(de, { e: { f: T } }), Le = ne.exports.f;
48316
48360
  return Le;
48317
- }, Yt, or = (T) => Yt.get(T), dr = (T, pt) => {
48361
+ }, Yt, or = (T) => Yt.get(T), dr = (T, mt) => {
48318
48362
  if (Ke)
48319
- for (var qt = T; qt < T + pt; qt++) {
48363
+ for (var qt = T; qt < T + mt; qt++) {
48320
48364
  var de = or(qt);
48321
48365
  de && Ke.set(de, qt);
48322
48366
  }
48323
- }, Ke, ke = (T) => (Ke || (Ke = /* @__PURE__ */ new WeakMap(), dr(0, Yt.length)), Ke.get(T) || 0), Ie = [], Un = () => Ie.length ? Ie.pop() : Yt.grow(1), $i = (T, pt) => Yt.set(T, pt), Li = (T, pt) => {
48367
+ }, Ke, ke = (T) => (Ke || (Ke = /* @__PURE__ */ new WeakMap(), dr(0, Yt.length)), Ke.get(T) || 0), Ie = [], Un = () => Ie.length ? Ie.pop() : Yt.grow(1), $i = (T, mt) => Yt.set(T, mt), Li = (T, mt) => {
48324
48368
  var qt = ke(T);
48325
48369
  if (qt)
48326
48370
  return qt;
@@ -48330,7 +48374,7 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48330
48374
  } catch (Le) {
48331
48375
  if (!(Le instanceof TypeError))
48332
48376
  throw Le;
48333
- var ne = Xt(T, pt);
48377
+ var ne = Xt(T, mt);
48334
48378
  $i(de, ne);
48335
48379
  }
48336
48380
  return Ke.set(T, de), de;
@@ -48364,8 +48408,8 @@ var TU = Ge({ "node_modules/.pnpm/harfbuzzjs@0.4.12/node_modules/harfbuzzjs/hb.j
48364
48408
  for (typeof s.preInit == "function" && (s.preInit = [s.preInit]); s.preInit.length > 0; )
48365
48409
  s.preInit.shift()();
48366
48410
  }
48367
- return jn(), Zi(), Z ? a = s : a = new Promise((T, pt) => {
48368
- S = T, _ = pt;
48411
+ return jn(), Zi(), Z ? a = s : a = new Promise((T, mt) => {
48412
+ S = T, _ = mt;
48369
48413
  }), a;
48370
48414
  };
48371
48415
  })();