@waveform-playlist/browser 5.0.0-alpha.7 → 5.0.0-alpha.9

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.js CHANGED
@@ -1,28 +1,28 @@
1
- "use strict";var Ca=Object.create;var Pn=Object.defineProperty;var xa=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var ya=Object.getPrototypeOf,Ia=Object.prototype.hasOwnProperty;var Sa=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of wa(t))!Ia.call(e,a)&&a!==n&&Pn(e,a,{get:()=>t[a],enumerable:!(r=xa(t,a))||r.enumerable});return e};var Aa=(e,t,n)=>(n=e!=null?Ca(ya(e)):{},Sa(t||!e||!e.__esModule?Pn(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("tone"),c=require("react"),k=require("styled-components");require("react-dom");var cn=typeof document<"u"?document.currentScript:null;function Fr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Wr=Fr(P),J=Fr(c);var Vt={exports:{}},kt={};var Vn;function ka(){if(Vn)return kt;Vn=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,s){var o=null;if(s!==void 0&&(o=""+s),a.key!==void 0&&(o=""+a.key),"key"in a){s={};for(var i in a)i!=="key"&&(s[i]=a[i])}else s=a;return a=s.ref,{$$typeof:e,type:r,key:o,ref:a!==void 0?a:null,props:s}}return kt.Fragment=t,kt.jsx=n,kt.jsxs=n,kt}var $t={};var jn;function $a(){return jn||(jn=1,process.env.NODE_ENV!=="production"&&(function(){function e(A){if(A==null)return null;if(typeof A=="function")return A.$$typeof===T?null:A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case v:return"Fragment";case C:return"Profiler";case m:return"StrictMode";case I:return"Suspense";case E:return"SuspenseList";case B:return"Activity"}if(typeof A=="object")switch(typeof A.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),A.$$typeof){case y:return"Portal";case g:return A.displayName||"Context";case w:return(A._context.displayName||"Context")+".Consumer";case S:var j=A.render;return A=A.displayName,A||(A=j.displayName||j.name||"",A=A!==""?"ForwardRef("+A+")":"ForwardRef"),A;case D:return j=A.displayName||null,j!==null?j:e(A.type)||"Memo";case _:j=A._payload,A=A._init;try{return e(A(j))}catch{}}return null}function t(A){return""+A}function n(A){try{t(A);var j=!1}catch{j=!0}if(j){j=console;var H=j.error,K=typeof Symbol=="function"&&Symbol.toStringTag&&A[Symbol.toStringTag]||A.constructor.name||"Object";return H.call(j,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",K),t(A)}}function r(A){if(A===v)return"<>";if(typeof A=="object"&&A!==null&&A.$$typeof===_)return"<...>";try{var j=e(A);return j?"<"+j+">":"<...>"}catch{return"<...>"}}function a(){var A=V.A;return A===null?null:A.getOwner()}function s(){return Error("react-stack-top-frame")}function o(A){if(W.call(A,"key")){var j=Object.getOwnPropertyDescriptor(A,"key").get;if(j&&j.isReactWarning)return!1}return A.key!==void 0}function i(A,j){function H(){G||(G=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",j))}H.isReactWarning=!0,Object.defineProperty(A,"key",{get:H,configurable:!0})}function l(){var A=e(this.type);return Q[A]||(Q[A]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),A=this.props.ref,A!==void 0?A:null}function u(A,j,H,K,be,Be){var ie=H.ref;return A={$$typeof:x,type:A,key:j,props:H,_owner:K},(ie!==void 0?ie:null)!==null?Object.defineProperty(A,"ref",{enumerable:!1,get:l}):Object.defineProperty(A,"ref",{enumerable:!1,value:null}),A._store={},Object.defineProperty(A._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(A,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(A,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:be}),Object.defineProperty(A,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Be}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A}function d(A,j,H,K,be,Be){var ie=j.children;if(ie!==void 0)if(K)if(O(ie)){for(K=0;K<ie.length;K++)b(ie[K]);Object.freeze&&Object.freeze(ie)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(ie);if(W.call(j,"key")){ie=e(A);var De=Object.keys(j).filter(function(he){return he!=="key"});K=0<De.length?"{key: someKey, "+De.join(": ..., ")+": ...}":"{key: someKey}",oe[ie+K]||(De=0<De.length?"{"+De.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ "use strict";var wa=Object.create;var Pn=Object.defineProperty;var xa=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var Ia=Object.getPrototypeOf,Sa=Object.prototype.hasOwnProperty;var Aa=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ya(t))!Sa.call(e,a)&&a!==n&&Pn(e,a,{get:()=>t[a],enumerable:!(r=xa(t,a))||r.enumerable});return e};var ka=(e,t,n)=>(n=e!=null?wa(Ia(e)):{},Aa(t||!e||!e.__esModule?Pn(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("tone"),c=require("react"),k=require("styled-components");require("react-dom");var cn=typeof document<"u"?document.currentScript:null;function Fr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Wr=Fr(P),Q=Fr(c);var jt={exports:{}},kt={};var Vn;function $a(){if(Vn)return kt;Vn=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,s){var o=null;if(s!==void 0&&(o=""+s),a.key!==void 0&&(o=""+a.key),"key"in a){s={};for(var l in a)l!=="key"&&(s[l]=a[l])}else s=a;return a=s.ref,{$$typeof:e,type:r,key:o,ref:a!==void 0?a:null,props:s}}return kt.Fragment=t,kt.jsx=n,kt.jsxs=n,kt}var $t={};var jn;function Ra(){return jn||(jn=1,process.env.NODE_ENV!=="production"&&(function(){function e(A){if(A==null)return null;if(typeof A=="function")return A.$$typeof===D?null:A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case g:return"Fragment";case w:return"Profiler";case m:return"StrictMode";case I:return"Suspense";case $:return"SuspenseList";case _:return"Activity"}if(typeof A=="object")switch(typeof A.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),A.$$typeof){case y:return"Portal";case v:return A.displayName||"Context";case x:return(A._context.displayName||"Context")+".Consumer";case S:var j=A.render;return A=A.displayName,A||(A=j.displayName||j.name||"",A=A!==""?"ForwardRef("+A+")":"ForwardRef"),A;case M:return j=A.displayName||null,j!==null?j:e(A.type)||"Memo";case T:j=A._payload,A=A._init;try{return e(A(j))}catch{}}return null}function t(A){return""+A}function n(A){try{t(A);var j=!1}catch{j=!0}if(j){j=console;var H=j.error,U=typeof Symbol=="function"&&Symbol.toStringTag&&A[Symbol.toStringTag]||A.constructor.name||"Object";return H.call(j,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",U),t(A)}}function r(A){if(A===g)return"<>";if(typeof A=="object"&&A!==null&&A.$$typeof===T)return"<...>";try{var j=e(A);return j?"<"+j+">":"<...>"}catch{return"<...>"}}function a(){var A=V.A;return A===null?null:A.getOwner()}function s(){return Error("react-stack-top-frame")}function o(A){if(W.call(A,"key")){var j=Object.getOwnPropertyDescriptor(A,"key").get;if(j&&j.isReactWarning)return!1}return A.key!==void 0}function l(A,j){function H(){Y||(Y=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",j))}H.isReactWarning=!0,Object.defineProperty(A,"key",{get:H,configurable:!0})}function i(){var A=e(this.type);return ee[A]||(ee[A]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),A=this.props.ref,A!==void 0?A:null}function u(A,j,H,U,ge,Be){var ie=H.ref;return A={$$typeof:C,type:A,key:j,props:H,_owner:U},(ie!==void 0?ie:null)!==null?Object.defineProperty(A,"ref",{enumerable:!1,get:i}):Object.defineProperty(A,"ref",{enumerable:!1,value:null}),A._store={},Object.defineProperty(A._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(A,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(A,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ge}),Object.defineProperty(A,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Be}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A}function d(A,j,H,U,ge,Be){var ie=j.children;if(ie!==void 0)if(U)if(O(ie)){for(U=0;U<ie.length;U++)b(ie[U]);Object.freeze&&Object.freeze(ie)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(ie);if(W.call(j,"key")){ie=e(A);var Te=Object.keys(j).filter(function(me){return me!=="key"});U=0<Te.length?"{key: someKey, "+Te.join(": ..., ")+": ...}":"{key: someKey}",oe[ie+U]||(Te=0<Te.length?"{"+Te.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,K,ie,De,ie),oe[ie+K]=!0)}if(ie=null,H!==void 0&&(n(H),ie=""+H),o(j)&&(n(j.key),ie=""+j.key),"key"in j){H={};for(var ue in j)ue!=="key"&&(H[ue]=j[ue])}else H=j;return ie&&i(H,typeof A=="function"?A.displayName||A.name||"Unknown":A),u(A,ie,H,a(),be,Be)}function b(A){p(A)?A._store&&(A._store.validated=1):typeof A=="object"&&A!==null&&A.$$typeof===_&&(A._payload.status==="fulfilled"?p(A._payload.value)&&A._payload.value._store&&(A._payload.value._store.validated=1):A._store&&(A._store.validated=1))}function p(A){return typeof A=="object"&&A!==null&&A.$$typeof===x}var f=c,x=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),g=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),T=Symbol.for("react.client.reference"),V=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=Object.prototype.hasOwnProperty,O=Array.isArray,X=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(A){return A()}};var G,Q={},ne=f.react_stack_bottom_frame.bind(f,s)(),L=X(r(s)),oe={};$t.Fragment=v,$t.jsx=function(A,j,H){var K=1e4>V.recentlyCreatedOwnerStacks++;return d(A,j,H,!1,K?Error("react-stack-top-frame"):ne,K?X(r(A)):L)},$t.jsxs=function(A,j,H){var K=1e4>V.recentlyCreatedOwnerStacks++;return d(A,j,H,!0,K?Error("react-stack-top-frame"):ne,K?X(r(A)):L)}})()),$t}var zn;function Ra(){return zn||(zn=1,process.env.NODE_ENV==="production"?Vt.exports=ka():Vt.exports=$a()),Vt.exports}var Z=Ra();function On(e,t){const n=new Float32Array(e),r=e-1;for(let a=0;a<e;a++){const s=a/r;n[a]=t?s:1-s}return n}function Ea(e,t){const n=new Float32Array(e),r=e-1;for(let a=0;a<e;a++){const s=a/r,o=t?a:e-1-a;n[o]=Math.exp(2*s-1)/Math.E}return n}function Ta(e,t){const n=new Float32Array(e),r=t?Math.PI/2:-Math.PI/2;for(let a=0;a<e;a++)n[a]=Math.sin(Math.PI*a/e-r)/2+.5;return n}function Da(e,t,n=10){const r=new Float32Array(e);for(let a=0;a<e;a++){const s=t?a:e-1-a,o=a/e;r[s]=Math.log(1+n*o)/Math.log(1+n)}return r}function Zr(e,t,n){switch(e){case"linear":return On(t,n);case"exponential":return Ea(t,n);case"sCurve":return Ta(t,n);case"logarithmic":return Da(t,n);default:return On(t,n)}}function Nn(e,t,n,r="linear",a=0,s=1){if(!(n<=0))if(r==="linear")e.setValueAtTime(a,t),e.linearRampToValueAtTime(s,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(a,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+n);else{const o=Zr(r,1e4,!0),i=new Float32Array(o.length),l=s-a;for(let u=0;u<o.length;u++)i[u]=a+o[u]*l;e.setValueCurveAtTime(i,t,n)}}function Ln(e,t,n,r="linear",a=1,s=0){if(!(n<=0))if(r==="linear")e.setValueAtTime(a,t),e.linearRampToValueAtTime(s,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(a,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+n);else{const o=Zr(r,1e4,!1),i=new Float32Array(o.length),l=a-s;for(let u=0;u<o.length;u++)i[u]=s+o[u]*l;e.setValueCurveAtTime(i,t,n)}}var _a=class{constructor(e){this.activePlayers=0,this.track=e.track,this.volumeNode=new P.Volume(this.gainToDb(e.track.gain)),this.panNode=new P.Panner(e.track.stereoPan),this.muteGain=new P.Gain(e.track.muted?0:1);const t=e.destination||P.getDestination();if(e.effects){const r=e.effects(this.muteGain,t,!1);r&&(this.effectsCleanup=r)}else this.muteGain.connect(t);const n=e.clips||(e.buffer?[{buffer:e.buffer,startTime:0,duration:e.buffer.duration,offset:0,fadeIn:e.track.fadeIn,fadeOut:e.track.fadeOut,gain:1}]:[]);this.clips=n.map(r=>{const a=new P.Player({url:r.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}}),s=new P.Gain(r.gain);return a.connect(s),s.chain(this.volumeNode,this.panNode,this.muteGain),{player:a,clipInfo:r,fadeGain:s,pausedPosition:0,playStartTime:0}})}scheduleFades(e,t,n=0){const{clipInfo:r,fadeGain:a}=e,s=a.gain._param;s.cancelScheduledValues(0);const o=n-r.offset;if(r.fadeIn&&o<r.fadeIn.duration){const i=r.fadeIn.duration;if(o<=0)Nn(s,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,u=o/i,d=r.gain*u;Nn(s,t,l,r.fadeIn.type||"linear",d,r.gain)}}else s.setValueAtTime(r.gain,t);if(r.fadeOut){const l=r.duration-r.fadeOut.duration-o;if(l>0){const u=t+l;Ln(s,u,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const u=-l,d=r.fadeOut.duration-u,b=u/r.fadeOut.duration,p=r.gain*(1-b);Ln(s,t,d,r.fadeOut.type||"linear",p,0)}}}gainToDb(e){return 20*Math.log10(e)}setVolume(e){this.track.gain=e,this.volumeNode.volume.value=this.gainToDb(e)}setPan(e){this.track.stereoPan=e,this.panNode.pan.value=e}setMute(e){this.track.muted=e,this.muteGain.gain.value=e?0:1}setSolo(e){this.track.soloed=e}play(e,t=0,n){const r=e??P.now();this.isPlaying&&this.stop(),this.activePlayers=0,this.clips.forEach(a=>{const{player:s,clipInfo:o}=a,i=t,l=o.startTime,u=o.startTime+o.duration;if(i<u)if(this.activePlayers++,a.playStartTime=P.now(),i>=l){const d=i-l+o.offset,b=o.duration-(i-l),p=n?Math.min(n,b):b;a.pausedPosition=d,this.scheduleFades(a,r,d),s.start(r,d,p)}else{const d=l-i,b=n?Math.min(n-d,o.duration):o.duration;d<(n??1/0)?(a.pausedPosition=o.offset,this.scheduleFades(a,r+d,o.offset),s.start(r+d,o.offset,b)):this.activePlayers--}})}pause(){this.clips.forEach(e=>{if(e.player.state==="started"){const t=(P.now()-e.playStartTime)*e.player.playbackRate;e.pausedPosition=e.pausedPosition+t}e.player.stop()}),this.activePlayers=0}stop(e){const t=e??P.now();this.clips.forEach(n=>{n.player.stop(t),n.pausedPosition=0}),this.activePlayers=0}dispose(){this.effectsCleanup&&this.effectsCleanup(),this.clips.forEach(e=>{e.player.dispose(),e.fadeGain.dispose()}),this.volumeNode.dispose(),this.panNode.dispose(),this.muteGain.dispose()}get id(){return this.track.id}get duration(){if(this.clips.length===0)return 0;const e=this.clips[this.clips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get buffer(){return this.clips[0]?.clipInfo.buffer}get isPlaying(){return this.clips.some(e=>e.player.state==="started")}get muted(){return this.track.muted}get startTime(){return this.track.startTime}setOnStopCallback(e){this.onStopCallback=e}},Ma=class{constructor(e={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this.activeTracks=new Map,this.playbackSessionId=0,this.masterVolume=new P.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,P.getDestination(),!1);t&&(this.effectsCleanup=t)}else this.masterVolume.toDestination();e.tracks&&e.tracks.forEach(t=>{this.tracks.set(t.id,t),this.manualMuteState.set(t.id,t.muted)})}gainToDb(e){return 20*Math.log10(e)}async init(){this.isInitialized||(await P.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new _a(t);return this.tracks.set(n.id,n),this.manualMuteState.set(n.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(n.id),n}applyInitialSoloState(){this.updateSoloMuting()}removeTrack(e){const t=this.tracks.get(e);t&&(t.dispose(),this.tracks.delete(e),this.manualMuteState.delete(e),this.soloedTracks.delete(e))}getTrack(e){return this.tracks.get(e)}play(e,t,n){if(!this.isInitialized){console.warn("TonePlayout not initialized. Call init() first.");return}const r=e??P.now(),a=t??0;this.playbackSessionId++;const s=this.playbackSessionId;this.activeTracks.clear(),this.tracks.forEach(o=>{const i=o.startTime;if(a>=i){const l=a-i;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r,l,n)}else{const l=i-a;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r+l,0,n)}}),t!==void 0?P.getTransport().start(r,t):P.getTransport().start(r)}pause(){P.getTransport().pause(),this.tracks.forEach(e=>{e.pause()})}stop(){P.getTransport().stop(),this.tracks.forEach(e=>{e.stop()})}setMasterGain(e){this.masterVolume.volume.value=this.gainToDb(e)}setSolo(e,t){const n=this.tracks.get(e);n&&(n.setSolo(t),t?this.soloedTracks.add(e):this.soloedTracks.delete(e),this.updateSoloMuting())}updateSoloMuting(){const e=this.soloedTracks.size>0;this.tracks.forEach((t,n)=>{if(e)if(!this.soloedTracks.has(n))t.setMute(!0);else{const r=this.manualMuteState.get(n)??!1;t.setMute(r)}else{const r=this.manualMuteState.get(n)??!1;t.setMute(r)}})}setMute(e,t){const n=this.tracks.get(e);n&&(this.manualMuteState.set(e,t),n.setMute(t))}getCurrentTime(){return P.getTransport().seconds}seekTo(e){P.getTransport().seconds=e}dispose(){this.tracks.forEach(e=>{e.dispose()}),this.tracks.clear(),this.effectsCleanup&&this.effectsCleanup(),this.masterVolume.dispose()}get context(){return P.getContext()}get sampleRate(){return P.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},jt=null;function Ba(){return jt||(jt=new P.Context,P.setContext(jt)),jt}async function un(){const e=Ba();e.state!=="running"&&await e.resume()}var zt={exports:{}},Rt={};var Xn;function Fa(){if(Xn)return Rt;Xn=1;var e=c,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(i,l,u){var d,b={},p=null,f=null;u!==void 0&&(p=""+u),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(b[d]=l[d]);if(i&&i.defaultProps)for(d in l=i.defaultProps,l)b[d]===void 0&&(b[d]=l[d]);return{$$typeof:t,type:i,key:p,ref:f,props:b,_owner:a.current}}return Rt.Fragment=n,Rt.jsx=o,Rt.jsxs=o,Rt}var Et={};var Hn;function Wa(){return Hn||(Hn=1,process.env.NODE_ENV!=="production"&&(function(){var e=c,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),x=Symbol.iterator,y="@@iterator";function v(h){if(h===null||typeof h!="object")return null;var $=x&&h[x]||h[y];return typeof $=="function"?$:null}var m=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(h){{for(var $=arguments.length,F=new Array($>1?$-1:0),U=1;U<$;U++)F[U-1]=arguments[U];w("error",h,F)}}function w(h,$,F){{var U=m.ReactDebugCurrentFrame,se=U.getStackAddendum();se!==""&&($+="%s",F=F.concat([se]));var ce=F.map(function(re){return String(re)});ce.unshift("Warning: "+$),Function.prototype.apply.call(console[h],console,ce)}}var g=!1,S=!1,I=!1,E=!1,D=!1,_;_=Symbol.for("react.module.reference");function B(h){return!!(typeof h=="string"||typeof h=="function"||h===r||h===s||D||h===a||h===u||h===d||E||h===f||g||S||I||typeof h=="object"&&h!==null&&(h.$$typeof===p||h.$$typeof===b||h.$$typeof===o||h.$$typeof===i||h.$$typeof===l||h.$$typeof===_||h.getModuleId!==void 0))}function T(h,$,F){var U=h.displayName;if(U)return U;var se=$.displayName||$.name||"";return se!==""?F+"("+se+")":F}function V(h){return h.displayName||"Context"}function W(h){if(h==null)return null;if(typeof h.tag=="number"&&C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case a:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof h=="object")switch(h.$$typeof){case i:var $=h;return V($)+".Consumer";case o:var F=h;return V(F._context)+".Provider";case l:return T(h,h.render,"ForwardRef");case b:var U=h.displayName||null;return U!==null?U:W(h.type)||"Memo";case p:{var se=h,ce=se._payload,re=se._init;try{return W(re(ce))}catch{return null}}}return null}var O=Object.assign,X=0,G,Q,ne,L,oe,A,j;function H(){}H.__reactDisabledLog=!0;function K(){{if(X===0){G=console.log,Q=console.info,ne=console.warn,L=console.error,oe=console.group,A=console.groupCollapsed,j=console.groupEnd;var h={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:h,log:h,warn:h,error:h,group:h,groupCollapsed:h,groupEnd:h})}X++}}function be(){{if(X--,X===0){var h={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},h,{value:G}),info:O({},h,{value:Q}),warn:O({},h,{value:ne}),error:O({},h,{value:L}),group:O({},h,{value:oe}),groupCollapsed:O({},h,{value:A}),groupEnd:O({},h,{value:j})})}X<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Be=m.ReactCurrentDispatcher,ie;function De(h,$,F){{if(ie===void 0)try{throw Error()}catch(se){var U=se.stack.trim().match(/\n( *(at )?)/);ie=U&&U[1]||""}return`
7
- `+ie+h}}var ue=!1,he;{var gt=typeof WeakMap=="function"?WeakMap:Map;he=new gt}function ut(h,$){if(!h||ue)return"";{var F=he.get(h);if(F!==void 0)return F}var U;ue=!0;var se=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ce;ce=Be.current,Be.current=null,K();try{if($){var re=function(){throw Error()};if(Object.defineProperty(re.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(re,[])}catch(M){U=M}Reflect.construct(h,[],re)}else{try{re.call()}catch(M){U=M}h.call(re.prototype)}}else{try{throw Error()}catch(M){U=M}h()}}catch(M){if(M&&U&&typeof M.stack=="string"){for(var te=M.stack.split(`
8
- `),ke=U.stack.split(`
9
- `),pe=te.length-1,Ce=ke.length-1;pe>=1&&Ce>=0&&te[pe]!==ke[Ce];)Ce--;for(;pe>=1&&Ce>=0;pe--,Ce--)if(te[pe]!==ke[Ce]){if(pe!==1||Ce!==1)do if(pe--,Ce--,Ce<0||te[pe]!==ke[Ce]){var Me=`
10
- `+te[pe].replace(" at new "," at ");return h.displayName&&Me.includes("<anonymous>")&&(Me=Me.replace("<anonymous>",h.displayName)),typeof h=="function"&&he.set(h,Me),Me}while(pe>=1&&Ce>=0);break}}}finally{ue=!1,Be.current=ce,be(),Error.prepareStackTrace=se}var it=h?h.displayName||h.name:"",Qe=it?De(it):"";return typeof h=="function"&&he.set(h,Qe),Qe}function de(h,$,F){return ut(h,!1)}function rt(h){var $=h.prototype;return!!($&&$.isReactComponent)}function at(h,$,F){if(h==null)return"";if(typeof h=="function")return ut(h,rt(h));if(typeof h=="string")return De(h);switch(h){case u:return De("Suspense");case d:return De("SuspenseList")}if(typeof h=="object")switch(h.$$typeof){case l:return de(h.render);case b:return at(h.type,$,F);case p:{var U=h,se=U._payload,ce=U._init;try{return at(ce(se),$,F)}catch{}}}return""}var Ue=Object.prototype.hasOwnProperty,ot={},z=m.ReactDebugCurrentFrame;function Re(h){if(h){var $=h._owner,F=at(h.type,h._source,$?$.type:null);z.setExtraStackFrame(F)}else z.setExtraStackFrame(null)}function we(h,$,F,U,se){{var ce=Function.call.bind(Ue);for(var re in h)if(ce(h,re)){var te=void 0;try{if(typeof h[re]!="function"){var ke=Error((U||"React class")+": "+F+" type `"+re+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof h[re]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ke.name="Invariant Violation",ke}te=h[re]($,re,U,F,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pe){te=pe}te&&!(te instanceof Error)&&(Re(se),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",U||"React class",F,re,typeof te),Re(null)),te instanceof Error&&!(te.message in ot)&&(ot[te.message]=!0,Re(se),C("Failed %s type: %s",F,te.message),Re(null))}}}var ve=Array.isArray;function Ze(h){return ve(h)}function Le(h){{var $=typeof Symbol=="function"&&Symbol.toStringTag,F=$&&h[Symbol.toStringTag]||h.constructor.name||"Object";return F}}function Pe(h){try{return Xe(h),!1}catch{return!0}}function Xe(h){return""+h}function He(h){if(Pe(h))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Le(h)),Xe(h)}var dt=m.ReactCurrentOwner,At={key:!0,ref:!0,__self:!0,__source:!0},Y,ee;function me(h){if(Ue.call(h,"ref")){var $=Object.getOwnPropertyDescriptor(h,"ref").get;if($&&$.isReactWarning)return!1}return h.ref!==void 0}function Ie(h){if(Ue.call(h,"key")){var $=Object.getOwnPropertyDescriptor(h,"key").get;if($&&$.isReactWarning)return!1}return h.key!==void 0}function Ee(h,$){typeof h.ref=="string"&&dt.current}function Se(h,$){{var F=function(){Y||(Y=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",$))};F.isReactWarning=!0,Object.defineProperty(h,"key",{get:F,configurable:!0})}}function le(h,$){{var F=function(){ee||(ee=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",$))};F.isReactWarning=!0,Object.defineProperty(h,"ref",{get:F,configurable:!0})}}var Ge=function(h,$,F,U,se,ce,re){var te={$$typeof:t,type:h,key:$,ref:F,props:re,_owner:ce};return te._store={},Object.defineProperty(te._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(te,"_self",{configurable:!1,enumerable:!1,writable:!1,value:U}),Object.defineProperty(te,"_source",{configurable:!1,enumerable:!1,writable:!1,value:se}),Object.freeze&&(Object.freeze(te.props),Object.freeze(te)),te};function Ye(h,$,F,U,se){{var ce,re={},te=null,ke=null;F!==void 0&&(He(F),te=""+F),Ie($)&&(He($.key),te=""+$.key),me($)&&(ke=$.ref,Ee($,se));for(ce in $)Ue.call($,ce)&&!At.hasOwnProperty(ce)&&(re[ce]=$[ce]);if(h&&h.defaultProps){var pe=h.defaultProps;for(ce in pe)re[ce]===void 0&&(re[ce]=pe[ce])}if(te||ke){var Ce=typeof h=="function"?h.displayName||h.name||"Unknown":h;te&&Se(re,Ce),ke&&le(re,Ce)}return Ge(h,te,ke,se,U,dt.current,re)}}var je=m.ReactCurrentOwner,_e=m.ReactDebugCurrentFrame;function Ae(h){if(h){var $=h._owner,F=at(h.type,h._source,$?$.type:null);_e.setExtraStackFrame(F)}else _e.setExtraStackFrame(null)}var Je;Je=!1;function ft(h){return typeof h=="object"&&h!==null&&h.$$typeof===t}function Bt(){{if(je.current){var h=W(je.current.type);if(h)return`
6
+ <%s key={someKey} {...props} />`,U,ie,Te,ie),oe[ie+U]=!0)}if(ie=null,H!==void 0&&(n(H),ie=""+H),o(j)&&(n(j.key),ie=""+j.key),"key"in j){H={};for(var ue in j)ue!=="key"&&(H[ue]=j[ue])}else H=j;return ie&&l(H,typeof A=="function"?A.displayName||A.name||"Unknown":A),u(A,ie,H,a(),ge,Be)}function b(A){p(A)?A._store&&(A._store.validated=1):typeof A=="object"&&A!==null&&A.$$typeof===T&&(A._payload.status==="fulfilled"?p(A._payload.value)&&A._payload.value._store&&(A._payload.value._store.validated=1):A._store&&(A._store.validated=1))}function p(A){return typeof A=="object"&&A!==null&&A.$$typeof===C}var f=c,C=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),v=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),D=Symbol.for("react.client.reference"),V=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=Object.prototype.hasOwnProperty,O=Array.isArray,N=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(A){return A()}};var Y,ee={},re=f.react_stack_bottom_frame.bind(f,s)(),X=N(r(s)),oe={};$t.Fragment=g,$t.jsx=function(A,j,H){var U=1e4>V.recentlyCreatedOwnerStacks++;return d(A,j,H,!1,U?Error("react-stack-top-frame"):re,U?N(r(A)):X)},$t.jsxs=function(A,j,H){var U=1e4>V.recentlyCreatedOwnerStacks++;return d(A,j,H,!0,U?Error("react-stack-top-frame"):re,U?N(r(A)):X)}})()),$t}var zn;function Ea(){return zn||(zn=1,process.env.NODE_ENV==="production"?jt.exports=$a():jt.exports=Ra()),jt.exports}var Z=Ea();function On(e,t){const n=new Float32Array(e),r=e-1;for(let a=0;a<e;a++){const s=a/r;n[a]=t?s:1-s}return n}function Da(e,t){const n=new Float32Array(e),r=e-1;for(let a=0;a<e;a++){const s=a/r,o=t?a:e-1-a;n[o]=Math.exp(2*s-1)/Math.E}return n}function Ta(e,t){const n=new Float32Array(e),r=t?Math.PI/2:-Math.PI/2;for(let a=0;a<e;a++)n[a]=Math.sin(Math.PI*a/e-r)/2+.5;return n}function _a(e,t,n=10){const r=new Float32Array(e);for(let a=0;a<e;a++){const s=t?a:e-1-a,o=a/e;r[s]=Math.log(1+n*o)/Math.log(1+n)}return r}function Zr(e,t,n){switch(e){case"linear":return On(t,n);case"exponential":return Da(t,n);case"sCurve":return Ta(t,n);case"logarithmic":return _a(t,n);default:return On(t,n)}}function Nn(e,t,n,r="linear",a=0,s=1){if(!(n<=0))if(r==="linear")e.setValueAtTime(a,t),e.linearRampToValueAtTime(s,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(a,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+n);else{const o=Zr(r,1e4,!0),l=new Float32Array(o.length),i=s-a;for(let u=0;u<o.length;u++)l[u]=a+o[u]*i;e.setValueCurveAtTime(l,t,n)}}function Ln(e,t,n,r="linear",a=1,s=0){if(!(n<=0))if(r==="linear")e.setValueAtTime(a,t),e.linearRampToValueAtTime(s,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(a,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+n);else{const o=Zr(r,1e4,!1),l=new Float32Array(o.length),i=a-s;for(let u=0;u<o.length;u++)l[u]=s+o[u]*i;e.setValueCurveAtTime(l,t,n)}}var Ma=class{constructor(e){this.activePlayers=0,this.track=e.track,this.volumeNode=new P.Volume(this.gainToDb(e.track.gain)),this.panNode=new P.Panner(e.track.stereoPan),this.muteGain=new P.Gain(e.track.muted?0:1);const t=e.destination||P.getDestination();if(e.effects){const r=e.effects(this.muteGain,t,!1);r&&(this.effectsCleanup=r)}else this.muteGain.connect(t);const n=e.clips||(e.buffer?[{buffer:e.buffer,startTime:0,duration:e.buffer.duration,offset:0,fadeIn:e.track.fadeIn,fadeOut:e.track.fadeOut,gain:1}]:[]);this.clips=n.map(r=>{const a=new P.Player({url:r.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}}),s=new P.Gain(r.gain);return a.connect(s),s.chain(this.volumeNode,this.panNode,this.muteGain),{player:a,clipInfo:r,fadeGain:s,pausedPosition:0,playStartTime:0}})}scheduleFades(e,t,n=0){const{clipInfo:r,fadeGain:a}=e,s=a.gain._param;s.cancelScheduledValues(0);const o=n-r.offset;if(r.fadeIn&&o<r.fadeIn.duration){const l=r.fadeIn.duration;if(o<=0)Nn(s,t,l,r.fadeIn.type||"linear",0,r.gain);else{const i=l-o,u=o/l,d=r.gain*u;Nn(s,t,i,r.fadeIn.type||"linear",d,r.gain)}}else s.setValueAtTime(r.gain,t);if(r.fadeOut){const i=r.duration-r.fadeOut.duration-o;if(i>0){const u=t+i;Ln(s,u,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(i>-r.fadeOut.duration){const u=-i,d=r.fadeOut.duration-u,b=u/r.fadeOut.duration,p=r.gain*(1-b);Ln(s,t,d,r.fadeOut.type||"linear",p,0)}}}gainToDb(e){return 20*Math.log10(e)}setVolume(e){this.track.gain=e,this.volumeNode.volume.value=this.gainToDb(e)}setPan(e){this.track.stereoPan=e,this.panNode.pan.value=e}setMute(e){this.track.muted=e,this.muteGain.gain.value=e?0:1}setSolo(e){this.track.soloed=e}play(e,t=0,n){this.clips.forEach(r=>{r.player.stop(),r.player.disconnect(),r.player.dispose();const a=new P.Player({url:r.clipInfo.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}});a.connect(r.fadeGain),r.player=a,r.pausedPosition=0}),this.activePlayers=0,this.clips.forEach(r=>{const{player:a,clipInfo:s}=r,o=t,l=s.startTime,i=s.startTime+s.duration;if(o<i){this.activePlayers++;const u=e??P.now();if(r.playStartTime=u,o>=l){const d=o-l+s.offset,b=s.duration-(o-l),p=n?Math.min(n,b):b;r.pausedPosition=d,this.scheduleFades(r,u,d),a.start(u,d,p)}else{const d=l-o,b=n?Math.min(n-d,s.duration):s.duration;d<(n??1/0)?(r.pausedPosition=s.offset,this.scheduleFades(r,u+d,s.offset),a.start(u+d,s.offset,b)):this.activePlayers--}}})}pause(){this.clips.forEach(e=>{if(e.player.state==="started"){const t=(P.now()-e.playStartTime)*e.player.playbackRate;e.pausedPosition=e.pausedPosition+t}e.player.stop()}),this.activePlayers=0}stop(e){const t=e??P.now();this.clips.forEach(n=>{n.player.stop(t),n.pausedPosition=0}),this.activePlayers=0}dispose(){this.effectsCleanup&&this.effectsCleanup(),this.clips.forEach(e=>{e.player.dispose(),e.fadeGain.dispose()}),this.volumeNode.dispose(),this.panNode.dispose(),this.muteGain.dispose()}get id(){return this.track.id}get duration(){if(this.clips.length===0)return 0;const e=this.clips[this.clips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get buffer(){return this.clips[0]?.clipInfo.buffer}get isPlaying(){return this.clips.some(e=>e.player.state==="started")}get muted(){return this.track.muted}get startTime(){return this.track.startTime}setOnStopCallback(e){this.onStopCallback=e}},Ba=class{constructor(e={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this.activeTracks=new Map,this.playbackSessionId=0,this.masterVolume=new P.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,P.getDestination(),!1);t&&(this.effectsCleanup=t)}else this.masterVolume.toDestination();e.tracks&&e.tracks.forEach(t=>{this.tracks.set(t.id,t),this.manualMuteState.set(t.id,t.muted)})}gainToDb(e){return 20*Math.log10(e)}async init(){this.isInitialized||(await P.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new Ma(t);return this.tracks.set(n.id,n),this.manualMuteState.set(n.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(n.id),n}applyInitialSoloState(){this.updateSoloMuting()}removeTrack(e){const t=this.tracks.get(e);t&&(t.dispose(),this.tracks.delete(e),this.manualMuteState.delete(e),this.soloedTracks.delete(e))}getTrack(e){return this.tracks.get(e)}play(e,t,n){if(!this.isInitialized){console.warn("TonePlayout not initialized. Call init() first.");return}const r=e??P.now(),a=t??0;this.playbackSessionId++;const s=this.playbackSessionId;this.activeTracks.clear(),this.tracks.forEach(o=>{const l=o.startTime;if(a>=l){const i=a-l;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r,i,n)}else{const i=l-a;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r+i,0,n)}}),t!==void 0?P.getTransport().start(r,t):P.getTransport().start(r)}pause(){P.getTransport().pause(),this.tracks.forEach(e=>{e.pause()})}stop(){P.getTransport().stop(),this.tracks.forEach(e=>{e.stop()})}setMasterGain(e){this.masterVolume.volume.value=this.gainToDb(e)}setSolo(e,t){const n=this.tracks.get(e);n&&(n.setSolo(t),t?this.soloedTracks.add(e):this.soloedTracks.delete(e),this.updateSoloMuting())}updateSoloMuting(){const e=this.soloedTracks.size>0;this.tracks.forEach((t,n)=>{if(e)if(!this.soloedTracks.has(n))t.setMute(!0);else{const r=this.manualMuteState.get(n)??!1;t.setMute(r)}else{const r=this.manualMuteState.get(n)??!1;t.setMute(r)}})}setMute(e,t){const n=this.tracks.get(e);n&&(this.manualMuteState.set(e,t),n.setMute(t))}getCurrentTime(){return P.getTransport().seconds}seekTo(e){P.getTransport().seconds=e}dispose(){this.tracks.forEach(e=>{e.dispose()}),this.tracks.clear(),this.effectsCleanup&&this.effectsCleanup(),this.masterVolume.dispose()}get context(){return P.getContext()}get sampleRate(){return P.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},zt=null;function Fa(){return zt||(zt=new P.Context,P.setContext(zt)),zt}async function un(){const e=Fa();e.state!=="running"&&await e.resume()}var Ot={exports:{}},Rt={};var Xn;function Wa(){if(Xn)return Rt;Xn=1;var e=c,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(l,i,u){var d,b={},p=null,f=null;u!==void 0&&(p=""+u),i.key!==void 0&&(p=""+i.key),i.ref!==void 0&&(f=i.ref);for(d in i)r.call(i,d)&&!s.hasOwnProperty(d)&&(b[d]=i[d]);if(l&&l.defaultProps)for(d in i=l.defaultProps,i)b[d]===void 0&&(b[d]=i[d]);return{$$typeof:t,type:l,key:p,ref:f,props:b,_owner:a.current}}return Rt.Fragment=n,Rt.jsx=o,Rt.jsxs=o,Rt}var Et={};var Hn;function Za(){return Hn||(Hn=1,process.env.NODE_ENV!=="production"&&(function(){var e=c,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),i=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),C=Symbol.iterator,y="@@iterator";function g(h){if(h===null||typeof h!="object")return null;var R=C&&h[C]||h[y];return typeof R=="function"?R:null}var m=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(h){{for(var R=arguments.length,F=new Array(R>1?R-1:0),J=1;J<R;J++)F[J-1]=arguments[J];x("error",h,F)}}function x(h,R,F){{var J=m.ReactDebugCurrentFrame,se=J.getStackAddendum();se!==""&&(R+="%s",F=F.concat([se]));var ce=F.map(function(ae){return String(ae)});ce.unshift("Warning: "+R),Function.prototype.apply.call(console[h],console,ce)}}var v=!1,S=!1,I=!1,$=!1,M=!1,T;T=Symbol.for("react.module.reference");function _(h){return!!(typeof h=="string"||typeof h=="function"||h===r||h===s||M||h===a||h===u||h===d||$||h===f||v||S||I||typeof h=="object"&&h!==null&&(h.$$typeof===p||h.$$typeof===b||h.$$typeof===o||h.$$typeof===l||h.$$typeof===i||h.$$typeof===T||h.getModuleId!==void 0))}function D(h,R,F){var J=h.displayName;if(J)return J;var se=R.displayName||R.name||"";return se!==""?F+"("+se+")":F}function V(h){return h.displayName||"Context"}function W(h){if(h==null)return null;if(typeof h.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case a:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof h=="object")switch(h.$$typeof){case l:var R=h;return V(R)+".Consumer";case o:var F=h;return V(F._context)+".Provider";case i:return D(h,h.render,"ForwardRef");case b:var J=h.displayName||null;return J!==null?J:W(h.type)||"Memo";case p:{var se=h,ce=se._payload,ae=se._init;try{return W(ae(ce))}catch{return null}}}return null}var O=Object.assign,N=0,Y,ee,re,X,oe,A,j;function H(){}H.__reactDisabledLog=!0;function U(){{if(N===0){Y=console.log,ee=console.info,re=console.warn,X=console.error,oe=console.group,A=console.groupCollapsed,j=console.groupEnd;var h={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:h,log:h,warn:h,error:h,group:h,groupCollapsed:h,groupEnd:h})}N++}}function ge(){{if(N--,N===0){var h={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},h,{value:Y}),info:O({},h,{value:ee}),warn:O({},h,{value:re}),error:O({},h,{value:X}),group:O({},h,{value:oe}),groupCollapsed:O({},h,{value:A}),groupEnd:O({},h,{value:j})})}N<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Be=m.ReactCurrentDispatcher,ie;function Te(h,R,F){{if(ie===void 0)try{throw Error()}catch(se){var J=se.stack.trim().match(/\n( *(at )?)/);ie=J&&J[1]||""}return`
7
+ `+ie+h}}var ue=!1,me;{var gt=typeof WeakMap=="function"?WeakMap:Map;me=new gt}function dt(h,R){if(!h||ue)return"";{var F=me.get(h);if(F!==void 0)return F}var J;ue=!0;var se=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ce;ce=Be.current,Be.current=null,U();try{if(R){var ae=function(){throw Error()};if(Object.defineProperty(ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ae,[])}catch(B){J=B}Reflect.construct(h,[],ae)}else{try{ae.call()}catch(B){J=B}h.call(ae.prototype)}}else{try{throw Error()}catch(B){J=B}h()}}catch(B){if(B&&J&&typeof B.stack=="string"){for(var ne=B.stack.split(`
8
+ `),ke=J.stack.split(`
9
+ `),pe=ne.length-1,ve=ke.length-1;pe>=1&&ve>=0&&ne[pe]!==ke[ve];)ve--;for(;pe>=1&&ve>=0;pe--,ve--)if(ne[pe]!==ke[ve]){if(pe!==1||ve!==1)do if(pe--,ve--,ve<0||ne[pe]!==ke[ve]){var Me=`
10
+ `+ne[pe].replace(" at new "," at ");return h.displayName&&Me.includes("<anonymous>")&&(Me=Me.replace("<anonymous>",h.displayName)),typeof h=="function"&&me.set(h,Me),Me}while(pe>=1&&ve>=0);break}}}finally{ue=!1,Be.current=ce,ge(),Error.prepareStackTrace=se}var lt=h?h.displayName||h.name:"",et=lt?Te(lt):"";return typeof h=="function"&&me.set(h,et),et}function de(h,R,F){return dt(h,!1)}function at(h){var R=h.prototype;return!!(R&&R.isReactComponent)}function ot(h,R,F){if(h==null)return"";if(typeof h=="function")return dt(h,at(h));if(typeof h=="string")return Te(h);switch(h){case u:return Te("Suspense");case d:return Te("SuspenseList")}if(typeof h=="object")switch(h.$$typeof){case i:return de(h.render);case b:return ot(h.type,R,F);case p:{var J=h,se=J._payload,ce=J._init;try{return ot(ce(se),R,F)}catch{}}}return""}var Je=Object.prototype.hasOwnProperty,st={},z=m.ReactDebugCurrentFrame;function Re(h){if(h){var R=h._owner,F=ot(h.type,h._source,R?R.type:null);z.setExtraStackFrame(F)}else z.setExtraStackFrame(null)}function xe(h,R,F,J,se){{var ce=Function.call.bind(Je);for(var ae in h)if(ce(h,ae)){var ne=void 0;try{if(typeof h[ae]!="function"){var ke=Error((J||"React class")+": "+F+" type `"+ae+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof h[ae]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ke.name="Invariant Violation",ke}ne=h[ae](R,ae,J,F,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pe){ne=pe}ne&&!(ne instanceof Error)&&(Re(se),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",J||"React class",F,ae,typeof ne),Re(null)),ne instanceof Error&&!(ne.message in st)&&(st[ne.message]=!0,Re(se),w("Failed %s type: %s",F,ne.message),Re(null))}}}var be=Array.isArray;function Ze(h){return be(h)}function Xe(h){{var R=typeof Symbol=="function"&&Symbol.toStringTag,F=R&&h[Symbol.toStringTag]||h.constructor.name||"Object";return F}}function Pe(h){try{return He(h),!1}catch{return!0}}function He(h){return""+h}function Ge(h){if(Pe(h))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Xe(h)),He(h)}var ft=m.ReactCurrentOwner,At={key:!0,ref:!0,__self:!0,__source:!0},K,te;function he(h){if(Je.call(h,"ref")){var R=Object.getOwnPropertyDescriptor(h,"ref").get;if(R&&R.isReactWarning)return!1}return h.ref!==void 0}function ye(h){if(Je.call(h,"key")){var R=Object.getOwnPropertyDescriptor(h,"key").get;if(R&&R.isReactWarning)return!1}return h.key!==void 0}function Ee(h,R){typeof h.ref=="string"&&ft.current}function Ae(h,R){{var F=function(){K||(K=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",R))};F.isReactWarning=!0,Object.defineProperty(h,"key",{get:F,configurable:!0})}}function le(h,R){{var F=function(){te||(te=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",R))};F.isReactWarning=!0,Object.defineProperty(h,"ref",{get:F,configurable:!0})}}var Ye=function(h,R,F,J,se,ce,ae){var ne={$$typeof:t,type:h,key:R,ref:F,props:ae,_owner:ce};return ne._store={},Object.defineProperty(ne._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ne,"_self",{configurable:!1,enumerable:!1,writable:!1,value:J}),Object.defineProperty(ne,"_source",{configurable:!1,enumerable:!1,writable:!1,value:se}),Object.freeze&&(Object.freeze(ne.props),Object.freeze(ne)),ne};function Ke(h,R,F,J,se){{var ce,ae={},ne=null,ke=null;F!==void 0&&(Ge(F),ne=""+F),ye(R)&&(Ge(R.key),ne=""+R.key),he(R)&&(ke=R.ref,Ee(R,se));for(ce in R)Je.call(R,ce)&&!At.hasOwnProperty(ce)&&(ae[ce]=R[ce]);if(h&&h.defaultProps){var pe=h.defaultProps;for(ce in pe)ae[ce]===void 0&&(ae[ce]=pe[ce])}if(ne||ke){var ve=typeof h=="function"?h.displayName||h.name||"Unknown":h;ne&&Ae(ae,ve),ke&&le(ae,ve)}return Ye(h,ne,ke,se,J,ft.current,ae)}}var ze=m.ReactCurrentOwner,_e=m.ReactDebugCurrentFrame;function Ie(h){if(h){var R=h._owner,F=ot(h.type,h._source,R?R.type:null);_e.setExtraStackFrame(F)}else _e.setExtraStackFrame(null)}var qe;qe=!1;function mt(h){return typeof h=="object"&&h!==null&&h.$$typeof===t}function Bt(){{if(ze.current){var h=W(ze.current.type);if(h)return`
11
11
 
12
- Check the render method of \``+h+"`."}return""}}function st(h){return""}var Ft={};function ht(h){{var $=Bt();if(!$){var F=typeof h=="string"?h:h.displayName||h.name;F&&($=`
12
+ Check the render method of \``+h+"`."}return""}}function it(h){return""}var Ft={};function ht(h){{var R=Bt();if(!R){var F=typeof h=="string"?h:h.displayName||h.name;F&&(R=`
13
13
 
14
- Check the top-level render call using <`+F+">.")}return $}}function Wt(h,$){{if(!h._store||h._store.validated||h.key!=null)return;h._store.validated=!0;var F=ht($);if(Ft[F])return;Ft[F]=!0;var U="";h&&h._owner&&h._owner!==je.current&&(U=" It was passed a child from "+W(h._owner.type)+"."),Ae(h),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',F,U),Ae(null)}}function Zt(h,$){{if(typeof h!="object")return;if(Ze(h))for(var F=0;F<h.length;F++){var U=h[F];ft(U)&&Wt(U,$)}else if(ft(h))h._store&&(h._store.validated=!0);else if(h){var se=v(h);if(typeof se=="function"&&se!==h.entries)for(var ce=se.call(h),re;!(re=ce.next()).done;)ft(re.value)&&Wt(re.value,$)}}}function bt(h){{var $=h.type;if($==null||typeof $=="string")return;var F;if(typeof $=="function")F=$.propTypes;else if(typeof $=="object"&&($.$$typeof===l||$.$$typeof===b))F=$.propTypes;else return;if(F){var U=W($);we(F,h.props,"prop",U,h)}else if($.PropTypes!==void 0&&!Je){Je=!0;var se=W($);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",se||"Unknown")}typeof $.getDefaultProps=="function"&&!$.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function qe(h){{for(var $=Object.keys(h.props),F=0;F<$.length;F++){var U=$[F];if(U!=="children"&&U!=="key"){Ae(h),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",U),Ae(null);break}}h.ref!==null&&(Ae(h),C("Invalid attribute `ref` supplied to `React.Fragment`."),Ae(null))}}var Fe={};function vt(h,$,F,U,se,ce){{var re=B(h);if(!re){var te="";(h===void 0||typeof h=="object"&&h!==null&&Object.keys(h).length===0)&&(te+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ke=st();ke?te+=ke:te+=Bt();var pe;h===null?pe="null":Ze(h)?pe="array":h!==void 0&&h.$$typeof===t?(pe="<"+(W(h.type)||"Unknown")+" />",te=" Did you accidentally export a JSX literal instead of a component?"):pe=typeof h,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",pe,te)}var Ce=Ye(h,$,F,se,ce);if(Ce==null)return Ce;if(re){var Me=$.children;if(Me!==void 0)if(U)if(Ze(Me)){for(var it=0;it<Me.length;it++)Zt(Me[it],h);Object.freeze&&Object.freeze(Me)}else C("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Zt(Me,h)}if(Ue.call($,"key")){var Qe=W(h),M=Object.keys($).filter(function(fe){return fe!=="key"}),N=M.length>0?"{key: someKey, "+M.join(": ..., ")+": ...}":"{key: someKey}";if(!Fe[Qe+N]){var q=M.length>0?"{"+M.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX:
14
+ Check the top-level render call using <`+F+">.")}return R}}function Wt(h,R){{if(!h._store||h._store.validated||h.key!=null)return;h._store.validated=!0;var F=ht(R);if(Ft[F])return;Ft[F]=!0;var J="";h&&h._owner&&h._owner!==ze.current&&(J=" It was passed a child from "+W(h._owner.type)+"."),Ie(h),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',F,J),Ie(null)}}function Zt(h,R){{if(typeof h!="object")return;if(Ze(h))for(var F=0;F<h.length;F++){var J=h[F];mt(J)&&Wt(J,R)}else if(mt(h))h._store&&(h._store.validated=!0);else if(h){var se=g(h);if(typeof se=="function"&&se!==h.entries)for(var ce=se.call(h),ae;!(ae=ce.next()).done;)mt(ae.value)&&Wt(ae.value,R)}}}function bt(h){{var R=h.type;if(R==null||typeof R=="string")return;var F;if(typeof R=="function")F=R.propTypes;else if(typeof R=="object"&&(R.$$typeof===i||R.$$typeof===b))F=R.propTypes;else return;if(F){var J=W(R);xe(F,h.props,"prop",J,h)}else if(R.PropTypes!==void 0&&!qe){qe=!0;var se=W(R);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",se||"Unknown")}typeof R.getDefaultProps=="function"&&!R.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Qe(h){{for(var R=Object.keys(h.props),F=0;F<R.length;F++){var J=R[F];if(J!=="children"&&J!=="key"){Ie(h),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",J),Ie(null);break}}h.ref!==null&&(Ie(h),w("Invalid attribute `ref` supplied to `React.Fragment`."),Ie(null))}}var Fe={};function vt(h,R,F,J,se,ce){{var ae=_(h);if(!ae){var ne="";(h===void 0||typeof h=="object"&&h!==null&&Object.keys(h).length===0)&&(ne+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ke=it();ke?ne+=ke:ne+=Bt();var pe;h===null?pe="null":Ze(h)?pe="array":h!==void 0&&h.$$typeof===t?(pe="<"+(W(h.type)||"Unknown")+" />",ne=" Did you accidentally export a JSX literal instead of a component?"):pe=typeof h,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",pe,ne)}var ve=Ke(h,R,F,se,ce);if(ve==null)return ve;if(ae){var Me=R.children;if(Me!==void 0)if(J)if(Ze(Me)){for(var lt=0;lt<Me.length;lt++)Zt(Me[lt],h);Object.freeze&&Object.freeze(Me)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Zt(Me,h)}if(Je.call(R,"key")){var et=W(h),B=Object.keys(R).filter(function(fe){return fe!=="key"}),L=B.length>0?"{key: someKey, "+B.join(": ..., ")+": ...}":"{key: someKey}";if(!Fe[et+L]){var q=B.length>0?"{"+B.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
15
15
  let props = %s;
16
16
  <%s {...props} />
17
17
  React keys must be passed directly to JSX without using spread:
18
18
  let props = %s;
19
- <%s key={someKey} {...props} />`,N,Qe,q,Qe),Fe[Qe+N]=!0}}return h===r?qe(Ce):bt(Ce),Ce}}function nn(h,$,F){return vt(h,$,F,!0)}function rn(h,$,F){return vt(h,$,F,!1)}var an=rn,on=nn;Et.Fragment=r,Et.jsx=an,Et.jsxs=on})()),Et}var Gn;function Za(){return Gn||(Gn=1,process.env.NODE_ENV==="production"?zt.exports=Fa():zt.exports=Wa()),zt.exports}var R=Za();const Pa=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Kt=Pa?c.useLayoutEffect:c.useEffect;function Va(e){const t=c.useRef(e);return Kt(()=>{t.current=e}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}function Pr(e,t){t===void 0&&(t=[e]);const n=c.useRef(e);return Kt(()=>{n.current!==e&&(n.current=e)},t),n}function Xt(e){const t=Va(e),n=c.useRef(null),r=c.useCallback(a=>{a!==n.current&&t?.(a,n.current),n.current=a},[]);return[n,r]}let dn={};function Vr(e,t){return c.useMemo(()=>{const n=dn[e]==null?0:dn[e]+1;return dn[e]=n,e+"-"+n},[e,t])}const Cn=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Cn.Translate.toString(e),Cn.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}});var Yn;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Yn||(Yn={}));function Kn(){}const ja=Object.freeze({x:0,y:0});var xt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(xt||(xt={}));var Un;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Un||(Un={}));var lt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(lt||(lt={}));lt.Space,lt.Enter,lt.Esc,lt.Space,lt.Enter,lt.Tab;var Jn;(function(e){e[e.RightClick=2]="RightClick"})(Jn||(Jn={}));var qn;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qn||(qn={}));var Qn;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Qn||(Qn={}));xt.Backward+"",xt.Forward+"",xt.Backward+"",xt.Forward+"";var xn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(xn||(xn={}));var wn;(function(e){e.Optimized="optimized"})(wn||(wn={}));function za(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:a,handler:s}=r;return n[a]=o=>{s(o,t)},n},{}),[e,t])}xn.WhileDragging,wn.Optimized;const Oa={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Kn,draggableNodes:new Map,over:null,measureDroppableContainers:Kn},Na=c.createContext(Oa),La=c.createContext({...ja,scaleX:1,scaleY:1});var er;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(er||(er={}));const Xa=c.createContext(null),tr="button",Ha="Draggable";function fn(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=Vr(Ha),{activators:o,activatorEvent:i,active:l,activeNodeRect:u,ariaDescribedById:d,draggableNodes:b,over:p}=c.useContext(Na),{role:f=tr,roleDescription:x="draggable",tabIndex:y=0}=a??{},v=l?.id===t,m=c.useContext(v?La:Xa),[C,w]=Xt(),[g,S]=Xt(),I=za(o,t),E=Pr(n);Kt(()=>(b.set(t,{id:t,key:s,node:C,activatorNode:g,data:E}),()=>{const _=b.get(t);_&&_.key===s&&b.delete(t)}),[b,t]);const D=c.useMemo(()=>({role:f,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&f===tr?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,f,y,v,x,d.draggable]);return{active:l,activatorEvent:i,activeNodeRect:u,attributes:D,isDragging:v,listeners:r?void 0:I,node:C,over:p,setNodeRef:w,setActivatorNodeRef:S,transform:m}}const Ga=new Map([["bold",J.createElement(J.Fragment,null,J.createElement("path",{d:"M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,1,1-18-15.88,20,20,0,0,0,0-26.43,12,12,0,0,1,18-15.86A43.94,43.94,0,0,1,212,128Zm40,0a83.87,83.87,0,0,1-21.39,56,12,12,0,0,1-17.89-16,60,60,0,0,0,0-80,12,12,0,1,1,17.88-16A83.87,83.87,0,0,1,252,128Z"}))],["duotone",J.createElement(J.Fragment,null,J.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),J.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55Zm54-106.08a40,40,0,0,1,0,52.88,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,0,1,12-10.58ZM248,128a79.9,79.9,0,0,1-20.37,53.34,8,8,0,0,1-11.92-10.67,64,64,0,0,0,0-85.33,8,8,0,1,1,11.92-10.67A79.83,79.83,0,0,1,248,128Z"}))],["fill",J.createElement(J.Fragment,null,J.createElement("path",{d:"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z"}))],["light",J.createElement(J.Fragment,null,J.createElement("path",{d:"M154.64,26.61a6,6,0,0,0-6.32.65L77.94,82H32A14,14,0,0,0,18,96v64a14,14,0,0,0,14,14H77.94l70.38,54.74A6,6,0,0,0,158,224V32A6,6,0,0,0,154.64,26.61ZM30,160V96a2,2,0,0,1,2-2H74v68H32A2,2,0,0,1,30,160Zm116,51.73L86,165.07V90.93l60-46.66Zm50.53-108.85a38,38,0,0,1,0,50.24,6,6,0,1,1-9-7.94,26,26,0,0,0,0-34.37,6,6,0,0,1,9-7.93ZM246,128a77.86,77.86,0,0,1-19.86,52,6,6,0,1,1-8.94-8,66,66,0,0,0,0-88,6,6,0,1,1,8.94-8A77.86,77.86,0,0,1,246,128Z"}))],["regular",J.createElement(J.Fragment,null,J.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55Zm54-106.08a40,40,0,0,1,0,52.88,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,0,1,12-10.58ZM248,128a79.9,79.9,0,0,1-20.37,53.34,8,8,0,0,1-11.92-10.67,64,64,0,0,0,0-85.33,8,8,0,1,1,11.92-10.67A79.83,79.83,0,0,1,248,128Z"}))],["thin",J.createElement(J.Fragment,null,J.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.78Zm47-111.61a36,36,0,0,1,0,47.59,4,4,0,1,1-6-5.3,28,28,0,0,0,0-37,4,4,0,0,1,6-5.28ZM244,128a75.88,75.88,0,0,1-19.35,50.67,4,4,0,0,1-6-5.34,68,68,0,0,0,0-90.66,4,4,0,0,1,6-5.34A75.88,75.88,0,0,1,244,128Z"}))]]),Ya=new Map([["bold",J.createElement(J.Fragment,null,J.createElement("path",{d:"M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,0,1-18-15.88,20,20,0,0,0,0-26.44,12,12,0,0,1,18-15.85A43.94,43.94,0,0,1,212,128Z"}))],["duotone",J.createElement(J.Fragment,null,J.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),J.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55ZM208,128a39.93,39.93,0,0,1-10,26.46,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,1,1,12-10.58A40,40,0,0,1,208,128Z"}))],["fill",J.createElement(J.Fragment,null,J.createElement("path",{d:"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80ZM198,101.56a8,8,0,1,0-12,10.58,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88Z"}))],["light",J.createElement(J.Fragment,null,J.createElement("path",{d:"M154.64,26.61a6,6,0,0,0-6.32.65L77.94,82H32A14,14,0,0,0,18,96v64a14,14,0,0,0,14,14H77.94l70.38,54.74A6,6,0,0,0,158,224V32A6,6,0,0,0,154.64,26.61ZM30,160V96a2,2,0,0,1,2-2H74v68H32A2,2,0,0,1,30,160Zm116,51.73L86,165.07V90.93l60-46.66ZM206,128a37.94,37.94,0,0,1-9.5,25.14,6,6,0,1,1-9-7.94,26,26,0,0,0,0-34.37,6,6,0,0,1,9-7.93A38,38,0,0,1,206,128Z"}))],["regular",J.createElement(J.Fragment,null,J.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55ZM208,128a39.93,39.93,0,0,1-10,26.46,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,1,1,12-10.58A40,40,0,0,1,208,128Z"}))],["thin",J.createElement(J.Fragment,null,J.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"}))]]),Ka=c.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),En=J.forwardRef((e,t)=>{const{alt:n,color:r,size:a,weight:s,mirrored:o,children:i,weights:l,...u}=e,{color:d="currentColor",size:b,weight:p="regular",mirrored:f=!1,...x}=J.useContext(Ka);return J.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:a??b,height:a??b,fill:r??d,viewBox:"0 0 256 256",transform:o||f?"scale(-1, 1)":void 0,...x,...u},!!n&&J.createElement("title",null,n),i,l.get(s??p))});En.displayName="IconBase";const jr=J.forwardRef((e,t)=>J.createElement(En,{ref:t,...e,weights:Ga}));jr.displayName="SpeakerHighIcon";const zr=J.forwardRef((e,t)=>J.createElement(En,{ref:t,...e,weights:Ya}));zr.displayName="SpeakerLowIcon";k.span`
19
+ <%s key={someKey} {...props} />`,L,et,q,et),Fe[et+L]=!0}}return h===r?Qe(ve):bt(ve),ve}}function rn(h,R,F){return vt(h,R,F,!0)}function an(h,R,F){return vt(h,R,F,!1)}var on=an,sn=rn;Et.Fragment=r,Et.jsx=on,Et.jsxs=sn})()),Et}var Gn;function Pa(){return Gn||(Gn=1,process.env.NODE_ENV==="production"?Ot.exports=Wa():Ot.exports=Za()),Ot.exports}var E=Pa();const Va=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ut=Va?c.useLayoutEffect:c.useEffect;function ja(e){const t=c.useRef(e);return Ut(()=>{t.current=e}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}function Pr(e,t){t===void 0&&(t=[e]);const n=c.useRef(e);return Ut(()=>{n.current!==e&&(n.current=e)},t),n}function Ht(e){const t=ja(e),n=c.useRef(null),r=c.useCallback(a=>{a!==n.current&&t?.(a,n.current),n.current=a},[]);return[n,r]}let dn={};function Vr(e,t){return c.useMemo(()=>{const n=dn[e]==null?0:dn[e]+1;return dn[e]=n,e+"-"+n},[e,t])}const Cn=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Cn.Translate.toString(e),Cn.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}});var Yn;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Yn||(Yn={}));function Kn(){}const za=Object.freeze({x:0,y:0});var wt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(wt||(wt={}));var Un;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Un||(Un={}));var ct;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(ct||(ct={}));ct.Space,ct.Enter,ct.Esc,ct.Space,ct.Enter,ct.Tab;var Jn;(function(e){e[e.RightClick=2]="RightClick"})(Jn||(Jn={}));var qn;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qn||(qn={}));var Qn;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Qn||(Qn={}));wt.Backward+"",wt.Forward+"",wt.Backward+"",wt.Forward+"";var wn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(wn||(wn={}));var xn;(function(e){e.Optimized="optimized"})(xn||(xn={}));function Oa(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:a,handler:s}=r;return n[a]=o=>{s(o,t)},n},{}),[e,t])}wn.WhileDragging,xn.Optimized;const Na={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Kn,draggableNodes:new Map,over:null,measureDroppableContainers:Kn},La=c.createContext(Na),Xa=c.createContext({...za,scaleX:1,scaleY:1});var er;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(er||(er={}));const Ha=c.createContext(null),tr="button",Ga="Draggable";function fn(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=Vr(Ga),{activators:o,activatorEvent:l,active:i,activeNodeRect:u,ariaDescribedById:d,draggableNodes:b,over:p}=c.useContext(La),{role:f=tr,roleDescription:C="draggable",tabIndex:y=0}=a??{},g=i?.id===t,m=c.useContext(g?Xa:Ha),[w,x]=Ht(),[v,S]=Ht(),I=Oa(o,t),$=Pr(n);Ut(()=>(b.set(t,{id:t,key:s,node:w,activatorNode:v,data:$}),()=>{const T=b.get(t);T&&T.key===s&&b.delete(t)}),[b,t]);const M=c.useMemo(()=>({role:f,tabIndex:y,"aria-disabled":r,"aria-pressed":g&&f===tr?!0:void 0,"aria-roledescription":C,"aria-describedby":d.draggable}),[r,f,y,g,C,d.draggable]);return{active:i,activatorEvent:l,activeNodeRect:u,attributes:M,isDragging:g,listeners:r?void 0:I,node:w,over:p,setNodeRef:x,setActivatorNodeRef:S,transform:m}}const Ya=new Map([["bold",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,1,1-18-15.88,20,20,0,0,0,0-26.43,12,12,0,0,1,18-15.86A43.94,43.94,0,0,1,212,128Zm40,0a83.87,83.87,0,0,1-21.39,56,12,12,0,0,1-17.89-16,60,60,0,0,0,0-80,12,12,0,1,1,17.88-16A83.87,83.87,0,0,1,252,128Z"}))],["duotone",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),Q.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55Zm54-106.08a40,40,0,0,1,0,52.88,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,0,1,12-10.58ZM248,128a79.9,79.9,0,0,1-20.37,53.34,8,8,0,0,1-11.92-10.67,64,64,0,0,0,0-85.33,8,8,0,1,1,11.92-10.67A79.83,79.83,0,0,1,248,128Z"}))],["fill",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z"}))],["light",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M154.64,26.61a6,6,0,0,0-6.32.65L77.94,82H32A14,14,0,0,0,18,96v64a14,14,0,0,0,14,14H77.94l70.38,54.74A6,6,0,0,0,158,224V32A6,6,0,0,0,154.64,26.61ZM30,160V96a2,2,0,0,1,2-2H74v68H32A2,2,0,0,1,30,160Zm116,51.73L86,165.07V90.93l60-46.66Zm50.53-108.85a38,38,0,0,1,0,50.24,6,6,0,1,1-9-7.94,26,26,0,0,0,0-34.37,6,6,0,0,1,9-7.93ZM246,128a77.86,77.86,0,0,1-19.86,52,6,6,0,1,1-8.94-8,66,66,0,0,0,0-88,6,6,0,1,1,8.94-8A77.86,77.86,0,0,1,246,128Z"}))],["regular",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55Zm54-106.08a40,40,0,0,1,0,52.88,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,0,1,12-10.58ZM248,128a79.9,79.9,0,0,1-20.37,53.34,8,8,0,0,1-11.92-10.67,64,64,0,0,0,0-85.33,8,8,0,1,1,11.92-10.67A79.83,79.83,0,0,1,248,128Z"}))],["thin",Q.createElement(Q.Fragment,null,Q.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.78Zm47-111.61a36,36,0,0,1,0,47.59,4,4,0,1,1-6-5.3,28,28,0,0,0,0-37,4,4,0,0,1,6-5.28ZM244,128a75.88,75.88,0,0,1-19.35,50.67,4,4,0,0,1-6-5.34,68,68,0,0,0,0-90.66,4,4,0,0,1,6-5.34A75.88,75.88,0,0,1,244,128Z"}))]]),Ka=new Map([["bold",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,0,1-18-15.88,20,20,0,0,0,0-26.44,12,12,0,0,1,18-15.85A43.94,43.94,0,0,1,212,128Z"}))],["duotone",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),Q.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55ZM208,128a39.93,39.93,0,0,1-10,26.46,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,1,1,12-10.58A40,40,0,0,1,208,128Z"}))],["fill",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80ZM198,101.56a8,8,0,1,0-12,10.58,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88Z"}))],["light",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M154.64,26.61a6,6,0,0,0-6.32.65L77.94,82H32A14,14,0,0,0,18,96v64a14,14,0,0,0,14,14H77.94l70.38,54.74A6,6,0,0,0,158,224V32A6,6,0,0,0,154.64,26.61ZM30,160V96a2,2,0,0,1,2-2H74v68H32A2,2,0,0,1,30,160Zm116,51.73L86,165.07V90.93l60-46.66ZM206,128a37.94,37.94,0,0,1-9.5,25.14,6,6,0,1,1-9-7.94,26,26,0,0,0,0-34.37,6,6,0,0,1,9-7.93A38,38,0,0,1,206,128Z"}))],["regular",Q.createElement(Q.Fragment,null,Q.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55ZM208,128a39.93,39.93,0,0,1-10,26.46,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,1,1,12-10.58A40,40,0,0,1,208,128Z"}))],["thin",Q.createElement(Q.Fragment,null,Q.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"}))]]),Ua=c.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),En=Q.forwardRef((e,t)=>{const{alt:n,color:r,size:a,weight:s,mirrored:o,children:l,weights:i,...u}=e,{color:d="currentColor",size:b,weight:p="regular",mirrored:f=!1,...C}=Q.useContext(Ua);return Q.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:a??b,height:a??b,fill:r??d,viewBox:"0 0 256 256",transform:o||f?"scale(-1, 1)":void 0,...C,...u},!!n&&Q.createElement("title",null,n),l,i.get(s??p))});En.displayName="IconBase";const jr=Q.forwardRef((e,t)=>Q.createElement(En,{ref:t,...e,weights:Ya}));jr.displayName="SpeakerHighIcon";const zr=Q.forwardRef((e,t)=>Q.createElement(En,{ref:t,...e,weights:Ka}));zr.displayName="SpeakerLowIcon";k.span`
20
20
  font-family: 'Courier New', Monaco, monospace;
21
21
  font-size: 1rem;
22
22
  font-weight: 600;
23
23
  color: ${e=>e.theme?.textColor||"#333"};
24
24
  user-select: none;
25
- `;var Tn=k.button`
25
+ `;var Dn=k.button`
26
26
  display: inline-flex;
27
27
  align-items: center;
28
28
  justify-content: center;
@@ -51,37 +51,37 @@ React keys must be passed directly to JSX without using spread:
51
51
  opacity: 0.6;
52
52
  cursor: not-allowed;
53
53
  }
54
- `;k(Tn)`
54
+ `;k(Dn)`
55
55
  padding: 0.25rem 0.5rem;
56
56
  font-size: ${e=>e.theme.fontSizeSmall};
57
- `;k(Tn)`
57
+ `;k(Dn)`
58
58
  padding: 0.5rem;
59
59
  min-width: 2.25rem;
60
60
  min-height: 2.25rem;
61
- `;k(Tn)`
61
+ `;k(Dn)`
62
62
  padding: 0.25rem;
63
63
  min-width: 1.75rem;
64
64
  min-height: 1.75rem;
65
65
  font-size: ${e=>e.theme.fontSizeSmall};
66
- `;var Ut=k.div`
66
+ `;var Jt=k.div`
67
67
  display: inline-flex;
68
68
  align-items: center;
69
69
  gap: 0.5rem;
70
- `,Jt=k.input`
70
+ `,qt=k.input`
71
71
  cursor: pointer;
72
72
  accent-color: ${e=>e.theme.inputFocusBorder};
73
73
 
74
74
  &:disabled {
75
75
  cursor: not-allowed;
76
76
  }
77
- `,qt=k.label`
77
+ `,Qt=k.label`
78
78
  margin: 0;
79
79
  cursor: pointer;
80
80
  user-select: none;
81
81
  font-family: ${e=>e.theme.fontFamily};
82
82
  font-size: ${e=>e.theme.fontSize};
83
83
  color: ${e=>e.theme.textColor};
84
- `,Oe=k.button`
84
+ `,Ne=k.button`
85
85
  padding: 0.5rem 1rem;
86
86
  background: ${e=>e.theme.buttonBackground||"#007bff"};
87
87
  color: ${e=>e.theme.buttonText||"white"};
@@ -149,7 +149,7 @@ React keys must be passed directly to JSX without using spread:
149
149
  align-items: center;
150
150
  gap: 0.5rem;
151
151
  cursor: pointer;
152
- `;var Ua=k.span`
152
+ `;var Ja=k.span`
153
153
  position: absolute;
154
154
  width: 1px;
155
155
  height: 1px;
@@ -159,7 +159,7 @@ React keys must be passed directly to JSX without using spread:
159
159
  clip: rect(0, 0, 0, 0);
160
160
  white-space: nowrap;
161
161
  border: 0;
162
- `,Dn=k.select`
162
+ `,Tn=k.select`
163
163
  padding: 0.5rem 2rem 0.5rem 0.75rem;
164
164
  font-family: ${e=>e.theme.fontFamily};
165
165
  font-size: ${e=>e.theme.fontSize};
@@ -190,7 +190,7 @@ React keys must be passed directly to JSX without using spread:
190
190
  color: ${e=>e.theme.inputText};
191
191
  background-color: ${e=>e.theme.inputBackground};
192
192
  }
193
- `;k(Dn)`
193
+ `;k(Tn)`
194
194
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
195
195
  font-size: ${e=>e.theme.fontSizeSmall};
196
196
  `;var Lr=k.input.attrs({type:"range"})`
@@ -269,7 +269,7 @@ React keys must be passed directly to JSX without using spread:
269
269
  &:disabled::-moz-range-thumb {
270
270
  cursor: not-allowed;
271
271
  }
272
- `,Ja=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return R.jsxs(Ut,{className:r,children:[R.jsx(Jt,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:a,disabled:n}),R.jsx(qt,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Xr(e){return typeof e=="object"&&e!==null&&"type"in e}function Ht(e){if(!Xr(e))return e;const t=e.direction==="vertical"?"to bottom":"to right",n=e.stops.map(r=>`${r.color} ${r.offset*100}%`).join(", ");return`linear-gradient(${t}, ${n})`}var qa={waveformDrawMode:"inverted",waveOutlineColor:"#ffffff",waveFillColor:"#1a7f8e",waveProgressColor:"rgba(0, 0, 0, 0.10)",selectedWaveOutlineColor:"#ffffff",selectedWaveFillColor:"#00b4d8",selectedTrackControlsBackground:"#d9e9ff",timeColor:"#000",timescaleBackgroundColor:"#fff",playheadColor:"#f00",selectionColor:"rgba(255, 105, 180, 0.7)",loopRegionColor:"rgba(59, 130, 246, 0.3)",loopMarkerColor:"#3b82f6",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},Qa=1e3;function eo(e,t,n,r){if(!Xr(t))return t;let a;t.direction==="vertical"?a=e.createLinearGradient(0,0,0,r):a=e.createLinearGradient(0,0,n,0);for(const s of t.stops)a.addColorStop(s.offset,s.color);return a}var to=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
272
+ `,qa=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return E.jsxs(Jt,{className:r,children:[E.jsx(qt,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:a,disabled:n}),E.jsx(Qt,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Xr(e){return typeof e=="object"&&e!==null&&"type"in e}function Gt(e){if(!Xr(e))return e;const t=e.direction==="vertical"?"to bottom":"to right",n=e.stops.map(r=>`${r.color} ${r.offset*100}%`).join(", ");return`linear-gradient(${t}, ${n})`}var Qa={waveformDrawMode:"inverted",waveOutlineColor:"#ffffff",waveFillColor:"#1a7f8e",waveProgressColor:"rgba(0, 0, 0, 0.10)",selectedWaveOutlineColor:"#ffffff",selectedWaveFillColor:"#00b4d8",selectedTrackControlsBackground:"#d9e9ff",timeColor:"#000",timescaleBackgroundColor:"#fff",playheadColor:"#f00",selectionColor:"rgba(255, 105, 180, 0.7)",loopRegionColor:"rgba(59, 130, 246, 0.3)",loopMarkerColor:"#3b82f6",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},eo=1e3;function to(e,t,n,r){if(!Xr(t))return t;let a;t.direction==="vertical"?a=e.createLinearGradient(0,0,0,r):a=e.createLinearGradient(0,0,n,0);for(const s of t.stops)a.addColorStop(s.offset,s.color);return a}var no=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
273
273
  float: left;
274
274
  position: relative;
275
275
  /* Promote to own compositing layer for smoother scrolling */
@@ -277,13 +277,13 @@ React keys must be passed directly to JSX without using spread:
277
277
  /* Disable image rendering interpolation */
278
278
  image-rendering: pixelated;
279
279
  image-rendering: crisp-edges;
280
- `,no=k.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
280
+ `,ro=k.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
281
281
  position: absolute;
282
282
  background: ${e=>e.$waveFillColor};
283
283
  /* Force GPU compositing layer to reduce scroll flickering */
284
284
  transform: translateZ(0);
285
285
  backface-visibility: hidden;
286
- `,ro=e=>{const{data:t,bits:n,length:r,index:a,className:s,devicePixelRatio:o=1,waveHeight:i=80,waveOutlineColor:l="#E0EFF1",waveFillColor:u="grey",barWidth:d=1,barGap:b=0,transparentBackground:p=!1,drawMode:f="inverted"}=e,x=c.useRef([]),y=c.useCallback(S=>{if(S!==null){const I=parseInt(S.dataset.index,10);x.current[I]=S}},[]);c.useLayoutEffect(()=>{const S=x.current,I=d+b;let E=0;for(let D=0;D<S.length;D++){const _=S[D],B=_.getContext("2d"),T=Math.floor(i/2),V=2**(n-1);if(B){B.resetTransform(),B.clearRect(0,0,_.width,_.height),B.imageSmoothingEnabled=!1,B.scale(o,o);const W=_.width/o;let O;f==="normal"?O=u:O=l,B.fillStyle=eo(B,O,W,i);const X=E,G=E+W,Q=Math.floor((X-d+I)/I)*I;for(let ne=Math.max(0,Q);ne<G;ne+=I){const L=ne-X;if(L+d<=0)continue;const oe=ne;if(oe*2+1<t.length){const A=t[oe*2]/V,j=t[oe*2+1]/V,H=Math.abs(A*T),K=Math.abs(j*T);f==="normal"?B.fillRect(L,T-K,d,K+H):(B.fillRect(L,0,d,T-K),B.fillRect(L,T+H,d,T-H))}}}E+=_.width/o}},[t,n,i,l,u,o,r,d,b,f]);let v=r,m=0;const C=[];for(;v>0;){const S=Math.min(v,Qa),I=R.jsx(to,{$cssWidth:S,width:S*o,height:i*o,$waveHeight:i,"data-index":m,ref:y},`${r}-${m}`);C.push(I),v-=S,m+=1}const g=p?"transparent":Ht(u);return R.jsx(no,{$index:a,$cssWidth:r,className:s,$waveHeight:i,$waveFillColor:g,children:C})},Hr=22,Gr=k.div`
286
+ `,ao=e=>{const{data:t,bits:n,length:r,index:a,className:s,devicePixelRatio:o=1,waveHeight:l=80,waveOutlineColor:i="#E0EFF1",waveFillColor:u="grey",barWidth:d=1,barGap:b=0,transparentBackground:p=!1,drawMode:f="inverted"}=e,C=c.useRef([]),y=c.useCallback(S=>{if(S!==null){const I=parseInt(S.dataset.index,10);C.current[I]=S}},[]);c.useLayoutEffect(()=>{const S=C.current,I=d+b;let $=0;for(let M=0;M<S.length;M++){const T=S[M],_=T.getContext("2d"),D=Math.floor(l/2),V=2**(n-1);if(_){_.resetTransform(),_.clearRect(0,0,T.width,T.height),_.imageSmoothingEnabled=!1,_.scale(o,o);const W=T.width/o;let O;f==="normal"?O=u:O=i,_.fillStyle=to(_,O,W,l);const N=$,Y=$+W,ee=Math.floor((N-d+I)/I)*I;for(let re=Math.max(0,ee);re<Y;re+=I){const X=re-N;if(X+d<=0)continue;const oe=re;if(oe*2+1<t.length){const A=t[oe*2]/V,j=t[oe*2+1]/V,H=Math.abs(A*D),U=Math.abs(j*D);f==="normal"?_.fillRect(X,D-U,d,U+H):(_.fillRect(X,0,d,D-U),_.fillRect(X,D+H,d,D-H))}}}$+=T.width/o}},[t,n,l,i,u,o,r,d,b,f]);let g=r,m=0;const w=[];for(;g>0;){const S=Math.min(g,eo),I=E.jsx(no,{$cssWidth:S,width:S*o,height:l*o,$waveHeight:l,"data-index":m,ref:y},`${r}-${m}`);w.push(I),g-=S,m+=1}const v=p?"transparent":Gt(u);return E.jsx(ro,{$index:a,$cssWidth:r,className:s,$waveHeight:l,$waveFillColor:v,children:w})},Hr=22,Gr=k.div`
287
287
  position: relative;
288
288
  height: ${Hr}px;
289
289
  background: ${e=>e.$isSelected?e.theme.selectedClipHeaderBackgroundColor:e.theme.clipHeaderBackgroundColor};
@@ -315,12 +315,12 @@ React keys must be passed directly to JSX without using spread:
315
315
  white-space: nowrap;
316
316
  overflow: hidden;
317
317
  text-overflow: ellipsis;
318
- `,ao=({trackName:e,isSelected:t=!1})=>R.jsx(Gr,{$isDragging:!1,$interactive:!1,$isSelected:t,children:R.jsx(Yr,{children:e})}),oo=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:a=!1,disableDrag:s=!1,dragHandleProps:o})=>{if(s||!o)return R.jsx(ao,{trackName:r,isSelected:a});const{attributes:i,listeners:l,setActivatorNodeRef:u}=o;return R.jsx(Gr,{ref:u,"data-clip-id":e,$interactive:!0,$isSelected:a,...l,...i,children:R.jsx(Yr,{children:r})})},so=8,io=24,lo=k.div`
318
+ `,oo=({trackName:e,isSelected:t=!1})=>E.jsx(Gr,{$isDragging:!1,$interactive:!1,$isSelected:t,children:E.jsx(Yr,{children:e})}),so=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:a=!1,disableDrag:s=!1,dragHandleProps:o})=>{if(s||!o)return E.jsx(oo,{trackName:r,isSelected:a});const{attributes:l,listeners:i,setActivatorNodeRef:u}=o;return E.jsx(Gr,{ref:u,"data-clip-id":e,$interactive:!0,$isSelected:a,...i,...l,children:E.jsx(Yr,{children:r})})},io=8,lo=24,co=k.div`
319
319
  position: absolute;
320
320
  ${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
321
321
  top: 0;
322
322
  bottom: 0;
323
- width: ${e=>e.$touchOptimized?io:so}px;
323
+ width: ${e=>e.$touchOptimized?lo:io}px;
324
324
  cursor: col-resize;
325
325
  user-select: none;
326
326
  z-index: 105; /* Above waveform, below header */
@@ -343,19 +343,19 @@ React keys must be passed directly to JSX without using spread:
343
343
  background: rgba(255, 255, 255, 0.4);
344
344
  ${e=>e.$edge==="left"?"border-left: 2px solid rgba(255, 255, 255, 0.8);":"border-right: 2px solid rgba(255, 255, 255, 0.8);"}
345
345
  }
346
- `,nr=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:a,touchOptimized:s=!1})=>{const[o,i]=c.useState(!1);if(!a)return null;const{attributes:l,listeners:u,setActivatorNodeRef:d,isDragging:b}=a;return R.jsx(lo,{ref:d,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:b,$isHovered:o,$touchOptimized:s,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),...u,...l})},co=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
346
+ `,nr=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:a,touchOptimized:s=!1})=>{const[o,l]=c.useState(!1);if(!a)return null;const{attributes:i,listeners:u,setActivatorNodeRef:d,isDragging:b}=a;return E.jsx(co,{ref:d,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:b,$isHovered:o,$touchOptimized:s,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),...u,...i})},uo=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
347
347
  position: absolute;
348
348
  top: 0;
349
349
  bottom: 0;
350
350
  pointer-events: none;
351
351
  z-index: 50;
352
- `,uo=k.svg`
352
+ `,fo=k.svg`
353
353
  width: 100%;
354
354
  height: 100%;
355
355
  display: block;
356
356
  /* Flip horizontally for fadeOut - makes it mirror of fadeIn */
357
357
  transform: ${e=>e.$type==="fadeOut"?"scaleX(-1)":"none"};
358
- `;function fo(e,t,n="logarithmic"){const r=[],a=Math.max(20,Math.min(e,100));for(let s=0;s<=a;s++){const o=s/a*e,i=s/a;let l;switch(n){case"linear":l=i;break;case"exponential":l=i*i;break;case"sCurve":l=(1-Math.cos(i*Math.PI))/2;break;case"logarithmic":default:l=Math.log10(1+i*9)/Math.log10(10);break}const u=(1-l)*t;r.push(`${o},${u}`)}return`M 0,${t} L ${r.join(" L ")} L ${e},0 L 0,0 Z`}var rr=({left:e,width:t,type:n,curveType:r="logarithmic",color:a})=>{const s=k.useTheme();if(t<1)return null;const o=a||s?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return R.jsx(co,{$left:e,$width:t,$type:n,children:R.jsx(uo,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:R.jsx("path",{d:fo(t,100,r),fill:o})})})},ho=k.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
358
+ `;function mo(e,t,n="logarithmic"){const r=[],a=Math.max(20,Math.min(e,100));for(let s=0;s<=a;s++){const o=s/a*e,l=s/a;let i;switch(n){case"linear":i=l;break;case"exponential":i=l*l;break;case"sCurve":i=(1-Math.cos(l*Math.PI))/2;break;case"logarithmic":default:i=Math.log10(1+l*9)/Math.log10(10);break}const u=(1-i)*t;r.push(`${o},${u}`)}return`M 0,${t} L ${r.join(" L ")} L ${e},0 L 0,0 Z`}var rr=({left:e,width:t,type:n,curveType:r="logarithmic",color:a})=>{const s=k.useTheme();if(t<1)return null;const o=a||s?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return E.jsx(uo,{$left:e,$width:t,$type:n,children:E.jsx(fo,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:E.jsx("path",{d:mo(t,100,r),fill:o})})})},ho=k.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
359
359
  position: ${e=>e.$isOverlay?"relative":"absolute"};
360
360
  top: 0;
361
361
  height: ${e=>e.$isOverlay?"auto":"100%"};
@@ -369,20 +369,20 @@ React keys must be passed directly to JSX without using spread:
369
369
  &:hover {
370
370
  background: rgba(255, 255, 255, 0.08);
371
371
  }
372
- `,mo=k.div`
372
+ `,po=k.div`
373
373
  flex: 1;
374
374
  position: relative;
375
375
  overflow: ${e=>e.$isOverlay?"visible":"hidden"};
376
- `,ar=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:a,trackName:s,startSample:o,durationSamples:i,samplesPerPixel:l,showHeader:u=!1,disableHeaderDrag:d=!1,isOverlay:b=!1,isSelected:p=!1,onMouseDown:f,trackId:x,fadeIn:y,fadeOut:v,sampleRate:m=44100,showFades:C=!1,touchOptimized:w=!1})=>{const g=Math.floor(o/l),I=Math.floor((o+i)/l)-g,E=u&&!d&&!b,D=`clip-${r}-${a}`,{attributes:_,listeners:B,setNodeRef:T,setActivatorNodeRef:V,transform:W,isDragging:O}=fn({id:D,data:{clipId:n,trackIndex:r,clipIndex:a},disabled:!E}),X=`clip-boundary-left-${r}-${a}`,{attributes:G,listeners:Q,setActivatorNodeRef:ne,isDragging:L}=fn({id:X,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"left"},disabled:!E}),oe=`clip-boundary-right-${r}-${a}`,{attributes:A,listeners:j,setActivatorNodeRef:H,isDragging:K}=fn({id:oe,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"right"},disabled:!E}),be=W?{transform:Cn.Translate.toString(W),zIndex:O?100:void 0}:void 0;return R.jsxs(ho,{ref:T,style:be,className:t,$left:g,$width:I,$isOverlay:b,"data-clip-container":"true","data-track-id":x,onMouseDown:f,children:[u&&R.jsx(oo,{clipId:n,trackIndex:r,clipIndex:a,trackName:s,isSelected:p,disableDrag:d,dragHandleProps:E?{attributes:_,listeners:B,setActivatorNodeRef:V}:void 0}),R.jsxs(mo,{$isOverlay:b,children:[e,C&&y&&y.duration>0&&R.jsx(rr,{left:0,width:Math.floor(y.duration*m/l),type:"fadeIn",curveType:y.type}),C&&v&&v.duration>0&&R.jsx(rr,{left:I-Math.floor(v.duration*m/l),width:Math.floor(v.duration*m/l),type:"fadeOut",curveType:v.type})]}),u&&!d&&!b&&R.jsxs(R.Fragment,{children:[R.jsx(nr,{clipId:n,trackIndex:r,clipIndex:a,edge:"left",touchOptimized:w,dragHandleProps:{attributes:G,listeners:Q,setActivatorNodeRef:ne,isDragging:L}}),R.jsx(nr,{clipId:n,trackIndex:r,clipIndex:a,edge:"right",touchOptimized:w,dragHandleProps:{attributes:A,listeners:j,setActivatorNodeRef:H,isDragging:K}})]})]})},po=k.div`
376
+ `,ar=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:a,trackName:s,startSample:o,durationSamples:l,samplesPerPixel:i,showHeader:u=!1,disableHeaderDrag:d=!1,isOverlay:b=!1,isSelected:p=!1,onMouseDown:f,trackId:C,fadeIn:y,fadeOut:g,sampleRate:m=44100,showFades:w=!1,touchOptimized:x=!1})=>{const v=Math.floor(o/i),I=Math.floor((o+l)/i)-v,$=u&&!d&&!b,M=`clip-${r}-${a}`,{attributes:T,listeners:_,setNodeRef:D,setActivatorNodeRef:V,transform:W,isDragging:O}=fn({id:M,data:{clipId:n,trackIndex:r,clipIndex:a},disabled:!$}),N=`clip-boundary-left-${r}-${a}`,{attributes:Y,listeners:ee,setActivatorNodeRef:re,isDragging:X}=fn({id:N,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"left"},disabled:!$}),oe=`clip-boundary-right-${r}-${a}`,{attributes:A,listeners:j,setActivatorNodeRef:H,isDragging:U}=fn({id:oe,data:{clipId:n,trackIndex:r,clipIndex:a,boundary:"right"},disabled:!$}),ge=W?{transform:Cn.Translate.toString(W),zIndex:O?100:void 0}:void 0;return E.jsxs(ho,{ref:D,style:ge,className:t,$left:v,$width:I,$isOverlay:b,"data-clip-container":"true","data-track-id":C,onMouseDown:f,children:[u&&E.jsx(so,{clipId:n,trackIndex:r,clipIndex:a,trackName:s,isSelected:p,disableDrag:d,dragHandleProps:$?{attributes:T,listeners:_,setActivatorNodeRef:V}:void 0}),E.jsxs(po,{$isOverlay:b,children:[e,w&&y&&y.duration>0&&E.jsx(rr,{left:0,width:Math.floor(y.duration*m/i),type:"fadeIn",curveType:y.type}),w&&g&&g.duration>0&&E.jsx(rr,{left:I-Math.floor(g.duration*m/i),width:Math.floor(g.duration*m/i),type:"fadeOut",curveType:g.type})]}),u&&!d&&!b&&E.jsxs(E.Fragment,{children:[E.jsx(nr,{clipId:n,trackIndex:r,clipIndex:a,edge:"left",touchOptimized:x,dragHandleProps:{attributes:Y,listeners:ee,setActivatorNodeRef:re,isDragging:X}}),E.jsx(nr,{clipId:n,trackIndex:r,clipIndex:a,edge:"right",touchOptimized:x,dragHandleProps:{attributes:A,listeners:j,setActivatorNodeRef:H,isDragging:U}})]})]})},go=k.div`
377
377
  display: inline-flex;
378
378
  align-items: center;
379
379
  gap: 0.5rem;
380
- `,go=k(Nr)`
380
+ `,bo=k(Nr)`
381
381
  margin: 0;
382
382
  white-space: nowrap;
383
- `,bo=k(Lr)`
383
+ `,vo=k(Lr)`
384
384
  width: 120px;
385
- `,vo=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(parseFloat(s.target.value)/100)};return R.jsxs(po,{className:r,children:[R.jsx(go,{htmlFor:"master-gain",children:"Master Volume"}),R.jsx(bo,{min:"0",max:"100",value:e*100,onChange:a,disabled:n,id:"master-gain"})]})};k.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
385
+ `,Co=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(parseFloat(s.target.value)/100)};return E.jsxs(go,{className:r,children:[E.jsx(bo,{htmlFor:"master-gain",children:"Master Volume"}),E.jsx(vo,{min:"0",max:"100",value:e*100,onChange:a,disabled:n,id:"master-gain"})]})};k.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
386
386
  position: absolute;
387
387
  top: 0;
388
388
  left: 0;
@@ -416,23 +416,23 @@ React keys must be passed directly to JSX without using spread:
416
416
  width: 2px;
417
417
  height: 100%;
418
418
  background: ${e=>e.$color};
419
- `;var Co=k.div`
419
+ `;var wo=k.div`
420
420
  overflow-y: hidden;
421
421
  overflow-x: auto;
422
422
  position: relative;
423
423
  `,xo=k.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
424
424
  position: relative;
425
425
  background: ${e=>e.$backgroundColor||"transparent"};
426
- `,wo=k.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
426
+ `,yo=k.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
427
427
  background: ${e=>e.$backgroundColor||"white"};
428
428
  width: 100%;
429
429
  position: relative;
430
430
  overflow: hidden; /* Constrain loop region to timescale area */
431
- `,yo=k.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
431
+ `,Io=k.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
432
432
  position: relative;
433
433
  background: ${e=>e.$backgroundColor||"transparent"};
434
434
  width: 100%;
435
- `,Io=k.div`
435
+ `,So=k.div`
436
436
  position: absolute;
437
437
  top: 0;
438
438
  left: 0;
@@ -441,7 +441,7 @@ React keys must be passed directly to JSX without using spread:
441
441
  cursor: crosshair;
442
442
  /* When selecting, raise z-index above clip boundaries (z-index: 105) to prevent interference */
443
443
  z-index: ${e=>e.$isSelecting?110:1};
444
- `,Kr=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:a,tracksWidth:s,scrollContainerWidth:o,controlsWidth:i,onTracksClick:l,onTracksMouseDown:u,onTracksMouseMove:d,onTracksMouseUp:b,scrollContainerRef:p,isSelecting:f})=>R.jsx(Co,{"data-scroll-container":"true",ref:p,children:R.jsxs(xo,{$backgroundColor:t,$width:o,children:[r&&R.jsx(wo,{$width:a,$backgroundColor:n,children:r}),R.jsxs(yo,{$width:s,$backgroundColor:t,children:[e,(l||u)&&R.jsx(Io,{$controlsWidth:i,$isSelecting:f,onClick:l,onMouseDown:u,onMouseMove:d,onMouseUp:b})]})]})});k.withTheme(Kr);var So=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
444
+ `,Kr=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:a,tracksWidth:s,scrollContainerWidth:o,controlsWidth:l,onTracksClick:i,onTracksMouseDown:u,onTracksMouseMove:d,onTracksMouseUp:b,scrollContainerRef:p,isSelecting:f})=>E.jsx(wo,{"data-scroll-container":"true",ref:p,children:E.jsxs(xo,{$backgroundColor:t,$width:o,children:[r&&E.jsx(yo,{$width:a,$backgroundColor:n,children:r}),E.jsxs(Io,{$width:s,$backgroundColor:t,children:[e,(i||u)&&E.jsx(So,{$controlsWidth:l,$isSelecting:f,onClick:i,onMouseDown:u,onMouseMove:d,onMouseUp:b})]})]})});k.withTheme(Kr);var Ao=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
445
445
  position: absolute;
446
446
  top: 0;
447
447
  background: ${e=>e.$color};
@@ -449,7 +449,7 @@ React keys must be passed directly to JSX without using spread:
449
449
  z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
450
450
  pointer-events: none;
451
451
  opacity: 0.3;
452
- `,Ao=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:R.jsx(So,{$left:e,$width:r,$color:n,"data-selection":!0})};k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
452
+ `,ko=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:E.jsx(Ao,{$left:e,$width:r,$color:n,"data-selection":!0})};k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
453
453
  position: absolute;
454
454
  top: 0;
455
455
  background: ${e=>e.$color};
@@ -513,7 +513,7 @@ React keys must be passed directly to JSX without using spread:
513
513
  &:hover::before {
514
514
  opacity: 1;
515
515
  }
516
- `,ko=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
516
+ `,$o=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
517
517
  position: absolute;
518
518
  top: 0;
519
519
  height: 100%;
@@ -524,41 +524,41 @@ React keys must be passed directly to JSX without using spread:
524
524
  &:active {
525
525
  cursor: grabbing;
526
526
  }
527
- `,$o=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopStartChange:a,onLoopEndChange:s,onLoopRegionMove:o,minPosition:i=0,maxPosition:l=1/0})=>{const[u,d]=c.useState(null),b=c.useRef(0),p=c.useRef(0),f=c.useRef(0),x=Math.max(0,t-e),y=c.useCallback((m,C)=>{m.preventDefault(),m.stopPropagation(),d(C),b.current=m.clientX,p.current=C==="start"?e:t;const w=S=>{const I=S.clientX-b.current,E=p.current+I;if(C==="start"){const D=Math.max(i,Math.min(t-10,E));a?.(D)}else{const D=Math.max(e+10,Math.min(l,E));s?.(D)}},g=()=>{d(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",g)},[e,t,i,l,a,s]),v=c.useCallback(m=>{m.preventDefault(),m.stopPropagation(),d("region"),b.current=m.clientX,p.current=e,f.current=t;const C=t-e,w=S=>{const I=S.clientX-b.current;let E=p.current+I,D=f.current+I;E<i&&(E=i,D=i+C),D>l&&(D=l,E=l-C),o?.(E,D)},g=()=>{d(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",g)},[e,t,i,l,o]);return x<=0?null:R.jsxs(R.Fragment,{children:[R.jsx(ko,{$left:e,$width:x,$color:r,$isDragging:u==="region",onMouseDown:v,"data-loop-region-timescale":!0}),R.jsx(or,{$left:e,$color:n,$isStart:!0,$isDragging:u==="start",onMouseDown:m=>y(m,"start"),"data-loop-marker-handle":"start"}),R.jsx(or,{$left:t,$color:n,$isStart:!1,$isDragging:u==="end",onMouseDown:m=>y(m,"end"),"data-loop-marker-handle":"end"})]})},Ro=k.div.attrs(e=>({style:{left:`${e.$leftOffset||0}px`}}))`
527
+ `,Ro=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopStartChange:a,onLoopEndChange:s,onLoopRegionMove:o,minPosition:l=0,maxPosition:i=1/0})=>{const[u,d]=c.useState(null),b=c.useRef(0),p=c.useRef(0),f=c.useRef(0),C=Math.max(0,t-e),y=c.useCallback((m,w)=>{m.preventDefault(),m.stopPropagation(),d(w),b.current=m.clientX,p.current=w==="start"?e:t;const x=S=>{const I=S.clientX-b.current,$=p.current+I;if(w==="start"){const M=Math.max(l,Math.min(t-10,$));a?.(M)}else{const M=Math.max(e+10,Math.min(i,$));s?.(M)}},v=()=>{d(null),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",v)},[e,t,l,i,a,s]),g=c.useCallback(m=>{m.preventDefault(),m.stopPropagation(),d("region"),b.current=m.clientX,p.current=e,f.current=t;const w=t-e,x=S=>{const I=S.clientX-b.current;let $=p.current+I,M=f.current+I;$<l&&($=l,M=l+w),M>i&&(M=i,$=i-w),o?.($,M)},v=()=>{d(null),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",v)},[e,t,l,i,o]);return C<=0?null:E.jsxs(E.Fragment,{children:[E.jsx($o,{$left:e,$width:C,$color:r,$isDragging:u==="region",onMouseDown:g,"data-loop-region-timescale":!0}),E.jsx(or,{$left:e,$color:n,$isStart:!0,$isDragging:u==="start",onMouseDown:m=>y(m,"start"),"data-loop-marker-handle":"start"}),E.jsx(or,{$left:t,$color:n,$isStart:!1,$isDragging:u==="end",onMouseDown:m=>y(m,"end"),"data-loop-marker-handle":"end"})]})},Eo=k.div.attrs(e=>({style:{left:`${e.$leftOffset||0}px`}}))`
528
528
  position: absolute;
529
529
  top: 0;
530
530
  right: 0;
531
531
  height: 100%; /* Stay within timescale bounds, don't extend into tracks */
532
532
  cursor: crosshair;
533
533
  z-index: 40; /* Below markers and shading */
534
- `,Eo=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopRegionChange:a,minPosition:s=0,maxPosition:o=1/0,controlsOffset:i=0})=>{const[l,u]=c.useState(!1),d=c.useRef(0),b=c.useRef(null),p=t>e,f=c.useCallback(x=>{const y=x.target;if(y.closest("[data-loop-marker-handle]")||y.closest("[data-loop-region-timescale]"))return;x.preventDefault(),u(!0);const v=b.current?.getBoundingClientRect();if(!v)return;const m=x.clientX-v.left,C=Math.max(s,Math.min(o,m));d.current=C,a?.(C,C);const w=S=>{const I=S.clientX-v.left,E=Math.max(s,Math.min(o,I)),D=Math.min(d.current,E),_=Math.max(d.current,E);a?.(D,_)},g=()=>{u(!1),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",g)},[s,o,a]);return R.jsx(Ro,{ref:b,$leftOffset:i,onMouseDown:f,"data-timescale-loop-creator":!0,children:p&&R.jsx($o,{startPosition:e,endPosition:t,markerColor:n,regionColor:r,minPosition:s,maxPosition:o,onLoopStartChange:x=>a?.(x,t),onLoopEndChange:x=>a?.(e,x),onLoopRegionMove:(x,y)=>a?.(x,y)})})};function Tt(e,t){const n=Math.floor(e/3600)%24,r=Math.floor(e/60)%60,a=(e%60).toFixed(t);return String(n).padStart(2,"0")+":"+String(r).padStart(2,"0")+":"+a.padStart(t+3,"0")}function It(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return Tt(e,0);case"hh:mm:ss.u":return Tt(e,1);case"hh:mm:ss.uu":return Tt(e,2);case"hh:mm:ss.uuu":return Tt(e,3);default:return Tt(e,3)}}function Ur(e,t){if(!e)return 0;switch(t){case"seconds":case"thousandths":return parseFloat(e)||0;case"hh:mm:ss":case"hh:mm:ss.u":case"hh:mm:ss.uu":case"hh:mm:ss.uuu":{const n=e.split(":");if(n.length!==3)return 0;const r=parseInt(n[0],10)||0,a=parseInt(n[1],10)||0,s=parseFloat(n[2])||0;return r*3600+a*60+s}default:return 0}}var sr=({id:e,label:t,value:n,format:r,className:a,onChange:s,readOnly:o=!1})=>{const[i,l]=c.useState("");c.useEffect(()=>{const p=It(n,r);l(p)},[n,r,e]);const u=p=>{const f=p.target.value;l(f)},d=()=>{if(s){const p=Ur(i,r);s(p)}l(It(n,r))},b=p=>{p.key==="Enter"&&p.currentTarget.blur()};return R.jsxs(R.Fragment,{children:[R.jsx(Ua,{as:"label",htmlFor:e,children:t}),R.jsx(Or,{type:"text",className:a,id:e,value:i,onChange:u,onBlur:d,onKeyDown:b,readOnly:o})]})},To=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[a,s]=c.useState("hh:mm:ss.uuu");c.useEffect(()=>{const l=document.querySelector(".time-format"),u=()=>{l&&s(l.value)};return l&&(s(l.value),l.addEventListener("change",u)),()=>{l?.removeEventListener("change",u)}},[]);const o=l=>{n&&n(l,t)},i=l=>{n&&n(e,l)};return R.jsxs(R.Fragment,{children:[R.jsx(sr,{id:"audio_start",label:"Start of audio selection",value:e,format:a,className:"audio-start form-control mr-sm-2",onChange:o}),R.jsx(sr,{id:"audio_end",label:"End of audio selection",value:t,format:a,className:"audio-end form-control mr-sm-2",onChange:i})]})};function Lt(){return window.devicePixelRatio}var Jr=c.createContext(Lt()),Do=({children:e})=>{const[t,n]=c.useState(Lt());return matchMedia(`(resolution: ${Lt()}dppx)`).addEventListener("change",()=>{n(Lt())},{once:!0}),R.jsx(Jr.Provider,{value:Math.ceil(t),children:e})},qr=()=>c.useContext(Jr),_n=c.createContext({sampleRate:48e3,samplesPerPixel:1e3,zoomLevels:[1e3,1500,2e3,2500],waveHeight:80,timeScaleHeight:15,controls:{show:!1,width:150},duration:3e4,barWidth:1,barGap:0}),Qt=()=>c.useContext(_n),Mn=()=>c.useContext(k.ThemeContext),Qr=c.createContext(R.jsx(c.Fragment,{})),_o=()=>c.useContext(Qr),Mo=0,Bo=!1,Fo=0,Wo=0,Zo={progress:Mo,isPlaying:Bo,selectionStart:Fo,selectionEnd:Wo};c.createContext(Zo);c.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var Po=({isSelected:e,transparentBackground:t,...n})=>{const r=Mn(),{waveHeight:a,barWidth:s,barGap:o}=Qt(),i=qr(),l=e&&r?r.selectedWaveOutlineColor:r?.waveOutlineColor,u=e&&r?r.selectedWaveFillColor:r?.waveFillColor,d=r?.waveformDrawMode||"inverted";return R.jsx(ro,{...n,...r,waveOutlineColor:l,waveFillColor:u,waveHeight:a,devicePixelRatio:i,barWidth:s,barGap:o,transparentBackground:t,drawMode:d})};function Vo(e,t,n){return Math.ceil(e*n/t)}function jo(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var zo=k.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,marginLeft:`${e.$controlWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
534
+ `,Do=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopRegionChange:a,minPosition:s=0,maxPosition:o=1/0,controlsOffset:l=0})=>{const[i,u]=c.useState(!1),d=c.useRef(0),b=c.useRef(null),p=t>e,f=c.useCallback(C=>{const y=C.target;if(y.closest("[data-loop-marker-handle]")||y.closest("[data-loop-region-timescale]"))return;C.preventDefault(),u(!0);const g=b.current?.getBoundingClientRect();if(!g)return;const m=C.clientX-g.left,w=Math.max(s,Math.min(o,m));d.current=w,a?.(w,w);const x=S=>{const I=S.clientX-g.left,$=Math.max(s,Math.min(o,I)),M=Math.min(d.current,$),T=Math.max(d.current,$);a?.(M,T)},v=()=>{u(!1),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",v)},[s,o,a]);return E.jsx(Eo,{ref:b,$leftOffset:l,onMouseDown:f,"data-timescale-loop-creator":!0,children:p&&E.jsx(Ro,{startPosition:e,endPosition:t,markerColor:n,regionColor:r,minPosition:s,maxPosition:o,onLoopStartChange:C=>a?.(C,t),onLoopEndChange:C=>a?.(e,C),onLoopRegionMove:(C,y)=>a?.(C,y)})})};function Dt(e,t){const n=Math.floor(e/3600)%24,r=Math.floor(e/60)%60,a=(e%60).toFixed(t);return String(n).padStart(2,"0")+":"+String(r).padStart(2,"0")+":"+a.padStart(t+3,"0")}function It(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return Dt(e,0);case"hh:mm:ss.u":return Dt(e,1);case"hh:mm:ss.uu":return Dt(e,2);case"hh:mm:ss.uuu":return Dt(e,3);default:return Dt(e,3)}}function Ur(e,t){if(!e)return 0;switch(t){case"seconds":case"thousandths":return parseFloat(e)||0;case"hh:mm:ss":case"hh:mm:ss.u":case"hh:mm:ss.uu":case"hh:mm:ss.uuu":{const n=e.split(":");if(n.length!==3)return 0;const r=parseInt(n[0],10)||0,a=parseInt(n[1],10)||0,s=parseFloat(n[2])||0;return r*3600+a*60+s}default:return 0}}var sr=({id:e,label:t,value:n,format:r,className:a,onChange:s,readOnly:o=!1})=>{const[l,i]=c.useState("");c.useEffect(()=>{const p=It(n,r);i(p)},[n,r,e]);const u=p=>{const f=p.target.value;i(f)},d=()=>{if(s){const p=Ur(l,r);s(p)}i(It(n,r))},b=p=>{p.key==="Enter"&&p.currentTarget.blur()};return E.jsxs(E.Fragment,{children:[E.jsx(Ja,{as:"label",htmlFor:e,children:t}),E.jsx(Or,{type:"text",className:a,id:e,value:l,onChange:u,onBlur:d,onKeyDown:b,readOnly:o})]})},To=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[a,s]=c.useState("hh:mm:ss.uuu");c.useEffect(()=>{const i=document.querySelector(".time-format"),u=()=>{i&&s(i.value)};return i&&(s(i.value),i.addEventListener("change",u)),()=>{i?.removeEventListener("change",u)}},[]);const o=i=>{n&&n(i,t)},l=i=>{n&&n(e,i)};return E.jsxs(E.Fragment,{children:[E.jsx(sr,{id:"audio_start",label:"Start of audio selection",value:e,format:a,className:"audio-start form-control mr-sm-2",onChange:o}),E.jsx(sr,{id:"audio_end",label:"End of audio selection",value:t,format:a,className:"audio-end form-control mr-sm-2",onChange:l})]})};function Xt(){return window.devicePixelRatio}var Jr=c.createContext(Xt()),_o=({children:e})=>{const[t,n]=c.useState(Xt());return matchMedia(`(resolution: ${Xt()}dppx)`).addEventListener("change",()=>{n(Xt())},{once:!0}),E.jsx(Jr.Provider,{value:Math.ceil(t),children:e})},qr=()=>c.useContext(Jr),_n=c.createContext({sampleRate:48e3,samplesPerPixel:1e3,zoomLevels:[1e3,1500,2e3,2500],waveHeight:80,timeScaleHeight:15,controls:{show:!1,width:150},duration:3e4,barWidth:1,barGap:0}),en=()=>c.useContext(_n),Mn=()=>c.useContext(k.ThemeContext),Qr=c.createContext(E.jsx(c.Fragment,{})),Mo=()=>c.useContext(Qr),Bo=0,Fo=!1,Wo=0,Zo=0,Po={progress:Bo,isPlaying:Fo,selectionStart:Wo,selectionEnd:Zo};c.createContext(Po);c.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var Vo=({isSelected:e,transparentBackground:t,...n})=>{const r=Mn(),{waveHeight:a,barWidth:s,barGap:o}=en(),l=qr(),i=e&&r?r.selectedWaveOutlineColor:r?.waveOutlineColor,u=e&&r?r.selectedWaveFillColor:r?.waveFillColor,d=r?.waveformDrawMode||"inverted";return E.jsx(ao,{...n,...r,waveOutlineColor:i,waveFillColor:u,waveHeight:a,devicePixelRatio:l,barWidth:s,barGap:o,transparentBackground:t,drawMode:d})};function jo(e,t,n){return Math.ceil(e*n/t)}function zo(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var Oo=k.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,marginLeft:`${e.$controlWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
535
535
  position: relative;
536
536
  overflow: visible; /* Allow time labels to render above the container */
537
537
  border-bottom: 1px solid ${e=>e.theme.timeColor};
538
538
  box-sizing: border-box;
539
- `,Oo=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
539
+ `,No=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
540
540
  position: absolute;
541
541
  left: 0;
542
542
  right: 0;
543
543
  bottom: 0;
544
- `,No=k.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
544
+ `,Lo=k.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
545
545
  position: absolute;
546
546
  font-size: 0.75rem; /* Smaller font to prevent overflow */
547
547
  white-space: nowrap; /* Prevent text wrapping */
548
548
  color: ${e=>e.theme.timeColor}; /* Use theme color instead of inheriting */
549
- `,Lo=e=>{const{theme:{timeColor:t},duration:n,marker:r,bigStep:a,secondStep:s,renderTimestamp:o}=e,i=new Map,l=[],u=c.useRef(null),{sampleRate:d,samplesPerPixel:b,timeScaleHeight:p,controls:{show:f,width:x}}=c.useContext(_n),y=qr();c.useEffect(()=>{if(u.current!==null){const w=u.current,g=w.getContext("2d");if(g){g.resetTransform(),g.clearRect(0,0,w.width,w.height),g.imageSmoothingEnabled=!1,g.fillStyle=t,g.scale(y,y);for(const[S,I]of i.entries()){const E=p-I;g.fillRect(S,E,1,I)}}}},[n,y,t,p,a,s,r,i]);const v=Vo(n/1e3,b,d),m=d/b;let C=0;for(let w=0;w<v;w+=m*s/1e3){const g=Math.floor(w);if(C%r===0){const S=C,I=jo(S),E=o?R.jsx(c.Fragment,{children:o(S,g)},`timestamp-${C}`):R.jsx(No,{$left:g,children:I},I);l.push(E),i.set(g,p)}else C%a===0?i.set(g,Math.floor(p/2)):C%s===0&&i.set(g,Math.floor(p/5));C+=s}return R.jsxs(zo,{$cssWidth:v,$controlWidth:f?x:0,$timeScaleHeight:p,children:[l,R.jsx(Oo,{$cssWidth:v,$timeScaleHeight:p,width:v*y,height:p*y,ref:u})]})},Xo=k.withTheme(Lo),Ho=k.div`
549
+ `,Xo=e=>{const{theme:{timeColor:t},duration:n,marker:r,bigStep:a,secondStep:s,renderTimestamp:o}=e,l=new Map,i=[],u=c.useRef(null),{sampleRate:d,samplesPerPixel:b,timeScaleHeight:p,controls:{show:f,width:C}}=c.useContext(_n),y=qr();c.useEffect(()=>{if(u.current!==null){const x=u.current,v=x.getContext("2d");if(v){v.resetTransform(),v.clearRect(0,0,x.width,x.height),v.imageSmoothingEnabled=!1,v.fillStyle=t,v.scale(y,y);for(const[S,I]of l.entries()){const $=p-I;v.fillRect(S,$,1,I)}}}},[n,y,t,p,a,s,r,l]);const g=jo(n/1e3,b,d),m=d/b;let w=0;for(let x=0;x<g;x+=m*s/1e3){const v=Math.floor(x);if(w%r===0){const S=w,I=zo(S),$=o?E.jsx(c.Fragment,{children:o(S,v)},`timestamp-${w}`):E.jsx(Lo,{$left:v,children:I},I);i.push($),l.set(v,p)}else w%a===0?l.set(v,Math.floor(p/2)):w%s===0&&l.set(v,Math.floor(p/5));w+=s}return E.jsxs(Oo,{$cssWidth:g,$controlWidth:f?C:0,$timeScaleHeight:p,children:[i,E.jsx(No,{$cssWidth:g,$timeScaleHeight:p,width:g*y,height:p*y,ref:u})]})},Ho=k.withTheme(Xo),Go=k.div`
550
550
  display: inline-flex;
551
551
  align-items: center;
552
552
  gap: 0.5rem;
553
- `,Go=[{value:"seconds",label:"seconds"},{value:"thousandths",label:"thousandths"},{value:"hh:mm:ss",label:"hh:mm:ss"},{value:"hh:mm:ss.u",label:"hh:mm:ss + tenths"},{value:"hh:mm:ss.uu",label:"hh:mm:ss + hundredths"},{value:"hh:mm:ss.uuu",label:"hh:mm:ss + milliseconds"}],Yo=({value:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.value)};return R.jsx(Ho,{className:r,children:R.jsx(Dn,{className:"time-format",value:e,onChange:a,disabled:n,"aria-label":"Time format selection",children:Go.map(s=>R.jsx("option",{value:s.value,children:s.label},s.value))})})},Ko=k.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?Hr:0)}px`}}))`
553
+ `,Yo=[{value:"seconds",label:"seconds"},{value:"thousandths",label:"thousandths"},{value:"hh:mm:ss",label:"hh:mm:ss"},{value:"hh:mm:ss.u",label:"hh:mm:ss + tenths"},{value:"hh:mm:ss.uu",label:"hh:mm:ss + hundredths"},{value:"hh:mm:ss.uuu",label:"hh:mm:ss + milliseconds"}],Ko=({value:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.value)};return E.jsx(Go,{className:r,children:E.jsx(Tn,{className:"time-format",value:e,onChange:a,disabled:n,"aria-label":"Time format selection",children:Yo.map(s=>E.jsx("option",{value:s.value,children:s.label},s.value))})})},Uo=k.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?Hr:0)}px`}}))`
554
554
  position: relative;
555
555
  display: flex;
556
556
  ${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
557
- `,Uo=k.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
557
+ `,Jo=k.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
558
558
  position: relative;
559
559
  background: ${e=>e.$backgroundColor||"transparent"};
560
560
  flex: 1;
561
- `,Jo=k.div.attrs(e=>({style:{width:`${e.$controlWidth}px`}}))`
561
+ `,qo=k.div.attrs(e=>({style:{width:`${e.$controlWidth}px`}}))`
562
562
  position: sticky;
563
563
  z-index: 101; /* Above waveform content, below Docusaurus navbar (z-index: 200) */
564
564
  left: 0;
@@ -572,7 +572,7 @@ React keys must be passed directly to JSX without using spread:
572
572
  ${e=>e.$isSelected&&`
573
573
  background: ${e.theme.selectedTrackControlsBackground};
574
574
  `}
575
- `,qo=({numChannels:e,children:t,className:n,backgroundColor:r,offset:a=0,width:s,hasClipHeaders:o=!1,onClick:i,trackId:l,isSelected:u=!1})=>{const{waveHeight:d,controls:{show:b,width:p}}=Qt(),f=_o();return R.jsxs(Ko,{$numChannels:e,className:n,$waveHeight:d,$controlWidth:b?p:0,$width:s,$hasClipHeaders:o,$isSelected:u,children:[R.jsx(Jo,{$controlWidth:b?p:0,$isSelected:u,children:f}),R.jsx(Uo,{$controlWidth:b?p:0,$backgroundColor:r,$offset:a,onClick:i,"data-track-id":l,children:t})]})},ir=k.button.attrs({type:"button"})`
575
+ `,Qo=({numChannels:e,children:t,className:n,backgroundColor:r,offset:a=0,width:s,hasClipHeaders:o=!1,onClick:l,trackId:i,isSelected:u=!1})=>{const{waveHeight:d,controls:{show:b,width:p}}=en(),f=Mo();return E.jsxs(Uo,{$numChannels:e,className:n,$waveHeight:d,$controlWidth:b?p:0,$width:s,$hasClipHeaders:o,$isSelected:u,children:[E.jsx(qo,{$controlWidth:b?p:0,$isSelected:u,children:f}),E.jsx(Jo,{$controlWidth:b?p:0,$backgroundColor:r,$offset:a,onClick:l,"data-track-id":i,children:t})]})},ir=k.button.attrs({type:"button"})`
576
576
  display: inline-block;
577
577
  font-family: ${e=>e.theme.fontFamily};
578
578
  font-weight: 500;
@@ -631,7 +631,7 @@ React keys must be passed directly to JSX without using spread:
631
631
  box-shadow: 0 0 0 0.2rem ${e.theme.inputFocusBorder}33;
632
632
  }
633
633
  `}
634
- `,Qo=k.div`
634
+ `,es=k.div`
635
635
  margin-bottom: 0.3rem;
636
636
 
637
637
  button:not(:first-child) {
@@ -643,7 +643,7 @@ React keys must be passed directly to JSX without using spread:
643
643
  border-top-right-radius: 0;
644
644
  border-bottom-right-radius: 0;
645
645
  }
646
- `,es=k.div`
646
+ `,ts=k.div`
647
647
  background: transparent;
648
648
  width: 100%;
649
649
  height: 100%;
@@ -656,7 +656,7 @@ React keys must be passed directly to JSX without using spread:
656
656
  text-align: center;
657
657
  border: 1px solid ${e=>e.theme.borderColor};
658
658
  border-radius: ${e=>e.theme.borderRadius};
659
- `,ts=k.header`
659
+ `,ns=k.header`
660
660
  overflow: hidden;
661
661
  height: 26px;
662
662
  width: 100%;
@@ -667,7 +667,7 @@ React keys must be passed directly to JSX without using spread:
667
667
  font-size: ${e=>e.theme.fontSizeSmall};
668
668
  color: ${e=>e.theme.textColor};
669
669
  background-color: transparent;
670
- `,ns=e=>R.jsx(zr,{weight:"light",...e}),rs=e=>R.jsx(jr,{weight:"light",...e}),lr=k(Lr)`
670
+ `,rs=e=>E.jsx(zr,{weight:"light",...e}),as=e=>E.jsx(jr,{weight:"light",...e}),lr=k(Lr)`
671
671
  width: 75%;
672
672
  height: 5px;
673
673
  background: ${e=>e.theme.sliderTrackColor};
@@ -762,7 +762,8 @@ React keys must be passed directly to JSX without using spread:
762
762
  &:active {
763
763
  transform: scale(0.9);
764
764
  }
765
- `;function as(e){let t=1/0,n=-1/0;for(let r=0;r<e.length;r++){const a=e[r];t>a&&(t=a),n<a&&(n=a)}return{min:t,max:n}}function ur(e,t){const n=Math.pow(2,t-1),r=e<0?e*n:e*(n-1);return Math.max(-n,Math.min(n-1,r))}function ea(e,t){switch(e){case 8:return new Int8Array(t);case 16:return new Int16Array(t)}}function dr(e,t,n){const r=e.length,a=Math.ceil(r/t),s=ea(n,a*2);for(let o=0;o<a;o++){const i=o*t,l=Math.min((o+1)*t,r),u=e.subarray(i,l),d=as(u),b=ur(d.min,n),p=ur(d.max,n);s[o*2]=b,s[o*2+1]=p}return s}function os(e,t){const n=e.length,r=1/n,a=e[0].length/2,s=ea(t,a*2);for(let o=0;o<a;o++){let i=0,l=0;for(let u=0;u<n;u++)i+=r*e[u][o*2],l+=r*e[u][o*2+1];s[o*2]=i,s[o*2+1]=l}return[s]}function ss(e,t=1e3,n=!0,r=0,a,s=16){if(s!==8&&s!==16)throw new Error("Invalid number of bits specified for peaks. Must be 8 or 16.");let o=[];if("getChannelData"in e){const l=e.numberOfChannels,u=a??e.length;for(let d=0;d<l;d++){const p=e.getChannelData(d).subarray(r,u);o.push(dr(p,t,s))}}else{const l=a??e.length,u=e.subarray(r,l);o.push(dr(u,t,s))}return n&&o.length>1&&(o=os(o,s)),{length:o[0].length/2,data:o,bits:s}}function is(e,t=1e3,n=!0,r=8,a=0,s){const o=e.sampleRate,i=Math.floor(a*o),l=s!==void 0?Math.floor((a+s)*o):void 0;return ss(e,t,n,i,l,r)}var fr;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(fr||(fr={}));function hr(){}const ls=Object.freeze({x:0,y:0});var wt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(wt||(wt={}));var mr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(mr||(mr={}));var ct;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(ct||(ct={}));ct.Space,ct.Enter,ct.Esc,ct.Space,ct.Enter,ct.Tab;var pr;(function(e){e[e.RightClick=2]="RightClick"})(pr||(pr={}));var gr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(gr||(gr={}));var br;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(br||(br={}));wt.Backward+"",wt.Forward+"",wt.Backward+"",wt.Forward+"";var yn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(yn||(yn={}));var In;(function(e){e.Optimized="optimized"})(In||(In={}));function cs(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:a,handler:s}=r;return n[a]=o=>{s(o,t)},n},{}),[e,t])}yn.WhileDragging,In.Optimized;const us={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:hr,draggableNodes:new Map,over:null,measureDroppableContainers:hr},ds=c.createContext(us),fs=c.createContext({...ls,scaleX:1,scaleY:1});var vr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(vr||(vr={}));const hs=c.createContext(null),Cr="button",ms="Draggable";function xr(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=Vr(ms),{activators:o,activatorEvent:i,active:l,activeNodeRect:u,ariaDescribedById:d,draggableNodes:b,over:p}=c.useContext(ds),{role:f=Cr,roleDescription:x="draggable",tabIndex:y=0}=a??{},v=l?.id===t,m=c.useContext(v?fs:hs),[C,w]=Xt(),[g,S]=Xt(),I=cs(o,t),E=Pr(n);Kt(()=>(b.set(t,{id:t,key:s,node:C,activatorNode:g,data:E}),()=>{const _=b.get(t);_&&_.key===s&&b.delete(t)}),[b,t]);const D=c.useMemo(()=>({role:f,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&f===Cr?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,f,y,v,x,d.draggable]);return{active:l,activatorEvent:i,activeNodeRect:u,attributes:D,isDragging:v,listeners:r?void 0:I,node:C,over:p,setNodeRef:w,setActivatorNodeRef:S,transform:m}}function ps(e){return{id:e.id,start:parseFloat(e.begin),end:parseFloat(e.end),lines:e.lines,lang:e.language}}function gs(e){return{id:e.id,begin:e.start.toFixed(3),end:e.end.toFixed(3),lines:e.lines,language:e.lang||"en"}}k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
765
+ `;function os(e){let t=1/0,n=-1/0;for(let r=0;r<e.length;r++){const a=e[r];t>a&&(t=a),n<a&&(n=a)}return{min:t,max:n}}function ur(e,t){const n=Math.pow(2,t-1),r=e<0?e*n:e*(n-1);return Math.max(-n,Math.min(n-1,r))}function ea(e,t){switch(e){case 8:return new Int8Array(t);case 16:return new Int16Array(t)}}function dr(e,t,n){const r=e.length,a=Math.ceil(r/t),s=ea(n,a*2);for(let o=0;o<a;o++){const l=o*t,i=Math.min((o+1)*t,r),u=e.subarray(l,i),d=os(u),b=ur(d.min,n),p=ur(d.max,n);s[o*2]=b,s[o*2+1]=p}return s}function ss(e,t){const n=e.length,r=1/n,a=e[0].length/2,s=ea(t,a*2);for(let o=0;o<a;o++){let l=0,i=0;for(let u=0;u<n;u++)l+=r*e[u][o*2],i+=r*e[u][o*2+1];s[o*2]=l,s[o*2+1]=i}return[s]}function is(e,t=1e3,n=!0,r=0,a,s=16){if(s!==8&&s!==16)throw new Error("Invalid number of bits specified for peaks. Must be 8 or 16.");let o=[];if("getChannelData"in e){const i=e.numberOfChannels,u=a??e.length;for(let d=0;d<i;d++){const p=e.getChannelData(d).subarray(r,u);o.push(dr(p,t,s))}}else{const i=a??e.length,u=e.subarray(r,i);o.push(dr(u,t,s))}return n&&o.length>1&&(o=ss(o,s)),{length:o[0].length/2,data:o,bits:s}}function ls(e,t=1e3,n=!0,r=8,a=0,s){const o=s!==void 0?a+s:void 0;return is(e,t,n,a,o,r)}function pt(e,t){this._waveformData=e,this._channelIndex=t}pt.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};pt.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};pt.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};pt.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};pt.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};pt.prototype.max_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.max_sample(n));return t};var cs=127,us=-128,ds=32767,fs=-32768;function ms(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function hs(e){for(var t=e.scale,n=e.amplitude_scale,r=e.split_channels,a=e.length,s=e.sample_rate,o=e.channels.map(function(D){return new Float32Array(D)}),l=r?o.length:1,i=24,u=ms(a,t),d=e.bits===8?1:2,b=i+u*2*d*l,p=new ArrayBuffer(b),f=new DataView(p),C=0,y=i,g=new Array(l),m=new Array(l),w=0;w<l;w++)g[w]=1/0,m[w]=-1/0;var x=e.bits===8?us:fs,v=e.bits===8?cs:ds;f.setInt32(0,2,!0),f.setUint32(4,e.bits===8,!0),f.setInt32(8,s,!0),f.setInt32(12,t,!0),f.setInt32(16,u,!0),f.setInt32(20,l,!0);for(var S=0;S<a;S++){var I=0;if(l===1){for(var $=0;$<o.length;++$)I+=o[$][S];I=Math.floor(v*I*n/o.length),I<g[0]&&(g[0]=I,g[0]<x&&(g[0]=x)),I>m[0]&&(m[0]=I,m[0]>v&&(m[0]=v))}else for(var M=0;M<l;++M)I=Math.floor(v*o[M][S]*n),I<g[M]&&(g[M]=I,g[M]<x&&(g[M]=x)),I>m[M]&&(m[M]=I,m[M]>v&&(m[M]=v));if(++C===t){for(var T=0;T<l;T++)e.bits===8?(f.setInt8(y++,g[T]),f.setInt8(y++,m[T])):(f.setInt16(y,g[T],!0),f.setInt16(y+2,m[T],!0),y+=4),g[T]=1/0,m[T]=-1/0;C=0}}if(C>0)for(var _=0;_<l;_++)e.bits===8?(f.setInt8(y++,g[_]),f.setInt8(y++,m[_])):(f.setInt16(y,g[_],!0),f.setInt16(y+2,m[_],!0));return p}function Yt(e){"@babel/helpers - typeof";return Yt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yt(e)}function ps(e){return e&&Yt(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function gs(e){var t=e&&Yt(e)==="object"&&"byteLength"in e;if(t){var n=new DataView(e),r=n.getInt32(0,!0);if(r!==1&&r!==2)throw new TypeError("WaveformData.create(): This waveform data version not supported")}return t}function bs(e){var t=e.data,n=e.channels||1,r=24,a=e.bits===8?1:2,s=e.length*2*n;if(t.length!==s)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=r+t.length*a,l=new ArrayBuffer(o),i=new DataView(l);i.setInt32(0,2,!0),i.setUint32(4,e.bits===8,!0),i.setInt32(8,e.sample_rate,!0),i.setInt32(12,e.samples_per_pixel,!0),i.setInt32(16,e.length,!0),i.setInt32(20,n,!0);var u=r;if(e.bits===8)for(var d=0;d<t.length;d++)i.setInt8(u++,t[d],!0);else for(var b=0;b<t.length;b++)i.setInt16(u,t[b],!0),u+=2;return l}function Ct(e){return e==null}function vs(e,t){var n=atob(e);return n}function Cs(e,t,n){var r=vs(e),a=r.indexOf(`
766
+ `,10)+1,s=r.substring(a)+"",o=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(o)}function ws(e,t,n){var r;return function(s){return r=r||Cs(e),new Worker(r,s)}}var xs=ws("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function Oe(e){if(ps(e)&&(e=bs(e)),gs(e)){this._data=new DataView(e),this._offset=this._version()===2?24:20,this._channels=[];for(var t=0;t<this.channels;t++)this._channels[t]=new pt(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var Tt={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function ys(e){var t={scale:e.scale||Tt.scale,bits:e.bits||Tt.bits,amplitude_scale:e.amplitude_scale||Tt.amplitude_scale,split_channels:e.split_channels||Tt.split_channels,disable_worker:e.disable_worker||Tt.disable_worker};return t}function Is(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function ta(e,t,n){var r=Is(e);if(t.disable_worker){var a=hs({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:r});n(void 0,new Oe(a),e)}else{var s=new xs;s.onmessage=function(o){n(void 0,new Oe(o.data),e)},s.postMessage({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:r},r)}}function Ss(e,t,n,r){function a(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var s=e.decodeAudioData(t,function(o){ta(o,n,r)},a);s&&s.catch(a)}Oe.create=function(t){return new Oe(t)};Oe.createFromAudio=function(e,t){var n=ys(e);if(e.audio_context&&e.array_buffer)return Ss(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return ta(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function tn(e){this._inputData=e.waveformData,this._output_samples_per_pixel=e.scale,this._scale=this._inputData.scale,this._input_buffer_size=this._inputData.length;var t=this._input_buffer_size*this._inputData.scale,n=Math.ceil(t/this._output_samples_per_pixel),r=24,a=this._inputData.bits===8?1:2,s=r+n*2*this._inputData.channels*a;this._output_data=new ArrayBuffer(s),this.output_dataview=new DataView(this._output_data),this.output_dataview.setInt32(0,2,!0),this.output_dataview.setUint32(4,this._inputData.bits===8,!0),this.output_dataview.setInt32(8,this._inputData.sample_rate,!0),this.output_dataview.setInt32(12,this._output_samples_per_pixel,!0),this.output_dataview.setInt32(16,n,!0),this.output_dataview.setInt32(20,this._inputData.channels,!0),this._outputWaveformData=new Oe(this._output_data),this._input_index=0,this._output_index=0;var o=this._inputData.channels;this._min=new Array(o),this._max=new Array(o);for(var l=0;l<o;++l)this._input_buffer_size>0?(this._min[l]=this._inputData.channel(l).min_sample(this._input_index),this._max[l]=this._inputData.channel(l).max_sample(this._input_index)):(this._min[l]=0,this._max[l]=0);this._min_value=this._inputData.bits===8?-128:-32768,this._max_value=this._inputData.bits===8?127:32767,this._where=0,this._prev_where=0,this._stop=0,this._last_input_index=0}tn.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};tn.prototype.next=function(){for(var e=0,t=1e3,n=this._inputData.channels,r;this._input_index<this._input_buffer_size&&e<t;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(var a=0;a<n;++a)r=this._outputWaveformData.channel(a),r.set_min_sample(this._output_index-1,this._min[a]),r.set_max_sample(this._output_index-1,this._max[a]);if(this._last_input_index=this._input_index,this._output_index++,this._where=this.sample_at_pixel(this._output_index),this._prev_where=this.sample_at_pixel(this._output_index-1),this._where!==this._prev_where)for(var s=0;s<n;++s)this._min[s]=this._max_value,this._max[s]=this._min_value}for(this._where=this.sample_at_pixel(this._output_index),this._stop=Math.floor(this._where/this._scale),this._stop>this._input_buffer_size&&(this._stop=this._input_buffer_size);this._input_index<this._stop;){for(var o=0;o<n;++o){r=this._inputData.channel(o);var l=r.min_sample(this._input_index);l<this._min[o]&&(this._min[o]=l),l=r.max_sample(this._input_index),l>this._max[o]&&(this._max[o]=l)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var i=0;i<n;++i)r=this._outputWaveformData.channel(i),r.set_min_sample(this._output_index-1,this._min[i]),r.set_max_sample(this._output_index-1,this._max[i]);return!0};tn.prototype.getOutputData=function(){return this._output_data};Oe.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Ct(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Ct(n.scale)&&(typeof n.scale!="number"||n.scale<=0))throw new RangeError("WaveformData.resample(): scale should be a positive integer value");if(!n.scale&&!n.width)throw new Error("WaveformData.resample(): Missing scale or width option");if(n.width&&(n.scale=Math.floor(this.duration*this.sample_rate/n.width)),n.scale<this.scale)throw new Error("WaveformData.resample(): Zoom level "+n.scale+" too low, minimum: "+this.scale);return n.abortSignal=t.abortSignal,n},resample:function(t){t=this._getResampleOptions(t),t.waveformData=this;for(var n=new tn(t);!n.next(););return new Oe(n.getOutputData())},concat:function(){var t=this,n=Array.prototype.slice.call(arguments);n.forEach(function(a){if(t.channels!==a.channels||t.sample_rate!==a.sample_rate||t.bits!==a.bits||t.scale!==a.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")});var r=this._concatBuffers.apply(this,n);return Oe.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,a=0,s=[this].concat(t).map(function(m){return m._data.buffer}),o=0;o<s.length;o++){var l=s[o],i=new DataView(l).getInt32(16,!0);r+=l.byteLength-n,a+=i}for(var u=new ArrayBuffer(r),d=new DataView(s[0]),b=new DataView(u),p=0;p<n;p++)b.setUint8(p,d.getUint8(p));b.setInt32(16,a,!0);for(var f=0,C=new Uint8Array(u,n),y=0;y<s.length;y++){var g=s[y];C.set(new Uint8Array(g,n),f),f+=g.byteLength-n}return u},slice:function(t){var n=0,r=0;if(!Ct(t.startIndex)&&!Ct(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Ct(t.startTime)&&!Ct(t.endTime)&&(n=this.at_time(t.startTime),r=this.at_time(t.endTime)),n<0)throw new RangeError("startIndex or startTime must not be negative");if(r<0)throw new RangeError("endIndex or endTime must not be negative");n>this.length&&(n=this.length),r>this.length&&(r=this.length),n>r&&(n=r);var a=r-n,s=24,o=this.bits===8?1:2,l=s+a*2*this.channels*o,i=new ArrayBuffer(l),u=new DataView(i);u.setInt32(0,2,!0),u.setUint32(4,this.bits===8,!0),u.setInt32(8,this.sample_rate,!0),u.setInt32(12,this.scale,!0),u.setInt32(16,a,!0),u.setInt32(20,this.channels,!0);for(var d=0;d<a*this.channels*2;d++){var b=this._at(n*this.channels*2+d);this.bits===8?u.setInt8(s+d,b):u.setInt16(s+d*2,b,!0)}return new Oe(i)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){var e=!!this._data.getUint32(4,!0);return e?8:16},get duration(){return this.length*this.scale/this.sample_rate},get pixels_per_second(){return this.sample_rate/this.scale},get seconds_per_pixel(){return this.scale/this.sample_rate},get channels(){return this._version()===2?this._data.getInt32(20,!0):1},channel:function(t){if(t>=0&&t<this._channels.length)return this._channels[t];throw new RangeError("Invalid channel: "+t)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(t){return this.bits===8?this._data.getInt8(this._offset+t):this._data.getInt16(this._offset+t*2,!0)},_set_at:function(t,n){return this.bits===8?this._data.setInt8(this._offset+t,n):this._data.setInt16(this._offset+t*2,n,!0)},at_time:function(t){return Math.floor(t*this.sample_rate/this.scale)},time:function(t){return t*this.scale/this.sample_rate},toJSON:function(){for(var t={version:2,channels:this.channels,sample_rate:this.sample_rate,samples_per_pixel:this.scale,bits:this.bits,length:this.length,data:[]},n=0;n<this.length;n++)for(var r=0;r<this.channels;r++)t.data.push(this.channel(r).min_sample(n)),t.data.push(this.channel(r).max_sample(n));return t},toArrayBuffer:function(){return this._data.buffer}};async function Bn(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch waveform data: ${t.statusText}`);if(e.endsWith(".dat")){const r=await t.arrayBuffer();return Oe.create(r)}else{const r=await t.json();return Oe.create(r)}}function na(e,t=0){const n=e.channel(t),r=e.bits,a=n.min_array(),s=n.max_array(),o=a.length,l=r===8?new Int8Array(o*2):new Int16Array(o*2);for(let i=0;i<o;i++)l[i*2]=a[i],l[i*2+1]=s[i];return{data:l,bits:r,length:o,sampleRate:e.sample_rate}}async function As(e,t=0){const n=await Bn(e);return na(n,t)}async function ks(e){const t=await Bn(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function $s(e,t,n=0,r,a){let s=e;if(r!==void 0&&a!==void 0){const p=e.scale,f=Math.floor(r/p),C=Math.ceil((r+a)/p);s=s.slice({startIndex:f,endIndex:C})}s.scale!==t&&(s=s.resample({scale:t}));const o=s.channel(n),l=s.bits,i=o.min_array(),u=o.max_array(),d=i.length,b=l===8?new Int8Array(d*2):new Int16Array(d*2);for(let p=0;p<d;p++)b[p*2]=i[p],b[p*2+1]=u[p];return{data:b,bits:l,length:d}}var fr;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(fr||(fr={}));function mr(){}const Rs=Object.freeze({x:0,y:0});var xt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(xt||(xt={}));var hr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(hr||(hr={}));var ut;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(ut||(ut={}));ut.Space,ut.Enter,ut.Esc,ut.Space,ut.Enter,ut.Tab;var pr;(function(e){e[e.RightClick=2]="RightClick"})(pr||(pr={}));var gr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(gr||(gr={}));var br;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(br||(br={}));xt.Backward+"",xt.Forward+"",xt.Backward+"",xt.Forward+"";var yn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(yn||(yn={}));var In;(function(e){e.Optimized="optimized"})(In||(In={}));function Es(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:a,handler:s}=r;return n[a]=o=>{s(o,t)},n},{}),[e,t])}yn.WhileDragging,In.Optimized;const Ds={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:mr,draggableNodes:new Map,over:null,measureDroppableContainers:mr},Ts=c.createContext(Ds),_s=c.createContext({...Rs,scaleX:1,scaleY:1});var vr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(vr||(vr={}));const Ms=c.createContext(null),Cr="button",Bs="Draggable";function wr(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=Vr(Bs),{activators:o,activatorEvent:l,active:i,activeNodeRect:u,ariaDescribedById:d,draggableNodes:b,over:p}=c.useContext(Ts),{role:f=Cr,roleDescription:C="draggable",tabIndex:y=0}=a??{},g=i?.id===t,m=c.useContext(g?_s:Ms),[w,x]=Ht(),[v,S]=Ht(),I=Es(o,t),$=Pr(n);Ut(()=>(b.set(t,{id:t,key:s,node:w,activatorNode:v,data:$}),()=>{const T=b.get(t);T&&T.key===s&&b.delete(t)}),[b,t]);const M=c.useMemo(()=>({role:f,tabIndex:y,"aria-disabled":r,"aria-pressed":g&&f===Cr?!0:void 0,"aria-roledescription":C,"aria-describedby":d.draggable}),[r,f,y,g,C,d.draggable]);return{active:i,activatorEvent:l,activeNodeRect:u,attributes:M,isDragging:g,listeners:r?void 0:I,node:w,over:p,setNodeRef:x,setActivatorNodeRef:S,transform:m}}function Fs(e){return{id:e.id,start:parseFloat(e.begin),end:parseFloat(e.end),lines:e.lines,lang:e.language}}function Ws(e){return{id:e.id,begin:e.start.toFixed(3),end:e.end.toFixed(3),lines:e.lines,language:e.lang||"en"}}k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
766
767
  position: absolute;
767
768
  top: 0;
768
769
  background: ${e=>e.$color};
@@ -847,12 +848,12 @@ React keys must be passed directly to JSX without using spread:
847
848
  &:active {
848
849
  background: rgba(255, 255, 255, 0.3);
849
850
  }
850
- `;var bs=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
851
+ `;var Zs=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
851
852
  position: absolute;
852
853
  top: 0;
853
854
  height: 100%;
854
855
  pointer-events: none; /* Let events pass through to children */
855
- `,vs=k.div`
856
+ `,Ps=k.div`
856
857
  position: absolute;
857
858
  top: 0;
858
859
  left: 0;
@@ -876,7 +877,7 @@ React keys must be passed directly to JSX without using spread:
876
877
  border-width: 3px;
877
878
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
878
879
  }
879
- `,Cs=k.span`
880
+ `,Vs=k.span`
880
881
  font-size: 12px;
881
882
  font-weight: 600;
882
883
  color: ${e=>e.theme?.annotationLabelColor||"#2a2a2a"};
@@ -886,7 +887,7 @@ React keys must be passed directly to JSX without using spread:
886
887
  padding: 0 6px;
887
888
  letter-spacing: 0.3px;
888
889
  user-select: none;
889
- `,wr=k.div`
890
+ `,xr=k.div`
890
891
  position: absolute;
891
892
  top: 0;
892
893
  ${e=>e.$position==="left"?"left: -8px":"right: -8px"};
@@ -921,13 +922,13 @@ React keys must be passed directly to JSX without using spread:
921
922
  opacity: 1;
922
923
  background: ${e=>e.theme?.annotationResizeHandleActiveColor||"rgba(0, 0, 0, 0.7)"};
923
924
  }
924
- `,xs=({annotationId:e,annotationIndex:t,startPosition:n,endPosition:r,label:a,color:s="#ff9800",isActive:o=!1,onClick:i,editable:l=!0})=>{const u=Math.max(0,r-n),d=`annotation-boundary-start-${t}`,{attributes:b,listeners:p,setActivatorNodeRef:f,isDragging:x}=xr({id:d,data:{annotationId:e,annotationIndex:t,edge:"start"},disabled:!l}),y=`annotation-boundary-end-${t}`,{attributes:v,listeners:m,setActivatorNodeRef:C,isDragging:w}=xr({id:y,data:{annotationId:e,annotationIndex:t,edge:"end"},disabled:!l});if(u<=0)return null;const g=I=>E=>{E.stopPropagation(),I?.(E)},S=I=>{I.stopPropagation()};return R.jsxs(bs,{$left:n,$width:u,children:[R.jsx(vs,{$color:s,$isActive:o,onClick:i,children:a&&R.jsx(Cs,{children:a})}),l&&R.jsx(wr,{ref:f,$position:"left",$isDragging:x,onClick:S,...p,onPointerDown:g(p?.onPointerDown),...b}),l&&R.jsx(wr,{ref:C,$position:"right",$isDragging:w,onClick:S,...m,onPointerDown:g(m?.onPointerDown),...v})]})},ws=k.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
925
+ `,js=({annotationId:e,annotationIndex:t,startPosition:n,endPosition:r,label:a,color:s="#ff9800",isActive:o=!1,onClick:l,editable:i=!0})=>{const u=Math.max(0,r-n),d=`annotation-boundary-start-${t}`,{attributes:b,listeners:p,setActivatorNodeRef:f,isDragging:C}=wr({id:d,data:{annotationId:e,annotationIndex:t,edge:"start"},disabled:!i}),y=`annotation-boundary-end-${t}`,{attributes:g,listeners:m,setActivatorNodeRef:w,isDragging:x}=wr({id:y,data:{annotationId:e,annotationIndex:t,edge:"end"},disabled:!i});if(u<=0)return null;const v=I=>$=>{$.stopPropagation(),I?.($)},S=I=>{I.stopPropagation()};return E.jsxs(Zs,{$left:n,$width:u,children:[E.jsx(Ps,{$color:s,$isActive:o,onClick:l,children:a&&E.jsx(Vs,{children:a})}),i&&E.jsx(xr,{ref:f,$position:"left",$isDragging:C,onClick:S,...p,onPointerDown:v(p?.onPointerDown),...b}),i&&E.jsx(xr,{ref:w,$position:"right",$isDragging:x,onClick:S,...m,onPointerDown:v(m?.onPointerDown),...g})]})},zs=k.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
925
926
  position: relative;
926
927
  display: flex;
927
928
  ${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
928
929
  background: transparent;
929
930
  z-index: 110;
930
- `,ys=k.div`
931
+ `,Os=k.div`
931
932
  position: sticky;
932
933
  z-index: 200;
933
934
  left: 0;
@@ -935,11 +936,11 @@ React keys must be passed directly to JSX without using spread:
935
936
  width: ${e=>e.$controlWidth}px;
936
937
  flex-shrink: 0;
937
938
  background: transparent;
938
- `,Is=k.div`
939
+ `,Ns=k.div`
939
940
  position: relative;
940
941
  flex: 1;
941
942
  padding-left: ${e=>e.$offset||0}px;
942
- `,Ss=({children:e,className:t,height:n=30,offset:r=0,width:a})=>{const{controls:{show:s,width:o}}=Qt();return R.jsxs(ws,{className:t,$height:n,$controlWidth:s?o:0,$width:a,children:[R.jsx(ys,{$controlWidth:s?o:0}),R.jsx(Is,{$offset:r,children:e})]})};k.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
943
+ `,Ls=({children:e,className:t,height:n=30,offset:r=0,width:a})=>{const{controls:{show:s,width:o}}=en();return E.jsxs(zs,{className:t,$height:n,$controlWidth:s?o:0,$width:a,children:[E.jsx(Os,{$controlWidth:s?o:0}),E.jsx(Ns,{$offset:r,children:e})]})};k.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
943
944
  position: relative;
944
945
  display: flex;
945
946
  ${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
@@ -962,12 +963,12 @@ React keys must be passed directly to JSX without using spread:
962
963
  position: relative;
963
964
  flex: 1;
964
965
  padding-left: ${e=>e.$offset||0}px;
965
- `;var As=k.div`
966
+ `;var Xs=k.div`
966
967
  background: ${e=>e.theme?.backgroundColor||"#fff"};
967
968
  ${e=>e.$height?`height: ${e.$height}px;`:"max-height: 200px;"}
968
969
  overflow-y: auto;
969
970
  padding: 8px;
970
- `,ks=k.div`
971
+ `,Hs=k.div`
971
972
  padding: 12px;
972
973
  margin-bottom: 6px;
973
974
  border-left: 4px solid ${e=>e.$isActive?"#ff9800":"transparent"};
@@ -986,16 +987,16 @@ React keys must be passed directly to JSX without using spread:
986
987
  outline: 2px solid #ff9800;
987
988
  outline-offset: 2px;
988
989
  }
989
- `,$s=k.div`
990
+ `,Gs=k.div`
990
991
  display: flex;
991
992
  justify-content: space-between;
992
993
  align-items: center;
993
994
  margin-bottom: 6px;
994
- `,Rs=k.div`
995
+ `,Ys=k.div`
995
996
  display: flex;
996
997
  align-items: center;
997
998
  gap: 8px;
998
- `,Es=k.span`
999
+ `,Ks=k.span`
999
1000
  font-size: 11px;
1000
1001
  font-weight: 600;
1001
1002
  color: ${e=>e.theme?.textColorMuted||"#666"};
@@ -1009,16 +1010,16 @@ React keys must be passed directly to JSX without using spread:
1009
1010
  outline: 2px solid #ff9800;
1010
1011
  background: rgba(255, 152, 0, 0.1);
1011
1012
  }
1012
- `,Ts=k.span`
1013
+ `,Us=k.span`
1013
1014
  font-size: 12px;
1014
1015
  font-weight: 500;
1015
1016
  color: ${e=>e.theme?.textColorMuted||"#555"};
1016
1017
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
1017
1018
  letter-spacing: 0.5px;
1018
- `,Ds=k.div`
1019
+ `,Js=k.div`
1019
1020
  display: flex;
1020
1021
  gap: 6px;
1021
- `,_s=k.button`
1022
+ `,qs=k.button`
1022
1023
  background: ${e=>e.theme?.surfaceColor||"#f5f5f5"};
1023
1024
  border: 1px solid ${e=>e.theme?.borderColor||"#ccc"};
1024
1025
  color: ${e=>e.theme?.textColor||"#333"};
@@ -1037,7 +1038,7 @@ React keys must be passed directly to JSX without using spread:
1037
1038
  &:active {
1038
1039
  transform: scale(0.95);
1039
1040
  }
1040
- `,Ms=k.div`
1041
+ `,Qs=k.div`
1041
1042
  font-size: 14px;
1042
1043
  line-height: 1.6;
1043
1044
  color: ${e=>e.theme?.textColor||"#2a2a2a"};
@@ -1052,9 +1053,9 @@ React keys must be passed directly to JSX without using spread:
1052
1053
  outline: 2px solid #ff9800;
1053
1054
  background: rgba(255, 152, 0, 0.1);
1054
1055
  }
1055
- `,Bs=({annotations:e,activeAnnotationId:t,shouldScrollToActive:n=!1,editable:r=!1,controls:a=[],annotationListConfig:s,height:o,onAnnotationClick:i,onAnnotationUpdate:l})=>{const u=c.useRef(null),d=c.useRef(null),b=c.useRef(void 0);c.useEffect(()=>{}),c.useEffect(()=>{const m=d.current;if(!m)return;const C=()=>{};return m.addEventListener("scroll",C),()=>m.removeEventListener("scroll",C)},[]),c.useEffect(()=>{t&&u.current&&n&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"}),b.current=t},[t,n]);const p=m=>{if(isNaN(m)||!isFinite(m))return"0:00.000";const C=Math.floor(m/60),w=(m%60).toFixed(3);return`${C}:${w.padStart(6,"0")}`},f=(m,C)=>{if(!r||!l)return;const w=[...e];w[m]={...w[m],lines:C.split(`
1056
- `)},l(w)},x=(m,C)=>{if(!r||!l)return;const w=C.trim();if(!w)return;const g=[...e];g[m]={...g[m],id:w},l(g)},y=(m,C,w)=>{if(!l)return;const g=[...e];m.action(g[w],w,g,s||{}),l(g)},v=m=>m.replace(/\./g," ");return R.jsx(As,{ref:d,$height:o,children:e.map((m,C)=>{const w=m.id===t;return R.jsxs(ks,{ref:w?u:null,$isActive:w,onClick:()=>i?.(m),children:[R.jsxs($s,{children:[R.jsxs(Rs,{children:[R.jsx(Es,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:g=>x(C,g.currentTarget.textContent||""),children:m.id}),R.jsxs(Ts,{children:[p(m.start)," - ",p(m.end)]})]}),a.length>0&&R.jsx(Ds,{onClick:g=>g.stopPropagation(),children:a.map((g,S)=>R.jsx(_s,{title:g.title,onClick:()=>y(g,m,C),children:g.text?g.text:R.jsx("i",{className:v(g.class||"")})},S))})]}),R.jsx(Ms,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:g=>f(C,g.currentTarget.textContent||""),children:m.lines.join(`
1057
- `)})]},m.id)})})},Fs=c.memo(Bs),Ws=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return R.jsxs(Ut,{className:r,children:[R.jsx(Jt,{type:"checkbox",id:"continuous-play",className:"continuous-play",checked:e,onChange:a,disabled:n}),R.jsx(qt,{htmlFor:"continuous-play",children:"Continuous Play"})]})},Zs=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return R.jsxs(Ut,{className:r,children:[R.jsx(Jt,{type:"checkbox",id:"link-endpoints",className:"link-endpoints",checked:e,onChange:a,disabled:n}),R.jsx(qt,{htmlFor:"link-endpoints",children:"Link Endpoints"})]})},Ps=({checked:e,onChange:t,className:n})=>R.jsxs(Ut,{className:n,children:[R.jsx(Jt,{type:"checkbox",id:"editable-annotations",checked:e,onChange:r=>t(r.target.checked)}),R.jsx(qt,{htmlFor:"editable-annotations",children:"Editable Annotations"})]}),Vs=k.button`
1056
+ `,ei=({annotations:e,activeAnnotationId:t,shouldScrollToActive:n=!1,editable:r=!1,controls:a=[],annotationListConfig:s,height:o,onAnnotationClick:l,onAnnotationUpdate:i})=>{const u=c.useRef(null),d=c.useRef(null),b=c.useRef(void 0);c.useEffect(()=>{}),c.useEffect(()=>{const m=d.current;if(!m)return;const w=()=>{};return m.addEventListener("scroll",w),()=>m.removeEventListener("scroll",w)},[]),c.useEffect(()=>{t&&u.current&&n&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"}),b.current=t},[t,n]);const p=m=>{if(isNaN(m)||!isFinite(m))return"0:00.000";const w=Math.floor(m/60),x=(m%60).toFixed(3);return`${w}:${x.padStart(6,"0")}`},f=(m,w)=>{if(!r||!i)return;const x=[...e];x[m]={...x[m],lines:w.split(`
1057
+ `)},i(x)},C=(m,w)=>{if(!r||!i)return;const x=w.trim();if(!x)return;const v=[...e];v[m]={...v[m],id:x},i(v)},y=(m,w,x)=>{if(!i)return;const v=[...e];m.action(v[x],x,v,s||{}),i(v)},g=m=>m.replace(/\./g," ");return E.jsx(Xs,{ref:d,$height:o,children:e.map((m,w)=>{const x=m.id===t;return E.jsxs(Hs,{ref:x?u:null,$isActive:x,onClick:()=>l?.(m),children:[E.jsxs(Gs,{children:[E.jsxs(Ys,{children:[E.jsx(Ks,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:v=>C(w,v.currentTarget.textContent||""),children:m.id}),E.jsxs(Us,{children:[p(m.start)," - ",p(m.end)]})]}),a.length>0&&E.jsx(Js,{onClick:v=>v.stopPropagation(),children:a.map((v,S)=>E.jsx(qs,{title:v.title,onClick:()=>y(v,m,w),children:v.text?v.text:E.jsx("i",{className:g(v.class||"")})},S))})]}),E.jsx(Qs,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:v=>f(w,v.currentTarget.textContent||""),children:m.lines.join(`
1058
+ `)})]},m.id)})})},ti=c.memo(ei),ni=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return E.jsxs(Jt,{className:r,children:[E.jsx(qt,{type:"checkbox",id:"continuous-play",className:"continuous-play",checked:e,onChange:a,disabled:n}),E.jsx(Qt,{htmlFor:"continuous-play",children:"Continuous Play"})]})},ri=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return E.jsxs(Jt,{className:r,children:[E.jsx(qt,{type:"checkbox",id:"link-endpoints",className:"link-endpoints",checked:e,onChange:a,disabled:n}),E.jsx(Qt,{htmlFor:"link-endpoints",children:"Link Endpoints"})]})},ai=({checked:e,onChange:t,className:n})=>E.jsxs(Jt,{className:n,children:[E.jsx(qt,{type:"checkbox",id:"editable-annotations",checked:e,onChange:r=>t(r.target.checked)}),E.jsx(Qt,{htmlFor:"editable-annotations",children:"Editable Annotations"})]}),oi=k.button`
1058
1059
  padding: 0.5rem 1rem;
1059
1060
  background: ${e=>e.theme?.surfaceColor||"#f5f5f5"};
1060
1061
  color: ${e=>e.theme?.textColor||"#333"};
@@ -1080,7 +1081,7 @@ React keys must be passed directly to JSX without using spread:
1080
1081
  opacity: 0.6;
1081
1082
  cursor: not-allowed;
1082
1083
  }
1083
- `,js=({annotations:e,filename:t="annotations.json",disabled:n=!1,className:r,children:a="Download JSON"})=>{const s=()=>{if(e.length===0)return;const o=e.map(b=>gs(b)),i=JSON.stringify(o,null,2),l=new Blob([i],{type:"application/json"}),u=URL.createObjectURL(l),d=document.createElement("a");d.href=u,d.download=t,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(u)};return R.jsx(Vs,{onClick:s,disabled:n||e.length===0,className:r,title:e.length===0?"No annotations to download":"Download the annotations as JSON",children:a})};function ta(){const[e,t]=c.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:a=>It(a,e),parseTime:a=>Ur(a,e)}}const zs=[256,512,1024,2048,4096,8192];function na({initialSamplesPerPixel:e,zoomLevels:t=zs}){const[n,r]=c.useState(()=>{const u=t.indexOf(e);return u!==-1?u:Math.floor(t.length/2)}),a=t[n],s=n>0,o=n<t.length-1,i=c.useCallback(()=>{r(u=>Math.max(0,u-1))},[]),l=c.useCallback(()=>{r(u=>Math.min(t.length-1,u+1))},[t.length]);return{samplesPerPixel:a,zoomIn:i,zoomOut:l,canZoomIn:s,canZoomOut:o}}function ra({playoutRef:e,initialVolume:t=1,onVolumeChange:n}){const[r,a]=c.useState(t),s=c.useCallback(o=>{a(o),e.current&&e.current.setMasterGain(o),n?.(o)},[e,n]);return{masterVolume:r,setMasterVolume:s}}const Os=(e=256)=>{const t=c.useRef(null),n=c.useCallback((r,a,s)=>{const o=new P.Analyser("fft",e);return r.connect(o),r.connect(a),t.current=o,function(){o.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:n}};function Sn(e){const{audioBuffer:t,startSample:n,durationSamples:r=t.length,offsetSamples:a=0,gain:s=1,name:o,color:i,fadeIn:l,fadeOut:u}=e;return{id:aa(),audioBuffer:t,startSample:n,durationSamples:r,offsetSamples:a,gain:s,name:o,color:i,fadeIn:l,fadeOut:u}}function Ns(e){const{audioBuffer:t,startTime:n,duration:r=t.duration,offset:a=0,gain:s=1,name:o,color:i,fadeIn:l,fadeOut:u}=e,d=t.sampleRate;return Sn({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(r*d),offsetSamples:Math.round(a*d),gain:s,name:o,color:i,fadeIn:l,fadeOut:u})}function Ls(e){const{name:t,clips:n=[],muted:r=!1,soloed:a=!1,volume:s=1,pan:o=0,color:i,height:l}=e;return{id:aa(),name:t,clips:n,muted:r,soloed:a,volume:s,pan:o,color:i,height:l}}function aa(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function Xs(e){const[t,n]=c.useState([]),[r,a]=c.useState(!0),[s,o]=c.useState(null);return c.useEffect(()=>{if(e.length===0){n([]),a(!1);return}let i=!1;return(async()=>{try{a(!0),o(null);const u=Wr.getContext().rawContext,d=e.map(async(p,f)=>{const x=await fetch(p.src);if(!x.ok)throw new Error(`Failed to fetch ${p.src}: ${x.statusText}`);const y=await x.arrayBuffer(),v=await u.decodeAudioData(y);if(!v||!v.sampleRate||!v.duration)throw new Error(`Invalid audio buffer for ${p.src}`);const m=p.duration??v.duration,C=Ns({audioBuffer:v,startTime:p.startTime??0,duration:m,offset:p.offset??0,name:p.name||`Track ${f+1}`,fadeIn:p.fadeIn,fadeOut:p.fadeOut});if(isNaN(C.startSample)||isNaN(C.durationSamples)||isNaN(C.offsetSamples))throw console.error("Invalid clip values:",C),new Error(`Invalid clip values for ${p.src}`);return{...Ls({name:p.name||`Track ${f+1}`,clips:[C],muted:p.muted??!1,soloed:p.soloed??!1,volume:p.volume??1,pan:p.pan??0,color:p.color}),effects:p.effects}}),b=await Promise.all(d);i||(n(b),a(!1))}catch(u){if(!i){const d=u instanceof Error?u.message:"Unknown error loading audio";o(d),a(!1),console.error("Error loading audio tracks:",u)}}})(),()=>{i=!0}},[e]),{tracks:t,loading:r,error:s}}function Hs({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r}){const a=c.useRef(null),s=c.useCallback(u=>{const{transform:d,active:b}=u;if(!b?.data?.current)return{...d,scaleX:1,scaleY:1};const{trackIndex:p,clipIndex:f,boundary:x}=b.data.current;if(x)return{...d,scaleX:1,scaleY:1};const y=e[p];if(!y)return{...d,scaleX:1,scaleY:1};const v=y.clips[f];if(!v)return{...d,scaleX:1,scaleY:1};const m=v.startSample/r,C=v.durationSamples/r,w=d.x*n/r;let g=m+w;const S=[...y.clips].sort((T,V)=>T.startSample-V.startSample),I=S.findIndex(T=>T===v);g=Math.max(0,g);const E=I>0?S[I-1]:null;if(E){const T=(E.startSample+E.durationSamples)/r;g=Math.max(g,T)}const D=I<S.length-1?S[I+1]:null;if(D){const T=g+C,V=D.startSample/r;T>V&&(g=V-C)}const B=(g-m)*r/n;return{...d,x:B,scaleX:1,scaleY:1}},[e,n,r]),o=c.useCallback(u=>{const{active:d}=u,{boundary:b}=d.data.current;if(!b){a.current=null;return}const{trackIndex:p,clipIndex:f}=d.data.current,y=e[p]?.clips[f];y&&(a.current={offsetSamples:y.offsetSamples,durationSamples:y.durationSamples,startSample:y.startSample})},[e]),i=c.useCallback(u=>{const{active:d,delta:b}=u,{boundary:p}=d.data.current;if(!p||!a.current)return;const{trackIndex:f,clipIndex:x}=d.data.current,y=b.x*n,v=Math.floor(.1*r),m=a.current,C=e.map((w,g)=>{if(g!==f)return w;const S=[...w.clips].sort((D,_)=>D.startSample-_.startSample),I=S.findIndex(D=>D===w.clips[x]),E=w.clips.map((D,_)=>{if(_!==x)return D;const B=Math.floor(D.audioBuffer.duration*r);if(p==="left"){let T=Math.floor(y);const V=-m.startSample;T<V&&(T=V);const W=-m.offsetSamples;T<W&&(T=W);const O=I>0?S[I-1]:null;if(O){const oe=O.startSample+O.durationSamples-m.startSample;T<oe&&(T=oe)}const X=m.durationSamples-v;T>X&&(T=X);const G=m.offsetSamples+T,Q=m.durationSamples-T,ne=m.startSample+T;return{...D,offsetSamples:G,durationSamples:Q,startSample:ne}}else{let T=Math.floor(m.durationSamples+y);T=Math.max(v,T),m.offsetSamples+T>B&&(T=B-m.offsetSamples);const V=I<S.length-1?S[I+1]:null;return V&&m.startSample+T>V.startSample&&(T=V.startSample-m.startSample,T=Math.max(v,T)),{...D,durationSamples:T}}});return{...w,clips:E}});t(C)},[e,t,n,r]),l=c.useCallback(u=>{const{active:d,delta:b}=u,{trackIndex:p,clipIndex:f,boundary:x}=d.data.current,y=b.x*n;if(x){a.current=null;return}const v=e.map((m,C)=>{if(C!==p)return m;const w=[...m.clips].sort((I,E)=>I.startSample-E.startSample),g=w.findIndex(I=>I===m.clips[f]),S=m.clips.map((I,E)=>{if(E!==f)return I;let D=Math.floor(I.startSample+y);D=Math.max(0,D);const _=g>0?w[g-1]:null;if(_){const T=_.startSample+_.durationSamples;D=Math.max(D,T)}const B=g<w.length-1?w[g+1]:null;return B&&D+I.durationSamples>B.startSample&&(D=B.startSample-I.durationSamples),{...I,startSample:D}});return{...m,clips:S}});t(v)},[e,t,n,r]);return{onDragStart:o,onDragMove:i,onDragEnd:l,collisionModifier:s}}const hn=.01;function Gs({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:a,linkEndpoints:s}){const o=c.useRef(null),i=c.useCallback(d=>{const{active:b}=d,p=b.data.current;if(!p||p.annotationIndex===void 0){o.current=null;return}const f=e[p.annotationIndex];f&&(o.current={start:f.start,end:f.end,annotationIndex:p.annotationIndex})},[e]),l=c.useCallback(d=>{const{active:b,delta:p}=d;if(!o.current)return;const f=b.data.current;if(!f)return;const{edge:x,annotationIndex:y}=f,v=o.current,m=p.x*n/r,C=x==="start"?v.start+m:v.end+m,w=Ys({annotationIndex:y,newTime:C,isDraggingStart:x==="start",annotations:e,duration:a,linkEndpoints:s});t(w)},[e,t,n,r,a,s]),u=c.useCallback(()=>{o.current=null},[]);return{onDragStart:i,onDragMove:l,onDragEnd:u}}function Ys({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:a,linkEndpoints:s}){const o=[...r],i=r[e];if(n){const l=Math.min(i.end-.1,Math.max(0,t)),u=l-i.start;if(o[e]={...i,start:l},s&&e>0){const d=o[e-1];Math.abs(d.end-i.start)<hn?o[e-1]={...d,end:Math.max(d.start+.1,d.end+u)}:l<=d.end&&(o[e]={...o[e],start:d.end})}else!s&&e>0&&l<o[e-1].end&&(o[e-1]={...o[e-1],end:l})}else{const l=Math.max(i.start+.1,Math.min(t,a)),u=l-i.end;if(o[e]={...i,end:l},s&&e<o.length-1){const d=o[e+1];if(Math.abs(d.start-i.end)<hn){const b=d.start+u;o[e+1]={...d,start:Math.min(d.end-.1,b)};let p=e+1;for(;p<o.length-1;){const f=o[p],x=o[p+1];if(Math.abs(x.start-f.end)<hn){const y=f.end-r[p].end;o[p+1]={...x,start:Math.min(x.end-.1,x.start+y)},p++}else break}}else l>=d.start&&(o[e]={...o[e],end:d.start})}else if(!s&&e<o.length-1&&l>o[e+1].start){const d=o[e+1];o[e+1]={...d,start:l};let b=e+1;for(;b<o.length-1;){const p=o[b],f=o[b+1];if(p.end>f.start)o[b+1]={...f,start:p.end},b++;else break}}}return o}function Bn(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function oa(e){return"nodeType"in e}function St(e){var t,n;return e?Bn(e)?e:oa(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Ks(e){const{Document:t}=St(e);return e instanceof t}function Us(e){return Bn(e)?!1:e instanceof St(e).HTMLElement}function Js(e){return e instanceof St(e).SVGElement}function en(e){return e?Bn(e)?e.document:oa(e)?Ks(e)?e:Us(e)||Js(e)?e.ownerDocument:document:document:document}function qs(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((s,o)=>{const i=Object.entries(o);for(const[l,u]of i){const d=s[l];d!=null&&(s[l]=d+e*u)}return s},{...t})}}const Qs=qs(-1);function ei(e){return"clientX"in e&&"clientY"in e}function ti(e){if(!e)return!1;const{TouchEvent:t}=St(e.target);return t&&e instanceof t}function yr(e){if(ti(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return ei(e)?{x:e.clientX,y:e.clientY}:null}var Ir;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Ir||(Ir={}));function mn(e,t){return c.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function ni(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const An=Object.freeze({x:0,y:0});var yt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(yt||(yt={}));class pn{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var a;(a=this.target)==null||a.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function ri(e){const{EventTarget:t}=St(e);return e instanceof t?e:en(e)}function gn(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var tt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(tt||(tt={}));function Sr(e){e.preventDefault()}function ai(e){e.stopPropagation()}var nt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(nt||(nt={}));nt.Space,nt.Enter,nt.Esc,nt.Space,nt.Enter,nt.Tab;function Ar(e){return!!(e&&"distance"in e)}function kr(e){return!!(e&&"delay"in e)}class Fn{constructor(t,n,r){var a;r===void 0&&(r=ri(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:s}=t,{target:o}=s;this.props=t,this.events=n,this.document=en(o),this.documentListeners=new pn(this.document),this.listeners=new pn(r),this.windowListeners=new pn(St(o)),this.initialCoordinates=(a=yr(s))!=null?a:An,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(tt.Resize,this.handleCancel),this.windowListeners.add(tt.DragStart,Sr),this.windowListeners.add(tt.VisibilityChange,this.handleCancel),this.windowListeners.add(tt.ContextMenu,Sr),this.documentListeners.add(tt.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(kr(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Ar(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:a}=this.props;a(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(tt.Click,ai,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(tt.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:a,props:s}=this,{onMove:o,options:{activationConstraint:i}}=s;if(!a)return;const l=(n=yr(t))!=null?n:An,u=Qs(a,l);if(!r&&i){if(Ar(i)){if(i.tolerance!=null&&gn(u,i.tolerance))return this.handleCancel();if(gn(u,i.distance))return this.handleStart()}if(kr(i)&&gn(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}t.cancelable&&t.preventDefault(),o(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===nt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const oi={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class sa extends Fn{constructor(t){const{event:n}=t,r=en(n.target);super(t,oi,r)}}sa.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const si={move:{name:"mousemove"},end:{name:"mouseup"}};var kn;(function(e){e[e.RightClick=2]="RightClick"})(kn||(kn={}));class ia extends Fn{constructor(t){super(t,si,en(t.event.target))}}ia.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===kn.RightClick?!1:(r?.({event:n}),!0)}}];const bn={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class la extends Fn{constructor(t){super(t,bn)}static setup(){return window.addEventListener(bn.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(bn.move.name,t)};function t(){}}}la.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:a}=n;return a.length>1?!1:(r?.({event:n}),!0)}}];var $r;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})($r||($r={}));var Rr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Rr||(Rr={}));yt.Backward+"",yt.Forward+"",yt.Backward+"",yt.Forward+"";var $n;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})($n||($n={}));var Rn;(function(e){e.Optimized="optimized"})(Rn||(Rn={}));$n.WhileDragging,Rn.Optimized;({...An});var Er;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Er||(Er={}));function ii(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:a=1}=e,s=mn(ia,{activationConstraint:{distance:a}}),o=mn(la,{activationConstraint:t?{delay:n,tolerance:r}:{distance:a}}),i=mn(sa,{activationConstraint:{distance:a}});return ni(...t?[s,o]:[i])}const li=e=>{const{tracks:t,onTracksChange:n,sampleRate:r}=e,{currentTimeRef:a}=We(),{selectedTrackId:s}=Ne(),o=c.useCallback((l,u,d)=>{const{sampleRate:b,samplesPerPixel:p}=e,f=t[l];if(!f)return!1;const x=f.clips[u];if(!x)return!1;const y=x.startSample/b,v=(x.startSample+x.durationSamples)/b;if(d<=y||d>=v)return console.warn("Split time is outside clip bounds"),!1;const m=Math.round(d*b),C=Math.floor(m/p),w=x.startSample+x.durationSamples,g=C*p,S=x.startSample,I=g-S,E=g,D=w-E,_=g-x.startSample,B=Sn({audioBuffer:x.audioBuffer,startSample:S,durationSamples:I,offsetSamples:x.offsetSamples,gain:x.gain,name:x.name?`${x.name} (1)`:void 0,color:x.color,fadeIn:x.fadeIn}),T=Sn({audioBuffer:x.audioBuffer,startSample:E,durationSamples:D,offsetSamples:x.offsetSamples+_,gain:x.gain,name:x.name?`${x.name} (2)`:void 0,color:x.color,fadeOut:x.fadeOut}),V=[...f.clips];V.splice(u,1,B,T);const W=[...t];return W[l]={...f,clips:V},n(W),!0},[t,n,e]);return{splitClipAtPlayhead:c.useCallback(()=>{if(!s)return console.log("No track selected - click a clip to select a track first"),!1;const l=t.findIndex(b=>b.id===s);if(l===-1)return console.warn("Selected track not found"),!1;const u=t[l],d=a.current??0;for(let b=0;b<u.clips.length;b++){const p=u.clips[b],f=p.startSample/r,x=(p.startSample+p.durationSamples)/r;if(d>f&&d<x)return console.log(`Splitting clip on track "${u.name}" at ${d}s`),o(l,b,d)}return console.log(`No clip found at playhead position on track "${u.name}"`),!1},[t,a,s,o,r]),splitClipAt:o}},Gt=e=>{const{shortcuts:t,enabled:n=!0}=e,r=c.useCallback(a=>{if(!n)return;const s=a.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const o=t.find(i=>{const l=a.key.toLowerCase()===i.key.toLowerCase()||a.key===i.key,u=i.ctrlKey===void 0||a.ctrlKey===i.ctrlKey,d=i.shiftKey===void 0||a.shiftKey===i.shiftKey,b=i.metaKey===void 0||a.metaKey===i.metaKey,p=i.altKey===void 0||a.altKey===i.altKey;return l&&u&&d&&b&&p});o&&(o.preventDefault!==!1&&a.preventDefault(),o.action())},[t,n]);c.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},ci=e=>{const t=[],n=typeof navigator<"u"&&navigator.platform.includes("Mac");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("+")},ui=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:a}=We(),{setCurrentTime:s,play:o,pause:i,stop:l}=xe(),{playoutRef:u}=Te(),d=c.useCallback(()=>{a?i():o()},[a,o,i]),b=c.useCallback(()=>{l()},[l]),p=c.useCallback(()=>{a&&u.current?(u.current.stop(),s(0),o(0)):s(0)},[a,u,s,o]),x=r??[...[{key:" ",action:d,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:b,description:"Stop",preventDefault:!0},{key:"0",action:p,description:"Rewind to start",preventDefault:!0}],...n];return Gt({shortcuts:x,enabled:t}),{rewindToStart:p,togglePlayPause:d,stopPlayback:b,shortcuts:x}},vn=.01,Ot=.01;function di({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:a,linkEndpoints:s,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:u,sampleRate:d,controlsWidth:b=0,onPlay:p}){const f=c.useMemo(()=>t?e.findIndex(_=>_.id===t):-1,[e,t]),x=c.useCallback(_=>{if(!l?.current||!u||!d)return;const B=e.find(L=>L.id===_);if(!B)return;const T=l.current,V=T.clientWidth,W=B.start*d/u+b,O=B.end*d/u+b,X=(W+O)/2,G=T.scrollLeft,Q=G,ne=G+V;if(W<Q||O>ne){const L=Math.max(0,X-V/2);T.scrollTo({left:L,behavior:"smooth"})}},[e,l,u,d,b]);c.useEffect(()=>{t&&l?.current&&u&&d&&x(t)},[t,x,l,u,d]);const y=c.useCallback(_=>{if(f<0)return;const B=e[f],T=Math.max(0,Math.min(B.end-.1,B.start+_)),V=T-B.start,W=[...e];if(W[f]={...B,start:T},s&&f>0){const O=W[f-1];Math.abs(O.end-B.start)<vn&&(W[f-1]={...O,end:Math.max(O.start+.1,O.end+V)})}else if(!s&&f>0){const O=W[f-1];T<O.end&&(W[f-1]={...O,end:T})}n(W)},[e,f,s,n]),v=c.useCallback(_=>{if(f<0)return;const B=e[f],T=Math.max(B.start+.1,Math.min(a,B.end+_)),V=T-B.end,W=[...e];if(W[f]={...B,end:T},s&&f<e.length-1){const O=W[f+1];if(Math.abs(O.start-B.end)<vn){const X=Math.min(O.end-.1,O.start+V);W[f+1]={...O,start:X};let G=f+1;for(;G<W.length-1;){const Q=W[G],ne=W[G+1];if(Math.abs(ne.start-e[G].end)<vn){const L=Q.end-e[G].end;W[G+1]={...ne,start:Math.min(ne.end-.1,ne.start+L)},G++}else break}}}else if(!s&&f<e.length-1){const O=W[f+1];if(T>O.start){W[f+1]={...O,start:T};let X=f+1;for(;X<W.length-1;){const G=W[X],Q=W[X+1];if(G.end>Q.start)W[X+1]={...Q,start:G.end},X++;else break}}}n(W)},[e,f,a,s,n]),m=c.useCallback(()=>{!r||e.length===0||(f<=0?r(e[e.length-1].id):r(e[f-1].id))},[e,f,r]),C=c.useCallback(()=>{!r||e.length===0||(f<0||f>=e.length-1?r(e[0].id):r(e[f+1].id))},[e,f,r]),w=c.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),g=c.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),S=c.useCallback(()=>{r&&r(null)},[r]),I=c.useCallback(()=>{if(f<0||!p)return;const _=e[f],B=o?void 0:_.end-_.start;p(_.start,B)},[e,f,o,p]),E=c.useMemo(()=>[{key:"[",action:()=>y(-Ot),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>y(Ot),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-Ot),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(Ot),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:I,description:"Play selected annotation",preventDefault:!0}],[y,v,I]),D=c.useMemo(()=>[{key:"ArrowUp",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:C,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:C,description:"Select next annotation",preventDefault:!0},{key:"Home",action:w,description:"Select first annotation",preventDefault:!0},{key:"End",action:g,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:S,description:"Deselect annotation",preventDefault:!0}],[m,C,w,g,S]);return Gt({shortcuts:E,enabled:i&&f>=0}),Gt({shortcuts:D,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:y,moveEndBoundary:v,selectPrevious:m,selectNext:C,selectFirst:w,selectLast:g,clearSelection:S,scrollToAnnotation:x,playActiveAnnotation:I}}function fi(e){const t=e.reduce((a,s)=>a+s.length,0),n=new Float32Array(t);let r=0;for(const a of e)n.set(a,r),r+=a.length;return n}function hi(e,t,n,r=1){const a=e.createBuffer(r,t.length,n),s=new Float32Array(t);return a.copyToChannel(s,0),a}function Tr(e,t,n=16){const r=Math.ceil(e.length/t),a=n===8?new Int8Array(r*2):new Int16Array(r*2),s=2**(n-1);for(let o=0;o<r;o++){const i=o*t,l=Math.min(i+t,e.length);let u=0,d=0;for(let b=i;b<l;b++){const p=e[b];p<u&&(u=p),p>d&&(d=p)}a[o*2]=Math.floor(u*s),a[o*2+1]=Math.floor(d*s)}return a}function mi(e,t,n,r,a=16){const s=2**(a-1),o=r%n;let i=0;if(o>0&&e.length>0){const d=n-o,b=Math.min(d,t.length);let p=e[e.length-2]/s,f=e[e.length-1]/s;for(let m=0;m<b;m++){const C=t[m];C<p&&(p=C),C>f&&(f=C)}const x=new(a===8?Int8Array:Int16Array)(e.length);x.set(e),x[e.length-2]=Math.floor(p*s),x[e.length-1]=Math.floor(f*s),i=b;const y=Tr(t.slice(i),n,a),v=new(a===8?Int8Array:Int16Array)(x.length+y.length);return v.set(x),v.set(y,x.length),v}const l=Tr(t.slice(i),n,a),u=new(a===8?Int8Array:Int16Array)(e.length+l.length);return u.set(e),u.set(l,e.length),u}function pi(e,t={}){const{channelCount:n=1,samplesPerPixel:r=1024}=t,[a,s]=c.useState(!1),[o,i]=c.useState(!1),[l,u]=c.useState(0),[d,b]=c.useState(new Int16Array(0)),[p,f]=c.useState(null),[x,y]=c.useState(null),[v,m]=c.useState(0),[C,w]=c.useState(0),g=16,S=c.useRef(!1),I=c.useRef(null),E=c.useRef(null),D=c.useRef([]),_=c.useRef(0),B=c.useRef(null),T=c.useRef(0),V=c.useRef(!1),W=c.useRef(!1),O=c.useCallback(async()=>{if(!S.current)try{const L=P.getContext(),oe=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw",typeof document>"u"?require("url").pathToFileURL(__filename).href:cn&&cn.tagName.toUpperCase()==="SCRIPT"&&cn.src||new URL("index.js",document.baseURI).href).href;await L.addAudioWorkletModule(oe),S.current=!0}catch(L){throw console.error("Failed to load AudioWorklet module:",L),new Error("Failed to load recording processor")}},[]),X=c.useCallback(async()=>{if(!e){y(new Error("No microphone stream available"));return}try{y(null);const L=P.getContext();L.state==="suspended"&&await L.resume(),await O();const oe=L.createMediaStreamSource(e);E.current=oe;const A=L.createAudioWorkletNode("recording-processor");I.current=A,oe.connect(A),A.port.onmessage=H=>{const{samples:K}=H.data;D.current.push(K),_.current+=K.length,b(be=>mi(be,K,r,_.current-K.length,g))},A.port.postMessage({command:"start",sampleRate:L.sampleRate,channelCount:n}),D.current=[],_.current=0,b(new Int16Array(0)),f(null),m(0),w(0),V.current=!0,W.current=!1,s(!0),i(!1),T.current=performance.now();const j=()=>{if(V.current&&!W.current){const H=(performance.now()-T.current)/1e3;u(H),B.current=requestAnimationFrame(j)}};j()}catch(L){console.error("Failed to start recording:",L),y(L instanceof Error?L:new Error("Failed to start recording"))}},[e,n,r,O,a,o]),G=c.useCallback(async()=>{if(!a)return null;try{if(I.current){if(I.current.port.postMessage({command:"stop"}),E.current)try{E.current.disconnect(I.current)}catch{}I.current.disconnect()}B.current!==null&&(cancelAnimationFrame(B.current),B.current=null);const L=fi(D.current),A=P.getContext().rawContext,j=hi(A,L,A.sampleRate,n);return f(j),u(j.duration),V.current=!1,W.current=!1,s(!1),i(!1),m(0),j}catch(L){return console.error("Failed to stop recording:",L),y(L instanceof Error?L:new Error("Failed to stop recording")),null}},[a,n]),Q=c.useCallback(()=>{a&&!o&&(B.current!==null&&(cancelAnimationFrame(B.current),B.current=null),W.current=!0,i(!0))},[a,o]),ne=c.useCallback(()=>{if(a&&o){W.current=!1,i(!1),T.current=performance.now()-l*1e3;const L=()=>{if(V.current&&!W.current){const oe=(performance.now()-T.current)/1e3;u(oe),B.current=requestAnimationFrame(L)}};L()}},[a,o,l]);return c.useEffect(()=>()=>{if(I.current){if(I.current.port.postMessage({command:"stop"}),E.current)try{E.current.disconnect(I.current)}catch{}I.current.disconnect()}B.current!==null&&cancelAnimationFrame(B.current)},[]),{isRecording:a,isPaused:o,duration:l,peaks:d,audioBuffer:p,level:v,peakLevel:C,startRecording:X,stopRecording:G,pauseRecording:Q,resumeRecording:ne,error:x}}function gi(){const[e,t]=c.useState(null),[n,r]=c.useState([]),[a,s]=c.useState(!1),[o,i]=c.useState(!1),[l,u]=c.useState(null),d=c.useCallback(async()=>{try{const x=(await navigator.mediaDevices.enumerateDevices()).filter(y=>y.kind==="audioinput").map(y=>({deviceId:y.deviceId,label:y.label||`Microphone ${y.deviceId.slice(0,8)}`,groupId:y.groupId}));r(x)}catch(f){console.error("Failed to enumerate devices:",f),u(f instanceof Error?f:new Error("Failed to enumerate devices"))}},[]),b=c.useCallback(async(f,x)=>{i(!0),u(null);try{e&&e.getTracks().forEach(C=>C.stop());const v={audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,latency:0,...x,...f&&{deviceId:{exact:f}}},video:!1},m=await navigator.mediaDevices.getUserMedia(v);t(m),s(!0),await d()}catch(y){console.error("Failed to access microphone:",y),u(y instanceof Error?y:new Error("Failed to access microphone")),s(!1)}finally{i(!1)}},[e,d]),p=c.useCallback(()=>{e&&(e.getTracks().forEach(f=>f.stop()),t(null),s(!1))},[e]);return c.useEffect(()=>(d(),()=>{e&&e.getTracks().forEach(f=>f.stop())}),[]),{stream:e,devices:n,hasPermission:a,isLoading:o,requestAccess:b,stopStream:p,error:l}}function bi(e,t={}){const{updateRate:n=60,smoothingTimeConstant:r=.8}=t,[a,s]=c.useState(0),[o,i]=c.useState(0),l=c.useRef(null),u=c.useRef(null),d=c.useRef(null),b=()=>i(0);return c.useEffect(()=>{if(!e){s(0),i(0);return}let p=!0;return(async()=>{if(!p)return;const x=P.getContext();if(x.state==="suspended"&&await x.resume(),!p)return;const y=new P.Meter({smoothing:r,context:x});l.current=y;const v=x.createMediaStreamSource(e);u.current=v,P.connect(v,y);const m=1e3/n;let C=0;const w=g=>{if(!(!p||!l.current)){if(g-C>=m){C=g;const S=l.current.getValue(),I=typeof S=="number"?S:S[0],E=Math.max(0,Math.min(1,(I+100)/100));s(E),i(D=>Math.max(D,E))}d.current=requestAnimationFrame(w)}};d.current=requestAnimationFrame(w)})(),()=>{if(p=!1,d.current&&(cancelAnimationFrame(d.current),d.current=null),u.current){try{u.current.disconnect()}catch{}u.current=null}l.current&&(l.current.dispose(),l.current=null)}},[e,r,n]),{level:a,peakLevel:o,resetPeak:b}}k.button`
1084
+ `,si=({annotations:e,filename:t="annotations.json",disabled:n=!1,className:r,children:a="Download JSON"})=>{const s=()=>{if(e.length===0)return;const o=e.map(b=>Ws(b)),l=JSON.stringify(o,null,2),i=new Blob([l],{type:"application/json"}),u=URL.createObjectURL(i),d=document.createElement("a");d.href=u,d.download=t,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(u)};return E.jsx(oi,{onClick:s,disabled:n||e.length===0,className:r,title:e.length===0?"No annotations to download":"Download the annotations as JSON",children:a})};function ra(){const[e,t]=c.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:a=>It(a,e),parseTime:a=>Ur(a,e)}}const ii=[256,512,1024,2048,4096,8192];function aa({initialSamplesPerPixel:e,zoomLevels:t=ii}){const[n,r]=c.useState(()=>{const u=t.indexOf(e);return u!==-1?u:Math.floor(t.length/2)}),a=t[n],s=n>0,o=n<t.length-1,l=c.useCallback(()=>{r(u=>Math.max(0,u-1))},[]),i=c.useCallback(()=>{r(u=>Math.min(t.length-1,u+1))},[t.length]);return{samplesPerPixel:a,zoomIn:l,zoomOut:i,canZoomIn:s,canZoomOut:o}}function oa({playoutRef:e,initialVolume:t=1,onVolumeChange:n}){const[r,a]=c.useState(t),s=c.useCallback(o=>{a(o),e.current&&e.current.setMasterGain(o),n?.(o)},[e,n]);return{masterVolume:r,setMasterVolume:s}}const li=(e=256)=>{const t=c.useRef(null),n=c.useCallback((r,a,s)=>{const o=new P.Analyser("fft",e);return r.connect(o),r.connect(a),t.current=o,function(){o.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:n}};function Sn(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:a=1,name:s,color:o,fadeIn:l,fadeOut:i,waveformData:u}=e,d=t?.sampleRate??e.sampleRate??u?.sample_rate,b=t?.length??e.sourceDurationSamples??(u&&d?Math.ceil(u.duration*d):void 0);if(d===void 0)throw new Error("createClip: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");if(b===void 0)throw new Error("createClip: sourceDurationSamples is required when audioBuffer is not provided (can use waveformData.duration)");t&&u&&t.sampleRate!==u.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${u.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const p=e.durationSamples??b;return{id:sa(),audioBuffer:t,startSample:n,durationSamples:p,offsetSamples:r,sampleRate:d,sourceDurationSamples:b,gain:a,name:s,color:o,fadeIn:l,fadeOut:i,waveformData:u}}function ci(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:a=1,name:s,color:o,fadeIn:l,fadeOut:i,waveformData:u}=e,d=t?.sampleRate??e.sampleRate??u?.sample_rate;if(d===void 0)throw new Error("createClipFromSeconds: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");const b=t?.duration??e.sourceDuration??u?.duration;if(b===void 0)throw new Error("createClipFromSeconds: sourceDuration is required when audioBuffer is not provided (can use waveformData.duration)");t&&u&&t.sampleRate!==u.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${u.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const p=e.duration??b;return Sn({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(p*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(b*d),gain:a,name:s,color:o,fadeIn:l,fadeOut:i,waveformData:u})}function ui(e){const{name:t,clips:n=[],muted:r=!1,soloed:a=!1,volume:s=1,pan:o=0,color:l,height:i}=e;return{id:sa(),name:t,clips:n,muted:r,soloed:a,volume:s,pan:o,color:l,height:i}}function sa(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function di(e,t={}){const{progressive:n=!1}=t,[r,a]=c.useState([]),[s,o]=c.useState(!0),[l,i]=c.useState(null),[u,d]=c.useState(0),b=e.length;return c.useEffect(()=>{if(e.length===0){a([]),o(!1),d(0);return}let p=!1;const f=new Map,C=(g,m,w)=>{const x=w??g.audioBuffer;if(!x&&!g.waveformData)throw new Error(`Track ${m+1}: Must provide src, audioBuffer, or waveformData`);const v=x?.duration??g.waveformData?.duration,S=ci({audioBuffer:x,startTime:g.startTime??0,duration:g.duration??v,offset:g.offset??0,name:g.name||`Track ${m+1}`,fadeIn:g.fadeIn,fadeOut:g.fadeOut,waveformData:g.waveformData});if(isNaN(S.startSample)||isNaN(S.durationSamples)||isNaN(S.offsetSamples))throw console.error("Invalid clip values:",S),new Error(`Invalid clip values for track ${m+1}`);return{...ui({name:g.name||`Track ${m+1}`,clips:[S],muted:g.muted??!1,soloed:g.soloed??!1,volume:g.volume??1,pan:g.pan??0,color:g.color}),effects:g.effects}};return(async()=>{try{o(!0),i(null),d(0);const g=Wr.getContext().rawContext,m=e.map(async(x,v)=>{if(x.audioBuffer){const T=C(x,v,x.audioBuffer);return n&&!p&&(f.set(v,T),d(_=>_+1),a(Array.from({length:e.length},(_,D)=>f.get(D)).filter(_=>_!==void 0))),T}if(!x.src&&x.waveformData){const T=C(x,v);return n&&!p&&(f.set(v,T),d(_=>_+1),a(Array.from({length:e.length},(_,D)=>f.get(D)).filter(_=>_!==void 0))),T}if(!x.src)throw new Error(`Track ${v+1}: Must provide src, audioBuffer, or waveformData`);const S=await fetch(x.src);if(!S.ok)throw new Error(`Failed to fetch ${x.src}: ${S.statusText}`);const I=await S.arrayBuffer(),$=await g.decodeAudioData(I);if(!$||!$.sampleRate||!$.duration)throw new Error(`Invalid audio buffer for ${x.src}`);const M=C(x,v,$);return n&&!p&&(f.set(v,M),d(T=>T+1),a(Array.from({length:e.length},(T,_)=>f.get(_)).filter(T=>T!==void 0))),M}),w=await Promise.all(m);p||(n||(a(w),d(w.length)),o(!1))}catch(g){if(!p){const m=g instanceof Error?g.message:"Unknown error loading audio";i(m),o(!1),console.error("Error loading audio tracks:",g)}}})(),()=>{p=!0}},[e,n]),{tracks:r,loading:s,error:l,loadedCount:u,totalCount:b}}function fi({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r}){const a=c.useRef(null),s=c.useCallback(u=>{const{transform:d,active:b}=u;if(!b?.data?.current)return{...d,scaleX:1,scaleY:1};const{trackIndex:p,clipIndex:f,boundary:C}=b.data.current;if(C)return{...d,scaleX:1,scaleY:1};const y=e[p];if(!y)return{...d,scaleX:1,scaleY:1};const g=y.clips[f];if(!g)return{...d,scaleX:1,scaleY:1};const m=g.startSample/r,w=g.durationSamples/r,x=d.x*n/r;let v=m+x;const S=[...y.clips].sort((D,V)=>D.startSample-V.startSample),I=S.findIndex(D=>D===g);v=Math.max(0,v);const $=I>0?S[I-1]:null;if($){const D=($.startSample+$.durationSamples)/r;v=Math.max(v,D)}const M=I<S.length-1?S[I+1]:null;if(M){const D=v+w,V=M.startSample/r;D>V&&(v=V-w)}const _=(v-m)*r/n;return{...d,x:_,scaleX:1,scaleY:1}},[e,n,r]),o=c.useCallback(u=>{const{active:d}=u,{boundary:b}=d.data.current;if(!b){a.current=null;return}const{trackIndex:p,clipIndex:f}=d.data.current,y=e[p]?.clips[f];y&&(a.current={offsetSamples:y.offsetSamples,durationSamples:y.durationSamples,startSample:y.startSample})},[e]),l=c.useCallback(u=>{const{active:d,delta:b}=u,{boundary:p}=d.data.current;if(!p||!a.current)return;const{trackIndex:f,clipIndex:C}=d.data.current,y=b.x*n,g=Math.floor(.1*r),m=a.current,w=e.map((x,v)=>{if(v!==f)return x;const S=[...x.clips].sort((M,T)=>M.startSample-T.startSample),I=S.findIndex(M=>M===x.clips[C]),$=x.clips.map((M,T)=>{if(T!==C)return M;const _=M.sourceDurationSamples;if(p==="left"){let D=Math.floor(y);const V=-m.startSample;D<V&&(D=V);const W=-m.offsetSamples;D<W&&(D=W);const O=I>0?S[I-1]:null;if(O){const oe=O.startSample+O.durationSamples-m.startSample;D<oe&&(D=oe)}const N=m.durationSamples-g;D>N&&(D=N);const Y=m.offsetSamples+D,ee=m.durationSamples-D,re=m.startSample+D;return{...M,offsetSamples:Y,durationSamples:ee,startSample:re}}else{let D=Math.floor(m.durationSamples+y);D=Math.max(g,D),m.offsetSamples+D>_&&(D=_-m.offsetSamples);const V=I<S.length-1?S[I+1]:null;return V&&m.startSample+D>V.startSample&&(D=V.startSample-m.startSample,D=Math.max(g,D)),{...M,durationSamples:D}}});return{...x,clips:$}});t(w)},[e,t,n,r]),i=c.useCallback(u=>{const{active:d,delta:b}=u,{trackIndex:p,clipIndex:f,boundary:C}=d.data.current,y=b.x*n;if(C){a.current=null;return}const g=e.map((m,w)=>{if(w!==p)return m;const x=[...m.clips].sort((I,$)=>I.startSample-$.startSample),v=x.findIndex(I=>I===m.clips[f]),S=m.clips.map((I,$)=>{if($!==f)return I;let M=Math.floor(I.startSample+y);M=Math.max(0,M);const T=v>0?x[v-1]:null;if(T){const D=T.startSample+T.durationSamples;M=Math.max(M,D)}const _=v<x.length-1?x[v+1]:null;return _&&M+I.durationSamples>_.startSample&&(M=_.startSample-I.durationSamples),{...I,startSample:M}});return{...m,clips:S}});t(g)},[e,t,n,r]);return{onDragStart:o,onDragMove:l,onDragEnd:i,collisionModifier:s}}const mn=.01;function mi({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:a,linkEndpoints:s}){const o=c.useRef(null),l=c.useCallback(d=>{const{active:b}=d,p=b.data.current;if(!p||p.annotationIndex===void 0){o.current=null;return}const f=e[p.annotationIndex];f&&(o.current={start:f.start,end:f.end,annotationIndex:p.annotationIndex})},[e]),i=c.useCallback(d=>{const{active:b,delta:p}=d;if(!o.current)return;const f=b.data.current;if(!f)return;const{edge:C,annotationIndex:y}=f,g=o.current,m=p.x*n/r,w=C==="start"?g.start+m:g.end+m,x=hi({annotationIndex:y,newTime:w,isDraggingStart:C==="start",annotations:e,duration:a,linkEndpoints:s});t(x)},[e,t,n,r,a,s]),u=c.useCallback(()=>{o.current=null},[]);return{onDragStart:l,onDragMove:i,onDragEnd:u}}function hi({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:a,linkEndpoints:s}){const o=[...r],l=r[e];if(n){const i=Math.min(l.end-.1,Math.max(0,t)),u=i-l.start;if(o[e]={...l,start:i},s&&e>0){const d=o[e-1];Math.abs(d.end-l.start)<mn?o[e-1]={...d,end:Math.max(d.start+.1,d.end+u)}:i<=d.end&&(o[e]={...o[e],start:d.end})}else!s&&e>0&&i<o[e-1].end&&(o[e-1]={...o[e-1],end:i})}else{const i=Math.max(l.start+.1,Math.min(t,a)),u=i-l.end;if(o[e]={...l,end:i},s&&e<o.length-1){const d=o[e+1];if(Math.abs(d.start-l.end)<mn){const b=d.start+u;o[e+1]={...d,start:Math.min(d.end-.1,b)};let p=e+1;for(;p<o.length-1;){const f=o[p],C=o[p+1];if(Math.abs(C.start-f.end)<mn){const y=f.end-r[p].end;o[p+1]={...C,start:Math.min(C.end-.1,C.start+y)},p++}else break}}else i>=d.start&&(o[e]={...o[e],end:d.start})}else if(!s&&e<o.length-1&&i>o[e+1].start){const d=o[e+1];o[e+1]={...d,start:i};let b=e+1;for(;b<o.length-1;){const p=o[b],f=o[b+1];if(p.end>f.start)o[b+1]={...f,start:p.end},b++;else break}}}return o}function Fn(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ia(e){return"nodeType"in e}function St(e){var t,n;return e?Fn(e)?e:ia(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function pi(e){const{Document:t}=St(e);return e instanceof t}function gi(e){return Fn(e)?!1:e instanceof St(e).HTMLElement}function bi(e){return e instanceof St(e).SVGElement}function nn(e){return e?Fn(e)?e.document:ia(e)?pi(e)?e:gi(e)||bi(e)?e.ownerDocument:document:document:document}function vi(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((s,o)=>{const l=Object.entries(o);for(const[i,u]of l){const d=s[i];d!=null&&(s[i]=d+e*u)}return s},{...t})}}const Ci=vi(-1);function wi(e){return"clientX"in e&&"clientY"in e}function xi(e){if(!e)return!1;const{TouchEvent:t}=St(e.target);return t&&e instanceof t}function yr(e){if(xi(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return wi(e)?{x:e.clientX,y:e.clientY}:null}var Ir;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Ir||(Ir={}));function hn(e,t){return c.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function yi(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const An=Object.freeze({x:0,y:0});var yt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(yt||(yt={}));class pn{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var a;(a=this.target)==null||a.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function Ii(e){const{EventTarget:t}=St(e);return e instanceof t?e:nn(e)}function gn(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var nt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(nt||(nt={}));function Sr(e){e.preventDefault()}function Si(e){e.stopPropagation()}var rt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(rt||(rt={}));rt.Space,rt.Enter,rt.Esc,rt.Space,rt.Enter,rt.Tab;function Ar(e){return!!(e&&"distance"in e)}function kr(e){return!!(e&&"delay"in e)}class Wn{constructor(t,n,r){var a;r===void 0&&(r=Ii(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:s}=t,{target:o}=s;this.props=t,this.events=n,this.document=nn(o),this.documentListeners=new pn(this.document),this.listeners=new pn(r),this.windowListeners=new pn(St(o)),this.initialCoordinates=(a=yr(s))!=null?a:An,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(nt.Resize,this.handleCancel),this.windowListeners.add(nt.DragStart,Sr),this.windowListeners.add(nt.VisibilityChange,this.handleCancel),this.windowListeners.add(nt.ContextMenu,Sr),this.documentListeners.add(nt.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(kr(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Ar(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:a}=this.props;a(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(nt.Click,Si,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(nt.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:a,props:s}=this,{onMove:o,options:{activationConstraint:l}}=s;if(!a)return;const i=(n=yr(t))!=null?n:An,u=Ci(a,i);if(!r&&l){if(Ar(l)){if(l.tolerance!=null&&gn(u,l.tolerance))return this.handleCancel();if(gn(u,l.distance))return this.handleStart()}if(kr(l)&&gn(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}t.cancelable&&t.preventDefault(),o(i)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===rt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Ai={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class la extends Wn{constructor(t){const{event:n}=t,r=nn(n.target);super(t,Ai,r)}}la.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const ki={move:{name:"mousemove"},end:{name:"mouseup"}};var kn;(function(e){e[e.RightClick=2]="RightClick"})(kn||(kn={}));class ca extends Wn{constructor(t){super(t,ki,nn(t.event.target))}}ca.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===kn.RightClick?!1:(r?.({event:n}),!0)}}];const bn={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ua extends Wn{constructor(t){super(t,bn)}static setup(){return window.addEventListener(bn.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(bn.move.name,t)};function t(){}}}ua.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:a}=n;return a.length>1?!1:(r?.({event:n}),!0)}}];var $r;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})($r||($r={}));var Rr;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Rr||(Rr={}));yt.Backward+"",yt.Forward+"",yt.Backward+"",yt.Forward+"";var $n;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})($n||($n={}));var Rn;(function(e){e.Optimized="optimized"})(Rn||(Rn={}));$n.WhileDragging,Rn.Optimized;({...An});var Er;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Er||(Er={}));function $i(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:a=1}=e,s=hn(ca,{activationConstraint:{distance:a}}),o=hn(ua,{activationConstraint:t?{delay:n,tolerance:r}:{distance:a}}),l=hn(la,{activationConstraint:{distance:a}});return yi(...t?[s,o]:[l])}const Ri=e=>{const{tracks:t,onTracksChange:n,sampleRate:r}=e,{currentTimeRef:a}=We(),{selectedTrackId:s}=Le(),o=c.useCallback((i,u,d)=>{const{sampleRate:b,samplesPerPixel:p}=e,f=t[i];if(!f)return!1;const C=f.clips[u];if(!C)return!1;const y=C.startSample/b,g=(C.startSample+C.durationSamples)/b;if(d<=y||d>=g)return console.warn("Split time is outside clip bounds"),!1;const m=Math.round(d*b),w=Math.floor(m/p),x=C.startSample+C.durationSamples,v=w*p,S=C.startSample,I=v-S,$=v,M=x-$,T=v-C.startSample,_=Sn({audioBuffer:C.audioBuffer,startSample:S,durationSamples:I,offsetSamples:C.offsetSamples,sampleRate:C.sampleRate,sourceDurationSamples:C.sourceDurationSamples,gain:C.gain,name:C.name?`${C.name} (1)`:void 0,color:C.color,fadeIn:C.fadeIn,waveformData:C.waveformData}),D=Sn({audioBuffer:C.audioBuffer,startSample:$,durationSamples:M,offsetSamples:C.offsetSamples+T,sampleRate:C.sampleRate,sourceDurationSamples:C.sourceDurationSamples,gain:C.gain,name:C.name?`${C.name} (2)`:void 0,color:C.color,waveformData:C.waveformData,fadeOut:C.fadeOut}),V=[...f.clips];V.splice(u,1,_,D);const W=[...t];return W[i]={...f,clips:V},n(W),!0},[t,n,e]);return{splitClipAtPlayhead:c.useCallback(()=>{if(!s)return console.log("No track selected - click a clip to select a track first"),!1;const i=t.findIndex(b=>b.id===s);if(i===-1)return console.warn("Selected track not found"),!1;const u=t[i],d=a.current??0;for(let b=0;b<u.clips.length;b++){const p=u.clips[b],f=p.startSample/r,C=(p.startSample+p.durationSamples)/r;if(d>f&&d<C)return console.log(`Splitting clip on track "${u.name}" at ${d}s`),o(i,b,d)}return console.log(`No clip found at playhead position on track "${u.name}"`),!1},[t,a,s,o,r]),splitClipAt:o}},Kt=e=>{const{shortcuts:t,enabled:n=!0}=e,r=c.useCallback(a=>{if(!n)return;const s=a.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const o=t.find(l=>{const i=a.key.toLowerCase()===l.key.toLowerCase()||a.key===l.key,u=l.ctrlKey===void 0||a.ctrlKey===l.ctrlKey,d=l.shiftKey===void 0||a.shiftKey===l.shiftKey,b=l.metaKey===void 0||a.metaKey===l.metaKey,p=l.altKey===void 0||a.altKey===l.altKey;return i&&u&&d&&b&&p});o&&(o.preventDefault!==!1&&a.preventDefault(),o.action())},[t,n]);c.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},Ei=e=>{const t=[],n=typeof navigator<"u"&&navigator.platform.includes("Mac");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("+")},Di=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:a}=We(),{setCurrentTime:s,play:o,pause:l,stop:i}=we(),{playoutRef:u}=De(),d=c.useCallback(()=>{a?l():o()},[a,o,l]),b=c.useCallback(()=>{i()},[i]),p=c.useCallback(()=>{a&&u.current?(u.current.stop(),s(0),o(0)):s(0)},[a,u,s,o]),C=r??[...[{key:" ",action:d,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:b,description:"Stop",preventDefault:!0},{key:"0",action:p,description:"Rewind to start",preventDefault:!0}],...n];return Kt({shortcuts:C,enabled:t}),{rewindToStart:p,togglePlayPause:d,stopPlayback:b,shortcuts:C}},vn=.01,Nt=.01;function Ti({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:a,linkEndpoints:s,continuousPlay:o=!1,enabled:l=!0,scrollContainerRef:i,samplesPerPixel:u,sampleRate:d,controlsWidth:b=0,onPlay:p}){const f=c.useMemo(()=>t?e.findIndex(T=>T.id===t):-1,[e,t]),C=c.useCallback(T=>{if(!i?.current||!u||!d)return;const _=e.find(X=>X.id===T);if(!_)return;const D=i.current,V=D.clientWidth,W=_.start*d/u+b,O=_.end*d/u+b,N=(W+O)/2,Y=D.scrollLeft,ee=Y,re=Y+V;if(W<ee||O>re){const X=Math.max(0,N-V/2);D.scrollTo({left:X,behavior:"smooth"})}},[e,i,u,d,b]);c.useEffect(()=>{t&&i?.current&&u&&d&&C(t)},[t,C,i,u,d]);const y=c.useCallback(T=>{if(f<0)return;const _=e[f],D=Math.max(0,Math.min(_.end-.1,_.start+T)),V=D-_.start,W=[...e];if(W[f]={..._,start:D},s&&f>0){const O=W[f-1];Math.abs(O.end-_.start)<vn&&(W[f-1]={...O,end:Math.max(O.start+.1,O.end+V)})}else if(!s&&f>0){const O=W[f-1];D<O.end&&(W[f-1]={...O,end:D})}n(W)},[e,f,s,n]),g=c.useCallback(T=>{if(f<0)return;const _=e[f],D=Math.max(_.start+.1,Math.min(a,_.end+T)),V=D-_.end,W=[...e];if(W[f]={..._,end:D},s&&f<e.length-1){const O=W[f+1];if(Math.abs(O.start-_.end)<vn){const N=Math.min(O.end-.1,O.start+V);W[f+1]={...O,start:N};let Y=f+1;for(;Y<W.length-1;){const ee=W[Y],re=W[Y+1];if(Math.abs(re.start-e[Y].end)<vn){const X=ee.end-e[Y].end;W[Y+1]={...re,start:Math.min(re.end-.1,re.start+X)},Y++}else break}}}else if(!s&&f<e.length-1){const O=W[f+1];if(D>O.start){W[f+1]={...O,start:D};let N=f+1;for(;N<W.length-1;){const Y=W[N],ee=W[N+1];if(Y.end>ee.start)W[N+1]={...ee,start:Y.end},N++;else break}}}n(W)},[e,f,a,s,n]),m=c.useCallback(()=>{!r||e.length===0||(f<=0?r(e[e.length-1].id):r(e[f-1].id))},[e,f,r]),w=c.useCallback(()=>{!r||e.length===0||(f<0||f>=e.length-1?r(e[0].id):r(e[f+1].id))},[e,f,r]),x=c.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),v=c.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),S=c.useCallback(()=>{r&&r(null)},[r]),I=c.useCallback(()=>{if(f<0||!p)return;const T=e[f],_=o?void 0:T.end-T.start;p(T.start,_)},[e,f,o,p]),$=c.useMemo(()=>[{key:"[",action:()=>y(-Nt),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>y(Nt),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>g(-Nt),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>g(Nt),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:I,description:"Play selected annotation",preventDefault:!0}],[y,g,I]),M=c.useMemo(()=>[{key:"ArrowUp",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:w,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:w,description:"Select next annotation",preventDefault:!0},{key:"Home",action:x,description:"Select first annotation",preventDefault:!0},{key:"End",action:v,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:S,description:"Deselect annotation",preventDefault:!0}],[m,w,x,v,S]);return Kt({shortcuts:$,enabled:l&&f>=0}),Kt({shortcuts:M,enabled:l&&e.length>0&&!!r}),{moveStartBoundary:y,moveEndBoundary:g,selectPrevious:m,selectNext:w,selectFirst:x,selectLast:v,clearSelection:S,scrollToAnnotation:C,playActiveAnnotation:I}}function _i(e){const t=e.reduce((a,s)=>a+s.length,0),n=new Float32Array(t);let r=0;for(const a of e)n.set(a,r),r+=a.length;return n}function Mi(e,t,n,r=1){const a=e.createBuffer(r,t.length,n),s=new Float32Array(t);return a.copyToChannel(s,0),a}function Dr(e,t,n=16){const r=Math.ceil(e.length/t),a=n===8?new Int8Array(r*2):new Int16Array(r*2),s=2**(n-1);for(let o=0;o<r;o++){const l=o*t,i=Math.min(l+t,e.length);let u=0,d=0;for(let b=l;b<i;b++){const p=e[b];p<u&&(u=p),p>d&&(d=p)}a[o*2]=Math.floor(u*s),a[o*2+1]=Math.floor(d*s)}return a}function Bi(e,t,n,r,a=16){const s=2**(a-1),o=r%n;let l=0;if(o>0&&e.length>0){const d=n-o,b=Math.min(d,t.length);let p=e[e.length-2]/s,f=e[e.length-1]/s;for(let m=0;m<b;m++){const w=t[m];w<p&&(p=w),w>f&&(f=w)}const C=new(a===8?Int8Array:Int16Array)(e.length);C.set(e),C[e.length-2]=Math.floor(p*s),C[e.length-1]=Math.floor(f*s),l=b;const y=Dr(t.slice(l),n,a),g=new(a===8?Int8Array:Int16Array)(C.length+y.length);return g.set(C),g.set(y,C.length),g}const i=Dr(t.slice(l),n,a),u=new(a===8?Int8Array:Int16Array)(e.length+i.length);return u.set(e),u.set(i,e.length),u}function Fi(e,t={}){const{channelCount:n=1,samplesPerPixel:r=1024}=t,[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,u]=c.useState(0),[d,b]=c.useState(new Int16Array(0)),[p,f]=c.useState(null),[C,y]=c.useState(null),[g,m]=c.useState(0),[w,x]=c.useState(0),v=16,S=c.useRef(!1),I=c.useRef(null),$=c.useRef(null),M=c.useRef([]),T=c.useRef(0),_=c.useRef(null),D=c.useRef(0),V=c.useRef(!1),W=c.useRef(!1),O=c.useCallback(async()=>{if(!S.current)try{const X=P.getContext(),oe=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw",typeof document>"u"?require("url").pathToFileURL(__filename).href:cn&&cn.tagName.toUpperCase()==="SCRIPT"&&cn.src||new URL("index.js",document.baseURI).href).href;await X.addAudioWorkletModule(oe),S.current=!0}catch(X){throw console.error("Failed to load AudioWorklet module:",X),new Error("Failed to load recording processor")}},[]),N=c.useCallback(async()=>{if(!e){y(new Error("No microphone stream available"));return}try{y(null);const X=P.getContext();X.state==="suspended"&&await X.resume(),await O();const oe=X.createMediaStreamSource(e);$.current=oe;const A=X.createAudioWorkletNode("recording-processor");I.current=A,oe.connect(A),A.port.onmessage=H=>{const{samples:U}=H.data;M.current.push(U),T.current+=U.length,b(ge=>Bi(ge,U,r,T.current-U.length,v))},A.port.postMessage({command:"start",sampleRate:X.sampleRate,channelCount:n}),M.current=[],T.current=0,b(new Int16Array(0)),f(null),m(0),x(0),V.current=!0,W.current=!1,s(!0),l(!1),D.current=performance.now();const j=()=>{if(V.current&&!W.current){const H=(performance.now()-D.current)/1e3;u(H),_.current=requestAnimationFrame(j)}};j()}catch(X){console.error("Failed to start recording:",X),y(X instanceof Error?X:new Error("Failed to start recording"))}},[e,n,r,O,a,o]),Y=c.useCallback(async()=>{if(!a)return null;try{if(I.current){if(I.current.port.postMessage({command:"stop"}),$.current)try{$.current.disconnect(I.current)}catch{}I.current.disconnect()}_.current!==null&&(cancelAnimationFrame(_.current),_.current=null);const X=_i(M.current),A=P.getContext().rawContext,j=Mi(A,X,A.sampleRate,n);return f(j),u(j.duration),V.current=!1,W.current=!1,s(!1),l(!1),m(0),j}catch(X){return console.error("Failed to stop recording:",X),y(X instanceof Error?X:new Error("Failed to stop recording")),null}},[a,n]),ee=c.useCallback(()=>{a&&!o&&(_.current!==null&&(cancelAnimationFrame(_.current),_.current=null),W.current=!0,l(!0))},[a,o]),re=c.useCallback(()=>{if(a&&o){W.current=!1,l(!1),D.current=performance.now()-i*1e3;const X=()=>{if(V.current&&!W.current){const oe=(performance.now()-D.current)/1e3;u(oe),_.current=requestAnimationFrame(X)}};X()}},[a,o,i]);return c.useEffect(()=>()=>{if(I.current){if(I.current.port.postMessage({command:"stop"}),$.current)try{$.current.disconnect(I.current)}catch{}I.current.disconnect()}_.current!==null&&cancelAnimationFrame(_.current)},[]),{isRecording:a,isPaused:o,duration:i,peaks:d,audioBuffer:p,level:g,peakLevel:w,startRecording:N,stopRecording:Y,pauseRecording:ee,resumeRecording:re,error:C}}function Wi(){const[e,t]=c.useState(null),[n,r]=c.useState([]),[a,s]=c.useState(!1),[o,l]=c.useState(!1),[i,u]=c.useState(null),d=c.useCallback(async()=>{try{const C=(await navigator.mediaDevices.enumerateDevices()).filter(y=>y.kind==="audioinput").map(y=>({deviceId:y.deviceId,label:y.label||`Microphone ${y.deviceId.slice(0,8)}`,groupId:y.groupId}));r(C)}catch(f){console.error("Failed to enumerate devices:",f),u(f instanceof Error?f:new Error("Failed to enumerate devices"))}},[]),b=c.useCallback(async(f,C)=>{l(!0),u(null);try{e&&e.getTracks().forEach(w=>w.stop());const g={audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,latency:0,...C,...f&&{deviceId:{exact:f}}},video:!1},m=await navigator.mediaDevices.getUserMedia(g);t(m),s(!0),await d()}catch(y){console.error("Failed to access microphone:",y),u(y instanceof Error?y:new Error("Failed to access microphone")),s(!1)}finally{l(!1)}},[e,d]),p=c.useCallback(()=>{e&&(e.getTracks().forEach(f=>f.stop()),t(null),s(!1))},[e]);return c.useEffect(()=>(d(),()=>{e&&e.getTracks().forEach(f=>f.stop())}),[]),{stream:e,devices:n,hasPermission:a,isLoading:o,requestAccess:b,stopStream:p,error:i}}function Zi(e,t={}){const{updateRate:n=60,smoothingTimeConstant:r=.8}=t,[a,s]=c.useState(0),[o,l]=c.useState(0),i=c.useRef(null),u=c.useRef(null),d=c.useRef(null),b=()=>l(0);return c.useEffect(()=>{if(!e){s(0),l(0);return}let p=!0;return(async()=>{if(!p)return;const C=P.getContext();if(C.state==="suspended"&&await C.resume(),!p)return;const y=new P.Meter({smoothing:r,context:C});i.current=y;const g=C.createMediaStreamSource(e);u.current=g,P.connect(g,y);const m=1e3/n;let w=0;const x=v=>{if(!(!p||!i.current)){if(v-w>=m){w=v;const S=i.current.getValue(),I=typeof S=="number"?S:S[0],$=Math.max(0,Math.min(1,(I+100)/100));s($),l(M=>Math.max(M,$))}d.current=requestAnimationFrame(x)}};d.current=requestAnimationFrame(x)})(),()=>{if(p=!1,d.current&&(cancelAnimationFrame(d.current),d.current=null),u.current){try{u.current.disconnect()}catch{}u.current=null}i.current&&(i.current.dispose(),i.current=null)}},[e,r,n]),{level:a,peakLevel:o,resetPeak:b}}k.button`
1084
1085
  padding: 0.5rem 1rem;
1085
1086
  font-size: 0.875rem;
1086
1087
  font-weight: 500;
@@ -1128,7 +1129,7 @@ React keys must be passed directly to JSX without using spread:
1128
1129
  opacity: 0.3;
1129
1130
  }
1130
1131
  }
1131
- `;k(Dn)`
1132
+ `;k(Tn)`
1132
1133
  min-width: 200px;
1133
1134
  `;k(Nr)`
1134
1135
  display: flex;
@@ -1173,7 +1174,7 @@ React keys must be passed directly to JSX without using spread:
1173
1174
  font-weight: 500;
1174
1175
  color: ${e=>e.$isPaused?"#ffc107":"#dc3545"};
1175
1176
  text-transform: uppercase;
1176
- `;var vi=k.div`
1177
+ `;var Pi=k.div`
1177
1178
  position: relative;
1178
1179
  width: ${e=>e.$width}px;
1179
1180
  height: ${e=>e.$height}px;
@@ -1181,39 +1182,39 @@ React keys must be passed directly to JSX without using spread:
1181
1182
  border-radius: 4px;
1182
1183
  overflow: hidden;
1183
1184
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
1184
- `,Ci=e=>e<.6?"linear-gradient(90deg, #27ae60, #2ecc71)":e<.85?"linear-gradient(90deg, #f39c12, #f1c40f)":"linear-gradient(90deg, #c0392b, #e74c3c)",xi=k.div.attrs(e=>({style:{width:`${e.$level*100}%`,height:`${e.$height}px`,background:Ci(e.$level),boxShadow:e.$level>.01?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}}))`
1185
+ `,Vi=e=>e<.6?"linear-gradient(90deg, #27ae60, #2ecc71)":e<.85?"linear-gradient(90deg, #f39c12, #f1c40f)":"linear-gradient(90deg, #c0392b, #e74c3c)",ji=k.div.attrs(e=>({style:{width:`${e.$level*100}%`,height:`${e.$height}px`,background:Vi(e.$level),boxShadow:e.$level>.01?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}}))`
1185
1186
  position: absolute;
1186
1187
  left: 0;
1187
1188
  top: 0;
1188
1189
  transition: width 0.05s ease-out, background 0.1s ease-out;
1189
- `,wi=k.div.attrs(e=>({style:{left:`${e.$peakLevel*100}%`,height:`${e.$height}px`}}))`
1190
+ `,zi=k.div.attrs(e=>({style:{left:`${e.$peakLevel*100}%`,height:`${e.$height}px`}}))`
1190
1191
  position: absolute;
1191
1192
  top: 0;
1192
1193
  width: 2px;
1193
1194
  background: #ecf0f1;
1194
1195
  box-shadow: 0 0 4px rgba(236, 240, 241, 0.8);
1195
1196
  transition: left 0.1s ease-out;
1196
- `,yi=k.div`
1197
+ `,Oi=k.div`
1197
1198
  position: absolute;
1198
1199
  top: 0;
1199
1200
  left: 0;
1200
1201
  width: 100%;
1201
1202
  height: ${e=>e.$height}px;
1202
1203
  pointer-events: none;
1203
- `,Dr=k.div`
1204
+ `,Tr=k.div`
1204
1205
  position: absolute;
1205
1206
  left: ${e=>e.$position}%;
1206
1207
  top: 0;
1207
1208
  width: 1px;
1208
1209
  height: ${e=>e.$height}px;
1209
1210
  background: rgba(255, 255, 255, 0.2);
1210
- `,Ii=({level:e,peakLevel:t,width:n=200,height:r=20,className:a})=>{const s=Math.max(0,Math.min(1,e)),o=t!==void 0?Math.max(0,Math.min(1,t)):0;return R.jsxs(vi,{$width:n,$height:r,className:a,children:[R.jsx(xi,{$level:s,$height:r}),t!==void 0&&o>0&&R.jsx(wi,{$peakLevel:o,$height:r}),R.jsxs(yi,{$height:r,children:[R.jsx(Dr,{$position:60,$height:r}),R.jsx(Dr,{$position:85,$height:r})]})]})};c.memo(Ii);function Si(e,t,n,r={}){const{currentTime:a=0,audioConstraints:s,...o}=r,[i,l]=c.useState(!1),[u,d]=c.useState(null),{stream:b,devices:p,hasPermission:f,requestAccess:x,error:y}=gi(),{level:v,peakLevel:m}=bi(b),{isRecording:C,isPaused:w,duration:g,peaks:S,startRecording:I,stopRecording:E,pauseRecording:D,resumeRecording:_,error:B}=pi(b,o),T=c.useCallback(async()=>{n&&(i||(await un(),l(!0)),await I())},[n,i,I]),V=c.useCallback(async()=>{const X=await E();if(X&&n){const G=e.findIndex(H=>H.id===n);if(G===-1)return;const Q=e[G],ne=Math.floor(a*X.sampleRate);let L=0;if(Q.clips.length>0){const H=Q.clips.map(K=>K.startSample+K.durationSamples);L=Math.max(...H)}const oe=Math.max(ne,L),A={id:`clip-${Date.now()}`,audioBuffer:X,startSample:oe,durationSamples:X.length,offsetSamples:0,gain:1,name:`Recording ${new Date().toLocaleTimeString()}`},j=e.map((H,K)=>K===G?{...H,clips:[...H.clips,A]}:H);t(j)}},[n,e,t,a,E]);c.useEffect(()=>{f&&p.length>0&&u===null&&d(p[0].deviceId)},[f,p.length]);const W=c.useCallback(async()=>{await x(void 0,s),await un(),l(!0)},[x,s]),O=c.useCallback(async X=>{d(X),await x(X,s),await un(),l(!0)},[x,s]);return{isRecording:C,isPaused:w,duration:g,level:v,peakLevel:m,error:y||B,stream:b,devices:p,hasPermission:f,selectedDevice:u,startRecording:T,stopRecording:V,pauseRecording:D,resumeRecording:_,requestMicAccess:W,changeDevice:O,recordingPeaks:S}}const Mt=[{id:"reverb",name:"Reverb",category:"reverb",description:"Simple convolution reverb with adjustable decay time",parameters:[{name:"decay",label:"Decay",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"s"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"freeverb",name:"Freeverb",category:"reverb",description:"Classic Schroeder/Moorer reverb with room size and dampening",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.7},{name:"dampening",label:"Dampening",type:"number",min:0,max:1e4,step:100,default:3e3,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"jcReverb",name:"JC Reverb",category:"reverb",description:"Attempt at Roland JC-120 chorus reverb emulation",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"feedbackDelay",name:"Feedback Delay",category:"delay",description:"Delay line with feedback for echo effects",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"pingPongDelay",name:"Ping Pong Delay",category:"delay",description:"Stereo delay bouncing between left and right channels",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"chorus",name:"Chorus",category:"modulation",description:"Creates thickness by layering detuned copies of the signal",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"Hz"},{name:"delayTime",label:"Delay",type:"number",min:0,max:20,step:.5,default:3.5,unit:"ms"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.7},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"phaser",name:"Phaser",category:"modulation",description:"Classic phaser effect using allpass filters",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:.5,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:6,step:1,default:3},{name:"baseFrequency",label:"Base Freq",type:"number",min:100,max:2e3,step:10,default:350,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"tremolo",name:"Tremolo",category:"modulation",description:"Rhythmic volume modulation",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:4,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"vibrato",name:"Vibrato",category:"modulation",description:"Pitch modulation effect",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:5,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoPanner",name:"Auto Panner",category:"modulation",description:"Automatic left-right panning",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoFilter",name:"Auto Filter",category:"filter",description:"Automated filter sweep with LFO",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:2e3,step:10,default:200,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:.5,max:8,step:.5,default:2.6},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoWah",name:"Auto Wah",category:"filter",description:"Envelope follower filter effect",parameters:[{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:500,step:10,default:100,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:8,step:1,default:6},{name:"sensitivity",label:"Sensitivity",type:"number",min:-40,max:0,step:1,default:0,unit:"dB"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"eq3",name:"3-Band EQ",category:"filter",description:"Three band equalizer with low, mid, and high controls",parameters:[{name:"low",label:"Low",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"mid",label:"Mid",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"high",label:"High",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"lowFrequency",label:"Low Freq",type:"number",min:20,max:500,step:10,default:400,unit:"Hz"},{name:"highFrequency",label:"High Freq",type:"number",min:1e3,max:1e4,step:100,default:2500,unit:"Hz"}]},{id:"distortion",name:"Distortion",category:"distortion",description:"Wave shaping distortion effect",parameters:[{name:"distortion",label:"Drive",type:"number",min:0,max:1,step:.01,default:.4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"bitCrusher",name:"Bit Crusher",category:"distortion",description:"Reduces bit depth for lo-fi digital texture",parameters:[{name:"bits",label:"Bits",type:"number",min:1,max:16,step:1,default:4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"chebyshev",name:"Chebyshev",category:"distortion",description:"Waveshaping distortion using Chebyshev polynomials",parameters:[{name:"order",label:"Order",type:"number",min:1,max:100,step:1,default:50},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"compressor",name:"Compressor",category:"dynamics",description:"Dynamic range compressor",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-60,max:0,step:1,default:-24,unit:"dB"},{name:"ratio",label:"Ratio",type:"number",min:1,max:20,step:.5,default:4},{name:"attack",label:"Attack",type:"number",min:0,max:1,step:.001,default:.003,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"knee",label:"Knee",type:"number",min:0,max:40,step:1,default:30,unit:"dB"}]},{id:"limiter",name:"Limiter",category:"dynamics",description:"Hard limiter to prevent clipping",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-12,max:0,step:.5,default:-6,unit:"dB"}]},{id:"gate",name:"Gate",category:"dynamics",description:"Noise gate to silence signal below threshold",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-100,max:0,step:1,default:-40,unit:"dB"},{name:"attack",label:"Attack",type:"number",min:0,max:.3,step:.001,default:.001,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:.5,step:.01,default:.1,unit:"s"}]},{id:"stereoWidener",name:"Stereo Widener",category:"spatial",description:"Expands or narrows the stereo image",parameters:[{name:"width",label:"Width",type:"number",min:0,max:1,step:.01,default:.5}]}],Wn=e=>Mt.find(t=>t.id===e),Ai=e=>Mt.filter(t=>t.category===e),ki=[{id:"reverb",name:"Reverb"},{id:"delay",name:"Delay"},{id:"modulation",name:"Modulation"},{id:"filter",name:"Filter"},{id:"distortion",name:"Distortion"},{id:"dynamics",name:"Dynamics"},{id:"spatial",name:"Spatial"}],$i={reverb:P.Reverb,freeverb:P.Freeverb,jcReverb:P.JCReverb,feedbackDelay:P.FeedbackDelay,pingPongDelay:P.PingPongDelay,chorus:P.Chorus,phaser:P.Phaser,tremolo:P.Tremolo,vibrato:P.Vibrato,autoPanner:P.AutoPanner,autoFilter:P.AutoFilter,autoWah:P.AutoWah,eq3:P.EQ3,distortion:P.Distortion,bitCrusher:P.BitCrusher,chebyshev:P.Chebyshev,compressor:P.Compressor,limiter:P.Limiter,gate:P.Gate,stereoWidener:P.StereoWidener};let Ri=0;const Ei=()=>`effect_${Date.now()}_${++Ri}`;function _t(e,t){const n=$i[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(o=>{const i=t?.[o.name]??o.default;r[o.name]=i});const a=new n(r),s=Ei();return{effect:a,id:e.id,instanceId:s,dispose(){try{a.disconnect(),a.dispose()}catch{}},setParameter(o,i){o==="wet"&&a.wet?a.wet.value=i:a[o]!==void 0&&(a[o]?.value!==void 0?a[o].value=i:a[o]=i)},getParameter(o){if(o==="wet"&&a.wet)return a.wet.value;if(a[o]!==void 0)return a[o]?.value!==void 0?a[o].value:a[o]},connect(o){a.connect(o)},disconnect(){try{a.disconnect()}catch{}}}}function Ti(e){if(e.length===0)throw new Error("Cannot create effect chain with no effects");for(let t=0;t<e.length-1;t++)e[t].effect.connect(e[t+1].effect);return{input:e[0].effect,output:e[e.length-1].effect,dispose(){e.forEach(t=>t.dispose())}}}function Di(e=256){const[t,n]=c.useState([]),r=c.useRef(t);r.current=t;const a=c.useRef(new Map),s=c.useRef(null),o=c.useRef(null),i=c.useCallback(v=>{const m=o.current;if(!m)return;const{masterGainNode:C,destination:w,analyserNode:g}=m;try{C.disconnect()}catch{}const S=v.map(I=>a.current.get(I.instanceId)).filter(I=>I!==void 0);if(S.length===0)C.connect(g),g.connect(w);else{let I=C;S.forEach(E=>{try{E.disconnect()}catch{}I.connect(E.effect),I=E.effect}),I.connect(g),g.connect(w)}},[]),l=c.useCallback(v=>{const m=Wn(v);if(!m){console.error(`Unknown effect: ${v}`);return}const C={};m.parameters.forEach(S=>{C[S.name]=S.default});const w=_t(m,C);a.current.set(w.instanceId,w);const g={instanceId:w.instanceId,effectId:m.id,definition:m,params:C,bypassed:!1};n(S=>[...S,g])},[]),u=c.useCallback(v=>{const m=a.current.get(v);m&&(m.dispose(),a.current.delete(v)),n(C=>C.filter(w=>w.instanceId!==v))},[]),d=c.useCallback((v,m,C)=>{const w=a.current.get(v);w&&w.setParameter(m,C),n(g=>g.map(S=>S.instanceId===v?{...S,params:{...S.params,[m]:C}}:S))},[]),b=c.useCallback(v=>{const m=r.current.find(g=>g.instanceId===v);if(!m)return;const C=!m.bypassed,w=a.current.get(v);if(w){const g=m.params.wet??1;w.setParameter("wet",C?0:g)}n(g=>g.map(S=>S.instanceId===v?{...S,bypassed:C}:S))},[]),p=c.useCallback((v,m)=>{n(C=>{const w=[...C],[g]=w.splice(v,1);return w.splice(m,0,g),w})},[]),f=c.useCallback(()=>{a.current.forEach(v=>v.dispose()),a.current.clear(),n([])},[]);c.useEffect(()=>{i(t)},[t,i]);const x=c.useCallback((v,m,C)=>{const w=new P.Analyser("fft",e);s.current=w,o.current={masterGainNode:v,destination:m,analyserNode:w};const S=r.current.map(I=>a.current.get(I.instanceId)).filter(I=>I!==void 0);if(S.length===0)v.connect(w),w.connect(m);else{let I=v;S.forEach(E=>{I.connect(E.effect),I=E.effect}),I.connect(w),w.connect(m)}return function(){w.dispose(),s.current=null,o.current=null}},[e]);c.useEffect(()=>()=>{a.current.forEach(v=>v.dispose()),a.current.clear()},[]);const y=c.useCallback(()=>{const v=t.filter(m=>!m.bypassed);if(v.length!==0)return(m,C,w)=>{const g=[];for(const S of v){const I=_t(S.definition,S.params);g.push(I)}if(g.length===0)m.connect(C);else{let S=m;g.forEach(I=>{S.connect(I.effect),S=I.effect}),S.connect(C)}return function(){g.forEach(I=>I.dispose())}}},[t]);return{activeEffects:t,availableEffects:Mt,addEffect:l,removeEffect:u,updateParameter:d,toggleBypass:b,reorderEffects:p,clearAllEffects:f,masterEffects:x,createOfflineEffectsFunction:y,analyserRef:s}}function _i(){const[e,t]=c.useState(new Map),n=c.useRef(new Map),r=c.useRef(new Map),a=c.useCallback((f,x)=>{const y=r.current.get(f);if(!y)return;const{graphEnd:v,masterGainNode:m}=y,C=n.current.get(f);try{v.disconnect()}catch{}const w=x.map(g=>C?.get(g.instanceId)).filter(g=>g!==void 0);if(w.length===0)v.connect(m);else{let g=v;w.forEach(S=>{try{S.disconnect()}catch{}g.connect(S.effect),g=S.effect}),g.connect(m)}},[]),s=c.useCallback((f,x)=>{const y=Wn(x);if(!y){console.error(`Unknown effect: ${x}`);return}const v={};y.parameters.forEach(w=>{v[w.name]=w.default});const m=_t(y,v);n.current.has(f)||n.current.set(f,new Map),n.current.get(f).set(m.instanceId,m);const C={instanceId:m.instanceId,effectId:y.id,definition:y,params:v,bypassed:!1};t(w=>{const g=new Map(w),S=g.get(f)||[];return g.set(f,[...S,C]),g})},[]),o=c.useCallback((f,x)=>{const y=n.current.get(f),v=y?.get(x);v&&(v.dispose(),y?.delete(x)),t(m=>{const C=new Map(m),w=C.get(f)||[];return C.set(f,w.filter(g=>g.instanceId!==x)),C})},[]),i=c.useCallback((f,x,y,v)=>{const C=n.current.get(f)?.get(x);C&&C.setParameter(y,v),t(w=>{const g=new Map(w),S=g.get(f)||[];return g.set(f,S.map(I=>I.instanceId===x?{...I,params:{...I.params,[y]:v}}:I)),g})},[]),l=c.useCallback((f,x)=>{const v=(d.current.get(f)||[]).find(g=>g.instanceId===x);if(!v)return;const m=!v.bypassed,w=n.current.get(f)?.get(x);if(w){const g=v.params.wet??1;w.setParameter("wet",m?0:g)}t(g=>{const S=new Map(g),I=S.get(f)||[];return S.set(f,I.map(E=>E.instanceId===x?{...E,bypassed:m}:E)),S})},[]),u=c.useCallback(f=>{const x=n.current.get(f);x&&(x.forEach(y=>y.dispose()),x.clear()),t(y=>{const v=new Map(y);return v.set(f,[]),v})},[]),d=c.useRef(e);d.current=e;const b=c.useCallback(f=>(x,y,v)=>{r.current.set(f,{graphEnd:x,masterGainNode:y});const m=d.current.get(f)||[],C=n.current.get(f),w=m.map(g=>C?.get(g.instanceId)).filter(g=>g!==void 0);if(w.length===0)x.connect(y);else{let g=x;w.forEach(S=>{g.connect(S.effect),g=S.effect}),g.connect(y)}return function(){r.current.delete(f)}},[]);c.useEffect(()=>{e.forEach((f,x)=>{a(x,f)})},[e,a]),c.useEffect(()=>()=>{n.current.forEach(f=>{f.forEach(x=>x.dispose()),f.clear()}),n.current.clear()},[]);const p=c.useCallback(f=>{const y=(e.get(f)||[]).filter(v=>!v.bypassed);if(y.length!==0)return(v,m,C)=>{const w=[];for(const g of y){const S=_t(g.definition,g.params);w.push(S)}if(w.length===0)v.connect(m);else{let g=v;w.forEach(S=>{g.connect(S.effect),g=S.effect}),g.connect(m)}return function(){w.forEach(S=>S.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:s,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:u,getTrackEffectsFunction:b,createOfflineTrackEffectsFunction:p,availableEffects:Mt}}function Mi(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,a=e.sampleRate,s=e.length,o=n/8,i=r*o,l=a*i,u=s*i,d=44,b=d+u,p=new ArrayBuffer(b),f=new DataView(p);Nt(f,0,"RIFF"),f.setUint32(4,b-8,!0),Nt(f,8,"WAVE"),Nt(f,12,"fmt "),f.setUint32(16,16,!0),f.setUint16(20,n===32?3:1,!0),f.setUint16(22,r,!0),f.setUint32(24,a,!0),f.setUint32(28,l,!0),f.setUint16(32,i,!0),f.setUint16(34,n,!0),Nt(f,36,"data"),f.setUint32(40,u,!0);const x=[];for(let v=0;v<r;v++)x.push(e.getChannelData(v));let y=d;if(n===16)for(let v=0;v<s;v++)for(let m=0;m<r;m++){const C=x[m][v],w=Math.max(-1,Math.min(1,C)),g=w<0?w*32768:w*32767;f.setInt16(y,g,!0),y+=2}else for(let v=0;v<s;v++)for(let m=0;m<r;m++)f.setFloat32(y,x[m][v],!0),y+=4;return new Blob([p],{type:"audio/wav"})}function Nt(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function Bi(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}function ca(){const[e,t]=c.useState(!1),[n,r]=c.useState(0),[a,s]=c.useState(null);return{exportWav:c.useCallback(async(i,l,u={})=>{const{filename:d="export",mode:b="master",trackIndex:p,autoDownload:f=!0,applyEffects:x=!0,effectsFunction:y,createOfflineTrackEffects:v,bitDepth:m=16,onProgress:C}=u;t(!0),r(0),s(null);try{if(i.length===0)throw new Error("No tracks to export");if(b==="individual"&&(p===void 0||p<0||p>=i.length))throw new Error("Invalid track index for individual export");const w=i[0].clips[0]?.audioBuffer.sampleRate||44100;let g=0;for(const T of i)for(const V of T.clips){const W=V.startSample+V.durationSamples;g=Math.max(g,W)}g+=Math.round(w*.1);const S=g/w,I=b==="individual"?[{track:i[p],state:l[p],index:p}]:i.map((T,V)=>({track:T,state:l[V],index:V})),E=l.some(T=>T.soloed),D=!!v;let _;if((y||D)&&x)_=await Fi(I,l,E,S,w,y,v,T=>{r(T),C?.(T)});else{const T=new OfflineAudioContext(2,g,w);let V=0;const W=I.reduce((O,{track:X})=>O+X.clips.length,0);for(const{track:O,state:X}of I)if(!(X.muted&&!X.soloed)&&!(E&&!X.soloed))for(const G of O.clips){await Zi(T,G,X,w,x),V++;const Q=V/W*.5;r(Q),C?.(Q)}r(.5),C?.(.5),_=await T.startRendering()}r(.9),C?.(.9);const B=Mi(_,{bitDepth:m});if(r(1),C?.(1),f){const T=b==="individual"?`${d}_${i[p].name}`:d;Bi(B,`${T}.wav`)}return{audioBuffer:_,blob:B,duration:S}}catch(w){const g=w instanceof Error?w.message:"Export failed";throw s(g),w}finally{t(!1)}},[]),isExporting:e,progress:n,error:a}}async function Fi(e,t,n,r,a,s,o,i){const{Offline:l,Volume:u,Gain:d,Panner:b,Player:p,ToneAudioBuffer:f}=await import("tone");i(.1);let x;try{x=await l(async({transport:y,destination:v})=>{const m=new u(0);let C;s?C=s(m,v,!0):m.connect(v);for(const{track:w,state:g}of e){if(g.muted&&!g.soloed||n&&!g.soloed)continue;const S=new u(Wi(g.volume)),I=new b(g.pan),E=new d(g.muted?0:1),D=o?.(w.id);D?D(E,m,!0):E.connect(m),I.connect(E),S.connect(I);for(const _ of w.clips){const{audioBuffer:B,startSample:T,durationSamples:V,offsetSamples:W,gain:O,fadeIn:X,fadeOut:G}=_,Q=T/a,ne=V/a,L=W/a,oe=new f(B),A=new p(oe),j=new d(O);if(A.connect(j),j.connect(S),X){const H=Q,K=Q+X.duration,be=j.gain._param;be.setValueAtTime(0,H),be.linearRampToValueAtTime(O,K)}if(G){const H=Q+ne-G.duration,K=Q+ne,be=j.gain._param;be.setValueAtTime(O,H),be.linearRampToValueAtTime(0,K)}A.start(Q,L,ne)}}y.start(0)},r,2,a)}catch(y){throw y instanceof Error?y:new Error(`Tone.Offline rendering failed: ${String(y)}`)}return i(.9),x.get()}function Wi(e){return 20*Math.log10(Math.max(e,1e-4))}async function Zi(e,t,n,r,a){const{audioBuffer:s,startSample:o,durationSamples:i,offsetSamples:l,gain:u,fadeIn:d,fadeOut:b}=t,p=o/r,f=i/r,x=l/r,y=e.createBufferSource();y.buffer=s;const v=e.createGain(),m=u*n.volume,C=e.createStereoPanner();if(C.pan.value=n.pan,y.connect(v),v.connect(C),C.connect(e.destination),a){if(d?v.gain.setValueAtTime(0,p):v.gain.setValueAtTime(m,p),d){const w=p,g=p+d.duration;_r(v.gain,w,g,0,m,d.type||"linear")}if(b){const w=p+f-b.duration,g=p+f;(!d||d.duration<f-b.duration)&&v.gain.setValueAtTime(m,w),_r(v.gain,w,g,m,0,b.type||"linear")}}else v.gain.setValueAtTime(m,p);y.start(p,x,f)}function _r(e,t,n,r,a,s){const o=n-t;if(!(o<=0))switch(s){case"linear":e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n);break;case"exponential":const i=Math.max(r,1e-4),l=Math.max(a,1e-4);e.setValueAtTime(i,t),e.exponentialRampToValueAtTime(l,n),a===0&&e.setValueAtTime(0,n);break;case"logarithmic":const u=Mr(r,a,256,"logarithmic");e.setValueCurveAtTime(u,t,o);break;case"sCurve":const d=Mr(r,a,256,"sCurve");e.setValueCurveAtTime(d,t,o);break;default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n)}}function Mr(e,t,n,r){const a=new Float32Array(n),s=t-e;for(let o=0;o<n;o++){const i=o/(n-1);let l;r==="logarithmic"?s>0?l=Math.log10(1+i*9)/Math.log10(10):l=1-Math.log10(1+(1-i)*9)/Math.log10(10):l=i*i*(3-2*i),a[o]=e+s*l}return a}const ua=c.createContext(null),da=c.createContext(null),fa=c.createContext(null),ha=c.createContext(null),ma=c.createContext(null),Pi=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:a=1024,zoomLevels:s,automaticScroll:o=!1,theme:i,controls:l={show:!1,width:0},annotationList:u,effects:d,onReady:b,onAnnotationUpdate:p,barWidth:f=1,barGap:x=0,progressBarWidth:y,children:v})=>{const m=y??f+x,[C,w]=c.useState([]),[g,S]=c.useState(null),[I,E]=c.useState(!1),[D,_]=c.useState(0),[B,T]=c.useState(0),[V,W]=c.useState([]),[O,X]=c.useState([]),[G,Q]=c.useState([]),[ne,L]=c.useState(0),[oe,A]=c.useState(0),[j,H]=c.useState(null),[K,be]=c.useState(o),[Be,ie]=c.useState(u?.isContinuousPlay??!1),[De,ue]=c.useState(u?.linkEndpoints??!0),[he,gt]=c.useState(u?.editable??!1),[ut,de]=c.useState(!1),[rt,at]=c.useState(0),[Ue,ot]=c.useState(0),z=c.useRef(null),Re=c.useRef(0),we=c.useRef(0),ve=c.useRef(null),Ze=c.useRef(G),Le=c.useRef(0),Pe=c.useRef(0),Xe=c.useRef(null),He=c.useRef(null),dt=c.useRef(!1),At=c.useRef(u?.isContinuousPlay??!1),Y=c.useRef(null),ee=c.useRef(a),me=c.useRef(!1),Ie=c.useRef(0),Ee=c.useRef(0),Se=c.useRef(0),le=c.useRef(0),{timeFormat:Ge,setTimeFormat:Ye,formatTime:je}=ta(),_e=na({initialSamplesPerPixel:a,zoomLevels:s}),Ae=_e.samplesPerPixel,{masterVolume:Je,setMasterVolume:ft}=ra({playoutRef:z,initialVolume:1}),Bt=c.useCallback(M=>{At.current=M,ie(M)},[]),st=c.useCallback(M=>{Y.current=M,S(M)},[]),Ft=c.useCallback(M=>{me.current=M,de(M)},[]),ht=c.useCallback((M,N)=>{Se.current=M,le.current=N,at(M),ot(N)},[]),Wt=c.useCallback(()=>{const M=Ie.current,N=Ee.current;M!==N&&N>M&&ht(M,N)},[ht]),Zt=c.useCallback(()=>{ht(0,0)},[ht]);c.useEffect(()=>{dt.current=K},[K]),c.useEffect(()=>{Ze.current=G},[G]),c.useEffect(()=>{Ie.current=ne,Ee.current=oe},[ne,oe]),c.useEffect(()=>{if(!He.current||!V.length)return;const M=He.current,N=ee.current,q=Ae;if(N===q)return;const fe=l.show?l.width:0,ae=M.clientWidth,et=M.scrollLeft+ae/2-fe,ge=V[0].sampleRate,Ke=et*N/ge*ge/q,mt=Math.max(0,Ke+fe-ae/2);M.scrollLeft=mt,ee.current=q},[Ae,V,l]);const bt=c.useRef(null);c.useEffect(()=>{if(e.length===0){W([]),T(0),Q([]),X([]),z.current&&(z.current.dispose(),z.current=null);return}const M=I,N=we.current;return z.current&&M&&(z.current.stop(),ve.current&&(cancelAnimationFrame(ve.current),ve.current=null),bt.current={position:N}),(async()=>{try{const fe=[];e.forEach(ge=>{ge.clips.length>0&&fe.push(ge.clips[0].audioBuffer)});let ae=0;e.forEach(ge=>{ge.clips.forEach($e=>{const Ke=$e.audioBuffer.sampleRate,sn=($e.startSample+$e.durationSamples)/Ke;ae=Math.max(ae,sn)})}),W(fe),T(ae),Q(ge=>ge.length===e.length?ge.map(($e,Ke)=>({...$e,name:e[Ke].name})):e.map($e=>({name:$e.name,muted:$e.muted,soloed:$e.soloed,volume:$e.volume,pan:$e.pan}))),z.current&&z.current.dispose();const ye=new Ma({effects:d}),et=Ze.current;e.forEach((ge,$e)=>{if(ge.clips.length>0){const Ke=ge.clips[0].audioBuffer.sampleRate,mt=Math.min(...ge.clips.map(Ve=>Ve.startSample/Ke)),sn=Math.max(...ge.clips.map(Ve=>(Ve.startSample+Ve.durationSamples)/Ke)),Pt=et[$e],ba={id:`track-${$e}`,name:ge.name,gain:Pt?.volume??ge.volume,muted:Pt?.muted??ge.muted,soloed:Pt?.soloed??ge.soloed,stereoPan:Pt?.pan??ge.pan,startTime:mt,endTime:sn},va=ge.clips.map(Ve=>{const ln=Ve.audioBuffer.sampleRate;return{buffer:Ve.audioBuffer,startTime:Ve.startSample/ln-mt,duration:Ve.durationSamples/ln,offset:Ve.offsetSamples/ln,fadeIn:Ve.fadeIn,fadeOut:Ve.fadeOut,gain:Ve.gain}});ye.addTrack({clips:va,track:ba,effects:ge.effects})}}),ye.applyInitialSoloState(),z.current=ye,b?.()}catch(fe){console.error("Error loading audio:",fe)}})(),()=>{ve.current&&cancelAnimationFrame(ve.current),z.current&&z.current.dispose()}},[e,b,I]),c.useEffect(()=>{if(e.length===0)return;const M=16,N=e.map(q=>q.clips.map(ae=>{const ye=ae.audioBuffer.sampleRate,et=is(ae.audioBuffer,Ae,n,M,ae.offsetSamples/ye,ae.durationSamples/ye);return{clipId:ae.id,trackName:q.name,peaks:et,startSample:ae.startSample,durationSamples:ae.durationSamples,fadeIn:ae.fadeIn,fadeOut:ae.fadeOut}}));X(N)},[e,Ae,n]),c.useEffect(()=>{if(u?.annotations){const M=u.annotations.map(N=>typeof N.start=="number"?N:ps(N));w(M)}},[u]);const qe=c.useCallback(()=>{ve.current&&(cancelAnimationFrame(ve.current),ve.current=null);const M=()=>{const N=P.getContext().currentTime-Le.current,q=Pe.current+N;if(we.current=q,_(q),C.length>0){const ae=C.find(ye=>q>=ye.start&&q<ye.end);if(At.current){if(ae&&ae.id!==Y.current)st(ae.id);else if(!ae&&Y.current!==null){const ye=C[C.length-1];if(q>=ye.end){z.current&&z.current.stop(),E(!1),we.current=Re.current,_(Re.current),st(null);return}}}else if(Y.current){const ye=C.find(et=>et.id===Y.current);if(ye&&q>=ye.end){z.current&&z.current.stop(),E(!1),we.current=Re.current,_(Re.current);return}}else ae&&st(ae.id)}if(dt.current&&He.current&&V.length>0){const ae=He.current,ye=V[0].sampleRate,et=q*ye/ee.current,ge=ae.clientWidth,$e=l.show?l.width:0,Ke=et+$e,mt=Math.max(0,Ke-ge/2);ae.scrollLeft=mt}if(Xe.current!==null&&q>=Xe.current){z.current&&z.current.stop(),E(!1),we.current=Xe.current,_(Xe.current),Xe.current=null;return}const fe=Se.current!==le.current&&le.current>Se.current;if(me.current&&fe&&q>=le.current){z.current?.stop();const ye=P.getContext().currentTime;Le.current=ye,Pe.current=Se.current,we.current=Se.current,z.current?.play(ye,Se.current),ve.current=requestAnimationFrame(M);return}if(q>=B){z.current&&z.current.stop(),E(!1),we.current=Re.current,_(Re.current),st(null);return}ve.current=requestAnimationFrame(M)};ve.current=requestAnimationFrame(M)},[B,V,Ae,C,Be]),Fe=c.useCallback(()=>{ve.current&&(cancelAnimationFrame(ve.current),ve.current=null)},[]);c.useEffect(()=>{(async()=>{if(I&&ve.current&&z.current)if(Be){const N=we.current;z.current.stop(),Fe(),await z.current.init(),z.current.setOnPlaybackComplete(()=>{});const fe=P.getContext().currentTime;Le.current=fe,Pe.current=N,z.current.play(fe,N),qe()}else Fe(),qe()})()},[Be,I,qe,Fe]),c.useEffect(()=>{(async()=>{if(bt.current&&z.current){const{position:N}=bt.current;bt.current=null,await z.current.init(),z.current.setOnPlaybackComplete(()=>{});const fe=P.getContext().currentTime;Le.current=fe,Pe.current=N,z.current.play(fe,N),E(!0),qe()}})()},[e,qe]);const vt=c.useCallback(async(M,N)=>{if(!z.current||V.length===0)return;await z.current.init(),await P.start();const q=M??we.current;Re.current=q,we.current=q,z.current.setOnPlaybackComplete(()=>{}),z.current.stop(),Fe();const ae=P.getContext().currentTime;Le.current=ae,Pe.current=q,Xe.current=N!==void 0?q+N:null,z.current.play(ae,q,N),E(!0),qe()},[V.length,qe,Fe]),nn=c.useCallback(()=>{if(!z.current)return;const M=P.getContext().currentTime-Le.current,N=Pe.current+M;z.current.pause(),E(!1),Fe(),we.current=N,_(N)},[Fe]),rn=c.useCallback(()=>{z.current&&(z.current.stop(),E(!1),Fe(),we.current=Re.current,_(Re.current),st(null))},[Fe]),an=c.useCallback(M=>{const N=Math.max(0,Math.min(M,B));we.current=N,_(N),I&&z.current&&(z.current.stop(),Fe(),vt(N))},[B,I,vt,Fe]),on=c.useCallback((M,N)=>{const q=[...G];if(q[M]={...q[M],muted:N},Q(q),z.current){const fe=`track-${M}`;z.current.setMute(fe,N)}},[G]),h=c.useCallback((M,N)=>{const q=[...G];if(q[M]={...q[M],soloed:N},Q(q),z.current){const fe=`track-${M}`;z.current.setSolo(fe,N)}},[G]),$=c.useCallback((M,N)=>{const q=[...G];if(q[M]={...q[M],volume:N},Q(q),z.current){const fe=`track-${M}`,ae=z.current.getTrack(fe);ae&&ae.setVolume(N)}},[G]),F=c.useCallback((M,N)=>{const q=[...G];if(q[M]={...q[M],pan:N},Q(q),z.current){const fe=`track-${M}`,ae=z.current.getTrack(fe);ae&&ae.setPan(N)}},[G]),U=c.useCallback((M,N)=>{L(M),A(N),we.current=M,_(M),I&&z.current&&(z.current.stop(),z.current.play(P.getContext().currentTime,M))},[I]),se=c.useCallback(M=>{He.current=M},[]),ce=V[0]?.sampleRate||44100,re=t?30:0,te=e.length*r+re,ke={isPlaying:I,currentTime:D,currentTimeRef:we,playbackStartTimeRef:Le,audioStartPositionRef:Pe},pe={continuousPlay:Be,linkEndpoints:De,annotationsEditable:he,isAutomaticScroll:K,isLoopEnabled:ut,annotations:C,activeAnnotationId:g,selectionStart:ne,selectionEnd:oe,selectedTrackId:j,loopStart:rt,loopEnd:Ue},Ce={play:vt,pause:nn,stop:rn,seekTo:an,setCurrentTime:M=>{we.current=M,_(M)},setTrackMute:on,setTrackSolo:h,setTrackVolume:$,setTrackPan:F,setSelection:U,setSelectedTrackId:H,setTimeFormat:Ye,formatTime:je,zoomIn:_e.zoomIn,zoomOut:_e.zoomOut,setMasterVolume:ft,setAutomaticScroll:M=>{be(M)},setScrollContainer:se,scrollContainerRef:He,setContinuousPlay:Bt,setLinkEndpoints:ue,setAnnotationsEditable:gt,setAnnotations:w,setActiveAnnotationId:st,setLoopEnabled:Ft,setLoopRegion:ht,setLoopRegionFromSelection:Wt,clearLoopRegion:Zt},Me={duration:B,audioBuffers:V,peaksDataArray:O,trackStates:G,tracks:e,sampleRate:ce,waveHeight:r,timeScaleHeight:re,minimumPlaylistHeight:te,controls:l,playoutRef:z,samplesPerPixel:Ae,timeFormat:Ge,masterVolume:Je,canZoomIn:_e.canZoomIn,canZoomOut:_e.canZoomOut,barWidth:f,barGap:x,progressBarWidth:m},it={...ke,...pe,...Ce,...Me},Qe={...qa,...i};return Z.jsx(k.ThemeProvider,{theme:Qe,children:Z.jsx(ua.Provider,{value:ke,children:Z.jsx(da.Provider,{value:pe,children:Z.jsx(fa.Provider,{value:Ce,children:Z.jsx(ha.Provider,{value:Me,children:Z.jsx(ma.Provider,{value:it,children:v})})})})})})},We=()=>{const e=c.useContext(ua);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},Ne=()=>{const e=c.useContext(da);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},xe=()=>{const e=c.useContext(fa);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},Te=()=>{const e=c.useContext(ha);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e},Vi=()=>{const e=c.useContext(ma);if(!e)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return e},ji=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=We(),{selectionStart:r,selectionEnd:a,isLoopEnabled:s}=Ne(),{play:o}=xe(),i=async()=>{if(r!==a&&a>r)if(s)await o(r);else{const u=a-r;await o(r,u)}else await o(n.current??0)};return Z.jsx(Oe,{onClick:i,disabled:t,className:e,children:"Play"})},zi=({className:e})=>{const{isPlaying:t}=We(),{pause:n}=xe();return Z.jsx(Oe,{onClick:n,disabled:!t,className:e,children:"Pause"})},Oi=({className:e})=>{const{isPlaying:t}=We(),{stop:n}=xe();return Z.jsx(Oe,{onClick:n,disabled:!t,className:e,children:"Stop"})},Ni=({className:e})=>{const{isPlaying:t}=We(),{play:n,setCurrentTime:r}=xe(),{playoutRef:a}=Te(),s=()=>{r(0),t&&a.current&&(a.current.stop(),n(0))};return Z.jsx(Oe,{onClick:s,className:e,children:"Rewind"})},Li=({className:e})=>{const{isPlaying:t}=We(),{play:n,setCurrentTime:r}=xe(),{duration:a,playoutRef:s}=Te(),o=()=>{r(a),t&&s.current&&(s.current.stop(),n(a))};return Z.jsx(Oe,{onClick:o,className:e,children:"Fast Forward"})},Xi=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=We(),{play:a,setCurrentTime:s}=xe(),{playoutRef:o}=Te(),i=()=>{const l=Math.max(0,(n.current??0)-e);s(l),r&&o.current&&(o.current.stop(),a(l))};return Z.jsx(Oe,{onClick:i,className:t,children:"Skip Backward"})},Hi=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=We(),{play:a,setCurrentTime:s}=xe(),{duration:o,playoutRef:i}=Te(),l=()=>{const u=Math.min(o,(n.current??0)+e);s(u),r&&i.current&&(i.current.stop(),a(u))};return Z.jsx(Oe,{onClick:l,className:t,children:"Skip Forward"})},Gi=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=Ne(),{setLoopEnabled:a,setLoopRegion:s}=xe(),{duration:o}=Te(),i=n!==r&&r>n,l=()=>{if(!t&&!i){const u=Math.min(10,o*.25);s(0,Math.max(1,u))}a(!t)};return Z.jsx(Oe,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},Yi=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:a}=Ne(),{setLoopRegionFromSelection:s,clearLoopRegion:o}=xe(),i=t!==n&&n>t,l=r!==a&&a>r,u=()=>{l?o():s()};return Z.jsx(Oe,{onClick:u,disabled:!i&&!l,className:e,title:l?"Clear loop region":i?"Set loop region from selection":"Create a selection first",children:l?"Clear Loop":"Set Loop"})},Ki=({className:e,disabled:t})=>{const{zoomIn:n}=xe(),{canZoomIn:r}=Te();return Z.jsx(Oe,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},Ui=({className:e,disabled:t})=>{const{zoomOut:n}=xe(),{canZoomOut:r}=Te();return Z.jsx(Oe,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},Ji=({className:e})=>{const{masterVolume:t}=Te(),{setMasterVolume:n}=xe();return Z.jsx(vo,{volume:t,onChange:n,className:e})},qi=({className:e})=>{const{timeFormat:t}=Te(),{setTimeFormat:n}=xe();return Z.jsx(Yo,{value:t,onChange:n,className:e})},Qi=k.span`
1211
+ `,Ni=({level:e,peakLevel:t,width:n=200,height:r=20,className:a})=>{const s=Math.max(0,Math.min(1,e)),o=t!==void 0?Math.max(0,Math.min(1,t)):0;return E.jsxs(Pi,{$width:n,$height:r,className:a,children:[E.jsx(ji,{$level:s,$height:r}),t!==void 0&&o>0&&E.jsx(zi,{$peakLevel:o,$height:r}),E.jsxs(Oi,{$height:r,children:[E.jsx(Tr,{$position:60,$height:r}),E.jsx(Tr,{$position:85,$height:r})]})]})};c.memo(Ni);function Li(e,t,n,r={}){const{currentTime:a=0,audioConstraints:s,...o}=r,[l,i]=c.useState(!1),[u,d]=c.useState(null),{stream:b,devices:p,hasPermission:f,requestAccess:C,error:y}=Wi(),{level:g,peakLevel:m}=Zi(b),{isRecording:w,isPaused:x,duration:v,peaks:S,startRecording:I,stopRecording:$,pauseRecording:M,resumeRecording:T,error:_}=Fi(b,o),D=c.useCallback(async()=>{n&&(l||(await un(),i(!0)),await I())},[n,l,I]),V=c.useCallback(async()=>{const N=await $();if(N&&n){const Y=e.findIndex(H=>H.id===n);if(Y===-1)return;const ee=e[Y],re=Math.floor(a*N.sampleRate);let X=0;if(ee.clips.length>0){const H=ee.clips.map(U=>U.startSample+U.durationSamples);X=Math.max(...H)}const oe=Math.max(re,X),A={id:`clip-${Date.now()}`,audioBuffer:N,startSample:oe,durationSamples:N.length,offsetSamples:0,sampleRate:N.sampleRate,sourceDurationSamples:N.length,gain:1,name:`Recording ${new Date().toLocaleTimeString()}`},j=e.map((H,U)=>U===Y?{...H,clips:[...H.clips,A]}:H);t(j)}},[n,e,t,a,$]);c.useEffect(()=>{f&&p.length>0&&u===null&&d(p[0].deviceId)},[f,p.length]);const W=c.useCallback(async()=>{await C(void 0,s),await un(),i(!0)},[C,s]),O=c.useCallback(async N=>{d(N),await C(N,s),await un(),i(!0)},[C,s]);return{isRecording:w,isPaused:x,duration:v,level:g,peakLevel:m,error:y||_,stream:b,devices:p,hasPermission:f,selectedDevice:u,startRecording:D,stopRecording:V,pauseRecording:M,resumeRecording:T,requestMicAccess:W,changeDevice:O,recordingPeaks:S}}const Mt=[{id:"reverb",name:"Reverb",category:"reverb",description:"Simple convolution reverb with adjustable decay time",parameters:[{name:"decay",label:"Decay",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"s"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"freeverb",name:"Freeverb",category:"reverb",description:"Classic Schroeder/Moorer reverb with room size and dampening",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.7},{name:"dampening",label:"Dampening",type:"number",min:0,max:1e4,step:100,default:3e3,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"jcReverb",name:"JC Reverb",category:"reverb",description:"Attempt at Roland JC-120 chorus reverb emulation",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"feedbackDelay",name:"Feedback Delay",category:"delay",description:"Delay line with feedback for echo effects",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"pingPongDelay",name:"Ping Pong Delay",category:"delay",description:"Stereo delay bouncing between left and right channels",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"chorus",name:"Chorus",category:"modulation",description:"Creates thickness by layering detuned copies of the signal",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"Hz"},{name:"delayTime",label:"Delay",type:"number",min:0,max:20,step:.5,default:3.5,unit:"ms"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.7},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"phaser",name:"Phaser",category:"modulation",description:"Classic phaser effect using allpass filters",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:.5,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:6,step:1,default:3},{name:"baseFrequency",label:"Base Freq",type:"number",min:100,max:2e3,step:10,default:350,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"tremolo",name:"Tremolo",category:"modulation",description:"Rhythmic volume modulation",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:4,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"vibrato",name:"Vibrato",category:"modulation",description:"Pitch modulation effect",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:5,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoPanner",name:"Auto Panner",category:"modulation",description:"Automatic left-right panning",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoFilter",name:"Auto Filter",category:"filter",description:"Automated filter sweep with LFO",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:2e3,step:10,default:200,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:.5,max:8,step:.5,default:2.6},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoWah",name:"Auto Wah",category:"filter",description:"Envelope follower filter effect",parameters:[{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:500,step:10,default:100,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:8,step:1,default:6},{name:"sensitivity",label:"Sensitivity",type:"number",min:-40,max:0,step:1,default:0,unit:"dB"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"eq3",name:"3-Band EQ",category:"filter",description:"Three band equalizer with low, mid, and high controls",parameters:[{name:"low",label:"Low",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"mid",label:"Mid",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"high",label:"High",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"lowFrequency",label:"Low Freq",type:"number",min:20,max:500,step:10,default:400,unit:"Hz"},{name:"highFrequency",label:"High Freq",type:"number",min:1e3,max:1e4,step:100,default:2500,unit:"Hz"}]},{id:"distortion",name:"Distortion",category:"distortion",description:"Wave shaping distortion effect",parameters:[{name:"distortion",label:"Drive",type:"number",min:0,max:1,step:.01,default:.4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"bitCrusher",name:"Bit Crusher",category:"distortion",description:"Reduces bit depth for lo-fi digital texture",parameters:[{name:"bits",label:"Bits",type:"number",min:1,max:16,step:1,default:4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"chebyshev",name:"Chebyshev",category:"distortion",description:"Waveshaping distortion using Chebyshev polynomials",parameters:[{name:"order",label:"Order",type:"number",min:1,max:100,step:1,default:50},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"compressor",name:"Compressor",category:"dynamics",description:"Dynamic range compressor",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-60,max:0,step:1,default:-24,unit:"dB"},{name:"ratio",label:"Ratio",type:"number",min:1,max:20,step:.5,default:4},{name:"attack",label:"Attack",type:"number",min:0,max:1,step:.001,default:.003,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"knee",label:"Knee",type:"number",min:0,max:40,step:1,default:30,unit:"dB"}]},{id:"limiter",name:"Limiter",category:"dynamics",description:"Hard limiter to prevent clipping",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-12,max:0,step:.5,default:-6,unit:"dB"}]},{id:"gate",name:"Gate",category:"dynamics",description:"Noise gate to silence signal below threshold",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-100,max:0,step:1,default:-40,unit:"dB"},{name:"attack",label:"Attack",type:"number",min:0,max:.3,step:.001,default:.001,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:.5,step:.01,default:.1,unit:"s"}]},{id:"stereoWidener",name:"Stereo Widener",category:"spatial",description:"Expands or narrows the stereo image",parameters:[{name:"width",label:"Width",type:"number",min:0,max:1,step:.01,default:.5}]}],Zn=e=>Mt.find(t=>t.id===e),Xi=e=>Mt.filter(t=>t.category===e),Hi=[{id:"reverb",name:"Reverb"},{id:"delay",name:"Delay"},{id:"modulation",name:"Modulation"},{id:"filter",name:"Filter"},{id:"distortion",name:"Distortion"},{id:"dynamics",name:"Dynamics"},{id:"spatial",name:"Spatial"}],Gi={reverb:P.Reverb,freeverb:P.Freeverb,jcReverb:P.JCReverb,feedbackDelay:P.FeedbackDelay,pingPongDelay:P.PingPongDelay,chorus:P.Chorus,phaser:P.Phaser,tremolo:P.Tremolo,vibrato:P.Vibrato,autoPanner:P.AutoPanner,autoFilter:P.AutoFilter,autoWah:P.AutoWah,eq3:P.EQ3,distortion:P.Distortion,bitCrusher:P.BitCrusher,chebyshev:P.Chebyshev,compressor:P.Compressor,limiter:P.Limiter,gate:P.Gate,stereoWidener:P.StereoWidener};let Yi=0;const Ki=()=>`effect_${Date.now()}_${++Yi}`;function _t(e,t){const n=Gi[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(o=>{const l=t?.[o.name]??o.default;r[o.name]=l});const a=new n(r),s=Ki();return{effect:a,id:e.id,instanceId:s,dispose(){try{a.disconnect(),a.dispose()}catch{}},setParameter(o,l){o==="wet"&&a.wet?a.wet.value=l:a[o]!==void 0&&(a[o]?.value!==void 0?a[o].value=l:a[o]=l)},getParameter(o){if(o==="wet"&&a.wet)return a.wet.value;if(a[o]!==void 0)return a[o]?.value!==void 0?a[o].value:a[o]},connect(o){a.connect(o)},disconnect(){try{a.disconnect()}catch{}}}}function Ui(e){if(e.length===0)throw new Error("Cannot create effect chain with no effects");for(let t=0;t<e.length-1;t++)e[t].effect.connect(e[t+1].effect);return{input:e[0].effect,output:e[e.length-1].effect,dispose(){e.forEach(t=>t.dispose())}}}function Ji(e=256){const[t,n]=c.useState([]),r=c.useRef(t);r.current=t;const a=c.useRef(new Map),s=c.useRef(null),o=c.useRef(null),l=c.useCallback(g=>{const m=o.current;if(!m)return;const{masterGainNode:w,destination:x,analyserNode:v}=m;try{w.disconnect()}catch{}const S=g.map(I=>a.current.get(I.instanceId)).filter(I=>I!==void 0);if(S.length===0)w.connect(v),v.connect(x);else{let I=w;S.forEach($=>{try{$.disconnect()}catch{}I.connect($.effect),I=$.effect}),I.connect(v),v.connect(x)}},[]),i=c.useCallback(g=>{const m=Zn(g);if(!m){console.error(`Unknown effect: ${g}`);return}const w={};m.parameters.forEach(S=>{w[S.name]=S.default});const x=_t(m,w);a.current.set(x.instanceId,x);const v={instanceId:x.instanceId,effectId:m.id,definition:m,params:w,bypassed:!1};n(S=>[...S,v])},[]),u=c.useCallback(g=>{const m=a.current.get(g);m&&(m.dispose(),a.current.delete(g)),n(w=>w.filter(x=>x.instanceId!==g))},[]),d=c.useCallback((g,m,w)=>{const x=a.current.get(g);x&&x.setParameter(m,w),n(v=>v.map(S=>S.instanceId===g?{...S,params:{...S.params,[m]:w}}:S))},[]),b=c.useCallback(g=>{const m=r.current.find(v=>v.instanceId===g);if(!m)return;const w=!m.bypassed,x=a.current.get(g);if(x){const v=m.params.wet??1;x.setParameter("wet",w?0:v)}n(v=>v.map(S=>S.instanceId===g?{...S,bypassed:w}:S))},[]),p=c.useCallback((g,m)=>{n(w=>{const x=[...w],[v]=x.splice(g,1);return x.splice(m,0,v),x})},[]),f=c.useCallback(()=>{a.current.forEach(g=>g.dispose()),a.current.clear(),n([])},[]);c.useEffect(()=>{l(t)},[t,l]);const C=c.useCallback((g,m,w)=>{const x=new P.Analyser("fft",e);s.current=x,o.current={masterGainNode:g,destination:m,analyserNode:x};const S=r.current.map(I=>a.current.get(I.instanceId)).filter(I=>I!==void 0);if(S.length===0)g.connect(x),x.connect(m);else{let I=g;S.forEach($=>{I.connect($.effect),I=$.effect}),I.connect(x),x.connect(m)}return function(){x.dispose(),s.current=null,o.current=null}},[e]);c.useEffect(()=>()=>{a.current.forEach(g=>g.dispose()),a.current.clear()},[]);const y=c.useCallback(()=>{const g=t.filter(m=>!m.bypassed);if(g.length!==0)return(m,w,x)=>{const v=[];for(const S of g){const I=_t(S.definition,S.params);v.push(I)}if(v.length===0)m.connect(w);else{let S=m;v.forEach(I=>{S.connect(I.effect),S=I.effect}),S.connect(w)}return function(){v.forEach(I=>I.dispose())}}},[t]);return{activeEffects:t,availableEffects:Mt,addEffect:i,removeEffect:u,updateParameter:d,toggleBypass:b,reorderEffects:p,clearAllEffects:f,masterEffects:C,createOfflineEffectsFunction:y,analyserRef:s}}function qi(){const[e,t]=c.useState(new Map),n=c.useRef(new Map),r=c.useRef(new Map),a=c.useCallback((f,C)=>{const y=r.current.get(f);if(!y)return;const{graphEnd:g,masterGainNode:m}=y,w=n.current.get(f);try{g.disconnect()}catch{}const x=C.map(v=>w?.get(v.instanceId)).filter(v=>v!==void 0);if(x.length===0)g.connect(m);else{let v=g;x.forEach(S=>{try{S.disconnect()}catch{}v.connect(S.effect),v=S.effect}),v.connect(m)}},[]),s=c.useCallback((f,C)=>{const y=Zn(C);if(!y){console.error(`Unknown effect: ${C}`);return}const g={};y.parameters.forEach(x=>{g[x.name]=x.default});const m=_t(y,g);n.current.has(f)||n.current.set(f,new Map),n.current.get(f).set(m.instanceId,m);const w={instanceId:m.instanceId,effectId:y.id,definition:y,params:g,bypassed:!1};t(x=>{const v=new Map(x),S=v.get(f)||[];return v.set(f,[...S,w]),v})},[]),o=c.useCallback((f,C)=>{const y=n.current.get(f),g=y?.get(C);g&&(g.dispose(),y?.delete(C)),t(m=>{const w=new Map(m),x=w.get(f)||[];return w.set(f,x.filter(v=>v.instanceId!==C)),w})},[]),l=c.useCallback((f,C,y,g)=>{const w=n.current.get(f)?.get(C);w&&w.setParameter(y,g),t(x=>{const v=new Map(x),S=v.get(f)||[];return v.set(f,S.map(I=>I.instanceId===C?{...I,params:{...I.params,[y]:g}}:I)),v})},[]),i=c.useCallback((f,C)=>{const g=(d.current.get(f)||[]).find(v=>v.instanceId===C);if(!g)return;const m=!g.bypassed,x=n.current.get(f)?.get(C);if(x){const v=g.params.wet??1;x.setParameter("wet",m?0:v)}t(v=>{const S=new Map(v),I=S.get(f)||[];return S.set(f,I.map($=>$.instanceId===C?{...$,bypassed:m}:$)),S})},[]),u=c.useCallback(f=>{const C=n.current.get(f);C&&(C.forEach(y=>y.dispose()),C.clear()),t(y=>{const g=new Map(y);return g.set(f,[]),g})},[]),d=c.useRef(e);d.current=e;const b=c.useCallback(f=>(C,y,g)=>{r.current.set(f,{graphEnd:C,masterGainNode:y});const m=d.current.get(f)||[],w=n.current.get(f),x=m.map(v=>w?.get(v.instanceId)).filter(v=>v!==void 0);if(x.length===0)C.connect(y);else{let v=C;x.forEach(S=>{v.connect(S.effect),v=S.effect}),v.connect(y)}return function(){r.current.delete(f)}},[]);c.useEffect(()=>{e.forEach((f,C)=>{a(C,f)})},[e,a]),c.useEffect(()=>()=>{n.current.forEach(f=>{f.forEach(C=>C.dispose()),f.clear()}),n.current.clear()},[]);const p=c.useCallback(f=>{const y=(e.get(f)||[]).filter(g=>!g.bypassed);if(y.length!==0)return(g,m,w)=>{const x=[];for(const v of y){const S=_t(v.definition,v.params);x.push(S)}if(x.length===0)g.connect(m);else{let v=g;x.forEach(S=>{v.connect(S.effect),v=S.effect}),v.connect(m)}return function(){x.forEach(S=>S.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:s,removeEffectFromTrack:o,updateTrackEffectParameter:l,toggleBypass:i,clearTrackEffects:u,getTrackEffectsFunction:b,createOfflineTrackEffectsFunction:p,availableEffects:Mt}}function Qi(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,a=e.sampleRate,s=e.length,o=n/8,l=r*o,i=a*l,u=s*l,d=44,b=d+u,p=new ArrayBuffer(b),f=new DataView(p);Lt(f,0,"RIFF"),f.setUint32(4,b-8,!0),Lt(f,8,"WAVE"),Lt(f,12,"fmt "),f.setUint32(16,16,!0),f.setUint16(20,n===32?3:1,!0),f.setUint16(22,r,!0),f.setUint32(24,a,!0),f.setUint32(28,i,!0),f.setUint16(32,l,!0),f.setUint16(34,n,!0),Lt(f,36,"data"),f.setUint32(40,u,!0);const C=[];for(let g=0;g<r;g++)C.push(e.getChannelData(g));let y=d;if(n===16)for(let g=0;g<s;g++)for(let m=0;m<r;m++){const w=C[m][g],x=Math.max(-1,Math.min(1,w)),v=x<0?x*32768:x*32767;f.setInt16(y,v,!0),y+=2}else for(let g=0;g<s;g++)for(let m=0;m<r;m++)f.setFloat32(y,C[m][g],!0),y+=4;return new Blob([p],{type:"audio/wav"})}function Lt(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function el(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}function da(){const[e,t]=c.useState(!1),[n,r]=c.useState(0),[a,s]=c.useState(null);return{exportWav:c.useCallback(async(l,i,u={})=>{const{filename:d="export",mode:b="master",trackIndex:p,autoDownload:f=!0,applyEffects:C=!0,effectsFunction:y,createOfflineTrackEffects:g,bitDepth:m=16,onProgress:w}=u;t(!0),r(0),s(null);try{if(l.length===0)throw new Error("No tracks to export");if(b==="individual"&&(p===void 0||p<0||p>=l.length))throw new Error("Invalid track index for individual export");const x=l[0].clips[0]?.sampleRate||44100;let v=0;for(const D of l)for(const V of D.clips){const W=V.startSample+V.durationSamples;v=Math.max(v,W)}v+=Math.round(x*.1);const S=v/x,I=b==="individual"?[{track:l[p],state:i[p],index:p}]:l.map((D,V)=>({track:D,state:i[V],index:V})),$=i.some(D=>D.soloed),M=!!g;let T;if((y||M)&&C)T=await tl(I,i,$,S,x,y,g,D=>{r(D),w?.(D)});else{const D=new OfflineAudioContext(2,v,x);let V=0;const W=I.reduce((O,{track:N})=>O+N.clips.length,0);for(const{track:O,state:N}of I)if(!(N.muted&&!N.soloed)&&!($&&!N.soloed))for(const Y of O.clips){await rl(D,Y,N,x,C),V++;const ee=V/W*.5;r(ee),w?.(ee)}r(.5),w?.(.5),T=await D.startRendering()}r(.9),w?.(.9);const _=Qi(T,{bitDepth:m});if(r(1),w?.(1),f){const D=b==="individual"?`${d}_${l[p].name}`:d;el(_,`${D}.wav`)}return{audioBuffer:T,blob:_,duration:S}}catch(x){const v=x instanceof Error?x.message:"Export failed";throw s(v),x}finally{t(!1)}},[]),isExporting:e,progress:n,error:a}}async function tl(e,t,n,r,a,s,o,l){const{Offline:i,Volume:u,Gain:d,Panner:b,Player:p,ToneAudioBuffer:f}=await import("tone");l(.1);let C;try{C=await i(async({transport:y,destination:g})=>{const m=new u(0);let w;s?w=s(m,g,!0):m.connect(g);for(const{track:x,state:v}of e){if(v.muted&&!v.soloed||n&&!v.soloed)continue;const S=new u(nl(v.volume)),I=new b(v.pan),$=new d(v.muted?0:1),M=o?.(x.id);M?M($,m,!0):$.connect(m),I.connect($),S.connect(I);for(const T of x.clips){const{audioBuffer:_,startSample:D,durationSamples:V,offsetSamples:W,gain:O,fadeIn:N,fadeOut:Y}=T,ee=D/a,re=V/a,X=W/a,oe=new f(_),A=new p(oe),j=new d(O);if(A.connect(j),j.connect(S),N){const H=ee,U=ee+N.duration,ge=j.gain._param;ge.setValueAtTime(0,H),ge.linearRampToValueAtTime(O,U)}if(Y){const H=ee+re-Y.duration,U=ee+re,ge=j.gain._param;ge.setValueAtTime(O,H),ge.linearRampToValueAtTime(0,U)}A.start(ee,X,re)}}y.start(0)},r,2,a)}catch(y){throw y instanceof Error?y:new Error(`Tone.Offline rendering failed: ${String(y)}`)}return l(.9),C.get()}function nl(e){return 20*Math.log10(Math.max(e,1e-4))}async function rl(e,t,n,r,a){const{audioBuffer:s,startSample:o,durationSamples:l,offsetSamples:i,gain:u,fadeIn:d,fadeOut:b}=t;if(!s){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const p=o/r,f=l/r,C=i/r,y=e.createBufferSource();y.buffer=s;const g=e.createGain(),m=u*n.volume,w=e.createStereoPanner();if(w.pan.value=n.pan,y.connect(g),g.connect(w),w.connect(e.destination),a){if(d?g.gain.setValueAtTime(0,p):g.gain.setValueAtTime(m,p),d){const x=p,v=p+d.duration;_r(g.gain,x,v,0,m,d.type||"linear")}if(b){const x=p+f-b.duration,v=p+f;(!d||d.duration<f-b.duration)&&g.gain.setValueAtTime(m,x),_r(g.gain,x,v,m,0,b.type||"linear")}}else g.gain.setValueAtTime(m,p);y.start(p,C,f)}function _r(e,t,n,r,a,s){const o=n-t;if(!(o<=0))switch(s){case"linear":e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n);break;case"exponential":const l=Math.max(r,1e-4),i=Math.max(a,1e-4);e.setValueAtTime(l,t),e.exponentialRampToValueAtTime(i,n),a===0&&e.setValueAtTime(0,n);break;case"logarithmic":const u=Mr(r,a,256,"logarithmic");e.setValueCurveAtTime(u,t,o);break;case"sCurve":const d=Mr(r,a,256,"sCurve");e.setValueCurveAtTime(d,t,o);break;default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n)}}function Mr(e,t,n,r){const a=new Float32Array(n),s=t-e;for(let o=0;o<n;o++){const l=o/(n-1);let i;r==="logarithmic"?s>0?i=Math.log10(1+l*9)/Math.log10(10):i=1-Math.log10(1+(1-l)*9)/Math.log10(10):i=l*l*(3-2*l),a[o]=e+s*i}return a}const fa=c.createContext(null),ma=c.createContext(null),ha=c.createContext(null),pa=c.createContext(null),ga=c.createContext(null),al=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:a=1024,zoomLevels:s,automaticScroll:o=!1,theme:l,controls:i={show:!1,width:0},annotationList:u,effects:d,onReady:b,onAnnotationUpdate:p,barWidth:f=1,barGap:C=0,progressBarWidth:y,children:g})=>{const m=y??f+C,[w,x]=c.useState([]),[v,S]=c.useState(null),[I,$]=c.useState(!1),[M,T]=c.useState(0),[_,D]=c.useState(0),[V,W]=c.useState([]),[O,N]=c.useState([]),[Y,ee]=c.useState([]),[re,X]=c.useState(0),[oe,A]=c.useState(0),[j,H]=c.useState(null),[U,ge]=c.useState(o),[Be,ie]=c.useState(u?.isContinuousPlay??!1),[Te,ue]=c.useState(u?.linkEndpoints??!0),[me,gt]=c.useState(u?.editable??!1),[dt,de]=c.useState(!1),[at,ot]=c.useState(0),[Je,st]=c.useState(0),z=c.useRef(null),Re=c.useRef(0),xe=c.useRef(0),be=c.useRef(null),Ze=c.useRef(Y),Xe=c.useRef(0),Pe=c.useRef(0),He=c.useRef(null),Ge=c.useRef(null),ft=c.useRef(!1),At=c.useRef(u?.isContinuousPlay??!1),K=c.useRef(null),te=c.useRef(a),he=c.useRef(!1),ye=c.useRef(0),Ee=c.useRef(0),Ae=c.useRef(0),le=c.useRef(0),{timeFormat:Ye,setTimeFormat:Ke,formatTime:ze}=ra(),_e=aa({initialSamplesPerPixel:a,zoomLevels:s}),Ie=_e.samplesPerPixel,{masterVolume:qe,setMasterVolume:mt}=oa({playoutRef:z,initialVolume:1}),Bt=c.useCallback(B=>{At.current=B,ie(B)},[]),it=c.useCallback(B=>{K.current=B,S(B)},[]),Ft=c.useCallback(B=>{he.current=B,de(B)},[]),ht=c.useCallback((B,L)=>{Ae.current=B,le.current=L,ot(B),st(L)},[]),Wt=c.useCallback(()=>{const B=ye.current,L=Ee.current;B!==L&&L>B&&ht(B,L)},[ht]),Zt=c.useCallback(()=>{ht(0,0)},[ht]);c.useEffect(()=>{ft.current=U},[U]),c.useEffect(()=>{Ze.current=Y},[Y]),c.useEffect(()=>{ye.current=re,Ee.current=oe},[re,oe]),c.useEffect(()=>{if(!Ge.current||!V.length)return;const B=Ge.current,L=te.current,q=Ie;if(L===q)return;const fe=i.show?i.width:0,G=B.clientWidth,Ue=B.scrollLeft+G/2-fe,Ce=V[0].sampleRate,Ve=Ue*L/Ce*Ce/q,tt=Math.max(0,Ve+fe-G/2);B.scrollLeft=tt,te.current=q},[Ie,V,i]);const bt=c.useRef(null);c.useEffect(()=>{if(e.length===0){W([]),D(0),ee([]),N([]),z.current&&(z.current.dispose(),z.current=null);return}const B=I,L=xe.current;return z.current&&B&&(z.current.stop(),be.current&&(cancelAnimationFrame(be.current),be.current=null),bt.current={position:L}),(async()=>{try{const fe=[];e.forEach(Ce=>{Ce.clips.length>0&&Ce.clips[0].audioBuffer&&fe.push(Ce.clips[0].audioBuffer)});let G=0;e.forEach(Ce=>{Ce.clips.forEach($e=>{const Ve=$e.sampleRate,Pt=($e.startSample+$e.durationSamples)/Ve;G=Math.max(G,Pt)})}),W(fe),D(G),ee(Ce=>Ce.length===e.length?Ce.map(($e,Ve)=>({...$e,name:e[Ve].name})):e.map($e=>({name:$e.name,muted:$e.muted,soloed:$e.soloed,volume:$e.volume,pan:$e.pan}))),z.current&&z.current.dispose();const Se=new Ba({effects:d}),Ue=Ze.current;e.forEach((Ce,$e)=>{const Ve=Ce.clips.filter(tt=>tt.audioBuffer);if(Ve.length>0){const tt=Ve[0].sampleRate,Pt=Math.min(...Ve.map(je=>je.startSample/tt)),ba=Math.max(...Ve.map(je=>(je.startSample+je.durationSamples)/tt)),Vt=Ue[$e],va={id:`track-${$e}`,name:Ce.name,gain:Vt?.volume??Ce.volume,muted:Vt?.muted??Ce.muted,soloed:Vt?.soloed??Ce.soloed,stereoPan:Vt?.pan??Ce.pan,startTime:Pt,endTime:ba},Ca=Ve.map(je=>{const ln=je.sampleRate;return{buffer:je.audioBuffer,startTime:je.startSample/ln-Pt,duration:je.durationSamples/ln,offset:je.offsetSamples/ln,fadeIn:je.fadeIn,fadeOut:je.fadeOut,gain:je.gain}});Se.addTrack({clips:Ca,track:va,effects:Ce.effects})}}),Se.applyInitialSoloState(),z.current=Se,b?.()}catch(fe){console.error("Error loading audio:",fe)}})(),()=>{be.current&&cancelAnimationFrame(be.current),z.current&&z.current.dispose()}},[e,b,I]),c.useEffect(()=>{if(e.length===0)return;const B=16,L=e.map(q=>q.clips.map(G=>{if(G.waveformData){const Ue=$s(G.waveformData,Ie,0,G.offsetSamples,G.durationSamples);return{clipId:G.id,trackName:q.name,peaks:{length:Ue.length,data:[Ue.data],bits:Ue.bits},startSample:G.startSample,durationSamples:G.durationSamples,fadeIn:G.fadeIn,fadeOut:G.fadeOut}}if(!G.audioBuffer)return console.warn(`Clip "${G.name||G.id}" has neither waveformData nor audioBuffer - rendering empty`),{clipId:G.id,trackName:q.name,peaks:{length:0,data:[],bits:B},startSample:G.startSample,durationSamples:G.durationSamples,fadeIn:G.fadeIn,fadeOut:G.fadeOut};const Se=ls(G.audioBuffer,Ie,n,B,G.offsetSamples,G.durationSamples);return{clipId:G.id,trackName:q.name,peaks:Se,startSample:G.startSample,durationSamples:G.durationSamples,fadeIn:G.fadeIn,fadeOut:G.fadeOut}}));N(L)},[e,Ie,n]),c.useEffect(()=>{if(u?.annotations){const B=u.annotations.map(L=>typeof L.start=="number"?L:Fs(L));x(B)}},[u]);const Qe=c.useCallback(()=>{be.current&&(cancelAnimationFrame(be.current),be.current=null);const B=()=>{const L=P.getContext().currentTime-Xe.current,q=Pe.current+L;if(xe.current=q,T(q),w.length>0){const G=w.find(Se=>q>=Se.start&&q<Se.end);if(At.current){if(G&&G.id!==K.current)it(G.id);else if(!G&&K.current!==null){const Se=w[w.length-1];if(q>=Se.end){z.current&&z.current.stop(),$(!1),xe.current=Re.current,T(Re.current),it(null);return}}}else if(K.current){const Se=w.find(Ue=>Ue.id===K.current);if(Se&&q>=Se.end){z.current&&z.current.stop(),$(!1),xe.current=Re.current,T(Re.current);return}}else G&&it(G.id)}if(ft.current&&Ge.current&&V.length>0){const G=Ge.current,Se=V[0].sampleRate,Ue=q*Se/te.current,Ce=G.clientWidth,$e=i.show?i.width:0,Ve=Ue+$e,tt=Math.max(0,Ve-Ce/2);G.scrollLeft=tt}if(He.current!==null&&q>=He.current){z.current&&z.current.stop(),$(!1),xe.current=He.current,T(He.current),He.current=null;return}const fe=Ae.current!==le.current&&le.current>Ae.current;if(he.current&&fe&&q>=le.current){z.current?.stop();const Se=P.getContext().currentTime;Xe.current=Se,Pe.current=Ae.current,xe.current=Ae.current,z.current?.play(Se,Ae.current),be.current=requestAnimationFrame(B);return}if(q>=_){z.current&&z.current.stop(),$(!1),xe.current=Re.current,T(Re.current),it(null);return}be.current=requestAnimationFrame(B)};be.current=requestAnimationFrame(B)},[_,V,Ie,w,Be]),Fe=c.useCallback(()=>{be.current&&(cancelAnimationFrame(be.current),be.current=null)},[]);c.useEffect(()=>{(async()=>{if(I&&be.current&&z.current)if(Be){const L=xe.current;z.current.stop(),Fe(),await z.current.init(),z.current.setOnPlaybackComplete(()=>{});const fe=P.getContext().currentTime;Xe.current=fe,Pe.current=L,z.current.play(fe,L),Qe()}else Fe(),Qe()})()},[Be,I,Qe,Fe]),c.useEffect(()=>{(async()=>{if(bt.current&&z.current){const{position:L}=bt.current;bt.current=null,await z.current.init(),z.current.setOnPlaybackComplete(()=>{});const fe=P.getContext().currentTime;Xe.current=fe,Pe.current=L,z.current.play(fe,L),$(!0),Qe()}})()},[e,Qe]);const vt=c.useCallback(async(B,L)=>{if(!z.current||V.length===0)return;await z.current.init(),await P.start();const q=B??xe.current;Re.current=q,xe.current=q,z.current.setOnPlaybackComplete(()=>{}),z.current.stop(),Fe();const G=P.getContext().currentTime;Xe.current=G,Pe.current=q,He.current=L!==void 0?q+L:null,z.current.play(G,q,L),$(!0),Qe()},[V.length,Qe,Fe]),rn=c.useCallback(()=>{if(!z.current)return;const B=P.getContext().currentTime-Xe.current,L=Pe.current+B;z.current.pause(),$(!1),Fe(),xe.current=L,T(L)},[Fe]),an=c.useCallback(()=>{z.current&&(z.current.stop(),$(!1),Fe(),xe.current=Re.current,T(Re.current),it(null))},[Fe]),on=c.useCallback(B=>{const L=Math.max(0,Math.min(B,_));xe.current=L,T(L),I&&z.current&&(z.current.stop(),Fe(),vt(L))},[_,I,vt,Fe]),sn=c.useCallback((B,L)=>{const q=[...Y];if(q[B]={...q[B],muted:L},ee(q),z.current){const fe=`track-${B}`;z.current.setMute(fe,L)}},[Y]),h=c.useCallback((B,L)=>{const q=[...Y];if(q[B]={...q[B],soloed:L},ee(q),z.current){const fe=`track-${B}`;z.current.setSolo(fe,L)}},[Y]),R=c.useCallback((B,L)=>{const q=[...Y];if(q[B]={...q[B],volume:L},ee(q),z.current){const fe=`track-${B}`,G=z.current.getTrack(fe);G&&G.setVolume(L)}},[Y]),F=c.useCallback((B,L)=>{const q=[...Y];if(q[B]={...q[B],pan:L},ee(q),z.current){const fe=`track-${B}`,G=z.current.getTrack(fe);G&&G.setPan(L)}},[Y]),J=c.useCallback((B,L)=>{X(B),A(L),xe.current=B,T(B),I&&z.current&&(z.current.stop(),z.current.play(P.getContext().currentTime,B))},[I]),se=c.useCallback(B=>{Ge.current=B},[]),ce=V[0]?.sampleRate||44100,ae=t?30:0,ne=e.length*r+ae,ke={isPlaying:I,currentTime:M,currentTimeRef:xe,playbackStartTimeRef:Xe,audioStartPositionRef:Pe},pe={continuousPlay:Be,linkEndpoints:Te,annotationsEditable:me,isAutomaticScroll:U,isLoopEnabled:dt,annotations:w,activeAnnotationId:v,selectionStart:re,selectionEnd:oe,selectedTrackId:j,loopStart:at,loopEnd:Je},ve={play:vt,pause:rn,stop:an,seekTo:on,setCurrentTime:B=>{xe.current=B,T(B)},setTrackMute:sn,setTrackSolo:h,setTrackVolume:R,setTrackPan:F,setSelection:J,setSelectedTrackId:H,setTimeFormat:Ke,formatTime:ze,zoomIn:_e.zoomIn,zoomOut:_e.zoomOut,setMasterVolume:mt,setAutomaticScroll:B=>{ge(B)},setScrollContainer:se,scrollContainerRef:Ge,setContinuousPlay:Bt,setLinkEndpoints:ue,setAnnotationsEditable:gt,setAnnotations:x,setActiveAnnotationId:it,setLoopEnabled:Ft,setLoopRegion:ht,setLoopRegionFromSelection:Wt,clearLoopRegion:Zt},Me={duration:_,audioBuffers:V,peaksDataArray:O,trackStates:Y,tracks:e,sampleRate:ce,waveHeight:r,timeScaleHeight:ae,minimumPlaylistHeight:ne,controls:i,playoutRef:z,samplesPerPixel:Ie,timeFormat:Ye,masterVolume:qe,canZoomIn:_e.canZoomIn,canZoomOut:_e.canZoomOut,barWidth:f,barGap:C,progressBarWidth:m},lt={...ke,...pe,...ve,...Me},et={...Qa,...l};return Z.jsx(k.ThemeProvider,{theme:et,children:Z.jsx(fa.Provider,{value:ke,children:Z.jsx(ma.Provider,{value:pe,children:Z.jsx(ha.Provider,{value:ve,children:Z.jsx(pa.Provider,{value:Me,children:Z.jsx(ga.Provider,{value:lt,children:g})})})})})})},We=()=>{const e=c.useContext(fa);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},Le=()=>{const e=c.useContext(ma);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},we=()=>{const e=c.useContext(ha);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},De=()=>{const e=c.useContext(pa);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e},ol=()=>{const e=c.useContext(ga);if(!e)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return e},sl=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=We(),{selectionStart:r,selectionEnd:a,isLoopEnabled:s}=Le(),{play:o}=we(),l=async()=>{if(r!==a&&a>r)if(s)await o(r);else{const u=a-r;await o(r,u)}else await o(n.current??0)};return Z.jsx(Ne,{onClick:l,disabled:t,className:e,children:"Play"})},il=({className:e})=>{const{isPlaying:t}=We(),{pause:n}=we();return Z.jsx(Ne,{onClick:n,disabled:!t,className:e,children:"Pause"})},ll=({className:e})=>{const{isPlaying:t}=We(),{stop:n}=we();return Z.jsx(Ne,{onClick:n,disabled:!t,className:e,children:"Stop"})},cl=({className:e})=>{const{isPlaying:t}=We(),{play:n,setCurrentTime:r}=we(),{playoutRef:a}=De(),s=()=>{r(0),t&&a.current&&(a.current.stop(),n(0))};return Z.jsx(Ne,{onClick:s,className:e,children:"Rewind"})},ul=({className:e})=>{const{isPlaying:t}=We(),{play:n,setCurrentTime:r}=we(),{duration:a,playoutRef:s}=De(),o=()=>{r(a),t&&s.current&&(s.current.stop(),n(a))};return Z.jsx(Ne,{onClick:o,className:e,children:"Fast Forward"})},dl=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=We(),{play:a,setCurrentTime:s}=we(),{playoutRef:o}=De(),l=()=>{const i=Math.max(0,(n.current??0)-e);s(i),r&&o.current&&(o.current.stop(),a(i))};return Z.jsx(Ne,{onClick:l,className:t,children:"Skip Backward"})},fl=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=We(),{play:a,setCurrentTime:s}=we(),{duration:o,playoutRef:l}=De(),i=()=>{const u=Math.min(o,(n.current??0)+e);s(u),r&&l.current&&(l.current.stop(),a(u))};return Z.jsx(Ne,{onClick:i,className:t,children:"Skip Forward"})},ml=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=Le(),{setLoopEnabled:a,setLoopRegion:s}=we(),{duration:o}=De(),l=n!==r&&r>n,i=()=>{if(!t&&!l){const u=Math.min(10,o*.25);s(0,Math.max(1,u))}a(!t)};return Z.jsx(Ne,{onClick:i,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},hl=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:a}=Le(),{setLoopRegionFromSelection:s,clearLoopRegion:o}=we(),l=t!==n&&n>t,i=r!==a&&a>r,u=()=>{i?o():s()};return Z.jsx(Ne,{onClick:u,disabled:!l&&!i,className:e,title:i?"Clear loop region":l?"Set loop region from selection":"Create a selection first",children:i?"Clear Loop":"Set Loop"})},pl=({className:e,disabled:t})=>{const{zoomIn:n}=we(),{canZoomIn:r}=De();return Z.jsx(Ne,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},gl=({className:e,disabled:t})=>{const{zoomOut:n}=we(),{canZoomOut:r}=De();return Z.jsx(Ne,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},bl=({className:e})=>{const{masterVolume:t}=De(),{setMasterVolume:n}=we();return Z.jsx(Co,{volume:t,onChange:n,className:e})},vl=({className:e})=>{const{timeFormat:t}=De(),{setTimeFormat:n}=we();return Z.jsx(Ko,{value:t,onChange:n,className:e})},Cl=k.span`
1211
1212
  font-family: 'Courier New', Monaco, monospace;
1212
1213
  font-size: 1rem;
1213
1214
  font-weight: 600;
1214
1215
  color: ${e=>e.theme?.textColor||"#333"};
1215
1216
  user-select: none;
1216
- `,el=({className:e})=>{const t=c.useRef(null),n=c.useRef(null),{isPlaying:r,currentTimeRef:a,playbackStartTimeRef:s,audioStartPositionRef:o}=We(),{timeFormat:i}=Te(),l=i;return c.useEffect(()=>{const u=()=>{if(t.current){let d;if(r){const b=P.getContext().currentTime-(s.current??0);d=(o.current??0)+b}else d=a.current??0;t.current.textContent=It(d,l)}r&&(n.current=requestAnimationFrame(u))};return r?n.current=requestAnimationFrame(u):u(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,l,a,s,o]),c.useEffect(()=>{!r&&t.current&&(t.current.textContent=It(a.current??0,l))}),Z.jsx(Qi,{ref:t,className:e,"aria-label":"Audio position",children:It(a.current??0,l)})},tl=({className:e})=>{const{selectionStart:t,selectionEnd:n}=Ne(),{setSelection:r}=xe();return Z.jsx(To,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},nl=({className:e})=>{const{isAutomaticScroll:t}=Ne(),{setAutomaticScroll:n}=xe();return Z.jsx(Ja,{checked:t,onChange:n,className:e})},rl=({className:e})=>{const{continuousPlay:t}=Ne(),{setContinuousPlay:n}=xe();return Z.jsx(Ws,{checked:t,onChange:n,className:e})},al=({className:e})=>{const{linkEndpoints:t}=Ne(),{setLinkEndpoints:n}=xe();return Z.jsx(Zs,{checked:t,onChange:n,className:e})},ol=({className:e})=>{const{annotationsEditable:t}=Ne(),{setAnnotationsEditable:n}=xe();return Z.jsx(Ps,{checked:t,onChange:n,className:e})},sl=({filename:e,className:t})=>{const{annotations:n}=Ne();return Z.jsx(js,{annotations:n,filename:e,className:t})},il=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:r,bitDepth:a=16,applyEffects:s=!0,effectsFunction:o,createOfflineTrackEffects:i,className:l,onExportComplete:u,onExportError:d})=>{const{tracks:b,trackStates:p}=Te(),{exportWav:f,isExporting:x,progress:y}=ca(),v=async()=>{try{const C=await f(b,p,{filename:t,mode:n,trackIndex:r,bitDepth:a,applyEffects:s,effectsFunction:o,createOfflineTrackEffects:i,autoDownload:!0});u?.(C.blob)}catch(C){d?.(C instanceof Error?C:new Error("Export failed"))}},m=x?`Exporting ${Math.round(y*100)}%`:e;return Z.jsx(Oe,{onClick:v,disabled:x||b.length===0,className:l,children:m})},ll=k.div`
1217
+ `,wl=({className:e})=>{const t=c.useRef(null),n=c.useRef(null),{isPlaying:r,currentTimeRef:a,playbackStartTimeRef:s,audioStartPositionRef:o}=We(),{timeFormat:l}=De(),i=l;return c.useEffect(()=>{const u=()=>{if(t.current){let d;if(r){const b=P.getContext().currentTime-(s.current??0);d=(o.current??0)+b}else d=a.current??0;t.current.textContent=It(d,i)}r&&(n.current=requestAnimationFrame(u))};return r?n.current=requestAnimationFrame(u):u(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,i,a,s,o]),c.useEffect(()=>{!r&&t.current&&(t.current.textContent=It(a.current??0,i))}),Z.jsx(Cl,{ref:t,className:e,"aria-label":"Audio position",children:It(a.current??0,i)})},xl=({className:e})=>{const{selectionStart:t,selectionEnd:n}=Le(),{setSelection:r}=we();return Z.jsx(To,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},yl=({className:e})=>{const{isAutomaticScroll:t}=Le(),{setAutomaticScroll:n}=we();return Z.jsx(qa,{checked:t,onChange:n,className:e})},Il=({className:e})=>{const{continuousPlay:t}=Le(),{setContinuousPlay:n}=we();return Z.jsx(ni,{checked:t,onChange:n,className:e})},Sl=({className:e})=>{const{linkEndpoints:t}=Le(),{setLinkEndpoints:n}=we();return Z.jsx(ri,{checked:t,onChange:n,className:e})},Al=({className:e})=>{const{annotationsEditable:t}=Le(),{setAnnotationsEditable:n}=we();return Z.jsx(ai,{checked:t,onChange:n,className:e})},kl=({filename:e,className:t})=>{const{annotations:n}=Le();return Z.jsx(si,{annotations:n,filename:e,className:t})},$l=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:r,bitDepth:a=16,applyEffects:s=!0,effectsFunction:o,createOfflineTrackEffects:l,className:i,onExportComplete:u,onExportError:d})=>{const{tracks:b,trackStates:p}=De(),{exportWav:f,isExporting:C,progress:y}=da(),g=async()=>{try{const w=await f(b,p,{filename:t,mode:n,trackIndex:r,bitDepth:a,applyEffects:s,effectsFunction:o,createOfflineTrackEffects:l,autoDownload:!0});u?.(w.blob)}catch(w){d?.(w instanceof Error?w:new Error("Export failed"))}},m=C?`Exporting ${Math.round(y*100)}%`:e;return Z.jsx(Ne,{onClick:g,disabled:C||b.length===0,className:i,children:m})},Rl=k.div`
1217
1218
  position: absolute;
1218
1219
  top: 0;
1219
1220
  left: 0;
@@ -1223,9 +1224,9 @@ React keys must be passed directly to JSX without using spread:
1223
1224
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
1224
1225
  pointer-events: none;
1225
1226
  will-change: transform;
1226
- `,cl=({color:e="#ff0000",controlsOffset:t=0})=>{const n=c.useRef(null),r=c.useRef(null),{isPlaying:a,currentTimeRef:s,playbackStartTimeRef:o,audioStartPositionRef:i}=We(),{samplesPerPixel:l,sampleRate:u,progressBarWidth:d}=Te();return c.useEffect(()=>{const b=()=>{if(n.current){let p;if(a){const x=P.getContext().currentTime-(o.current??0);p=(i.current??0)+x}else p=s.current??0;const f=p*u/l+t;n.current.style.transform=`translate3d(${f}px, 0, 0)`}a&&(r.current=requestAnimationFrame(b))};return a?r.current=requestAnimationFrame(b):b(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[a,u,l,t,s,o,i]),c.useEffect(()=>{if(!a&&n.current){const p=(s.current??0)*u/l+t;n.current.style.transform=`translate3d(${p}px, 0, 0)`}}),Z.jsx(ll,{ref:n,$color:e,$width:d,"data-playhead":!0})},ul=k.div`
1227
+ `,El=({color:e="#ff0000",controlsOffset:t=0})=>{const n=c.useRef(null),r=c.useRef(null),{isPlaying:a,currentTimeRef:s,playbackStartTimeRef:o,audioStartPositionRef:l}=We(),{samplesPerPixel:i,sampleRate:u,progressBarWidth:d}=De();return c.useEffect(()=>{const b=()=>{if(n.current){let p;if(a){const C=P.getContext().currentTime-(o.current??0);p=(l.current??0)+C}else p=s.current??0;const f=p*u/i+t;n.current.style.transform=`translate3d(${f}px, 0, 0)`}a&&(r.current=requestAnimationFrame(b))};return a?r.current=requestAnimationFrame(b):b(),()=>{r.current&&(cancelAnimationFrame(r.current),r.current=null)}},[a,u,i,t,s,o,l]),c.useEffect(()=>{if(!a&&n.current){const p=(s.current??0)*u/i+t;n.current.style.transform=`translate3d(${p}px, 0, 0)`}}),Z.jsx(Rl,{ref:n,$color:e,$width:d,"data-playhead":!0})},Dl=k.div`
1227
1228
  position: relative;
1228
- `,dl=k.div`
1229
+ `,Tl=k.div`
1229
1230
  position: absolute;
1230
1231
  top: ${e=>e.$top}px;
1231
1232
  left: 0;
@@ -1237,7 +1238,7 @@ React keys must be passed directly to JSX without using spread:
1237
1238
  transform: translateZ(0);
1238
1239
  backface-visibility: hidden;
1239
1240
  will-change: transform;
1240
- `,fl=k.div`
1241
+ `,_l=k.div`
1241
1242
  position: absolute;
1242
1243
  top: ${e=>e.$top}px;
1243
1244
  left: 0;
@@ -1246,9 +1247,8 @@ React keys must be passed directly to JSX without using spread:
1246
1247
  pointer-events: none;
1247
1248
  z-index: 1;
1248
1249
  will-change: width;
1249
- `,hl=k.div`
1250
+ `,Ml=k.div`
1250
1251
  position: relative;
1251
1252
  z-index: 2;
1252
- `,Br=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=c.useRef(null),a=c.useRef(null),s=Mn(),{waveHeight:o}=Qt(),{isPlaying:i,currentTimeRef:l,playbackStartTimeRef:u,audioStartPositionRef:d}=We(),{samplesPerPixel:b,sampleRate:p}=Te(),f=s?.waveProgressColor||"rgba(0, 0, 0, 0.1)";c.useEffect(()=>{const m=()=>{if(r.current){let C;if(i){const I=P.getContext().currentTime-(u.current??0);C=(d.current??0)+I}else C=l.current??0;const w=C*p,g=e+t;let S=0;if(w<=e)S=0;else if(w>=g)S=n.length;else{const I=w-e;S=Math.floor(I/b)}r.current.style.width=`${S}px`}i&&(a.current=requestAnimationFrame(m))};return i?a.current=requestAnimationFrame(m):m(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[i,p,b,e,t,n.length,l,u,d]),c.useEffect(()=>{if(!i&&r.current){const C=(l.current??0)*p,w=e+t;let g=0;if(C<=e)g=0;else if(C>=w)g=n.length;else{const S=C-e;g=Math.floor(S/b)}r.current.style.width=`${g}px`}});const x=s?.waveformDrawMode||"inverted";let y;x==="inverted"?y=n.isSelected&&s?s.selectedWaveFillColor:s?.waveFillColor||"white":y=n.isSelected&&s?s.selectedWaveOutlineColor:s?.waveOutlineColor||"grey";const v=Ht(y);return Z.jsxs(ul,{children:[Z.jsx(dl,{$color:v,$height:o,$top:n.index*o,$width:n.length}),Z.jsx(fl,{ref:r,$color:f,$height:o,$top:n.index*o}),Z.jsx(hl,{children:Z.jsx(Po,{...n,transparentBackground:!0})})]})},ml=60,pl=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:a,annotationTextHeight:s,className:o,showClipHeaders:i=!1,interactiveClips:l=!1,showFades:u=!1,touchOptimized:d=!1,recordingState:b})=>{const p=Mn(),{isPlaying:f,currentTimeRef:x,playbackStartTimeRef:y,audioStartPositionRef:v}=We(),{selectionStart:m,selectionEnd:C,annotations:w,activeAnnotationId:g,annotationsEditable:S,linkEndpoints:I,continuousPlay:E,selectedTrackId:D,loopStart:_,loopEnd:B,isLoopEnabled:T}=Ne(),{setAnnotations:V,setActiveAnnotationId:W,setTrackMute:O,setTrackSolo:X,setTrackVolume:G,setTrackPan:Q,setSelection:ne,play:L,setScrollContainer:oe,setSelectedTrackId:A,setCurrentTime:j,setLoopRegion:H}=xe(),{audioBuffers:K,peaksDataArray:be,trackStates:Be,tracks:ie,duration:De,samplesPerPixel:ue,sampleRate:he,waveHeight:gt,timeScaleHeight:ut,controls:de,playoutRef:rt,barWidth:at,barGap:Ue}=Te(),[ot,z]=c.useState(!1),Re=c.useRef(null),we=c.useCallback(Y=>{Re.current=Y,oe(Y)},[oe]);let ve=K.length>0?De:ml;if(b?.isRecording){const ee=(b.startSample+b.durationSamples)/he;ve=Math.max(ve,ee+10)}const Ze=Math.floor(ve*he/ue),Le=async Y=>{console.log("Annotation clicked:",Y.id),W(Y.id);const ee=E?void 0:Y.end-Y.start;await L(Y.start,ee)},Pe=c.useCallback(Y=>{if(Y>=0&&Y<ie.length){const ee=ie[Y];A(ee.id)}},[ie,A]),Xe=Y=>{const ee=Y.currentTarget.getBoundingClientRect(),me=de.show?de.width:0,Ee=(Y.clientX-ee.left-me)*ue/he,le=Y.clientY-ee.top;let Ge=0,Ye=-1;for(let je=0;je<be.length;je++){const _e=be[je],Je=(_e.length>0?Math.max(..._e.map(ft=>ft.peaks.data.length)):1)*gt+(i?22:0);if(le>=Ge&&le<Ge+Je){Ye=je;break}Ge+=Je}Ye!==-1&&Pe(Ye),z(!0),j(Ee),ne(Ee,Ee)},He=Y=>{if(!ot)return;const ee=Y.currentTarget.getBoundingClientRect(),me=de.show?de.width:0,Ee=(Y.clientX-ee.left-me)*ue/he,Se=Math.min(m,Ee),le=Math.max(m,Ee);ne(Se,le)},dt=Y=>{if(!ot)return;z(!1);const ee=Y.currentTarget.getBoundingClientRect(),me=de.show?de.width:0,Ee=(Y.clientX-ee.left-me)*ue/he,Se=Math.min(m,Ee),le=Math.max(m,Ee);Math.abs(le-Se)<.1?(j(Se),f&&rt.current?(rt.current.stop(),L(Se)):rt.current&&rt.current.stop()):ne(Se,le)};return ie.some(Y=>Y.clips.length>0)&&(K.length===0||be.length===0)?Z.jsx("div",{className:o,children:"Loading waveform..."}):Z.jsx(Do,{children:Z.jsxs(_n.Provider,{value:{samplesPerPixel:ue,sampleRate:he,zoomLevels:[ue],waveHeight:gt,timeScaleHeight:ut,duration:ve,controls:de,barWidth:at,barGap:Ue},children:[Z.jsx(Kr,{theme:p,backgroundColor:Ht(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,scrollContainerWidth:Ze+(de.show?de.width:0),timescaleWidth:Ze,tracksWidth:Ze,controlsWidth:de.show?de.width:0,onTracksMouseDown:Xe,onTracksMouseMove:He,onTracksMouseUp:dt,scrollContainerRef:we,isSelecting:ot,timescale:ut>0?Z.jsxs(Z.Fragment,{children:[Z.jsx(Xo,{duration:ve*1e3,marker:1e4,bigStep:5e3,secondStep:1e3,renderTimestamp:t}),T&&Z.jsx(Eo,{startPosition:Math.min(_,B)*he/ue,endPosition:Math.max(_,B)*he/ue,markerColor:p.loopMarkerColor,regionColor:p.loopRegionColor,minPosition:0,maxPosition:Ze,controlsOffset:de.show?de.width:0,onLoopRegionChange:(Y,ee)=>{const me=Y*ue/he,Ie=ee*ue/he;H(me,Ie)}})]}):void 0,children:Z.jsxs(Z.Fragment,{children:[be.map((Y,ee)=>{const me=ie[ee];if(!me)return null;const Ie=Be[ee]||{name:`Track ${ee+1}`,muted:!1,soloed:!1,volume:1,pan:0},Ee=e?e(ee):Z.jsxs(es,{onClick:()=>Pe(ee),children:[Z.jsx(ts,{style:{justifyContent:"center"},children:Ie.name||`Track ${ee+1}`}),Z.jsxs(Qo,{children:[Z.jsx(ir,{$variant:Ie.muted?"danger":"outline",onClick:()=>O(ee,!Ie.muted),children:"Mute"}),Z.jsx(ir,{$variant:Ie.soloed?"info":"outline",onClick:()=>X(ee,!Ie.soloed),children:"Solo"})]}),Z.jsxs(cr,{children:[Z.jsx(ns,{}),Z.jsx(lr,{min:"0",max:"1",step:"0.01",value:Ie.volume,onChange:le=>G(ee,parseFloat(le.target.value))}),Z.jsx(rs,{})]}),Z.jsxs(cr,{children:[Z.jsx("span",{children:"L"}),Z.jsx(lr,{min:"-1",max:"1",step:"0.01",value:Ie.pan,onChange:le=>Q(ee,parseFloat(le.target.value))}),Z.jsx("span",{children:"R"})]})]}),Se=Y.length>0?Math.max(...Y.map(le=>le.peaks.data.length)):1;return Z.jsx(Qr.Provider,{value:Ee,children:Z.jsxs(qo,{numChannels:Se,backgroundColor:Ht(p.waveOutlineColor),offset:0,width:Ze,hasClipHeaders:i,trackId:me.id,isSelected:me.id===D,children:[Y.map((le,Ge)=>{const Ye=le.peaks,je=Ye.length;return Z.jsx(ar,{clipId:le.clipId,trackIndex:ee,clipIndex:Ge,trackName:le.trackName,startSample:le.startSample,durationSamples:le.durationSamples,samplesPerPixel:ue,showHeader:i,disableHeaderDrag:!l,isSelected:me.id===D,trackId:me.id,fadeIn:le.fadeIn,fadeOut:le.fadeOut,sampleRate:he,showFades:u,touchOptimized:d,onMouseDown:_e=>{_e.target.closest('[role="button"][aria-roledescription="draggable"]')||Pe(ee)},children:Ye.data.map((_e,Ae)=>Z.jsx(Br,{index:Ae,data:_e,bits:Ye.bits,length:je,isSelected:me.id===D,clipStartSample:le.startSample,clipDurationSamples:le.durationSamples},`${ee}-${Ge}-${Ae}`))},`${ee}-${Ge}`)}),b?.isRecording&&b.trackId===me.id&&b.peaks.length>0&&Z.jsx(ar,{clipId:"recording-preview",trackIndex:ee,clipIndex:Y.length,trackName:"Recording...",startSample:b.startSample,durationSamples:b.durationSamples,samplesPerPixel:ue,showHeader:i,disableHeaderDrag:!0,isSelected:me.id===D,trackId:me.id,children:Z.jsx(Br,{index:0,data:b.peaks,bits:16,length:Math.floor(b.peaks.length/2),isSelected:me.id===D,clipStartSample:b.startSample,clipDurationSamples:b.durationSamples},`${ee}-recording-0`)},`${ee}-recording`)]})},me.id)}),w.length>0&&Z.jsx(Ss,{height:30,width:Ze,children:w.map((Y,ee)=>{const me=Y.start*he/ue,Ie=Y.end*he/ue;return Z.jsx(xs,{annotationId:Y.id,annotationIndex:ee,startPosition:me,endPosition:Ie,label:Y.id,color:"#ff9800",isActive:Y.id===g,onClick:()=>Le(Y),editable:S},Y.id)})}),m!==C&&Z.jsx(Ao,{startPosition:Math.min(m,C)*he/ue+(de.show?de.width:0),endPosition:Math.max(m,C)*he/ue+(de.show?de.width:0),color:p.selectionColor}),(f||m===C)&&(n?n({position:(x.current??0)*he/ue+(de.show?de.width:0),color:p.playheadColor,isPlaying:f,currentTimeRef:x,playbackStartTimeRef:y,audioStartPositionRef:v,samplesPerPixel:ue,sampleRate:he,controlsOffset:de.show?de.width:0,getAudioContextTime:()=>P.getContext().currentTime}):Z.jsx(cl,{color:p.playheadColor,controlsOffset:de.show?de.width:0}))]})}),w.length>0&&Z.jsx(Fs,{annotations:w,activeAnnotationId:g??void 0,shouldScrollToActive:!0,editable:S,controls:S?r:void 0,annotationListConfig:{linkEndpoints:I,continuousPlay:E},height:s,onAnnotationUpdate:Y=>{V(Y)}})]})})};function pt(e,t){this._waveformData=e,this._channelIndex=t}pt.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};pt.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};pt.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};pt.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};pt.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};pt.prototype.max_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.max_sample(n));return t};var gl=127,bl=-128,vl=32767,Cl=-32768;function xl(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function wl(e){for(var t=e.scale,n=e.amplitude_scale,r=e.split_channels,a=e.length,s=e.sample_rate,o=e.channels.map(function(T){return new Float32Array(T)}),i=r?o.length:1,l=24,u=xl(a,t),d=e.bits===8?1:2,b=l+u*2*d*i,p=new ArrayBuffer(b),f=new DataView(p),x=0,y=l,v=new Array(i),m=new Array(i),C=0;C<i;C++)v[C]=1/0,m[C]=-1/0;var w=e.bits===8?bl:Cl,g=e.bits===8?gl:vl;f.setInt32(0,2,!0),f.setUint32(4,e.bits===8,!0),f.setInt32(8,s,!0),f.setInt32(12,t,!0),f.setInt32(16,u,!0),f.setInt32(20,i,!0);for(var S=0;S<a;S++){var I=0;if(i===1){for(var E=0;E<o.length;++E)I+=o[E][S];I=Math.floor(g*I*n/o.length),I<v[0]&&(v[0]=I,v[0]<w&&(v[0]=w)),I>m[0]&&(m[0]=I,m[0]>g&&(m[0]=g))}else for(var D=0;D<i;++D)I=Math.floor(g*o[D][S]*n),I<v[D]&&(v[D]=I,v[D]<w&&(v[D]=w)),I>m[D]&&(m[D]=I,m[D]>g&&(m[D]=g));if(++x===t){for(var _=0;_<i;_++)e.bits===8?(f.setInt8(y++,v[_]),f.setInt8(y++,m[_])):(f.setInt16(y,v[_],!0),f.setInt16(y+2,m[_],!0),y+=4),v[_]=1/0,m[_]=-1/0;x=0}}if(x>0)for(var B=0;B<i;B++)e.bits===8?(f.setInt8(y++,v[B]),f.setInt8(y++,m[B])):(f.setInt16(y,v[B],!0),f.setInt16(y+2,m[B],!0));return p}function Yt(e){"@babel/helpers - typeof";return Yt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yt(e)}function yl(e){return e&&Yt(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function Il(e){var t=e&&Yt(e)==="object"&&"byteLength"in e;if(t){var n=new DataView(e),r=n.getInt32(0,!0);if(r!==1&&r!==2)throw new TypeError("WaveformData.create(): This waveform data version not supported")}return t}function Sl(e){var t=e.data,n=e.channels||1,r=24,a=e.bits===8?1:2,s=e.length*2*n;if(t.length!==s)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=r+t.length*a,i=new ArrayBuffer(o),l=new DataView(i);l.setInt32(0,2,!0),l.setUint32(4,e.bits===8,!0),l.setInt32(8,e.sample_rate,!0),l.setInt32(12,e.samples_per_pixel,!0),l.setInt32(16,e.length,!0),l.setInt32(20,n,!0);var u=r;if(e.bits===8)for(var d=0;d<t.length;d++)l.setInt8(u++,t[d],!0);else for(var b=0;b<t.length;b++)l.setInt16(u,t[b],!0),u+=2;return i}function Ct(e){return e==null}function Al(e,t){var n=atob(e);return n}function kl(e,t,n){var r=Al(e),a=r.indexOf(`
1253
- `,10)+1,s=r.substring(a)+"",o=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(o)}function $l(e,t,n){var r;return function(s){return r=r||kl(e),new Worker(r,s)}}var Rl=$l("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function ze(e){if(yl(e)&&(e=Sl(e)),Il(e)){this._data=new DataView(e),this._offset=this._version()===2?24:20,this._channels=[];for(var t=0;t<this.channels;t++)this._channels[t]=new pt(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var Dt={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function El(e){var t={scale:e.scale||Dt.scale,bits:e.bits||Dt.bits,amplitude_scale:e.amplitude_scale||Dt.amplitude_scale,split_channels:e.split_channels||Dt.split_channels,disable_worker:e.disable_worker||Dt.disable_worker};return t}function Tl(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function pa(e,t,n){var r=Tl(e);if(t.disable_worker){var a=wl({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:r});n(void 0,new ze(a),e)}else{var s=new Rl;s.onmessage=function(o){n(void 0,new ze(o.data),e)},s.postMessage({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:r},r)}}function Dl(e,t,n,r){function a(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var s=e.decodeAudioData(t,function(o){pa(o,n,r)},a);s&&s.catch(a)}ze.create=function(t){return new ze(t)};ze.createFromAudio=function(e,t){var n=El(e);if(e.audio_context&&e.array_buffer)return Dl(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return pa(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function tn(e){this._inputData=e.waveformData,this._output_samples_per_pixel=e.scale,this._scale=this._inputData.scale,this._input_buffer_size=this._inputData.length;var t=this._input_buffer_size*this._inputData.scale,n=Math.ceil(t/this._output_samples_per_pixel),r=24,a=this._inputData.bits===8?1:2,s=r+n*2*this._inputData.channels*a;this._output_data=new ArrayBuffer(s),this.output_dataview=new DataView(this._output_data),this.output_dataview.setInt32(0,2,!0),this.output_dataview.setUint32(4,this._inputData.bits===8,!0),this.output_dataview.setInt32(8,this._inputData.sample_rate,!0),this.output_dataview.setInt32(12,this._output_samples_per_pixel,!0),this.output_dataview.setInt32(16,n,!0),this.output_dataview.setInt32(20,this._inputData.channels,!0),this._outputWaveformData=new ze(this._output_data),this._input_index=0,this._output_index=0;var o=this._inputData.channels;this._min=new Array(o),this._max=new Array(o);for(var i=0;i<o;++i)this._input_buffer_size>0?(this._min[i]=this._inputData.channel(i).min_sample(this._input_index),this._max[i]=this._inputData.channel(i).max_sample(this._input_index)):(this._min[i]=0,this._max[i]=0);this._min_value=this._inputData.bits===8?-128:-32768,this._max_value=this._inputData.bits===8?127:32767,this._where=0,this._prev_where=0,this._stop=0,this._last_input_index=0}tn.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};tn.prototype.next=function(){for(var e=0,t=1e3,n=this._inputData.channels,r;this._input_index<this._input_buffer_size&&e<t;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(var a=0;a<n;++a)r=this._outputWaveformData.channel(a),r.set_min_sample(this._output_index-1,this._min[a]),r.set_max_sample(this._output_index-1,this._max[a]);if(this._last_input_index=this._input_index,this._output_index++,this._where=this.sample_at_pixel(this._output_index),this._prev_where=this.sample_at_pixel(this._output_index-1),this._where!==this._prev_where)for(var s=0;s<n;++s)this._min[s]=this._max_value,this._max[s]=this._min_value}for(this._where=this.sample_at_pixel(this._output_index),this._stop=Math.floor(this._where/this._scale),this._stop>this._input_buffer_size&&(this._stop=this._input_buffer_size);this._input_index<this._stop;){for(var o=0;o<n;++o){r=this._inputData.channel(o);var i=r.min_sample(this._input_index);i<this._min[o]&&(this._min[o]=i),i=r.max_sample(this._input_index),i>this._max[o]&&(this._max[o]=i)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var l=0;l<n;++l)r=this._outputWaveformData.channel(l),r.set_min_sample(this._output_index-1,this._min[l]),r.set_max_sample(this._output_index-1,this._max[l]);return!0};tn.prototype.getOutputData=function(){return this._output_data};ze.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Ct(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Ct(n.scale)&&(typeof n.scale!="number"||n.scale<=0))throw new RangeError("WaveformData.resample(): scale should be a positive integer value");if(!n.scale&&!n.width)throw new Error("WaveformData.resample(): Missing scale or width option");if(n.width&&(n.scale=Math.floor(this.duration*this.sample_rate/n.width)),n.scale<this.scale)throw new Error("WaveformData.resample(): Zoom level "+n.scale+" too low, minimum: "+this.scale);return n.abortSignal=t.abortSignal,n},resample:function(t){t=this._getResampleOptions(t),t.waveformData=this;for(var n=new tn(t);!n.next(););return new ze(n.getOutputData())},concat:function(){var t=this,n=Array.prototype.slice.call(arguments);n.forEach(function(a){if(t.channels!==a.channels||t.sample_rate!==a.sample_rate||t.bits!==a.bits||t.scale!==a.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")});var r=this._concatBuffers.apply(this,n);return ze.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,a=0,s=[this].concat(t).map(function(m){return m._data.buffer}),o=0;o<s.length;o++){var i=s[o],l=new DataView(i).getInt32(16,!0);r+=i.byteLength-n,a+=l}for(var u=new ArrayBuffer(r),d=new DataView(s[0]),b=new DataView(u),p=0;p<n;p++)b.setUint8(p,d.getUint8(p));b.setInt32(16,a,!0);for(var f=0,x=new Uint8Array(u,n),y=0;y<s.length;y++){var v=s[y];x.set(new Uint8Array(v,n),f),f+=v.byteLength-n}return u},slice:function(t){var n=0,r=0;if(!Ct(t.startIndex)&&!Ct(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Ct(t.startTime)&&!Ct(t.endTime)&&(n=this.at_time(t.startTime),r=this.at_time(t.endTime)),n<0)throw new RangeError("startIndex or startTime must not be negative");if(r<0)throw new RangeError("endIndex or endTime must not be negative");n>this.length&&(n=this.length),r>this.length&&(r=this.length),n>r&&(n=r);var a=r-n,s=24,o=this.bits===8?1:2,i=s+a*2*this.channels*o,l=new ArrayBuffer(i),u=new DataView(l);u.setInt32(0,2,!0),u.setUint32(4,this.bits===8,!0),u.setInt32(8,this.sample_rate,!0),u.setInt32(12,this.scale,!0),u.setInt32(16,a,!0),u.setInt32(20,this.channels,!0);for(var d=0;d<a*this.channels*2;d++){var b=this._at(n*this.channels*2+d);this.bits===8?u.setInt8(s+d,b):u.setInt16(s+d*2,b,!0)}return new ze(l)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){var e=!!this._data.getUint32(4,!0);return e?8:16},get duration(){return this.length*this.scale/this.sample_rate},get pixels_per_second(){return this.sample_rate/this.scale},get seconds_per_pixel(){return this.scale/this.sample_rate},get channels(){return this._version()===2?this._data.getInt32(20,!0):1},channel:function(t){if(t>=0&&t<this._channels.length)return this._channels[t];throw new RangeError("Invalid channel: "+t)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(t){return this.bits===8?this._data.getInt8(this._offset+t):this._data.getInt16(this._offset+t*2,!0)},_set_at:function(t,n){return this.bits===8?this._data.setInt8(this._offset+t,n):this._data.setInt16(this._offset+t*2,n,!0)},at_time:function(t){return Math.floor(t*this.sample_rate/this.scale)},time:function(t){return t*this.scale/this.sample_rate},toJSON:function(){for(var t={version:2,channels:this.channels,sample_rate:this.sample_rate,samples_per_pixel:this.scale,bits:this.bits,length:this.length,data:[]},n=0;n<this.length;n++)for(var r=0;r<this.channels;r++)t.data.push(this.channel(r).min_sample(n)),t.data.push(this.channel(r).max_sample(n));return t},toArrayBuffer:function(){return this._data.buffer}};async function Zn(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch waveform data: ${t.statusText}`);if(e.endsWith(".dat")){const r=await t.arrayBuffer();return ze.create(r)}else{const r=await t.json();return ze.create(r)}}function ga(e,t=0){const n=e.channel(t),r=e.bits,a=n.min_array(),s=n.max_array(),o=a.length,i=r===8?new Int8Array(o*2):new Int16Array(o*2);for(let l=0;l<o;l++)i[l*2]=a[l],i[l*2+1]=s[l];return{data:i,bits:r,length:o,sampleRate:e.sample_rate}}async function _l(e,t=0){const n=await Zn(e);return ga(n,t)}async function Ml(e){const t=await Zn(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}exports.Tone=Wr;exports.AudioPosition=el;exports.AutomaticScrollCheckbox=nl;exports.ContinuousPlayCheckbox=rl;exports.DownloadAnnotationsButton=sl;exports.EditableCheckbox=ol;exports.ExportWavButton=il;exports.FastForwardButton=Li;exports.LinkEndpointsCheckbox=al;exports.LoopButton=Gi;exports.MasterVolumeControl=Ji;exports.PauseButton=zi;exports.PlayButton=ji;exports.RewindButton=Ni;exports.SelectionTimeInputs=tl;exports.SetLoopRegionButton=Yi;exports.SkipBackwardButton=Xi;exports.SkipForwardButton=Hi;exports.StopButton=Oi;exports.TimeFormatSelect=qi;exports.Waveform=pl;exports.WaveformPlaylistProvider=Pi;exports.ZoomInButton=Ki;exports.ZoomOutButton=Ui;exports.createEffectChain=Ti;exports.createEffectInstance=_t;exports.effectCategories=ki;exports.effectDefinitions=Mt;exports.getEffectDefinition=Wn;exports.getEffectsByCategory=Ai;exports.getShortcutLabel=ci;exports.getWaveformDataMetadata=Ml;exports.loadPeaksFromWaveformData=_l;exports.loadWaveformData=Zn;exports.useAnnotationDragHandlers=Gs;exports.useAnnotationKeyboardControls=di;exports.useAudioTracks=Xs;exports.useClipDragHandlers=Hs;exports.useClipSplitting=li;exports.useDragSensors=ii;exports.useDynamicEffects=Di;exports.useExportWav=ca;exports.useIntegratedRecording=Si;exports.useKeyboardShortcuts=Gt;exports.useMasterAnalyser=Os;exports.useMasterVolume=ra;exports.usePlaybackAnimation=We;exports.usePlaybackShortcuts=ui;exports.usePlaylistControls=xe;exports.usePlaylistData=Te;exports.usePlaylistState=Ne;exports.useTimeFormat=ta;exports.useTrackDynamicEffects=_i;exports.useWaveformPlaylist=Vi;exports.useZoomControls=na;exports.waveformDataToPeaks=ga;
1253
+ `,Br=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=c.useRef(null),a=c.useRef(null),s=Mn(),{waveHeight:o}=en(),{isPlaying:l,currentTimeRef:i,playbackStartTimeRef:u,audioStartPositionRef:d}=We(),{samplesPerPixel:b,sampleRate:p}=De(),f=s?.waveProgressColor||"rgba(0, 0, 0, 0.1)";c.useEffect(()=>{const m=()=>{if(r.current){let w;if(l){const I=P.getContext().currentTime-(u.current??0);w=(d.current??0)+I}else w=i.current??0;const x=w*p,v=e+t;let S=0;if(x<=e)S=0;else if(x>=v)S=n.length;else{const I=x-e;S=Math.floor(I/b)}r.current.style.width=`${S}px`}l&&(a.current=requestAnimationFrame(m))};return l?a.current=requestAnimationFrame(m):m(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[l,p,b,e,t,n.length,i,u,d]),c.useEffect(()=>{if(!l&&r.current){const w=(i.current??0)*p,x=e+t;let v=0;if(w<=e)v=0;else if(w>=x)v=n.length;else{const S=w-e;v=Math.floor(S/b)}r.current.style.width=`${v}px`}});const C=s?.waveformDrawMode||"inverted";let y;C==="inverted"?y=n.isSelected&&s?s.selectedWaveFillColor:s?.waveFillColor||"white":y=n.isSelected&&s?s.selectedWaveOutlineColor:s?.waveOutlineColor||"grey";const g=Gt(y);return Z.jsxs(Dl,{children:[Z.jsx(Tl,{$color:g,$height:o,$top:n.index*o,$width:n.length}),Z.jsx(_l,{ref:r,$color:f,$height:o,$top:n.index*o}),Z.jsx(Ml,{children:Z.jsx(Vo,{...n,transparentBackground:!0})})]})},Bl=60,Fl=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:a,annotationTextHeight:s,className:o,showClipHeaders:l=!1,interactiveClips:i=!1,showFades:u=!1,touchOptimized:d=!1,recordingState:b})=>{const p=Mn(),{isPlaying:f,currentTimeRef:C,playbackStartTimeRef:y,audioStartPositionRef:g}=We(),{selectionStart:m,selectionEnd:w,annotations:x,activeAnnotationId:v,annotationsEditable:S,linkEndpoints:I,continuousPlay:$,selectedTrackId:M,loopStart:T,loopEnd:_,isLoopEnabled:D}=Le(),{setAnnotations:V,setActiveAnnotationId:W,setTrackMute:O,setTrackSolo:N,setTrackVolume:Y,setTrackPan:ee,setSelection:re,play:X,setScrollContainer:oe,setSelectedTrackId:A,setCurrentTime:j,setLoopRegion:H}=we(),{audioBuffers:U,peaksDataArray:ge,trackStates:Be,tracks:ie,duration:Te,samplesPerPixel:ue,sampleRate:me,waveHeight:gt,timeScaleHeight:dt,controls:de,playoutRef:at,barWidth:ot,barGap:Je}=De(),[st,z]=c.useState(!1),Re=c.useRef(null),xe=c.useCallback(K=>{Re.current=K,oe(K)},[oe]);let be=U.length>0?Te:Bl;if(b?.isRecording){const te=(b.startSample+b.durationSamples)/me;be=Math.max(be,te+10)}const Ze=Math.floor(be*me/ue),Xe=async K=>{console.log("Annotation clicked:",K.id),W(K.id);const te=$?void 0:K.end-K.start;await X(K.start,te)},Pe=c.useCallback(K=>{if(K>=0&&K<ie.length){const te=ie[K];A(te.id)}},[ie,A]),He=K=>{const te=K.currentTarget.getBoundingClientRect(),he=de.show?de.width:0,Ee=(K.clientX-te.left-he)*ue/me,le=K.clientY-te.top;let Ye=0,Ke=-1;for(let ze=0;ze<ge.length;ze++){const _e=ge[ze],qe=(_e.length>0?Math.max(..._e.map(mt=>mt.peaks.data.length)):1)*gt+(l?22:0);if(le>=Ye&&le<Ye+qe){Ke=ze;break}Ye+=qe}Ke!==-1&&Pe(Ke),z(!0),j(Ee),re(Ee,Ee)},Ge=K=>{if(!st)return;const te=K.currentTarget.getBoundingClientRect(),he=de.show?de.width:0,Ee=(K.clientX-te.left-he)*ue/me,Ae=Math.min(m,Ee),le=Math.max(m,Ee);re(Ae,le)},ft=K=>{if(!st)return;z(!1);const te=K.currentTarget.getBoundingClientRect(),he=de.show?de.width:0,Ee=(K.clientX-te.left-he)*ue/me,Ae=Math.min(m,Ee),le=Math.max(m,Ee);Math.abs(le-Ae)<.1?(j(Ae),f&&at.current?(at.current.stop(),X(Ae)):at.current&&at.current.stop()):re(Ae,le)};return ie.some(K=>K.clips.length>0)&&(U.length===0||ge.length===0)?Z.jsx("div",{className:o,children:"Loading waveform..."}):Z.jsx(_o,{children:Z.jsxs(_n.Provider,{value:{samplesPerPixel:ue,sampleRate:me,zoomLevels:[ue],waveHeight:gt,timeScaleHeight:dt,duration:be,controls:de,barWidth:ot,barGap:Je},children:[Z.jsx(Kr,{theme:p,backgroundColor:Gt(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,scrollContainerWidth:Ze+(de.show?de.width:0),timescaleWidth:Ze,tracksWidth:Ze,controlsWidth:de.show?de.width:0,onTracksMouseDown:He,onTracksMouseMove:Ge,onTracksMouseUp:ft,scrollContainerRef:xe,isSelecting:st,timescale:dt>0?Z.jsxs(Z.Fragment,{children:[Z.jsx(Ho,{duration:be*1e3,marker:1e4,bigStep:5e3,secondStep:1e3,renderTimestamp:t}),D&&Z.jsx(Do,{startPosition:Math.min(T,_)*me/ue,endPosition:Math.max(T,_)*me/ue,markerColor:p.loopMarkerColor,regionColor:p.loopRegionColor,minPosition:0,maxPosition:Ze,controlsOffset:de.show?de.width:0,onLoopRegionChange:(K,te)=>{const he=K*ue/me,ye=te*ue/me;H(he,ye)}})]}):void 0,children:Z.jsxs(Z.Fragment,{children:[ge.map((K,te)=>{const he=ie[te];if(!he)return null;const ye=Be[te]||{name:`Track ${te+1}`,muted:!1,soloed:!1,volume:1,pan:0},Ee=e?e(te):Z.jsxs(ts,{onClick:()=>Pe(te),children:[Z.jsx(ns,{style:{justifyContent:"center"},children:ye.name||`Track ${te+1}`}),Z.jsxs(es,{children:[Z.jsx(ir,{$variant:ye.muted?"danger":"outline",onClick:()=>O(te,!ye.muted),children:"Mute"}),Z.jsx(ir,{$variant:ye.soloed?"info":"outline",onClick:()=>N(te,!ye.soloed),children:"Solo"})]}),Z.jsxs(cr,{children:[Z.jsx(rs,{}),Z.jsx(lr,{min:"0",max:"1",step:"0.01",value:ye.volume,onChange:le=>Y(te,parseFloat(le.target.value))}),Z.jsx(as,{})]}),Z.jsxs(cr,{children:[Z.jsx("span",{children:"L"}),Z.jsx(lr,{min:"-1",max:"1",step:"0.01",value:ye.pan,onChange:le=>ee(te,parseFloat(le.target.value))}),Z.jsx("span",{children:"R"})]})]}),Ae=K.length>0?Math.max(...K.map(le=>le.peaks.data.length)):1;return Z.jsx(Qr.Provider,{value:Ee,children:Z.jsxs(Qo,{numChannels:Ae,backgroundColor:Gt(p.waveOutlineColor),offset:0,width:Ze,hasClipHeaders:l,trackId:he.id,isSelected:he.id===M,children:[K.map((le,Ye)=>{const Ke=le.peaks,ze=Ke.length;return Z.jsx(ar,{clipId:le.clipId,trackIndex:te,clipIndex:Ye,trackName:le.trackName,startSample:le.startSample,durationSamples:le.durationSamples,samplesPerPixel:ue,showHeader:l,disableHeaderDrag:!i,isSelected:he.id===M,trackId:he.id,fadeIn:le.fadeIn,fadeOut:le.fadeOut,sampleRate:me,showFades:u,touchOptimized:d,onMouseDown:_e=>{_e.target.closest('[role="button"][aria-roledescription="draggable"]')||Pe(te)},children:Ke.data.map((_e,Ie)=>Z.jsx(Br,{index:Ie,data:_e,bits:Ke.bits,length:ze,isSelected:he.id===M,clipStartSample:le.startSample,clipDurationSamples:le.durationSamples},`${te}-${Ye}-${Ie}`))},`${te}-${Ye}`)}),b?.isRecording&&b.trackId===he.id&&b.peaks.length>0&&Z.jsx(ar,{clipId:"recording-preview",trackIndex:te,clipIndex:K.length,trackName:"Recording...",startSample:b.startSample,durationSamples:b.durationSamples,samplesPerPixel:ue,showHeader:l,disableHeaderDrag:!0,isSelected:he.id===M,trackId:he.id,children:Z.jsx(Br,{index:0,data:b.peaks,bits:16,length:Math.floor(b.peaks.length/2),isSelected:he.id===M,clipStartSample:b.startSample,clipDurationSamples:b.durationSamples},`${te}-recording-0`)},`${te}-recording`)]})},he.id)}),x.length>0&&Z.jsx(Ls,{height:30,width:Ze,children:x.map((K,te)=>{const he=K.start*me/ue,ye=K.end*me/ue;return Z.jsx(js,{annotationId:K.id,annotationIndex:te,startPosition:he,endPosition:ye,label:K.id,color:"#ff9800",isActive:K.id===v,onClick:()=>Xe(K),editable:S},K.id)})}),m!==w&&Z.jsx(ko,{startPosition:Math.min(m,w)*me/ue+(de.show?de.width:0),endPosition:Math.max(m,w)*me/ue+(de.show?de.width:0),color:p.selectionColor}),(f||m===w)&&(n?n({position:(C.current??0)*me/ue+(de.show?de.width:0),color:p.playheadColor,isPlaying:f,currentTimeRef:C,playbackStartTimeRef:y,audioStartPositionRef:g,samplesPerPixel:ue,sampleRate:me,controlsOffset:de.show?de.width:0,getAudioContextTime:()=>P.getContext().currentTime}):Z.jsx(El,{color:p.playheadColor,controlsOffset:de.show?de.width:0}))]})}),x.length>0&&Z.jsx(ti,{annotations:x,activeAnnotationId:v??void 0,shouldScrollToActive:!0,editable:S,controls:S?r:void 0,annotationListConfig:{linkEndpoints:I,continuousPlay:$},height:s,onAnnotationUpdate:K=>{V(K)}})]})})};exports.Tone=Wr;exports.AudioPosition=wl;exports.AutomaticScrollCheckbox=yl;exports.ContinuousPlayCheckbox=Il;exports.DownloadAnnotationsButton=kl;exports.EditableCheckbox=Al;exports.ExportWavButton=$l;exports.FastForwardButton=ul;exports.LinkEndpointsCheckbox=Sl;exports.LoopButton=ml;exports.MasterVolumeControl=bl;exports.PauseButton=il;exports.PlayButton=sl;exports.RewindButton=cl;exports.SelectionTimeInputs=xl;exports.SetLoopRegionButton=hl;exports.SkipBackwardButton=dl;exports.SkipForwardButton=fl;exports.StopButton=ll;exports.TimeFormatSelect=vl;exports.Waveform=Fl;exports.WaveformPlaylistProvider=al;exports.ZoomInButton=pl;exports.ZoomOutButton=gl;exports.createEffectChain=Ui;exports.createEffectInstance=_t;exports.effectCategories=Hi;exports.effectDefinitions=Mt;exports.getEffectDefinition=Zn;exports.getEffectsByCategory=Xi;exports.getShortcutLabel=Ei;exports.getWaveformDataMetadata=ks;exports.loadPeaksFromWaveformData=As;exports.loadWaveformData=Bn;exports.useAnnotationDragHandlers=mi;exports.useAnnotationKeyboardControls=Ti;exports.useAudioTracks=di;exports.useClipDragHandlers=fi;exports.useClipSplitting=Ri;exports.useDragSensors=$i;exports.useDynamicEffects=Ji;exports.useExportWav=da;exports.useIntegratedRecording=Li;exports.useKeyboardShortcuts=Kt;exports.useMasterAnalyser=li;exports.useMasterVolume=oa;exports.usePlaybackAnimation=We;exports.usePlaybackShortcuts=Di;exports.usePlaylistControls=we;exports.usePlaylistData=De;exports.usePlaylistState=Le;exports.useTimeFormat=ra;exports.useTrackDynamicEffects=qi;exports.useWaveformPlaylist=ol;exports.useZoomControls=aa;exports.waveformDataToPeaks=na;
1254
1254
  //# sourceMappingURL=index.js.map