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

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,22 +1,22 @@
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 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 b: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 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,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++)g(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 g(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:
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(`
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 g(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"),b=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,ee={},re=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"):re,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"):re,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,g=u/r.fadeOut.duration,p=r.gain*(1-g);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,g=o.duration-(i-l),p=n?Math.min(n,g):g;a.pausedPosition=d,this.scheduleFades(a,r,d),s.start(r,d,p)}else{const d=l-i,g=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,g)):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,g={},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)&&(g[d]=l[d]);if(i&&i.defaultProps)for(d in l=i.defaultProps,l)g[d]===void 0&&(g[d]=l[d]);return{$$typeof:t,type:i,key:p,ref:f,props:g,_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"),g=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(ae){return String(ae)});ce.unshift("Warning: "+$),Function.prototype.apply.call(console[h],console,ce)}}var b=!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||b||S||I||typeof h=="object"&&h!==null&&(h.$$typeof===p||h.$$typeof===g||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 g:var U=h.displayName||null;return U!==null?U: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,X=0,G,ee,re,L,oe,A,j;function H(){}H.__reactDisabledLog=!0;function K(){{if(X===0){G=console.log,ee=console.info,re=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:ee}),warn:O({},h,{value:re}),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 ae=function(){throw Error()};if(Object.defineProperty(ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ae,[])}catch(M){U=M}Reflect.construct(h,[],ae)}else{try{ae.call()}catch(M){U=M}h.call(ae.prototype)}}else{try{throw Error()}catch(M){U=M}h()}}catch(M){if(M&&U&&typeof M.stack=="string"){for(var ne=M.stack.split(`
8
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`
9
+ `),pe=ne.length-1,Ce=ke.length-1;pe>=1&&Ce>=0&&ne[pe]!==ke[Ce];)Ce--;for(;pe>=1&&Ce>=0;pe--,Ce--)if(ne[pe]!==ke[Ce]){if(pe!==1||Ce!==1)do if(pe--,Ce--,Ce<0||ne[pe]!==ke[Ce]){var Me=`
10
+ `+ne[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:"",et=it?De(it):"";return typeof h=="function"&&he.set(h,et),et}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 g: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 Je=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(Je);for(var ae in h)if(ce(h,ae)){var ne=void 0;try{if(typeof h[ae]!="function"){var ke=Error((U||"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]($,ae,U,F,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pe){ne=pe}ne&&!(ne 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,ae,typeof ne),Re(null)),ne instanceof Error&&!(ne.message in ot)&&(ot[ne.message]=!0,Re(se),C("Failed %s type: %s",F,ne.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,te;function me(h){if(Je.call(h,"ref")){var $=Object.getOwnPropertyDescriptor(h,"ref").get;if($&&$.isReactWarning)return!1}return h.ref!==void 0}function ye(h){if(Je.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 Ae(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(){te||(te=!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,ae){var ne={$$typeof:t,type:h,key:$,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:U}),Object.defineProperty(ne,"_source",{configurable:!1,enumerable:!1,writable:!1,value:se}),Object.freeze&&(Object.freeze(ne.props),Object.freeze(ne)),ne};function Ye(h,$,F,U,se){{var ce,ae={},ne=null,ke=null;F!==void 0&&(He(F),ne=""+F),ye($)&&(He($.key),ne=""+$.key),me($)&&(ke=$.ref,Ee($,se));for(ce in $)Je.call($,ce)&&!At.hasOwnProperty(ce)&&(ae[ce]=$[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 Ce=typeof h=="function"?h.displayName||h.name||"Unknown":h;ne&&Ae(ae,Ce),ke&&le(ae,Ce)}return Ge(h,ne,ke,se,U,dt.current,ae)}}var je=m.ReactCurrentOwner,_e=m.ReactDebugCurrentFrame;function Ie(h){if(h){var $=h._owner,F=at(h.type,h._source,$?$.type:null);_e.setExtraStackFrame(F)}else _e.setExtraStackFrame(null)}var qe;qe=!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`
11
11
 
12
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&&($=`
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 $}}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)+"."),Ie(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),Ie(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),ae;!(ae=ce.next()).done;)ft(ae.value)&&Wt(ae.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===g))F=$.propTypes;else return;if(F){var U=W($);we(F,h.props,"prop",U,h)}else if($.PropTypes!==void 0&&!qe){qe=!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"){Ie(h),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",U),Ie(null);break}}h.ref!==null&&(Ie(h),C("Invalid attribute `ref` supplied to `React.Fragment`."),Ie(null))}}var Fe={};function vt(h,$,F,U,se,ce){{var ae=B(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=st();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,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,ne)}var Ce=Ye(h,$,F,se,ce);if(Ce==null)return Ce;if(ae){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(Je.call($,"key")){var et=W(h),M=Object.keys($).filter(function(fe){return fe!=="key"}),N=M.length>0?"{key: someKey, "+M.join(": ..., ")+": ...}":"{key: someKey}";if(!Fe[et+N]){var q=M.length>0?"{"+M.join(": ..., ")+": ...}":"{}";C(`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} />`,N,et,q,et),Fe[et+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:g,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(),[b,S]=Xt(),I=za(o,t),E=Pr(n);Kt(()=>(g.set(t,{id:t,key:s,node:C,activatorNode:b,data:E}),()=>{const _=g.get(t);_&&_.key===s&&g.delete(t)}),[g,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:g,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??g,height:a??g,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`
20
20
  font-family: 'Courier New', Monaco, monospace;
21
21
  font-size: 1rem;
22
22
  font-weight: 600;
@@ -283,7 +283,7 @@ React keys must be passed directly to JSX without using spread:
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
+ `,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:g=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+g;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,ee=Math.floor((X-d+I)/I)*I;for(let re=Math.max(0,ee);re<G;re+=I){const L=re-X;if(L+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*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,g,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 b=p?"transparent":Ht(u);return R.jsx(no,{$index:a,$cssWidth:r,className:s,$waveHeight:i,$waveFillColor:b,children:C})},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};
@@ -343,7 +343,7 @@ 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,i]=c.useState(!1);if(!a)return null;const{attributes:l,listeners:u,setActivatorNodeRef:d,isDragging:g}=a;return R.jsx(lo,{ref:d,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:g,$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`}}))`
347
347
  position: absolute;
348
348
  top: 0;
349
349
  bottom: 0;
@@ -373,7 +373,7 @@ React keys must be passed directly to JSX without using spread:
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:i,samplesPerPixel:l,showHeader:u=!1,disableHeaderDrag:d=!1,isOverlay:g=!1,isSelected:p=!1,onMouseDown:f,trackId:x,fadeIn:y,fadeOut:v,sampleRate:m=44100,showFades:C=!1,touchOptimized:w=!1})=>{const b=Math.floor(o/l),I=Math.floor((o+i)/l)-b,E=u&&!d&&!g,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:ee,setActivatorNodeRef:re,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:b,$width:I,$isOverlay:g,"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:g,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&&!g&&R.jsxs(R.Fragment,{children:[R.jsx(nr,{clipId:n,trackIndex:r,clipIndex:a,edge:"left",touchOptimized:w,dragHandleProps:{attributes:G,listeners:ee,setActivatorNodeRef:re,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`
377
377
  display: inline-flex;
378
378
  align-items: center;
379
379
  gap: 0.5rem;
@@ -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:i,onTracksClick:l,onTracksMouseDown:u,onTracksMouseMove:d,onTracksMouseUp:g,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:g})]})]})});k.withTheme(Kr);var So=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};
@@ -524,14 +524,14 @@ 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
+ `,$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),g=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),g.current=m.clientX,p.current=C==="start"?e:t;const w=S=>{const I=S.clientX-g.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)}},b=()=>{d(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",b)},[e,t,i,l,a,s]),v=c.useCallback(m=>{m.preventDefault(),m.stopPropagation(),d("region"),g.current=m.clientX,p.current=e,f.current=t;const C=t-e,w=S=>{const I=S.clientX-g.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)},b=()=>{d(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",b)},[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`}}))`
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
+ `,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),g=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=g.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,_)},b=()=>{u(!1),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",b)},[s,o,a]);return R.jsx(Ro,{ref:g,$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))},g=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:g,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`}}))`
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};
@@ -546,7 +546,7 @@ React keys must be passed directly to JSX without using spread:
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
+ `,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:g,timeScaleHeight:p,controls:{show:f,width:x}}=c.useContext(_n),y=qr();c.useEffect(()=>{if(u.current!==null){const w=u.current,b=w.getContext("2d");if(b){b.resetTransform(),b.clearRect(0,0,w.width,w.height),b.imageSmoothingEnabled=!1,b.fillStyle=t,b.scale(y,y);for(const[S,I]of i.entries()){const E=p-I;b.fillRect(S,E,1,I)}}}},[n,y,t,p,a,s,r,i]);const v=Vo(n/1e3,g,d),m=d/g;let C=0;for(let w=0;w<v;w+=m*s/1e3){const b=Math.floor(w);if(C%r===0){const S=C,I=jo(S),E=o?R.jsx(c.Fragment,{children:o(S,b)},`timestamp-${C}`):R.jsx(No,{$left:b,children:I},I);l.push(E),i.set(b,p)}else C%a===0?i.set(b,Math.floor(p/2)):C%s===0&&i.set(b,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`
550
550
  display: inline-flex;
