@waveform-playlist/browser 5.0.0-alpha.18 → 5.0.0-alpha.19

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/index.mjs CHANGED
@@ -2,7 +2,7 @@ import * as Rr from "tone";
2
2
  import { Volume as An, getDestination as kn, start as Sn, now as At, getTransport as lt, getContext as Ae, Context as Er, setContext as Wr, Panner as _r, Gain as rn, Player as an, Analyser as $n, Meter as Fr, connect as Zr, StereoWidener as Vr, Gate as Pr, Limiter as zr, Compressor as Hr, Chebyshev as Xr, BitCrusher as Gr, Distortion as Nr, EQ3 as Lr, AutoWah as Yr, AutoFilter as Or, AutoPanner as Kr, Vibrato as Ur, Tremolo as jr, Phaser as Jr, Chorus as Qr, PingPongDelay as qr, FeedbackDelay as ea, JCReverb as ta, Freeverb as na, Reverb as ra } from "tone";
3
3
  import { jsx as I, jsxs as ne, Fragment as ot } from "react/jsx-runtime";
4
4
  import * as L from "react";
5
- import _e, { createContext as De, useContext as Re, useState as W, useEffect as J, Fragment as aa, useRef as R, useCallback as D, useLayoutEffect as oa, useMemo as at } from "react";
5
+ import _e, { createContext as Be, useContext as Re, useState as W, useEffect as J, Fragment as aa, useRef as R, useCallback as D, useLayoutEffect as oa, useMemo as at } from "react";
6
6
  import S, { withTheme as Mn, ThemeContext as sa, useTheme as ia, ThemeProvider as Bn } from "styled-components";
7
7
  import { useDraggable as ht, useSensor as Zt, MouseSensor as la, TouchSensor as ca, PointerSensor as ua, useSensors as da, DndContext as ma } from "@dnd-kit/core";
8
8
  import { restrictToHorizontalAxis as fa } from "@dnd-kit/modifiers";
