@waveform-playlist/browser 5.0.0-alpha.5 → 5.0.0-alpha.7
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.d.ts +17 -0
- package/dist/index.js +203 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4113 -3481
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,K,ie,De,ie),oe[ie+K]=!0)}if(ie=null,H!==void 0&&(n(H),ie=""+H),o(j)&&(n(j.key),ie=""+j.key),"key"in j){H={};for(var ue in j)ue!=="key"&&(H[ue]=j[ue])}else H=j;return ie&&i(H,typeof A=="function"?A.displayName||A.name||"Unknown":A),u(A,ie,H,a(),be,Be)}function b(A){p(A)?A._store&&(A._store.validated=1):typeof A=="object"&&A!==null&&A.$$typeof===_&&(A._payload.status==="fulfilled"?p(A._payload.value)&&A._payload.value._store&&(A._payload.value._store.validated=1):A._store&&(A._store.validated=1))}function p(A){return typeof A=="object"&&A!==null&&A.$$typeof===x}var f=c,x=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),g=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),T=Symbol.for("react.client.reference"),V=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=Object.prototype.hasOwnProperty,O=Array.isArray,X=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(A){return A()}};var G,Q={},ne=f.react_stack_bottom_frame.bind(f,s)(),L=X(r(s)),oe={};$t.Fragment=v,$t.jsx=function(A,j,H){var K=1e4>V.recentlyCreatedOwnerStacks++;return d(A,j,H,!1,K?Error("react-stack-top-frame"):ne,K?X(r(A)):L)},$t.jsxs=function(A,j,H){var K=1e4>V.recentlyCreatedOwnerStacks++;return d(A,j,H,!0,K?Error("react-stack-top-frame"):ne,K?X(r(A)):L)}})()),$t}var zn;function Ra(){return zn||(zn=1,process.env.NODE_ENV==="production"?Vt.exports=ka():Vt.exports=$a()),Vt.exports}var Z=Ra();function On(e,t){const n=new Float32Array(e),r=e-1;for(let a=0;a<e;a++){const s=a/r;n[a]=t?s:1-s}return n}function Ea(e,t){const n=new Float32Array(e),r=e-1;for(let a=0;a<e;a++){const s=a/r,o=t?a:e-1-a;n[o]=Math.exp(2*s-1)/Math.E}return n}function Ta(e,t){const n=new Float32Array(e),r=t?Math.PI/2:-Math.PI/2;for(let a=0;a<e;a++)n[a]=Math.sin(Math.PI*a/e-r)/2+.5;return n}function Da(e,t,n=10){const r=new Float32Array(e);for(let a=0;a<e;a++){const s=t?a:e-1-a,o=a/e;r[s]=Math.log(1+n*o)/Math.log(1+n)}return r}function Zr(e,t,n){switch(e){case"linear":return On(t,n);case"exponential":return Ea(t,n);case"sCurve":return Ta(t,n);case"logarithmic":return Da(t,n);default:return On(t,n)}}function Nn(e,t,n,r="linear",a=0,s=1){if(!(n<=0))if(r==="linear")e.setValueAtTime(a,t),e.linearRampToValueAtTime(s,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(a,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+n);else{const o=Zr(r,1e4,!0),i=new Float32Array(o.length),l=s-a;for(let u=0;u<o.length;u++)i[u]=a+o[u]*l;e.setValueCurveAtTime(i,t,n)}}function Ln(e,t,n,r="linear",a=1,s=0){if(!(n<=0))if(r==="linear")e.setValueAtTime(a,t),e.linearRampToValueAtTime(s,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(a,.001),t),e.exponentialRampToValueAtTime(Math.max(s,.001),t+n);else{const o=Zr(r,1e4,!1),i=new Float32Array(o.length),l=a-s;for(let u=0;u<o.length;u++)i[u]=s+o[u]*l;e.setValueCurveAtTime(i,t,n)}}var _a=class{constructor(e){this.activePlayers=0,this.track=e.track,this.volumeNode=new P.Volume(this.gainToDb(e.track.gain)),this.panNode=new P.Panner(e.track.stereoPan),this.muteGain=new P.Gain(e.track.muted?0:1);const t=e.destination||P.getDestination();if(e.effects){const r=e.effects(this.muteGain,t,!1);r&&(this.effectsCleanup=r)}else this.muteGain.connect(t);const n=e.clips||(e.buffer?[{buffer:e.buffer,startTime:0,duration:e.buffer.duration,offset:0,fadeIn:e.track.fadeIn,fadeOut:e.track.fadeOut,gain:1}]:[]);this.clips=n.map(r=>{const a=new P.Player({url:r.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}}),s=new P.Gain(r.gain);return a.connect(s),s.chain(this.volumeNode,this.panNode,this.muteGain),{player:a,clipInfo:r,fadeGain:s,pausedPosition:0,playStartTime:0}})}scheduleFades(e,t,n=0){const{clipInfo:r,fadeGain:a}=e,s=a.gain._param;s.cancelScheduledValues(0);const o=n-r.offset;if(r.fadeIn&&o<r.fadeIn.duration){const i=r.fadeIn.duration;if(o<=0)Nn(s,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,u=o/i,d=r.gain*u;Nn(s,t,l,r.fadeIn.type||"linear",d,r.gain)}}else s.setValueAtTime(r.gain,t);if(r.fadeOut){const l=r.duration-r.fadeOut.duration-o;if(l>0){const u=t+l;Ln(s,u,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const u=-l,d=r.fadeOut.duration-u,b=u/r.fadeOut.duration,p=r.gain*(1-b);Ln(s,t,d,r.fadeOut.type||"linear",p,0)}}}gainToDb(e){return 20*Math.log10(e)}setVolume(e){this.track.gain=e,this.volumeNode.volume.value=this.gainToDb(e)}setPan(e){this.track.stereoPan=e,this.panNode.pan.value=e}setMute(e){this.track.muted=e,this.muteGain.gain.value=e?0:1}setSolo(e){this.track.soloed=e}play(e,t=0,n){const r=e??P.now();this.isPlaying&&this.stop(),this.activePlayers=0,this.clips.forEach(a=>{const{player:s,clipInfo:o}=a,i=t,l=o.startTime,u=o.startTime+o.duration;if(i<u)if(this.activePlayers++,a.playStartTime=P.now(),i>=l){const d=i-l+o.offset,b=o.duration-(i-l),p=n?Math.min(n,b):b;a.pausedPosition=d,this.scheduleFades(a,r,d),s.start(r,d,p)}else{const d=l-i,b=n?Math.min(n-d,o.duration):o.duration;d<(n??1/0)?(a.pausedPosition=o.offset,this.scheduleFades(a,r+d,o.offset),s.start(r+d,o.offset,b)):this.activePlayers--}})}pause(){this.clips.forEach(e=>{if(e.player.state==="started"){const t=(P.now()-e.playStartTime)*e.player.playbackRate;e.pausedPosition=e.pausedPosition+t}e.player.stop()}),this.activePlayers=0}stop(e){const t=e??P.now();this.clips.forEach(n=>{n.player.stop(t),n.pausedPosition=0}),this.activePlayers=0}dispose(){this.effectsCleanup&&this.effectsCleanup(),this.clips.forEach(e=>{e.player.dispose(),e.fadeGain.dispose()}),this.volumeNode.dispose(),this.panNode.dispose(),this.muteGain.dispose()}get id(){return this.track.id}get duration(){if(this.clips.length===0)return 0;const e=this.clips[this.clips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get buffer(){return this.clips[0]?.clipInfo.buffer}get isPlaying(){return this.clips.some(e=>e.player.state==="started")}get muted(){return this.track.muted}get startTime(){return this.track.startTime}setOnStopCallback(e){this.onStopCallback=e}},Ma=class{constructor(e={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this.activeTracks=new Map,this.playbackSessionId=0,this.masterVolume=new P.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,P.getDestination(),!1);t&&(this.effectsCleanup=t)}else this.masterVolume.toDestination();e.tracks&&e.tracks.forEach(t=>{this.tracks.set(t.id,t),this.manualMuteState.set(t.id,t.muted)})}gainToDb(e){return 20*Math.log10(e)}async init(){this.isInitialized||(await P.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new _a(t);return this.tracks.set(n.id,n),this.manualMuteState.set(n.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(n.id),n}applyInitialSoloState(){this.updateSoloMuting()}removeTrack(e){const t=this.tracks.get(e);t&&(t.dispose(),this.tracks.delete(e),this.manualMuteState.delete(e),this.soloedTracks.delete(e))}getTrack(e){return this.tracks.get(e)}play(e,t,n){if(!this.isInitialized){console.warn("TonePlayout not initialized. Call init() first.");return}const r=e??P.now(),a=t??0;this.playbackSessionId++;const s=this.playbackSessionId;this.activeTracks.clear(),this.tracks.forEach(o=>{const i=o.startTime;if(a>=i){const l=a-i;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r,l,n)}else{const l=i-a;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r+l,0,n)}}),t!==void 0?P.getTransport().start(r,t):P.getTransport().start(r)}pause(){P.getTransport().pause(),this.tracks.forEach(e=>{e.pause()})}stop(){P.getTransport().stop(),this.tracks.forEach(e=>{e.stop()})}setMasterGain(e){this.masterVolume.volume.value=this.gainToDb(e)}setSolo(e,t){const n=this.tracks.get(e);n&&(n.setSolo(t),t?this.soloedTracks.add(e):this.soloedTracks.delete(e),this.updateSoloMuting())}updateSoloMuting(){const e=this.soloedTracks.size>0;this.tracks.forEach((t,n)=>{if(e)if(!this.soloedTracks.has(n))t.setMute(!0);else{const r=this.manualMuteState.get(n)??!1;t.setMute(r)}else{const r=this.manualMuteState.get(n)??!1;t.setMute(r)}})}setMute(e,t){const n=this.tracks.get(e);n&&(this.manualMuteState.set(e,t),n.setMute(t))}getCurrentTime(){return P.getTransport().seconds}seekTo(e){P.getTransport().seconds=e}dispose(){this.tracks.forEach(e=>{e.dispose()}),this.tracks.clear(),this.effectsCleanup&&this.effectsCleanup(),this.masterVolume.dispose()}get context(){return P.getContext()}get sampleRate(){return P.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},jt=null;function Ba(){return jt||(jt=new P.Context,P.setContext(jt)),jt}async function un(){const e=Ba();e.state!=="running"&&await e.resume()}var zt={exports:{}},Rt={};var Xn;function Fa(){if(Xn)return Rt;Xn=1;var e=c,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(i,l,u){var d,b={},p=null,f=null;u!==void 0&&(p=""+u),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(b[d]=l[d]);if(i&&i.defaultProps)for(d in l=i.defaultProps,l)b[d]===void 0&&(b[d]=l[d]);return{$$typeof:t,type:i,key:p,ref:f,props:b,_owner:a.current}}return Rt.Fragment=n,Rt.jsx=o,Rt.jsxs=o,Rt}var Et={};var Hn;function Wa(){return Hn||(Hn=1,process.env.NODE_ENV!=="production"&&(function(){var e=c,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),x=Symbol.iterator,y="@@iterator";function v(h){if(h===null||typeof h!="object")return null;var $=x&&h[x]||h[y];return typeof $=="function"?$:null}var m=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(h){{for(var $=arguments.length,F=new Array($>1?$-1:0),U=1;U<$;U++)F[U-1]=arguments[U];w("error",h,F)}}function w(h,$,F){{var U=m.ReactDebugCurrentFrame,se=U.getStackAddendum();se!==""&&($+="%s",F=F.concat([se]));var ce=F.map(function(re){return String(re)});ce.unshift("Warning: "+$),Function.prototype.apply.call(console[h],console,ce)}}var g=!1,S=!1,I=!1,E=!1,D=!1,_;_=Symbol.for("react.module.reference");function B(h){return!!(typeof h=="string"||typeof h=="function"||h===r||h===s||D||h===a||h===u||h===d||E||h===f||g||S||I||typeof h=="object"&&h!==null&&(h.$$typeof===p||h.$$typeof===b||h.$$typeof===o||h.$$typeof===i||h.$$typeof===l||h.$$typeof===_||h.getModuleId!==void 0))}function T(h,$,F){var U=h.displayName;if(U)return U;var se=$.displayName||$.name||"";return se!==""?F+"("+se+")":F}function V(h){return h.displayName||"Context"}function W(h){if(h==null)return null;if(typeof h.tag=="number"&&C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case a:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof h=="object")switch(h.$$typeof){case i:var $=h;return V($)+".Consumer";case o:var F=h;return V(F._context)+".Provider";case l:return T(h,h.render,"ForwardRef");case b:var U=h.displayName||null;return U!==null?U:W(h.type)||"Memo";case p:{var se=h,ce=se._payload,re=se._init;try{return W(re(ce))}catch{return null}}}return null}var O=Object.assign,X=0,G,Q,ne,L,oe,A,j;function H(){}H.__reactDisabledLog=!0;function K(){{if(X===0){G=console.log,Q=console.info,ne=console.warn,L=console.error,oe=console.group,A=console.groupCollapsed,j=console.groupEnd;var h={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:h,log:h,warn:h,error:h,group:h,groupCollapsed:h,groupEnd:h})}X++}}function be(){{if(X--,X===0){var h={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},h,{value:G}),info:O({},h,{value:Q}),warn:O({},h,{value:ne}),error:O({},h,{value:L}),group:O({},h,{value:oe}),groupCollapsed:O({},h,{value:A}),groupEnd:O({},h,{value:j})})}X<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Be=m.ReactCurrentDispatcher,ie;function De(h,$,F){{if(ie===void 0)try{throw Error()}catch(se){var U=se.stack.trim().match(/\n( *(at )?)/);ie=U&&U[1]||""}return`
|
|
7
|
+
`+ie+h}}var ue=!1,he;{var gt=typeof WeakMap=="function"?WeakMap:Map;he=new gt}function ut(h,$){if(!h||ue)return"";{var F=he.get(h);if(F!==void 0)return F}var U;ue=!0;var se=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ce;ce=Be.current,Be.current=null,K();try{if($){var re=function(){throw Error()};if(Object.defineProperty(re.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(re,[])}catch(M){U=M}Reflect.construct(h,[],re)}else{try{re.call()}catch(M){U=M}h.call(re.prototype)}}else{try{throw Error()}catch(M){U=M}h()}}catch(M){if(M&&U&&typeof M.stack=="string"){for(var te=M.stack.split(`
|
|
8
|
+
`),ke=U.stack.split(`
|
|
9
|
+
`),pe=te.length-1,Ce=ke.length-1;pe>=1&&Ce>=0&&te[pe]!==ke[Ce];)Ce--;for(;pe>=1&&Ce>=0;pe--,Ce--)if(te[pe]!==ke[Ce]){if(pe!==1||Ce!==1)do if(pe--,Ce--,Ce<0||te[pe]!==ke[Ce]){var Me=`
|
|
10
|
+
`+te[pe].replace(" at new "," at ");return h.displayName&&Me.includes("<anonymous>")&&(Me=Me.replace("<anonymous>",h.displayName)),typeof h=="function"&&he.set(h,Me),Me}while(pe>=1&&Ce>=0);break}}}finally{ue=!1,Be.current=ce,be(),Error.prepareStackTrace=se}var it=h?h.displayName||h.name:"",Qe=it?De(it):"";return typeof h=="function"&&he.set(h,Qe),Qe}function de(h,$,F){return ut(h,!1)}function rt(h){var $=h.prototype;return!!($&&$.isReactComponent)}function at(h,$,F){if(h==null)return"";if(typeof h=="function")return ut(h,rt(h));if(typeof h=="string")return De(h);switch(h){case u:return De("Suspense");case d:return De("SuspenseList")}if(typeof h=="object")switch(h.$$typeof){case l:return de(h.render);case b:return at(h.type,$,F);case p:{var U=h,se=U._payload,ce=U._init;try{return at(ce(se),$,F)}catch{}}}return""}var Ue=Object.prototype.hasOwnProperty,ot={},z=m.ReactDebugCurrentFrame;function Re(h){if(h){var $=h._owner,F=at(h.type,h._source,$?$.type:null);z.setExtraStackFrame(F)}else z.setExtraStackFrame(null)}function we(h,$,F,U,se){{var ce=Function.call.bind(Ue);for(var re in h)if(ce(h,re)){var te=void 0;try{if(typeof h[re]!="function"){var ke=Error((U||"React class")+": "+F+" type `"+re+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof h[re]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ke.name="Invariant Violation",ke}te=h[re]($,re,U,F,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pe){te=pe}te&&!(te instanceof Error)&&(Re(se),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",U||"React class",F,re,typeof te),Re(null)),te instanceof Error&&!(te.message in ot)&&(ot[te.message]=!0,Re(se),C("Failed %s type: %s",F,te.message),Re(null))}}}var ve=Array.isArray;function Ze(h){return ve(h)}function Le(h){{var $=typeof Symbol=="function"&&Symbol.toStringTag,F=$&&h[Symbol.toStringTag]||h.constructor.name||"Object";return F}}function Pe(h){try{return Xe(h),!1}catch{return!0}}function Xe(h){return""+h}function He(h){if(Pe(h))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Le(h)),Xe(h)}var dt=m.ReactCurrentOwner,At={key:!0,ref:!0,__self:!0,__source:!0},Y,ee;function me(h){if(Ue.call(h,"ref")){var $=Object.getOwnPropertyDescriptor(h,"ref").get;if($&&$.isReactWarning)return!1}return h.ref!==void 0}function Ie(h){if(Ue.call(h,"key")){var $=Object.getOwnPropertyDescriptor(h,"key").get;if($&&$.isReactWarning)return!1}return h.key!==void 0}function Ee(h,$){typeof h.ref=="string"&&dt.current}function Se(h,$){{var F=function(){Y||(Y=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",$))};F.isReactWarning=!0,Object.defineProperty(h,"key",{get:F,configurable:!0})}}function le(h,$){{var F=function(){ee||(ee=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",$))};F.isReactWarning=!0,Object.defineProperty(h,"ref",{get:F,configurable:!0})}}var Ge=function(h,$,F,U,se,ce,re){var te={$$typeof:t,type:h,key:$,ref:F,props:re,_owner:ce};return te._store={},Object.defineProperty(te._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(te,"_self",{configurable:!1,enumerable:!1,writable:!1,value:U}),Object.defineProperty(te,"_source",{configurable:!1,enumerable:!1,writable:!1,value:se}),Object.freeze&&(Object.freeze(te.props),Object.freeze(te)),te};function Ye(h,$,F,U,se){{var ce,re={},te=null,ke=null;F!==void 0&&(He(F),te=""+F),Ie($)&&(He($.key),te=""+$.key),me($)&&(ke=$.ref,Ee($,se));for(ce in $)Ue.call($,ce)&&!At.hasOwnProperty(ce)&&(re[ce]=$[ce]);if(h&&h.defaultProps){var pe=h.defaultProps;for(ce in pe)re[ce]===void 0&&(re[ce]=pe[ce])}if(te||ke){var Ce=typeof h=="function"?h.displayName||h.name||"Unknown":h;te&&Se(re,Ce),ke&&le(re,Ce)}return Ge(h,te,ke,se,U,dt.current,re)}}var je=m.ReactCurrentOwner,_e=m.ReactDebugCurrentFrame;function Ae(h){if(h){var $=h._owner,F=at(h.type,h._source,$?$.type:null);_e.setExtraStackFrame(F)}else _e.setExtraStackFrame(null)}var Je;Je=!1;function ft(h){return typeof h=="object"&&h!==null&&h.$$typeof===t}function Bt(){{if(je.current){var h=W(je.current.type);if(h)return`
|
|
6
11
|
|
|
7
|
-
Check the render method of \``+
|
|
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&&($=`
|
|
8
13
|
|
|
9
|
-
Check the top-level render call using <`+
|
|
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:
|
|
10
15
|
let props = %s;
|
|
11
16
|
<%s {...props} />
|
|
12
17
|
React keys must be passed directly to JSX without using spread:
|
|
13
18
|
let props = %s;
|
|
14
|
-
<%s key={someKey} {...props} />`,Ke,je,jr,je),lt[je+Ke]=!0}}return c===r?xt(de):jt(de),de}}function yt(c,S,R){return ct(c,S,R,!0)}function zt(c,S,R){return ct(c,S,R,!1)}var Ot=zt,j=yt;dt.Fragment=r,dt.jsx=Ot,dt.jsxs=j})()),dt}var xn;function Jr(){return xn||(xn=1,process.env.NODE_ENV==="production"?wt.exports=Kr():wt.exports=Ur()),wt.exports}var w=Jr();function yn(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 qr(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 Qr(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 ea(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 sr(e,t,n){switch(e){case"linear":return yn(t,n);case"exponential":return qr(t,n);case"sCurve":return Qr(t,n);case"logarithmic":return ea(t,n);default:return yn(t,n)}}function wn(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=sr(r,1e4,!0),l=new Float32Array(o.length),i=s-a;for(let d=0;d<o.length;d++)l[d]=a+o[d]*i;e.setValueCurveAtTime(l,t,n)}}function In(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=sr(r,1e4,!1),l=new Float32Array(o.length),i=a-s;for(let d=0;d<o.length;d++)l[d]=s+o[d]*i;e.setValueCurveAtTime(l,t,n)}}var ta=class{constructor(e){this.activePlayers=0,this.track=e.track,this.volumeNode=new F.Volume(this.gainToDb(e.track.gain)),this.panNode=new F.Panner(e.track.stereoPan),this.muteGain=new F.Gain(e.track.muted?0:1);const t=e.destination||F.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 F.Player({url:r.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}}),s=new F.Gain(r.gain);return a.connect(s),s.chain(this.volumeNode,this.panNode,this.muteGain),{player:a,clipInfo:r,fadeGain:s,pausedPosition:0,playStartTime:0}})}scheduleFades(e,t,n=0){const{clipInfo:r,fadeGain:a}=e,s=a.gain._param;s.cancelScheduledValues(0);const o=n-r.offset;if(r.fadeIn&&o<r.fadeIn.duration){const l=r.fadeIn.duration;if(o<=0)wn(s,t,l,r.fadeIn.type||"linear",0,r.gain);else{const i=l-o,d=o/l,f=r.gain*d;wn(s,t,i,r.fadeIn.type||"linear",f,r.gain)}}else s.setValueAtTime(r.gain,t);if(r.fadeOut){const i=r.duration-r.fadeOut.duration-o;if(i>0){const d=t+i;In(s,d,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(i>-r.fadeOut.duration){const d=-i,f=r.fadeOut.duration-d,b=d/r.fadeOut.duration,p=r.gain*(1-b);In(s,t,f,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??F.now();this.isPlaying&&this.stop(),this.activePlayers=0,this.clips.forEach(a=>{const{player:s,clipInfo:o}=a,l=t,i=o.startTime,d=o.startTime+o.duration;if(l<d)if(this.activePlayers++,a.playStartTime=F.now(),l>=i){const f=l-i+o.offset,b=o.duration-(l-i),p=n?Math.min(n,b):b;a.pausedPosition=f,this.scheduleFades(a,r,f),s.start(r,f,p)}else{const f=i-l,b=n?Math.min(n-f,o.duration):o.duration;f<(n??1/0)?(a.pausedPosition=o.offset,this.scheduleFades(a,r+f,o.offset),s.start(r+f,o.offset,b)):this.activePlayers--}})}pause(){this.clips.forEach(e=>{if(e.player.state==="started"){const t=(F.now()-e.playStartTime)*e.player.playbackRate;e.pausedPosition=e.pausedPosition+t}e.player.stop()}),this.activePlayers=0}stop(e){const t=e??F.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}},na=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 F.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,F.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 F.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new ta(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??F.now(),a=t??0;this.playbackSessionId++;const s=this.playbackSessionId;this.activeTracks.clear(),this.tracks.forEach(o=>{const l=o.startTime;if(a>=l){const i=a-l;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r,i,n)}else{const i=l-a;n!==void 0&&(this.activeTracks.set(o.id,s),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===s&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(r+i,0,n)}}),t!==void 0?F.getTransport().start(r,t):F.getTransport().start(r)}pause(){F.getTransport().pause(),this.tracks.forEach(e=>{e.pause()})}stop(){F.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 F.getTransport().seconds}seekTo(e){F.getTransport().seconds=e}dispose(){this.tracks.forEach(e=>{e.dispose()}),this.tracks.clear(),this.effectsCleanup&&this.effectsCleanup(),this.masterVolume.dispose()}get context(){return F.getContext()}get sampleRate(){return F.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},It=null;function ra(){return It||(It=new F.Context,F.setContext(It)),It}async function Ht(){const e=ra();e.state!=="running"&&await e.resume()}const aa=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ln(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ir(e){return"nodeType"in e}function rt(e){var t,n;return e?ln(e)?e:ir(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function oa(e){const{Document:t}=rt(e);return e instanceof t}function sa(e){return ln(e)?!1:e instanceof rt(e).HTMLElement}function ia(e){return e instanceof rt(e).SVGElement}function Tt(e){return e?ln(e)?e.document:ir(e)?oa(e)?e:sa(e)||ia(e)?e.ownerDocument:document:document:document}const Mt=aa?u.useLayoutEffect:u.useEffect;function la(e){const t=u.useRef(e);return Mt(()=>{t.current=e}),u.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 lr(e,t){t===void 0&&(t=[e]);const n=u.useRef(e);return Mt(()=>{n.current!==e&&(n.current=e)},t),n}function $t(e){const t=la(e),n=u.useRef(null),r=u.useCallback(a=>{a!==n.current&&t?.(a,n.current),n.current=a},[]);return[n,r]}let Gt={};function cr(e,t){return u.useMemo(()=>{const n=Gt[e]==null?0:Gt[e]+1;return Gt[e]=n,e+"-"+n},[e,t])}function ca(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((s,o)=>{const l=Object.entries(o);for(const[i,d]of l){const f=s[i];f!=null&&(s[i]=f+e*d)}return s},{...t})}}const ua=ca(-1);function da(e){return"clientX"in e&&"clientY"in e}function fa(e){if(!e)return!1;const{TouchEvent:t}=rt(e.target);return t&&e instanceof t}function An(e){if(fa(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 da(e)?{x:e.clientX,y:e.clientY}:null}const Qt=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[Qt.Translate.toString(e),Qt.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}});var Sn;(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"})(Sn||(Sn={}));function kn(){}function Xt(e,t){return u.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function ha(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return u.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const en=Object.freeze({x:0,y:0});var et;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(et||(et={}));class Yt{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 ma(e){const{EventTarget:t}=rt(e);return e instanceof t?e:Tt(e)}function Lt(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 ze;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ze||(ze={}));function $n(e){e.preventDefault()}function pa(e){e.stopPropagation()}var Oe;(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"})(Oe||(Oe={}));Oe.Space,Oe.Enter,Oe.Esc,Oe.Space,Oe.Enter,Oe.Tab;function Rn(e){return!!(e&&"distance"in e)}function Dn(e){return!!(e&&"delay"in e)}class cn{constructor(t,n,r){var a;r===void 0&&(r=ma(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=Tt(o),this.documentListeners=new Yt(this.document),this.listeners=new Yt(r),this.windowListeners=new Yt(rt(o)),this.initialCoordinates=(a=An(s))!=null?a:en,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(ze.Resize,this.handleCancel),this.windowListeners.add(ze.DragStart,$n),this.windowListeners.add(ze.VisibilityChange,this.handleCancel),this.windowListeners.add(ze.ContextMenu,$n),this.documentListeners.add(ze.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Dn(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Rn(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(ze.Click,pa,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ze.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:a,props:s}=this,{onMove:o,options:{activationConstraint:l}}=s;if(!a)return;const i=(n=An(t))!=null?n:en,d=ua(a,i);if(!r&&l){if(Rn(l)){if(l.tolerance!=null&&Lt(d,l.tolerance))return this.handleCancel();if(Lt(d,l.distance))return this.handleStart()}if(Dn(l)&&Lt(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);return}t.cancelable&&t.preventDefault(),o(i)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Oe.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const ga={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ur extends cn{constructor(t){const{event:n}=t,r=Tt(n.target);super(t,ga,r)}}ur.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 ba={move:{name:"mousemove"},end:{name:"mouseup"}};var tn;(function(e){e[e.RightClick=2]="RightClick"})(tn||(tn={}));class dr extends cn{constructor(t){super(t,ba,Tt(t.event.target))}}dr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===tn.RightClick?!1:(r?.({event:n}),!0)}}];const Kt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class fr extends cn{constructor(t){super(t,Kt)}static setup(){return window.addEventListener(Kt.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Kt.move.name,t)};function t(){}}}fr.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 En;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(En||(En={}));var Tn;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Tn||(Tn={}));et.Backward+"",et.Forward+"",et.Backward+"",et.Forward+"";var nn;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(nn||(nn={}));var rn;(function(e){e.Optimized="optimized"})(rn||(rn={}));function va(e,t){return u.useMemo(()=>e.reduce((n,r)=>{let{eventName:a,handler:s}=r;return n[a]=o=>{s(o,t)},n},{}),[e,t])}nn.WhileDragging,rn.Optimized;const Ca={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:kn,draggableNodes:new Map,over:null,measureDroppableContainers:kn},xa=u.createContext(Ca),ya=u.createContext({...en,scaleX:1,scaleY:1});var Mn;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Mn||(Mn={}));const wa=u.createContext(null),Bn="button",Ia="Draggable";function Ut(e){let{id:t,data:n,disabled:r=!1,attributes:a}=e;const s=cr(Ia),{activators:o,activatorEvent:l,active:i,activeNodeRect:d,ariaDescribedById:f,draggableNodes:b,over:p}=u.useContext(xa),{role:h=Bn,roleDescription:x="draggable",tabIndex:I=0}=a??{},v=i?.id===t,m=u.useContext(v?ya:wa),[C,y]=$t(),[g,k]=$t(),A=va(o,t),E=lr(n);Mt(()=>(b.set(t,{id:t,key:s,node:C,activatorNode:g,data:E}),()=>{const B=b.get(t);B&&B.key===s&&b.delete(t)}),[b,t]);const _=u.useMemo(()=>({role:h,tabIndex:I,"aria-disabled":r,"aria-pressed":v&&h===Bn?!0:void 0,"aria-roledescription":x,"aria-describedby":f.draggable}),[r,h,I,v,x,f.draggable]);return{active:i,activatorEvent:l,activeNodeRect:d,attributes:_,isDragging:v,listeners:r?void 0:A,node:C,over:p,setNodeRef:y,setActivatorNodeRef:k,transform:m}}const Aa=new Map([["bold",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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"}))]]),Sa=new Map([["bold",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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",X.createElement(X.Fragment,null,X.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=u.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),un=X.forwardRef((e,t)=>{const{alt:n,color:r,size:a,weight:s,mirrored:o,children:l,weights:i,...d}=e,{color:f="currentColor",size:b,weight:p="regular",mirrored:h=!1,...x}=X.useContext(ka);return X.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:a??b,height:a??b,fill:r??f,viewBox:"0 0 256 256",transform:o||h?"scale(-1, 1)":void 0,...x,...d},!!n&&X.createElement("title",null,n),l,i.get(s??p))});un.displayName="IconBase";const hr=X.forwardRef((e,t)=>X.createElement(un,{ref:t,...e,weights:Aa}));hr.displayName="SpeakerHighIcon";const mr=X.forwardRef((e,t)=>X.createElement(un,{ref:t,...e,weights:Sa}));mr.displayName="SpeakerLowIcon";$.span`
|
|
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`
|
|
15
20
|
font-family: 'Courier New', Monaco, monospace;
|
|
16
21
|
font-size: 1rem;
|
|
17
22
|
font-weight: 600;
|
|
18
23
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
19
24
|
user-select: none;
|
|
20
|
-
`;var
|
|
25
|
+
`;var Tn=k.button`
|
|
21
26
|
display: inline-flex;
|
|
22
27
|
align-items: center;
|
|
23
28
|
justify-content: center;
|
|
@@ -46,37 +51,37 @@ React keys must be passed directly to JSX without using spread:
|
|
|
46
51
|
opacity: 0.6;
|
|
47
52
|
cursor: not-allowed;
|
|
48
53
|
}
|
|
49
|
-
|
|
54
|
+
`;k(Tn)`
|
|
50
55
|
padding: 0.25rem 0.5rem;
|
|
51
56
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
52
|
-
|
|
57
|
+
`;k(Tn)`
|
|
53
58
|
padding: 0.5rem;
|
|
54
59
|
min-width: 2.25rem;
|
|
55
60
|
min-height: 2.25rem;
|
|
56
|
-
|
|
61
|
+
`;k(Tn)`
|
|
57
62
|
padding: 0.25rem;
|
|
58
63
|
min-width: 1.75rem;
|
|
59
64
|
min-height: 1.75rem;
|
|
60
65
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
61
|
-
`;var
|
|
66
|
+
`;var Ut=k.div`
|
|
62
67
|
display: inline-flex;
|
|
63
68
|
align-items: center;
|
|
64
69
|
gap: 0.5rem;
|
|
65
|
-
`,
|
|
70
|
+
`,Jt=k.input`
|
|
66
71
|
cursor: pointer;
|
|
67
72
|
accent-color: ${e=>e.theme.inputFocusBorder};
|
|
68
73
|
|
|
69
74
|
&:disabled {
|
|
70
75
|
cursor: not-allowed;
|
|
71
76
|
}
|
|
72
|
-
`,
|
|
77
|
+
`,qt=k.label`
|
|
73
78
|
margin: 0;
|
|
74
79
|
cursor: pointer;
|
|
75
80
|
user-select: none;
|
|
76
81
|
font-family: ${e=>e.theme.fontFamily};
|
|
77
82
|
font-size: ${e=>e.theme.fontSize};
|
|
78
83
|
color: ${e=>e.theme.textColor};
|
|
79
|
-
`,
|
|
84
|
+
`,Oe=k.button`
|
|
80
85
|
padding: 0.5rem 1rem;
|
|
81
86
|
background: ${e=>e.theme.buttonBackground||"#007bff"};
|
|
82
87
|
color: ${e=>e.theme.buttonText||"white"};
|
|
@@ -102,7 +107,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
102
107
|
cursor: not-allowed;
|
|
103
108
|
opacity: 0.6;
|
|
104
109
|
}
|
|
105
|
-
`,
|
|
110
|
+
`,Or=k.input`
|
|
106
111
|
padding: 0.5rem 0.75rem;
|
|
107
112
|
font-family: ${e=>e.theme.fontFamily};
|
|
108
113
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -126,17 +131,17 @@ React keys must be passed directly to JSX without using spread:
|
|
|
126
131
|
opacity: 0.6;
|
|
127
132
|
cursor: not-allowed;
|
|
128
133
|
}
|
|
129
|
-
|
|
134
|
+
`;k(Or)`
|
|
130
135
|
padding: 0.25rem 0.5rem;
|
|
131
136
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
132
|
-
`;var
|
|
137
|
+
`;var Nr=k.label`
|
|
133
138
|
font-family: ${e=>e.theme.fontFamily};
|
|
134
139
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
135
140
|
font-weight: 500;
|
|
136
141
|
color: ${e=>e.theme.textColorMuted};
|
|
137
142
|
margin-bottom: 0.25rem;
|
|
138
143
|
display: block;
|
|
139
|
-
|
|
144
|
+
`;k.label`
|
|
140
145
|
font-family: ${e=>e.theme.fontFamily};
|
|
141
146
|
font-size: ${e=>e.theme.fontSize};
|
|
142
147
|
color: ${e=>e.theme.textColor};
|
|
@@ -144,7 +149,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
144
149
|
align-items: center;
|
|
145
150
|
gap: 0.5rem;
|
|
146
151
|
cursor: pointer;
|
|
147
|
-
`;var
|
|
152
|
+
`;var Ua=k.span`
|
|
148
153
|
position: absolute;
|
|
149
154
|
width: 1px;
|
|
150
155
|
height: 1px;
|
|
@@ -154,7 +159,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
154
159
|
clip: rect(0, 0, 0, 0);
|
|
155
160
|
white-space: nowrap;
|
|
156
161
|
border: 0;
|
|
157
|
-
`,
|
|
162
|
+
`,Dn=k.select`
|
|
158
163
|
padding: 0.5rem 2rem 0.5rem 0.75rem;
|
|
159
164
|
font-family: ${e=>e.theme.fontFamily};
|
|
160
165
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -185,10 +190,10 @@ React keys must be passed directly to JSX without using spread:
|
|
|
185
190
|
color: ${e=>e.theme.inputText};
|
|
186
191
|
background-color: ${e=>e.theme.inputBackground};
|
|
187
192
|
}
|
|
188
|
-
|
|
193
|
+
`;k(Dn)`
|
|
189
194
|
padding: 0.25rem 1.75rem 0.25rem 0.5rem;
|
|
190
195
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
191
|
-
`;var
|
|
196
|
+
`;var Lr=k.input.attrs({type:"range"})`
|
|
192
197
|
-webkit-appearance: none;
|
|
193
198
|
appearance: none;
|
|
194
199
|
width: 100%;
|
|
@@ -264,7 +269,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
264
269
|
&:disabled::-moz-range-thumb {
|
|
265
270
|
cursor: not-allowed;
|
|
266
271
|
}
|
|
267
|
-
`,
|
|
272
|
+
`,Ja=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.checked)};return R.jsxs(Ut,{className:r,children:[R.jsx(Jt,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:a,disabled:n}),R.jsx(qt,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Xr(e){return typeof e=="object"&&e!==null&&"type"in e}function Ht(e){if(!Xr(e))return e;const t=e.direction==="vertical"?"to bottom":"to right",n=e.stops.map(r=>`${r.color} ${r.offset*100}%`).join(", ");return`linear-gradient(${t}, ${n})`}var qa={waveformDrawMode:"inverted",waveOutlineColor:"#ffffff",waveFillColor:"#1a7f8e",waveProgressColor:"rgba(0, 0, 0, 0.10)",selectedWaveOutlineColor:"#ffffff",selectedWaveFillColor:"#00b4d8",selectedTrackControlsBackground:"#d9e9ff",timeColor:"#000",timescaleBackgroundColor:"#fff",playheadColor:"#f00",selectionColor:"rgba(255, 105, 180, 0.7)",loopRegionColor:"rgba(59, 130, 246, 0.3)",loopMarkerColor:"#3b82f6",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},Qa=1e3;function eo(e,t,n,r){if(!Xr(t))return t;let a;t.direction==="vertical"?a=e.createLinearGradient(0,0,0,r):a=e.createLinearGradient(0,0,n,0);for(const s of t.stops)a.addColorStop(s.offset,s.color);return a}var to=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
268
273
|
float: left;
|
|
269
274
|
position: relative;
|
|
270
275
|
/* Promote to own compositing layer for smoother scrolling */
|
|
@@ -272,15 +277,15 @@ React keys must be passed directly to JSX without using spread:
|
|
|
272
277
|
/* Disable image rendering interpolation */
|
|
273
278
|
image-rendering: pixelated;
|
|
274
279
|
image-rendering: crisp-edges;
|
|
275
|
-
`,
|
|
280
|
+
`,no=k.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
276
281
|
position: absolute;
|
|
277
282
|
background: ${e=>e.$waveFillColor};
|
|
278
283
|
/* Force GPU compositing layer to reduce scroll flickering */
|
|
279
284
|
transform: translateZ(0);
|
|
280
285
|
backface-visibility: hidden;
|
|
281
|
-
`,
|
|
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`
|
|
282
287
|
position: relative;
|
|
283
|
-
height: ${
|
|
288
|
+
height: ${Hr}px;
|
|
284
289
|
background: ${e=>e.$isSelected?e.theme.selectedClipHeaderBackgroundColor:e.theme.clipHeaderBackgroundColor};
|
|
285
290
|
border-bottom: 1px solid ${e=>e.theme.clipHeaderBorderColor};
|
|
286
291
|
display: flex;
|
|
@@ -302,7 +307,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
302
307
|
cursor: grabbing;
|
|
303
308
|
}
|
|
304
309
|
`}
|
|
305
|
-
`,
|
|
310
|
+
`,Yr=k.span`
|
|
306
311
|
font-size: 11px;
|
|
307
312
|
font-weight: 600;
|
|
308
313
|
font-family: ${e=>e.theme.clipHeaderFontFamily};
|
|
@@ -310,12 +315,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
310
315
|
white-space: nowrap;
|
|
311
316
|
overflow: hidden;
|
|
312
317
|
text-overflow: ellipsis;
|
|
313
|
-
`,
|
|
318
|
+
`,ao=({trackName:e,isSelected:t=!1})=>R.jsx(Gr,{$isDragging:!1,$interactive:!1,$isSelected:t,children:R.jsx(Yr,{children:e})}),oo=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:a=!1,disableDrag:s=!1,dragHandleProps:o})=>{if(s||!o)return R.jsx(ao,{trackName:r,isSelected:a});const{attributes:i,listeners:l,setActivatorNodeRef:u}=o;return R.jsx(Gr,{ref:u,"data-clip-id":e,$interactive:!0,$isSelected:a,...l,...i,children:R.jsx(Yr,{children:r})})},so=8,io=24,lo=k.div`
|
|
314
319
|
position: absolute;
|
|
315
320
|
${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
|
|
316
321
|
top: 0;
|
|
317
322
|
bottom: 0;
|
|
318
|
-
width: ${e=>e.$touchOptimized?
|
|
323
|
+
width: ${e=>e.$touchOptimized?io:so}px;
|
|
319
324
|
cursor: col-resize;
|
|
320
325
|
user-select: none;
|
|
321
326
|
z-index: 105; /* Above waveform, below header */
|
|
@@ -338,19 +343,19 @@ React keys must be passed directly to JSX without using spread:
|
|
|
338
343
|
background: rgba(255, 255, 255, 0.4);
|
|
339
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);"}
|
|
340
345
|
}
|
|
341
|
-
`,
|
|
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`}}))`
|
|
342
347
|
position: absolute;
|
|
343
348
|
top: 0;
|
|
344
349
|
bottom: 0;
|
|
345
350
|
pointer-events: none;
|
|
346
351
|
z-index: 50;
|
|
347
|
-
`,
|
|
352
|
+
`,uo=k.svg`
|
|
348
353
|
width: 100%;
|
|
349
354
|
height: 100%;
|
|
350
355
|
display: block;
|
|
351
356
|
/* Flip horizontally for fadeOut - makes it mirror of fadeIn */
|
|
352
357
|
transform: ${e=>e.$type==="fadeOut"?"scaleX(-1)":"none"};
|
|
353
|
-
`;function
|
|
358
|
+
`;function fo(e,t,n="logarithmic"){const r=[],a=Math.max(20,Math.min(e,100));for(let s=0;s<=a;s++){const o=s/a*e,i=s/a;let l;switch(n){case"linear":l=i;break;case"exponential":l=i*i;break;case"sCurve":l=(1-Math.cos(i*Math.PI))/2;break;case"logarithmic":default:l=Math.log10(1+i*9)/Math.log10(10);break}const u=(1-l)*t;r.push(`${o},${u}`)}return`M 0,${t} L ${r.join(" L ")} L ${e},0 L 0,0 Z`}var rr=({left:e,width:t,type:n,curveType:r="logarithmic",color:a})=>{const s=k.useTheme();if(t<1)return null;const o=a||s?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return R.jsx(co,{$left:e,$width:t,$type:n,children:R.jsx(uo,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:R.jsx("path",{d:fo(t,100,r),fill:o})})})},ho=k.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
354
359
|
position: ${e=>e.$isOverlay?"relative":"absolute"};
|
|
355
360
|
top: 0;
|
|
356
361
|
height: ${e=>e.$isOverlay?"auto":"100%"};
|
|
@@ -364,20 +369,20 @@ React keys must be passed directly to JSX without using spread:
|
|
|
364
369
|
&:hover {
|
|
365
370
|
background: rgba(255, 255, 255, 0.08);
|
|
366
371
|
}
|
|
367
|
-
`,
|
|
372
|
+
`,mo=k.div`
|
|
368
373
|
flex: 1;
|
|
369
374
|
position: relative;
|
|
370
375
|
overflow: ${e=>e.$isOverlay?"visible":"hidden"};
|
|
371
|
-
`,
|
|
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`
|
|
372
377
|
display: inline-flex;
|
|
373
378
|
align-items: center;
|
|
374
379
|
gap: 0.5rem;
|
|
375
|
-
`,
|
|
380
|
+
`,go=k(Nr)`
|
|
376
381
|
margin: 0;
|
|
377
382
|
white-space: nowrap;
|
|
378
|
-
`,
|
|
383
|
+
`,bo=k(Lr)`
|
|
379
384
|
width: 120px;
|
|
380
|
-
`,
|
|
385
|
+
`,vo=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(parseFloat(s.target.value)/100)};return R.jsxs(po,{className:r,children:[R.jsx(go,{htmlFor:"master-gain",children:"Master Volume"}),R.jsx(bo,{min:"0",max:"100",value:e*100,onChange:a,disabled:n,id:"master-gain"})]})};k.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
|
|
381
386
|
position: absolute;
|
|
382
387
|
top: 0;
|
|
383
388
|
left: 0;
|
|
@@ -387,7 +392,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
387
392
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
388
393
|
pointer-events: none;
|
|
389
394
|
will-change: transform;
|
|
390
|
-
|
|
395
|
+
`;k.div`
|
|
391
396
|
position: absolute;
|
|
392
397
|
top: 0;
|
|
393
398
|
left: 0;
|
|
@@ -395,7 +400,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
395
400
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
396
401
|
pointer-events: none;
|
|
397
402
|
will-change: transform;
|
|
398
|
-
|
|
403
|
+
`;k.div`
|
|
399
404
|
position: absolute;
|
|
400
405
|
top: -10px;
|
|
401
406
|
left: -6px;
|
|
@@ -404,37 +409,39 @@ React keys must be passed directly to JSX without using spread:
|
|
|
404
409
|
border-left: 7px solid transparent;
|
|
405
410
|
border-right: 7px solid transparent;
|
|
406
411
|
border-top: 10px solid ${e=>e.$color};
|
|
407
|
-
|
|
412
|
+
`;k.div`
|
|
408
413
|
position: absolute;
|
|
409
414
|
top: 0;
|
|
410
415
|
left: 0;
|
|
411
416
|
width: 2px;
|
|
412
417
|
height: 100%;
|
|
413
418
|
background: ${e=>e.$color};
|
|
414
|
-
`;var
|
|
419
|
+
`;var Co=k.div`
|
|
415
420
|
overflow-y: hidden;
|
|
416
421
|
overflow-x: auto;
|
|
417
422
|
position: relative;
|
|
418
|
-
`,
|
|
423
|
+
`,xo=k.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
|
|
419
424
|
position: relative;
|
|
420
425
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
421
|
-
`,
|
|
426
|
+
`,wo=k.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
|
|
422
427
|
background: ${e=>e.$backgroundColor||"white"};
|
|
423
428
|
width: 100%;
|
|
424
|
-
|
|
425
|
-
|
|
429
|
+
position: relative;
|
|
430
|
+
overflow: hidden; /* Constrain loop region to timescale area */
|
|
431
|
+
`,yo=k.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
|
|
426
432
|
position: relative;
|
|
427
433
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
428
434
|
width: 100%;
|
|
429
|
-
`,
|
|
435
|
+
`,Io=k.div`
|
|
430
436
|
position: absolute;
|
|
431
437
|
top: 0;
|
|
432
438
|
left: 0;
|
|
433
439
|
right: 0;
|
|
434
440
|
bottom: 0;
|
|
435
441
|
cursor: crosshair;
|
|
436
|
-
|
|
437
|
-
|
|
442
|
+
/* When selecting, raise z-index above clip boundaries (z-index: 105) to prevent interference */
|
|
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`}}))`
|
|
438
445
|
position: absolute;
|
|
439
446
|
top: 0;
|
|
440
447
|
background: ${e=>e.$color};
|
|
@@ -442,34 +449,116 @@ React keys must be passed directly to JSX without using spread:
|
|
|
442
449
|
z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
|
|
443
450
|
pointer-events: none;
|
|
444
451
|
opacity: 0.3;
|
|
445
|
-
`,
|
|
452
|
+
`,Ao=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:R.jsx(So,{$left:e,$width:r,$color:n,"data-selection":!0})};k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
453
|
+
position: absolute;
|
|
454
|
+
top: 0;
|
|
455
|
+
background: ${e=>e.$color};
|
|
456
|
+
height: 100%;
|
|
457
|
+
z-index: 55; /* Between clips (z-index: 50) and selection (z-index: 60) */
|
|
458
|
+
pointer-events: none;
|
|
459
|
+
`;k.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
|
|
460
|
+
position: absolute;
|
|
461
|
+
top: 0;
|
|
462
|
+
width: 2px;
|
|
463
|
+
height: 100%;
|
|
464
|
+
background: ${e=>e.$color};
|
|
465
|
+
z-index: 90; /* Below playhead (z-index: 100) */
|
|
466
|
+
pointer-events: none;
|
|
467
|
+
|
|
468
|
+
/* Triangle marker at top */
|
|
469
|
+
&::before {
|
|
470
|
+
content: '';
|
|
471
|
+
position: absolute;
|
|
472
|
+
top: 0;
|
|
473
|
+
${e=>e.$isStart?"left: 0":"right: 0"};
|
|
474
|
+
width: 0;
|
|
475
|
+
height: 0;
|
|
476
|
+
border-top: 8px solid ${e=>e.$color};
|
|
477
|
+
${e=>e.$isStart?"border-right: 8px solid transparent;":"border-left: 8px solid transparent;"}
|
|
478
|
+
}
|
|
479
|
+
`;var or=k.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
|
|
480
|
+
position: absolute;
|
|
481
|
+
top: 0;
|
|
482
|
+
width: 12px;
|
|
483
|
+
height: 100%;
|
|
484
|
+
cursor: ew-resize;
|
|
485
|
+
z-index: 100;
|
|
486
|
+
/* Center the handle on the marker position */
|
|
487
|
+
transform: translateX(-5px);
|
|
488
|
+
|
|
489
|
+
/* Visual marker line */
|
|
490
|
+
&::before {
|
|
491
|
+
content: '';
|
|
492
|
+
position: absolute;
|
|
493
|
+
top: 0;
|
|
494
|
+
left: 5px;
|
|
495
|
+
width: 2px;
|
|
496
|
+
height: 100%;
|
|
497
|
+
background: ${e=>e.$color};
|
|
498
|
+
opacity: ${e=>e.$isDragging?1:.8};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/* Triangle marker at top */
|
|
502
|
+
&::after {
|
|
503
|
+
content: '';
|
|
504
|
+
position: absolute;
|
|
505
|
+
top: 0;
|
|
506
|
+
${e=>e.$isStart?"left: 5px":"left: -1px"};
|
|
507
|
+
width: 0;
|
|
508
|
+
height: 0;
|
|
509
|
+
border-top: 10px solid ${e=>e.$color};
|
|
510
|
+
${e=>e.$isStart?"border-right: 10px solid transparent;":"border-left: 10px solid transparent;"}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
&:hover::before {
|
|
514
|
+
opacity: 1;
|
|
515
|
+
}
|
|
516
|
+
`,ko=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
517
|
+
position: absolute;
|
|
518
|
+
top: 0;
|
|
519
|
+
height: 100%;
|
|
520
|
+
background: ${e=>e.$color};
|
|
521
|
+
z-index: 50;
|
|
522
|
+
cursor: grab;
|
|
523
|
+
|
|
524
|
+
&:active {
|
|
525
|
+
cursor: grabbing;
|
|
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`}}))`
|
|
528
|
+
position: absolute;
|
|
529
|
+
top: 0;
|
|
530
|
+
right: 0;
|
|
531
|
+
height: 100%; /* Stay within timescale bounds, don't extend into tracks */
|
|
532
|
+
cursor: crosshair;
|
|
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`}}))`
|
|
446
535
|
position: relative;
|
|
447
536
|
overflow: visible; /* Allow time labels to render above the container */
|
|
448
537
|
border-bottom: 1px solid ${e=>e.theme.timeColor};
|
|
449
538
|
box-sizing: border-box;
|
|
450
|
-
`,
|
|
539
|
+
`,Oo=k.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
|
|
451
540
|
position: absolute;
|
|
452
541
|
left: 0;
|
|
453
542
|
right: 0;
|
|
454
543
|
bottom: 0;
|
|
455
|
-
`,
|
|
544
|
+
`,No=k.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
|
|
456
545
|
position: absolute;
|
|
457
546
|
font-size: 0.75rem; /* Smaller font to prevent overflow */
|
|
458
547
|
white-space: nowrap; /* Prevent text wrapping */
|
|
459
548
|
color: ${e=>e.theme.timeColor}; /* Use theme color instead of inheriting */
|
|
460
|
-
`,
|
|
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`
|
|
461
550
|
display: inline-flex;
|
|
462
551
|
align-items: center;
|
|
463
552
|
gap: 0.5rem;
|
|
464
|
-
`,
|
|
553
|
+
`,Go=[{value:"seconds",label:"seconds"},{value:"thousandths",label:"thousandths"},{value:"hh:mm:ss",label:"hh:mm:ss"},{value:"hh:mm:ss.u",label:"hh:mm:ss + tenths"},{value:"hh:mm:ss.uu",label:"hh:mm:ss + hundredths"},{value:"hh:mm:ss.uuu",label:"hh:mm:ss + milliseconds"}],Yo=({value:e,onChange:t,disabled:n=!1,className:r})=>{const a=s=>{t(s.target.value)};return R.jsx(Ho,{className:r,children:R.jsx(Dn,{className:"time-format",value:e,onChange:a,disabled:n,"aria-label":"Time format selection",children:Go.map(s=>R.jsx("option",{value:s.value,children:s.label},s.value))})})},Ko=k.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?Hr:0)}px`}}))`
|
|
465
554
|
position: relative;
|
|
466
555
|
display: flex;
|
|
467
556
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
468
|
-
`,
|
|
557
|
+
`,Uo=k.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
|
|
469
558
|
position: relative;
|
|
470
559
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
471
560
|
flex: 1;
|
|
472
|
-
`,
|
|
561
|
+
`,Jo=k.div.attrs(e=>({style:{width:`${e.$controlWidth}px`}}))`
|
|
473
562
|
position: sticky;
|
|
474
563
|
z-index: 101; /* Above waveform content, below Docusaurus navbar (z-index: 200) */
|
|
475
564
|
left: 0;
|
|
@@ -483,7 +572,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
483
572
|
${e=>e.$isSelected&&`
|
|
484
573
|
background: ${e.theme.selectedTrackControlsBackground};
|
|
485
574
|
`}
|
|
486
|
-
`,
|
|
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"})`
|
|
487
576
|
display: inline-block;
|
|
488
577
|
font-family: ${e=>e.theme.fontFamily};
|
|
489
578
|
font-weight: 500;
|
|
@@ -542,7 +631,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
542
631
|
box-shadow: 0 0 0 0.2rem ${e.theme.inputFocusBorder}33;
|
|
543
632
|
}
|
|
544
633
|
`}
|
|
545
|
-
`,
|
|
634
|
+
`,Qo=k.div`
|
|
546
635
|
margin-bottom: 0.3rem;
|
|
547
636
|
|
|
548
637
|
button:not(:first-child) {
|
|
@@ -554,7 +643,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
554
643
|
border-top-right-radius: 0;
|
|
555
644
|
border-bottom-right-radius: 0;
|
|
556
645
|
}
|
|
557
|
-
|
|
646
|
+
`,es=k.div`
|
|
558
647
|
background: transparent;
|
|
559
648
|
width: 100%;
|
|
560
649
|
height: 100%;
|
|
@@ -567,7 +656,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
567
656
|
text-align: center;
|
|
568
657
|
border: 1px solid ${e=>e.theme.borderColor};
|
|
569
658
|
border-radius: ${e=>e.theme.borderRadius};
|
|
570
|
-
`,
|
|
659
|
+
`,ts=k.header`
|
|
571
660
|
overflow: hidden;
|
|
572
661
|
height: 26px;
|
|
573
662
|
width: 100%;
|
|
@@ -578,7 +667,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
578
667
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
579
668
|
color: ${e=>e.theme.textColor};
|
|
580
669
|
background-color: transparent;
|
|
581
|
-
`,
|
|
670
|
+
`,ns=e=>R.jsx(zr,{weight:"light",...e}),rs=e=>R.jsx(jr,{weight:"light",...e}),lr=k(Lr)`
|
|
582
671
|
width: 75%;
|
|
583
672
|
height: 5px;
|
|
584
673
|
background: ${e=>e.theme.sliderTrackColor};
|
|
@@ -627,7 +716,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
627
716
|
&:focus::-moz-range-thumb {
|
|
628
717
|
border: 2px solid ${e=>e.theme.textColor};
|
|
629
718
|
}
|
|
630
|
-
`,
|
|
719
|
+
`,cr=k.label`
|
|
631
720
|
width: 100%;
|
|
632
721
|
display: flex;
|
|
633
722
|
justify-content: space-between;
|
|
@@ -635,12 +724,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
635
724
|
padding: 0 1rem;
|
|
636
725
|
margin-bottom: 0.2rem;
|
|
637
726
|
font-size: 14px;
|
|
638
|
-
|
|
727
|
+
`;k.div`
|
|
639
728
|
display: flex;
|
|
640
729
|
align-items: center;
|
|
641
730
|
gap: 0.25rem;
|
|
642
731
|
padding: 0.5rem 0.5rem 0.25rem 0.5rem;
|
|
643
|
-
|
|
732
|
+
`;k.span`
|
|
644
733
|
flex: 1;
|
|
645
734
|
font-weight: 600;
|
|
646
735
|
font-size: 0.875rem;
|
|
@@ -648,7 +737,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
648
737
|
text-overflow: ellipsis;
|
|
649
738
|
white-space: nowrap;
|
|
650
739
|
margin: 0 0.25rem;
|
|
651
|
-
|
|
740
|
+
`;k.button`
|
|
652
741
|
display: flex;
|
|
653
742
|
align-items: center;
|
|
654
743
|
justify-content: center;
|
|
@@ -673,7 +762,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
673
762
|
&:active {
|
|
674
763
|
transform: scale(0.9);
|
|
675
764
|
}
|
|
676
|
-
`;function
|
|
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`}}))`
|
|
677
766
|
position: absolute;
|
|
678
767
|
top: 0;
|
|
679
768
|
background: ${e=>e.$color};
|
|
@@ -689,7 +778,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
689
778
|
opacity: 0.5;
|
|
690
779
|
border-color: ${e=>e.$color};
|
|
691
780
|
}
|
|
692
|
-
|
|
781
|
+
`;k.div`
|
|
693
782
|
position: absolute;
|
|
694
783
|
bottom: 0;
|
|
695
784
|
left: 0;
|
|
@@ -705,7 +794,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
705
794
|
pointer-events: none;
|
|
706
795
|
white-space: pre-wrap;
|
|
707
796
|
word-break: break-word;
|
|
708
|
-
|
|
797
|
+
`;k.textarea`
|
|
709
798
|
position: absolute;
|
|
710
799
|
bottom: 0;
|
|
711
800
|
left: 0;
|
|
@@ -725,7 +814,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
725
814
|
outline: none;
|
|
726
815
|
border-color: #4CAF50;
|
|
727
816
|
}
|
|
728
|
-
|
|
817
|
+
`;k.div`
|
|
729
818
|
position: absolute;
|
|
730
819
|
top: 0;
|
|
731
820
|
left: 0;
|
|
@@ -736,7 +825,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
736
825
|
padding: 4px;
|
|
737
826
|
justify-content: flex-start;
|
|
738
827
|
align-items: center;
|
|
739
|
-
|
|
828
|
+
`;k.button`
|
|
740
829
|
background: transparent;
|
|
741
830
|
border: 1px solid rgba(255, 255, 255, 0.5);
|
|
742
831
|
color: white;
|
|
@@ -758,12 +847,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
758
847
|
&:active {
|
|
759
848
|
background: rgba(255, 255, 255, 0.3);
|
|
760
849
|
}
|
|
761
|
-
`;var
|
|
850
|
+
`;var bs=k.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
762
851
|
position: absolute;
|
|
763
852
|
top: 0;
|
|
764
853
|
height: 100%;
|
|
765
854
|
pointer-events: none; /* Let events pass through to children */
|
|
766
|
-
`,
|
|
855
|
+
`,vs=k.div`
|
|
767
856
|
position: absolute;
|
|
768
857
|
top: 0;
|
|
769
858
|
left: 0;
|
|
@@ -787,7 +876,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
787
876
|
border-width: 3px;
|
|
788
877
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
|
|
789
878
|
}
|
|
790
|
-
`,
|
|
879
|
+
`,Cs=k.span`
|
|
791
880
|
font-size: 12px;
|
|
792
881
|
font-weight: 600;
|
|
793
882
|
color: ${e=>e.theme?.annotationLabelColor||"#2a2a2a"};
|
|
@@ -797,7 +886,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
797
886
|
padding: 0 6px;
|
|
798
887
|
letter-spacing: 0.3px;
|
|
799
888
|
user-select: none;
|
|
800
|
-
`,
|
|
889
|
+
`,wr=k.div`
|
|
801
890
|
position: absolute;
|
|
802
891
|
top: 0;
|
|
803
892
|
${e=>e.$position==="left"?"left: -8px":"right: -8px"};
|
|
@@ -832,13 +921,13 @@ React keys must be passed directly to JSX without using spread:
|
|
|
832
921
|
opacity: 1;
|
|
833
922
|
background: ${e=>e.theme?.annotationResizeHandleActiveColor||"rgba(0, 0, 0, 0.7)"};
|
|
834
923
|
}
|
|
835
|
-
`,
|
|
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`}}))`
|
|
836
925
|
position: relative;
|
|
837
926
|
display: flex;
|
|
838
927
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
839
928
|
background: transparent;
|
|
840
929
|
z-index: 110;
|
|
841
|
-
`,
|
|
930
|
+
`,ys=k.div`
|
|
842
931
|
position: sticky;
|
|
843
932
|
z-index: 200;
|
|
844
933
|
left: 0;
|
|
@@ -846,16 +935,16 @@ React keys must be passed directly to JSX without using spread:
|
|
|
846
935
|
width: ${e=>e.$controlWidth}px;
|
|
847
936
|
flex-shrink: 0;
|
|
848
937
|
background: transparent;
|
|
849
|
-
`,
|
|
938
|
+
`,Is=k.div`
|
|
850
939
|
position: relative;
|
|
851
940
|
flex: 1;
|
|
852
941
|
padding-left: ${e=>e.$offset||0}px;
|
|
853
|
-
`,
|
|
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`}}))`
|
|
854
943
|
position: relative;
|
|
855
944
|
display: flex;
|
|
856
945
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
857
946
|
background: transparent;
|
|
858
|
-
|
|
947
|
+
`;k.div`
|
|
859
948
|
position: sticky;
|
|
860
949
|
z-index: 200;
|
|
861
950
|
left: 0;
|
|
@@ -869,16 +958,16 @@ React keys must be passed directly to JSX without using spread:
|
|
|
869
958
|
font-size: 12px;
|
|
870
959
|
color: ${e=>e.theme?.textColorMuted||"#666"};
|
|
871
960
|
font-weight: bold;
|
|
872
|
-
|
|
961
|
+
`;k.div`
|
|
873
962
|
position: relative;
|
|
874
963
|
flex: 1;
|
|
875
964
|
padding-left: ${e=>e.$offset||0}px;
|
|
876
|
-
`;var
|
|
965
|
+
`;var As=k.div`
|
|
877
966
|
background: ${e=>e.theme?.backgroundColor||"#fff"};
|
|
878
967
|
${e=>e.$height?`height: ${e.$height}px;`:"max-height: 200px;"}
|
|
879
968
|
overflow-y: auto;
|
|
880
969
|
padding: 8px;
|
|
881
|
-
`,
|
|
970
|
+
`,ks=k.div`
|
|
882
971
|
padding: 12px;
|
|
883
972
|
margin-bottom: 6px;
|
|
884
973
|
border-left: 4px solid ${e=>e.$isActive?"#ff9800":"transparent"};
|
|
@@ -897,16 +986,16 @@ React keys must be passed directly to JSX without using spread:
|
|
|
897
986
|
outline: 2px solid #ff9800;
|
|
898
987
|
outline-offset: 2px;
|
|
899
988
|
}
|
|
900
|
-
|
|
989
|
+
`,$s=k.div`
|
|
901
990
|
display: flex;
|
|
902
991
|
justify-content: space-between;
|
|
903
992
|
align-items: center;
|
|
904
993
|
margin-bottom: 6px;
|
|
905
|
-
`,
|
|
994
|
+
`,Rs=k.div`
|
|
906
995
|
display: flex;
|
|
907
996
|
align-items: center;
|
|
908
997
|
gap: 8px;
|
|
909
|
-
`,
|
|
998
|
+
`,Es=k.span`
|
|
910
999
|
font-size: 11px;
|
|
911
1000
|
font-weight: 600;
|
|
912
1001
|
color: ${e=>e.theme?.textColorMuted||"#666"};
|
|
@@ -920,16 +1009,16 @@ React keys must be passed directly to JSX without using spread:
|
|
|
920
1009
|
outline: 2px solid #ff9800;
|
|
921
1010
|
background: rgba(255, 152, 0, 0.1);
|
|
922
1011
|
}
|
|
923
|
-
`,
|
|
1012
|
+
`,Ts=k.span`
|
|
924
1013
|
font-size: 12px;
|
|
925
1014
|
font-weight: 500;
|
|
926
1015
|
color: ${e=>e.theme?.textColorMuted||"#555"};
|
|
927
1016
|
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
928
1017
|
letter-spacing: 0.5px;
|
|
929
|
-
`,
|
|
1018
|
+
`,Ds=k.div`
|
|
930
1019
|
display: flex;
|
|
931
1020
|
gap: 6px;
|
|
932
|
-
`,
|
|
1021
|
+
`,_s=k.button`
|
|
933
1022
|
background: ${e=>e.theme?.surfaceColor||"#f5f5f5"};
|
|
934
1023
|
border: 1px solid ${e=>e.theme?.borderColor||"#ccc"};
|
|
935
1024
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
@@ -948,7 +1037,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
948
1037
|
&:active {
|
|
949
1038
|
transform: scale(0.95);
|
|
950
1039
|
}
|
|
951
|
-
`,
|
|
1040
|
+
`,Ms=k.div`
|
|
952
1041
|
font-size: 14px;
|
|
953
1042
|
line-height: 1.6;
|
|
954
1043
|
color: ${e=>e.theme?.textColor||"#2a2a2a"};
|
|
@@ -963,9 +1052,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
963
1052
|
outline: 2px solid #ff9800;
|
|
964
1053
|
background: rgba(255, 152, 0, 0.1);
|
|
965
1054
|
}
|
|
966
|
-
`,
|
|
967
|
-
`)},
|
|
968
|
-
`)})]},m.id)})})},
|
|
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`
|
|
969
1058
|
padding: 0.5rem 1rem;
|
|
970
1059
|
background: ${e=>e.theme?.surfaceColor||"#f5f5f5"};
|
|
971
1060
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
@@ -991,7 +1080,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
991
1080
|
opacity: 0.6;
|
|
992
1081
|
cursor: not-allowed;
|
|
993
1082
|
}
|
|
994
|
-
`,hs=({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=>No(b)),l=JSON.stringify(o,null,2),i=new Blob([l],{type:"application/json"}),d=URL.createObjectURL(i),f=document.createElement("a");f.href=d,f.download=t,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(d)};return w.jsx(fs,{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 Rr(){const[e,t]=u.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:a=>nt(a,e),parseTime:a=>Ir(a,e)}}const ms=[256,512,1024,2048,4096,8192];function Dr({initialSamplesPerPixel:e,zoomLevels:t=ms}){const[n,r]=u.useState(()=>{const d=t.indexOf(e);return d!==-1?d:Math.floor(t.length/2)}),a=t[n],s=n>0,o=n<t.length-1,l=u.useCallback(()=>{r(d=>Math.max(0,d-1))},[]),i=u.useCallback(()=>{r(d=>Math.min(t.length-1,d+1))},[t.length]);return{samplesPerPixel:a,zoomIn:l,zoomOut:i,canZoomIn:s,canZoomOut:o}}function Er({playoutRef:e,initialVolume:t=1,onVolumeChange:n}){const[r,a]=u.useState(t),s=u.useCallback(o=>{a(o),e.current&&e.current.setMasterGain(o),n?.(o)},[e,n]);return{masterVolume:r,setMasterVolume:s}}const ps=(e=256)=>{const t=u.useRef(null),n=u.useCallback((r,a,s)=>{const o=new F.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:l,fadeIn:i,fadeOut:d}=e;return{id:Tr(),audioBuffer:t,startSample:n,durationSamples:r,offsetSamples:a,gain:s,name:o,color:l,fadeIn:i,fadeOut:d}}function gs(e){const{audioBuffer:t,startTime:n,duration:r=t.duration,offset:a=0,gain:s=1,name:o,color:l,fadeIn:i,fadeOut:d}=e,f=t.sampleRate;return sn({audioBuffer:t,startSample:Math.round(n*f),durationSamples:Math.round(r*f),offsetSamples:Math.round(a*f),gain:s,name:o,color:l,fadeIn:i,fadeOut:d})}function bs(e){const{name:t,clips:n=[],muted:r=!1,soloed:a=!1,volume:s=1,pan:o=0,color:l,height:i}=e;return{id:Tr(),name:t,clips:n,muted:r,soloed:a,volume:s,pan:o,color:l,height:i}}function Tr(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function vs(e){const[t,n]=u.useState([]),[r,a]=u.useState(!0),[s,o]=u.useState(null);return u.useEffect(()=>{if(e.length===0){n([]),a(!1);return}let l=!1;return(async()=>{try{a(!0),o(null);const d=or.getContext().rawContext,f=e.map(async(p,h)=>{const x=await fetch(p.src);if(!x.ok)throw new Error(`Failed to fetch ${p.src}: ${x.statusText}`);const I=await x.arrayBuffer(),v=await d.decodeAudioData(I);if(!v||!v.sampleRate||!v.duration)throw new Error(`Invalid audio buffer for ${p.src}`);const m=p.duration??v.duration,C=gs({audioBuffer:v,startTime:p.startTime??0,duration:m,offset:p.offset??0,name:p.name||`Track ${h+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{...bs({name:p.name||`Track ${h+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(f);l||(n(b),a(!1))}catch(d){if(!l){const f=d instanceof Error?d.message:"Unknown error loading audio";o(f),a(!1),console.error("Error loading audio tracks:",d)}}})(),()=>{l=!0}},[e]),{tracks:t,loading:r,error:s}}function Cs({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r}){const a=u.useRef(null),s=u.useCallback(d=>{const{transform:f,active:b}=d;if(!b?.data?.current)return{...f,scaleX:1,scaleY:1};const{trackIndex:p,clipIndex:h,boundary:x}=b.data.current;if(x)return{...f,scaleX:1,scaleY:1};const I=e[p];if(!I)return{...f,scaleX:1,scaleY:1};const v=I.clips[h];if(!v)return{...f,scaleX:1,scaleY:1};const m=v.startSample/r,C=v.durationSamples/r,y=f.x*n/r;let g=m+y;const k=[...I.clips].sort((D,Z)=>D.startSample-Z.startSample),A=k.findIndex(D=>D===v);g=Math.max(0,g);const E=A>0?k[A-1]:null;if(E){const D=(E.startSample+E.durationSamples)/r;g=Math.max(g,D)}const _=A<k.length-1?k[A+1]:null;if(_){const D=g+C,Z=_.startSample/r;D>Z&&(g=Z-C)}const M=(g-m)*r/n;return{...f,x:M,scaleX:1,scaleY:1}},[e,n,r]),o=u.useCallback(d=>{const{active:f}=d,{boundary:b}=f.data.current;if(!b){a.current=null;return}const{trackIndex:p,clipIndex:h}=f.data.current,I=e[p]?.clips[h];I&&(a.current={offsetSamples:I.offsetSamples,durationSamples:I.durationSamples,startSample:I.startSample})},[e]),l=u.useCallback(d=>{const{active:f,delta:b}=d,{boundary:p}=f.data.current;if(!p||!a.current)return;const{trackIndex:h,clipIndex:x}=f.data.current,I=b.x*n,v=Math.floor(.1*r),m=a.current,C=e.map((y,g)=>{if(g!==h)return y;const k=[...y.clips].sort((_,B)=>_.startSample-B.startSample),A=k.findIndex(_=>_===y.clips[x]),E=y.clips.map((_,B)=>{if(B!==x)return _;const M=Math.floor(_.audioBuffer.duration*r);if(p==="left"){let D=Math.floor(I);const Z=-m.startSample;D<Z&&(D=Z);const W=-m.offsetSamples;D<W&&(D=W);const O=A>0?k[A-1]:null;if(O){const ee=O.startSample+O.durationSamples-m.startSample;D<ee&&(D=ee)}const N=m.durationSamples-v;D>N&&(D=N);const G=m.offsetSamples+D,K=m.durationSamples-D,Q=m.startSample+D;return{..._,offsetSamples:G,durationSamples:K,startSample:Q}}else{let D=Math.floor(m.durationSamples+I);D=Math.max(v,D),m.offsetSamples+D>M&&(D=M-m.offsetSamples);const Z=A<k.length-1?k[A+1]:null;return Z&&m.startSample+D>Z.startSample&&(D=Z.startSample-m.startSample,D=Math.max(v,D)),{..._,durationSamples:D}}});return{...y,clips:E}});t(C)},[e,t,n,r]),i=u.useCallback(d=>{const{active:f,delta:b}=d,{trackIndex:p,clipIndex:h,boundary:x}=f.data.current,I=b.x*n;if(x){a.current=null;return}const v=e.map((m,C)=>{if(C!==p)return m;const y=[...m.clips].sort((A,E)=>A.startSample-E.startSample),g=y.findIndex(A=>A===m.clips[h]),k=m.clips.map((A,E)=>{if(E!==h)return A;let _=Math.floor(A.startSample+I);_=Math.max(0,_);const B=g>0?y[g-1]:null;if(B){const D=B.startSample+B.durationSamples;_=Math.max(_,D)}const M=g<y.length-1?y[g+1]:null;return M&&_+A.durationSamples>M.startSample&&(_=M.startSample-A.durationSamples),{...A,startSample:_}});return{...m,clips:k}});t(v)},[e,t,n,r]);return{onDragStart:o,onDragMove:l,onDragEnd:i,collisionModifier:s}}const Jt=.01;function xs({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:a,linkEndpoints:s}){const o=u.useRef(null),l=u.useCallback(f=>{const{active:b}=f,p=b.data.current;if(!p||p.annotationIndex===void 0){o.current=null;return}const h=e[p.annotationIndex];h&&(o.current={start:h.start,end:h.end,annotationIndex:p.annotationIndex})},[e]),i=u.useCallback(f=>{const{active:b,delta:p}=f;if(!o.current)return;const h=b.data.current;if(!h)return;const{edge:x,annotationIndex:I}=h,v=o.current,m=p.x*n/r,C=x==="start"?v.start+m:v.end+m,y=ys({annotationIndex:I,newTime:C,isDraggingStart:x==="start",annotations:e,duration:a,linkEndpoints:s});t(y)},[e,t,n,r,a,s]),d=u.useCallback(()=>{o.current=null},[]);return{onDragStart:l,onDragMove:i,onDragEnd:d}}function ys({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:a,linkEndpoints:s}){const o=[...r],l=r[e];if(n){const i=Math.min(l.end-.1,Math.max(0,t)),d=i-l.start;if(o[e]={...l,start:i},s&&e>0){const f=o[e-1];Math.abs(f.end-l.start)<Jt?o[e-1]={...f,end:Math.max(f.start+.1,f.end+d)}:i<=f.end&&(o[e]={...o[e],start:f.end})}else!s&&e>0&&i<o[e-1].end&&(o[e-1]={...o[e-1],end:i})}else{const i=Math.max(l.start+.1,Math.min(t,a)),d=i-l.end;if(o[e]={...l,end:i},s&&e<o.length-1){const f=o[e+1];if(Math.abs(f.start-l.end)<Jt){const b=f.start+d;o[e+1]={...f,start:Math.min(f.end-.1,b)};let p=e+1;for(;p<o.length-1;){const h=o[p],x=o[p+1];if(Math.abs(x.start-h.end)<Jt){const I=h.end-r[p].end;o[p+1]={...x,start:Math.min(x.end-.1,x.start+I)},p++}else break}}else i>=f.start&&(o[e]={...o[e],end:f.start})}else if(!s&&e<o.length-1&&i>o[e+1].start){const f=o[e+1];o[e+1]={...f,start:i};let b=e+1;for(;b<o.length-1;){const p=o[b],h=o[b+1];if(p.end>h.start)o[b+1]={...h,start:p.end},b++;else break}}}return o}function ws(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:a=1}=e,s=Xt(dr,{activationConstraint:{distance:a}}),o=Xt(fr,{activationConstraint:t?{delay:n,tolerance:r}:{distance:a}}),l=Xt(ur,{activationConstraint:{distance:a}});return ha(...t?[s,o]:[l])}const Is=e=>{const{tracks:t,onTracksChange:n,sampleRate:r}=e,{currentTimeRef:a}=$e(),{selectedTrackId:s}=Fe(),o=u.useCallback((i,d,f)=>{const{sampleRate:b,samplesPerPixel:p}=e,h=t[i];if(!h)return!1;const x=h.clips[d];if(!x)return!1;const I=x.startSample/b,v=(x.startSample+x.durationSamples)/b;if(f<=I||f>=v)return console.warn("Split time is outside clip bounds"),!1;const m=Math.round(f*b),C=Math.floor(m/p),y=x.startSample+x.durationSamples,g=C*p,k=x.startSample,A=g-k,E=g,_=y-E,B=g-x.startSample,M=sn({audioBuffer:x.audioBuffer,startSample:k,durationSamples:A,offsetSamples:x.offsetSamples,gain:x.gain,name:x.name?`${x.name} (1)`:void 0,color:x.color,fadeIn:x.fadeIn}),D=sn({audioBuffer:x.audioBuffer,startSample:E,durationSamples:_,offsetSamples:x.offsetSamples+B,gain:x.gain,name:x.name?`${x.name} (2)`:void 0,color:x.color,fadeOut:x.fadeOut}),Z=[...h.clips];Z.splice(d,1,M,D);const W=[...t];return W[i]={...h,clips:Z},n(W),!0},[t,n,e]);return{splitClipAtPlayhead:u.useCallback(()=>{if(!s)return console.log("No track selected - click a clip to select a track first"),!1;const i=t.findIndex(b=>b.id===s);if(i===-1)return console.warn("Selected track not found"),!1;const d=t[i],f=a.current??0;for(let b=0;b<d.clips.length;b++){const p=d.clips[b],h=p.startSample/r,x=(p.startSample+p.durationSamples)/r;if(f>h&&f<x)return console.log(`Splitting clip on track "${d.name}" at ${f}s`),o(i,b,f)}return console.log(`No clip found at playhead position on track "${d.name}"`),!1},[t,a,s,o,r]),splitClipAt:o}},Dt=e=>{const{shortcuts:t,enabled:n=!0}=e,r=u.useCallback(a=>{if(!n)return;const s=a.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const o=t.find(l=>{const i=a.key.toLowerCase()===l.key.toLowerCase()||a.key===l.key,d=l.ctrlKey===void 0||a.ctrlKey===l.ctrlKey,f=l.shiftKey===void 0||a.shiftKey===l.shiftKey,b=l.metaKey===void 0||a.metaKey===l.metaKey,p=l.altKey===void 0||a.altKey===l.altKey;return i&&d&&f&&b&&p});o&&(o.preventDefault!==!1&&a.preventDefault(),o.action())},[t,n]);u.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},As=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("+")},Ss=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:a}=$e(),{setCurrentTime:s,play:o,pause:l,stop:i}=be(),{playoutRef:d}=Ae(),f=u.useCallback(()=>{a?l():o()},[a,o,l]),b=u.useCallback(()=>{i()},[i]),p=u.useCallback(()=>{a&&d.current?(d.current.stop(),s(0),o(0)):s(0)},[a,d,s,o]),x=r??[...[{key:" ",action:f,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 Dt({shortcuts:x,enabled:t}),{rewindToStart:p,togglePlayPause:f,stopPlayback:b,shortcuts:x}},qt=.01,At=.01;function ks({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:a,linkEndpoints:s,continuousPlay:o=!1,enabled:l=!0,scrollContainerRef:i,samplesPerPixel:d,sampleRate:f,controlsWidth:b=0,onPlay:p}){const h=u.useMemo(()=>t?e.findIndex(B=>B.id===t):-1,[e,t]),x=u.useCallback(B=>{if(!i?.current||!d||!f)return;const M=e.find(H=>H.id===B);if(!M)return;const D=i.current,Z=D.clientWidth,W=M.start*f/d+b,O=M.end*f/d+b,N=(W+O)/2,G=D.scrollLeft,K=G,Q=G+Z;if(W<K||O>Q){const H=Math.max(0,N-Z/2);D.scrollTo({left:H,behavior:"smooth"})}},[e,i,d,f,b]);u.useEffect(()=>{t&&i?.current&&d&&f&&x(t)},[t,x,i,d,f]);const I=u.useCallback(B=>{if(h<0)return;const M=e[h],D=Math.max(0,Math.min(M.end-.1,M.start+B)),Z=D-M.start,W=[...e];if(W[h]={...M,start:D},s&&h>0){const O=W[h-1];Math.abs(O.end-M.start)<qt&&(W[h-1]={...O,end:Math.max(O.start+.1,O.end+Z)})}else if(!s&&h>0){const O=W[h-1];D<O.end&&(W[h-1]={...O,end:D})}n(W)},[e,h,s,n]),v=u.useCallback(B=>{if(h<0)return;const M=e[h],D=Math.max(M.start+.1,Math.min(a,M.end+B)),Z=D-M.end,W=[...e];if(W[h]={...M,end:D},s&&h<e.length-1){const O=W[h+1];if(Math.abs(O.start-M.end)<qt){const N=Math.min(O.end-.1,O.start+Z);W[h+1]={...O,start:N};let G=h+1;for(;G<W.length-1;){const K=W[G],Q=W[G+1];if(Math.abs(Q.start-e[G].end)<qt){const H=K.end-e[G].end;W[G+1]={...Q,start:Math.min(Q.end-.1,Q.start+H)},G++}else break}}}else if(!s&&h<e.length-1){const O=W[h+1];if(D>O.start){W[h+1]={...O,start:D};let N=h+1;for(;N<W.length-1;){const G=W[N],K=W[N+1];if(G.end>K.start)W[N+1]={...K,start:G.end},N++;else break}}}n(W)},[e,h,a,s,n]),m=u.useCallback(()=>{!r||e.length===0||(h<=0?r(e[e.length-1].id):r(e[h-1].id))},[e,h,r]),C=u.useCallback(()=>{!r||e.length===0||(h<0||h>=e.length-1?r(e[0].id):r(e[h+1].id))},[e,h,r]),y=u.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),g=u.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),k=u.useCallback(()=>{r&&r(null)},[r]),A=u.useCallback(()=>{if(h<0||!p)return;const B=e[h],M=o?void 0:B.end-B.start;p(B.start,M)},[e,h,o,p]),E=u.useMemo(()=>[{key:"[",action:()=>I(-At),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>I(At),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-At),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(At),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:A,description:"Play selected annotation",preventDefault:!0}],[I,v,A]),_=u.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:y,description:"Select first annotation",preventDefault:!0},{key:"End",action:g,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:k,description:"Deselect annotation",preventDefault:!0}],[m,C,y,g,k]);return Dt({shortcuts:E,enabled:l&&h>=0}),Dt({shortcuts:_,enabled:l&&e.length>0&&!!r}),{moveStartBoundary:I,moveEndBoundary:v,selectPrevious:m,selectNext:C,selectFirst:y,selectLast:g,clearSelection:k,scrollToAnnotation:x,playActiveAnnotation:A}}function $s(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 Rs(e,t,n,r=1){const a=e.createBuffer(r,t.length,n),s=new Float32Array(t);return a.copyToChannel(s,0),a}function Qn(e,t,n=16){const r=Math.ceil(e.length/t),a=n===8?new Int8Array(r*2):new Int16Array(r*2),s=2**(n-1);for(let o=0;o<r;o++){const l=o*t,i=Math.min(l+t,e.length);let d=0,f=0;for(let b=l;b<i;b++){const p=e[b];p<d&&(d=p),p>f&&(f=p)}a[o*2]=Math.floor(d*s),a[o*2+1]=Math.floor(f*s)}return a}function Ds(e,t,n,r,a=16){const s=2**(a-1),o=r%n;let l=0;if(o>0&&e.length>0){const f=n-o,b=Math.min(f,t.length);let p=e[e.length-2]/s,h=e[e.length-1]/s;for(let m=0;m<b;m++){const C=t[m];C<p&&(p=C),C>h&&(h=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(h*s),l=b;const I=Qn(t.slice(l),n,a),v=new(a===8?Int8Array:Int16Array)(x.length+I.length);return v.set(x),v.set(I,x.length),v}const i=Qn(t.slice(l),n,a),d=new(a===8?Int8Array:Int16Array)(e.length+i.length);return d.set(e),d.set(i,e.length),d}function Es(e,t={}){const{channelCount:n=1,samplesPerPixel:r=1024}=t,[a,s]=u.useState(!1),[o,l]=u.useState(!1),[i,d]=u.useState(0),[f,b]=u.useState(new Int16Array(0)),[p,h]=u.useState(null),[x,I]=u.useState(null),[v,m]=u.useState(0),[C,y]=u.useState(0),g=16,k=u.useRef(!1),A=u.useRef(null),E=u.useRef(null),_=u.useRef([]),B=u.useRef(0),M=u.useRef(null),D=u.useRef(0),Z=u.useRef(!1),W=u.useRef(!1),O=u.useCallback(async()=>{if(!k.current)try{const H=F.getContext(),ee=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw",typeof document>"u"?require("url").pathToFileURL(__filename).href:Nt&&Nt.tagName.toUpperCase()==="SCRIPT"&&Nt.src||new URL("index.js",document.baseURI).href).href;await H.addAudioWorkletModule(ee),k.current=!0}catch(H){throw console.error("Failed to load AudioWorklet module:",H),new Error("Failed to load recording processor")}},[]),N=u.useCallback(async()=>{if(!e){I(new Error("No microphone stream available"));return}try{I(null);const H=F.getContext();H.state==="suspended"&&await H.resume(),await O();const ee=H.createMediaStreamSource(e);E.current=ee;const ie=H.createAudioWorkletNode("recording-processor");A.current=ie,ee.connect(ie),ie.port.onmessage=q=>{const{samples:re}=q.data;_.current.push(re),B.current+=re.length,b(te=>Ds(te,re,r,B.current-re.length,g))},ie.port.postMessage({command:"start",sampleRate:H.sampleRate,channelCount:n}),_.current=[],B.current=0,b(new Int16Array(0)),h(null),m(0),y(0),Z.current=!0,W.current=!1,s(!0),l(!1),D.current=performance.now();const ce=()=>{if(Z.current&&!W.current){const q=(performance.now()-D.current)/1e3;d(q),M.current=requestAnimationFrame(ce)}};ce()}catch(H){console.error("Failed to start recording:",H),I(H instanceof Error?H:new Error("Failed to start recording"))}},[e,n,r,O,a,o]),G=u.useCallback(async()=>{if(!a)return null;try{if(A.current){if(A.current.port.postMessage({command:"stop"}),E.current)try{E.current.disconnect(A.current)}catch{}A.current.disconnect()}M.current!==null&&(cancelAnimationFrame(M.current),M.current=null);const H=$s(_.current),ie=F.getContext().rawContext,ce=Rs(ie,H,ie.sampleRate,n);return h(ce),d(ce.duration),Z.current=!1,W.current=!1,s(!1),l(!1),m(0),ce}catch(H){return console.error("Failed to stop recording:",H),I(H instanceof Error?H:new Error("Failed to stop recording")),null}},[a,n]),K=u.useCallback(()=>{a&&!o&&(M.current!==null&&(cancelAnimationFrame(M.current),M.current=null),W.current=!0,l(!0))},[a,o]),Q=u.useCallback(()=>{if(a&&o){W.current=!1,l(!1),D.current=performance.now()-i*1e3;const H=()=>{if(Z.current&&!W.current){const ee=(performance.now()-D.current)/1e3;d(ee),M.current=requestAnimationFrame(H)}};H()}},[a,o,i]);return u.useEffect(()=>()=>{if(A.current){if(A.current.port.postMessage({command:"stop"}),E.current)try{E.current.disconnect(A.current)}catch{}A.current.disconnect()}M.current!==null&&cancelAnimationFrame(M.current)},[]),{isRecording:a,isPaused:o,duration:i,peaks:f,audioBuffer:p,level:v,peakLevel:C,startRecording:N,stopRecording:G,pauseRecording:K,resumeRecording:Q,error:x}}function Ts(){const[e,t]=u.useState(null),[n,r]=u.useState([]),[a,s]=u.useState(!1),[o,l]=u.useState(!1),[i,d]=u.useState(null),f=u.useCallback(async()=>{try{const x=(await navigator.mediaDevices.enumerateDevices()).filter(I=>I.kind==="audioinput").map(I=>({deviceId:I.deviceId,label:I.label||`Microphone ${I.deviceId.slice(0,8)}`,groupId:I.groupId}));r(x)}catch(h){console.error("Failed to enumerate devices:",h),d(h instanceof Error?h:new Error("Failed to enumerate devices"))}},[]),b=u.useCallback(async(h,x)=>{l(!0),d(null);try{e&&e.getTracks().forEach(C=>C.stop());const v={audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,latency:0,...x,...h&&{deviceId:{exact:h}}},video:!1},m=await navigator.mediaDevices.getUserMedia(v);t(m),s(!0),await f()}catch(I){console.error("Failed to access microphone:",I),d(I instanceof Error?I:new Error("Failed to access microphone")),s(!1)}finally{l(!1)}},[e,f]),p=u.useCallback(()=>{e&&(e.getTracks().forEach(h=>h.stop()),t(null),s(!1))},[e]);return u.useEffect(()=>(f(),()=>{e&&e.getTracks().forEach(h=>h.stop())}),[]),{stream:e,devices:n,hasPermission:a,isLoading:o,requestAccess:b,stopStream:p,error:i}}function Ms(e,t={}){const{updateRate:n=60,smoothingTimeConstant:r=.8}=t,[a,s]=u.useState(0),[o,l]=u.useState(0),i=u.useRef(null),d=u.useRef(null),f=u.useRef(null),b=()=>l(0);return u.useEffect(()=>{if(!e){s(0),l(0);return}let p=!0;return(async()=>{if(!p)return;const x=F.getContext();if(x.state==="suspended"&&await x.resume(),!p)return;const I=new F.Meter({smoothing:r,context:x});i.current=I;const v=x.createMediaStreamSource(e);d.current=v,F.connect(v,I);const m=1e3/n;let C=0;const y=g=>{if(!(!p||!i.current)){if(g-C>=m){C=g;const k=i.current.getValue(),A=typeof k=="number"?k:k[0],E=Math.max(0,Math.min(1,(A+100)/100));s(E),l(_=>Math.max(_,E))}f.current=requestAnimationFrame(y)}};f.current=requestAnimationFrame(y)})(),()=>{if(p=!1,f.current&&(cancelAnimationFrame(f.current),f.current=null),d.current){try{d.current.disconnect()}catch{}d.current=null}i.current&&(i.current.dispose(),i.current=null)}},[e,r,n]),{level:a,peakLevel:o,resetPeak:b}}$.button`
|
|
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`
|
|
995
1084
|
padding: 0.5rem 1rem;
|
|
996
1085
|
font-size: 0.875rem;
|
|
997
1086
|
font-weight: 500;
|
|
@@ -1021,7 +1110,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1021
1110
|
outline: none;
|
|
1022
1111
|
box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.3);
|
|
1023
1112
|
}
|
|
1024
|
-
|
|
1113
|
+
`;k.span`
|
|
1025
1114
|
display: inline-block;
|
|
1026
1115
|
width: 8px;
|
|
1027
1116
|
height: 8px;
|
|
@@ -1039,13 +1128,13 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1039
1128
|
opacity: 0.3;
|
|
1040
1129
|
}
|
|
1041
1130
|
}
|
|
1042
|
-
|
|
1131
|
+
`;k(Dn)`
|
|
1043
1132
|
min-width: 200px;
|
|
1044
|
-
|
|
1133
|
+
`;k(Nr)`
|
|
1045
1134
|
display: flex;
|
|
1046
1135
|
flex-direction: column;
|
|
1047
1136
|
gap: 0.25rem;
|
|
1048
|
-
|
|
1137
|
+
`;k.div`
|
|
1049
1138
|
display: flex;
|
|
1050
1139
|
align-items: center;
|
|
1051
1140
|
gap: 0.75rem;
|
|
@@ -1053,7 +1142,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1053
1142
|
background: ${e=>e.$isRecording?"#fff3cd":"transparent"};
|
|
1054
1143
|
border-radius: 0.25rem;
|
|
1055
1144
|
transition: background 0.2s ease-in-out;
|
|
1056
|
-
|
|
1145
|
+
`;k.div`
|
|
1057
1146
|
width: 12px;
|
|
1058
1147
|
height: 12px;
|
|
1059
1148
|
border-radius: 50%;
|
|
@@ -1073,18 +1162,18 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1073
1162
|
}
|
|
1074
1163
|
}
|
|
1075
1164
|
`}
|
|
1076
|
-
|
|
1165
|
+
`;k.span`
|
|
1077
1166
|
font-family: 'Courier New', Monaco, monospace;
|
|
1078
1167
|
font-size: 1rem;
|
|
1079
1168
|
font-weight: 600;
|
|
1080
1169
|
color: #495057;
|
|
1081
1170
|
min-width: 70px;
|
|
1082
|
-
|
|
1171
|
+
`;k.span`
|
|
1083
1172
|
font-size: 0.75rem;
|
|
1084
1173
|
font-weight: 500;
|
|
1085
1174
|
color: ${e=>e.$isPaused?"#ffc107":"#dc3545"};
|
|
1086
1175
|
text-transform: uppercase;
|
|
1087
|
-
`;var
|
|
1176
|
+
`;var vi=k.div`
|
|
1088
1177
|
position: relative;
|
|
1089
1178
|
width: ${e=>e.$width}px;
|
|
1090
1179
|
height: ${e=>e.$height}px;
|
|
@@ -1092,39 +1181,39 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1092
1181
|
border-radius: 4px;
|
|
1093
1182
|
overflow: hidden;
|
|
1094
1183
|
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
|
|
1095
|
-
`,
|
|
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"}}))`
|
|
1096
1185
|
position: absolute;
|
|
1097
1186
|
left: 0;
|
|
1098
1187
|
top: 0;
|
|
1099
1188
|
transition: width 0.05s ease-out, background 0.1s ease-out;
|
|
1100
|
-
`,
|
|
1189
|
+
`,wi=k.div.attrs(e=>({style:{left:`${e.$peakLevel*100}%`,height:`${e.$height}px`}}))`
|
|
1101
1190
|
position: absolute;
|
|
1102
1191
|
top: 0;
|
|
1103
1192
|
width: 2px;
|
|
1104
1193
|
background: #ecf0f1;
|
|
1105
1194
|
box-shadow: 0 0 4px rgba(236, 240, 241, 0.8);
|
|
1106
1195
|
transition: left 0.1s ease-out;
|
|
1107
|
-
`,
|
|
1196
|
+
`,yi=k.div`
|
|
1108
1197
|
position: absolute;
|
|
1109
1198
|
top: 0;
|
|
1110
1199
|
left: 0;
|
|
1111
1200
|
width: 100%;
|
|
1112
1201
|
height: ${e=>e.$height}px;
|
|
1113
1202
|
pointer-events: none;
|
|
1114
|
-
`,
|
|
1203
|
+
`,Dr=k.div`
|
|
1115
1204
|
position: absolute;
|
|
1116
1205
|
left: ${e=>e.$position}%;
|
|
1117
1206
|
top: 0;
|
|
1118
1207
|
width: 1px;
|
|
1119
1208
|
height: ${e=>e.$height}px;
|
|
1120
1209
|
background: rgba(255, 255, 255, 0.2);
|
|
1121
|
-
`,Ps=({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 w.jsxs(Bs,{$width:n,$height:r,className:a,children:[w.jsx(Ws,{$level:s,$height:r}),t!==void 0&&o>0&&w.jsx(Fs,{$peakLevel:o,$height:r}),w.jsxs(Zs,{$height:r,children:[w.jsx(er,{$position:60,$height:r}),w.jsx(er,{$position:85,$height:r})]})]})};u.memo(Ps);function Vs(e,t,n,r={}){const{currentTime:a=0,audioConstraints:s,...o}=r,[l,i]=u.useState(!1),[d,f]=u.useState(null),{stream:b,devices:p,hasPermission:h,requestAccess:x,error:I}=Ts(),{level:v,peakLevel:m}=Ms(b),{isRecording:C,isPaused:y,duration:g,peaks:k,startRecording:A,stopRecording:E,pauseRecording:_,resumeRecording:B,error:M}=Es(b,o),D=u.useCallback(async()=>{n&&(l||(await Ht(),i(!0)),await A())},[n,l,A]),Z=u.useCallback(async()=>{const N=await E();if(N&&n){const G=e.findIndex(q=>q.id===n);if(G===-1)return;const K=e[G],Q=Math.floor(a*N.sampleRate);let H=0;if(K.clips.length>0){const q=K.clips.map(re=>re.startSample+re.durationSamples);H=Math.max(...q)}const ee=Math.max(Q,H),ie={id:`clip-${Date.now()}`,audioBuffer:N,startSample:ee,durationSamples:N.length,offsetSamples:0,gain:1,name:`Recording ${new Date().toLocaleTimeString()}`},ce=e.map((q,re)=>re===G?{...q,clips:[...q.clips,ie]}:q);t(ce)}},[n,e,t,a,E]);u.useEffect(()=>{h&&p.length>0&&d===null&&f(p[0].deviceId)},[h,p.length]);const W=u.useCallback(async()=>{await x(void 0,s),await Ht(),i(!0)},[x,s]),O=u.useCallback(async N=>{f(N),await x(N,s),await Ht(),i(!0)},[x,s]);return{isRecording:C,isPaused:y,duration:g,level:v,peakLevel:m,error:I||M,stream:b,devices:p,hasPermission:h,selectedDevice:d,startRecording:D,stopRecording:Z,pauseRecording:_,resumeRecording:B,requestMicAccess:W,changeDevice:O,recordingPeaks:k}}const pt=[{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}]}],pn=e=>pt.find(t=>t.id===e),js=e=>pt.filter(t=>t.category===e),zs=[{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"}],Os={reverb:F.Reverb,freeverb:F.Freeverb,jcReverb:F.JCReverb,feedbackDelay:F.FeedbackDelay,pingPongDelay:F.PingPongDelay,chorus:F.Chorus,phaser:F.Phaser,tremolo:F.Tremolo,vibrato:F.Vibrato,autoPanner:F.AutoPanner,autoFilter:F.AutoFilter,autoWah:F.AutoWah,eq3:F.EQ3,distortion:F.Distortion,bitCrusher:F.BitCrusher,chebyshev:F.Chebyshev,compressor:F.Compressor,limiter:F.Limiter,gate:F.Gate,stereoWidener:F.StereoWidener};let Ns=0;const Hs=()=>`effect_${Date.now()}_${++Ns}`;function mt(e,t){const n=Os[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(o=>{const l=t?.[o.name]??o.default;r[o.name]=l});const a=new n(r),s=Hs();return{effect:a,id:e.id,instanceId:s,dispose(){try{a.disconnect(),a.dispose()}catch{}},setParameter(o,l){o==="wet"&&a.wet?a.wet.value=l:a[o]!==void 0&&(a[o]?.value!==void 0?a[o].value=l:a[o]=l)},getParameter(o){if(o==="wet"&&a.wet)return a.wet.value;if(a[o]!==void 0)return a[o]?.value!==void 0?a[o].value:a[o]},connect(o){a.connect(o)},disconnect(){try{a.disconnect()}catch{}}}}function Gs(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 Xs(e=256){const[t,n]=u.useState([]),r=u.useRef(t);r.current=t;const a=u.useRef(new Map),s=u.useRef(null),o=u.useRef(null),l=u.useCallback(v=>{const m=o.current;if(!m)return;const{masterGainNode:C,destination:y,analyserNode:g}=m;try{C.disconnect()}catch{}const k=v.map(A=>a.current.get(A.instanceId)).filter(A=>A!==void 0);if(k.length===0)C.connect(g),g.connect(y);else{let A=C;k.forEach(E=>{try{E.disconnect()}catch{}A.connect(E.effect),A=E.effect}),A.connect(g),g.connect(y)}},[]),i=u.useCallback(v=>{const m=pn(v);if(!m){console.error(`Unknown effect: ${v}`);return}const C={};m.parameters.forEach(k=>{C[k.name]=k.default});const y=mt(m,C);a.current.set(y.instanceId,y);const g={instanceId:y.instanceId,effectId:m.id,definition:m,params:C,bypassed:!1};n(k=>[...k,g])},[]),d=u.useCallback(v=>{const m=a.current.get(v);m&&(m.dispose(),a.current.delete(v)),n(C=>C.filter(y=>y.instanceId!==v))},[]),f=u.useCallback((v,m,C)=>{const y=a.current.get(v);y&&y.setParameter(m,C),n(g=>g.map(k=>k.instanceId===v?{...k,params:{...k.params,[m]:C}}:k))},[]),b=u.useCallback(v=>{const m=r.current.find(g=>g.instanceId===v);if(!m)return;const C=!m.bypassed,y=a.current.get(v);if(y){const g=m.params.wet??1;y.setParameter("wet",C?0:g)}n(g=>g.map(k=>k.instanceId===v?{...k,bypassed:C}:k))},[]),p=u.useCallback((v,m)=>{n(C=>{const y=[...C],[g]=y.splice(v,1);return y.splice(m,0,g),y})},[]),h=u.useCallback(()=>{a.current.forEach(v=>v.dispose()),a.current.clear(),n([])},[]);u.useEffect(()=>{l(t)},[t,l]);const x=u.useCallback((v,m,C)=>{const y=new F.Analyser("fft",e);s.current=y,o.current={masterGainNode:v,destination:m,analyserNode:y};const k=r.current.map(A=>a.current.get(A.instanceId)).filter(A=>A!==void 0);if(k.length===0)v.connect(y),y.connect(m);else{let A=v;k.forEach(E=>{A.connect(E.effect),A=E.effect}),A.connect(y),y.connect(m)}return function(){y.dispose(),s.current=null,o.current=null}},[e]);u.useEffect(()=>()=>{a.current.forEach(v=>v.dispose()),a.current.clear()},[]);const I=u.useCallback(()=>{const v=t.filter(m=>!m.bypassed);if(v.length!==0)return(m,C,y)=>{const g=[];for(const k of v){const A=mt(k.definition,k.params);g.push(A)}if(g.length===0)m.connect(C);else{let k=m;g.forEach(A=>{k.connect(A.effect),k=A.effect}),k.connect(C)}return function(){g.forEach(A=>A.dispose())}}},[t]);return{activeEffects:t,availableEffects:pt,addEffect:i,removeEffect:d,updateParameter:f,toggleBypass:b,reorderEffects:p,clearAllEffects:h,masterEffects:x,createOfflineEffectsFunction:I,analyserRef:s}}function Ys(){const[e,t]=u.useState(new Map),n=u.useRef(new Map),r=u.useRef(new Map),a=u.useCallback((h,x)=>{const I=r.current.get(h);if(!I)return;const{graphEnd:v,masterGainNode:m}=I,C=n.current.get(h);try{v.disconnect()}catch{}const y=x.map(g=>C?.get(g.instanceId)).filter(g=>g!==void 0);if(y.length===0)v.connect(m);else{let g=v;y.forEach(k=>{try{k.disconnect()}catch{}g.connect(k.effect),g=k.effect}),g.connect(m)}},[]),s=u.useCallback((h,x)=>{const I=pn(x);if(!I){console.error(`Unknown effect: ${x}`);return}const v={};I.parameters.forEach(y=>{v[y.name]=y.default});const m=mt(I,v);n.current.has(h)||n.current.set(h,new Map),n.current.get(h).set(m.instanceId,m);const C={instanceId:m.instanceId,effectId:I.id,definition:I,params:v,bypassed:!1};t(y=>{const g=new Map(y),k=g.get(h)||[];return g.set(h,[...k,C]),g})},[]),o=u.useCallback((h,x)=>{const I=n.current.get(h),v=I?.get(x);v&&(v.dispose(),I?.delete(x)),t(m=>{const C=new Map(m),y=C.get(h)||[];return C.set(h,y.filter(g=>g.instanceId!==x)),C})},[]),l=u.useCallback((h,x,I,v)=>{const C=n.current.get(h)?.get(x);C&&C.setParameter(I,v),t(y=>{const g=new Map(y),k=g.get(h)||[];return g.set(h,k.map(A=>A.instanceId===x?{...A,params:{...A.params,[I]:v}}:A)),g})},[]),i=u.useCallback((h,x)=>{const v=(f.current.get(h)||[]).find(g=>g.instanceId===x);if(!v)return;const m=!v.bypassed,y=n.current.get(h)?.get(x);if(y){const g=v.params.wet??1;y.setParameter("wet",m?0:g)}t(g=>{const k=new Map(g),A=k.get(h)||[];return k.set(h,A.map(E=>E.instanceId===x?{...E,bypassed:m}:E)),k})},[]),d=u.useCallback(h=>{const x=n.current.get(h);x&&(x.forEach(I=>I.dispose()),x.clear()),t(I=>{const v=new Map(I);return v.set(h,[]),v})},[]),f=u.useRef(e);f.current=e;const b=u.useCallback(h=>(x,I,v)=>{r.current.set(h,{graphEnd:x,masterGainNode:I});const m=f.current.get(h)||[],C=n.current.get(h),y=m.map(g=>C?.get(g.instanceId)).filter(g=>g!==void 0);if(y.length===0)x.connect(I);else{let g=x;y.forEach(k=>{g.connect(k.effect),g=k.effect}),g.connect(I)}return function(){r.current.delete(h)}},[]);u.useEffect(()=>{e.forEach((h,x)=>{a(x,h)})},[e,a]),u.useEffect(()=>()=>{n.current.forEach(h=>{h.forEach(x=>x.dispose()),h.clear()}),n.current.clear()},[]);const p=u.useCallback(h=>{const I=(e.get(h)||[]).filter(v=>!v.bypassed);if(I.length!==0)return(v,m,C)=>{const y=[];for(const g of I){const k=mt(g.definition,g.params);y.push(k)}if(y.length===0)v.connect(m);else{let g=v;y.forEach(k=>{g.connect(k.effect),g=k.effect}),g.connect(m)}return function(){y.forEach(k=>k.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:s,removeEffectFromTrack:o,updateTrackEffectParameter:l,toggleBypass:i,clearTrackEffects:d,getTrackEffectsFunction:b,createOfflineTrackEffectsFunction:p,availableEffects:pt}}function Ls(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,a=e.sampleRate,s=e.length,o=n/8,l=r*o,i=a*l,d=s*l,f=44,b=f+d,p=new ArrayBuffer(b),h=new DataView(p);St(h,0,"RIFF"),h.setUint32(4,b-8,!0),St(h,8,"WAVE"),St(h,12,"fmt "),h.setUint32(16,16,!0),h.setUint16(20,n===32?3:1,!0),h.setUint16(22,r,!0),h.setUint32(24,a,!0),h.setUint32(28,i,!0),h.setUint16(32,l,!0),h.setUint16(34,n,!0),St(h,36,"data"),h.setUint32(40,d,!0);const x=[];for(let v=0;v<r;v++)x.push(e.getChannelData(v));let I=f;if(n===16)for(let v=0;v<s;v++)for(let m=0;m<r;m++){const C=x[m][v],y=Math.max(-1,Math.min(1,C)),g=y<0?y*32768:y*32767;h.setInt16(I,g,!0),I+=2}else for(let v=0;v<s;v++)for(let m=0;m<r;m++)h.setFloat32(I,x[m][v],!0),I+=4;return new Blob([p],{type:"audio/wav"})}function St(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function Ks(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 Mr(){const[e,t]=u.useState(!1),[n,r]=u.useState(0),[a,s]=u.useState(null);return{exportWav:u.useCallback(async(l,i,d={})=>{const{filename:f="export",mode:b="master",trackIndex:p,autoDownload:h=!0,applyEffects:x=!0,effectsFunction:I,createOfflineTrackEffects:v,bitDepth:m=16,onProgress:C}=d;t(!0),r(0),s(null);try{if(l.length===0)throw new Error("No tracks to export");if(b==="individual"&&(p===void 0||p<0||p>=l.length))throw new Error("Invalid track index for individual export");const y=l[0].clips[0]?.audioBuffer.sampleRate||44100;let g=0;for(const D of l)for(const Z of D.clips){const W=Z.startSample+Z.durationSamples;g=Math.max(g,W)}g+=Math.round(y*.1);const k=g/y,A=b==="individual"?[{track:l[p],state:i[p],index:p}]:l.map((D,Z)=>({track:D,state:i[Z],index:Z})),E=i.some(D=>D.soloed),_=!!v;let B;if((I||_)&&x)B=await Us(A,i,E,k,y,I,v,D=>{r(D),C?.(D)});else{const D=new OfflineAudioContext(2,g,y);let Z=0;const W=A.reduce((O,{track:N})=>O+N.clips.length,0);for(const{track:O,state:N}of A)if(!(N.muted&&!N.soloed)&&!(E&&!N.soloed))for(const G of O.clips){await qs(D,G,N,y,x),Z++;const K=Z/W*.5;r(K),C?.(K)}r(.5),C?.(.5),B=await D.startRendering()}r(.9),C?.(.9);const M=Ls(B,{bitDepth:m});if(r(1),C?.(1),h){const D=b==="individual"?`${f}_${l[p].name}`:f;Ks(M,`${D}.wav`)}return{audioBuffer:B,blob:M,duration:k}}catch(y){const g=y instanceof Error?y.message:"Export failed";throw s(g),y}finally{t(!1)}},[]),isExporting:e,progress:n,error:a}}async function Us(e,t,n,r,a,s,o,l){const{Offline:i,Volume:d,Gain:f,Panner:b,Player:p,ToneAudioBuffer:h}=await import("tone");l(.1);let x;try{x=await i(async({transport:I,destination:v})=>{const m=new d(0);let C;s?C=s(m,v,!0):m.connect(v);for(const{track:y,state:g}of e){if(g.muted&&!g.soloed||n&&!g.soloed)continue;const k=new d(Js(g.volume)),A=new b(g.pan),E=new f(g.muted?0:1),_=o?.(y.id);_?_(E,m,!0):E.connect(m),A.connect(E),k.connect(A);for(const B of y.clips){const{audioBuffer:M,startSample:D,durationSamples:Z,offsetSamples:W,gain:O,fadeIn:N,fadeOut:G}=B,K=D/a,Q=Z/a,H=W/a,ee=new h(M),ie=new p(ee),ce=new f(O);if(ie.connect(ce),ce.connect(k),N){const q=K,re=K+N.duration,te=ce.gain._param;te.setValueAtTime(0,q),te.linearRampToValueAtTime(O,re)}if(G){const q=K+Q-G.duration,re=K+Q,te=ce.gain._param;te.setValueAtTime(O,q),te.linearRampToValueAtTime(0,re)}ie.start(K,H,Q)}}I.start(0)},r,2,a)}catch(I){throw I instanceof Error?I:new Error(`Tone.Offline rendering failed: ${String(I)}`)}return l(.9),x.get()}function Js(e){return 20*Math.log10(Math.max(e,1e-4))}async function qs(e,t,n,r,a){const{audioBuffer:s,startSample:o,durationSamples:l,offsetSamples:i,gain:d,fadeIn:f,fadeOut:b}=t,p=o/r,h=l/r,x=i/r,I=e.createBufferSource();I.buffer=s;const v=e.createGain(),m=d*n.volume,C=e.createStereoPanner();if(C.pan.value=n.pan,I.connect(v),v.connect(C),C.connect(e.destination),a){if(f?v.gain.setValueAtTime(0,p):v.gain.setValueAtTime(m,p),f){const y=p,g=p+f.duration;tr(v.gain,y,g,0,m,f.type||"linear")}if(b){const y=p+h-b.duration,g=p+h;(!f||f.duration<h-b.duration)&&v.gain.setValueAtTime(m,y),tr(v.gain,y,g,m,0,b.type||"linear")}}else v.gain.setValueAtTime(m,p);I.start(p,x,h)}function tr(e,t,n,r,a,s){const o=n-t;if(!(o<=0))switch(s){case"linear":e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n);break;case"exponential":const l=Math.max(r,1e-4),i=Math.max(a,1e-4);e.setValueAtTime(l,t),e.exponentialRampToValueAtTime(i,n),a===0&&e.setValueAtTime(0,n);break;case"logarithmic":const d=nr(r,a,256,"logarithmic");e.setValueCurveAtTime(d,t,o);break;case"sCurve":const f=nr(r,a,256,"sCurve");e.setValueCurveAtTime(f,t,o);break;default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(a,n)}}function nr(e,t,n,r){const a=new Float32Array(n),s=t-e;for(let o=0;o<n;o++){const l=o/(n-1);let i;r==="logarithmic"?s>0?i=Math.log10(1+l*9)/Math.log10(10):i=1-Math.log10(1+(1-l)*9)/Math.log10(10):i=l*l*(3-2*l),a[o]=e+s*i}return a}const Br=u.createContext(null),_r=u.createContext(null),Wr=u.createContext(null),Fr=u.createContext(null),Zr=u.createContext(null),Qs=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:a=1024,zoomLevels:s,automaticScroll:o=!1,theme:l,controls:i={show:!1,width:0},annotationList:d,effects:f,onReady:b,onAnnotationUpdate:p,barWidth:h=1,barGap:x=0,progressBarWidth:I,children:v})=>{const m=I??h+x,[C,y]=u.useState([]),[g,k]=u.useState(null),[A,E]=u.useState(!1),[_,B]=u.useState(0),[M,D]=u.useState(0),[Z,W]=u.useState([]),[O,N]=u.useState([]),[G,K]=u.useState([]),[Q,H]=u.useState(0),[ee,ie]=u.useState(0),[ce,q]=u.useState(null),[re,te]=u.useState(o),[fe,Ne]=u.useState(d?.isContinuousPlay??!1),[Ze,ae]=u.useState(d?.linkEndpoints??!0),[Me,at]=u.useState(d?.editable??!1),V=u.useRef(null),Se=u.useRef(0),pe=u.useRef(0),he=u.useRef(null),_e=u.useRef(G),we=u.useRef(0),Ie=u.useRef(0),Re=u.useRef(null),Ee=u.useRef(null),Je=u.useRef(!1),He=u.useRef(d?.isContinuousPlay??!1),Pe=u.useRef(null),qe=u.useRef(a),{timeFormat:Y,setTimeFormat:U,formatTime:ue}=Rr(),ge=Dr({initialSamplesPerPixel:a,zoomLevels:s}),me=ge.samplesPerPixel,{masterVolume:ke,setMasterVolume:oe}=Er({playoutRef:V,initialVolume:1}),Be=u.useCallback(j=>{He.current=j,Ne(j)},[]),xe=u.useCallback(j=>{Pe.current=j,k(j)},[]);u.useEffect(()=>{Je.current=re},[re]),u.useEffect(()=>{_e.current=G},[G]),u.useEffect(()=>{if(!Ee.current||!Z.length)return;const j=Ee.current,c=qe.current,S=me;if(c===S)return;const R=i.show?i.width:0,T=j.clientWidth,J=j.scrollLeft+T/2-R,P=Z[0].sampleRate,le=J*c/P*P/S,se=Math.max(0,le+R-T/2);j.scrollLeft=se,qe.current=S},[me,Z,i]);const De=u.useRef(null);u.useEffect(()=>{if(e.length===0){W([]),D(0),K([]),N([]),V.current&&(V.current.dispose(),V.current=null);return}const j=A,c=pe.current;return V.current&&j&&(V.current.stop(),he.current&&(cancelAnimationFrame(he.current),he.current=null),De.current={position:c}),(async()=>{try{const R=[];e.forEach(P=>{P.clips.length>0&&R.push(P.clips[0].audioBuffer)});let T=0;e.forEach(P=>{P.clips.forEach(z=>{const le=z.audioBuffer.sampleRate,de=(z.startSample+z.durationSamples)/le;T=Math.max(T,de)})}),W(R),D(T),K(P=>P.length===e.length?P.map((z,le)=>({...z,name:e[le].name})):e.map(z=>({name:z.name,muted:z.muted,soloed:z.soloed,volume:z.volume,pan:z.pan}))),V.current&&V.current.dispose();const L=new na({effects:f}),J=_e.current;e.forEach((P,z)=>{if(P.clips.length>0){const le=P.clips[0].audioBuffer.sampleRate,se=Math.min(...P.clips.map(ne=>ne.startSample/le)),de=Math.max(...P.clips.map(ne=>(ne.startSample+ne.durationSamples)/le)),Ce=J[z],Xe={id:`track-${z}`,name:P.name,gain:Ce?.volume??P.volume,muted:Ce?.muted??P.muted,soloed:Ce?.soloed??P.soloed,stereoPan:Ce?.pan??P.pan,startTime:se,endTime:de},je=P.clips.map(ne=>{const Ke=ne.audioBuffer.sampleRate;return{buffer:ne.audioBuffer,startTime:ne.startSample/Ke-se,duration:ne.durationSamples/Ke,offset:ne.offsetSamples/Ke,fadeIn:ne.fadeIn,fadeOut:ne.fadeOut,gain:ne.gain}});L.addTrack({clips:je,track:Xe,effects:P.effects})}}),L.applyInitialSoloState(),V.current=L,b?.()}catch(R){console.error("Error loading audio:",R)}})(),()=>{he.current&&cancelAnimationFrame(he.current),V.current&&V.current.dispose()}},[e,b,A]),u.useEffect(()=>{if(e.length===0)return;const j=16,c=e.map(S=>S.clips.map(T=>{const L=T.audioBuffer.sampleRate,J=_o(T.audioBuffer,me,n,j,T.offsetSamples/L,T.durationSamples/L);return{clipId:T.id,trackName:S.name,peaks:J,startSample:T.startSample,durationSamples:T.durationSamples,fadeIn:T.fadeIn,fadeOut:T.fadeOut}}));N(c)},[e,me,n]),u.useEffect(()=>{if(d?.annotations){const j=d.annotations.map(c=>typeof c.start=="number"?c:Oo(c));y(j)}},[d]);const ye=u.useCallback(()=>{he.current&&(cancelAnimationFrame(he.current),he.current=null);const j=()=>{const c=F.getContext().currentTime-we.current,S=Ie.current+c;if(pe.current=S,B(S),C.length>0){const R=C.find(T=>S>=T.start&&S<T.end);if(He.current){if(R&&R.id!==Pe.current)xe(R.id);else if(!R&&Pe.current!==null){const T=C[C.length-1];if(S>=T.end){V.current&&V.current.stop(),E(!1),pe.current=Se.current,B(Se.current),xe(null);return}}}else if(Pe.current){const T=C.find(L=>L.id===Pe.current);if(T&&S>=T.end){V.current&&V.current.stop(),E(!1),pe.current=Se.current,B(Se.current);return}}else R&&xe(R.id)}if(Je.current&&Ee.current&&Z.length>0){const R=Ee.current,T=Z[0].sampleRate,L=S*T/qe.current,J=R.clientWidth,P=i.show?i.width:0,z=L+P,le=Math.max(0,z-J/2);R.scrollLeft=le}if(Re.current!==null&&S>=Re.current){V.current&&V.current.stop(),E(!1),pe.current=Re.current,B(Re.current),Re.current=null;return}if(S>=M){V.current&&V.current.stop(),E(!1),pe.current=Se.current,B(Se.current),xe(null);return}he.current=requestAnimationFrame(j)};he.current=requestAnimationFrame(j)},[M,Z,me,C,fe]),ve=u.useCallback(()=>{he.current&&(cancelAnimationFrame(he.current),he.current=null)},[]);u.useEffect(()=>{(async()=>{if(A&&he.current&&V.current)if(fe){const c=pe.current;V.current.stop(),ve(),await V.current.init(),V.current.setOnPlaybackComplete(()=>{});const R=F.getContext().currentTime;we.current=R,Ie.current=c,V.current.play(R,c),ye()}else ve(),ye()})()},[fe,A,ye,ve]),u.useEffect(()=>{(async()=>{if(De.current&&V.current){const{position:c}=De.current;De.current=null,await V.current.init(),V.current.setOnPlaybackComplete(()=>{});const R=F.getContext().currentTime;we.current=R,Ie.current=c,V.current.play(R,c),E(!0),ye()}})()},[e,ye]);const Ve=u.useCallback(async(j,c)=>{if(!V.current||Z.length===0)return;await V.current.init(),await F.start();const S=j??pe.current;Se.current=S,pe.current=S,V.current.setOnPlaybackComplete(()=>{}),V.current.stop(),ve();const T=F.getContext().currentTime;we.current=T,Ie.current=S,Re.current=c!==void 0?S+c:null,V.current.play(T,S,c),E(!0),ye()},[Z.length,ye,ve]),Le=u.useCallback(()=>{if(!V.current)return;const j=F.getContext().currentTime-we.current,c=Ie.current+j;V.current.pause(),E(!1),ve(),pe.current=c,B(c)},[ve]),gt=u.useCallback(()=>{V.current&&(V.current.stop(),E(!1),ve(),pe.current=Se.current,B(Se.current),xe(null))},[ve]),Ge=u.useCallback(j=>{const c=Math.max(0,Math.min(j,M));pe.current=c,B(c),A&&V.current&&(V.current.stop(),ve(),Ve(c))},[M,A,Ve,ve]),ot=u.useCallback((j,c)=>{const S=[...G];if(S[j]={...S[j],muted:c},K(S),V.current){const R=`track-${j}`;V.current.setMute(R,c)}},[G]),st=u.useCallback((j,c)=>{const S=[...G];if(S[j]={...S[j],soloed:c},K(S),V.current){const R=`track-${j}`;V.current.setSolo(R,c)}},[G]),bt=u.useCallback((j,c)=>{const S=[...G];if(S[j]={...S[j],volume:c},K(S),V.current){const R=`track-${j}`,T=V.current.getTrack(R);T&&T.setVolume(c)}},[G]),Pt=u.useCallback((j,c)=>{const S=[...G];if(S[j]={...S[j],pan:c},K(S),V.current){const R=`track-${j}`,T=V.current.getTrack(R);T&&T.setPan(c)}},[G]),vt=u.useCallback((j,c)=>{H(j),ie(c),pe.current=j,B(j),A&&V.current&&(V.current.stop(),V.current.play(F.getContext().currentTime,j))},[A]),Vt=u.useCallback(j=>{Ee.current=j},[]),Ct=Z[0]?.sampleRate||44100,it=t?30:0,jt=e.length*r+it,xt={isPlaying:A,currentTime:_,currentTimeRef:pe,playbackStartTimeRef:we,audioStartPositionRef:Ie},lt={continuousPlay:fe,linkEndpoints:Ze,annotationsEditable:Me,isAutomaticScroll:re,annotations:C,activeAnnotationId:g,selectionStart:Q,selectionEnd:ee,selectedTrackId:ce},ct={play:Ve,pause:Le,stop:gt,seekTo:Ge,setCurrentTime:j=>{pe.current=j,B(j)},setTrackMute:ot,setTrackSolo:st,setTrackVolume:bt,setTrackPan:Pt,setSelection:vt,setSelectedTrackId:q,setTimeFormat:U,formatTime:ue,zoomIn:ge.zoomIn,zoomOut:ge.zoomOut,setMasterVolume:oe,setAutomaticScroll:j=>{te(j)},setScrollContainer:Vt,scrollContainerRef:Ee,setContinuousPlay:Be,setLinkEndpoints:ae,setAnnotationsEditable:at,setAnnotations:y,setActiveAnnotationId:xe},yt={duration:M,audioBuffers:Z,peaksDataArray:O,trackStates:G,tracks:e,sampleRate:Ct,waveHeight:r,timeScaleHeight:it,minimumPlaylistHeight:jt,controls:i,playoutRef:V,samplesPerPixel:me,timeFormat:Y,masterVolume:ke,canZoomIn:ge.canZoomIn,canZoomOut:ge.canZoomOut,barWidth:h,barGap:x,progressBarWidth:m},zt={...xt,...lt,...ct,...yt},Ot={...Da,...l};return w.jsx($.ThemeProvider,{theme:Ot,children:w.jsx(Br.Provider,{value:xt,children:w.jsx(_r.Provider,{value:lt,children:w.jsx(Wr.Provider,{value:ct,children:w.jsx(Fr.Provider,{value:yt,children:w.jsx(Zr.Provider,{value:zt,children:v})})})})})})},$e=()=>{const e=u.useContext(Br);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},Fe=()=>{const e=u.useContext(_r);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},be=()=>{const e=u.useContext(Wr);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},Ae=()=>{const e=u.useContext(Fr);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e},ei=()=>{const e=u.useContext(Zr);if(!e)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return e},ti=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=$e(),{selectionStart:r,selectionEnd:a}=Fe(),{play:s}=be(),o=async()=>{if(r!==a&&a>r){const l=a-r;await s(r,l)}else await s(n.current??0)};return w.jsx(We,{onClick:o,disabled:t,className:e,children:"Play"})},ni=({className:e})=>{const{isPlaying:t}=$e(),{pause:n}=be();return w.jsx(We,{onClick:n,disabled:!t,className:e,children:"Pause"})},ri=({className:e})=>{const{isPlaying:t}=$e(),{stop:n}=be();return w.jsx(We,{onClick:n,disabled:!t,className:e,children:"Stop"})},ai=({className:e})=>{const{isPlaying:t}=$e(),{play:n,setCurrentTime:r}=be(),{playoutRef:a}=Ae(),s=()=>{r(0),t&&a.current&&(a.current.stop(),n(0))};return w.jsx(We,{onClick:s,className:e,children:"Rewind"})},oi=({className:e})=>{const{isPlaying:t}=$e(),{play:n,setCurrentTime:r}=be(),{duration:a,playoutRef:s}=Ae(),o=()=>{r(a),t&&s.current&&(s.current.stop(),n(a))};return w.jsx(We,{onClick:o,className:e,children:"Fast Forward"})},si=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=$e(),{play:a,setCurrentTime:s}=be(),{playoutRef:o}=Ae(),l=()=>{const i=Math.max(0,(n.current??0)-e);s(i),r&&o.current&&(o.current.stop(),a(i))};return w.jsx(We,{onClick:l,className:t,children:"Skip Backward"})},ii=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=$e(),{play:a,setCurrentTime:s}=be(),{duration:o,playoutRef:l}=Ae(),i=()=>{const d=Math.min(o,(n.current??0)+e);s(d),r&&l.current&&(l.current.stop(),a(d))};return w.jsx(We,{onClick:i,className:t,children:"Skip Forward"})},li=({className:e,disabled:t})=>{const{zoomIn:n}=be(),{canZoomIn:r}=Ae();return w.jsx(We,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},ci=({className:e,disabled:t})=>{const{zoomOut:n}=be(),{canZoomOut:r}=Ae();return w.jsx(We,{variant:"success",onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},ui=({className:e})=>{const{masterVolume:t}=Ae(),{setMasterVolume:n}=be();return w.jsx(La,{volume:t,onChange:n,className:e})},di=({className:e})=>{const{timeFormat:t}=Ae(),{setTimeFormat:n}=be();return w.jsx(yo,{value:t,onChange:n,className:e})},fi=$.span`
|
|
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`
|
|
1122
1211
|
font-family: 'Courier New', Monaco, monospace;
|
|
1123
1212
|
font-size: 1rem;
|
|
1124
1213
|
font-weight: 600;
|
|
1125
1214
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
1126
1215
|
user-select: none;
|
|
1127
|
-
`,
|
|
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`
|
|
1128
1217
|
position: absolute;
|
|
1129
1218
|
top: 0;
|
|
1130
1219
|
left: 0;
|
|
@@ -1134,9 +1223,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1134
1223
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
1135
1224
|
pointer-events: none;
|
|
1136
1225
|
will-change: transform;
|
|
1137
|
-
`,
|
|
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`
|
|
1138
1227
|
position: relative;
|
|
1139
|
-
`,
|
|
1228
|
+
`,dl=k.div`
|
|
1140
1229
|
position: absolute;
|
|
1141
1230
|
top: ${e=>e.$top}px;
|
|
1142
1231
|
left: 0;
|
|
@@ -1148,7 +1237,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1148
1237
|
transform: translateZ(0);
|
|
1149
1238
|
backface-visibility: hidden;
|
|
1150
1239
|
will-change: transform;
|
|
1151
|
-
`,
|
|
1240
|
+
`,fl=k.div`
|
|
1152
1241
|
position: absolute;
|
|
1153
1242
|
top: ${e=>e.$top}px;
|
|
1154
1243
|
left: 0;
|
|
@@ -1157,9 +1246,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1157
1246
|
pointer-events: none;
|
|
1158
1247
|
z-index: 1;
|
|
1159
1248
|
will-change: width;
|
|
1160
|
-
`,
|
|
1249
|
+
`,hl=k.div`
|
|
1161
1250
|
position: relative;
|
|
1162
1251
|
z-index: 2;
|
|
1163
|
-
`,rr=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=u.useRef(null),a=u.useRef(null),s=mn(),{waveHeight:o}=Ft(),{isPlaying:l,currentTimeRef:i,playbackStartTimeRef:d,audioStartPositionRef:f}=$e(),{samplesPerPixel:b,sampleRate:p}=Ae(),h=s?.waveProgressColor||"rgba(0, 0, 0, 0.1)";u.useEffect(()=>{const m=()=>{if(r.current){let C;if(l){const A=F.getContext().currentTime-(d.current??0);C=(f.current??0)+A}else C=i.current??0;const y=C*p,g=e+t;let k=0;if(y<=e)k=0;else if(y>=g)k=n.length;else{const A=y-e;k=Math.floor(A/b)}r.current.style.width=`${k}px`}l&&(a.current=requestAnimationFrame(m))};return l?a.current=requestAnimationFrame(m):m(),()=>{a.current&&(cancelAnimationFrame(a.current),a.current=null)}},[l,p,b,e,t,n.length,i,d,f]),u.useEffect(()=>{if(!l&&r.current){const C=(i.current??0)*p,y=e+t;let g=0;if(C<=e)g=0;else if(C>=y)g=n.length;else{const k=C-e;g=Math.floor(k/b)}r.current.style.width=`${g}px`}});const x=s?.waveformDrawMode||"inverted";let I;x==="inverted"?I=n.isSelected&&s?s.selectedWaveFillColor:s?.waveFillColor||"white":I=n.isSelected&&s?s.selectedWaveOutlineColor:s?.waveOutlineColor||"grey";const v=Rt(I);return w.jsxs(Ii,{children:[w.jsx(Ai,{$color:v,$height:o,$top:n.index*o,$width:n.length}),w.jsx(Si,{ref:r,$color:h,$height:o,$top:n.index*o}),w.jsx(ki,{children:w.jsx(uo,{...n,transparentBackground:!0})})]})},$i=60,Ri=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:a,annotationTextHeight:s,className:o,showClipHeaders:l=!1,interactiveClips:i=!1,showFades:d=!1,touchOptimized:f=!1,recordingState:b})=>{const p=mn(),{isPlaying:h,currentTimeRef:x,playbackStartTimeRef:I,audioStartPositionRef:v}=$e(),{selectionStart:m,selectionEnd:C,annotations:y,activeAnnotationId:g,annotationsEditable:k,linkEndpoints:A,continuousPlay:E,selectedTrackId:_}=Fe(),{setAnnotations:B,setActiveAnnotationId:M,setTrackMute:D,setTrackSolo:Z,setTrackVolume:W,setTrackPan:O,setSelection:N,play:G,setScrollContainer:K,setSelectedTrackId:Q,setCurrentTime:H}=be(),{audioBuffers:ee,peaksDataArray:ie,trackStates:ce,tracks:q,duration:re,samplesPerPixel:te,sampleRate:fe,waveHeight:Ne,timeScaleHeight:Ze,controls:ae,playoutRef:Me,barWidth:at,barGap:V}=Ae(),[Se,pe]=u.useState(!1),he=u.useRef(null),_e=u.useCallback(Y=>{he.current=Y,K(Y)},[K]);let we=ee.length>0?re:$i;if(b?.isRecording){const U=(b.startSample+b.durationSamples)/fe;we=Math.max(we,U+10)}const Ie=Math.floor(we*fe/te),Re=async Y=>{console.log("Annotation clicked:",Y.id),M(Y.id);const U=E?void 0:Y.end-Y.start;await G(Y.start,U)},Ee=u.useCallback(Y=>{if(Y>=0&&Y<q.length){const U=q[Y];Q(U.id)}},[q,Q]),Je=Y=>{const U=Y.currentTarget.getBoundingClientRect(),ue=ae.show?ae.width:0,me=(Y.clientX-U.left-ue)*te/fe,oe=Y.clientY-U.top;let Be=0,xe=-1;for(let De=0;De<ie.length;De++){const ye=ie[De],Ve=(ye.length>0?Math.max(...ye.map(Le=>Le.peaks.data.length)):1)*Ne+(l?22:0);if(oe>=Be&&oe<Be+Ve){xe=De;break}Be+=Ve}xe!==-1&&Ee(xe),pe(!0),H(me),N(me,me)},He=Y=>{if(!Se)return;const U=Y.currentTarget.getBoundingClientRect(),ue=ae.show?ae.width:0,me=(Y.clientX-U.left-ue)*te/fe,ke=Math.min(m,me),oe=Math.max(m,me);N(ke,oe)},Pe=Y=>{if(!Se)return;pe(!1);const U=Y.currentTarget.getBoundingClientRect(),ue=ae.show?ae.width:0,me=(Y.clientX-U.left-ue)*te/fe,ke=Math.min(m,me),oe=Math.max(m,me);Math.abs(oe-ke)<.1?(H(ke),h&&Me.current?(Me.current.stop(),G(ke)):Me.current&&Me.current.stop()):N(ke,oe)};return q.some(Y=>Y.clips.length>0)&&(ee.length===0||ie.length===0)?w.jsx("div",{className:o,children:"Loading waveform..."}):w.jsx(ro,{children:w.jsxs(hn.Provider,{value:{samplesPerPixel:te,sampleRate:fe,zoomLevels:[te],waveHeight:Ne,timeScaleHeight:Ze,duration:we,controls:ae,barWidth:at,barGap:V},children:[w.jsx(wr,{theme:p,backgroundColor:Rt(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,scrollContainerWidth:Ie+(ae.show?ae.width:0),timescaleWidth:Ie,tracksWidth:Ie,controlsWidth:ae.show?ae.width:0,onTracksMouseDown:Je,onTracksMouseMove:He,onTracksMouseUp:Pe,scrollContainerRef:_e,timescale:Ze>0?w.jsx(vo,{duration:we*1e3,marker:1e4,bigStep:5e3,secondStep:1e3,renderTimestamp:t}):void 0,children:w.jsxs(w.Fragment,{children:[ie.map((Y,U)=>{const ue=q[U];if(!ue)return null;const ge=ce[U]||{name:`Track ${U+1}`,muted:!1,soloed:!1,volume:1,pan:0},me=e?e(U):w.jsxs($o,{onClick:()=>Ee(U),children:[w.jsx(Ro,{style:{justifyContent:"center"},children:ge.name||`Track ${U+1}`}),w.jsxs(ko,{children:[w.jsx(Pn,{$variant:ge.muted?"danger":"outline",onClick:()=>D(U,!ge.muted),children:"Mute"}),w.jsx(Pn,{$variant:ge.soloed?"info":"outline",onClick:()=>Z(U,!ge.soloed),children:"Solo"})]}),w.jsxs(jn,{children:[w.jsx(Do,{}),w.jsx(Vn,{min:"0",max:"1",step:"0.01",value:ge.volume,onChange:oe=>W(U,parseFloat(oe.target.value))}),w.jsx(Eo,{})]}),w.jsxs(jn,{children:[w.jsx("span",{children:"L"}),w.jsx(Vn,{min:"-1",max:"1",step:"0.01",value:ge.pan,onChange:oe=>O(U,parseFloat(oe.target.value))}),w.jsx("span",{children:"R"})]})]}),ke=Y.length>0?Math.max(...Y.map(oe=>oe.peaks.data.length)):1;return w.jsx(kr.Provider,{value:me,children:w.jsxs(So,{numChannels:ke,backgroundColor:Rt(p.waveOutlineColor),offset:0,width:Ie,hasClipHeaders:l,trackId:ue.id,isSelected:ue.id===_,children:[Y.map((oe,Be)=>{const xe=oe.peaks,De=xe.length;return w.jsx(Fn,{clipId:oe.clipId,trackIndex:U,clipIndex:Be,trackName:oe.trackName,startSample:oe.startSample,durationSamples:oe.durationSamples,samplesPerPixel:te,showHeader:l,disableHeaderDrag:!i,isSelected:ue.id===_,trackId:ue.id,fadeIn:oe.fadeIn,fadeOut:oe.fadeOut,sampleRate:fe,showFades:d,touchOptimized:f,onMouseDown:ye=>{ye.target.closest('[role="button"][aria-roledescription="draggable"]')||Ee(U)},children:xe.data.map((ye,ve)=>w.jsx(rr,{index:ve,data:ye,bits:xe.bits,length:De,isSelected:ue.id===_,clipStartSample:oe.startSample,clipDurationSamples:oe.durationSamples},`${U}-${Be}-${ve}`))},`${U}-${Be}`)}),b?.isRecording&&b.trackId===ue.id&&b.peaks.length>0&&w.jsx(Fn,{clipId:"recording-preview",trackIndex:U,clipIndex:Y.length,trackName:"Recording...",startSample:b.startSample,durationSamples:b.durationSamples,samplesPerPixel:te,showHeader:l,disableHeaderDrag:!0,isSelected:ue.id===_,trackId:ue.id,children:w.jsx(rr,{index:0,data:b.peaks,bits:16,length:Math.floor(b.peaks.length/2),isSelected:ue.id===_,clipStartSample:b.startSample,clipDurationSamples:b.durationSamples},`${U}-recording-0`)},`${U}-recording`)]})},ue.id)}),y.length>0&&w.jsx(Jo,{height:30,width:Ie,children:y.map((Y,U)=>{const ue=Y.start*fe/te,ge=Y.end*fe/te;return w.jsx(Yo,{annotationId:Y.id,annotationIndex:U,startPosition:ue,endPosition:ge,label:Y.id,color:"#ff9800",isActive:Y.id===g,onClick:()=>Re(Y),editable:k},Y.id)})}),m!==C&&w.jsx(to,{startPosition:Math.min(m,C)*fe/te+(ae.show?ae.width:0),endPosition:Math.max(m,C)*fe/te+(ae.show?ae.width:0),color:p.selectionColor}),(h||m===C)&&(n?n({position:(x.current??0)*fe/te+(ae.show?ae.width:0),color:p.playheadColor,isPlaying:h,currentTimeRef:x,playbackStartTimeRef:I,audioStartPositionRef:v,samplesPerPixel:te,sampleRate:fe,controlsOffset:ae.show?ae.width:0,getAudioContextTime:()=>F.getContext().currentTime}):w.jsx(wi,{color:p.playheadColor,controlsOffset:ae.show?ae.width:0}))]})}),y.length>0&&w.jsx(ls,{annotations:y,activeAnnotationId:g??void 0,shouldScrollToActive:!0,editable:k,controls:k?r:void 0,annotationListConfig:{linkEndpoints:A,continuousPlay:E},height:s,onAnnotationUpdate:Y=>{B(Y)}})]})})};function Ue(e,t){this._waveformData=e,this._channelIndex=t}Ue.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};Ue.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};Ue.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};Ue.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};Ue.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};Ue.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 Di=127,Ei=-128,Ti=32767,Mi=-32768;function Bi(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function _i(e){for(var t=e.scale,n=e.amplitude_scale,r=e.split_channels,a=e.length,s=e.sample_rate,o=e.channels.map(function(D){return new Float32Array(D)}),l=r?o.length:1,i=24,d=Bi(a,t),f=e.bits===8?1:2,b=i+d*2*f*l,p=new ArrayBuffer(b),h=new DataView(p),x=0,I=i,v=new Array(l),m=new Array(l),C=0;C<l;C++)v[C]=1/0,m[C]=-1/0;var y=e.bits===8?Ei:Mi,g=e.bits===8?Di:Ti;h.setInt32(0,2,!0),h.setUint32(4,e.bits===8,!0),h.setInt32(8,s,!0),h.setInt32(12,t,!0),h.setInt32(16,d,!0),h.setInt32(20,l,!0);for(var k=0;k<a;k++){var A=0;if(l===1){for(var E=0;E<o.length;++E)A+=o[E][k];A=Math.floor(g*A*n/o.length),A<v[0]&&(v[0]=A,v[0]<y&&(v[0]=y)),A>m[0]&&(m[0]=A,m[0]>g&&(m[0]=g))}else for(var _=0;_<l;++_)A=Math.floor(g*o[_][k]*n),A<v[_]&&(v[_]=A,v[_]<y&&(v[_]=y)),A>m[_]&&(m[_]=A,m[_]>g&&(m[_]=g));if(++x===t){for(var B=0;B<l;B++)e.bits===8?(h.setInt8(I++,v[B]),h.setInt8(I++,m[B])):(h.setInt16(I,v[B],!0),h.setInt16(I+2,m[B],!0),I+=4),v[B]=1/0,m[B]=-1/0;x=0}}if(x>0)for(var M=0;M<l;M++)e.bits===8?(h.setInt8(I++,v[M]),h.setInt8(I++,m[M])):(h.setInt16(I,v[M],!0),h.setInt16(I+2,m[M],!0));return p}function Et(e){"@babel/helpers - typeof";return Et=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},Et(e)}function Wi(e){return e&&Et(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function Fi(e){var t=e&&Et(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 Zi(e){var t=e.data,n=e.channels||1,r=24,a=e.bits===8?1:2,s=e.length*2*n;if(t.length!==s)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=r+t.length*a,l=new ArrayBuffer(o),i=new DataView(l);i.setInt32(0,2,!0),i.setUint32(4,e.bits===8,!0),i.setInt32(8,e.sample_rate,!0),i.setInt32(12,e.samples_per_pixel,!0),i.setInt32(16,e.length,!0),i.setInt32(20,n,!0);var d=r;if(e.bits===8)for(var f=0;f<t.length;f++)i.setInt8(d++,t[f],!0);else for(var b=0;b<t.length;b++)i.setInt16(d,t[b],!0),d+=2;return l}function Qe(e){return e==null}function Pi(e,t){var n=atob(e);return n}function Vi(e,t,n){var r=Pi(e),a=r.indexOf(`
|
|
1164
|
-
`,10)+1,s=r.substring(a)+"",o=new Blob([s],{type:"application/javascript"});return URL.createObjectURL(o)}function ji(e,t,n){var r;return function(s){return r=r||Vi(e),new Worker(r,s)}}var zi=ji("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function Te(e){if(Wi(e)&&(e=Zi(e)),Fi(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 Ue(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var ht={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function Oi(e){var t={scale:e.scale||ht.scale,bits:e.bits||ht.bits,amplitude_scale:e.amplitude_scale||ht.amplitude_scale,split_channels:e.split_channels||ht.split_channels,disable_worker:e.disable_worker||ht.disable_worker};return t}function Ni(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Pr(e,t,n){var r=Ni(e);if(t.disable_worker){var a=_i({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 Te(a),e)}else{var s=new zi;s.onmessage=function(o){n(void 0,new Te(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 Hi(e,t,n,r){function a(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var s=e.decodeAudioData(t,function(o){Pr(o,n,r)},a);s&&s.catch(a)}Te.create=function(t){return new Te(t)};Te.createFromAudio=function(e,t){var n=Oi(e);if(e.audio_context&&e.array_buffer)return Hi(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Pr(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Zt(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 Te(this._output_data),this._input_index=0,this._output_index=0;var o=this._inputData.channels;this._min=new Array(o),this._max=new Array(o);for(var l=0;l<o;++l)this._input_buffer_size>0?(this._min[l]=this._inputData.channel(l).min_sample(this._input_index),this._max[l]=this._inputData.channel(l).max_sample(this._input_index)):(this._min[l]=0,this._max[l]=0);this._min_value=this._inputData.bits===8?-128:-32768,this._max_value=this._inputData.bits===8?127:32767,this._where=0,this._prev_where=0,this._stop=0,this._last_input_index=0}Zt.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};Zt.prototype.next=function(){for(var e=0,t=1e3,n=this._inputData.channels,r;this._input_index<this._input_buffer_size&&e<t;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(var a=0;a<n;++a)r=this._outputWaveformData.channel(a),r.set_min_sample(this._output_index-1,this._min[a]),r.set_max_sample(this._output_index-1,this._max[a]);if(this._last_input_index=this._input_index,this._output_index++,this._where=this.sample_at_pixel(this._output_index),this._prev_where=this.sample_at_pixel(this._output_index-1),this._where!==this._prev_where)for(var s=0;s<n;++s)this._min[s]=this._max_value,this._max[s]=this._min_value}for(this._where=this.sample_at_pixel(this._output_index),this._stop=Math.floor(this._where/this._scale),this._stop>this._input_buffer_size&&(this._stop=this._input_buffer_size);this._input_index<this._stop;){for(var o=0;o<n;++o){r=this._inputData.channel(o);var l=r.min_sample(this._input_index);l<this._min[o]&&(this._min[o]=l),l=r.max_sample(this._input_index),l>this._max[o]&&(this._max[o]=l)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var i=0;i<n;++i)r=this._outputWaveformData.channel(i),r.set_min_sample(this._output_index-1,this._min[i]),r.set_max_sample(this._output_index-1,this._max[i]);return!0};Zt.prototype.getOutputData=function(){return this._output_data};Te.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Qe(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Qe(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 Zt(t);!n.next(););return new Te(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 Te.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,a=0,s=[this].concat(t).map(function(m){return m._data.buffer}),o=0;o<s.length;o++){var l=s[o],i=new DataView(l).getInt32(16,!0);r+=l.byteLength-n,a+=i}for(var d=new ArrayBuffer(r),f=new DataView(s[0]),b=new DataView(d),p=0;p<n;p++)b.setUint8(p,f.getUint8(p));b.setInt32(16,a,!0);for(var h=0,x=new Uint8Array(d,n),I=0;I<s.length;I++){var v=s[I];x.set(new Uint8Array(v,n),h),h+=v.byteLength-n}return d},slice:function(t){var n=0,r=0;if(!Qe(t.startIndex)&&!Qe(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Qe(t.startTime)&&!Qe(t.endTime)&&(n=this.at_time(t.startTime),r=this.at_time(t.endTime)),n<0)throw new RangeError("startIndex or startTime must not be negative");if(r<0)throw new RangeError("endIndex or endTime must not be negative");n>this.length&&(n=this.length),r>this.length&&(r=this.length),n>r&&(n=r);var a=r-n,s=24,o=this.bits===8?1:2,l=s+a*2*this.channels*o,i=new ArrayBuffer(l),d=new DataView(i);d.setInt32(0,2,!0),d.setUint32(4,this.bits===8,!0),d.setInt32(8,this.sample_rate,!0),d.setInt32(12,this.scale,!0),d.setInt32(16,a,!0),d.setInt32(20,this.channels,!0);for(var f=0;f<a*this.channels*2;f++){var b=this._at(n*this.channels*2+f);this.bits===8?d.setInt8(s+f,b):d.setInt16(s+f*2,b,!0)}return new Te(i)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){var e=!!this._data.getUint32(4,!0);return e?8:16},get duration(){return this.length*this.scale/this.sample_rate},get pixels_per_second(){return this.sample_rate/this.scale},get seconds_per_pixel(){return this.scale/this.sample_rate},get channels(){return this._version()===2?this._data.getInt32(20,!0):1},channel:function(t){if(t>=0&&t<this._channels.length)return this._channels[t];throw new RangeError("Invalid channel: "+t)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(t){return this.bits===8?this._data.getInt8(this._offset+t):this._data.getInt16(this._offset+t*2,!0)},_set_at:function(t,n){return this.bits===8?this._data.setInt8(this._offset+t,n):this._data.setInt16(this._offset+t*2,n,!0)},at_time:function(t){return Math.floor(t*this.sample_rate/this.scale)},time:function(t){return t*this.scale/this.sample_rate},toJSON:function(){for(var t={version:2,channels:this.channels,sample_rate:this.sample_rate,samples_per_pixel:this.scale,bits:this.bits,length:this.length,data:[]},n=0;n<this.length;n++)for(var r=0;r<this.channels;r++)t.data.push(this.channel(r).min_sample(n)),t.data.push(this.channel(r).max_sample(n));return t},toArrayBuffer:function(){return this._data.buffer}};async function gn(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 Te.create(r)}else{const r=await t.json();return Te.create(r)}}function Vr(e,t=0){const n=e.channel(t),r=e.bits,a=n.min_array(),s=n.max_array(),o=a.length,l=r===8?new Int8Array(o*2):new Int16Array(o*2);for(let i=0;i<o;i++)l[i*2]=a[i],l[i*2+1]=s[i];return{data:l,bits:r,length:o,sampleRate:e.sample_rate}}async function Gi(e,t=0){const n=await gn(e);return Vr(n,t)}async function Xi(e){const t=await gn(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}exports.Tone=or;exports.AudioPosition=hi;exports.AutomaticScrollCheckbox=pi;exports.ContinuousPlayCheckbox=gi;exports.DownloadAnnotationsButton=Ci;exports.EditableCheckbox=vi;exports.ExportWavButton=xi;exports.FastForwardButton=oi;exports.LinkEndpointsCheckbox=bi;exports.MasterVolumeControl=ui;exports.PauseButton=ni;exports.PlayButton=ti;exports.RewindButton=ai;exports.SelectionTimeInputs=mi;exports.SkipBackwardButton=si;exports.SkipForwardButton=ii;exports.StopButton=ri;exports.TimeFormatSelect=di;exports.Waveform=Ri;exports.WaveformPlaylistProvider=Qs;exports.ZoomInButton=li;exports.ZoomOutButton=ci;exports.createEffectChain=Gs;exports.createEffectInstance=mt;exports.effectCategories=zs;exports.effectDefinitions=pt;exports.getEffectDefinition=pn;exports.getEffectsByCategory=js;exports.getShortcutLabel=As;exports.getWaveformDataMetadata=Xi;exports.loadPeaksFromWaveformData=Gi;exports.loadWaveformData=gn;exports.useAnnotationDragHandlers=xs;exports.useAnnotationKeyboardControls=ks;exports.useAudioTracks=vs;exports.useClipDragHandlers=Cs;exports.useClipSplitting=Is;exports.useDragSensors=ws;exports.useDynamicEffects=Xs;exports.useExportWav=Mr;exports.useIntegratedRecording=Vs;exports.useKeyboardShortcuts=Dt;exports.useMasterAnalyser=ps;exports.useMasterVolume=Er;exports.usePlaybackAnimation=$e;exports.usePlaybackShortcuts=Ss;exports.usePlaylistControls=be;exports.usePlaylistData=Ae;exports.usePlaylistState=Fe;exports.useTimeFormat=Rr;exports.useTrackDynamicEffects=Ys;exports.useWaveformPlaylist=ei;exports.useZoomControls=Dr;exports.waveformDataToPeaks=Vr;
|
|
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;
|
|
1165
1254
|
//# sourceMappingURL=index.js.map
|