551
551
  align-items: center;
552
552
  gap: 0.5rem;
@@ -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:i,trackId:l,isSelected:u=!1})=>{const{waveHeight:d,controls:{show:g,width:p}}=Qt(),f=_o();return R.jsxs(Ko,{$numChannels:e,className:n,$waveHeight:d,$controlWidth:g?p:0,$width:s,$hasClipHeaders:o,$isSelected:u,children:[R.jsx(Jo,{$controlWidth:g?p:0,$isSelected:u,children:f}),R.jsx(Uo,{$controlWidth:g?p:0,$backgroundColor:r,$offset:a,onClick:i,"data-track-id":l,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;
@@ -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 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),g=ur(d.min,n),p=ur(d.max,n);s[o*2]=g,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=s!==void 0?a+s:void 0;return ss(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 ls=127,cs=-128,us=32767,ds=-32768;function fs(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(T){return new Float32Array(T)}),i=r?o.length:1,l=24,u=fs(a,t),d=e.bits===8?1:2,g=l+u*2*d*i,p=new ArrayBuffer(g),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?cs:ds,b=e.bits===8?ls:us;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(b*I*n/o.length),I<v[0]&&(v[0]=I,v[0]<w&&(v[0]=w)),I>m[0]&&(m[0]=I,m[0]>b&&(m[0]=b))}else for(var D=0;D<i;++D)I=Math.floor(b*o[D][S]*n),I<v[D]&&(v[D]=I,v[D]<w&&(v[D]=w)),I>m[D]&&(m[D]=I,m[D]>b&&(m[D]=b));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 Gt(e){"@babel/helpers - typeof";return Gt=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},Gt(e)}function ms(e){return e&&Gt(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function ps(e){var t=e&&Gt(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 gs(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 g=0;g<t.length;g++)l.setInt16(u,t[g],!0),u+=2;return i}function Ct(e){return e==null}function bs(e,t){var n=atob(e);return n}function vs(e,t,n){var r=bs(e),a=r.indexOf(`
766
+ `,10)+1,s=r.substring(a)+"",o=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(o)}function Cs(e,t,n){var r;return function(s){return r=r||vs(e),new Worker(r,s)}}var xs=Cs("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function ze(e){if(ms(e)&&(e=gs(e)),ps(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 ws(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 ys(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=ys(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 ze(a),e)}else{var s=new xs;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 Is(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)}ze.create=function(t){return new ze(t)};ze.createFromAudio=function(e,t){var n=ws(e);if(e.audio_context&&e.array_buffer)return Is(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 en(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}en.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};en.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};en.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 en(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]),g=new DataView(u),p=0;p<n;p++)g.setUint8(p,d.getUint8(p));g.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 g=this._at(n*this.channels*2+d);this.bits===8?u.setInt8(s+d,g):u.setInt16(s+d*2,g,!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 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 ze.create(r)}else{const r=await t.json();return ze.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,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 Ss(e,t=0){const n=await Bn(e);return na(n,t)}async function As(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 ks(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),x=Math.ceil((r+a)/p);s=s.slice({startIndex:f,endIndex:x})}s.scale!==t&&(s=s.resample({scale:t}));const o=s.channel(n),i=s.bits,l=o.min_array(),u=o.max_array(),d=l.length,g=i===8?new Int8Array(d*2):new Int16Array(d*2);for(let p=0;p<d;p++)g[p*2]=l[p],g[p*2+1]=u[p];return{data:g,bits:i,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 hr(){}const $s=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 Rs(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 Es={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:hr,draggableNodes:new Map,over:null,measureDroppableContainers:hr},Ts=c.createContext(Es),Ds=c.createContext({...$s,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 _s=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:g,over:p}=c.useContext(Ts),{role:f=Cr,roleDescription:x="draggable",tabIndex:y=0}=a??{},v=l?.id===t,m=c.useContext(v?Ds:_s),[C,w]=Xt(),[b,S]=Xt(),I=Rs(o,t),E=Pr(n);Kt(()=>(g.set(t,{id:t,key:s,node:C,activatorNode:b,data:E}),()=>{const _=g.get(t);_&&_.key===s&&g.delete(t)}),[g,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 Bs(e){return{id:e.id,start:parseFloat(e.begin),end:parseFloat(e.end),lines:e.lines,lang:e.language}}function Fs(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 Ws=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
+ `,Zs=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
+ `,Ps=k.span`
880
881
  font-size: 12px;
881
882
  font-weight: 600;
882
883
  color: ${e=>e.theme?.annotationLabelColor||"#2a2a2a"};
@@ -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
+ `,Vs=({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:g,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 b=I=>E=>{E.stopPropagation(),I?.(E)},S=I=>{I.stopPropagation()};return R.jsxs(Ws,{$left:n,$width:u,children:[R.jsx(Zs,{$color:s,$isActive:o,onClick:i,children:a&&R.jsx(Ps,{children:a})}),l&&R.jsx(wr,{ref:f,$position:"left",$isDragging:x,onClick:S,...p,onPointerDown:b(p?.onPointerDown),...g}),l&&R.jsx(wr,{ref:C,$position:"right",$isDragging:w,onClick:S,...m,onPointerDown:b(m?.onPointerDown),...v})]})},js=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
+ `,zs=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
+ `,Os=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
+ `,Ns=({children:e,className:t,height:n=30,offset:r=0,width:a})=>{const{controls:{show:s,width:o}}=Qt();return R.jsxs(js,{className:t,$height:n,$controlWidth:s?o:0,$width:a,children:[R.jsx(zs,{$controlWidth:s?o:0}),R.jsx(Os,{$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 Ls=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
+ `,Xs=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
+ `,Hs=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
+ `,Gs=k.div`
995
996
  display: flex;
996
997
  align-items: center;
997
998
  gap: 8px;
998
- `,Es=k.span`
999
+ `,Ys=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
+ `,Ks=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
+ `,Us=k.div`
1019
1020
  display: flex;
1020
1021
  gap: 6px;
1021
- `,_s=k.button`
1022
+ `,Js=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
+ `,Qs=({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),g=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"}),g.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(`
1057
+ `)},l(w)},x=(m,C)=>{if(!r||!l)return;const w=C.trim();if(!w)return;const b=[...e];b[m]={...b[m],id:w},l(b)},y=(m,C,w)=>{if(!l)return;const b=[...e];m.action(b[w],w,b,s||{}),l(b)},v=m=>m.replace(/\./g," ");return R.jsx(Ls,{ref:d,$height:o,children:e.map((m,C)=>{const w=m.id===t;return R.jsxs(Xs,{ref:w?u:null,$isActive:w,onClick:()=>i?.(m),children:[R.jsxs(Hs,{children:[R.jsxs(Gs,{children:[R.jsx(Ys,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:b=>x(C,b.currentTarget.textContent||""),children:m.id}),R.jsxs(Ks,{children:[p(m.start)," - ",p(m.end)]})]}),a.length>0&&R.jsx(Us,{onClick:b=>b.stopPropagation(),children:a.map((b,S)=>R.jsx(Js,{title:b.title,onClick:()=>y(b,m,C),children:b.text?b.text:R.jsx("i",{className:v(b.class||"")})},S))})]}),R.jsx(qs,{$isEditable:r,contentEditable:r,suppressContentEditableWarning:!0,onBlur:b=>f(C,b.currentTarget.textContent||""),children:m.lines.join(`
1058
+ `)})]},m.id)})})},ei=c.memo(Qs),ti=({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"})]})},ni=({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"})]})},ri=({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"})]}),ai=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
+ `,oi=({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(g=>Fs(g)),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(ai,{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 si=[256,512,1024,2048,4096,8192];function aa({initialSamplesPerPixel:e,zoomLevels:t=si}){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 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 ii=(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,waveformData:d}=e;return{id:sa(),audioBuffer:t,startSample:n,durationSamples:r,offsetSamples:a,gain:s,name:o,color:i,fadeIn:l,fadeOut:u,waveformData:d}}function li(e){const{audioBuffer:t,startTime:n,duration:r=t.duration,offset:a=0,gain:s=1,name:o,color:i,fadeIn:l,fadeOut:u,waveformData:d}=e,g=t.sampleRate;return Sn({audioBuffer:t,startSample:Math.round(n*g),durationSamples:Math.round(r*g),offsetSamples:Math.round(a*g),gain:s,name:o,color:i,fadeIn:l,fadeOut:u,waveformData:d})}function ci(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:sa(),name:t,clips:n,muted:r,soloed:a,volume:s,pan:o,color:i,height:l}}function sa(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function ui(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=li({audioBuffer:v,startTime:p.startTime??0,duration:m,offset:p.offset??0,name:p.name||`Track ${f+1}`,fadeIn:p.fadeIn,fadeOut:p.fadeOut,waveformData:p.waveformData});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{...ci({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}}),g=await Promise.all(d);i||(n(g),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 di({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r}){const a=c.useRef(null),s=c.useCallback(u=>{const{transform:d,active:g}=u;if(!g?.data?.current)return{...d,scaleX:1,scaleY:1};const{trackIndex:p,clipIndex:f,boundary:x}=g.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 b=m+w;const S=[...y.clips].sort((T,V)=>T.startSample-V.startSample),I=S.findIndex(T=>T===v);b=Math.max(0,b);const E=I>0?S[I-1]:null;if(E){const T=(E.startSample+E.durationSamples)/r;b=Math.max(b,T)}const D=I<S.length-1?S[I+1]:null;if(D){const T=b+C,V=D.startSample/r;T>V&&(b=V-C)}const B=(b-m)*r/n;return{...d,x:B,scaleX:1,scaleY:1}},[e,n,r]),o=c.useCallback(u=>{const{active:d}=u,{boundary:g}=d.data.current;if(!g){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:g}=u,{boundary:p}=d.data.current;if(!p||!a.current)return;const{trackIndex:f,clipIndex:x}=d.data.current,y=g.x*n,v=Math.floor(.1*r),m=a.current,C=e.map((w,b)=>{if(b!==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,ee=m.durationSamples-T,re=m.startSample+T;return{...D,offsetSamples:G,durationSamples:ee,startSample:re}}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:g}=u,{trackIndex:p,clipIndex:f,boundary:x}=d.data.current,y=g.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),b=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 _=b>0?w[b-1]:null;if(_){const T=_.startSample+_.durationSamples;D=Math.max(D,T)}const B=b<w.length-1?w[b+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 fi({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:a,linkEndpoints:s}){const o=c.useRef(null),i=c.useCallback(d=>{const{active:g}=d,p=g.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:g,delta:p}=d;if(!o.current)return;const f=g.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=hi({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 hi({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 g=d.start+u;o[e+1]={...d,start:Math.min(d.end-.1,g)};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 g=e+1;for(;g<o.length-1;){const p=o[g],f=o[g+1];if(p.end>f.start)o[g+1]={...f,start:p.end},g++;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 mi(e){const{Document:t}=St(e);return e instanceof t}function pi(e){return Fn(e)?!1:e instanceof St(e).HTMLElement}function gi(e){return e instanceof St(e).SVGElement}function tn(e){return e?Fn(e)?e.document:ia(e)?mi(e)?e:pi(e)||gi(e)?e.ownerDocument:document:document:document}function bi(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 vi=bi(-1);function Ci(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 Ci(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 wi(){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 yi(e){const{EventTarget:t}=St(e);return e instanceof t?e:tn(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 Ii(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 Wn{constructor(t,n,r){var a;r===void 0&&(r=yi(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=tn(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,Ii,{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=vi(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 Si={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class la extends Wn{constructor(t){const{event:n}=t,r=tn(n.target);super(t,Si,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 Ai={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,Ai,tn(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 ki(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:a=1}=e,s=mn(ca,{activationConstraint:{distance:a}}),o=mn(ua,{activationConstraint:t?{delay:n,tolerance:r}:{distance:a}}),i=mn(la,{activationConstraint:{distance:a}});return wi(...t?[s,o]:[i])}const $i=e=>{const{tracks:t,onTracksChange:n,sampleRate:r}=e,{currentTimeRef:a}=We(),{selectedTrackId:s}=Ne(),o=c.useCallback((l,u,d)=>{const{sampleRate:g,samplesPerPixel:p}=e,f=t[l];if(!f)return!1;const x=f.clips[u];if(!x)return!1;const y=x.startSample/g,v=(x.startSample+x.durationSamples)/g;if(d<=y||d>=v)return console.warn("Split time is outside clip bounds"),!1;const m=Math.round(d*g),C=Math.floor(m/p),w=x.startSample+x.durationSamples,b=C*p,S=x.startSample,I=b-S,E=b,D=w-E,_=b-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(g=>g.id===s);if(l===-1)return console.warn("Selected track not found"),!1;const u=t[l],d=a.current??0;for(let g=0;g<u.clips.length;g++){const p=u.clips[g],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,g,d)}return console.log(`No clip found at playhead position on track "${u.name}"`),!1},[t,a,s,o,r]),splitClipAt:o}},Yt=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,g=i.metaKey===void 0||a.metaKey===i.metaKey,p=i.altKey===void 0||a.altKey===i.altKey;return l&&u&&d&&g&&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])},Ri=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("+")},Ei=(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]),g=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:g,description:"Stop",preventDefault:!0},{key:"0",action:p,description:"Rewind to start",preventDefault:!0}],...n];return Yt({shortcuts:x,enabled:t}),{rewindToStart:p,togglePlayPause:d,stopPlayback:g,shortcuts:x}},vn=.01,Ot=.01;function Ti({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:g=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+g,O=B.end*d/u+g,X=(W+O)/2,G=T.scrollLeft,ee=G,re=G+V;if(W<ee||O>re){const L=Math.max(0,X-V/2);T.scrollTo({left:L,behavior:"smooth"})}},[e,l,u,d,g]);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 ee=W[G],re=W[G+1];if(Math.abs(re.start-e[G].end)<vn){const L=ee.end-e[G].end;W[G+1]={...re,start:Math.min(re.end-.1,re.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],ee=W[X+1];if(G.end>ee.start)W[X+1]={...ee,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]),b=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:b,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:S,description:"Deselect annotation",preventDefault:!0}],[m,C,w,b,S]);return Yt({shortcuts:E,enabled:i&&f>=0}),Yt({shortcuts:D,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:y,moveEndBoundary:v,selectPrevious:m,selectNext:C,selectFirst:w,selectLast:b,clearSelection:S,scrollToAnnotation:x,playActiveAnnotation:I}}function Di(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 _i(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 g=i;g<l;g++){const p=e[g];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,g=Math.min(d,t.length);let p=e[e.length-2]/s,f=e[e.length-1]/s;for(let m=0;m<g;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=g;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 Bi(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,g]=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),b=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,g(be=>Mi(be,K,r,_.current-K.length,b))},A.port.postMessage({command:"start",sampleRate:L.sampleRate,channelCount:n}),D.current=[],_.current=0,g(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=Di(D.current),A=P.getContext().rawContext,j=_i(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]),ee=c.useCallback(()=>{a&&!o&&(B.current!==null&&(cancelAnimationFrame(B.current),B.current=null),W.current=!0,i(!0))},[a,o]),re=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:ee,resumeRecording:re,error:x}}function Fi(){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"))}},[]),g=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:g,stopStream:p,error:l}}function Wi(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),g=()=>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=b=>{if(!(!p||!l.current)){if(b-C>=m){C=b;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:g}}k.button`
1084
1085
  padding: 0.5rem 1rem;
1085
1086
  font-size: 0.875rem;
1086
1087
  font-weight: 500;
@@ -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 Zi=k.div`
1177
1178
  position: relative;
1178
1179
  width: ${e=>e.$width}px;
1179
1180
  height: ${e=>e.$height}px;
@@ -1181,19 +1182,19 @@ 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
+ `,Pi=e=>e<.6?"linear-gradient(90deg, #27ae60, #2ecc71)":e<.85?"linear-gradient(90deg, #f39c12, #f1c40f)":"linear-gradient(90deg, #c0392b, #e74c3c)",Vi=k.div.attrs(e=>({style:{width:`${e.$level*100}%`,height:`${e.$height}px`,background:Pi(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
+ `,ji=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
+ `,zi=k.div`
1197
1198
  position: absolute;
1198
1199
  top: 0;
1199
1200
  left: 0;
@@ -1207,13 +1208,13 @@ React keys must be passed directly to JSX without using spread:
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
+ `,Oi=({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(Zi,{$width:n,$height:r,className:a,children:[R.jsx(Vi,{$level:s,$height:r}),t!==void 0&&o>0&&R.jsx(ji,{$peakLevel:o,$height:r}),R.jsxs(zi,{$height:r,children:[R.jsx(Dr,{$position:60,$height:r}),R.jsx(Dr,{$position:85,$height:r})]})]})};c.memo(Oi);function Ni(e,t,n,r={}){const{currentTime:a=0,audioConstraints:s,...o}=r,[i,l]=c.useState(!1),[u,d]=c.useState(null),{stream:g,devices:p,hasPermission:f,requestAccess:x,error:y}=Fi(),{level:v,peakLevel:m}=Wi(g),{isRecording:C,isPaused:w,duration:b,peaks:S,startRecording:I,stopRecording:E,pauseRecording:D,resumeRecording:_,error:B}=Bi(g,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 ee=e[G],re=Math.floor(a*X.sampleRate);let L=0;if(ee.clips.length>0){const H=ee.clips.map(K=>K.startSample+K.durationSamples);L=Math.max(...H)}const oe=Math.max(re,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:b,level:v,peakLevel:m,error:y||B,stream:g,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}]}],Zn=e=>Mt.find(t=>t.id===e),Li=e=>Mt.filter(t=>t.category===e),Xi=[{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"}],Hi={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 Gi=0;const Yi=()=>`effect_${Date.now()}_${++Gi}`;function _t(e,t){const n=Hi[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=Yi();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 Ki(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 Ui(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:b}=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(b),b.connect(w);else{let I=C;S.forEach(E=>{try{E.disconnect()}catch{}I.connect(E.effect),I=E.effect}),I.connect(b),b.connect(w)}},[]),l=c.useCallback(v=>{const m=Zn(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 b={instanceId:w.instanceId,effectId:m.id,definition:m,params:C,bypassed:!1};n(S=>[...S,b])},[]),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(b=>b.map(S=>S.instanceId===v?{...S,params:{...S.params,[m]:C}}:S))},[]),g=c.useCallback(v=>{const m=r.current.find(b=>b.instanceId===v);if(!m)return;const C=!m.bypassed,w=a.current.get(v);if(w){const b=m.params.wet??1;w.setParameter("wet",C?0:b)}n(b=>b.map(S=>S.instanceId===v?{...S,bypassed:C}:S))},[]),p=c.useCallback((v,m)=>{n(C=>{const w=[...C],[b]=w.splice(v,1);return w.splice(m,0,b),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 b=[];for(const S of v){const I=_t(S.definition,S.params);b.push(I)}if(b.length===0)m.connect(C);else{let S=m;b.forEach(I=>{S.connect(I.effect),S=I.effect}),S.connect(C)}return function(){b.forEach(I=>I.dispose())}}},[t]);return{activeEffects:t,availableEffects:Mt,addEffect:l,removeEffect:u,updateParameter:d,toggleBypass:g,reorderEffects:p,clearAllEffects:f,masterEffects:x,createOfflineEffectsFunction:y,analyserRef:s}}function Ji(){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(b=>C?.get(b.instanceId)).filter(b=>b!==void 0);if(w.length===0)v.connect(m);else{let b=v;w.forEach(S=>{try{S.disconnect()}catch{}b.connect(S.effect),b=S.effect}),b.connect(m)}},[]),s=c.useCallback((f,x)=>{const y=Zn(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 b=new Map(w),S=b.get(f)||[];return b.set(f,[...S,C]),b})},[]),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(b=>b.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 b=new Map(w),S=b.get(f)||[];return b.set(f,S.map(I=>I.instanceId===x?{...I,params:{...I.params,[y]:v}}:I)),b})},[]),l=c.useCallback((f,x)=>{const v=(d.current.get(f)||[]).find(b=>b.instanceId===x);if(!v)return;const m=!v.bypassed,w=n.current.get(f)?.get(x);if(w){const b=v.params.wet??1;w.setParameter("wet",m?0:b)}t(b=>{const S=new Map(b),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 g=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(b=>C?.get(b.instanceId)).filter(b=>b!==void 0);if(w.length===0)x.connect(y);else{let b=x;w.forEach(S=>{b.connect(S.effect),b=S.effect}),b.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 b of y){const S=_t(b.definition,b.params);w.push(S)}if(w.length===0)v.connect(m);else{let b=v;w.forEach(S=>{b.connect(S.effect),b=S.effect}),b.connect(m)}return function(){w.forEach(S=>S.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:s,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:u,getTrackEffectsFunction:g,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,i=r*o,l=a*i,u=s*i,d=44,g=d+u,p=new ArrayBuffer(g),f=new DataView(p);Nt(f,0,"RIFF"),f.setUint32(4,g-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)),b=w<0?w*32768:w*32767;f.setInt16(y,b,!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 Qi(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(i,l,u={})=>{const{filename:d="export",mode:g="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(g==="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 b=0;for(const T of i)for(const V of T.clips){const W=V.startSample+V.durationSamples;b=Math.max(b,W)}b+=Math.round(w*.1);const S=b/w,I=g==="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 el(I,l,E,S,w,y,v,T=>{r(T),C?.(T)});else{const T=new OfflineAudioContext(2,b,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 nl(T,G,X,w,x),V++;const ee=V/W*.5;r(ee),C?.(ee)}r(.5),C?.(.5),_=await T.startRendering()}r(.9),C?.(.9);const B=qi(_,{bitDepth:m});if(r(1),C?.(1),f){const T=g==="individual"?`${d}_${i[p].name}`:d;Qi(B,`${T}.wav`)}return{audioBuffer:_,blob:B,duration:S}}catch(w){const b=w instanceof Error?w.message:"Export failed";throw s(b),w}finally{t(!1)}},[]),isExporting:e,progress:n,error:a}}async function el(e,t,n,r,a,s,o,i){const{Offline:l,Volume:u,Gain:d,Panner:g,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:b}of e){if(b.muted&&!b.soloed||n&&!b.soloed)continue;const S=new u(tl(b.volume)),I=new g(b.pan),E=new d(b.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}=_,ee=T/a,re=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=ee,K=ee+X.duration,be=j.gain._param;be.setValueAtTime(0,H),be.linearRampToValueAtTime(O,K)}if(G){const H=ee+re-G.duration,K=ee+re,be=j.gain._param;be.setValueAtTime(O,H),be.linearRampToValueAtTime(0,K)}A.start(ee,L,re)}}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 tl(e){return 20*Math.log10(Math.max(e,1e-4))}async function nl(e,t,n,r,a){const{audioBuffer:s,startSample:o,durationSamples:i,offsetSamples:l,gain:u,fadeIn:d,fadeOut:g}=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,b=p+d.duration;_r(v.gain,w,b,0,m,d.type||"linear")}if(g){const w=p+f-g.duration,b=p+f;(!d||d.duration<f-g.duration)&&v.gain.setValueAtTime(m,w),_r(v.gain,w,b,m,0,g.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 fa=c.createContext(null),ha=c.createContext(null),ma=c.createContext(null),pa=c.createContext(null),ga=c.createContext(null),rl=({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:g,onAnnotationUpdate:p,barWidth:f=1,barGap:x=0,progressBarWidth:y,children:v})=>{const m=y??f+x,[C,w]=c.useState([]),[b,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,ee]=c.useState([]),[re,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),[Je,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),te=c.useRef(a),me=c.useRef(!1),ye=c.useRef(0),Ee=c.useRef(0),Ae=c.useRef(0),le=c.useRef(0),{timeFormat:Ge,setTimeFormat:Ye,formatTime:je}=ra(),_e=aa({initialSamplesPerPixel:a,zoomLevels:s}),Ie=_e.samplesPerPixel,{masterVolume:qe,setMasterVolume:ft}=oa({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)=>{Ae.current=M,le.current=N,at(M),ot(N)},[]),Wt=c.useCallback(()=>{const M=ye.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(()=>{ye.current=re,Ee.current=oe},[re,oe]),c.useEffect(()=>{if(!He.current||!V.length)return;const M=He.current,N=te.current,q=Ie;if(N===q)return;const fe=l.show?l.width:0,Q=M.clientWidth,Ke=M.scrollLeft+Q/2-fe,ge=V[0].sampleRate,Ue=Ke*N/ge*ge/q,mt=Math.max(0,Ue+fe-Q/2);M.scrollLeft=mt,te.current=q},[Ie,V,l]);const bt=c.useRef(null);c.useEffect(()=>{if(e.length===0){W([]),T(0),ee([]),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 Q=0;e.forEach(ge=>{ge.clips.forEach($e=>{const Ue=$e.audioBuffer.sampleRate,sn=($e.startSample+$e.durationSamples)/Ue;Q=Math.max(Q,sn)})}),W(fe),T(Q),ee(ge=>ge.length===e.length?ge.map(($e,Ue)=>({...$e,name:e[Ue].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 Ma({effects:d}),Ke=Ze.current;e.forEach((ge,$e)=>{if(ge.clips.length>0){const Ue=ge.clips[0].audioBuffer.sampleRate,mt=Math.min(...ge.clips.map(Ve=>Ve.startSample/Ue)),sn=Math.max(...ge.clips.map(Ve=>(Ve.startSample+Ve.durationSamples)/Ue)),Pt=Ke[$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}});Se.addTrack({clips:va,track:ba,effects:ge.effects})}}),Se.applyInitialSoloState(),z.current=Se,g?.()}catch(fe){console.error("Error loading audio:",fe)}})(),()=>{ve.current&&cancelAnimationFrame(ve.current),z.current&&z.current.dispose()}},[e,g,I]),c.useEffect(()=>{if(e.length===0)return;const M=16,N=e.map(q=>q.clips.map(Q=>{if(Q.waveformData){const Ke=ks(Q.waveformData,Ie,0,Q.offsetSamples,Q.durationSamples);return{clipId:Q.id,trackName:q.name,peaks:{length:Ke.length,data:[Ke.data],bits:Ke.bits},startSample:Q.startSample,durationSamples:Q.durationSamples,fadeIn:Q.fadeIn,fadeOut:Q.fadeOut}}const Se=is(Q.audioBuffer,Ie,n,M,Q.offsetSamples,Q.durationSamples);return{clipId:Q.id,trackName:q.name,peaks:Se,startSample:Q.startSample,durationSamples:Q.durationSamples,fadeIn:Q.fadeIn,fadeOut:Q.fadeOut}}));X(N)},[e,Ie,n]),c.useEffect(()=>{if(u?.annotations){const M=u.annotations.map(N=>typeof N.start=="number"?N:Bs(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 Q=C.find(Se=>q>=Se.start&&q<Se.end);if(At.current){if(Q&&Q.id!==Y.current)st(Q.id);else if(!Q&&Y.current!==null){const Se=C[C.length-1];if(q>=Se.end){z.current&&z.current.stop(),E(!1),we.current=Re.current,_(Re.current),st(null);return}}}else if(Y.current){const Se=C.find(Ke=>Ke.id===Y.current);if(Se&&q>=Se.end){z.current&&z.current.stop(),E(!1),we.current=Re.current,_(Re.current);return}}else Q&&st(Q.id)}if(dt.current&&He.current&&V.length>0){const Q=He.current,Se=V[0].sampleRate,Ke=q*Se/te.current,ge=Q.clientWidth,$e=l.show?l.width:0,Ue=Ke+$e,mt=Math.max(0,Ue-ge/2);Q.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=Ae.current!==le.current&&le.current>Ae.current;if(me.current&&fe&&q>=le.current){z.current?.stop();const Se=P.getContext().currentTime;Le.current=Se,Pe.current=Ae.current,we.current=Ae.current,z.current?.play(Se,Ae.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,Ie,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 Q=P.getContext().currentTime;Le.current=Q,Pe.current=q,Xe.current=N!==void 0?q+N:null,z.current.play(Q,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},ee(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},ee(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},ee(q),z.current){const fe=`track-${M}`,Q=z.current.getTrack(fe);Q&&Q.setVolume(N)}},[G]),F=c.useCallback((M,N)=>{const q=[...G];if(q[M]={...q[M],pan:N},ee(q),z.current){const fe=`track-${M}`,Q=z.current.getTrack(fe);Q&&Q.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,ae=t?30:0,ne=e.length*r+ae,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:b,selectionStart:re,selectionEnd:oe,selectedTrackId:j,loopStart:rt,loopEnd:Je},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:ae,minimumPlaylistHeight:ne,controls:l,playoutRef:z,samplesPerPixel:Ie,timeFormat:Ge,masterVolume:qe,canZoomIn:_e.canZoomIn,canZoomOut:_e.canZoomOut,barWidth:f,barGap:x,progressBarWidth:m},it={...ke,...pe,...Ce,...Me},et={...qa,...i};return Z.jsx(k.ThemeProvider,{theme:et,children:Z.jsx(fa.Provider,{value:ke,children:Z.jsx(ha.Provider,{value:pe,children:Z.jsx(ma.Provider,{value:Ce,children:Z.jsx(pa.Provider,{value:Me,children:Z.jsx(ga.Provider,{value:it,children:v})})})})})})},We=()=>{const e=c.useContext(fa);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},Ne=()=>{const e=c.useContext(ha);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},xe=()=>{const e=c.useContext(ma);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},Te=()=>{const e=c.useContext(pa);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e},al=()=>{const e=c.useContext(ga);if(!e)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return e},ol=({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"})},sl=({className:e})=>{const{isPlaying:t}=We(),{pause:n}=xe();return Z.jsx(Oe,{onClick:n,disabled:!t,className:e,children:"Pause"})},il=({className:e})=>{const{isPlaying:t}=We(),{stop:n}=xe();return Z.jsx(Oe,{onClick:n,disabled:!t,className:e,children:"Stop"})},ll=({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"})},cl=({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"})},ul=({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"})},dl=({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"})},fl=({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"})},hl=({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"})},ml=({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"})},pl=({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"})},gl=({className:e})=>{const{masterVolume:t}=Te(),{setMasterVolume:n}=xe();return Z.jsx(vo,{volume:t,onChange:n,className:e})},bl=({className:e})=>{const{timeFormat:t}=Te(),{setTimeFormat:n}=xe();return Z.jsx(Yo,{value:t,onChange:n,className:e})},vl=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
+ `,Cl=({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 g=P.getContext().currentTime-(s.current??0);d=(o.current??0)+g}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(vl,{ref:t,className:e,"aria-label":"Audio position",children:It(a.current??0,l)})},xl=({className:e})=>{const{selectionStart:t,selectionEnd:n}=Ne(),{setSelection:r}=xe();return Z.jsx(To,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},wl=({className:e})=>{const{isAutomaticScroll:t}=Ne(),{setAutomaticScroll:n}=xe();return Z.jsx(Ja,{checked:t,onChange:n,className:e})},yl=({className:e})=>{const{continuousPlay:t}=Ne(),{setContinuousPlay:n}=xe();return Z.jsx(ti,{checked:t,onChange:n,className:e})},Il=({className:e})=>{const{linkEndpoints:t}=Ne(),{setLinkEndpoints:n}=xe();return Z.jsx(ni,{checked:t,onChange:n,className:e})},Sl=({className:e})=>{const{annotationsEditable:t}=Ne(),{setAnnotationsEditable:n}=xe();return Z.jsx(ri,{checked:t,onChange:n,className:e})},Al=({filename:e,className:t})=>{const{annotations:n}=Ne();return Z.jsx(oi,{annotations:n,filename:e,className:t})},kl=({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:g,trackStates:p}=Te(),{exportWav:f,isExporting:x,progress:y}=da(),v=async()=>{try{const C=await f(g,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||g.length===0,className:l,children:m})},$l=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
+ `,Rl=({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 g=()=>{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(g))};return a?r.current=requestAnimationFrame(g):g(),()=>{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($l,{ref:n,$color:e,$width:d,"data-playhead":!0})},El=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
+ `,Dl=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
+ `,_l=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}=Qt(),{isPlaying:i,currentTimeRef:l,playbackStartTimeRef:u,audioStartPositionRef:d}=We(),{samplesPerPixel:g,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,b=e+t;let S=0;if(w<=e)S=0;else if(w>=b)S=n.length;else{const I=w-e;S=Math.floor(I/g)}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,g,e,t,n.length,l,u,d]),c.useEffect(()=>{if(!i&&r.current){const C=(l.current??0)*p,w=e+t;let b=0;if(C<=e)b=0;else if(C>=w)b=n.length;else{const S=C-e;b=Math.floor(S/g)}r.current.style.width=`${b}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(El,{children:[Z.jsx(Tl,{$color:v,$height:o,$top:n.index*o,$width:n.length}),Z.jsx(Dl,{ref:r,$color:f,$height:o,$top:n.index*o}),Z.jsx(_l,{children:Z.jsx(Po,{...n,transparentBackground:!0})})]})},Ml=60,Bl=({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:g})=>{const p=Mn(),{isPlaying:f,currentTimeRef:x,playbackStartTimeRef:y,audioStartPositionRef:v}=We(),{selectionStart:m,selectionEnd:C,annotations:w,activeAnnotationId:b,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:ee,setSelection:re,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:Je}=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(g?.isRecording){const te=(g.startSample+g.durationSamples)/he;ve=Math.max(ve,te+10)}const Ze=Math.floor(ve*he/ue),Le=async Y=>{console.log("Annotation clicked:",Y.id),W(Y.id);const te=E?void 0:Y.end-Y.start;await L(Y.start,te)},Pe=c.useCallback(Y=>{if(Y>=0&&Y<ie.length){const te=ie[Y];A(te.id)}},[ie,A]),Xe=Y=>{const te=Y.currentTarget.getBoundingClientRect(),me=de.show?de.width:0,Ee=(Y.clientX-te.left-me)*ue/he,le=Y.clientY-te.top;let Ge=0,Ye=-1;for(let je=0;je<be.length;je++){const _e=be[je],qe=(_e.length>0?Math.max(..._e.map(ft=>ft.peaks.data.length)):1)*gt+(i?22:0);if(le>=Ge&&le<Ge+qe){Ye=je;break}Ge+=qe}Ye!==-1&&Pe(Ye),z(!0),j(Ee),re(Ee,Ee)},He=Y=>{if(!ot)return;const te=Y.currentTarget.getBoundingClientRect(),me=de.show?de.width:0,Ee=(Y.clientX-te.left-me)*ue/he,Ae=Math.min(m,Ee),le=Math.max(m,Ee);re(Ae,le)},dt=Y=>{if(!ot)return;z(!1);const te=Y.currentTarget.getBoundingClientRect(),me=de.show?de.width:0,Ee=(Y.clientX-te.left-me)*ue/he,Ae=Math.min(m,Ee),le=Math.max(m,Ee);Math.abs(le-Ae)<.1?(j(Ae),f&&rt.current?(rt.current.stop(),L(Ae)):rt.current&&rt.current.stop()):re(Ae,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:Je},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,te)=>{const me=Y*ue/he,ye=te*ue/he;H(me,ye)}})]}):void 0,children:Z.jsxs(Z.Fragment,{children:[be.map((Y,te)=>{const me=ie[te];if(!me)return null;const ye=Be[te]||{name:`Track ${te+1}`,muted:!1,soloed:!1,volume:1,pan:0},Ee=e?e(te):Z.jsxs(es,{onClick:()=>Pe(te),children:[Z.jsx(ts,{style:{justifyContent:"center"},children:ye.name||`Track ${te+1}`}),Z.jsxs(Qo,{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:()=>X(te,!ye.soloed),children:"Solo"})]}),Z.jsxs(cr,{children:[Z.jsx(ns,{}),Z.jsx(lr,{min:"0",max:"1",step:"0.01",value:ye.volume,onChange:le=>G(te,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:ye.pan,onChange:le=>ee(te,parseFloat(le.target.value))}),Z.jsx("span",{children:"R"})]})]}),Ae=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:Ae,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:te,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(te)},children:Ye.data.map((_e,Ie)=>Z.jsx(Br,{index:Ie,data:_e,bits:Ye.bits,length:je,isSelected:me.id===D,clipStartSample:le.startSample,clipDurationSamples:le.durationSamples},`${te}-${Ge}-${Ie}`))},`${te}-${Ge}`)}),g?.isRecording&&g.trackId===me.id&&g.peaks.length>0&&Z.jsx(ar,{clipId:"recording-preview",trackIndex:te,clipIndex:Y.length,trackName:"Recording...",startSample:g.startSample,durationSamples:g.durationSamples,samplesPerPixel:ue,showHeader:i,disableHeaderDrag:!0,isSelected:me.id===D,trackId:me.id,children:Z.jsx(Br,{index:0,data:g.peaks,bits:16,length:Math.floor(g.peaks.length/2),isSelected:me.id===D,clipStartSample:g.startSample,clipDurationSamples:g.durationSamples},`${te}-recording-0`)},`${te}-recording`)]})},me.id)}),w.length>0&&Z.jsx(Ns,{height:30,width:Ze,children:w.map((Y,te)=>{const me=Y.start*he/ue,ye=Y.end*he/ue;return Z.jsx(Vs,{annotationId:Y.id,annotationIndex:te,startPosition:me,endPosition:ye,label:Y.id,color:"#ff9800",isActive:Y.id===b,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(Rl,{color:p.playheadColor,controlsOffset:de.show?de.width:0}))]})}),w.length>0&&Z.jsx(ei,{annotations:w,activeAnnotationId:b??void 0,shouldScrollToActive:!0,editable:S,controls:S?r:void 0,annotationListConfig:{linkEndpoints:I,continuousPlay:E},height:s,onAnnotationUpdate:Y=>{V(Y)}})]})})};exports.Tone=Wr;exports.AudioPosition=Cl;exports.AutomaticScrollCheckbox=wl;exports.ContinuousPlayCheckbox=yl;exports.DownloadAnnotationsButton=Al;exports.EditableCheckbox=Sl;exports.ExportWavButton=kl;exports.FastForwardButton=cl;exports.LinkEndpointsCheckbox=Il;exports.LoopButton=fl;exports.MasterVolumeControl=gl;exports.PauseButton=sl;exports.PlayButton=ol;exports.RewindButton=ll;exports.SelectionTimeInputs=xl;exports.SetLoopRegionButton=hl;exports.SkipBackwardButton=ul;exports.SkipForwardButton=dl;exports.StopButton=il;exports.TimeFormatSelect=bl;exports.Waveform=Bl;exports.WaveformPlaylistProvider=rl;exports.ZoomInButton=ml;exports.ZoomOutButton=pl;exports.createEffectChain=Ki;exports.createEffectInstance=_t;exports.effectCategories=Xi;exports.effectDefinitions=Mt;exports.getEffectDefinition=Zn;exports.getEffectsByCategory=Li;exports.getShortcutLabel=Ri;exports.getWaveformDataMetadata=As;exports.loadPeaksFromWaveformData=Ss;exports.loadWaveformData=Bn;exports.useAnnotationDragHandlers=fi;exports.useAnnotationKeyboardControls=Ti;exports.useAudioTracks=ui;exports.useClipDragHandlers=di;exports.useClipSplitting=$i;exports.useDragSensors=ki;exports.useDynamicEffects=Ui;exports.useExportWav=da;exports.useIntegratedRecording=Ni;exports.useKeyboardShortcuts=Yt;exports.useMasterAnalyser=ii;exports.useMasterVolume=oa;exports.usePlaybackAnimation=We;exports.usePlaybackShortcuts=Ei;exports.usePlaylistControls=xe;exports.usePlaylistData=Te;exports.usePlaylistState=Ne;exports.useTimeFormat=ra;exports.useTrackDynamicEffects=Ji;exports.useWaveformPlaylist=al;exports.useZoomControls=aa;exports.waveformDataToPeaks=na;
1254
1254
  //# sourceMappingURL=index.js.map