@@ -469,7 +469,7 @@ const Ht = /* @__PURE__ */ Object.freeze({
469
469
  "thin",
470
470
  /* @__PURE__ */ L.createElement(L.Fragment, null, /* @__PURE__ */ L.createElement("path", { d: "M153.76,28.41a4,4,0,0,0-4.22.43L78.63,84H32A12,12,0,0,0,20,96v64a12,12,0,0,0,12,12H78.63l70.91,55.16A4.07,4.07,0,0,0,152,228a3.92,3.92,0,0,0,1.76-.41A4,4,0,0,0,156,224V32A4,4,0,0,0,153.76,28.41ZM28,160V96a4,4,0,0,1,4-4H76v72H32A4,4,0,0,1,28,160Zm120,55.82L84,166V90l64-49.78ZM204,128a36,36,0,0,1-9,23.82,4,4,0,1,1-6-5.3,28,28,0,0,0,0-37,4,4,0,0,1,6-5.28A36,36,0,0,1,204,128Z" }))
471
471
  ]
472
- ]), xa = De({
472
+ ]), xa = Be({
473
473
  color: "currentColor",
474
474
  size: "1em",
475
475
  weight: "regular",
@@ -937,12 +937,12 @@ var $a = S.canvas.attrs((e) => ({
937
937
  );
938
938
  oa(() => {
939
939
  const w = b.current, y = u + g;
940
- let k = 0;
940
+ let A = 0;
941
941
  for (let $ = 0; $ < w.length; $++) {
942
- const A = w[$], B = A.getContext("2d"), M = Math.floor(i / 2), _ = 2 ** (n - 1);
942
+ const k = w[$], B = k.getContext("2d"), M = Math.floor(i / 2), _ = 2 ** (n - 1);
943
943
  if (B) {
944
- B.resetTransform(), B.clearRect(0, 0, A.width, A.height), B.imageSmoothingEnabled = !1, B.scale(o, o);
945
- const T = A.width / o;
944
+ B.resetTransform(), B.clearRect(0, 0, k.width, k.height), B.imageSmoothingEnabled = !1, B.scale(o, o);
945
+ const T = k.width / o;
946
946
  let z;
947
947
  d === "normal" ? z = c : z = l, B.fillStyle = Sa(
948
948
  B,
@@ -950,18 +950,18 @@ var $a = S.canvas.attrs((e) => ({
950
950
  T,
951
951
  i
952
952
  );
953
- const P = k, Z = k + T, O = Math.floor((P - u + y) / y) * y;
954
- for (let X = Math.max(0, O); X < Z; X += y) {
955
- const V = X - P;
953
+ const P = A, Z = A + T, Y = Math.floor((P - u + y) / y) * y;
954
+ for (let G = Math.max(0, Y); G < Z; G += y) {
955
+ const V = G - P;
956
956
  if (V + u <= 0) continue;
957
- const Q = X;
957
+ const Q = G;
958
958
  if (Q * 2 + 1 < t.length) {
959
- const ie = t[Q * 2] / _, oe = t[Q * 2 + 1] / _, te = Math.abs(ie * M), se = Math.abs(oe * M);
960
- d === "normal" ? B.fillRect(V, M - se, u, se + te) : (B.fillRect(V, 0, u, M - se), B.fillRect(V, M + te, u, M - te));
959
+ const ie = t[Q * 2] / _, oe = t[Q * 2 + 1] / _, ee = Math.abs(ie * M), se = Math.abs(oe * M);
960
+ d === "normal" ? B.fillRect(V, M - se, u, se + ee) : (B.fillRect(V, 0, u, M - se), B.fillRect(V, M + ee, u, M - ee));
961
961
  }
962
962
  }
963
963
  }
964
- k += A.width / o;
964
+ A += k.width / o;
965
965
  }
966
966
  }, [
967
967
  t,
@@ -1238,29 +1238,29 @@ var un = ({
1238
1238
  showFades: x = !1,
1239
1239
  touchOptimized: v = !1
1240
1240
  }) => {
1241
- const f = Math.floor(o / l), y = Math.floor((o + i) / l) - f, k = c && !u && !g, $ = `clip-${r}-${a}`, { attributes: A, listeners: B, setNodeRef: M, setActivatorNodeRef: _, transform: T, isDragging: z } = ht({
1241
+ const f = Math.floor(o / l), y = Math.floor((o + i) / l) - f, A = c && !u && !g, $ = `clip-${r}-${a}`, { attributes: k, listeners: B, setNodeRef: M, setActivatorNodeRef: _, transform: T, isDragging: z } = ht({
1242
1242
  id: $,
1243
1243
  data: { clipId: n, trackIndex: r, clipIndex: a },
1244
- disabled: !k
1244
+ disabled: !A
1245
1245
  }), P = `clip-boundary-left-${r}-${a}`, {
1246
1246
  attributes: Z,
1247
- listeners: O,
1248
- setActivatorNodeRef: X,
1247
+ listeners: Y,
1248
+ setActivatorNodeRef: G,
1249
1249
  isDragging: V
1250
1250
  } = ht({
1251
1251
  id: P,
1252
1252
  data: { clipId: n, trackIndex: r, clipIndex: a, boundary: "left" },
1253
- disabled: !k
1253
+ disabled: !A
1254
1254
  }), Q = `clip-boundary-right-${r}-${a}`, {
1255
1255
  attributes: ie,
1256
1256
  listeners: oe,
1257
- setActivatorNodeRef: te,
1257
+ setActivatorNodeRef: ee,
1258
1258
  isDragging: se
1259
1259
  } = ht({
1260
1260
  id: Q,
1261
1261
  data: { clipId: n, trackIndex: r, clipIndex: a, boundary: "right" },
1262
- disabled: !k
1263
- }), ye = T ? {
1262
+ disabled: !A
1263
+ }), Ce = T ? {
1264
1264
  transform: Ht.Translate.toString(T),
1265
1265
  zIndex: z ? 100 : void 0
1266
1266
  // Below controls (z-index: 999) but above other clips
@@ -1269,7 +1269,7 @@ var un = ({
1269
1269
  Va,
1270
1270
  {
1271
1271
  ref: M,
1272
- style: ye,
1272
+ style: Ce,
1273
1273
  className: t,
1274
1274
  $left: f,
1275
1275
  $width: y,
@@ -1287,7 +1287,7 @@ var un = ({
1287
1287
  trackName: s,
1288
1288
  isSelected: h,
1289
1289
  disableDrag: u,
1290
- dragHandleProps: k ? { attributes: A, listeners: B, setActivatorNodeRef: _ } : void 0
1290
+ dragHandleProps: A ? { attributes: k, listeners: B, setActivatorNodeRef: _ } : void 0
1291
1291
  }
1292
1292
  ),
1293
1293
  /* @__PURE__ */ ne(Pa, { $isOverlay: g, children: [
@@ -1322,8 +1322,8 @@ var un = ({
1322
1322
  touchOptimized: v,
1323
1323
  dragHandleProps: {
1324
1324
  attributes: Z,
1325
- listeners: O,
1326
- setActivatorNodeRef: X,
1325
+ listeners: Y,
1326
+ setActivatorNodeRef: G,
1327
1327
  isDragging: V
1328
1328
  }
1329
1329
  }
@@ -1339,7 +1339,7 @@ var un = ({
1339
1339
  dragHandleProps: {
1340
1340
  attributes: ie,
1341
1341
  listeners: oe,
1342
- setActivatorNodeRef: te,
1342
+ setActivatorNodeRef: ee,
1343
1343
  isDragging: se
1344
1344
  }
1345
1345
  }
@@ -1624,12 +1624,12 @@ var dn = S.div.attrs((e) => ({
1624
1624
  const [c, u] = W(null), g = R(0), h = R(0), d = R(0), b = Math.max(0, t - e), C = D((p, x) => {
1625
1625
  p.preventDefault(), p.stopPropagation(), u(x), g.current = p.clientX, h.current = x === "start" ? e : t;
1626
1626
  const v = (w) => {
1627
- const y = w.clientX - g.current, k = h.current + y;
1627
+ const y = w.clientX - g.current, A = h.current + y;
1628
1628
  if (x === "start") {
1629
- const $ = Math.max(i, Math.min(t - 10, k));
1629
+ const $ = Math.max(i, Math.min(t - 10, A));
1630
1630
  a?.($);
1631
1631
  } else {
1632
- const $ = Math.max(e + 10, Math.min(l, k));
1632
+ const $ = Math.max(e + 10, Math.min(l, A));
1633
1633
  s?.($);
1634
1634
  }
1635
1635
  }, f = () => {
@@ -1640,8 +1640,8 @@ var dn = S.div.attrs((e) => ({
1640
1640
  p.preventDefault(), p.stopPropagation(), u("region"), g.current = p.clientX, h.current = e, d.current = t;
1641
1641
  const x = t - e, v = (w) => {
1642
1642
  const y = w.clientX - g.current;
1643
- let k = h.current + y, $ = d.current + y;
1644
- k < i && (k = i, $ = i + x), $ > l && ($ = l, k = l - x), o?.(k, $);
1643
+ let A = h.current + y, $ = d.current + y;
1644
+ A < i && (A = i, $ = i + x), $ > l && ($ = l, A = l - x), o?.(A, $);
1645
1645
  }, f = () => {
1646
1646
  u(null), document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", f);
1647
1647
  };
@@ -1713,8 +1713,8 @@ var dn = S.div.attrs((e) => ({
1713
1713
  const p = b.clientX - m.left, x = Math.max(s, Math.min(o, p));
1714
1714
  u.current = x, a?.(x, x);
1715
1715
  const v = (w) => {
1716
- const y = w.clientX - m.left, k = Math.max(s, Math.min(o, y)), $ = Math.min(u.current, k), A = Math.max(u.current, k);
1717
- a?.($, A);
1716
+ const y = w.clientX - m.left, A = Math.max(s, Math.min(o, y)), $ = Math.min(u.current, A), k = Math.max(u.current, A);
1717
+ a?.($, k);
1718
1718
  }, f = () => {
1719
1719
  c(!1), document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", f);
1720
1720
  };
@@ -1871,7 +1871,7 @@ var mn = ({
1871
1871
  function kt() {
1872
1872
  return window.devicePixelRatio;
1873
1873
  }
1874
- var Gn = De(kt()), Nn = ({ children: e }) => {
1874
+ var Gn = Be(kt()), Nn = ({ children: e }) => {
1875
1875
  const [t, n] = W(kt());
1876
1876
  return matchMedia(`(resolution: ${kt()}dppx)`).addEventListener(
1877
1877
  "change",
@@ -1880,7 +1880,7 @@ var Gn = De(kt()), Nn = ({ children: e }) => {
1880
1880
  },
1881
1881
  { once: !0 }
1882
1882
  ), /* @__PURE__ */ I(Gn.Provider, { value: Math.ceil(t), children: e });
1883
- }, Ln = () => Re(Gn), Tt = De({
1883
+ }, Ln = () => Re(Gn), Tt = Be({
1884
1884
  sampleRate: 48e3,
1885
1885
  samplesPerPixel: 1e3,
1886
1886
  zoomLevels: [1e3, 1500, 2e3, 2500],
@@ -1893,14 +1893,14 @@ var Gn = De(kt()), Nn = ({ children: e }) => {
1893
1893
  duration: 3e4,
1894
1894
  barWidth: 1,
1895
1895
  barGap: 0
1896
- }), pt = () => Re(Tt), gt = () => Re(sa), Ut = De(/* @__PURE__ */ I(aa, {})), to = () => Re(Ut), no = 0, ro = !1, ao = 0, oo = 0, so = {
1896
+ }), pt = () => Re(Tt), gt = () => Re(sa), Ut = Be(/* @__PURE__ */ I(aa, {})), to = () => Re(Ut), no = 0, ro = !1, ao = 0, oo = 0, so = {
1897
1897
  progress: no,
1898
1898
  isPlaying: ro,
1899
1899
  selectionStart: ao,
1900
1900
  selectionEnd: oo
1901
1901
  };
1902
- De(so);
1903
- De({
1902
+ Be(so);
1903
+ Be({
1904
1904
  setIsPlaying: () => {
1905
1905
  },
1906
1906
  setProgress: () => {
@@ -1984,8 +1984,8 @@ var co = S.div.attrs((e) => ({
1984
1984
  if (f) {
1985
1985
  f.resetTransform(), f.clearRect(0, 0, v.width, v.height), f.imageSmoothingEnabled = !1, f.fillStyle = t, f.scale(C, C);
1986
1986
  for (const [w, y] of i.entries()) {
1987
- const k = h - y;
1988
- f.fillRect(w, k, 1, y);
1987
+ const A = h - y;
1988
+ f.fillRect(w, A, 1, y);
1989
1989
  }
1990
1990
  }
1991
1991
  }
@@ -2004,8 +2004,8 @@ var co = S.div.attrs((e) => ({
2004
2004
  for (let v = 0; v < m; v += p * s / 1e3) {
2005
2005
  const f = Math.floor(v);
2006
2006
  if (x % r === 0) {
2007
- const w = x, y = lo(w), k = o ? /* @__PURE__ */ I(_e.Fragment, { children: o(w, f) }, `timestamp-${x}`) : /* @__PURE__ */ I(mo, { $left: f, children: y }, y);
2008
- l.push(k), i.set(f, h);
2007
+ const w = x, y = lo(w), A = o ? /* @__PURE__ */ I(_e.Fragment, { children: o(w, f) }, `timestamp-${x}`) : /* @__PURE__ */ I(mo, { $left: f, children: y }, y);
2008
+ l.push(A), i.set(f, h);
2009
2009
  } else x % a === 0 ? i.set(f, Math.floor(h / 2)) : x % s === 0 && i.set(f, Math.floor(h / 5));
2010
2010
  x += s;
2011
2011
  }
@@ -2443,15 +2443,15 @@ function Wo(e) {
2443
2443
  for (var w = 0; w < a; w++) {
2444
2444
  var y = 0;
2445
2445
  if (i === 1) {
2446
- for (var k = 0; k < o.length; ++k)
2447
- y += o[k][w];
2446
+ for (var A = 0; A < o.length; ++A)
2447
+ y += o[A][w];
2448
2448
  y = Math.floor(f * y * n / o.length), y < m[0] && (m[0] = y, m[0] < v && (m[0] = v)), y > p[0] && (p[0] = y, p[0] > f && (p[0] = f));
2449
2449
  } else
2450
2450
  for (var $ = 0; $ < i; ++$)
2451
2451
  y = Math.floor(f * o[$][w] * n), y < m[$] && (m[$] = y, m[$] < v && (m[$] = v)), y > p[$] && (p[$] = y, p[$] > f && (p[$] = f));
2452
2452
  if (++b === t) {
2453
- for (var A = 0; A < i; A++)
2454
- e.bits === 8 ? (d.setInt8(C++, m[A]), d.setInt8(C++, p[A])) : (d.setInt16(C, m[A], !0), d.setInt16(C + 2, p[A], !0), C += 4), m[A] = 1 / 0, p[A] = -1 / 0;
2453
+ for (var k = 0; k < i; k++)
2454
+ e.bits === 8 ? (d.setInt8(C++, m[k]), d.setInt8(C++, p[k])) : (d.setInt16(C, m[k], !0), d.setInt16(C + 2, p[k], !0), C += 4), m[k] = 1 / 0, p[k] = -1 / 0;
2455
2455
  b = 0;
2456
2456
  }
2457
2457
  }
@@ -3090,8 +3090,8 @@ var Oo = S.div.attrs((e) => ({
3090
3090
  });
3091
3091
  if (c <= 0)
3092
3092
  return null;
3093
- const f = (y) => (k) => {
3094
- k.stopPropagation(), y?.(k);
3093
+ const f = (y) => (A) => {
3094
+ A.stopPropagation(), y?.(A);
3095
3095
  }, w = (y) => {
3096
3096
  y.stopPropagation();
3097
3097
  };
@@ -3342,18 +3342,18 @@ var qo = S.div`
3342
3342
  if (!s || !u) return;
3343
3343
  const y = w.trim();
3344
3344
  if (!y) return;
3345
- const k = [...e];
3346
- k[f] = {
3347
- ...k[f],
3345
+ const A = [...e];
3346
+ A[f] = {
3347
+ ...A[f],
3348
3348
  id: y
3349
- }, u(k);
3349
+ }, u(A);
3350
3350
  }, x = (f, w, y) => {
3351
3351
  if (!u) return;
3352
- const k = [...e];
3353
- f.action(k[y], y, k, i || {}), u(k);
3352
+ const A = [...e];
3353
+ f.action(A[y], y, A, i || {}), u(A);
3354
3354
  }, v = (f) => f.replace(/\./g, " ");
3355
3355
  return /* @__PURE__ */ I(qo, { ref: d, $height: l, children: e.map((f, w) => {
3356
- const y = f.id === t, k = () => c?.(f);
3356
+ const y = f.id === t, A = () => c?.(f);
3357
3357
  return g ? /* @__PURE__ */ I(
3358
3358
  "div",
3359
3359
  {
@@ -3362,7 +3362,7 @@ var qo = S.div`
3362
3362
  annotation: f,
3363
3363
  index: w,
3364
3364
  isActive: y,
3365
- onClick: k,
3365
+ onClick: A,
3366
3366
  formatTime: C
3367
3367
  })
3368
3368
  },
@@ -3372,7 +3372,7 @@ var qo = S.div`
3372
3372
  {
3373
3373
  ref: y ? h : null,
3374
3374
  $isActive: y,
3375
- onClick: k,
3375
+ onClick: A,
3376
3376
  children: [
3377
3377
  /* @__PURE__ */ ne(ts, { children: [
3378
3378
  /* @__PURE__ */ ne(ns, { children: [
@@ -3392,14 +3392,14 @@ var qo = S.div`
3392
3392
  C(f.end)
3393
3393
  ] })
3394
3394
  ] }),
3395
- o.length > 0 && /* @__PURE__ */ I(os, { onClick: ($) => $.stopPropagation(), children: o.map(($, A) => /* @__PURE__ */ I(
3395
+ o.length > 0 && /* @__PURE__ */ I(os, { onClick: ($) => $.stopPropagation(), children: o.map(($, k) => /* @__PURE__ */ I(
3396
3396
  ss,
3397
3397
  {
3398
3398
  title: $.title,
3399
3399
  onClick: () => x($, f, w),
3400
3400
  children: $.text ? $.text : /* @__PURE__ */ I("i", { className: v($.class || "") })
3401
3401
  },
3402
- A
3402
+ k
3403
3403
  )) })
3404
3404
  ] }),
3405
3405
  /* @__PURE__ */ I(
@@ -3714,28 +3714,28 @@ function bi(e, t = {}) {
3714
3714
  o(!0), l(null), u(0);
3715
3715
  const m = Rr.getContext().rawContext, p = e.map(async (v, f) => {
3716
3716
  if (v.audioBuffer) {
3717
- const A = b(v, f, v.audioBuffer);
3718
- return n && !h && (d.set(f, A), u((B) => B + 1), a(
3717
+ const k = b(v, f, v.audioBuffer);
3718
+ return n && !h && (d.set(f, k), u((B) => B + 1), a(
3719
3719
  Array.from({ length: e.length }, (B, M) => d.get(M)).filter((B) => B !== void 0)
3720
- )), A;
3720
+ )), k;
3721
3721
  }
3722
3722
  if (!v.src && v.waveformData) {
3723
- const A = b(v, f);
3724
- return n && !h && (d.set(f, A), u((B) => B + 1), a(
3723
+ const k = b(v, f);
3724
+ return n && !h && (d.set(f, k), u((B) => B + 1), a(
3725
3725
  Array.from({ length: e.length }, (B, M) => d.get(M)).filter((B) => B !== void 0)
3726
- )), A;
3726
+ )), k;
3727
3727
  }
3728
3728
  if (!v.src)
3729
3729
  throw new Error(`Track ${f + 1}: Must provide src, audioBuffer, or waveformData`);
3730
3730
  const w = await fetch(v.src);
3731
3731
  if (!w.ok)
3732
3732
  throw new Error(`Failed to fetch ${v.src}: ${w.statusText}`);
3733
- const y = await w.arrayBuffer(), k = await m.decodeAudioData(y);
3734
- if (!k || !k.sampleRate || !k.duration)
3733
+ const y = await w.arrayBuffer(), A = await m.decodeAudioData(y);
3734
+ if (!A || !A.sampleRate || !A.duration)
3735
3735
  throw new Error(`Invalid audio buffer for ${v.src}`);
3736
- const $ = b(v, f, k);
3737
- return n && !h && (d.set(f, $), u((A) => A + 1), a(
3738
- Array.from({ length: e.length }, (A, B) => d.get(B)).filter((A) => A !== void 0)
3736
+ const $ = b(v, f, A);
3737
+ return n && !h && (d.set(f, $), u((k) => k + 1), a(
3738
+ Array.from({ length: e.length }, (k, B) => d.get(B)).filter((k) => k !== void 0)
3739
3739
  )), $;
3740
3740
  }), x = await Promise.all(p);
3741
3741
  h || (n || (a(x), u(x.length)), o(!1));
@@ -3771,9 +3771,9 @@ function vi({
3771
3771
  let f = p + v;
3772
3772
  const w = [...C.clips].sort((M, _) => M.startSample - _.startSample), y = w.findIndex((M) => M === m);
3773
3773
  f = Math.max(0, f);
3774
- const k = y > 0 ? w[y - 1] : null;
3775
- if (k) {
3776
- const M = (k.startSample + k.durationSamples) / r;
3774
+ const A = y > 0 ? w[y - 1] : null;
3775
+ if (A) {
3776
+ const M = (A.startSample + A.durationSamples) / r;
3777
3777
  f = Math.max(f, M);
3778
3778
  }
3779
3779
  const $ = y < w.length - 1 ? w[y + 1] : null;
@@ -3811,8 +3811,8 @@ function vi({
3811
3811
  if (!h || !a.current) return;
3812
3812
  const { trackIndex: d, clipIndex: b } = u.data.current, C = g.x * n, m = Math.floor(0.1 * r), p = a.current, x = e.map((v, f) => {
3813
3813
  if (f !== d) return v;
3814
- const w = [...v.clips].sort(($, A) => $.startSample - A.startSample), y = w.findIndex(($) => $ === v.clips[b]), k = v.clips.map(($, A) => {
3815
- if (A !== b) return $;
3814
+ const w = [...v.clips].sort(($, k) => $.startSample - k.startSample), y = w.findIndex(($) => $ === v.clips[b]), A = v.clips.map(($, k) => {
3815
+ if (k !== b) return $;
3816
3816
  const B = $.sourceDurationSamples;
3817
3817
  if (h === "left") {
3818
3818
  let M = Math.floor(C);
@@ -3827,12 +3827,12 @@ function vi({
3827
3827
  }
3828
3828
  const P = p.durationSamples - m;
3829
3829
  M > P && (M = P);
3830
- const Z = p.offsetSamples + M, O = p.durationSamples - M, X = p.startSample + M;
3830
+ const Z = p.offsetSamples + M, Y = p.durationSamples - M, G = p.startSample + M;
3831
3831
  return {
3832
3832
  ...$,
3833
3833
  offsetSamples: Z,
3834
- durationSamples: O,
3835
- startSample: X
3834
+ durationSamples: Y,
3835
+ startSample: G
3836
3836
  };
3837
3837
  } else {
3838
3838
  let M = Math.floor(p.durationSamples + C);
@@ -3841,7 +3841,7 @@ function vi({
3841
3841
  return _ && p.startSample + M > _.startSample && (M = _.startSample - p.startSample, M = Math.max(m, M)), { ...$, durationSamples: M };
3842
3842
  }
3843
3843
  });
3844
- return { ...v, clips: k };
3844
+ return { ...v, clips: A };
3845
3845
  });
3846
3846
  t(x);
3847
3847
  },
@@ -3855,13 +3855,13 @@ function vi({
3855
3855
  }
3856
3856
  const m = e.map((p, x) => {
3857
3857
  if (x !== h) return p;
3858
- const v = [...p.clips].sort((y, k) => y.startSample - k.startSample), f = v.findIndex((y) => y === p.clips[d]), w = p.clips.map((y, k) => {
3859
- if (k !== d) return y;
3858
+ const v = [...p.clips].sort((y, A) => y.startSample - A.startSample), f = v.findIndex((y) => y === p.clips[d]), w = p.clips.map((y, A) => {
3859
+ if (A !== d) return y;
3860
3860
  let $ = Math.floor(y.startSample + C);
3861
3861
  $ = Math.max(0, $);
3862
- const A = f > 0 ? v[f - 1] : null;
3863
- if (A) {
3864
- const M = A.startSample + A.durationSamples;
3862
+ const k = f > 0 ? v[f - 1] : null;
3863
+ if (k) {
3864
+ const M = k.startSample + k.durationSamples;
3865
3865
  $ = Math.max($, M);
3866
3866
  }
3867
3867
  const B = f < v.length - 1 ? v[f + 1] : null;
@@ -4053,7 +4053,7 @@ const Ci = (e) => {
4053
4053
  const C = b.startSample / g, m = (b.startSample + b.durationSamples) / g;
4054
4054
  if (u <= C || u >= m)
4055
4055
  return console.warn("Split time is outside clip bounds"), !1;
4056
- const p = Math.round(u * g), x = Math.floor(p / h), v = b.startSample + b.durationSamples, f = x * h, w = b.startSample, y = f - w, k = f, $ = v - k, A = f - b.startSample, B = Gt({
4056
+ const p = Math.round(u * g), x = Math.floor(p / h), v = b.startSample + b.durationSamples, f = x * h, w = b.startSample, y = f - w, A = f, $ = v - A, k = f - b.startSample, B = Gt({
4057
4057
  audioBuffer: b.audioBuffer,
4058
4058
  startSample: w,
4059
4059
  durationSamples: y,
@@ -4069,9 +4069,9 @@ const Ci = (e) => {
4069
4069
  // Note: fadeOut removed for first clip since it's cut
4070
4070
  }), M = Gt({
4071
4071
  audioBuffer: b.audioBuffer,
4072
- startSample: k,
4072
+ startSample: A,
4073
4073
  durationSamples: $,
4074
- offsetSamples: b.offsetSamples + A,
4074
+ offsetSamples: b.offsetSamples + k,
4075
4075
  sampleRate: b.sampleRate,
4076
4076
  sourceDurationSamples: b.sourceDurationSamples,
4077
4077
  gain: b.gain,
@@ -4133,7 +4133,7 @@ const Ci = (e) => {
4133
4133
  const t = [], n = typeof navigator < "u" && navigator.platform.includes("Mac");
4134
4134
  return e.metaKey && t.push(n ? "Cmd" : "Ctrl"), e.ctrlKey && !e.metaKey && t.push("Ctrl"), e.altKey && t.push(n ? "Option" : "Alt"), e.shiftKey && t.push("Shift"), t.push(e.key.toUpperCase()), t.join("+");
4135
4135
  }, xi = (e = {}) => {
4136
- const { enabled: t = !0, additionalShortcuts: n = [], shortcuts: r } = e, { isPlaying: a } = Fe(), { setCurrentTime: s, play: o, pause: i, stop: l } = ve(), { playoutRef: c } = Te(), u = D(() => {
4136
+ const { enabled: t = !0, additionalShortcuts: n = [], shortcuts: r } = e, { isPlaying: a } = Fe(), { setCurrentTime: s, play: o, pause: i, stop: l } = be(), { playoutRef: c } = De(), u = D(() => {
4137
4137
  a ? i() : o();
4138
4138
  }, [a, o, i]), g = D(() => {
4139
4139
  l();
@@ -4184,13 +4184,13 @@ function Ii({
4184
4184
  controlsWidth: g = 0,
4185
4185
  onPlay: h
4186
4186
  }) {
4187
- const d = at(() => t ? e.findIndex((A) => A.id === t) : -1, [e, t]), b = D(
4188
- (A) => {
4187
+ const d = at(() => t ? e.findIndex((k) => k.id === t) : -1, [e, t]), b = D(
4188
+ (k) => {
4189
4189
  if (!l?.current || !c || !u) return;
4190
- const B = e.find((V) => V.id === A);
4190
+ const B = e.find((V) => V.id === k);
4191
4191
  if (!B) return;
4192
- const M = l.current, _ = M.clientWidth, T = B.start * u / c + g, z = B.end * u / c + g, P = (T + z) / 2, Z = M.scrollLeft, O = Z, X = Z + _;
4193
- if (T < O || z > X) {
4192
+ const M = l.current, _ = M.clientWidth, T = B.start * u / c + g, z = B.end * u / c + g, P = (T + z) / 2, Z = M.scrollLeft, Y = Z, G = Z + _;
4193
+ if (T < Y || z > G) {
4194
4194
  const V = Math.max(0, P - _ / 2);
4195
4195
  M.scrollTo({
4196
4196
  left: V,
@@ -4204,9 +4204,9 @@ function Ii({
4204
4204
  t && l?.current && c && u && b(t);
4205
4205
  }, [t, b, l, c, u]);
4206
4206
  const C = D(
4207
- (A) => {
4207
+ (k) => {
4208
4208
  if (d < 0) return;
4209
- const B = e[d], M = Math.max(0, Math.min(B.end - 0.1, B.start + A)), _ = M - B.start, T = [...e];
4209
+ const B = e[d], M = Math.max(0, Math.min(B.end - 0.1, B.start + k)), _ = M - B.start, T = [...e];
4210
4210
  if (T[d] = {
4211
4211
  ...B,
4212
4212
  start: M
@@ -4227,9 +4227,9 @@ function Ii({
4227
4227
  },
4228
4228
  [e, d, s, n]
4229
4229
  ), m = D(
4230
- (A) => {
4230
+ (k) => {
4231
4231
  if (d < 0) return;
4232
- const B = e[d], M = Math.max(B.start + 0.1, Math.min(a, B.end + A)), _ = M - B.end, T = [...e];
4232
+ const B = e[d], M = Math.max(B.start + 0.1, Math.min(a, B.end + k)), _ = M - B.end, T = [...e];
4233
4233
  if (T[d] = {
4234
4234
  ...B,
4235
4235
  end: M
@@ -4243,12 +4243,12 @@ function Ii({
4243
4243
  };
4244
4244
  let Z = d + 1;
4245
4245
  for (; Z < T.length - 1; ) {
4246
- const O = T[Z], X = T[Z + 1];
4247
- if (Math.abs(X.start - e[Z].end) < zt) {
4248
- const V = O.end - e[Z].end;
4246
+ const Y = T[Z], G = T[Z + 1];
4247
+ if (Math.abs(G.start - e[Z].end) < zt) {
4248
+ const V = Y.end - e[Z].end;
4249
4249
  T[Z + 1] = {
4250
- ...X,
4251
- start: Math.min(X.end - 0.1, X.start + V)
4250
+ ...G,
4251
+ start: Math.min(G.end - 0.1, G.start + V)
4252
4252
  }, Z++;
4253
4253
  } else
4254
4254
  break;
@@ -4263,10 +4263,10 @@ function Ii({
4263
4263
  };
4264
4264
  let P = d + 1;
4265
4265
  for (; P < T.length - 1; ) {
4266
- const Z = T[P], O = T[P + 1];
4267
- if (Z.end > O.start)
4266
+ const Z = T[P], Y = T[P + 1];
4267
+ if (Z.end > Y.start)
4268
4268
  T[P + 1] = {
4269
- ...O,
4269
+ ...Y,
4270
4270
  start: Z.end
4271
4271
  }, P++;
4272
4272
  else
@@ -4289,9 +4289,9 @@ function Ii({
4289
4289
  r && r(null);
4290
4290
  }, [r]), y = D(() => {
4291
4291
  if (d < 0 || !h) return;
4292
- const A = e[d], B = o ? void 0 : A.end - A.start;
4293
- h(A.start, B);
4294
- }, [e, d, o, h]), k = at(
4292
+ const k = e[d], B = o ? void 0 : k.end - k.start;
4293
+ h(k.start, B);
4294
+ }, [e, d, o, h]), A = at(
4295
4295
  () => [
4296
4296
  {
4297
4297
  key: "[",
@@ -4375,7 +4375,7 @@ function Ii({
4375
4375
  [p, x, v, f, w]
4376
4376
  );
4377
4377
  return Nt({
4378
- shortcuts: k,
4378
+ shortcuts: A,
4379
4379
  enabled: i && d >= 0
4380
4380
  }), Nt({
4381
4381
  shortcuts: $,
@@ -4442,7 +4442,7 @@ function ks(e, t = {}) {
4442
4442
  const {
4443
4443
  channelCount: n = 1,
4444
4444
  samplesPerPixel: r = 1024
4445
- } = t, [a, s] = W(!1), [o, i] = W(!1), [l, c] = W(0), [u, g] = W(new Int16Array(0)), [h, d] = W(null), [b, C] = W(null), [m, p] = W(0), [x, v] = W(0), f = 16, w = R(!1), y = R(null), k = R(null), $ = R([]), A = R(0), B = R(null), M = R(0), _ = R(!1), T = R(!1), z = D(async () => {
4445
+ } = t, [a, s] = W(!1), [o, i] = W(!1), [l, c] = W(0), [u, g] = W(new Int16Array(0)), [h, d] = W(null), [b, C] = W(null), [m, p] = W(0), [x, v] = W(0), f = 16, w = R(!1), y = R(null), A = R(null), $ = R([]), k = R(0), B = R(null), M = R(0), _ = R(!1), T = R(!1), z = D(async () => {
4446
4446
  if (!w.current)
4447
4447
  try {
4448
4448
  const V = Ae(), Q = new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw", import.meta.url).href;
@@ -4460,16 +4460,16 @@ function ks(e, t = {}) {
4460
4460
  const V = Ae();
4461
4461
  V.state === "suspended" && await V.resume(), await z();
4462
4462
  const Q = V.createMediaStreamSource(e);
4463
- k.current = Q;
4463
+ A.current = Q;
4464
4464
  const ie = V.createAudioWorkletNode("recording-processor");
4465
- y.current = ie, Q.connect(ie), ie.port.onmessage = (te) => {
4466
- const { samples: se } = te.data;
4467
- $.current.push(se), A.current += se.length, g(
4468
- (ye) => As(
4469
- ye,
4465
+ y.current = ie, Q.connect(ie), ie.port.onmessage = (ee) => {
4466
+ const { samples: se } = ee.data;
4467
+ $.current.push(se), k.current += se.length, g(
4468
+ (Ce) => As(
4469
+ Ce,
4470
4470
  se,
4471
4471
  r,
4472
- A.current - se.length,
4472
+ k.current - se.length,
4473
4473
  f
4474
4474
  )
4475
4475
  );
@@ -4477,11 +4477,11 @@ function ks(e, t = {}) {
4477
4477
  command: "start",
4478
4478
  sampleRate: V.sampleRate,
4479
4479
  channelCount: n
4480
- }), $.current = [], A.current = 0, g(new Int16Array(0)), d(null), p(0), v(0), _.current = !0, T.current = !1, s(!0), i(!1), M.current = performance.now();
4480
+ }), $.current = [], k.current = 0, g(new Int16Array(0)), d(null), p(0), v(0), _.current = !0, T.current = !1, s(!0), i(!1), M.current = performance.now();
4481
4481
  const oe = () => {
4482
4482
  if (_.current && !T.current) {
4483
- const te = (performance.now() - M.current) / 1e3;
4484
- c(te), B.current = requestAnimationFrame(oe);
4483
+ const ee = (performance.now() - M.current) / 1e3;
4484
+ c(ee), B.current = requestAnimationFrame(oe);
4485
4485
  }
4486
4486
  };
4487
4487
  oe();
@@ -4493,9 +4493,9 @@ function ks(e, t = {}) {
4493
4493
  return null;
4494
4494
  try {
4495
4495
  if (y.current) {
4496
- if (y.current.port.postMessage({ command: "stop" }), k.current)
4496
+ if (y.current.port.postMessage({ command: "stop" }), A.current)
4497
4497
  try {
4498
- k.current.disconnect(y.current);
4498
+ A.current.disconnect(y.current);
4499
4499
  } catch {
4500
4500
  }
4501
4501
  y.current.disconnect();
@@ -4511,9 +4511,9 @@ function ks(e, t = {}) {
4511
4511
  } catch (V) {
4512
4512
  return console.error("Failed to stop recording:", V), C(V instanceof Error ? V : new Error("Failed to stop recording")), null;
4513
4513
  }
4514
- }, [a, n]), O = D(() => {
4514
+ }, [a, n]), Y = D(() => {
4515
4515
  a && !o && (B.current !== null && (cancelAnimationFrame(B.current), B.current = null), T.current = !0, i(!0));
4516
- }, [a, o]), X = D(() => {
4516
+ }, [a, o]), G = D(() => {
4517
4517
  if (a && o) {
4518
4518
  T.current = !1, i(!1), M.current = performance.now() - l * 1e3;
4519
4519
  const V = () => {
@@ -4527,9 +4527,9 @@ function ks(e, t = {}) {
4527
4527
  }, [a, o, l]);
4528
4528
  return J(() => () => {
4529
4529
  if (y.current) {
4530
- if (y.current.port.postMessage({ command: "stop" }), k.current)
4530
+ if (y.current.port.postMessage({ command: "stop" }), A.current)
4531
4531
  try {
4532
- k.current.disconnect(y.current);
4532
+ A.current.disconnect(y.current);
4533
4533
  } catch {
4534
4534
  }
4535
4535
  y.current.disconnect();
@@ -4545,8 +4545,8 @@ function ks(e, t = {}) {
4545
4545
  peakLevel: x,
4546
4546
  startRecording: P,
4547
4547
  stopRecording: Z,
4548
- pauseRecording: O,
4549
- resumeRecording: X,
4548
+ pauseRecording: Y,
4549
+ resumeRecording: G,
4550
4550
  error: b
4551
4551
  };
4552
4552
  }
@@ -4629,8 +4629,8 @@ function $s(e, t = {}) {
4629
4629
  if (!(!h || !l.current)) {
4630
4630
  if (f - x >= p) {
4631
4631
  x = f;
4632
- const w = l.current.getValue(), y = typeof w == "number" ? w : w[0], k = Math.max(0, Math.min(1, (y + 100) / 100));
4633
- s(k), i(($) => Math.max($, k));
4632
+ const w = l.current.getValue(), y = typeof w == "number" ? w : w[0], A = Math.max(0, Math.min(1, (y + 100) / 100));
4633
+ s(A), i(($) => Math.max($, A));
4634
4634
  }
4635
4635
  u.current = requestAnimationFrame(v);
4636
4636
  }
@@ -4830,26 +4830,26 @@ function Ai(e, t, n, r = {}) {
4830
4830
  duration: f,
4831
4831
  peaks: w,
4832
4832
  startRecording: y,
4833
- stopRecording: k,
4833
+ stopRecording: A,
4834
4834
  pauseRecording: $,
4835
- resumeRecording: A,
4835
+ resumeRecording: k,
4836
4836
  error: B
4837
4837
  } = ks(g, o), M = D(async () => {
4838
4838
  n && (i || (await Vt(), l(!0)), await y());
4839
4839
  }, [n, i, y]), _ = D(async () => {
4840
- const P = await k();
4840
+ const P = await A();
4841
4841
  if (P && n) {
4842
- const Z = e.findIndex((te) => te.id === n);
4842
+ const Z = e.findIndex((ee) => ee.id === n);
4843
4843
  if (Z === -1) return;
4844
- const O = e[Z], X = Math.floor(a * P.sampleRate);
4844
+ const Y = e[Z], G = Math.floor(a * P.sampleRate);
4845
4845
  let V = 0;
4846
- if (O.clips.length > 0) {
4847
- const te = O.clips.map(
4846
+ if (Y.clips.length > 0) {
4847
+ const ee = Y.clips.map(
4848
4848
  (se) => se.startSample + se.durationSamples
4849
4849
  );
4850
- V = Math.max(...te);
4850
+ V = Math.max(...ee);
4851
4851
  }
4852
- const Q = Math.max(X, V), ie = {
4852
+ const Q = Math.max(G, V), ie = {
4853
4853
  id: `clip-${Date.now()}`,
4854
4854
  audioBuffer: P,
4855
4855
  startSample: Q,
@@ -4859,13 +4859,13 @@ function Ai(e, t, n, r = {}) {
4859
4859
  sourceDurationSamples: P.length,
4860
4860
  gain: 1,
4861
4861
  name: `Recording ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`
4862
- }, oe = e.map((te, se) => se === Z ? {
4863
- ...te,
4864
- clips: [...te.clips, ie]
4865
- } : te);
4862
+ }, oe = e.map((ee, se) => se === Z ? {
4863
+ ...ee,
4864
+ clips: [...ee.clips, ie]
4865
+ } : ee);
4866
4866
  t(oe);
4867
4867
  }
4868
- }, [n, e, t, a, k]);
4868
+ }, [n, e, t, a, A]);
4869
4869
  J(() => {
4870
4870
  d && h.length > 0 && c === null && u(h[0].deviceId);
4871
4871
  }, [d, h.length]);
@@ -4891,7 +4891,7 @@ function Ai(e, t, n, r = {}) {
4891
4891
  startRecording: M,
4892
4892
  stopRecording: _,
4893
4893
  pauseRecording: $,
4894
- resumeRecording: A,
4894
+ resumeRecording: k,
4895
4895
  requestMicAccess: T,
4896
4896
  changeDevice: z,
4897
4897
  // Track state
@@ -5227,12 +5227,12 @@ function Mi(e = 256) {
5227
5227
  x.connect(f), f.connect(v);
5228
5228
  else {
5229
5229
  let y = x;
5230
- w.forEach((k) => {
5230
+ w.forEach((A) => {
5231
5231
  try {
5232
- k.disconnect();
5232
+ A.disconnect();
5233
5233
  } catch {
5234
5234
  }
5235
- y.connect(k.effect), y = k.effect;
5235
+ y.connect(A.effect), y = A.effect;
5236
5236
  }), y.connect(f), f.connect(v);
5237
5237
  }
5238
5238
  }, []), l = D((m) => {
@@ -5308,8 +5308,8 @@ function Mi(e = 256) {
5308
5308
  m.connect(v), v.connect(p);
5309
5309
  else {
5310
5310
  let y = m;
5311
- w.forEach((k) => {
5312
- y.connect(k.effect), y = k.effect;
5311
+ w.forEach((A) => {
5312
+ y.connect(A.effect), y = A.effect;
5313
5313
  }), y.connect(v), v.connect(p);
5314
5314
  }
5315
5315
  return function() {
@@ -5439,7 +5439,7 @@ function Bi() {
5439
5439
  return w.set(
5440
5440
  d,
5441
5441
  y.map(
5442
- (k) => k.instanceId === b ? { ...k, bypassed: p } : k
5442
+ (A) => A.instanceId === b ? { ...A, bypassed: p } : A
5443
5443
  )
5444
5444
  ), w;
5445
5445
  });
@@ -5577,13 +5577,13 @@ function Ps() {
5577
5577
  f = Math.max(f, T);
5578
5578
  }
5579
5579
  f += Math.round(v * 0.1);
5580
- const w = f / v, y = g === "individual" ? [{ track: i[h], state: l[h], index: h }] : i.map((M, _) => ({ track: M, state: l[_], index: _ })), k = l.some((M) => M.soloed), $ = !!m;
5581
- let A;
5580
+ const w = f / v, y = g === "individual" ? [{ track: i[h], state: l[h], index: h }] : i.map((M, _) => ({ track: M, state: l[_], index: _ })), A = l.some((M) => M.soloed), $ = !!m;
5581
+ let k;
5582
5582
  if ((C || $) && b)
5583
- A = await zs(
5583
+ k = await zs(
5584
5584
  y,
5585
5585
  l,
5586
- k,
5586
+ A,
5587
5587
  w,
5588
5588
  v,
5589
5589
  C,
@@ -5597,22 +5597,22 @@ function Ps() {
5597
5597
  let _ = 0;
5598
5598
  const T = y.reduce((z, { track: P }) => z + P.clips.length, 0);
5599
5599
  for (const { track: z, state: P } of y)
5600
- if (!(P.muted && !P.soloed) && !(k && !P.soloed))
5600
+ if (!(P.muted && !P.soloed) && !(A && !P.soloed))
5601
5601
  for (const Z of z.clips) {
5602
5602
  await Xs(M, Z, P, v, b), _++;
5603
- const O = _ / T * 0.5;
5604
- r(O), x?.(O);
5603
+ const Y = _ / T * 0.5;
5604
+ r(Y), x?.(Y);
5605
5605
  }
5606
- r(0.5), x?.(0.5), A = await M.startRendering();
5606
+ r(0.5), x?.(0.5), k = await M.startRendering();
5607
5607
  }
5608
5608
  r(0.9), x?.(0.9);
5609
- const B = Zs(A, { bitDepth: p });
5609
+ const B = Zs(k, { bitDepth: p });
5610
5610
  if (r(1), x?.(1), d) {
5611
5611
  const M = g === "individual" ? `${u}_${i[h].name}` : u;
5612
5612
  Vs(B, `${M}.wav`);
5613
5613
  }
5614
5614
  return {
5615
- audioBuffer: A,
5615
+ audioBuffer: k,
5616
5616
  blob: B,
5617
5617
  duration: w
5618
5618
  };
@@ -5640,19 +5640,19 @@ async function zs(e, t, n, r, a, s, o, i) {
5640
5640
  s ? x = s(p, m, !0) : p.connect(m);
5641
5641
  for (const { track: v, state: f } of e) {
5642
5642
  if (f.muted && !f.soloed || n && !f.soloed) continue;
5643
- const w = new c(Hs(f.volume)), y = new g(f.pan), k = new u(f.muted ? 0 : 1), $ = o?.(v.id);
5644
- $ ? $(k, p, !0) : k.connect(p), y.connect(k), w.connect(y);
5645
- for (const A of v.clips) {
5646
- const { audioBuffer: B, startSample: M, durationSamples: _, offsetSamples: T, gain: z, fadeIn: P, fadeOut: Z } = A, O = M / a, X = _ / a, V = T / a, Q = new d(B), ie = new h(Q), oe = new u(z);
5643
+ const w = new c(Hs(f.volume)), y = new g(f.pan), A = new u(f.muted ? 0 : 1), $ = o?.(v.id);
5644
+ $ ? $(A, p, !0) : A.connect(p), y.connect(A), w.connect(y);
5645
+ for (const k of v.clips) {
5646
+ const { audioBuffer: B, startSample: M, durationSamples: _, offsetSamples: T, gain: z, fadeIn: P, fadeOut: Z } = k, Y = M / a, G = _ / a, V = T / a, Q = new d(B), ie = new h(Q), oe = new u(z);
5647
5647
  if (ie.connect(oe), oe.connect(w), P) {
5648
- const te = O, se = O + P.duration, ye = oe.gain._param;
5649
- ye.setValueAtTime(0, te), ye.linearRampToValueAtTime(z, se);
5648
+ const ee = Y, se = Y + P.duration, Ce = oe.gain._param;
5649
+ Ce.setValueAtTime(0, ee), Ce.linearRampToValueAtTime(z, se);
5650
5650
  }
5651
5651
  if (Z) {
5652
- const te = O + X - Z.duration, se = O + X, ye = oe.gain._param;
5653
- ye.setValueAtTime(z, te), ye.linearRampToValueAtTime(0, se);
5652
+ const ee = Y + G - Z.duration, se = Y + G, Ce = oe.gain._param;
5653
+ Ce.setValueAtTime(z, ee), Ce.linearRampToValueAtTime(0, se);
5654
5654
  }
5655
- ie.start(O, V, X);
5655
+ ie.start(Y, V, G);
5656
5656
  }
5657
5657
  }
5658
5658
  C.start(0);
@@ -5724,7 +5724,7 @@ function xn(e, t, n, r) {
5724
5724
  }
5725
5725
  return a;
5726
5726
  }
5727
- const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null), Di = ({
5727
+ const or = Be(null), sr = Be(null), ir = Be(null), lr = Be(null), cr = Be(null), Di = ({
5728
5728
  tracks: e,
5729
5729
  timescale: t = !1,
5730
5730
  mono: n = !1,
@@ -5743,17 +5743,17 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
5743
5743
  progressBarWidth: C,
5744
5744
  children: m
5745
5745
  }) => {
5746
- const p = C ?? d + b, [x, v] = W([]), [f, w] = W(null), [y, k] = W(!1), [$, A] = W(0), [B, M] = W(0), [_, T] = W([]), [z, P] = W([]), [Z, O] = W([]), [X, V] = W(0), [Q, ie] = W(0), [oe, te] = W(null), [se, ye] = W(o), [we, Ke] = W(c?.isContinuousPlay ?? !1), [Ne, ke] = W(c?.linkEndpoints ?? !0), [Ue, K] = W(c?.editable ?? !1), [fe, re] = W(!1), [q, he] = W(0), [xe, ae] = W(0), F = R(null), Se = R(0), be = R(0), pe = R(null), et = R(Z), j = R(0), ee = R(0), de = R(null), me = R(null), je = R(!1), Je = R(c?.isContinuousPlay ?? !1), Le = R(null), tt = R(a), bt = R(!1), Wt = R(0), N = R(0), U = R(0), ce = R(0), { timeFormat: $e, setTimeFormat: Me, formatTime: Pe } = hs(), le = gs({ initialSamplesPerPixel: a, zoomLevels: s }), Be = le.samplesPerPixel, { masterVolume: Ye, setMasterVolume: Qe } = bs({ playoutRef: F, initialVolume: 1 }), qe = D((E) => {
5746
+ const p = C ?? d + b, [x, v] = W([]), [f, w] = W(null), [y, A] = W(!1), [$, k] = W(0), [B, M] = W(0), [_, T] = W([]), [z, P] = W([]), [Z, Y] = W([]), [G, V] = W(0), [Q, ie] = W(0), [oe, ee] = W(null), [se, Ce] = W(o), [ve, Ke] = W(c?.isContinuousPlay ?? !1), [Ne, ke] = W(c?.linkEndpoints ?? !0), [Ue, O] = W(c?.editable ?? !1), [me, re] = W(!1), [q, fe] = W(0), [ye, ae] = W(0), F = R(null), Te = R(0), we = R(0), he = R(null), et = R(Z), j = R(0), te = R(0), de = R(null), pe = R(null), je = R(!1), Je = R(c?.isContinuousPlay ?? !1), Le = R(null), tt = R(a), bt = R(!1), Wt = R(0), N = R(0), U = R(0), ce = R(0), { timeFormat: Se, setTimeFormat: $e, formatTime: Pe } = hs(), le = gs({ initialSamplesPerPixel: a, zoomLevels: s }), Me = le.samplesPerPixel, { masterVolume: Ye, setMasterVolume: Qe } = bs({ playoutRef: F, initialVolume: 1 }), qe = D((E) => {
5747
5747
  Je.current = E, Ke(E);
5748
5748
  }, []), ze = D((E) => {
5749
5749
  Le.current = E, w(E);
5750
5750
  }, []), dt = D((E) => {
5751
5751
  bt.current = E, re(E);
5752
- }, []), nt = D((E, G) => {
5753
- U.current = E, ce.current = G, he(E), ae(G);
5752
+ }, []), nt = D((E, X) => {
5753
+ U.current = E, ce.current = X, fe(E), ae(X);
5754
5754
  }, []), hr = D(() => {
5755
- const E = Wt.current, G = N.current;
5756
- E !== G && G > E && nt(E, G);
5755
+ const E = Wt.current, X = N.current;
5756
+ E !== X && X > E && nt(E, X);
5757
5757
  }, [nt]), pr = D(() => {
5758
5758
  nt(0, 0);
5759
5759
  }, [nt]);
@@ -5762,22 +5762,22 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
5762
5762
  }, [se]), J(() => {
5763
5763
  et.current = Z;
5764
5764
  }, [Z]), J(() => {
5765
- Wt.current = X, N.current = Q;
5766
- }, [X, Q]), J(() => {
5767
- if (!me.current || !_.length) return;
5768
- const E = me.current, G = tt.current, Y = Be;
5769
- if (G === Y) return;
5770
- const ue = l.show ? l.width : 0, H = E.clientWidth, Xe = E.scrollLeft + H / 2 - ue, ge = _[0].sampleRate, Ee = Xe * G / ge * ge / Y, Oe = Math.max(0, Ee + ue - H / 2);
5771
- E.scrollLeft = Oe, tt.current = Y;
5772
- }, [Be, _, l]);
5765
+ Wt.current = G, N.current = Q;
5766
+ }, [G, Q]), J(() => {
5767
+ if (!pe.current || !_.length) return;
5768
+ const E = pe.current, X = tt.current, K = Me;
5769
+ if (X === K) return;
5770
+ const ue = l.show ? l.width : 0, H = E.clientWidth, Xe = E.scrollLeft + H / 2 - ue, ge = _[0].sampleRate, Ee = Xe * X / ge * ge / K, Oe = Math.max(0, Ee + ue - H / 2);
5771
+ E.scrollLeft = Oe, tt.current = K;
5772
+ }, [Me, _, l]);
5773
5773
  const vt = R(null);
5774
5774
  J(() => {
5775
5775
  if (e.length === 0) {
5776
- T([]), M(0), O([]), P([]), F.current && (F.current.dispose(), F.current = null);
5776
+ T([]), M(0), Y([]), P([]), F.current && (F.current.dispose(), F.current = null);
5777
5777
  return;
5778
5778
  }
5779
- const E = y, G = be.current;
5780
- return F.current && E && (F.current.stop(), pe.current && (cancelAnimationFrame(pe.current), pe.current = null), vt.current = { position: G }), (async () => {
5779
+ const E = y, X = we.current;
5780
+ return F.current && E && (F.current.stop(), he.current && (cancelAnimationFrame(he.current), he.current = null), vt.current = { position: X }), (async () => {
5781
5781
  try {
5782
5782
  const ue = [];
5783
5783
  e.forEach((ge) => {
@@ -5789,7 +5789,7 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
5789
5789
  const Ee = Ie.sampleRate, wt = (Ie.startSample + Ie.durationSamples) / Ee;
5790
5790
  H = Math.max(H, wt);
5791
5791
  });
5792
- }), T(ue), M(H), O((ge) => ge.length === e.length ? ge.map((Ie, Ee) => ({
5792
+ }), T(ue), M(H), Y((ge) => ge.length === e.length ? ge.map((Ie, Ee) => ({
5793
5793
  ...Ie,
5794
5794
  name: e[Ee].name
5795
5795
  })) : e.map((Ie) => ({
@@ -5799,7 +5799,7 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
5799
5799
  volume: Ie.volume,
5800
5800
  pan: Ie.pan
5801
5801
  }))), F.current && F.current.dispose();
5802
- const Ce = new va({
5802
+ const xe = new va({
5803
5803
  effects: u
5804
5804
  }), Xe = et.current;
5805
5805
  e.forEach((ge, Ie) => {
@@ -5829,28 +5829,28 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
5829
5829
  gain: We.gain
5830
5830
  };
5831
5831
  });
5832
- Ce.addTrack({
5832
+ xe.addTrack({
5833
5833
  clips: Tr,
5834
5834
  track: Dr,
5835
5835
  effects: ge.effects
5836
5836
  // Pass track effects
5837
5837
  });
5838
5838
  }
5839
- }), Ce.applyInitialSoloState(), F.current = Ce, g?.();
5839
+ }), xe.applyInitialSoloState(), F.current = xe, g?.();
5840
5840
  } catch (ue) {
5841
5841
  console.error("Error loading audio:", ue);
5842
5842
  }
5843
5843
  })(), () => {
5844
- pe.current && cancelAnimationFrame(pe.current), F.current && F.current.dispose();
5844
+ he.current && cancelAnimationFrame(he.current), F.current && F.current.dispose();
5845
5845
  };
5846
5846
  }, [e, g, y]), J(() => {
5847
5847
  if (e.length === 0) return;
5848
- const E = 16, G = e.map((Y) => Y.clips.map((H) => {
5848
+ const E = 16, X = e.map((K) => K.clips.map((H) => {
5849
5849
  if (H.waveformData) {
5850
5850
  const Xe = Qn(
5851
5851
  H.waveformData,
5852
5852
  // Cast to WaveformData type
5853
- Be,
5853
+ Me,
5854
5854
  0,
5855
5855
  // channel index
5856
5856
  H.offsetSamples,
@@ -5858,7 +5858,7 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
5858
5858
  );
5859
5859
  return {
5860
5860
  clipId: H.id,
5861
- trackName: Y.name,
5861
+ trackName: K.name,
5862
5862
  peaks: {
5863
5863
  length: Xe.length,
5864
5864
  data: [Xe.data],
@@ -5874,7 +5874,7 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
5874
5874
  if (!H.audioBuffer)
5875
5875
  return console.warn(`Clip "${H.name || H.id}" has neither waveformData nor audioBuffer - rendering empty`), {
5876
5876
  clipId: H.id,
5877
- trackName: Y.name,
5877
+ trackName: K.name,
5878
5878
  peaks: {
5879
5879
  length: 0,
5880
5880
  data: [],
@@ -5885,9 +5885,9 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
5885
5885
  fadeIn: H.fadeIn,
5886
5886
  fadeOut: H.fadeOut
5887
5887
  };
5888
- const Ce = Mo(
5888
+ const xe = Mo(
5889
5889
  H.audioBuffer,
5890
- Be,
5890
+ Me,
5891
5891
  n,
5892
5892
  E,
5893
5893
  H.offsetSamples,
@@ -5895,160 +5895,152 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
5895
5895
  );
5896
5896
  return {
5897
5897
  clipId: H.id,
5898
- trackName: Y.name,
5899
- peaks: Ce,
5898
+ trackName: K.name,
5899
+ peaks: xe,
5900
5900
  startSample: H.startSample,
5901
5901
  durationSamples: H.durationSamples,
5902
5902
  fadeIn: H.fadeIn,
5903
5903
  fadeOut: H.fadeOut
5904
5904
  };
5905
5905
  }));
5906
- P(G);
5907
- }, [e, Be, n]), J(() => {
5906
+ P(X);
5907
+ }, [e, Me, n]), J(() => {
5908
5908
  if (c?.annotations) {
5909
- const E = c.annotations.map((G) => typeof G.start == "number" ? G : qn(G));
5909
+ const E = c.annotations.map((X) => typeof X.start == "number" ? X : qn(X));
5910
5910
  v(E);
5911
5911
  }
5912
5912
  }, [c]);
5913
5913
  const rt = D(() => {
5914
- pe.current && (cancelAnimationFrame(pe.current), pe.current = null);
5914
+ he.current && (cancelAnimationFrame(he.current), he.current = null);
5915
5915
  const E = () => {
5916
- const G = Ae().currentTime - j.current, Y = ee.current + G;
5917
- if (be.current = Y, A(Y), x.length > 0) {
5916
+ const X = Ae().currentTime - j.current, K = te.current + X;
5917
+ if (we.current = K, k(K), x.length > 0) {
5918
5918
  const H = x.find(
5919
- (Ce) => Y >= Ce.start && Y < Ce.end
5919
+ (xe) => K >= xe.start && K < xe.end
5920
5920
  );
5921
- if (Je.current) {
5922
- if (H && H.id !== Le.current)
5923
- ze(H.id);
5924
- else if (!H && Le.current !== null) {
5925
- const Ce = x[x.length - 1];
5926
- if (Y >= Ce.end) {
5927
- F.current && F.current.stop(), k(!1), be.current = Se.current, A(Se.current), ze(null);
5928
- return;
5929
- }
5930
- }
5931
- } else if (Le.current) {
5932
- const Ce = x.find((Xe) => Xe.id === Le.current);
5933
- if (Ce && Y >= Ce.end) {
5934
- F.current && F.current.stop(), k(!1), be.current = Se.current, A(Se.current);
5921
+ if (Je.current)
5922
+ H && H.id !== Le.current ? ze(H.id) : !H && Le.current !== null && ze(null);
5923
+ else if (Le.current) {
5924
+ const xe = x.find((Xe) => Xe.id === Le.current);
5925
+ if (xe && K >= xe.end) {
5926
+ F.current && F.current.stop(), A(!1), we.current = Te.current, k(Te.current);
5935
5927
  return;
5936
5928
  }
5937
5929
  } else
5938
5930
  H && ze(H.id);
5939
5931
  }
5940
- if (je.current && me.current && _.length > 0) {
5941
- const H = me.current, Ce = _[0].sampleRate, Xe = Y * Ce / tt.current, ge = H.clientWidth, Ie = l.show ? l.width : 0, Ee = Xe + Ie, Oe = Math.max(0, Ee - ge / 2);
5932
+ if (je.current && pe.current && _.length > 0) {
5933
+ const H = pe.current, xe = _[0].sampleRate, Xe = K * xe / tt.current, ge = H.clientWidth, Ie = l.show ? l.width : 0, Ee = Xe + Ie, Oe = Math.max(0, Ee - ge / 2);
5942
5934
  H.scrollLeft = Oe;
5943
5935
  }
5944
- if (de.current !== null && Y >= de.current) {
5945
- F.current && F.current.stop(), k(!1), be.current = de.current, A(de.current), de.current = null;
5936
+ if (de.current !== null && K >= de.current) {
5937
+ F.current && F.current.stop(), A(!1), we.current = de.current, k(de.current), de.current = null;
5946
5938
  return;
5947
5939
  }
5948
5940
  const ue = U.current !== ce.current && ce.current > U.current;
5949
- if (bt.current && ue && Y >= ce.current) {
5941
+ if (bt.current && ue && K >= ce.current) {
5950
5942
  F.current?.stop();
5951
- const Ce = Ae().currentTime;
5952
- j.current = Ce, ee.current = U.current, be.current = U.current, F.current?.play(Ce, U.current), pe.current = requestAnimationFrame(E);
5943
+ const xe = Ae().currentTime;
5944
+ j.current = xe, te.current = U.current, we.current = U.current, F.current?.play(xe, U.current), he.current = requestAnimationFrame(E);
5953
5945
  return;
5954
5946
  }
5955
- if (Y >= B) {
5956
- F.current && F.current.stop(), k(!1), be.current = Se.current, A(Se.current), ze(null);
5947
+ if (K >= B) {
5948
+ F.current && F.current.stop(), A(!1), we.current = Te.current, k(Te.current), ze(null);
5957
5949
  return;
5958
5950
  }
5959
- pe.current = requestAnimationFrame(E);
5951
+ he.current = requestAnimationFrame(E);
5960
5952
  };
5961
- pe.current = requestAnimationFrame(E);
5962
- }, [B, _, Be, x, we]), He = D(() => {
5963
- pe.current && (cancelAnimationFrame(pe.current), pe.current = null);
5953
+ he.current = requestAnimationFrame(E);
5954
+ }, [B, _, Me, x, ve]), He = D(() => {
5955
+ he.current && (cancelAnimationFrame(he.current), he.current = null);
5964
5956
  }, []);
5965
5957
  J(() => {
5966
5958
  (async () => {
5967
- if (y && pe.current && F.current)
5968
- if (we) {
5969
- const G = be.current;
5959
+ if (y && he.current && F.current)
5960
+ if (ve) {
5961
+ const X = we.current;
5970
5962
  F.current.stop(), He(), await F.current.init(), F.current.setOnPlaybackComplete(() => {
5971
5963
  });
5972
5964
  const ue = Ae().currentTime;
5973
- j.current = ue, ee.current = G, F.current.play(ue, G), rt();
5965
+ j.current = ue, te.current = X, F.current.play(ue, X), rt();
5974
5966
  } else
5975
5967
  He(), rt();
5976
5968
  })();
5977
- }, [we, y, rt, He]), J(() => {
5969
+ }, [ve, y, rt, He]), J(() => {
5978
5970
  (async () => {
5979
5971
  if (vt.current && F.current) {
5980
- const { position: G } = vt.current;
5972
+ const { position: X } = vt.current;
5981
5973
  vt.current = null, await F.current.init(), F.current.setOnPlaybackComplete(() => {
5982
5974
  });
5983
5975
  const ue = Ae().currentTime;
5984
- j.current = ue, ee.current = G, F.current.play(ue, G), k(!0), rt();
5976
+ j.current = ue, te.current = X, F.current.play(ue, X), A(!0), rt();
5985
5977
  }
5986
5978
  })();
5987
5979
  }, [e, rt]);
5988
- const _t = D(async (E, G) => {
5980
+ const _t = D(async (E, X) => {
5989
5981
  if (!F.current || _.length === 0) return;
5990
5982
  await F.current.init(), await Sn();
5991
- const Y = E ?? be.current;
5992
- Se.current = Y, be.current = Y, F.current.setOnPlaybackComplete(() => {
5983
+ const K = E ?? we.current;
5984
+ Te.current = K, we.current = K, F.current.setOnPlaybackComplete(() => {
5993
5985
  }), F.current.stop(), He();
5994
5986
  const H = Ae().currentTime;
5995
- j.current = H, ee.current = Y, de.current = G !== void 0 ? Y + G : null, F.current.play(H, Y, G), k(!0), rt();
5987
+ j.current = H, te.current = K, de.current = X !== void 0 ? K + X : null, F.current.play(H, K, X), A(!0), rt();
5996
5988
  }, [_.length, rt, He]), gr = D(() => {
5997
5989
  if (!F.current) return;
5998
- const E = Ae().currentTime - j.current, G = ee.current + E;
5999
- F.current.pause(), k(!1), He(), be.current = G, A(G);
5990
+ const E = Ae().currentTime - j.current, X = te.current + E;
5991
+ F.current.pause(), A(!1), He(), we.current = X, k(X);
6000
5992
  }, [He]), br = D(() => {
6001
- F.current && (F.current.stop(), k(!1), He(), be.current = Se.current, A(Se.current), ze(null));
5993
+ F.current && (F.current.stop(), A(!1), He(), we.current = Te.current, k(Te.current), ze(null));
6002
5994
  }, [He]), vr = D((E) => {
6003
- const G = Math.max(0, Math.min(E, B));
6004
- be.current = G, A(G), y && F.current && (F.current.stop(), He(), _t(G));
6005
- }, [B, y, _t, He]), wr = D((E, G) => {
6006
- const Y = [...Z];
6007
- if (Y[E] = { ...Y[E], muted: G }, O(Y), F.current) {
5995
+ const X = Math.max(0, Math.min(E, B));
5996
+ we.current = X, k(X), y && F.current && (F.current.stop(), He(), _t(X));
5997
+ }, [B, y, _t, He]), wr = D((E, X) => {
5998
+ const K = [...Z];
5999
+ if (K[E] = { ...K[E], muted: X }, Y(K), F.current) {
6008
6000
  const ue = `track-${E}`;
6009
- F.current.setMute(ue, G);
6001
+ F.current.setMute(ue, X);
6010
6002
  }
6011
- }, [Z]), Cr = D((E, G) => {
6012
- const Y = [...Z];
6013
- if (Y[E] = { ...Y[E], soloed: G }, O(Y), F.current) {
6003
+ }, [Z]), Cr = D((E, X) => {
6004
+ const K = [...Z];
6005
+ if (K[E] = { ...K[E], soloed: X }, Y(K), F.current) {
6014
6006
  const ue = `track-${E}`;
6015
- F.current.setSolo(ue, G);
6007
+ F.current.setSolo(ue, X);
6016
6008
  }
6017
- }, [Z]), yr = D((E, G) => {
6018
- const Y = [...Z];
6019
- if (Y[E] = { ...Y[E], volume: G }, O(Y), F.current) {
6009
+ }, [Z]), yr = D((E, X) => {
6010
+ const K = [...Z];
6011
+ if (K[E] = { ...K[E], volume: X }, Y(K), F.current) {
6020
6012
  const ue = `track-${E}`, H = F.current.getTrack(ue);
6021
- H && H.setVolume(G);
6013
+ H && H.setVolume(X);
6022
6014
  }
6023
- }, [Z]), xr = D((E, G) => {
6024
- const Y = [...Z];
6025
- if (Y[E] = { ...Y[E], pan: G }, O(Y), F.current) {
6015
+ }, [Z]), xr = D((E, X) => {
6016
+ const K = [...Z];
6017
+ if (K[E] = { ...K[E], pan: X }, Y(K), F.current) {
6026
6018
  const ue = `track-${E}`, H = F.current.getTrack(ue);
6027
- H && H.setPan(G);
6019
+ H && H.setPan(X);
6028
6020
  }
6029
- }, [Z]), Ir = D((E, G) => {
6030
- V(E), ie(G), be.current = E, A(E), y && F.current && (F.current.stop(), F.current.play(Ae().currentTime, E));
6021
+ }, [Z]), Ir = D((E, X) => {
6022
+ V(E), ie(X), we.current = E, k(E), y && F.current && (F.current.stop(), F.current.play(Ae().currentTime, E));
6031
6023
  }, [y]), Ar = D((E) => {
6032
- me.current = E;
6024
+ pe.current = E;
6033
6025
  }, []), kr = _[0]?.sampleRate || 44100, Qt = t ? 30 : 0, Sr = e.length * r + Qt, qt = {
6034
6026
  isPlaying: y,
6035
6027
  currentTime: $,
6036
- currentTimeRef: be,
6028
+ currentTimeRef: we,
6037
6029
  playbackStartTimeRef: j,
6038
- audioStartPositionRef: ee
6030
+ audioStartPositionRef: te
6039
6031
  }, en = {
6040
- continuousPlay: we,
6032
+ continuousPlay: ve,
6041
6033
  linkEndpoints: Ne,
6042
6034
  annotationsEditable: Ue,
6043
6035
  isAutomaticScroll: se,
6044
- isLoopEnabled: fe,
6036
+ isLoopEnabled: me,
6045
6037
  annotations: x,
6046
6038
  activeAnnotationId: f,
6047
- selectionStart: X,
6039
+ selectionStart: G,
6048
6040
  selectionEnd: Q,
6049
6041
  selectedTrackId: oe,
6050
6042
  loopStart: q,
6051
- loopEnd: xe
6043
+ loopEnd: ye
6052
6044
  }, tn = {
6053
6045
  // Playback controls
6054
6046
  play: _t,
@@ -6056,7 +6048,7 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
6056
6048
  stop: br,
6057
6049
  seekTo: vr,
6058
6050
  setCurrentTime: (E) => {
6059
- be.current = E, A(E);
6051
+ we.current = E, k(E);
6060
6052
  },
6061
6053
  // Track controls
6062
6054
  setTrackMute: wr,
@@ -6065,9 +6057,9 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
6065
6057
  setTrackPan: xr,
6066
6058
  // Selection
6067
6059
  setSelection: Ir,
6068
- setSelectedTrackId: te,
6060
+ setSelectedTrackId: ee,
6069
6061
  // Time format
6070
- setTimeFormat: Me,
6062
+ setTimeFormat: $e,
6071
6063
  formatTime: Pe,
6072
6064
  // Zoom
6073
6065
  zoomIn: le.zoomIn,
@@ -6076,14 +6068,14 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
6076
6068
  setMasterVolume: Qe,
6077
6069
  // Automatic scroll
6078
6070
  setAutomaticScroll: (E) => {
6079
- ye(E);
6071
+ Ce(E);
6080
6072
  },
6081
6073
  setScrollContainer: Ar,
6082
- scrollContainerRef: me,
6074
+ scrollContainerRef: pe,
6083
6075
  // Annotation controls
6084
6076
  setContinuousPlay: qe,
6085
6077
  setLinkEndpoints: ke,
6086
- setAnnotationsEditable: K,
6078
+ setAnnotationsEditable: O,
6087
6079
  setAnnotations: v,
6088
6080
  setActiveAnnotationId: ze,
6089
6081
  // Loop controls
@@ -6103,8 +6095,8 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
6103
6095
  minimumPlaylistHeight: Sr,
6104
6096
  controls: l,
6105
6097
  playoutRef: F,
6106
- samplesPerPixel: Be,
6107
- timeFormat: $e,
6098
+ samplesPerPixel: Me,
6099
+ timeFormat: Se,
6108
6100
  masterVolume: Ye,
6109
6101
  canZoomIn: le.canZoomIn,
6110
6102
  canZoomOut: le.canZoomOut,
@@ -6128,12 +6120,12 @@ const or = De(null), sr = De(null), ir = De(null), lr = De(null), cr = De(null),
6128
6120
  if (!e)
6129
6121
  throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");
6130
6122
  return e;
6131
- }, ve = () => {
6123
+ }, be = () => {
6132
6124
  const e = Re(ir);
6133
6125
  if (!e)
6134
6126
  throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");
6135
6127
  return e;
6136
- }, Te = () => {
6128
+ }, De = () => {
6137
6129
  const e = Re(lr);
6138
6130
  if (!e)
6139
6131
  throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");
@@ -6385,7 +6377,7 @@ var Gs = class {
6385
6377
  return this.track?.peaks.sample_rate ?? 44100;
6386
6378
  }
6387
6379
  };
6388
- const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6380
+ const ur = Be(null), dr = Be(null), mr = Be(null), fr = Be(null), Ri = ({
6389
6381
  track: e,
6390
6382
  samplesPerPixel: t = 1024,
6391
6383
  waveHeight: n = 100,
@@ -6401,20 +6393,20 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6401
6393
  onReady: h,
6402
6394
  children: d
6403
6395
  }) => {
6404
- const b = g ?? c + u, [C, m] = W(!1), [p, x] = W(0), [v, f] = W(0), [w, y] = W([]), [k, $] = W(a), [A, B] = W([]), [M, _] = W(null), [T, z] = W(
6396
+ const b = g ?? c + u, [C, m] = W(!1), [p, x] = W(0), [v, f] = W(0), [w, y] = W([]), [A, $] = W(a), [k, B] = W([]), [M, _] = W(null), [T, z] = W(
6405
6397
  l?.isContinuousPlay ?? !1
6406
- ), [P] = W(t), [Z, O] = W(s), X = R(null), V = R(0), Q = R(null), ie = R(T), oe = R(null), te = R(null), se = R(s), ye = R(t);
6398
+ ), [P] = W(t), [Z, Y] = W(s), G = R(null), V = R(0), Q = R(null), ie = R(T), oe = R(null), ee = R(null), se = R(s), Ce = R(t);
6407
6399
  J(() => {
6408
6400
  ie.current = T;
6409
6401
  }, [T]), J(() => {
6410
6402
  se.current = Z;
6411
6403
  }, [Z]);
6412
- const we = D((j) => {
6404
+ const ve = D((j) => {
6413
6405
  oe.current = j, _(j);
6414
6406
  }, []), Ke = D((j) => {
6415
6407
  ie.current = j, z(j);
6416
6408
  }, []), Ne = D((j) => {
6417
- te.current = j;
6409
+ ee.current = j;
6418
6410
  }, []), ke = e.waveformData.sample_rate;
6419
6411
  J(() => {
6420
6412
  const j = new Ns({
@@ -6425,12 +6417,12 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6425
6417
  peaks: e.waveformData,
6426
6418
  name: e.name
6427
6419
  });
6428
- const ee = j.getTrack(j.track?.id ?? "");
6429
- return ee && ee.setOnTimeUpdateCallback((de) => {
6420
+ const te = j.getTrack(j.track?.id ?? "");
6421
+ return te && te.setOnTimeUpdateCallback((de) => {
6430
6422
  V.current = de;
6431
6423
  }), j.setOnPlaybackComplete(() => {
6432
6424
  m(!1);
6433
- }), X.current = j, f(e.waveformData.duration), h?.(), () => {
6425
+ }), G.current = j, f(e.waveformData.duration), h?.(), () => {
6434
6426
  Q.current && cancelAnimationFrame(Q.current), j.dispose();
6435
6427
  };
6436
6428
  }, [e.source, e.waveformData, e.name, a, h]), J(() => {
@@ -6443,7 +6435,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6443
6435
  // offset
6444
6436
  Math.ceil(e.waveformData.duration * ke)
6445
6437
  // duration in samples
6446
- ), ee = {
6438
+ ), te = {
6447
6439
  clipId: "media-element-clip",
6448
6440
  trackName: e.name ?? "Track",
6449
6441
  peaks: {
@@ -6454,74 +6446,66 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6454
6446
  startSample: 0,
6455
6447
  durationSamples: Math.ceil(e.waveformData.duration * ke)
6456
6448
  };
6457
- y([[ee]]);
6449
+ y([[te]]);
6458
6450
  }, [e.waveformData, e.name, P, ke]), J(() => {
6459
6451
  if (l?.annotations) {
6460
- const j = l.annotations.map((ee) => typeof ee.start == "number" ? ee : qn(ee));
6452
+ const j = l.annotations.map((te) => typeof te.start == "number" ? te : qn(te));
6461
6453
  B(j);
6462
6454
  }
6463
6455
  }, [l]);
6464
6456
  const Ue = D(() => {
6465
6457
  Q.current && cancelAnimationFrame(Q.current);
6466
6458
  const j = () => {
6467
- const ee = X.current?.getCurrentTime() ?? 0;
6468
- if (V.current = ee, x(ee), A.length > 0) {
6469
- const de = A.find(
6470
- (me) => ee >= me.start && ee < me.end
6459
+ const te = G.current?.getCurrentTime() ?? 0;
6460
+ if (V.current = te, x(te), k.length > 0) {
6461
+ const de = k.find(
6462
+ (pe) => te >= pe.start && te < pe.end
6471
6463
  );
6472
- if (ie.current) {
6473
- if (de && de.id !== oe.current)
6474
- we(de.id);
6475
- else if (!de && oe.current !== null) {
6476
- const me = A[A.length - 1];
6477
- if (ee >= me.end) {
6478
- X.current?.stop(), m(!1), we(null);
6479
- return;
6480
- }
6481
- }
6482
- } else if (oe.current) {
6483
- const me = A.find(
6464
+ if (ie.current)
6465
+ de && de.id !== oe.current ? ve(de.id) : !de && oe.current !== null && ve(null);
6466
+ else if (oe.current) {
6467
+ const pe = k.find(
6484
6468
  (je) => je.id === oe.current
6485
6469
  );
6486
- if (me && ee >= me.end) {
6487
- X.current?.stop(), m(!1);
6470
+ if (pe && te >= pe.end) {
6471
+ G.current?.stop(), m(!1);
6488
6472
  return;
6489
6473
  }
6490
- } else de && we(de.id);
6474
+ } else de && ve(de.id);
6491
6475
  }
6492
- if (se.current && te.current) {
6493
- const de = te.current, me = ee * ke / ye.current, je = de.clientWidth, Je = i.show ? i.width : 0, Le = me + Je, tt = Math.max(0, Le - je / 2);
6476
+ if (se.current && ee.current) {
6477
+ const de = ee.current, pe = te * ke / Ce.current, je = de.clientWidth, Je = i.show ? i.width : 0, Le = pe + Je, tt = Math.max(0, Le - je / 2);
6494
6478
  de.scrollLeft = tt;
6495
6479
  }
6496
- if (ee >= v) {
6497
- X.current?.stop(), m(!1), we(null);
6480
+ if (te >= v) {
6481
+ G.current?.stop(), m(!1), ve(null);
6498
6482
  return;
6499
6483
  }
6500
6484
  Q.current = requestAnimationFrame(j);
6501
6485
  };
6502
6486
  Q.current = requestAnimationFrame(j);
6503
- }, [v, A, we, ke, i]), K = D(() => {
6487
+ }, [v, k, ve, ke, i]), O = D(() => {
6504
6488
  Q.current && (cancelAnimationFrame(Q.current), Q.current = null);
6505
- }, []), fe = D(
6489
+ }, []), me = D(
6506
6490
  (j) => {
6507
- if (!X.current) return;
6508
- const ee = j ?? V.current;
6509
- X.current.play(void 0, ee), m(!0), Ue();
6491
+ if (!G.current) return;
6492
+ const te = j ?? V.current;
6493
+ G.current.play(void 0, te), m(!0), Ue();
6510
6494
  },
6511
6495
  [Ue]
6512
6496
  ), re = D(() => {
6513
- X.current && (X.current.pause(), m(!1), K(), x(X.current.getCurrentTime()));
6514
- }, [K]), q = D(() => {
6515
- X.current && (X.current.stop(), m(!1), K(), V.current = 0, x(0), we(null));
6516
- }, [K, we]), he = D(
6497
+ G.current && (G.current.pause(), m(!1), O(), x(G.current.getCurrentTime()));
6498
+ }, [O]), q = D(() => {
6499
+ G.current && (G.current.stop(), m(!1), O(), V.current = 0, x(0), ve(null));
6500
+ }, [O, ve]), fe = D(
6517
6501
  (j) => {
6518
- const ee = Math.max(0, Math.min(j, v));
6519
- V.current = ee, x(ee), X.current && X.current.seekTo(ee);
6502
+ const te = Math.max(0, Math.min(j, v));
6503
+ V.current = te, x(te), G.current && G.current.seekTo(te);
6520
6504
  },
6521
6505
  [v]
6522
- ), xe = D((j) => {
6523
- const ee = Math.max(0.5, Math.min(2, j));
6524
- $(ee), X.current && X.current.setPlaybackRate(ee);
6506
+ ), ye = D((j) => {
6507
+ const te = Math.max(0.5, Math.min(2, j));
6508
+ $(te), G.current && G.current.setPlaybackRate(te);
6525
6509
  }, []), ae = r ? 30 : 0, F = at(
6526
6510
  () => ({
6527
6511
  isPlaying: C,
@@ -6529,33 +6513,33 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6529
6513
  currentTimeRef: V
6530
6514
  }),
6531
6515
  [C, p]
6532
- ), Se = at(
6516
+ ), Te = at(
6533
6517
  () => ({
6534
6518
  continuousPlay: T,
6535
- annotations: A,
6519
+ annotations: k,
6536
6520
  activeAnnotationId: M,
6537
- playbackRate: k,
6521
+ playbackRate: A,
6538
6522
  isAutomaticScroll: Z
6539
6523
  }),
6540
- [T, A, M, k, Z]
6541
- ), be = at(
6524
+ [T, k, M, A, Z]
6525
+ ), we = at(
6542
6526
  () => ({
6543
- play: fe,
6527
+ play: me,
6544
6528
  pause: re,
6545
6529
  stop: q,
6546
- seekTo: he,
6547
- setPlaybackRate: xe,
6530
+ seekTo: fe,
6531
+ setPlaybackRate: ye,
6548
6532
  setContinuousPlay: Ke,
6549
6533
  setAnnotations: B,
6550
- setActiveAnnotationId: we,
6534
+ setActiveAnnotationId: ve,
6551
6535
  setAutomaticScroll: (j) => {
6552
- O(j);
6536
+ Y(j);
6553
6537
  },
6554
6538
  setScrollContainer: Ne,
6555
- scrollContainerRef: te
6539
+ scrollContainerRef: ee
6556
6540
  }),
6557
- [fe, re, q, he, xe, Ke, we, Ne]
6558
- ), pe = at(
6541
+ [me, re, q, fe, ye, Ke, ve, Ne]
6542
+ ), he = at(
6559
6543
  () => ({
6560
6544
  duration: v,
6561
6545
  peaksDataArray: w,
@@ -6563,7 +6547,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6563
6547
  waveHeight: n,
6564
6548
  timeScaleHeight: ae,
6565
6549
  samplesPerPixel: P,
6566
- playoutRef: X,
6550
+ playoutRef: G,
6567
6551
  controls: i,
6568
6552
  barWidth: c,
6569
6553
  barGap: u,
@@ -6582,7 +6566,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6582
6566
  b
6583
6567
  ]
6584
6568
  ), et = { ...Zn, ...o };
6585
- return /* @__PURE__ */ I(Bn, { theme: et, children: /* @__PURE__ */ I(ur.Provider, { value: F, children: /* @__PURE__ */ I(dr.Provider, { value: Se, children: /* @__PURE__ */ I(mr.Provider, { value: be, children: /* @__PURE__ */ I(fr.Provider, { value: pe, children: d }) }) }) }) });
6569
+ return /* @__PURE__ */ I(Bn, { theme: et, children: /* @__PURE__ */ I(ur.Provider, { value: F, children: /* @__PURE__ */ I(dr.Provider, { value: Te, children: /* @__PURE__ */ I(mr.Provider, { value: we, children: /* @__PURE__ */ I(fr.Provider, { value: he, children: d }) }) }) }) });
6586
6570
  }, jt = () => {
6587
6571
  const e = Re(ur);
6588
6572
  if (!e)
@@ -6612,7 +6596,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6612
6596
  );
6613
6597
  return e;
6614
6598
  }, Ei = ({ className: e }) => {
6615
- const { isPlaying: t, currentTimeRef: n } = Fe(), { selectionStart: r, selectionEnd: a, isLoopEnabled: s } = Ge(), { play: o } = ve();
6599
+ const { isPlaying: t, currentTimeRef: n } = Fe(), { selectionStart: r, selectionEnd: a, isLoopEnabled: s } = Ge(), { play: o } = be();
6616
6600
  return /* @__PURE__ */ I(Ve, { onClick: async () => {
6617
6601
  if (r !== a && a > r)
6618
6602
  if (s)
@@ -6625,18 +6609,18 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6625
6609
  await o(n.current ?? 0);
6626
6610
  }, disabled: t, className: e, children: "Play" });
6627
6611
  }, Wi = ({ className: e }) => {
6628
- const { isPlaying: t } = Fe(), { pause: n } = ve();
6612
+ const { isPlaying: t } = Fe(), { pause: n } = be();
6629
6613
  return /* @__PURE__ */ I(Ve, { onClick: n, disabled: !t, className: e, children: "Pause" });
6630
6614
  }, _i = ({ className: e }) => {
6631
- const { isPlaying: t } = Fe(), { stop: n } = ve();
6615
+ const { isPlaying: t } = Fe(), { stop: n } = be();
6632
6616
  return /* @__PURE__ */ I(Ve, { onClick: n, disabled: !t, className: e, children: "Stop" });
6633
6617
  }, Fi = ({ className: e }) => {
6634
- const { isPlaying: t } = Fe(), { play: n, setCurrentTime: r } = ve(), { playoutRef: a } = Te();
6618
+ const { isPlaying: t } = Fe(), { play: n, setCurrentTime: r } = be(), { playoutRef: a } = De();
6635
6619
  return /* @__PURE__ */ I(Ve, { onClick: () => {
6636
6620
  r(0), t && a.current && (a.current.stop(), n(0));
6637
6621
  }, className: e, children: "Rewind" });
6638
6622
  }, Zi = ({ className: e }) => {
6639
- const { isPlaying: t } = Fe(), { play: n, setCurrentTime: r } = ve(), { duration: a, playoutRef: s } = Te();
6623
+ const { isPlaying: t } = Fe(), { play: n, setCurrentTime: r } = be(), { duration: a, playoutRef: s } = De();
6640
6624
  return /* @__PURE__ */ I(Ve, { onClick: () => {
6641
6625
  r(a), t && s.current && (s.current.stop(), n(a));
6642
6626
  }, className: e, children: "Fast Forward" });
@@ -6644,7 +6628,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6644
6628
  skipAmount: e = 5,
6645
6629
  className: t
6646
6630
  }) => {
6647
- const { currentTimeRef: n, isPlaying: r } = Fe(), { play: a, setCurrentTime: s } = ve(), { playoutRef: o } = Te();
6631
+ const { currentTimeRef: n, isPlaying: r } = Fe(), { play: a, setCurrentTime: s } = be(), { playoutRef: o } = De();
6648
6632
  return /* @__PURE__ */ I(Ve, { onClick: () => {
6649
6633
  const l = Math.max(0, (n.current ?? 0) - e);
6650
6634
  s(l), r && o.current && (o.current.stop(), a(l));
@@ -6653,13 +6637,13 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6653
6637
  skipAmount: e = 5,
6654
6638
  className: t
6655
6639
  }) => {
6656
- const { currentTimeRef: n, isPlaying: r } = Fe(), { play: a, setCurrentTime: s } = ve(), { duration: o, playoutRef: i } = Te();
6640
+ const { currentTimeRef: n, isPlaying: r } = Fe(), { play: a, setCurrentTime: s } = be(), { duration: o, playoutRef: i } = De();
6657
6641
  return /* @__PURE__ */ I(Ve, { onClick: () => {
6658
6642
  const c = Math.min(o, (n.current ?? 0) + e);
6659
6643
  s(c), r && i.current && (i.current.stop(), a(c));
6660
6644
  }, className: t, children: "Skip Forward" });
6661
6645
  }, zi = ({ className: e }) => {
6662
- const { isLoopEnabled: t, loopStart: n, loopEnd: r } = Ge(), { setLoopEnabled: a, setLoopRegion: s } = ve(), { duration: o } = Te(), i = n !== r && r > n;
6646
+ const { isLoopEnabled: t, loopStart: n, loopEnd: r } = Ge(), { setLoopEnabled: a, setLoopRegion: s } = be(), { duration: o } = De(), i = n !== r && r > n;
6663
6647
  return /* @__PURE__ */ I(
6664
6648
  Ve,
6665
6649
  {
@@ -6676,7 +6660,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6676
6660
  }
6677
6661
  );
6678
6662
  }, Hi = ({ className: e }) => {
6679
- const { selectionStart: t, selectionEnd: n, loopStart: r, loopEnd: a } = Ge(), { setLoopRegionFromSelection: s, clearLoopRegion: o } = ve(), i = t !== n && n > t, l = r !== a && a > r;
6663
+ const { selectionStart: t, selectionEnd: n, loopStart: r, loopEnd: a } = Ge(), { setLoopRegionFromSelection: s, clearLoopRegion: o } = be(), i = t !== n && n > t, l = r !== a && a > r;
6680
6664
  return /* @__PURE__ */ I(
6681
6665
  Ve,
6682
6666
  {
@@ -6690,13 +6674,13 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6690
6674
  }
6691
6675
  );
6692
6676
  }, Xi = ({ className: e, disabled: t }) => {
6693
- const { zoomIn: n } = ve(), { canZoomIn: r } = Te();
6677
+ const { zoomIn: n } = be(), { canZoomIn: r } = De();
6694
6678
  return /* @__PURE__ */ I(Ve, { variant: "success", onClick: n, disabled: t || !r, className: e, children: "Zoom In" });
6695
6679
  }, Gi = ({ className: e, disabled: t }) => {
6696
- const { zoomOut: n } = ve(), { canZoomOut: r } = Te();
6680
+ const { zoomOut: n } = be(), { canZoomOut: r } = De();
6697
6681
  return /* @__PURE__ */ I(Ve, { variant: "success", onClick: n, disabled: t || !r, className: e, children: "Zoom Out" });
6698
6682
  }, Ni = ({ className: e }) => {
6699
- const { masterVolume: t } = Te(), { setMasterVolume: n } = ve();
6683
+ const { masterVolume: t } = De(), { setMasterVolume: n } = be();
6700
6684
  return /* @__PURE__ */ I(
6701
6685
  Ga,
6702
6686
  {
@@ -6706,7 +6690,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6706
6690
  }
6707
6691
  );
6708
6692
  }, Li = ({ className: e }) => {
6709
- const { timeFormat: t } = Te(), { setTimeFormat: n } = ve();
6693
+ const { timeFormat: t } = De(), { setTimeFormat: n } = be();
6710
6694
  return /* @__PURE__ */ I(
6711
6695
  go,
6712
6696
  {
@@ -6722,7 +6706,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6722
6706
  color: ${(e) => e.theme?.textColor || "#333"};
6723
6707
  user-select: none;
6724
6708
  `, Yi = ({ className: e }) => {
6725
- const t = R(null), n = R(null), { isPlaying: r, currentTimeRef: a, playbackStartTimeRef: s, audioStartPositionRef: o } = Fe(), { timeFormat: i } = Te(), l = i;
6709
+ const t = R(null), n = R(null), { isPlaying: r, currentTimeRef: a, playbackStartTimeRef: s, audioStartPositionRef: o } = Fe(), { timeFormat: i } = De(), l = i;
6726
6710
  return J(() => {
6727
6711
  const c = () => {
6728
6712
  if (t.current) {
@@ -6743,7 +6727,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6743
6727
  !r && t.current && (t.current.textContent = ut(a.current ?? 0, l));
6744
6728
  }), /* @__PURE__ */ I(Os, { ref: t, className: e, "aria-label": "Audio position", children: ut(a.current ?? 0, l) });
6745
6729
  }, Oi = ({ className: e }) => {
6746
- const { selectionStart: t, selectionEnd: n } = Ge(), { setSelection: r } = ve();
6730
+ const { selectionStart: t, selectionEnd: n } = Ge(), { setSelection: r } = be();
6747
6731
  return /* @__PURE__ */ I(
6748
6732
  eo,
6749
6733
  {
@@ -6754,7 +6738,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6754
6738
  }
6755
6739
  );
6756
6740
  }, Ki = ({ className: e }) => {
6757
- const { isAutomaticScroll: t } = Ge(), { setAutomaticScroll: n } = ve();
6741
+ const { isAutomaticScroll: t } = Ge(), { setAutomaticScroll: n } = be();
6758
6742
  return /* @__PURE__ */ I(
6759
6743
  Aa,
6760
6744
  {
@@ -6764,7 +6748,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6764
6748
  }
6765
6749
  );
6766
6750
  }, Ui = ({ className: e }) => {
6767
- const { continuousPlay: t } = Ge(), { setContinuousPlay: n } = ve();
6751
+ const { continuousPlay: t } = Ge(), { setContinuousPlay: n } = be();
6768
6752
  return /* @__PURE__ */ I(
6769
6753
  cs,
6770
6754
  {
@@ -6774,7 +6758,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6774
6758
  }
6775
6759
  );
6776
6760
  }, ji = ({ className: e }) => {
6777
- const { linkEndpoints: t } = Ge(), { setLinkEndpoints: n } = ve();
6761
+ const { linkEndpoints: t } = Ge(), { setLinkEndpoints: n } = be();
6778
6762
  return /* @__PURE__ */ I(
6779
6763
  us,
6780
6764
  {
@@ -6784,7 +6768,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6784
6768
  }
6785
6769
  );
6786
6770
  }, Ji = ({ className: e }) => {
6787
- const { annotationsEditable: t } = Ge(), { setAnnotationsEditable: n } = ve();
6771
+ const { annotationsEditable: t } = Ge(), { setAnnotationsEditable: n } = be();
6788
6772
  return /* @__PURE__ */ I(
6789
6773
  ds,
6790
6774
  {
@@ -6819,7 +6803,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6819
6803
  onExportComplete: c,
6820
6804
  onExportError: u
6821
6805
  }) => {
6822
- const { tracks: g, trackStates: h } = Te(), { exportWav: d, isExporting: b, progress: C } = Ps(), m = async () => {
6806
+ const { tracks: g, trackStates: h } = De(), { exportWav: d, isExporting: b, progress: C } = Ps(), m = async () => {
6823
6807
  try {
6824
6808
  const x = await d(g, h, {
6825
6809
  filename: t,
@@ -6859,7 +6843,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6859
6843
  color: e = "#ff0000",
6860
6844
  controlsOffset: t = 0
6861
6845
  }) => {
6862
- const n = R(null), r = R(null), { isPlaying: a, currentTimeRef: s, playbackStartTimeRef: o, audioStartPositionRef: i } = Fe(), { samplesPerPixel: l, sampleRate: c, progressBarWidth: u } = Te();
6846
+ const n = R(null), r = R(null), { isPlaying: a, currentTimeRef: s, playbackStartTimeRef: o, audioStartPositionRef: i } = Fe(), { samplesPerPixel: l, sampleRate: c, progressBarWidth: u } = De();
6863
6847
  return J(() => {
6864
6848
  const g = () => {
6865
6849
  if (n.current) {
@@ -6914,7 +6898,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
6914
6898
  clipDurationSamples: t,
6915
6899
  ...n
6916
6900
  }) => {
6917
- const r = R(null), a = R(null), s = gt(), { waveHeight: o } = pt(), { isPlaying: i, currentTimeRef: l, playbackStartTimeRef: c, audioStartPositionRef: u } = Fe(), { samplesPerPixel: g, sampleRate: h } = Te(), d = s?.waveProgressColor || "rgba(0, 0, 0, 0.1)";
6901
+ const r = R(null), a = R(null), s = gt(), { waveHeight: o } = pt(), { isPlaying: i, currentTimeRef: l, playbackStartTimeRef: c, audioStartPositionRef: u } = Fe(), { samplesPerPixel: g, sampleRate: h } = De(), d = s?.waveProgressColor || "rgba(0, 0, 0, 0.1)";
6918
6902
  J(() => {
6919
6903
  const p = () => {
6920
6904
  if (r.current) {
@@ -7002,9 +6986,9 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7002
6986
  const m = gt(), { isPlaying: p, currentTimeRef: x, playbackStartTimeRef: v, audioStartPositionRef: f } = Fe(), {
7003
6987
  selectionStart: w,
7004
6988
  selectionEnd: y,
7005
- annotations: k,
6989
+ annotations: A,
7006
6990
  activeAnnotationId: $,
7007
- annotationsEditable: A,
6991
+ annotationsEditable: k,
7008
6992
  linkEndpoints: B,
7009
6993
  continuousPlay: M,
7010
6994
  selectedTrackId: _,
@@ -7013,83 +6997,83 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7013
6997
  isLoopEnabled: P
7014
6998
  } = Ge(), {
7015
6999
  setAnnotations: Z,
7016
- setActiveAnnotationId: O,
7017
- setTrackMute: X,
7000
+ setActiveAnnotationId: Y,
7001
+ setTrackMute: G,
7018
7002
  setTrackSolo: V,
7019
7003
  setTrackVolume: Q,
7020
7004
  setTrackPan: ie,
7021
7005
  setSelection: oe,
7022
- play: te,
7006
+ play: ee,
7023
7007
  setScrollContainer: se,
7024
- setSelectedTrackId: ye,
7025
- setCurrentTime: we,
7008
+ setSelectedTrackId: Ce,
7009
+ setCurrentTime: ve,
7026
7010
  setLoopRegion: Ke
7027
- } = ve(), {
7011
+ } = be(), {
7028
7012
  audioBuffers: Ne,
7029
7013
  peaksDataArray: ke,
7030
7014
  trackStates: Ue,
7031
- tracks: K,
7032
- duration: fe,
7015
+ tracks: O,
7016
+ duration: me,
7033
7017
  samplesPerPixel: re,
7034
7018
  sampleRate: q,
7035
- waveHeight: he,
7036
- timeScaleHeight: xe,
7019
+ waveHeight: fe,
7020
+ timeScaleHeight: ye,
7037
7021
  controls: ae,
7038
7022
  playoutRef: F,
7039
- barWidth: Se,
7040
- barGap: be
7041
- } = Te(), [pe, et] = W(!1), j = R(null), ee = D((N) => {
7023
+ barWidth: Te,
7024
+ barGap: we
7025
+ } = De(), [he, et] = W(!1), j = R(null), te = D((N) => {
7042
7026
  j.current = N, se(N);
7043
7027
  }, [se]);
7044
- let de = Ne.length > 0 ? fe : ei;
7028
+ let de = Ne.length > 0 ? me : ei;
7045
7029
  if (C?.isRecording) {
7046
7030
  const U = (C.startSample + C.durationSamples) / q;
7047
7031
  de = Math.max(de, U + 10);
7048
7032
  }
7049
- const me = Math.floor(de * q / re), je = async (N) => {
7050
- console.log("Annotation clicked:", N.id), O(N.id);
7033
+ const pe = Math.floor(de * q / re), je = async (N) => {
7034
+ console.log("Annotation clicked:", N.id), Y(N.id);
7051
7035
  const U = M ? void 0 : N.end - N.start;
7052
- await te(N.start, U);
7036
+ await ee(N.start, U);
7053
7037
  }, Je = D((N) => {
7054
- if (N >= 0 && N < K.length) {
7055
- const U = K[N];
7056
- ye(U.id);
7038
+ if (N >= 0 && N < O.length) {
7039
+ const U = O[N];
7040
+ Ce(U.id);
7057
7041
  }
7058
- }, [K, ye]), Le = (N) => {
7059
- const U = N.currentTarget.getBoundingClientRect(), ce = ae.show ? ae.width : 0, Me = (N.clientX - U.left - ce) * re / q, le = N.clientY - U.top;
7060
- let Be = 0, Ye = -1;
7042
+ }, [O, Ce]), Le = (N) => {
7043
+ const U = N.currentTarget.getBoundingClientRect(), ce = ae.show ? ae.width : 0, $e = (N.clientX - U.left - ce) * re / q, le = N.clientY - U.top;
7044
+ let Me = 0, Ye = -1;
7061
7045
  for (let Qe = 0; Qe < ke.length; Qe++) {
7062
- const qe = ke[Qe], dt = (qe.length > 0 ? Math.max(...qe.map((nt) => nt.peaks.data.length)) : 1) * he + (g ? 22 : 0);
7063
- if (le >= Be && le < Be + dt) {
7046
+ const qe = ke[Qe], dt = (qe.length > 0 ? Math.max(...qe.map((nt) => nt.peaks.data.length)) : 1) * fe + (g ? 22 : 0);
7047
+ if (le >= Me && le < Me + dt) {
7064
7048
  Ye = Qe;
7065
7049
  break;
7066
7050
  }
7067
- Be += dt;
7051
+ Me += dt;
7068
7052
  }
7069
- Ye !== -1 && Je(Ye), et(!0), we(Me), oe(Me, Me);
7053
+ Ye !== -1 && Je(Ye), et(!0), ve($e), oe($e, $e);
7070
7054
  }, tt = (N) => {
7071
- if (!pe) return;
7072
- const U = N.currentTarget.getBoundingClientRect(), ce = ae.show ? ae.width : 0, Me = (N.clientX - U.left - ce) * re / q, Pe = Math.min(w, Me), le = Math.max(w, Me);
7055
+ if (!he) return;
7056
+ const U = N.currentTarget.getBoundingClientRect(), ce = ae.show ? ae.width : 0, $e = (N.clientX - U.left - ce) * re / q, Pe = Math.min(w, $e), le = Math.max(w, $e);
7073
7057
  oe(Pe, le);
7074
7058
  }, bt = (N) => {
7075
- if (!pe) return;
7059
+ if (!he) return;
7076
7060
  et(!1);
7077
- const U = N.currentTarget.getBoundingClientRect(), ce = ae.show ? ae.width : 0, Me = (N.clientX - U.left - ce) * re / q, Pe = Math.min(w, Me), le = Math.max(w, Me);
7078
- Math.abs(le - Pe) < 0.1 ? (we(Pe), p && F.current ? (F.current.stop(), te(Pe)) : F.current && F.current.stop()) : oe(Pe, le);
7061
+ const U = N.currentTarget.getBoundingClientRect(), ce = ae.show ? ae.width : 0, $e = (N.clientX - U.left - ce) * re / q, Pe = Math.min(w, $e), le = Math.max(w, $e);
7062
+ Math.abs(le - Pe) < 0.1 ? (ve(Pe), p && F.current ? (F.current.stop(), ee(Pe)) : F.current && F.current.stop()) : oe(Pe, le);
7079
7063
  };
7080
- return K.some((N) => N.clips.length > 0) && (Ne.length === 0 || ke.length === 0) ? /* @__PURE__ */ I("div", { className: u, children: "Loading waveform..." }) : /* @__PURE__ */ I(Nn, { children: /* @__PURE__ */ ne(
7064
+ return O.some((N) => N.clips.length > 0) && (Ne.length === 0 || ke.length === 0) ? /* @__PURE__ */ I("div", { className: u, children: "Loading waveform..." }) : /* @__PURE__ */ I(Nn, { children: /* @__PURE__ */ ne(
7081
7065
  Tt.Provider,
7082
7066
  {
7083
7067
  value: {
7084
7068
  samplesPerPixel: re,
7085
7069
  sampleRate: q,
7086
7070
  zoomLevels: [re],
7087
- waveHeight: he,
7088
- timeScaleHeight: xe,
7071
+ waveHeight: fe,
7072
+ timeScaleHeight: ye,
7089
7073
  duration: de,
7090
7074
  controls: ae,
7091
- barWidth: Se,
7092
- barGap: be
7075
+ barWidth: Te,
7076
+ barGap: we
7093
7077
  },
7094
7078
  children: [
7095
7079
  /* @__PURE__ */ I(
@@ -7098,16 +7082,16 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7098
7082
  theme: m,
7099
7083
  backgroundColor: st(m.waveOutlineColor),
7100
7084
  timescaleBackgroundColor: m.timescaleBackgroundColor,
7101
- scrollContainerWidth: me + (ae.show ? ae.width : 0),
7102
- timescaleWidth: me,
7103
- tracksWidth: me,
7085
+ scrollContainerWidth: pe + (ae.show ? ae.width : 0),
7086
+ timescaleWidth: pe,
7087
+ tracksWidth: pe,
7104
7088
  controlsWidth: ae.show ? ae.width : 0,
7105
7089
  onTracksMouseDown: Le,
7106
7090
  onTracksMouseMove: tt,
7107
7091
  onTracksMouseUp: bt,
7108
- scrollContainerRef: ee,
7109
- isSelecting: pe,
7110
- timescale: xe > 0 ? /* @__PURE__ */ ne(ot, { children: [
7092
+ scrollContainerRef: te,
7093
+ isSelecting: he,
7094
+ timescale: ye > 0 ? /* @__PURE__ */ ne(ot, { children: [
7111
7095
  /* @__PURE__ */ I(
7112
7096
  On,
7113
7097
  {
@@ -7126,41 +7110,41 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7126
7110
  markerColor: m.loopMarkerColor,
7127
7111
  regionColor: m.loopRegionColor,
7128
7112
  minPosition: 0,
7129
- maxPosition: me,
7113
+ maxPosition: pe,
7130
7114
  controlsOffset: ae.show ? ae.width : 0,
7131
7115
  onLoopRegionChange: (N, U) => {
7132
- const ce = N * re / q, $e = U * re / q;
7133
- Ke(ce, $e);
7116
+ const ce = N * re / q, Se = U * re / q;
7117
+ Ke(ce, Se);
7134
7118
  }
7135
7119
  }
7136
7120
  )
7137
7121
  ] }) : void 0,
7138
7122
  children: /* @__PURE__ */ ne(ot, { children: [
7139
7123
  ke.map((N, U) => {
7140
- const ce = K[U];
7124
+ const ce = O[U];
7141
7125
  if (!ce) return null;
7142
- const $e = Ue[U] || {
7126
+ const Se = Ue[U] || {
7143
7127
  name: `Track ${U + 1}`,
7144
7128
  muted: !1,
7145
7129
  soloed: !1,
7146
7130
  volume: 1,
7147
7131
  pan: 0
7148
- }, Me = e ? e(U) : /* @__PURE__ */ ne(yo, { onClick: () => Je(U), children: [
7149
- /* @__PURE__ */ I(xo, { style: { justifyContent: "center" }, children: $e.name || `Track ${U + 1}` }),
7132
+ }, $e = e ? e(U) : /* @__PURE__ */ ne(yo, { onClick: () => Je(U), children: [
7133
+ /* @__PURE__ */ I(xo, { style: { justifyContent: "center" }, children: Se.name || `Track ${U + 1}` }),
7150
7134
  /* @__PURE__ */ ne(Co, { children: [
7151
7135
  /* @__PURE__ */ I(
7152
7136
  fn,
7153
7137
  {
7154
- $variant: $e.muted ? "danger" : "outline",
7155
- onClick: () => X(U, !$e.muted),
7138
+ $variant: Se.muted ? "danger" : "outline",
7139
+ onClick: () => G(U, !Se.muted),
7156
7140
  children: "Mute"
7157
7141
  }
7158
7142
  ),
7159
7143
  /* @__PURE__ */ I(
7160
7144
  fn,
7161
7145
  {
7162
- $variant: $e.soloed ? "info" : "outline",
7163
- onClick: () => V(U, !$e.soloed),
7146
+ $variant: Se.soloed ? "info" : "outline",
7147
+ onClick: () => V(U, !Se.soloed),
7164
7148
  children: "Solo"
7165
7149
  }
7166
7150
  )
@@ -7173,7 +7157,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7173
7157
  min: "0",
7174
7158
  max: "1",
7175
7159
  step: "0.01",
7176
- value: $e.volume,
7160
+ value: Se.volume,
7177
7161
  onChange: (le) => Q(U, parseFloat(le.target.value))
7178
7162
  }
7179
7163
  ),
@@ -7187,32 +7171,32 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7187
7171
  min: "-1",
7188
7172
  max: "1",
7189
7173
  step: "0.01",
7190
- value: $e.pan,
7174
+ value: Se.pan,
7191
7175
  onChange: (le) => ie(U, parseFloat(le.target.value))
7192
7176
  }
7193
7177
  ),
7194
7178
  /* @__PURE__ */ I("span", { children: "R" })
7195
7179
  ] })
7196
7180
  ] }), Pe = N.length > 0 ? Math.max(...N.map((le) => le.peaks.data.length)) : 1;
7197
- return /* @__PURE__ */ I(Ut.Provider, { value: Me, children: /* @__PURE__ */ ne(
7181
+ return /* @__PURE__ */ I(Ut.Provider, { value: $e, children: /* @__PURE__ */ ne(
7198
7182
  Kn,
7199
7183
  {
7200
7184
  numChannels: Pe,
7201
7185
  backgroundColor: st(m.waveOutlineColor),
7202
7186
  offset: 0,
7203
- width: me,
7187
+ width: pe,
7204
7188
  hasClipHeaders: g,
7205
7189
  trackId: ce.id,
7206
7190
  isSelected: ce.id === _,
7207
7191
  children: [
7208
- N.map((le, Be) => {
7192
+ N.map((le, Me) => {
7209
7193
  const Ye = le.peaks, Qe = Ye.length;
7210
7194
  return /* @__PURE__ */ I(
7211
7195
  Xt,
7212
7196
  {
7213
7197
  clipId: le.clipId,
7214
7198
  trackIndex: U,
7215
- clipIndex: Be,
7199
+ clipIndex: Me,
7216
7200
  trackName: le.trackName,
7217
7201
  startSample: le.startSample,
7218
7202
  durationSamples: le.durationSamples,
@@ -7240,10 +7224,10 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7240
7224
  clipStartSample: le.startSample,
7241
7225
  clipDurationSamples: le.durationSamples
7242
7226
  },
7243
- `${U}-${Be}-${ze}`
7227
+ `${U}-${Me}-${ze}`
7244
7228
  ))
7245
7229
  },
7246
- `${U}-${Be}`
7230
+ `${U}-${Me}`
7247
7231
  );
7248
7232
  }),
7249
7233
  C?.isRecording && C.trackId === ce.id && C.peaks.length > 0 && /* @__PURE__ */ I(
@@ -7280,20 +7264,20 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7280
7264
  }
7281
7265
  ) }, ce.id);
7282
7266
  }),
7283
- k.length > 0 && /* @__PURE__ */ I(tr, { height: 30, width: me, children: k.map((N, U) => {
7284
- const ce = N.start * q / re, $e = N.end * q / re, Me = i ? i(N, U) : N.id;
7267
+ A.length > 0 && /* @__PURE__ */ I(tr, { height: 30, width: pe, children: A.map((N, U) => {
7268
+ const ce = N.start * q / re, Se = N.end * q / re, $e = i ? i(N, U) : N.id;
7285
7269
  return /* @__PURE__ */ I(
7286
7270
  er,
7287
7271
  {
7288
7272
  annotationId: N.id,
7289
7273
  annotationIndex: U,
7290
7274
  startPosition: ce,
7291
- endPosition: $e,
7292
- label: Me,
7275
+ endPosition: Se,
7276
+ label: $e,
7293
7277
  color: "#ff9800",
7294
7278
  isActive: N.id === $,
7295
7279
  onClick: () => je(N),
7296
- editable: A
7280
+ editable: k
7297
7281
  },
7298
7282
  N.id
7299
7283
  );
@@ -7330,16 +7314,16 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7330
7314
  ] })
7331
7315
  }
7332
7316
  ),
7333
- k.length > 0 && /* @__PURE__ */ I(
7317
+ A.length > 0 && /* @__PURE__ */ I(
7334
7318
  nr,
7335
7319
  {
7336
- annotations: k,
7320
+ annotations: A,
7337
7321
  activeAnnotationId: $ ?? void 0,
7338
7322
  shouldScrollToActive: !0,
7339
7323
  scrollActivePosition: l,
7340
7324
  scrollActiveContainer: c,
7341
- editable: A,
7342
- controls: A ? r : void 0,
7325
+ editable: k,
7326
+ controls: k ? r : void 0,
7343
7327
  annotationListConfig: { linkEndpoints: B, continuousPlay: M },
7344
7328
  height: s,
7345
7329
  renderAnnotationItem: o,
@@ -7489,38 +7473,38 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7489
7473
  peaksDataArray: f,
7490
7474
  sampleRate: w,
7491
7475
  waveHeight: y,
7492
- timeScaleHeight: k,
7476
+ timeScaleHeight: A,
7493
7477
  samplesPerPixel: $,
7494
- controls: A,
7478
+ controls: k,
7495
7479
  playoutRef: B,
7496
7480
  barWidth: M,
7497
7481
  barGap: _
7498
- } = Jt(), [T, z] = W(0), [P, Z] = W(0), [O, X] = W(!1), V = R(null), Q = D((K) => {
7499
- V.current = K, x(K);
7500
- }, [x]), ie = Math.floor(v * w / $), oe = D(async (K) => {
7501
- m(K.id), b(K.start);
7502
- }, [m, b]), te = D((K) => {
7503
- p(K), a?.(K);
7504
- }, [p, a]), { onDragStart: se, onDragMove: ye, onDragEnd: we } = Cs({
7482
+ } = Jt(), [T, z] = W(0), [P, Z] = W(0), [Y, G] = W(!1), V = R(null), Q = D((O) => {
7483
+ V.current = O, x(O);
7484
+ }, [x]), ie = Math.floor(v * w / $), oe = D(async (O) => {
7485
+ m(O.id), b(O.start);
7486
+ }, [m, b]), ee = D((O) => {
7487
+ p(O), a?.(O);
7488
+ }, [p, a]), { onDragStart: se, onDragMove: Ce, onDragEnd: ve } = Cs({
7505
7489
  annotations: g,
7506
- onAnnotationsChange: te,
7490
+ onAnnotationsChange: ee,
7507
7491
  samplesPerPixel: $,
7508
7492
  sampleRate: w,
7509
7493
  duration: v,
7510
7494
  linkEndpoints: !0
7511
- }), Ke = D((K) => {
7512
- const fe = K.currentTarget.getBoundingClientRect(), re = A.show ? A.width : 0, he = (K.clientX - fe.left - re) * $ / w;
7513
- X(!0), z(he), Z(he);
7514
- }, [A, $, w]), Ne = D((K) => {
7515
- if (!O) return;
7516
- const fe = K.currentTarget.getBoundingClientRect(), re = A.show ? A.width : 0, he = (K.clientX - fe.left - re) * $ / w;
7517
- Z(he);
7518
- }, [O, A, $, w]), ke = D((K) => {
7519
- if (!O) return;
7520
- X(!1);
7521
- const fe = K.currentTarget.getBoundingClientRect(), re = A.show ? A.width : 0, he = (K.clientX - fe.left - re) * $ / w, xe = Math.min(T, he), ae = Math.max(T, he);
7522
- Math.abs(ae - xe) < 0.1 ? (C(xe), z(xe), Z(xe), c && B.current && (B.current.stop(), b(xe))) : (z(xe), Z(ae));
7523
- }, [O, T, $, w, A, C, c, B, b]);
7495
+ }), Ke = D((O) => {
7496
+ const me = O.currentTarget.getBoundingClientRect(), re = k.show ? k.width : 0, fe = (O.clientX - me.left - re) * $ / w;
7497
+ G(!0), z(fe), Z(fe);
7498
+ }, [k, $, w]), Ne = D((O) => {
7499
+ if (!Y) return;
7500
+ const me = O.currentTarget.getBoundingClientRect(), re = k.show ? k.width : 0, fe = (O.clientX - me.left - re) * $ / w;
7501
+ Z(fe);
7502
+ }, [Y, k, $, w]), ke = D((O) => {
7503
+ if (!Y) return;
7504
+ G(!1);
7505
+ const me = O.currentTarget.getBoundingClientRect(), re = k.show ? k.width : 0, fe = (O.clientX - me.left - re) * $ / w, ye = Math.min(T, fe), ae = Math.max(T, fe);
7506
+ Math.abs(ae - ye) < 0.1 ? (C(ye), z(ye), Z(ye), c && B.current && (B.current.stop(), b(ye))) : (z(ye), Z(ae));
7507
+ }, [Y, T, $, w, k, C, c, B, b]);
7524
7508
  if (f.length === 0)
7525
7509
  return /* @__PURE__ */ I("div", { className: i, children: "Loading waveform..." });
7526
7510
  const Ue = null;
@@ -7532,9 +7516,9 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7532
7516
  sampleRate: w,
7533
7517
  zoomLevels: [$],
7534
7518
  waveHeight: y,
7535
- timeScaleHeight: k,
7519
+ timeScaleHeight: A,
7536
7520
  duration: v,
7537
- controls: A,
7521
+ controls: k,
7538
7522
  barWidth: M,
7539
7523
  barGap: _
7540
7524
  },
@@ -7545,16 +7529,16 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7545
7529
  theme: l,
7546
7530
  backgroundColor: st(l.waveOutlineColor),
7547
7531
  timescaleBackgroundColor: l.timescaleBackgroundColor,
7548
- scrollContainerWidth: ie + (A.show ? A.width : 0),
7532
+ scrollContainerWidth: ie + (k.show ? k.width : 0),
7549
7533
  timescaleWidth: ie,
7550
7534
  tracksWidth: ie,
7551
- controlsWidth: A.show ? A.width : 0,
7535
+ controlsWidth: k.show ? k.width : 0,
7552
7536
  onTracksMouseDown: Ke,
7553
7537
  onTracksMouseMove: Ne,
7554
7538
  onTracksMouseUp: ke,
7555
7539
  scrollContainerRef: Q,
7556
- isSelecting: O,
7557
- timescale: k > 0 ? /* @__PURE__ */ I(
7540
+ isSelecting: Y,
7541
+ timescale: A > 0 ? /* @__PURE__ */ I(
7558
7542
  On,
7559
7543
  {
7560
7544
  duration: v * 1e3,
@@ -7564,8 +7548,8 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7564
7548
  }
7565
7549
  ) : void 0,
7566
7550
  children: /* @__PURE__ */ ne(ot, { children: [
7567
- f.map((K, fe) => {
7568
- const re = K.length > 0 ? Math.max(...K.map((q) => q.peaks.data.length)) : 1;
7551
+ f.map((O, me) => {
7552
+ const re = O.length > 0 ? Math.max(...O.map((q) => q.peaks.data.length)) : 1;
7569
7553
  return /* @__PURE__ */ I(Ut.Provider, { value: Ue, children: /* @__PURE__ */ I(
7570
7554
  Kn,
7571
7555
  {
@@ -7574,16 +7558,16 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7574
7558
  offset: 0,
7575
7559
  width: ie,
7576
7560
  hasClipHeaders: !1,
7577
- trackId: `media-element-track-${fe}`,
7561
+ trackId: `media-element-track-${me}`,
7578
7562
  isSelected: !0,
7579
- children: K.map((q, he) => {
7580
- const xe = q.peaks, ae = xe.length;
7563
+ children: O.map((q, fe) => {
7564
+ const ye = q.peaks, ae = ye.length;
7581
7565
  return /* @__PURE__ */ I(
7582
7566
  Xt,
7583
7567
  {
7584
7568
  clipId: q.clipId,
7585
- trackIndex: fe,
7586
- clipIndex: he,
7569
+ trackIndex: me,
7570
+ clipIndex: fe,
7587
7571
  trackName: q.trackName,
7588
7572
  startSample: q.startSample,
7589
7573
  durationSamples: q.durationSamples,
@@ -7591,49 +7575,49 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7591
7575
  showHeader: !1,
7592
7576
  disableHeaderDrag: !0,
7593
7577
  isSelected: !0,
7594
- trackId: `media-element-track-${fe}`,
7595
- children: xe.data.map((F, Se) => /* @__PURE__ */ I(
7578
+ trackId: `media-element-track-${me}`,
7579
+ children: ye.data.map((F, Te) => /* @__PURE__ */ I(
7596
7580
  ii,
7597
7581
  {
7598
- index: Se,
7582
+ index: Te,
7599
7583
  data: F,
7600
- bits: xe.bits,
7584
+ bits: ye.bits,
7601
7585
  length: ae,
7602
7586
  clipStartSample: q.startSample,
7603
7587
  clipDurationSamples: q.durationSamples
7604
7588
  },
7605
- `${fe}-${he}-${Se}`
7589
+ `${me}-${fe}-${Te}`
7606
7590
  ))
7607
7591
  },
7608
- `${fe}-${he}`
7592
+ `${me}-${fe}`
7609
7593
  );
7610
7594
  })
7611
7595
  }
7612
- ) }, fe);
7596
+ ) }, me);
7613
7597
  }),
7614
7598
  g.length > 0 && /* @__PURE__ */ I(
7615
7599
  ma,
7616
7600
  {
7617
7601
  onDragStart: se,
7618
- onDragMove: ye,
7619
- onDragEnd: we,
7602
+ onDragMove: Ce,
7603
+ onDragEnd: ve,
7620
7604
  modifiers: r ? [fa] : [],
7621
- children: /* @__PURE__ */ I(tr, { height: 30, width: ie, children: g.map((K, fe) => {
7622
- const re = K.start * w / $, q = K.end * w / $, he = t ? t(K, fe) : K.id;
7605
+ children: /* @__PURE__ */ I(tr, { height: 30, width: ie, children: g.map((O, me) => {
7606
+ const re = O.start * w / $, q = O.end * w / $, fe = t ? t(O, me) : O.id;
7623
7607
  return /* @__PURE__ */ I(
7624
7608
  er,
7625
7609
  {
7626
- annotationId: K.id,
7627
- annotationIndex: fe,
7610
+ annotationId: O.id,
7611
+ annotationIndex: me,
7628
7612
  startPosition: re,
7629
7613
  endPosition: q,
7630
- label: he,
7614
+ label: fe,
7631
7615
  color: "#ff9800",
7632
- isActive: K.id === h,
7633
- onClick: () => oe(K),
7616
+ isActive: O.id === h,
7617
+ onClick: () => oe(O),
7634
7618
  editable: r
7635
7619
  },
7636
- K.id
7620
+ O.id
7637
7621
  );
7638
7622
  }) })
7639
7623
  }
@@ -7641,8 +7625,8 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7641
7625
  T !== P && /* @__PURE__ */ I(
7642
7626
  Hn,
7643
7627
  {
7644
- startPosition: Math.min(T, P) * w / $ + (A.show ? A.width : 0),
7645
- endPosition: Math.max(T, P) * w / $ + (A.show ? A.width : 0),
7628
+ startPosition: Math.min(T, P) * w / $ + (k.show ? k.width : 0),
7629
+ endPosition: Math.max(T, P) * w / $ + (k.show ? k.width : 0),
7646
7630
  color: l.selectionColor
7647
7631
  }
7648
7632
  ),
@@ -7650,7 +7634,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7650
7634
  ni,
7651
7635
  {
7652
7636
  color: l.playheadColor,
7653
- controlsOffset: A.show ? A.width : 0
7637
+ controlsOffset: k.show ? k.width : 0
7654
7638
  }
7655
7639
  )
7656
7640
  ] })
@@ -7667,7 +7651,7 @@ const ur = De(null), dr = De(null), mr = De(null), fr = De(null), Ri = ({
7667
7651
  editable: r,
7668
7652
  annotationListConfig: { linkEndpoints: !0, continuousPlay: d },
7669
7653
  height: e,
7670
- onAnnotationUpdate: te,
7654
+ onAnnotationUpdate: ee,
7671
7655
  renderAnnotationItem: n
7672
7656
  }
7673
7657
  )
@@ -7730,8 +7714,8 @@ export {
7730
7714
  Ls as useMediaElementState,
7731
7715
  Fe as usePlaybackAnimation,
7732
7716
  xi as usePlaybackShortcuts,
7733
- ve as usePlaylistControls,
7734
- Te as usePlaylistData,
7717
+ be as usePlaylistControls,
7718
+ De as usePlaylistData,
7735
7719
  Ge as usePlaylistState,
7736
7720
  hs as useTimeFormat,
7737
7721
  Bi as useTrackDynamicEffects,