@waveform-playlist/browser 9.0.4 → 9.1.0
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 +144 -6
- package/dist/index.js +117 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7108 -5282
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var vf=Object.create;var zi=Object.defineProperty;var yf=Object.getOwnPropertyDescriptor;var bf=Object.getOwnPropertyNames;var wf=Object.getPrototypeOf,_f=Object.prototype.hasOwnProperty;var xf=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of bf(t))!_f.call(e,s)&&s!==n&&zi(e,s,{get:()=>t[s],enumerable:!(r=yf(t,s))||r.enumerable});return e};var Cf=(e,t,n)=>(n=e!=null?vf(wf(e)):{},xf(t||!e||!e.__esModule?zi(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("tone"),C=require("react/jsx-runtime"),f=require("react"),R=require("styled-components"),ro=require("react-dom");function Vl(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 zl=Vl(j),D=Vl(f);var Ye=1e3;function ma(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c}=e,u=t?.sampleRate??e.sampleRate??c?.sample_rate,d=t?.length??e.sourceDurationSamples??(c&&u?Math.ceil(c.duration*u):void 0);if(u===void 0)throw new Error("createClip: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");if(d===void 0)throw new Error("createClip: sourceDurationSamples is required when audioBuffer is not provided (can use waveformData.duration)");t&&c&&t.sampleRate!==c.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${c.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const p=e.durationSamples??d;return{id:Hl(),audioBuffer:t,startSample:n,durationSamples:p,offsetSamples:r,sampleRate:u,sourceDurationSamples:d,gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c}}function jl(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c}=e,u=t?.sampleRate??e.sampleRate??c?.sample_rate;if(u===void 0)throw new Error("createClipFromSeconds: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");const d=t?.duration??e.sourceDuration??c?.duration;if(d===void 0)throw new Error("createClipFromSeconds: sourceDuration is required when audioBuffer is not provided (can use waveformData.duration)");t&&c&&t.sampleRate!==c.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${c.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const p=e.duration??d;return ma({audioBuffer:t,startSample:Math.round(n*u),durationSamples:Math.round(p*u),offsetSamples:Math.round(r*u),sampleRate:u,sourceDurationSamples:Math.ceil(d*u),gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c})}function Zl(e){const{name:t,clips:n=[],muted:r=!1,soloed:s=!1,volume:a=1,pan:o=0,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}=e;return{id:Hl(),name:t,clips:n,muted:r,soloed:s,volume:a,pan:o,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}}function Hl(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function ji(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function Zi(e){return e.startSample/e.sampleRate}function kf(e){return(e.startSample+e.durationSamples)/e.sampleRate}function Sf(e){return e.offsetSamples/e.sampleRate}function Ef(e){return e.durationSamples/e.sampleRate}var Hi=!1;function ga(e){const t=e._param;return!t&&!Hi&&(Hi=!0,console.warn("[waveform-playlist] Unable to access Tone.js internal _param. This likely means the Tone.js version is incompatible. Mute scheduling may not work correctly.")),t}function Ni(e,t){const n=new Float32Array(e),r=e-1;for(let s=0;s<e;s++){const a=s/r;n[s]=t?a:1-a}return n}function If(e,t){const n=new Float32Array(e),r=e-1;for(let s=0;s<e;s++){const a=s/r,o=t?s:e-1-s;n[o]=Math.exp(2*a-1)/Math.E}return n}function Af(e,t){const n=new Float32Array(e),r=t?Math.PI/2:-Math.PI/2;for(let s=0;s<e;s++)n[s]=Math.sin(Math.PI*s/e-r)/2+.5;return n}function Mf(e,t,n=10){const r=new Float32Array(e);for(let s=0;s<e;s++){const a=t?s:e-1-s,o=s/e;r[a]=Math.log(1+n*o)/Math.log(1+n)}return r}function Nl(e,t,n){switch(e){case"linear":return Ni(t,n);case"exponential":return If(t,n);case"sCurve":return Af(t,n);case"logarithmic":return Mf(t,n);default:return Ni(t,n)}}function Xi(e,t,n,r="linear",s=0,a=1){if(!(n<=0))if(r==="linear")e.setValueAtTime(s,t),e.linearRampToValueAtTime(a,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(s,.001),t),e.exponentialRampToValueAtTime(Math.max(a,.001),t+n);else{const o=Nl(r,1e4,!0),i=new Float32Array(o.length),l=a-s;for(let c=0;c<o.length;c++)i[c]=s+o[c]*l;e.setValueCurveAtTime(i,t,n)}}function Gi(e,t,n,r="linear",s=1,a=0){if(!(n<=0))if(r==="linear")e.setValueAtTime(s,t),e.linearRampToValueAtTime(a,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(s,.001),t),e.exponentialRampToValueAtTime(Math.max(a,.001),t+n);else{const o=Nl(r,1e4,!1),i=new Float32Array(o.length),l=s-a;for(let c=0;c<o.length;c++)i[c]=a+o[c]*l;e.setValueCurveAtTime(i,t,n)}}var $f=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new j.Volume(this.gainToDb(e.track.gain)),this.panNode=new j.Panner(e.track.stereoPan),this.muteGain=new j.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||j.getDestination();if(e.effects){const o=e.effects(this.muteGain,t,!1);o&&(this.effectsCleanup=o)}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}]:[]),r=j.getTransport(),s=j.getContext().rawContext,a=this.volumeNode.input.input;this.scheduledClips=n.map(o=>{const i=s.createGain();i.gain.value=o.gain,i.connect(a);const l=this.track.startTime+o.startTime,c=r.schedule(u=>{l<this._scheduleGuardOffset||this.startClipSource(o,i,u)},l);return{clipInfo:o,fadeGainNode:i,scheduleId:c}})}startClipSource(e,t,n,r,s){const o=j.getContext().rawContext.createBufferSource();o.buffer=e.buffer,o.connect(t);const i=r??e.offset,l=s??e.duration;try{o.start(n,i,l)}catch(c){console.warn(`[waveform-playlist] Failed to start source on track "${this.id}" (time=${n}, offset=${i}, duration=${l}):`,c),o.disconnect();return}this.activeSources.add(o),o.onended=()=>{this.activeSources.delete(o)}}setScheduleGuardOffset(e){this._scheduleGuardOffset=e}startMidClipSources(e,t){for(const{clipInfo:n,fadeGainNode:r}of this.scheduledClips){const s=this.track.startTime+n.startTime,a=s+n.duration;if(s<e&&a>e){const o=e-s,i=n.offset+o,l=n.duration-o;this.startClipSource(n,r,t,i,l)}}}stopAllSources(){this.activeSources.forEach(e=>{try{e.stop()}catch(t){console.warn(`[waveform-playlist] Error stopping source on track "${this.id}":`,t)}}),this.activeSources.clear()}scheduleFades(e,t,n=0){const{clipInfo:r,fadeGainNode:s}=e,a=s.gain;a.cancelScheduledValues(0);const o=n-r.offset;if(r.fadeIn&&o<r.fadeIn.duration){const i=r.fadeIn.duration;if(o<=0)Xi(a,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,c=o/i,u=r.gain*c;Xi(a,t,l,r.fadeIn.type||"linear",u,r.gain)}}else a.setValueAtTime(r.gain,t);if(r.fadeOut){const l=r.duration-r.fadeOut.duration-o;if(l>0){const c=t+l;Gi(a,c,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const c=-l,u=r.fadeOut.duration-c,d=c/r.fadeOut.duration,p=r.gain*(1-d);Gi(a,t,u,r.fadeOut.type||"linear",p,0)}}}prepareFades(e,t){this.scheduledClips.forEach(n=>{const r=this.track.startTime+n.clipInfo.startTime,s=r+n.clipInfo.duration;if(!(t>=s))if(t>=r){const a=t-r+n.clipInfo.offset;this.scheduleFades(n,e,a)}else{const a=r-t;this.scheduleFades(n,e+a,n.clipInfo.offset)}})}cancelFades(){this.scheduledClips.forEach(({fadeGainNode:e,clipInfo:t})=>{const n=e.gain;n.cancelScheduledValues(0),n.setValueAtTime(t.gain,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;const t=e?0:1;ga(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=j.getTransport();if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach((t,n)=>{try{e.clear(t.scheduleId)}catch(r){console.warn(`[waveform-playlist] Error clearing schedule ${n} on track "${this.id}":`,r)}try{t.fadeGainNode.disconnect()}catch(r){console.warn(`[waveform-playlist] Error disconnecting fadeGain ${n} on track "${this.id}":`,r)}});try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const e=this.scheduledClips[this.scheduledClips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get buffer(){return this.scheduledClips[0]?.clipInfo.buffer}get muted(){return this.track.muted}get startTime(){return this.track.startTime}},Tf=class{constructor(e={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this._completionEventId=null,this._loopHandler=null,this._loopEnabled=!1,this._loopStart=0,this._loopEnd=0,this.masterVolume=new j.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,j.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)}clearCompletionEvent(){if(this._completionEventId!==null){try{j.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await j.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new $f(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)throw new Error("[waveform-playlist] TonePlayout not initialized. Call init() first.");const r=e??j.now(),s=j.getTransport();this.clearCompletionEvent();const a=t??0;this.tracks.forEach(o=>{o.cancelFades(),o.prepareFades(r,a)}),n!==void 0&&(this._completionEventId=s.scheduleOnce(()=>{this._completionEventId=null;try{this.onPlaybackCompleteCallback?.()}catch(o){console.warn("[waveform-playlist] Error in playback completion callback:",o)}},a+n));try{s.state!=="stopped"&&s.stop(),this.tracks.forEach(o=>o.stopAllSources()),s.loopStart=this._loopStart,s.loopEnd=this._loopEnd,s.loop=this._loopEnabled,this.tracks.forEach(o=>o.setScheduleGuardOffset(a)),t!==void 0?s.start(r,t):s.start(r),s._clock._lastUpdate=r,this.tracks.forEach(o=>{o.startMidClipSources(a,r)})}catch(o){throw this.clearCompletionEvent(),this.tracks.forEach(i=>i.cancelFades()),console.warn("[waveform-playlist] Transport.start() failed. Audio playback could not begin.",o),o}}pause(){const e=j.getTransport();try{e.pause()}catch(t){console.warn("[waveform-playlist] Transport.pause() failed:",t)}this.tracks.forEach(t=>t.stopAllSources()),this.tracks.forEach(t=>t.cancelFades()),this.clearCompletionEvent()}stop(){const e=j.getTransport();try{e.stop()}catch(t){console.warn("[waveform-playlist] Transport.stop() failed:",t)}if(this._loopHandler){try{e.off("loop",this._loopHandler)}catch(t){console.warn("[waveform-playlist] Error removing loop handler:",t)}this._loopHandler=null}this.tracks.forEach(t=>t.stopAllSources()),this.tracks.forEach(t=>t.cancelFades()),this.clearCompletionEvent()}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))}setLoop(e,t,n){this._loopEnabled=e,this._loopStart=t,this._loopEnd=n;const r=j.getTransport();try{r.loopStart=t,r.loopEnd=n,r.loop=e}catch(s){console.warn("[waveform-playlist] Error configuring Transport loop:",s);return}e&&!this._loopHandler?(this._loopHandler=()=>{const s=j.now();this.tracks.forEach(a=>{try{a.stopAllSources(),a.cancelFades(),a.setScheduleGuardOffset(this._loopStart),a.startMidClipSources(this._loopStart,s),a.prepareFades(s,this._loopStart)}catch(o){console.warn(`[waveform-playlist] Error re-scheduling track "${a.id}" on loop:`,o)}})},r.on("loop",this._loopHandler)):!e&&this._loopHandler&&(r.off("loop",this._loopHandler),this._loopHandler=null)}getCurrentTime(){return j.getTransport().seconds}seekTo(e){j.getTransport().seconds=e}dispose(){if(this.clearCompletionEvent(),this._loopHandler){try{j.getTransport().off("loop",this._loopHandler)}catch(e){console.warn("[waveform-playlist] Error removing Transport loop handler:",e)}this._loopHandler=null}if(this.tracks.forEach(e=>{try{e.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing track "${e.id}":`,t)}}),this.tracks.clear(),this.effectsCleanup)try{this.effectsCleanup()}catch(e){console.warn("[waveform-playlist] Error during master effects cleanup:",e)}try{this.masterVolume.dispose()}catch(e){console.warn("[waveform-playlist] Error disposing master volume:",e)}}get context(){return j.getContext()}get sampleRate(){return j.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Ur=null;function Df(){return Ur||(Ur=new j.Context,j.setContext(Ur)),Ur}function Rf(){return Df().rawContext}function Pf(e){let t=null,n=!1,r=0,s=!1,a=0,o=0,i=!1;function l(c){if(t){try{t.dispose()}catch(d){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",d)}t=null}r++;const u=r;t=new Tf({effects:e?.effects}),i&&t.init().catch(d=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",d),i=!1});for(const d of c){const p=d.clips.filter(m=>m.audioBuffer);if(p.length===0)continue;const h=Math.min(...p.map(Zi)),g=Math.max(...p.map(kf)),b={id:d.id,name:d.name,gain:d.volume,muted:d.muted,soloed:d.soloed,stereoPan:d.pan,startTime:h,endTime:g},y=p.map(m=>({buffer:m.audioBuffer,startTime:Zi(m)-h,duration:Ef(m),offset:Sf(m),fadeIn:m.fadeIn,fadeOut:m.fadeOut,gain:m.gain}));t.addTrack({clips:y,track:b,effects:d.effects})}t.applyInitialSoloState(),t.setLoop(s,a,o),t.setOnPlaybackComplete(()=>{u===r&&(n=!1)})}return{async init(){t&&(await t.init(),i=!0)},setTracks(c){l(c)},play(c,u){if(!t){console.warn("[waveform-playlist] adapter.play() called but no playout is available. Tracks may not have been set, or the adapter was disposed.");return}const d=u!==void 0?u-c:void 0;t.play(j.now(),c,d),n=!0},pause(){t?.pause(),n=!1},stop(){t?.stop(),n=!1},seek(c){t?.seekTo(c)},getCurrentTime(){return t?.getCurrentTime()??0},isPlaying(){return n},setMasterVolume(c){t?.setMasterGain(c)},setTrackVolume(c,u){t?.getTrack(c)?.setVolume(u)},setTrackMute(c,u){t?.setMute(c,u)},setTrackSolo(c,u){t?.setSolo(c,u)},setTrackPan(c,u){t?.getTrack(c)?.setPan(u)},setLoop(c,u,d){s=c,a=u,o=d,t?.setLoop(c,u,d)},dispose(){try{t?.dispose()}catch(c){console.warn("[waveform-playlist] Error disposing playout:",c)}t=null,n=!1}}}function Xl(e,t,n,r){let s=t;const a=-e.startSample;if(s=Math.max(s,a),r>0){const o=n[r-1],l=o.startSample+o.durationSamples-e.startSample;s=Math.max(s,l)}if(r<n.length-1){const i=n[r+1].startSample-(e.startSample+e.durationSamples);s=Math.min(s,i)}return s}function va(e,t,n,r,s,a){let o=t;if(n==="left"){if(o=Math.max(o,-e.startSample),o=Math.max(o,-e.offsetSamples),s>0){const i=r[s-1],l=i.startSample+i.durationSamples;o=Math.max(o,l-e.startSample)}o=Math.min(o,e.durationSamples-a)}else if(o=Math.max(o,a-e.durationSamples),o=Math.min(o,e.sourceDurationSamples-e.offsetSamples-e.durationSamples),s<r.length-1){const i=r[s+1];o=Math.min(o,i.startSample-e.startSample-e.durationSamples)}return o}function Wf(e,t){return Math.floor(e/t)*t}function Ff(e,t){const n=t-e.startSample,r=e.durationSamples-n,s=e.name?`${e.name} (1)`:void 0,a=e.name?`${e.name} (2)`:void 0,o=ma({startSample:e.startSample,durationSamples:n,offsetSamples:e.offsetSamples,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:s,color:e.color,fadeIn:e.fadeIn,audioBuffer:e.audioBuffer,waveformData:e.waveformData}),i=ma({startSample:t,durationSamples:r,offsetSamples:e.offsetSamples+n,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:a,color:e.color,fadeOut:e.fadeOut,audioBuffer:e.audioBuffer,waveformData:e.waveformData});return{left:o,right:i}}function Gl(e,t,n){const r=e.startSample+e.durationSamples;if(t<=e.startSample||t>=r)return!1;const s=t-e.startSample,a=r-t;return s>=n&&a>=n}function Qs(e){let t=0;for(const n of e)for(const r of n.clips){const a=(r.startSample+r.durationSamples)/r.sampleRate;t=Math.max(t,a)}return t}function Yi(e,t){if(t.length===0)return 0;let n=0,r=Math.abs(t[0]-e);for(let s=1;s<t.length;s++){const a=Math.abs(t[s]-e);a<r&&(r=a,n=s)}return n}function Ui(e,t){return Math.max(0,Math.min(e,t))}var Of=44100,Bf=1e3,Lf=[256,512,1024,2048,4096,8192],Ki=.1,Vf=class{constructor(e={}){if(this._tracks=[],this._currentTime=0,this._playStartPosition=0,this._isPlaying=!1,this._selectedTrackId=null,this._selectionStart=0,this._selectionEnd=0,this._masterVolume=1,this._loopStart=0,this._loopEnd=0,this._isLoopEnabled=!1,this._tracksVersion=0,this._animFrameId=null,this._disposed=!1,this._listeners=new Map,this._sampleRate=e.sampleRate??Of,this._zoomLevels=[...e.zoomLevels??Lf],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??Bf;this._zoomIndex=Yi(t,this._zoomLevels)}getState(){return{tracks:this._tracks.map(e=>({...e,clips:[...e.clips]})),tracksVersion:this._tracksVersion,duration:Qs(this._tracks),currentTime:this._currentTime,isPlaying:this._isPlaying,samplesPerPixel:this._zoomLevels[this._zoomIndex],sampleRate:this._sampleRate,selectedTrackId:this._selectedTrackId,zoomIndex:this._zoomIndex,canZoomIn:this._zoomIndex>0,canZoomOut:this._zoomIndex<this._zoomLevels.length-1,selectionStart:this._selectionStart,selectionEnd:this._selectionEnd,masterVolume:this._masterVolume,loopStart:this._loopStart,loopEnd:this._loopEnd,isLoopEnabled:this._isLoopEnabled}}setTracks(e){this._tracks=[...e],this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}addTrack(e){this._tracks=[...this._tracks,e],this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}removeTrack(e){this._tracks.some(t=>t.id===e)&&(this._tracks=this._tracks.filter(t=>t.id!==e),this._tracksVersion++,this._selectedTrackId===e&&(this._selectedTrackId=null),this._adapter?.setTracks(this._tracks),this._emitStateChange())}selectTrack(e){e!==this._selectedTrackId&&(this._selectedTrackId=e,this._emitStateChange())}moveClip(e,t,n){const r=this._tracks.find(c=>c.id===e);if(!r){console.warn(`[waveform-playlist/engine] moveClip: track "${e}" not found`);return}const s=r.clips.findIndex(c=>c.id===t);if(s===-1){console.warn(`[waveform-playlist/engine] moveClip: clip "${t}" not found in track "${e}"`);return}const a=r.clips[s],o=ji(r.clips),i=o.findIndex(c=>c.id===t),l=Xl(a,n,o,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=c.clips.map((d,p)=>p===s?{...d,startSample:Math.floor(d.startSample+l)}:d);return{...c,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}splitClip(e,t,n){const r=this._tracks.find(c=>c.id===e);if(!r){console.warn(`[waveform-playlist/engine] splitClip: track "${e}" not found`);return}const s=r.clips.findIndex(c=>c.id===t);if(s===-1){console.warn(`[waveform-playlist/engine] splitClip: clip "${t}" not found in track "${e}"`);return}const a=r.clips[s],o=Math.floor(Ki*this._sampleRate);if(!Gl(a,n,o)){console.warn(`[waveform-playlist/engine] splitClip: cannot split clip "${t}" at sample ${n} (clip range: ${a.startSample}–${a.startSample+a.durationSamples}, minDuration: ${o})`);return}const{left:i,right:l}=Ff(a,n);this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=[...c.clips];return u.splice(s,1,i,l),{...c,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}trimClip(e,t,n,r){const s=this._tracks.find(d=>d.id===e);if(!s){console.warn(`[waveform-playlist/engine] trimClip: track "${e}" not found`);return}const a=s.clips.findIndex(d=>d.id===t);if(a===-1){console.warn(`[waveform-playlist/engine] trimClip: clip "${t}" not found in track "${e}"`);return}const o=s.clips[a],i=ji(s.clips),l=i.findIndex(d=>d.id===t),c=Math.floor(Ki*this._sampleRate),u=va(o,r,n,i,l,c);u!==0&&(this._tracks=this._tracks.map(d=>{if(d.id!==e)return d;const p=d.clips.map((h,g)=>g!==a?h:n==="left"?{...h,startSample:h.startSample+u,offsetSamples:h.offsetSamples+u,durationSamples:h.durationSamples-u}:{...h,durationSamples:h.durationSamples+u});return{...d,clips:p}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}async init(){this._adapter&&await this._adapter.init()}play(e,t){const n=this._currentTime,r=this._playStartPosition;if(e!==void 0){const s=Qs(this._tracks);this._currentTime=Ui(e,s)}if(this._playStartPosition=this._currentTime,this._adapter){if(t!==void 0)this._adapter.setLoop(!1,this._loopStart,this._loopEnd);else if(this._isLoopEnabled){const s=this._currentTime<this._loopEnd;this._adapter.setLoop(s,this._loopStart,this._loopEnd)}try{this._adapter.play(this._currentTime,t)}catch(s){throw this._currentTime=n,this._playStartPosition=r,s}}this._isPlaying=!0,this._startTimeUpdateLoop(),this._emit("play"),this._emitStateChange()}pause(){this._isPlaying=!1,this._stopTimeUpdateLoop(),this._adapter?.pause(),this._adapter&&(this._currentTime=this._adapter.getCurrentTime()),this._emit("pause"),this._emitStateChange()}stop(){this._isPlaying=!1,this._currentTime=this._playStartPosition,this._stopTimeUpdateLoop(),this._adapter?.setLoop(!1,this._loopStart,this._loopEnd),this._adapter?.stop(),this._emit("stop"),this._emitStateChange()}seek(e){const t=Qs(this._tracks);this._currentTime=Ui(e,t),this._adapter?.seek(this._currentTime),this._emitStateChange()}setMasterVolume(e){e!==this._masterVolume&&(this._masterVolume=e,this._adapter?.setMasterVolume(e),this._emitStateChange())}getCurrentTime(){return this._isPlaying&&this._adapter?this._adapter.getCurrentTime():this._currentTime}setSelection(e,t){const n=Math.min(e,t),r=Math.max(e,t);n===this._selectionStart&&r===this._selectionEnd||(this._selectionStart=n,this._selectionEnd=r,this._emitStateChange())}setLoopRegion(e,t){const n=Math.min(e,t),r=Math.max(e,t);n===this._loopStart&&r===this._loopEnd||(this._loopStart=n,this._loopEnd=r,this._adapter?.setLoop(this._isLoopEnabled&&this._isBeforeLoopEnd(),this._loopStart,this._loopEnd),this._emitStateChange())}setLoopEnabled(e){e!==this._isLoopEnabled&&(this._isLoopEnabled=e,this._adapter?.setLoop(e&&this._isBeforeLoopEnd(),this._loopStart,this._loopEnd),this._emitStateChange())}setTrackVolume(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.volume=t),this._adapter?.setTrackVolume(e,t)}setTrackMute(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.muted=t),this._adapter?.setTrackMute(e,t)}setTrackSolo(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.soloed=t),this._adapter?.setTrackSolo(e,t)}setTrackPan(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.pan=t),this._adapter?.setTrackPan(e,t)}zoomIn(){this._zoomIndex>0&&(this._zoomIndex--,this._emitStateChange())}zoomOut(){this._zoomIndex<this._zoomLevels.length-1&&(this._zoomIndex++,this._emitStateChange())}setZoomLevel(e){const t=Yi(e,this._zoomLevels);t!==this._zoomIndex&&(this._zoomIndex=t,this._emitStateChange())}on(e,t){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t)}off(e,t){this._listeners.get(e)?.delete(t)}dispose(){if(!this._disposed){this._disposed=!0,this._stopTimeUpdateLoop();try{this._adapter?.dispose()}catch(e){console.warn("[waveform-playlist/engine] Error disposing adapter:",e)}this._listeners.clear()}}_emit(e,...t){const n=this._listeners.get(e);if(n)for(const r of n)try{r(...t)}catch(s){console.warn("[waveform-playlist/engine] Error in event listener:",s)}}_isBeforeLoopEnd(){return this._isPlaying?(this._adapter?.getCurrentTime()??this._currentTime)<this._loopEnd:!0}_emitStateChange(){this._emit("statechange",this.getState())}_startTimeUpdateLoop(){if(typeof requestAnimationFrame>"u")return;this._stopTimeUpdateLoop();const e=()=>{this._disposed||!this._isPlaying||(this._adapter&&(this._currentTime=this._adapter.getCurrentTime(),this._emit("timeupdate",this._currentTime)),this._animFrameId=requestAnimationFrame(e))};this._animFrameId=requestAnimationFrame(e)}_stopTimeUpdateLoop(){this._animFrameId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this._animFrameId),this._animFrameId=null)}},zf=Symbol.for("preact-signals");function Rs(){if(Ut>1)Ut--;else{for(var e,t=!1;hr!==void 0;){var n=hr;for(hr=void 0,ya++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Ul(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(ya=0,Ut--,t)throw e}}function Kt(e){if(Ut>0)return e();Ut++;try{return e()}finally{Rs()}}var pe=void 0;function _e(e){var t=pe;pe=void 0;try{return e()}finally{pe=t}}var hr=void 0,Ut=0,ya=0,ms=0;function Yl(e){if(pe!==void 0){var t=e.n;if(t===void 0||t.t!==pe)return t={i:0,S:e,p:pe.s,n:void 0,t:pe,e:void 0,x:void 0,r:t},pe.s!==void 0&&(pe.s.n=t),pe.s=t,e.n=t,32&pe.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=pe.s,t.n=void 0,pe.s.n=t,pe.s=t),t}}function st(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}st.prototype.brand=zf;st.prototype.h=function(){return!0};st.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:_e(function(){var r;(r=t.W)==null||r.call(t)}))};st.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&_e(function(){var s;(s=t.Z)==null||s.call(t)}))}};st.prototype.subscribe=function(e){var t=this;return Ct(function(){var n=t.value,r=pe;pe=void 0;try{e(n)}finally{pe=r}},{name:"sub"})};st.prototype.valueOf=function(){return this.value};st.prototype.toString=function(){return this.value+""};st.prototype.toJSON=function(){return this.value};st.prototype.peek=function(){var e=pe;pe=void 0;try{return this.value}finally{pe=e}};Object.defineProperty(st.prototype,"value",{get:function(){var e=Yl(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ya>100)throw new Error("Cycle detected");this.v=e,this.i++,ms++,Ut++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Rs()}}}});function Mr(e,t){return new st(e,t)}function Ul(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Kl(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function ql(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function gn(e,t){st.call(this,void 0),this.x=e,this.s=void 0,this.g=ms-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}gn.prototype=new st;gn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ms))return!0;if(this.g=ms,this.f|=1,this.i>0&&!Ul(this))return this.f&=-2,!0;var e=pe;try{Kl(this),pe=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return pe=e,ql(this),this.f&=-2,!0};gn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}st.prototype.S.call(this,e)};gn.prototype.U=function(e){if(this.t!==void 0&&(st.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};gn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(gn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Yl(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function qi(e,t){return new gn(e,t)}function Jl(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Ut++;var n=pe;pe=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,so(e),r}finally{pe=n,Rs()}}}function so(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Jl(e)}function jf(e){if(pe!==this)throw new Error("Out-of-order effect");ql(this),pe=e,this.f&=-2,8&this.f&&so(this),Rs()}function jn(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}jn.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};jn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Jl(this),Kl(this),Ut++;var e=pe;return pe=this,jf.bind(this,e)};jn.prototype.N=function(){2&this.f||(this.f|=2,this.o=hr,hr=this)};jn.prototype.d=function(){this.f|=8,1&this.f||so(this)};jn.prototype.dispose=function(){this.d()};function Ct(e,t){var n=new jn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Zf=Object.create,ao=Object.defineProperty,Hf=Object.defineProperties,Nf=Object.getOwnPropertyDescriptor,Xf=Object.getOwnPropertyDescriptors,Ji=Object.getOwnPropertySymbols,Gf=Object.prototype.hasOwnProperty,Yf=Object.prototype.propertyIsEnumerable,Uf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},ba=(e,t,n)=>t in e?ao(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kf=(e,t)=>{for(var n in t||(t={}))Gf.call(t,n)&&ba(e,n,t[n]);if(Ji)for(var n of Ji(t))Yf.call(t,n)&&ba(e,n,t[n]);return e},qf=(e,t)=>Hf(e,Xf(t)),Qi=(e,t)=>ao(e,"name",{value:t,configurable:!0}),Jf=e=>{var t;return[,,,Zf((t=void 0)!=null?t:null)]},Ql=["class","method","getter","setter","accessor","field","value","get","set"],nr=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,Qf=(e,t,n,r,s)=>({kind:Ql[e],name:t,metadata:r,addInitializer:a=>n._?Zn("Already initialized"):s.push(nr(a||null))}),ec=(e,t)=>ba(t,Uf("metadata"),e[3]),sn=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},Hn=(e,t,n,r,s,a)=>{var o,i,l,c,u,d=t&7,p=!!(t&8),h=!!(t&16),g=d>3?e.length+1:d?p?1:2:0,b=Ql[d+5],y=d>3&&(e[g-1]=[]),m=e[g]||(e[g]=[]),w=d&&(!h&&!p&&(s=s.prototype),d<5&&(d>3||!h)&&Nf(d<4?s:{get[n](){return fn(this,a)},set[n](v){return Xt(this,a,v)}},n));d?h&&d<4&&Qi(a,(d>2?"set ":d>1?"get ":"")+n):Qi(s,n);for(var _=r.length-1;_>=0;_--)c=Qf(d,n,l={},e[3],m),d&&(c.static=p,c.private=h,u=c.access={has:h?v=>eh(s,v):v=>n in v},d^3&&(u.get=h?v=>(d^1?fn:th)(v,s,d^4?a:w.get):v=>v[n]),d>2&&(u.set=h?(v,x)=>Xt(v,s,x,d^4?a:w.set):(v,x)=>v[n]=x)),i=(0,r[_])(d?d<4?h?a:w[b]:d>4?void 0:{get:w.get,set:w.set}:s,c),l._=1,d^4||i===void 0?nr(i)&&(d>4?y.unshift(i):d?h?a=i:w[b]=i:s=i):typeof i!="object"||i===null?Zn("Object expected"):(nr(o=i.get)&&(w.get=o),nr(o=i.set)&&(w.set=o),nr(o=i.init)&&y.unshift(o));return d||ec(e,s),w&&ao(s,n,w),h?d^4?a:w:s},oo=(e,t,n)=>t.has(e)||Zn("Cannot "+n),eh=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),fn=(e,t,n)=>(oo(e,t,"read from private field"),n?n.call(e):t.get(e)),Kr=(e,t,n)=>t.has(e)?Zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xt=(e,t,n,r)=>(oo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),th=(e,t,n)=>(oo(e,t,"access private method"),n);function gs(e,t){if(t){let n;return qi(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return qi(e)}function br(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((r,s)=>!br(r,t[s]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(a=>!br(e[a],t[a]))}return!1}function ue({get:e},t){return{init(n){return Mr(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ae(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=gs(e.bind(this)),n.set(this,r)),r.value}}function ea(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),s=Object.getOwnPropertyDescriptor(r,n.name);s&&Object.defineProperty(r,n.name,qf(Kf({},s),{enumerable:e}))})}}function $r(...e){const t=e.map(n=>Ct(n));return()=>t.forEach(n=>n())}var tc,nc,rc,sc,ac,oc,tt,io,ta,wa,_a,qe,lo,na,ic,xa,co,ra,Ca,ka;oc=[ue],ac=[ue],sc=[ue],rc=[ea()],nc=[ea()],tc=[ea()];var Jt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,sn(tt,5,this),Kr(this,qe),Kr(this,io,sn(tt,8,this)),sn(tt,11,this),Kr(this,lo,sn(tt,12,this)),sn(tt,15,this),Kr(this,co,sn(tt,16,this)),sn(tt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return fn(this,qe,Ca)}get initial(){return fn(this,qe,wa)}get previous(){return fn(this,qe,ic)}set current(e){const t=_e(()=>fn(this,qe,Ca));e&&t&&this.equals(t,e)||Kt(()=>{fn(this,qe,wa)||Xt(this,qe,e,_a),Xt(this,qe,t,xa),Xt(this,qe,e,ka)})}reset(e=this.defaultValue){Kt(()=>{Xt(this,qe,void 0,xa),Xt(this,qe,e,_a),Xt(this,qe,e,ka)})}};tt=Jf();io=new WeakMap;qe=new WeakSet;lo=new WeakMap;co=new WeakMap;ta=Hn(tt,20,"#initial",oc,qe,io),wa=ta.get,_a=ta.set;na=Hn(tt,20,"#previous",ac,qe,lo),ic=na.get,xa=na.set;ra=Hn(tt,20,"#current",sc,qe,co),Ca=ra.get,ka=ra.set;Hn(tt,2,"current",rc,Jt);Hn(tt,2,"initial",nc,Jt);Hn(tt,2,"previous",tc,Jt);ec(tt,Jt);function sa(e){return _e(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var nh=Object.create,lc=Object.defineProperty,rh=Object.getOwnPropertyDescriptor,el=Object.getOwnPropertySymbols,sh=Object.prototype.hasOwnProperty,ah=Object.prototype.propertyIsEnumerable,cc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ps=e=>{throw TypeError(e)},tl=Math.pow,Sa=(e,t,n)=>t in e?lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,oh=(e,t)=>{for(var n in t||(t={}))sh.call(t,n)&&Sa(e,n,t[n]);if(el)for(var n of el(t))ah.call(t,n)&&Sa(e,n,t[n]);return e},ih=e=>{var t;return[,,,nh((t=e?.[cc("metadata")])!=null?t:null)]},uc=["class","method","getter","setter","accessor","field","value","get","set"],dc=e=>e!==void 0&&typeof e!="function"?Ps("Function expected"):e,lh=(e,t,n,r,s)=>({kind:uc[e],name:t,metadata:r,addInitializer:a=>n._?Ps("Already initialized"):s.push(dc(a||null))}),ch=(e,t)=>Sa(t,cc("metadata"),e[3]),uh=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},fc=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,d=!1,p=!1,h=2,g=uc[u+5],b=e[h]||(e[h]=[]),y=(s=s.prototype,rh(s,n)),m=r.length-1;m>=0;m--)l=lh(u,n,i={},e[3],b),l.static=d,l.private=p,c=l.access={has:w=>n in w},c.get=w=>w[n],o=(0,r[m])(y[g],l),i._=1,dc(o)&&(y[g]=o);return y&&lc(s,n,y),s},hc=(e,t,n)=>t.has(e)||Ps("Cannot "+n),dh=(e,t,n)=>(hc(e,t,"read from private field"),t.get(e)),fh=(e,t,n)=>t.has(e)?Ps("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),hh=(e,t,n,r)=>(hc(e,t,"write to private field"),t.set(e,n),n),Tt=class Ea{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ea(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Ea(t,n)}},Tr=class on{constructor(t,n,r,s){this.left=t,this.top=n,this.width=r,this.height=s,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:s,width:a,height:o,scale:i}=this,l=new on(s+t,r+n,a,o);return l.scale=oh({},i),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:a,bottom:o}=this;return{width:t,height:n,left:r,top:s,right:a,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new Tt((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof on))return!1;const{left:n,top:r,width:s,height:a}=this;return n===t.left&&r===t.top&&s===t.width&&a===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:a}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=a}intersectionArea(t){return t instanceof on?ph(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:s}){return new on(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(a,o)=>{const i=r[o],l=o==="x"?a.left:a.top,c=o==="x"?a.width:a.height;return i=="start"?l:i=="end"?l+c:l+c/2};return Tt.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return on.from(t).intersectionRatio(on.from(n))}};function ph(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=s-r,i=a-n;return r<s&&n<a?o*i:0}var pc,mc,Ia,rs,Dr,Ws=class extends(Ia=Jt,mc=[Ae],pc=[Ae],Ia){constructor(t){const n=Tt.from(t);super(n,(r,s)=>Tt.equals(r,s)),uh(Dr,5,this),fh(this,rs,0),this.velocity={x:0,y:0}}get delta(){return Tt.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Tt.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-dh(this,rs),i=l=>Math.round(l/o*100);Kt(()=>{hh(this,rs,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Tt.from(t)),this.velocity={x:0,y:0}}};Dr=ih(Ia);rs=new WeakMap;fc(Dr,2,"delta",mc,Ws);fc(Dr,2,"direction",pc,Ws);ch(Dr,Ws);function Aa({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(tl(r,2)+tl(s,2))>n:"x"in n&&"y"in n?r>n.x&&s>n.y:"x"in n?r>n.x:"y"in n?s>n.y:!1}var gc=(e=>(e.Horizontal="x",e.Vertical="y",e))(gc||{}),vc=Object.values(gc),mh=Object.create,uo=Object.defineProperty,gh=Object.defineProperties,vh=Object.getOwnPropertyDescriptor,yh=Object.getOwnPropertyDescriptors,vs=Object.getOwnPropertySymbols,yc=Object.prototype.hasOwnProperty,bc=Object.prototype.propertyIsEnumerable,wc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Nn=e=>{throw TypeError(e)},Ma=(e,t,n)=>t in e?uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_c=(e,t)=>{for(var n in t||(t={}))yc.call(t,n)&&Ma(e,n,t[n]);if(vs)for(var n of vs(t))bc.call(t,n)&&Ma(e,n,t[n]);return e},xc=(e,t)=>gh(e,yh(t)),nl=(e,t)=>uo(e,"name",{value:t,configurable:!0}),Cc=(e,t)=>{var n={};for(var r in e)yc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&vs)for(var r of vs(e))t.indexOf(r)<0&&bc.call(e,r)&&(n[r]=e[r]);return n},Xn=e=>{var t;return[,,,mh((t=e?.[wc("metadata")])!=null?t:null)]},kc=["class","method","getter","setter","accessor","field","value","get","set"],rr=e=>e!==void 0&&typeof e!="function"?Nn("Function expected"):e,bh=(e,t,n,r,s)=>({kind:kc[e],name:t,metadata:r,addInitializer:a=>n._?Nn("Already initialized"):s.push(rr(a||null))}),vn=(e,t)=>Ma(t,wc("metadata"),e[3]),J=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},ce=(e,t,n,r,s,a)=>{var o,i,l,c,u,d=t&7,p=!!(t&8),h=!!(t&16),g=d>3?e.length+1:d?p?1:2:0,b=kc[d+5],y=d>3&&(e[g-1]=[]),m=e[g]||(e[g]=[]),w=d&&(!h&&!p&&(s=s.prototype),d<5&&(d>3||!h)&&vh(d<4?s:{get[n](){return He(this,a)},set[n](v){return wt(this,a,v)}},n));d?h&&d<4&&nl(a,(d>2?"set ":d>1?"get ":"")+n):nl(s,n);for(var _=r.length-1;_>=0;_--)c=bh(d,n,l={},e[3],m),d&&(c.static=p,c.private=h,u=c.access={has:h?v=>wh(s,v):v=>n in v},d^3&&(u.get=h?v=>(d^1?He:_h)(v,s,d^4?a:w.get):v=>v[n]),d>2&&(u.set=h?(v,x)=>wt(v,s,x,d^4?a:w.set):(v,x)=>v[n]=x)),i=(0,r[_])(d?d<4?h?a:w[b]:d>4?void 0:{get:w.get,set:w.set}:s,c),l._=1,d^4||i===void 0?rr(i)&&(d>4?y.unshift(i):d?h?a=i:w[b]=i:s=i):typeof i!="object"||i===null?Nn("Object expected"):(rr(o=i.get)&&(w.get=o),rr(o=i.set)&&(w.set=o),rr(o=i.init)&&y.unshift(o));return d||vn(e,s),w&&uo(s,n,w),h?d^4?a:w:s},fo=(e,t,n)=>t.has(e)||Nn("Cannot "+n),wh=(e,t)=>Object(t)!==t?Nn('Cannot use the "in" operator on this value'):e.has(t),He=(e,t,n)=>(fo(e,t,"read from private field"),n?n.call(e):t.get(e)),we=(e,t,n)=>t.has(e)?Nn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),wt=(e,t,n,r)=>(fo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),_h=(e,t,n)=>(fo(e,t,"access private method"),n);function Sc(e,t){return{plugin:e,options:t}}function Gn(e){return t=>Sc(e,t)}function ho(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Ec,wr,po,ss;Ec=[ue];var lt=class{constructor(e,t){this.manager=e,this.options=t,we(this,po,J(wr,8,this,!1)),J(wr,11,this),we(this,ss,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return _e(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=Ct(e.bind(this));return He(this,ss).add(t),t}destroy(){He(this,ss).forEach(e=>e())}static configure(e){return Sc(this,e)}};wr=Xn(null);po=new WeakMap;ss=new WeakMap;ce(wr,4,"disabled",Ec,lt,po);vn(wr,lt);var Rr=class extends lt{},as,aa=class{constructor(e){this.manager=e,this.instances=new Map,we(this,as,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(ho).reduceRight((r,s)=>r.some(({plugin:a})=>a===s.plugin)?r:[s,...r],[]),n=t.map(({plugin:r})=>r);for(const r of He(this,as))if(!n.includes(r)){if(r.prototype instanceof Rr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);wt(this,as,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};as=new WeakMap;function xh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var qr=[],Mn,$n,Ch=class extends lt{constructor(e){super(e),we(this,Mn),we(this,$n),this.computeCollisions=this.computeCollisions.bind(this),wt(this,$n,Mr(qr)),this.destroy=$r(()=>{const t=this.computeCollisions(),n=_e(()=>this.manager.dragOperation.position.current);if(t!==qr){const r=He(this,Mn);if(wt(this,Mn,n),r&&n.x==r.x&&n.y==r.y)return}else wt(this,Mn,void 0);He(this,$n).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){_e(()=>{e?He(this,$n).value=this.computeCollisions():wt(this,Mn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:a,status:o}=r;if(!o.initialized||!a)return qr;const i=[],l=[];for(const c of e??n.droppables){if(c.disabled||s&&!c.accepts(s))continue;const u=t??c.collisionDetector;if(!u)continue;l.push(c),c.shape;const d=_e(()=>u({droppable:c,dragOperation:r}));d&&(c.collisionPriority!=null&&(d.priority=c.collisionPriority),i.push(d))}return l.length===0?qr:(i.sort(xh),i)}get collisions(){return He(this,$n).value}};Mn=new WeakMap;$n=new WeakMap;var kh=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const s of r)s(...t)}},Sh=class extends kh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function os(e,t=!0){let n=!1;return xc(_c({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Eh=class extends Rr{constructor(e){super(e);const t=(r,s)=>r.map(({id:a})=>a).join("")===s.map(({id:a})=>a).join("");let n=[];this.destroy=$r(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:a}=r;if(r.isDisabled())return;const o=os({collisions:a});if(s.dispatch("collision",o),o.defaultPrevented||t(a,n))return;n=a;const[i]=a;_e(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},mo=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(mo||{}),go=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(go||{}),Ic,Ac,Mc,$c,Tc,Dc,Rc,xt,vo;Rc=[ue],Dc=[Ae],Tc=[Ae],$c=[Ae],Mc=[Ae],Ac=[Ae],Ic=[Ae];var zt=class{constructor(){J(xt,5,this),we(this,vo,J(xt,8,this,"idle")),J(xt,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};xt=Xn(null);vo=new WeakMap;ce(xt,4,"value",Rc,zt,vo);ce(xt,2,"current",Dc,zt);ce(xt,2,"idle",Tc,zt);ce(xt,2,"initializing",$c,zt);ce(xt,2,"initialized",Mc,zt);ce(xt,2,"dragging",Ac,zt);ce(xt,2,"dropped",Ic,zt);vn(xt,zt);var Ih=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return _e(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=os({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return _e(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const r=new AbortController,{event:s,coordinates:a}=e;Kt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(a)});const o=os({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:i}=t;i.current==="initializing"&&(t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1}))}),r)})}move(e){return _e(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:a}=r;if(!s.dragging||!a||a.signal.aborted)return;const o=os({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var i,l,c,u,d;if(o.defaultPrevented)return;const p=(d=e.to)!=null?d:{x:r.position.current.x+((l=(i=e.by)==null?void 0:i.x)!=null?l:0),y:r.position.current.y+((u=(c=e.by)==null?void 0:c.y)!=null?u:0)};r.position.current=p})})}stop(e={}){return _e(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let a;const o=()=>{const l={resume:()=>{},abort:()=>{}};return a=new Promise((c,u)=>{l.resume=c,l.abort=u}),l};s.abort();const i=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=_e(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),c=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:u}=r,d=Ct(()=>{u?.status==="idle"&&(d(),c())})}else this.manager.renderer.rendering.then(c)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),a?a.then(i).catch(()=>r.reset()):i()})}},Pc,Wc,Fc,Oc,it,yo,bo,wo,_o;Oc=[ue],Fc=[ue],Wc=[ue],Pc=[ue];var Qt=class{constructor(e,t){we(this,yo,J(it,8,this)),J(it,11,this),we(this,bo,J(it,12,this)),J(it,15,this),we(this,wo,J(it,16,this)),J(it,19,this),we(this,_o,J(it,20,this)),J(it,23,this);const{effects:n,id:r,data:s={},disabled:a=!1,register:o=!0}=e;let i=r;this.manager=t,this.id=r,this.data=s,this.disabled=a,this.effects=()=>{var l;return[()=>{const{id:c,manager:u}=this;if(c!==i)return u?.registry.register(this),()=>u?.registry.unregister(this)},...(l=n?.())!=null?l:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),t&&o&&queueMicrotask(this.register)}register(){var e;return(e=this.manager)==null?void 0:e.registry.register(this)}unregister(){var e;(e=this.manager)==null||e.registry.unregister(this)}destroy(){var e;(e=this.manager)==null||e.registry.unregister(this)}};it=Xn(null);yo=new WeakMap;bo=new WeakMap;wo=new WeakMap;_o=new WeakMap;ce(it,4,"manager",Oc,Qt,yo);ce(it,4,"id",Fc,Qt,bo);ce(it,4,"data",Wc,Qt,wo);ce(it,4,"disabled",Pc,Qt,_o);vn(it,Qt);var rl=class{constructor(){this.map=Mr(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,t);if(r===t)return s;if(r){const i=this.cleanupFunctions.get(r);i?.(),this.cleanupFunctions.delete(r)}const a=new Map(n);a.set(e,t),this.map.value=a;const o=$r(...t.effects());return this.cleanupFunctions.set(t,o),s},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const s=new Map(n);s.delete(e),this.map.value=s}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Bc,Lc,Vc,zc,jc,Zc,$a,nt,xo,Co,ko,Dt=class extends($a=Qt,Zc=[ue],jc=[ue],zc=[ue],Vc=[Ae],Lc=[Ae],Bc=[Ae],$a){constructor(t,n){var r=t,{modifiers:s,type:a,sensors:o}=r,i=Cc(r,["modifiers","type","sensors"]);super(i,n),J(nt,5,this),we(this,xo,J(nt,8,this)),J(nt,11,this),we(this,Co,J(nt,12,this)),J(nt,15,this),we(this,ko,J(nt,16,this,this.isDragSource?"dragging":"idle")),J(nt,19,this),this.type=a,this.sensors=o,this.modifiers=s,this.alignment=i.alignment}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};nt=Xn($a);xo=new WeakMap;Co=new WeakMap;ko=new WeakMap;ce(nt,4,"type",Zc,Dt,xo);ce(nt,4,"modifiers",jc,Dt,Co);ce(nt,4,"status",zc,Dt,ko);ce(nt,2,"isDropping",Vc,Dt);ce(nt,2,"isDragging",Lc,Dt);ce(nt,2,"isDragSource",Bc,Dt);vn(nt,Dt);var Hc,Nc,Xc,Gc,Yc,Uc,Ta,Le,So,Eo,Io,Ao,Mo,Rt=class extends(Ta=Qt,Uc=[ue],Yc=[ue],Gc=[ue],Xc=[ue],Nc=[ue],Hc=[Ae],Ta){constructor(t,n){var r=t,{accept:s,collisionDetector:a,collisionPriority:o,type:i}=r,l=Cc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),J(Le,5,this),we(this,So,J(Le,8,this)),J(Le,11,this),we(this,Eo,J(Le,12,this)),J(Le,15,this),we(this,Io,J(Le,16,this)),J(Le,19,this),we(this,Ao,J(Le,20,this)),J(Le,23,this),we(this,Mo,J(Le,24,this)),J(Le,27,this),this.accept=s,this.collisionDetector=a,this.collisionPriority=o,this.type=i}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};Le=Xn(Ta);So=new WeakMap;Eo=new WeakMap;Io=new WeakMap;Ao=new WeakMap;Mo=new WeakMap;ce(Le,4,"accept",Uc,Rt,So);ce(Le,4,"type",Yc,Rt,Eo);ce(Le,4,"collisionDetector",Gc,Rt,Io);ce(Le,4,"collisionPriority",Xc,Rt,Ao);ce(Le,4,"shape",Nc,Rt,Mo);ce(Le,2,"isDropTarget",Hc,Rt);vn(Le,Rt);var On=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Ah=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},is,Kc=class{constructor(e){this.options=e,we(this,is)}set controller(e){wt(this,is,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=He(this,is))==null||t.activate(e)}};is=new WeakMap;var _r=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Mh=class{constructor(e){this.draggables=new rl,this.droppables=new rl,this.plugins=new aa(e),this.sensors=new aa(e),this.modifiers=new aa(e)}register(e,t){if(e instanceof Dt)return this.draggables.register(e.id,e);if(e instanceof Rt)return this.droppables.register(e.id,e);if(e.prototype instanceof _r)return this.modifiers.register(e,t);if(e.prototype instanceof On)return this.sensors.register(e,t);if(e.prototype instanceof lt)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Qt)return e instanceof Dt?this.draggables.unregister(e.id,e):e instanceof Rt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof _r)return this.modifiers.unregister(e);if(e.prototype instanceof On)return this.sensors.unregister(e);if(e.prototype instanceof lt)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},qc,Jc,Qc,eu,tu,nu,ru,su,au,sr,ls,Tn,Me,$o,To,Do,Ro,Po,ar;au=[Ae],su=[ue],ru=[ue],nu=[ue],tu=[ue],eu=[ue],Qc=[Ae],Jc=[Ae],qc=[Ae];var It=class{constructor(e){J(Me,5,this),we(this,sr),we(this,ls),we(this,Tn,new Jt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new zt,we(this,$o,J(Me,8,this,!1)),J(Me,11,this),we(this,To,J(Me,12,this,null)),J(Me,15,this),we(this,Do,J(Me,16,this,null)),J(Me,19,this),we(this,Ro,J(Me,20,this,null)),J(Me,23,this),we(this,Po,J(Me,24,this,[])),J(Me,27,this),this.position=new Ws({x:0,y:0}),we(this,ar,{x:0,y:0}),wt(this,sr,e)}get shape(){const{current:e,initial:t,previous:n}=He(this,Tn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?He(this,Tn).current=e:He(this,Tn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=He(this,sr).registry.draggables.get(t);return n&&wt(this,ls,n),(e=n??He(this,ls))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=He(this,sr).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(xc(_c({},this.snapshot()),{transform:n}));return wt(this,ar,n),n}snapshot(){return _e(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:He(this,ar),shape:this.shape?sa(this.shape):null,position:sa(this.position),status:sa(this.status),canceled:this.canceled}))}reset(){Kt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,He(this,Tn).reset(),this.position.reset({x:0,y:0}),wt(this,ar,{x:0,y:0}),this.modifiers=[]})}};Me=Xn(null);sr=new WeakMap;ls=new WeakMap;Tn=new WeakMap;$o=new WeakMap;To=new WeakMap;Do=new WeakMap;Ro=new WeakMap;Po=new WeakMap;ar=new WeakMap;ce(Me,2,"shape",au,It);ce(Me,4,"canceled",su,It,$o);ce(Me,4,"activatorEvent",ru,It,To);ce(Me,4,"sourceIdentifier",nu,It,Do);ce(Me,4,"targetIdentifier",tu,It,Ro);ce(Me,4,"modifiers",eu,It,Po);ce(Me,2,"source",Qc,It);ce(Me,2,"target",Jc,It);ce(Me,2,"transform",qc,It);vn(Me,It);var $h={get rendering(){return Promise.resolve()}};function Bt(e,t){return typeof e=="function"?e(t):e??t}var Th=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(p=>p.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=Bt(r.plugins,[]),a=Bt(r.sensors,[]),o=Bt(r.modifiers,[]),i=(n=r.renderer)!=null?n:$h,l=new Sh(this),c=new Mh(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new Ih(this),this.dragOperation=new It(this),this.collisionObserver=new Ch(this),this.plugins=[Eh,...s],this.modifiers=o,this.sensors=a;const{destroy:u}=this,d=$r(()=>{var p,h,g;const b=_e(()=>this.dragOperation.modifiers),y=this.modifiers;for(const m of b)y.includes(m)||m.destroy();this.dragOperation.modifiers=(g=(h=(p=this.dragOperation.source)==null?void 0:p.modifiers)==null?void 0:h.map(m=>{const{plugin:w,options:_}=ho(m);return new w(this,_)}))!=null?g:y});this.destroy=()=>{d(),u()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},ou=e=>{throw TypeError(e)},Wo=(e,t,n)=>t.has(e)||ou("Cannot "+n),te=(e,t,n)=>(Wo(e,t,"read from private field"),t.get(e)),ot=(e,t,n)=>t.has(e)?ou("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),pt=(e,t,n,r)=>(Wo(e,t,"write to private field"),t.set(e,n),n),iu=(e,t,n)=>(Wo(e,t,"access private method"),n);function Fs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Dh(e,t){const n=e.getAnimations();if(n.length>0)for(const r of n){if(r.playState!=="running")continue;const{effect:s}=r,o=(Fs(s)?s.getKeyframes():[]).filter(t);if(o.length>0)return[o[o.length-1],r]}return null}function Os(e){const{width:t,height:n,top:r,left:s,bottom:a,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:a,right:o}}function Fo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Pr(e){return"nodeType"in e}function kt(e){var t,n,r;return e?Fo(e)?e:Pr(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function Oo(e){const{Document:t}=kt(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function hn(e){return!e||Fo(e)?!1:e instanceof kt(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function lu(e){return e instanceof kt(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function yn(e){return e?Fo(e)?e.document:Pr(e)?Oo(e)?e:hn(e)||lu(e)?e.ownerDocument:document:document:document}function Rh(e){var t,n,r,s;const{documentElement:a}=yn(e),o=kt(e).visualViewport,i=(t=o?.width)!=null?t:a.clientWidth,l=(n=o?.height)!=null?n:a.clientHeight,c=(r=o?.offsetTop)!=null?r:0,u=(s=o?.offsetLeft)!=null?s:0;return{top:c,left:u,right:u+i,bottom:c+l,width:i,height:l}}function Ph(e,t){if(Wh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function Wh(e){return e.tagName==="DETAILS"}function ys(e,t=e.getBoundingClientRect(),n=0){var r,s,a,o,i;let l=t;const{ownerDocument:c}=e,u=(r=c.defaultView)!=null?r:window;let d=e.parentElement;for(;d&&d!==c.documentElement;){if(!Ph(d)){const _=d.getBoundingClientRect(),v=n*(_.bottom-_.top),x=n*(_.right-_.left),S=n*(_.bottom-_.top),k=n*(_.right-_.left);l={top:Math.max(l.top,_.top-v),right:Math.min(l.right,_.right+x),bottom:Math.min(l.bottom,_.bottom+S),left:Math.max(l.left,_.left-k),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}d=d.parentElement}const p=u.visualViewport,h=(s=p?.offsetTop)!=null?s:0,g=(a=p?.offsetLeft)!=null?a:0,b=(o=p?.width)!=null?o:u.innerWidth,y=(i=p?.height)!=null?i:u.innerHeight,m=n*y,w=n*b;return l={top:Math.max(l.top,h-m),right:Math.min(l.right,g+b+w),bottom:Math.min(l.bottom,h+y+m),left:Math.max(l.left,g-w),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function Bn(e){return{x:e.clientX,y:e.clientY}}var cu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Da(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const s=r.contentDocument;s&&!t.has(s)&&n.push(...Da(s,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const s=r.parent;s&&s.document&&s.document!==e&&n.push(...Da(s.document,t))}}catch{}return n}function Bo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function uu(){var e,t;const n=Bo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Lo(e){return!e||!Pr(e)?!1:e instanceof kt(e).ShadowRoot}function bs(e){if(e&&Pr(e)){let t=e.getRootNode();if(Lo(t))return t;if(t instanceof Document)return t}return yn(e)}function du(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Fh(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((a,o)=>{const i=r[o];if(sl(a)&&sl(i)&&(a.type!=="file"&&(a.value=i.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),al(a)&&al(i)&&i.width>0&&i.height>0){const l=a.getContext("2d");l?.drawImage(i,0,0)}}),n}function sl(e){return"value"in e}function al(e){return e.tagName==="CANVAS"}function fu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Oh(r)){const{contentDocument:s}=r;if(s){const{left:a,top:o}=r.getBoundingClientRect();return fu(s,{x:t-a,y:n-o})}}return r}function Oh(e){return e?.tagName==="IFRAME"}var ol=new WeakMap;function Bh(e){return!!e.closest(`
|
|
1
|
+
"use strict";var If=Object.create;var Yi=Object.defineProperty;var Mf=Object.getOwnPropertyDescriptor;var Af=Object.getOwnPropertyNames;var Tf=Object.getPrototypeOf,$f=Object.prototype.hasOwnProperty;var Rf=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Af(t))!$f.call(e,s)&&s!==n&&Yi(e,s,{get:()=>t[s],enumerable:!(r=Mf(t,s))||r.enumerable});return e};var Df=(e,t,n)=>(n=e!=null?If(Tf(e)):{},Rf(t||!e||!e.__esModule?Yi(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("tone"),C=require("react/jsx-runtime"),g=require("react"),P=require("styled-components"),da=require("react-dom");function Kl(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 ql=Kl(F),D=Kl(g);var oo={exports:{}},Ki;function Pf(){return Ki||(Ki=1,(function(e,t){(function(n,r){e.exports=r()})(window,(function(){return(function(n){var r={};function s(o){if(r[o])return r[o].exports;var a=r[o]={i:o,l:!1,exports:{}};return n[o].call(a.exports,a,a.exports,s),a.l=!0,a.exports}return s.m=n,s.c=r,s.d=function(o,a,i){s.o(o,a)||Object.defineProperty(o,a,{enumerable:!0,get:i})},s.r=function(o){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},s.t=function(o,a){if(1&a&&(o=s(o)),8&a||4&a&&typeof o=="object"&&o&&o.__esModule)return o;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:o}),2&a&&typeof o!="string")for(var l in o)s.d(i,l,(function(c){return o[c]}).bind(null,l));return i},s.n=function(o){var a=o&&o.__esModule?function(){return o.default}:function(){return o};return s.d(a,"a",a),a},s.o=function(o,a){return Object.prototype.hasOwnProperty.call(o,a)},s.p="",s(s.s="./src/index.ts")})({"./src/chunk.ts":function(n,r,s){s.r(r),s.d(r,"SF2Chunk",(function(){return d}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=s("./src/chunks/index.ts");function l(p){return(l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(v){return typeof v}:function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v})(p)}function c(p,v){for(var y=0;y<v.length;y++){var m=v[y];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(p,m.key,m)}}function u(p){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)})(p)}function f(p,v){return(f=Object.setPrototypeOf||function(y,m){return y.__proto__=m,y})(p,v)}function h(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}var d=(function(p){function v(b){var _,w,x,S,k,E;return(function(T,I){if(!(T instanceof I))throw new TypeError("Cannot call a class as a function")})(this,v),w=this,_=!(x=u(v).call(this,b.id,b.length,b.buffer,b.subChunks))||l(x)!=="object"&&typeof x!="function"?h(w):x,S=h(h(_)),E=void 0,(k="subChunks")in S?Object.defineProperty(S,k,{value:E,enumerable:!0,configurable:!0,writable:!0}):S[k]=E,_.subChunks=b.subChunks.map((function(T){return new v(T)})),_}var y,m;return(function(b,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(_&&_.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),_&&f(b,_)})(v,p),y=v,(m=[{key:"getMetaData",value:function(){if(this.id!=="LIST")throw new o.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks.reduce((function(_,w){if(w.id==="ifil"||w.id==="iver"){if(w.length!==a.SF_VERSION_LENGTH)throw new o.ParseError("Invalid size for the '".concat(w.id,"' sub-chunk"));_[w.id]="".concat(w.getInt16(),".").concat(w.getInt16(2))}else _[w.id]=w.getString();return _}),{});if(!b.ifil)throw new o.ParseError("Missing required 'ifil' sub-chunk");if(!b.INAM)throw new o.ParseError("Missing required 'INAM' sub-chunk");return{version:b.ifil,soundEngine:b.isng||"EMU8000",name:b.INAM,rom:b.irom,romVersion:b.iver,creationDate:b.ICRD,author:b.IENG,product:b.IPRD,copyright:b.ICOP,comments:b.ICMT,createdBy:b.ISFT}}},{key:"getSampleData",value:function(){if(this.id!=="LIST")throw new o.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks[0];if(b.id!=="smpl")throw new o.ParseError("Invalid chunk signature","'smpl'","'".concat(b.id,"'"));return b.buffer}},{key:"getPresetData",value:function(){if(this.id!=="LIST")throw new o.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));return{presetHeaders:Object(i.getPresetHeaders)(this.subChunks[0]),presetZones:Object(i.getZones)(this.subChunks[1],"pbag"),presetModulators:Object(i.getModulators)(this.subChunks[2],"pmod"),presetGenerators:Object(i.getGenerators)(this.subChunks[3],"pgen"),instrumentHeaders:Object(i.getInstrumentHeaders)(this.subChunks[4]),instrumentZones:Object(i.getZones)(this.subChunks[5],"ibag"),instrumentModulators:Object(i.getModulators)(this.subChunks[6],"imod"),instrumentGenerators:Object(i.getGenerators)(this.subChunks[7],"igen"),sampleHeaders:Object(i.getSampleHeaders)(this.subChunks[8])}}}])&&c(y.prototype,m),v})(o.RIFFChunk)},"./src/chunks/generators.ts":function(n,r,s){s.r(r),s.d(r,"getGenerators",(function(){return f}));var o=s("./src/riff/index.ts"),a=s("./src/types/index.ts"),i=s("./src/constants.ts"),l=[a.GeneratorType.StartAddrsOffset,a.GeneratorType.EndAddrsOffset,a.GeneratorType.StartLoopAddrsOffset,a.GeneratorType.EndLoopAddrsOffset,a.GeneratorType.StartAddrsCoarseOffset,a.GeneratorType.EndAddrsCoarseOffset,a.GeneratorType.StartLoopAddrsCoarseOffset,a.GeneratorType.KeyNum,a.GeneratorType.Velocity,a.GeneratorType.EndLoopAddrsCoarseOffset,a.GeneratorType.SampleModes,a.GeneratorType.ExclusiveClass,a.GeneratorType.OverridingRootKey],c=[a.GeneratorType.Unused1,a.GeneratorType.Unused2,a.GeneratorType.Unused3,a.GeneratorType.Unused4,a.GeneratorType.Reserved1,a.GeneratorType.Reserved2,a.GeneratorType.Reserved3],u=[a.GeneratorType.KeyRange,a.GeneratorType.VelRange],f=function(h,d){if(h.id!==d)throw new o.ParseError("Unexpected chunk ID","'".concat(d,"'"),"'".concat(h.id,"'"));if(h.length%i.SF_GENERATOR_SIZE)throw new o.ParseError("Invalid size for the '".concat(d,"' sub-chunk"));return h.iterate((function(p){var v=p.getInt16();return a.GeneratorType[v]?d==="pgen"&&l.includes(v)||d==="igen"&&c.includes(v)?null:u.includes(v)?{id:v,range:{lo:p.getByte(),hi:p.getByte()}}:{id:v,value:p.getInt16BE()}:null}))}},"./src/chunks/index.ts":function(n,r,s){s.r(r);var o=s("./src/chunks/instruments/index.ts");s.d(r,"getInstrumentHeaders",(function(){return o.getInstrumentHeaders}));var a=s("./src/chunks/presets/index.ts");s.d(r,"getPresetHeaders",(function(){return a.getPresetHeaders}));var i=s("./src/chunks/samples/index.ts");s.d(r,"getSampleHeaders",(function(){return i.getSampleHeaders}));var l=s("./src/chunks/generators.ts");s.d(r,"getGenerators",(function(){return l.getGenerators}));var c=s("./src/chunks/modulators.ts");s.d(r,"getModulators",(function(){return c.getModulators}));var u=s("./src/chunks/zones.ts");s.d(r,"getZones",(function(){return u.getZones})),s.d(r,"getItemsInZone",(function(){return u.getItemsInZone}))},"./src/chunks/instruments/headers.ts":function(n,r,s){s.r(r),s.d(r,"getInstrumentHeaders",(function(){return i}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=function(l){if(l.id!=="inst")throw new o.ParseError("Unexpected chunk ID","'inst'","'".concat(l.id,"'"));if(l.length%a.SF_INSTRUMENT_HEADER_SIZE)throw new o.ParseError("Invalid size for the 'inst' sub-chunk");return l.iterate((function(c){return{name:c.getString(),bagIndex:c.getInt16()}}))}},"./src/chunks/instruments/index.ts":function(n,r,s){s.r(r);var o=s("./src/chunks/instruments/headers.ts");s.d(r,"getInstrumentHeaders",(function(){return o.getInstrumentHeaders}))},"./src/chunks/modulators.ts":function(n,r,s){s.r(r),s.d(r,"getModulators",(function(){return l}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=function(c){return{type:c>>10&63,polarity:c>>9&1,direction:c>>8&1,palette:c>>7&1,index:127&c}},l=function(c,u){if(c.id!==u)throw new o.ParseError("Unexpected chunk ID","'".concat(u,"'"),"'".concat(c.id,"'"));if(c.length%a.SF_MODULATOR_SIZE)throw new o.ParseError("Invalid size for the '".concat(u,"' sub-chunk"));return c.iterate((function(f){return{source:i(f.getInt16BE()),id:f.getInt16BE(),value:f.getInt16BE(),valueSource:i(f.getInt16BE()),transform:f.getInt16BE()}}))}},"./src/chunks/presets/headers.ts":function(n,r,s){s.r(r),s.d(r,"getPresetHeaders",(function(){return i}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=function(l){if(l.id!=="phdr")throw new o.ParseError("Invalid chunk ID","'phdr'","'".concat(l.id,"'"));if(l.length%a.SF_PRESET_HEADER_SIZE)throw new o.ParseError("Invalid size for the 'phdr' sub-chunk");return l.iterate((function(c){return{name:c.getString(),preset:c.getInt16(),bank:c.getInt16(),bagIndex:c.getInt16(),library:c.getUInt32(),genre:c.getUInt32(),morphology:c.getUInt32()}}))}},"./src/chunks/presets/index.ts":function(n,r,s){s.r(r);var o=s("./src/chunks/presets/headers.ts");s.d(r,"getPresetHeaders",(function(){return o.getPresetHeaders}))},"./src/chunks/samples/headers.ts":function(n,r,s){s.r(r),s.d(r,"getSampleHeaders",(function(){return i}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=function(l){if(l.id!=="shdr")throw new o.ParseError("Unexpected chunk ID","'shdr'","'".concat(l.id,"'"));if(l.length%a.SF_SAMPLE_HEADER_SIZE)throw new o.ParseError("Invalid size for the 'shdr' sub-chunk");return l.iterate((function(c){return{name:c.getString(),start:c.getUInt32(),end:c.getUInt32(),startLoop:c.getUInt32(),endLoop:c.getUInt32(),sampleRate:c.getUInt32(),originalPitch:c.getByte(),pitchCorrection:c.getChar(),link:c.getInt16(),type:c.getInt16()}}))}},"./src/chunks/samples/index.ts":function(n,r,s){s.r(r);var o=s("./src/chunks/samples/headers.ts");s.d(r,"getSampleHeaders",(function(){return o.getSampleHeaders}))},"./src/chunks/zones.ts":function(n,r,s){s.r(r),s.d(r,"getZones",(function(){return l})),s.d(r,"getItemsInZone",(function(){return c}));var o=s("./src/riff/index.ts"),a=s("./src/constants.ts"),i=s("./src/types/index.ts"),l=function(d,p){if(d.id!==p)throw new o.ParseError("Unexpected chunk ID","'".concat(p,"'"),"'".concat(d.id,"'"));if(d.length%a.SF_BAG_SIZE)throw new o.ParseError("Invalid size for the '".concat(p,"' sub-chunk"));return d.iterate((function(v){return{generatorIndex:v.getInt16(),modulatorIndex:v.getInt16()}}))},c=function(d,p,v,y,m,b){for(var _=[],w=0;w<d.length;w++){for(var x=d[w],S=d[w+1],k=x.bagIndex,E=S?S.bagIndex:p.length,T=[],I=void 0,M=k;M<E;M++){var $=u(M,p,v),A=f(M,p,y),R=A[i.GeneratorType.KeyRange]&&A[i.GeneratorType.KeyRange].range,W=A[b];if(W){var q=m[W.value];q&&T.push({keyRange:R,modulators:$,generators:A,reference:q})}else M-k==0&&(I={keyRange:R,modulators:$,generators:A})}_.push({header:x,globalZone:I,zones:T})}return _},u=function(d,p,v){var y=p[d],m=p[d+1],b=y.modulatorIndex,_=m?m.modulatorIndex:p.length;return h(b,_,v)},f=function(d,p,v){var y=p[d],m=p[d+1],b=y.generatorIndex,_=m?m.generatorIndex:p.length;return h(b,_,v)},h=function(d,p,v){for(var y={},m=d;m<p;m++){var b=v[m];b&&(y[b.id]=b)}return y}},"./src/constants.ts":function(n,r,s){s.r(r),s.d(r,"SF_VERSION_LENGTH",(function(){return o})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return a})),s.d(r,"SF_BAG_SIZE",(function(){return i})),s.d(r,"SF_MODULATOR_SIZE",(function(){return l})),s.d(r,"SF_GENERATOR_SIZE",(function(){return c})),s.d(r,"SF_INSTRUMENT_HEADER_SIZE",(function(){return u})),s.d(r,"SF_SAMPLE_HEADER_SIZE",(function(){return f})),s.d(r,"DEFAULT_SAMPLE_RATE",(function(){return h}));var o=4,a=38,i=4,l=10,c=4,u=22,f=46,h=22050},"./src/index.ts":function(n,r,s){s.r(r);var o=s("./src/types/index.ts");for(var a in o)["default"].indexOf(a)<0&&(function(u){s.d(r,u,(function(){return o[u]}))})(a);var i=s("./src/chunk.ts");s.d(r,"SF2Chunk",(function(){return i.SF2Chunk}));var l=s("./src/constants.ts");s.d(r,"SF_VERSION_LENGTH",(function(){return l.SF_VERSION_LENGTH})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return l.SF_PRESET_HEADER_SIZE})),s.d(r,"SF_BAG_SIZE",(function(){return l.SF_BAG_SIZE})),s.d(r,"SF_MODULATOR_SIZE",(function(){return l.SF_MODULATOR_SIZE})),s.d(r,"SF_GENERATOR_SIZE",(function(){return l.SF_GENERATOR_SIZE})),s.d(r,"SF_INSTRUMENT_HEADER_SIZE",(function(){return l.SF_INSTRUMENT_HEADER_SIZE})),s.d(r,"SF_SAMPLE_HEADER_SIZE",(function(){return l.SF_SAMPLE_HEADER_SIZE})),s.d(r,"DEFAULT_SAMPLE_RATE",(function(){return l.DEFAULT_SAMPLE_RATE}));var c=s("./src/soundFont2.ts");s.d(r,"SoundFont2",(function(){return c.SoundFont2}))},"./src/riff/chunkIterator.ts":function(n,r,s){s.r(r),s.d(r,"ChunkIterator",(function(){return c}));var o=s("./src/utils/index.ts");function a(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function i(u,f){for(var h=0;h<f.length;h++){var d=f[h];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,h){return f in u?Object.defineProperty(u,f,{value:h,enumerable:!0,configurable:!0,writable:!0}):u[f]=h,u}var c=(function(){function u(d){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;a(this,u),l(this,"target",[]),l(this,"chunk",void 0),l(this,"position",0),this.chunk=d,this.position=p}var f,h;return f=u,(h=[{key:"iterate",value:function(d){for(;this.position<this.chunk.length;){var p=d(this);p&&this.target.push(p)}}},{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,p=Object(o.getStringFromBuffer)(this.getBuffer(this.position,d));return this.position+=d,p}},{key:"getInt16",value:function(){return this.chunk.buffer[this.position++]|this.chunk.buffer[this.position++]<<8}},{key:"getInt16BE",value:function(){return this.getInt16()<<16>>16}},{key:"getUInt32",value:function(){return(this.chunk.buffer[this.position++]|this.chunk.buffer[this.position++]<<8|this.chunk.buffer[this.position++]<<16|this.chunk.buffer[this.position++]<<24)>>>0}},{key:"getByte",value:function(){return this.chunk.buffer[this.position++]}},{key:"getChar",value:function(){return this.chunk.buffer[this.position++]<<24>>24}},{key:"skip",value:function(d){this.position+=d}},{key:"getBuffer",value:function(d,p){return this.chunk.buffer.subarray(d,d+p)}},{key:"currentPosition",get:function(){return this.position}}])&&i(f.prototype,h),u})()},"./src/riff/index.ts":function(n,r,s){s.r(r);var o=s("./src/riff/chunkIterator.ts");s.d(r,"ChunkIterator",(function(){return o.ChunkIterator}));var a=s("./src/riff/parseError.ts");s.d(r,"ParseError",(function(){return a.ParseError}));var i=s("./src/riff/parser.ts");s.d(r,"parseBuffer",(function(){return i.parseBuffer})),s.d(r,"getChunk",(function(){return i.getChunk})),s.d(r,"getChunkLength",(function(){return i.getChunkLength})),s.d(r,"getSubChunks",(function(){return i.getSubChunks})),s.d(r,"getChunkId",(function(){return i.getChunkId}));var l=s("./src/riff/riffChunk.ts");s.d(r,"RIFFChunk",(function(){return l.RIFFChunk}))},"./src/riff/parseError.ts":function(n,r,s){function o(d){return(o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p})(d)}function a(d,p){return!p||o(p)!=="object"&&typeof p!="function"?(function(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v})(d):p}function i(d){var p=typeof Map=="function"?new Map:void 0;return(i=function(v){if(v===null||(y=v,Function.toString.call(y).indexOf("[native code]")===-1))return v;var y;if(typeof v!="function")throw new TypeError("Super expression must either be null or a function");if(p!==void 0){if(p.has(v))return p.get(v);p.set(v,m)}function m(){return c(v,arguments,f(this).constructor)}return m.prototype=Object.create(v.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),u(m,v)})(d)}function l(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch{return!1}}function c(d,p,v){return(c=l()?Reflect.construct:function(y,m,b){var _=[null];_.push.apply(_,m);var w=new(Function.bind.apply(y,_));return b&&u(w,b.prototype),w}).apply(null,arguments)}function u(d,p){return(u=Object.setPrototypeOf||function(v,y){return v.__proto__=y,v})(d,p)}function f(d){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)})(d)}s.r(r),s.d(r,"ParseError",(function(){return h}));var h=(function(d){function p(v,y,m){return(function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,p),a(this,f(p).call(this,"".concat(v).concat(y&&m?", expected ".concat(y,", received ").concat(m):"")))}return(function(v,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(y&&y.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),y&&u(v,y)})(p,d),p})(i(Error))},"./src/riff/parser.ts":function(n,r,s){s.r(r),s.d(r,"parseBuffer",(function(){return l})),s.d(r,"getChunk",(function(){return c})),s.d(r,"getChunkLength",(function(){return u})),s.d(r,"getSubChunks",(function(){return f})),s.d(r,"getChunkId",(function(){return h}));var o=s("./src/riff/parseError.ts"),a=s("./src/utils/buffer.ts"),i=s("./src/riff/riffChunk.ts"),l=function(d){var p=h(d);if(p!=="RIFF")throw new o.ParseError("Invalid file format","RIFF",p);var v=h(d,8);if(v!=="sfbk")throw new o.ParseError("Invalid signature","sfbk",v);var y=d.subarray(8),m=f(y.subarray(4));return new i.RIFFChunk(p,y.length,y,m)},c=function(d,p){var v=h(d,p),y=u(d,p+4),m=[];return v!=="RIFF"&&v!=="LIST"||(m=f(d.subarray(p+12))),new i.RIFFChunk(v,y,d.subarray(p+8),m)},u=function(d,p){return((d=d.subarray(p,p+4))[0]|d[1]<<8|d[2]<<16|d[3]<<24)>>>0},f=function(d){for(var p=[],v=0;v<=d.length-8;){var y=c(d,v);p.push(y),v=(v+=8+y.length)%2?v+1:v}return p},h=function(d){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return Object(a.getStringFromBuffer)(d.subarray(p,p+4))}},"./src/riff/riffChunk.ts":function(n,r,s){s.r(r),s.d(r,"RIFFChunk",(function(){return c}));var o=s("./src/riff/chunkIterator.ts"),a=s("./src/utils/index.ts");function i(u,f){for(var h=0;h<f.length;h++){var d=f[h];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,h){return f in u?Object.defineProperty(u,f,{value:h,enumerable:!0,configurable:!0,writable:!0}):u[f]=h,u}var c=(function(){function u(d,p,v,y){(function(m,b){if(!(m instanceof b))throw new TypeError("Cannot call a class as a function")})(this,u),l(this,"id",void 0),l(this,"length",void 0),l(this,"buffer",void 0),l(this,"subChunks",void 0),this.id=d,this.length=p,this.buffer=v,this.subChunks=y}var f,h;return f=u,(h=[{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,p=arguments.length>1?arguments[1]:void 0;return Object(a.getStringFromBuffer)(this.getBuffer(d,p||this.length-d))}},{key:"getInt16",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d++]|this.buffer[d]<<8}},{key:"getUInt32",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return(this.buffer[d++]|this.buffer[d++]<<8|this.buffer[d++]<<16|this.buffer[d]<<24)>>>0}},{key:"getByte",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d]}},{key:"getChar",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d]<<24>>24}},{key:"iterator",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new o.ChunkIterator(this,d)}},{key:"iterate",value:function(d){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,v=new o.ChunkIterator(this,p);return v.iterate(d),v.target}},{key:"getBuffer",value:function(d,p){return this.buffer.subarray(d,d+p)}}])&&i(f.prototype,h),u})()},"./src/soundFont2.ts":function(n,r,s){s.r(r),s.d(r,"SoundFont2",(function(){return p}));var o=s("./src/types/index.ts"),a=s("./src/chunk.ts"),i=s("./src/riff/index.ts"),l=s("./src/chunks/index.ts"),c=s("./src/utils/index.ts");function u(v){for(var y=1;y<arguments.length;y++){var m=arguments[y]!=null?arguments[y]:{},b=Object.keys(m);typeof Object.getOwnPropertySymbols=="function"&&(b=b.concat(Object.getOwnPropertySymbols(m).filter((function(_){return Object.getOwnPropertyDescriptor(m,_).enumerable})))),b.forEach((function(_){d(v,_,m[_])}))}return v}function f(v,y){for(var m=0;m<y.length;m++){var b=y[m];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function h(v,y,m){return y&&f(v.prototype,y),m&&f(v,m),v}function d(v,y,m){return y in v?Object.defineProperty(v,y,{value:m,enumerable:!0,configurable:!0,writable:!0}):v[y]=m,v}var p=(function(){function v(y){if((function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),d(this,"chunk",void 0),d(this,"metaData",void 0),d(this,"sampleData",void 0),d(this,"samples",void 0),d(this,"presetData",void 0),d(this,"instruments",void 0),d(this,"presets",void 0),d(this,"banks",void 0),!(y instanceof a.SF2Chunk)){var m=Object(i.parseBuffer)(y);y=new a.SF2Chunk(m)}if(y.subChunks.length!==3)throw new i.ParseError("Invalid sfbk structure","3 chunks","".concat(y.subChunks.length," chunks"));this.chunk=y,this.metaData=y.subChunks[0].getMetaData(),this.sampleData=y.subChunks[1].getSampleData(),this.presetData=y.subChunks[2].getPresetData(),this.samples=this.getSamples(),this.instruments=this.getInstruments(),this.presets=this.getPresets(),this.banks=this.getBanks()}return h(v,null,[{key:"from",value:function(y){return new v(y)}}]),h(v,[{key:"getKeyData",value:function(y){var m=this,b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,_=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return Object(c.memoize)((function(w,x,S){var k=m.banks[x];if(k){var E=k.presets[S];if(E){var T=E.zones.filter((function(N){return m.isKeyInRange(N,w)}));if(T.length>0){var I=!0,M=!1,$=void 0;try{for(var A,R=T[Symbol.iterator]();!(I=(A=R.next()).done);I=!0){var W=A.value,q=W.instrument,z=q.zones.filter((function(N){return m.isKeyInRange(N,w)}));if(z.length>0){var J=!0,ee=!1,j=void 0;try{for(var se,U=z[Symbol.iterator]();!(J=(se=U.next()).done);J=!0){var ie=se.value,le=ie.sample,ge=u({},W.generators,ie.generators),Se=u({},W.modulators,ie.modulators);return{keyNumber:w,preset:E,instrument:q,sample:le,generators:ge,modulators:Se}}}catch(N){ee=!0,j=N}finally{try{J||U.return==null||U.return()}finally{if(ee)throw j}}}}}catch(N){M=!0,$=N}finally{try{I||R.return==null||R.return()}finally{if(M)throw $}}}}}return null}))(y,b,_)}},{key:"isKeyInRange",value:function(y,m){return y.keyRange===void 0||y.keyRange.lo<=m&&y.keyRange.hi>=m}},{key:"getBanks",value:function(){return this.presets.reduce((function(y,m){var b=m.header.bank;return y[b]||(y[b]={presets:[]}),y[b].presets[m.header.preset]=m,y}),[])}},{key:"getPresets",value:function(){var y=this.presetData,m=y.presetHeaders,b=y.presetZones,_=y.presetGenerators,w=y.presetModulators;return Object(l.getItemsInZone)(m,b,w,_,this.instruments,o.GeneratorType.Instrument).filter((function(x){return x.header.name!=="EOP"})).map((function(x){return{header:x.header,globalZone:x.globalZone,zones:x.zones.map((function(S){return{keyRange:S.keyRange,generators:S.generators,modulators:S.modulators,instrument:S.reference}}))}}))}},{key:"getInstruments",value:function(){var y=this.presetData,m=y.instrumentHeaders,b=y.instrumentZones,_=y.instrumentModulators,w=y.instrumentGenerators;return Object(l.getItemsInZone)(m,b,_,w,this.samples,o.GeneratorType.SampleId).filter((function(x){return x.header.name!=="EOI"})).map((function(x){return{header:x.header,globalZone:x.globalZone,zones:x.zones.map((function(S){return{keyRange:S.keyRange,generators:S.generators,modulators:S.modulators,sample:S.reference}}))}}))}},{key:"getSamples",value:function(){var y=this;return this.presetData.sampleHeaders.filter((function(m){return m.name!=="EOS"})).map((function(m){if(m.name!=="EOS"&&m.sampleRate<=0)throw new Error("Illegal sample rate of ".concat(m.sampleRate," hz in sample '").concat(m.name,"'"));return m.originalPitch>=128&&m.originalPitch<=254&&(m.originalPitch=60),m.startLoop-=m.start,m.endLoop-=m.start,{header:m,data:new Int16Array(new Uint8Array(y.sampleData.subarray(2*m.start,2*m.end)).buffer)}}))}}]),v})()},"./src/types/bank.ts":function(n,r){},"./src/types/generator.ts":function(n,r,s){var o,a;function i(c,u,f){return u in c?Object.defineProperty(c,u,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[u]=f,c}s.r(r),s.d(r,"GeneratorType",(function(){return a})),s.d(r,"DEFAULT_GENERATOR_VALUES",(function(){return l})),(function(c){c[c.StartAddrsOffset=0]="StartAddrsOffset",c[c.EndAddrsOffset=1]="EndAddrsOffset",c[c.StartLoopAddrsOffset=2]="StartLoopAddrsOffset",c[c.EndLoopAddrsOffset=3]="EndLoopAddrsOffset",c[c.StartAddrsCoarseOffset=4]="StartAddrsCoarseOffset",c[c.ModLFOToPitch=5]="ModLFOToPitch",c[c.VibLFOToPitch=6]="VibLFOToPitch",c[c.ModEnvToPitch=7]="ModEnvToPitch",c[c.InitialFilterFc=8]="InitialFilterFc",c[c.InitialFilterQ=9]="InitialFilterQ",c[c.ModLFOToFilterFc=10]="ModLFOToFilterFc",c[c.ModEnvToFilterFc=11]="ModEnvToFilterFc",c[c.EndAddrsCoarseOffset=12]="EndAddrsCoarseOffset",c[c.ModLFOToVolume=13]="ModLFOToVolume",c[c.Unused1=14]="Unused1",c[c.ChorusEffectsSend=15]="ChorusEffectsSend",c[c.ReverbEffectsSend=16]="ReverbEffectsSend",c[c.Pan=17]="Pan",c[c.Unused2=18]="Unused2",c[c.Unused3=19]="Unused3",c[c.Unused4=20]="Unused4",c[c.DelayModLFO=21]="DelayModLFO",c[c.FreqModLFO=22]="FreqModLFO",c[c.DelayVibLFO=23]="DelayVibLFO",c[c.FreqVibLFO=24]="FreqVibLFO",c[c.DelayModEnv=25]="DelayModEnv",c[c.AttackModEnv=26]="AttackModEnv",c[c.HoldModEnv=27]="HoldModEnv",c[c.DecayModEnv=28]="DecayModEnv",c[c.SustainModEnv=29]="SustainModEnv",c[c.ReleaseModEnv=30]="ReleaseModEnv",c[c.KeyNumToModEnvHold=31]="KeyNumToModEnvHold",c[c.KeyNumToModEnvDecay=32]="KeyNumToModEnvDecay",c[c.DelayVolEnv=33]="DelayVolEnv",c[c.AttackVolEnv=34]="AttackVolEnv",c[c.HoldVolEnv=35]="HoldVolEnv",c[c.DecayVolEnv=36]="DecayVolEnv",c[c.SustainVolEnv=37]="SustainVolEnv",c[c.ReleaseVolEnv=38]="ReleaseVolEnv",c[c.KeyNumToVolEnvHold=39]="KeyNumToVolEnvHold",c[c.KeyNumToVolEnvDecay=40]="KeyNumToVolEnvDecay",c[c.Instrument=41]="Instrument",c[c.Reserved1=42]="Reserved1",c[c.KeyRange=43]="KeyRange",c[c.VelRange=44]="VelRange",c[c.StartLoopAddrsCoarseOffset=45]="StartLoopAddrsCoarseOffset",c[c.KeyNum=46]="KeyNum",c[c.Velocity=47]="Velocity",c[c.InitialAttenuation=48]="InitialAttenuation",c[c.Reserved2=49]="Reserved2",c[c.EndLoopAddrsCoarseOffset=50]="EndLoopAddrsCoarseOffset",c[c.CoarseTune=51]="CoarseTune",c[c.FineTune=52]="FineTune",c[c.SampleId=53]="SampleId",c[c.SampleModes=54]="SampleModes",c[c.Reserved3=55]="Reserved3",c[c.ScaleTuning=56]="ScaleTuning",c[c.ExclusiveClass=57]="ExclusiveClass",c[c.OverridingRootKey=58]="OverridingRootKey",c[c.Unused5=59]="Unused5",c[c.EndOper=60]="EndOper"})(a||(a={}));var l=(i(o={},a.StartAddrsOffset,0),i(o,a.EndAddrsOffset,0),i(o,a.StartLoopAddrsOffset,0),i(o,a.EndLoopAddrsOffset,0),i(o,a.StartAddrsCoarseOffset,0),i(o,a.ModLFOToPitch,0),i(o,a.VibLFOToPitch,0),i(o,a.ModEnvToPitch,0),i(o,a.InitialFilterFc,13500),i(o,a.InitialFilterQ,0),i(o,a.ModLFOToFilterFc,0),i(o,a.ModEnvToFilterFc,0),i(o,a.EndAddrsCoarseOffset,0),i(o,a.ModLFOToVolume,0),i(o,a.ChorusEffectsSend,0),i(o,a.ReverbEffectsSend,0),i(o,a.Pan,0),i(o,a.DelayModLFO,-12e3),i(o,a.FreqModLFO,0),i(o,a.DelayVibLFO,-12e3),i(o,a.FreqVibLFO,0),i(o,a.DelayModEnv,-12e3),i(o,a.AttackModEnv,-12e3),i(o,a.HoldModEnv,-12e3),i(o,a.DecayModEnv,-12e3),i(o,a.SustainModEnv,0),i(o,a.ReleaseModEnv,-12e3),i(o,a.KeyNumToModEnvHold,0),i(o,a.KeyNumToModEnvDecay,0),i(o,a.DelayVolEnv,-12e3),i(o,a.AttackVolEnv,-12e3),i(o,a.HoldVolEnv,-12e3),i(o,a.DecayVolEnv,-12e3),i(o,a.SustainVolEnv,0),i(o,a.ReleaseVolEnv,-12e3),i(o,a.KeyNumToVolEnvHold,0),i(o,a.KeyNumToVolEnvDecay,0),i(o,a.StartLoopAddrsCoarseOffset,0),i(o,a.KeyNum,-1),i(o,a.Velocity,-1),i(o,a.InitialAttenuation,0),i(o,a.EndLoopAddrsCoarseOffset,0),i(o,a.CoarseTune,0),i(o,a.FineTune,0),i(o,a.SampleModes,0),i(o,a.ScaleTuning,100),i(o,a.ExclusiveClass,0),i(o,a.OverridingRootKey,-1),o)},"./src/types/index.ts":function(n,r,s){s.r(r);var o=s("./src/types/bank.ts");for(var a in o)["default"].indexOf(a)<0&&(function(y){s.d(r,y,(function(){return o[y]}))})(a);var i=s("./src/types/generator.ts");s.d(r,"GeneratorType",(function(){return i.GeneratorType})),s.d(r,"DEFAULT_GENERATOR_VALUES",(function(){return i.DEFAULT_GENERATOR_VALUES}));var l=s("./src/types/instrument.ts");for(var a in l)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(a)<0&&(function(m){s.d(r,m,(function(){return l[m]}))})(a);var c=s("./src/types/key.ts");for(var a in c)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(a)<0&&(function(m){s.d(r,m,(function(){return c[m]}))})(a);var u=s("./src/types/metaData.ts");for(var a in u)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(a)<0&&(function(m){s.d(r,m,(function(){return u[m]}))})(a);var f=s("./src/types/modulator.ts");s.d(r,"ControllerType",(function(){return f.ControllerType})),s.d(r,"ControllerPolarity",(function(){return f.ControllerPolarity})),s.d(r,"ControllerDirection",(function(){return f.ControllerDirection})),s.d(r,"ControllerPalette",(function(){return f.ControllerPalette})),s.d(r,"Controller",(function(){return f.Controller})),s.d(r,"TransformType",(function(){return f.TransformType})),s.d(r,"DEFAULT_INSTRUMENT_MODULATORS",(function(){return f.DEFAULT_INSTRUMENT_MODULATORS}));var h=s("./src/types/preset.ts");for(var a in h)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(a)<0&&(function(m){s.d(r,m,(function(){return h[m]}))})(a);var d=s("./src/types/presetData.ts");for(var a in d)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(a)<0&&(function(m){s.d(r,m,(function(){return d[m]}))})(a);var p=s("./src/types/sample.ts");s.d(r,"SampleType",(function(){return p.SampleType}));var v=s("./src/types/zone.ts");for(var a in v)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS","SampleType"].indexOf(a)<0&&(function(m){s.d(r,m,(function(){return v[m]}))})(a)},"./src/types/instrument.ts":function(n,r){},"./src/types/key.ts":function(n,r){},"./src/types/metaData.ts":function(n,r){},"./src/types/modulator.ts":function(n,r,s){s.r(r),s.d(r,"ControllerType",(function(){return o})),s.d(r,"ControllerPolarity",(function(){return a})),s.d(r,"ControllerDirection",(function(){return i})),s.d(r,"ControllerPalette",(function(){return l})),s.d(r,"Controller",(function(){return c})),s.d(r,"TransformType",(function(){return u})),s.d(r,"DEFAULT_INSTRUMENT_MODULATORS",(function(){return h}));var o,a,i,l,c,u,f=s("./src/types/generator.ts");(function(d){d[d.Linear=0]="Linear",d[d.Concave=1]="Concave",d[d.Convex=2]="Convex",d[d.Switch=3]="Switch"})(o||(o={})),(function(d){d[d.Unipolar=0]="Unipolar",d[d.Bipolar=1]="Bipolar"})(a||(a={})),(function(d){d[d.Increasing=0]="Increasing",d[d.Decreasing=1]="Decreasing"})(i||(i={})),(function(d){d[d.GeneralController=0]="GeneralController",d[d.MidiController=1]="MidiController"})(l||(l={})),(function(d){d[d.NoController=0]="NoController",d[d.NoteOnVelocity=2]="NoteOnVelocity",d[d.NoteOnKeyNumber=3]="NoteOnKeyNumber",d[d.PolyPressure=10]="PolyPressure",d[d.ChannelPressure=13]="ChannelPressure",d[d.PitchWheel=14]="PitchWheel",d[d.PitchWheelSensitivity=16]="PitchWheelSensitivity",d[d.Link=127]="Link"})(c||(c={})),(function(d){d[d.Linear=0]="Linear",d[d.Absolute=2]="Absolute"})(u||(u={}));var h=[{id:f.GeneratorType.InitialAttenuation,source:{type:o.Concave,polarity:a.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:960,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialFilterFc,source:{type:o.Linear,polarity:a.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:-2400,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.ChannelPressure},value:50,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.MidiController,index:1},value:50,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:o.Concave,polarity:a.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:7},value:960,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:o.Linear,polarity:a.Bipolar,direction:i.Increasing,palette:l.MidiController,index:10},value:1e3,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:o.Concave,polarity:a.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:11},value:960,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ReverbEffectsSend,source:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.MidiController,index:91},value:200,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ChorusEffectsSend,source:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.MidiController,index:93},value:200,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.CoarseTune,source:{type:o.Linear,polarity:a.Bipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheel},value:12700,valueSource:{type:o.Linear,polarity:a.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheelSensitivity},transform:u.Linear}]},"./src/types/preset.ts":function(n,r){},"./src/types/presetData.ts":function(n,r){},"./src/types/sample.ts":function(n,r,s){var o;s.r(r),s.d(r,"SampleType",(function(){return o})),(function(a){a[a.EOS=0]="EOS",a[a.Mono=1]="Mono",a[a.Right=2]="Right",a[a.Left=4]="Left",a[a.Linked=8]="Linked",a[a.RomMono=32769]="RomMono",a[a.RomRight=32770]="RomRight",a[a.RomLeft=32772]="RomLeft",a[a.RomLinked=32776]="RomLinked"})(o||(o={}))},"./src/types/zone.ts":function(n,r){},"./src/utils/buffer.ts":function(n,r,s){s.r(r),s.d(r,"getStringFromBuffer",(function(){return o}));var o=function(a){var i=new TextDecoder("utf8").decode(a),l=i.indexOf("\0");return(l===-1?i:i.slice(0,l)).trim()}},"./src/utils/index.ts":function(n,r,s){s.r(r);var o=s("./src/utils/buffer.ts");s.d(r,"getStringFromBuffer",(function(){return o.getStringFromBuffer}));var a=s("./src/utils/memoize.ts");s.d(r,"memoize",(function(){return a.memoize}))},"./src/utils/memoize.ts":function(n,r,s){s.r(r),s.d(r,"memoize",(function(){return o}));var o=function(a){var i={};return function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var f=JSON.stringify(c);if(f in i)return i[f];var h=a.apply(void 0,c);return i[f]=h,h}}}})}))})(oo)),oo.exports}Pf();var Le=1e3;function Co(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:s=1,name:o,color:a,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:h}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate,p=t?.length??e.sourceDurationSamples??(c&&d?Math.ceil(c.duration*d):void 0);if(d===void 0)throw new Error("createClip: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");if(p===void 0)throw new Error("createClip: sourceDurationSamples is required when audioBuffer is not provided (can use waveformData.duration)");t&&c&&t.sampleRate!==c.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${c.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const v=e.durationSamples??p;return{id:ec(),audioBuffer:t,startSample:n,durationSamples:v,offsetSamples:r,sampleRate:d,sourceDurationSamples:p,gain:s,name:o,color:a,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:h}}function Jl(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:s=1,name:o,color:a,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:h}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate;if(d===void 0)throw new Error("createClipFromSeconds: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");const p=t?.duration??e.sourceDuration??c?.duration;if(p===void 0)throw new Error("createClipFromSeconds: sourceDuration is required when audioBuffer is not provided (can use waveformData.duration)");t&&c&&t.sampleRate!==c.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${c.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const v=e.duration??p;return Co({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(v*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(p*d),gain:s,name:o,color:a,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:h})}function Ql(e){const{name:t,clips:n=[],muted:r=!1,soloed:s=!1,volume:o=1,pan:a=0,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}=e;return{id:ec(),name:t,clips:n,muted:r,soloed:s,volume:o,pan:a,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}}function ec(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function qi(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function Yr(e){return e.startSample/e.sampleRate}function Ji(e){return(e.startSample+e.durationSamples)/e.sampleRate}function Qi(e){return e.offsetSamples/e.sampleRate}function el(e){return e.durationSamples/e.sampleRate}var tl=!1;function wr(e){const t=e._param;return!t&&!tl&&(tl=!0,console.warn("[waveform-playlist] Unable to access Tone.js internal _param. This likely means the Tone.js version is incompatible. Mute scheduling may not work correctly.")),t}function nl(e,t){const n=new Float32Array(e),r=e-1;for(let s=0;s<e;s++){const o=s/r;n[s]=t?o:1-o}return n}function Ff(e,t){const n=new Float32Array(e),r=e-1;for(let s=0;s<e;s++){const o=s/r,a=t?s:e-1-s;n[a]=Math.exp(2*o-1)/Math.E}return n}function Of(e,t){const n=new Float32Array(e),r=t?Math.PI/2:-Math.PI/2;for(let s=0;s<e;s++)n[s]=Math.sin(Math.PI*s/e-r)/2+.5;return n}function Lf(e,t,n=10){const r=new Float32Array(e);for(let s=0;s<e;s++){const o=t?s:e-1-s,a=s/e;r[o]=Math.log(1+n*a)/Math.log(1+n)}return r}function tc(e,t,n){switch(e){case"linear":return nl(t,n);case"exponential":return Ff(t,n);case"sCurve":return Of(t,n);case"logarithmic":return Lf(t,n);default:return nl(t,n)}}function rl(e,t,n,r="linear",s=0,o=1){if(!(n<=0))if(r==="linear")e.setValueAtTime(s,t),e.linearRampToValueAtTime(o,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(s,.001),t),e.exponentialRampToValueAtTime(Math.max(o,.001),t+n);else{const a=tc(r,1e4,!0),i=new Float32Array(a.length),l=o-s;for(let c=0;c<a.length;c++)i[c]=s+a[c]*l;e.setValueCurveAtTime(i,t,n)}}function sl(e,t,n,r="linear",s=1,o=0){if(!(n<=0))if(r==="linear")e.setValueAtTime(s,t),e.linearRampToValueAtTime(o,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(s,.001),t),e.exponentialRampToValueAtTime(Math.max(o,.001),t+n);else{const a=tc(r,1e4,!1),i=new Float32Array(a.length),l=s-o;for(let c=0;c<a.length;c++)i[c]=o+a[c]*l;e.setValueCurveAtTime(i,t,n)}}var Wf=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=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),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||F.getDestination();if(e.effects){const a=e.effects(this.muteGain,t,!1);a&&(this.effectsCleanup=a)}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}]:[]),r=F.getTransport(),s=F.getContext().rawContext,o=this.volumeNode.input.input;this.scheduledClips=n.map(a=>{const i=s.createGain();i.gain.value=a.gain,i.connect(o);const l=this.track.startTime+a.startTime,c=r.schedule(u=>{l<this._scheduleGuardOffset||this.startClipSource(a,i,u)},l);return{clipInfo:a,fadeGainNode:i,scheduleId:c}})}startClipSource(e,t,n,r,s){const a=F.getContext().rawContext.createBufferSource();a.buffer=e.buffer,a.connect(t);const i=r??e.offset,l=s??e.duration;try{a.start(n,i,l)}catch(c){console.warn(`[waveform-playlist] Failed to start source on track "${this.id}" (time=${n}, offset=${i}, duration=${l}):`,c),a.disconnect();return}this.activeSources.add(a),a.onended=()=>{this.activeSources.delete(a)}}setScheduleGuardOffset(e){this._scheduleGuardOffset=e}startMidClipSources(e,t){for(const{clipInfo:n,fadeGainNode:r}of this.scheduledClips){const s=this.track.startTime+n.startTime,o=s+n.duration;if(s<e&&o>e){const a=e-s,i=n.offset+a,l=n.duration-a;this.startClipSource(n,r,t,i,l)}}}stopAllSources(){this.activeSources.forEach(e=>{try{e.stop()}catch(t){console.warn(`[waveform-playlist] Error stopping source on track "${this.id}":`,t)}}),this.activeSources.clear()}scheduleFades(e,t,n=0){const{clipInfo:r,fadeGainNode:s}=e,o=s.gain;o.cancelScheduledValues(0);const a=n-r.offset;if(r.fadeIn&&a<r.fadeIn.duration){const i=r.fadeIn.duration;if(a<=0)rl(o,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-a,c=a/i,u=r.gain*c;rl(o,t,l,r.fadeIn.type||"linear",u,r.gain)}}else o.setValueAtTime(r.gain,t);if(r.fadeOut){const l=r.duration-r.fadeOut.duration-a;if(l>0){const c=t+l;sl(o,c,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const c=-l,u=r.fadeOut.duration-c,f=c/r.fadeOut.duration,h=r.gain*(1-f);sl(o,t,u,r.fadeOut.type||"linear",h,0)}}}prepareFades(e,t){this.scheduledClips.forEach(n=>{const r=this.track.startTime+n.clipInfo.startTime,s=r+n.clipInfo.duration;if(!(t>=s))if(t>=r){const o=t-r+n.clipInfo.offset;this.scheduleFades(n,e,o)}else{const o=r-t;this.scheduleFades(n,e+o,n.clipInfo.offset)}})}cancelFades(){this.scheduledClips.forEach(({fadeGainNode:e,clipInfo:t})=>{const n=e.gain;n.cancelScheduledValues(0),n.setValueAtTime(t.gain,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;const t=e?0:1;wr(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=F.getTransport();if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach((t,n)=>{try{e.clear(t.scheduleId)}catch(r){console.warn(`[waveform-playlist] Error clearing schedule ${n} on track "${this.id}":`,r)}try{t.fadeGainNode.disconnect()}catch(r){console.warn(`[waveform-playlist] Error disconnecting fadeGain ${n} on track "${this.id}":`,r)}});try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const e=this.scheduledClips[this.scheduledClips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get buffer(){return this.scheduledClips[0]?.clipInfo.buffer}get muted(){return this.track.muted}get startTime(){return this.track.startTime}};function Bf(e){return e===35||e===36?"kick":e>=37&&e<=40?"snare":e===41||e===43||e===45||e===47||e===48||e===50?"tom":"cymbal"}var Vf=class{constructor(e){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),this.volumeNode.chain(this.panNode,this.muteGain),this.synth=new F.PolySynth(F.Synth,e.synthOptions),this.synth.connect(this.volumeNode),this.kickSynth=new F.PolySynth(F.MembraneSynth,{voice:F.MembraneSynth,options:{pitchDecay:.05,octaves:6,envelope:{attack:.001,decay:.4,sustain:0,release:.1}}}),this.snareSynth=new F.NoiseSynth({noise:{type:"white"},envelope:{attack:.001,decay:.15,sustain:0,release:.05}}),this.cymbalSynth=new F.PolySynth(F.MetalSynth,{voice:F.MetalSynth,options:{envelope:{attack:.001,decay:.3,release:.1},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5}}),this.tomSynth=new F.PolySynth(F.MembraneSynth,{voice:F.MembraneSynth,options:{pitchDecay:.08,octaves:4,envelope:{attack:.001,decay:.3,sustain:0,release:.1}}}),this.kickSynth.connect(this.volumeNode),this.snareSynth.connect(this.volumeNode),this.cymbalSynth.connect(this.volumeNode),this.tomSynth.connect(this.volumeNode);const t=e.destination||F.getDestination();if(e.effects){const n=e.effects(this.muteGain,t,!1);n&&(this.effectsCleanup=n)}else this.muteGain.connect(t);this.scheduledClips=e.clips.map(n=>{const r=n.notes.filter(i=>{const l=i.time+i.duration;return i.time<n.offset+n.duration&&l>n.offset}),s=this.track.startTime+n.startTime,o=r.map(i=>{const l=i.time-n.offset,c=Math.max(0,l),u=Math.min(i.duration-Math.max(0,n.offset-i.time),n.duration-c);return{time:s+c,note:i.name,midi:i.midi,duration:Math.max(0,u),velocity:i.velocity,channel:i.channel}}),a=new F.Part((i,l)=>{l.duration>0&&this.triggerNote(l.midi,l.note,l.duration,i,l.velocity,l.channel)},o);return a.start(0),{clipInfo:n,part:a}})}triggerNote(e,t,n,r,s,o){if(o===9)switch(Bf(e)){case"kick":this.kickSynth.triggerAttackRelease("C1",n,r,s);break;case"snare":try{this.snareSynth.triggerAttackRelease(n,r,s)}catch(i){console.warn("[waveform-playlist] Snare overlap — previous hit still decaying, skipped:",i)}break;case"tom":{const i={41:"G1",43:"A1",45:"C2",47:"D2",48:"E2",50:"G2"};this.tomSynth.triggerAttackRelease(i[e]||"C2",n,r,s);break}case"cymbal":this.cymbalSynth.triggerAttackRelease("C4",n,r,s);break}else this.synth.triggerAttackRelease(t,n,r,s)}gainToDb(e){return 20*Math.log10(e)}setScheduleGuardOffset(e){}startMidClipSources(e,t){for(const{clipInfo:n}of this.scheduledClips){const r=this.track.startTime+n.startTime,s=r+n.duration;if(r<e&&s>e)for(const o of n.notes){const a=o.time-n.offset,i=r+Math.max(0,a),l=i+o.duration;if(i<e&&l>e){const c=l-e;try{this.triggerNote(o.midi,o.name,c,t,o.velocity,o.channel)}catch(u){console.warn(`[waveform-playlist] Failed to start mid-clip MIDI note "${o.name}" on track "${this.id}":`,u)}}}}}stopAllSources(){const e=F.getContext().rawContext.currentTime;try{this.synth.releaseAll(e),this.kickSynth.releaseAll(e),this.cymbalSynth.releaseAll(e),this.tomSynth.releaseAll(e)}catch(t){console.warn(`[waveform-playlist] Error releasing synth on track "${this.id}":`,t)}}prepareFades(e,t){}cancelFades(){}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;const t=e?0:1;wr(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during MIDI track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach(({part:t},n)=>{try{t.dispose()}catch(r){console.warn(`[waveform-playlist] Error disposing Part ${n} on MIDI track "${this.id}":`,r)}});const e=[this.synth,this.kickSynth,this.snareSynth,this.cymbalSynth,this.tomSynth];for(const t of e)try{t?.dispose()}catch(n){console.warn(`[waveform-playlist] Error disposing synth on MIDI track "${this.id}":`,n)}try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on MIDI track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on MIDI track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on MIDI track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const e=this.scheduledClips[this.scheduledClips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get muted(){return this.track.muted}get startTime(){return this.track.startTime}},nc=class So{constructor(t){this.activeSources=new Set,this.track=t.track,this.soundFontCache=t.soundFontCache,this.programNumber=t.programNumber??0,this.bankNumber=t.isPercussion?128:0,this.volumeNode=new F.Volume(this.gainToDb(t.track.gain)),this.panNode=new F.Panner(t.track.stereoPan),this.muteGain=new F.Gain(t.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const n=t.destination||F.getDestination();if(t.effects){const r=t.effects(this.muteGain,n,!1);r&&(this.effectsCleanup=r)}else this.muteGain.connect(n);this.scheduledClips=t.clips.map(r=>{const s=r.notes.filter(l=>{const c=l.time+l.duration;return l.time<r.offset+r.duration&&c>r.offset}),o=this.track.startTime+r.startTime,a=s.map(l=>{const c=l.time-r.offset,u=Math.max(0,c),f=Math.min(l.duration-Math.max(0,r.offset-l.time),r.duration-u);return{time:o+u,note:l.name,midi:l.midi,duration:Math.max(0,f),velocity:l.velocity,channel:l.channel}}),i=new F.Part((l,c)=>{c.duration>0&&this.triggerNote(c.midi,c.duration,l,c.velocity,c.channel)},a);return i.start(0),{clipInfo:r,part:i}})}triggerNote(t,n,r,s,o){const a=o===9?128:this.bankNumber,i=o===9?0:this.programNumber,l=this.soundFontCache.getAudioBuffer(t,a,i);if(!l){So._missingSampleWarned||(console.warn(`[waveform-playlist] SoundFont sample not found for MIDI note ${t} (bank ${a}, preset ${i}). Subsequent missing samples will be silent.`),So._missingSampleWarned=!0);return}const c=F.getContext().rawContext,u=c.createBufferSource();u.buffer=l.buffer,u.playbackRate.value=l.playbackRate,(l.loopMode===1||l.loopMode===3)&&(u.loop=!0,u.loopStart=l.loopStart,u.loopEnd=l.loopEnd);const f=l.buffer.duration/l.playbackRate,h=l.loopMode===0?Math.max(n,f):n,d=s*s,p=c.createGain(),{attackVolEnv:v,holdVolEnv:y,decayVolEnv:m,sustainVolEnv:b,releaseVolEnv:_}=l,w=d*b;p.gain.setValueAtTime(0,r),p.gain.linearRampToValueAtTime(d,r+v),y>.001&&p.gain.setValueAtTime(d,r+v+y);const x=r+v+y;p.gain.linearRampToValueAtTime(w,x+m),p.gain.setValueAtTime(w,r+h),p.gain.linearRampToValueAtTime(0,r+h+_),u.connect(p),p.connect(this.volumeNode.input.input),this.activeSources.add(u),u.onended=()=>{this.activeSources.delete(u);try{p.disconnect()}catch(S){console.warn("[waveform-playlist] GainNode already disconnected:",S)}},u.start(r),u.stop(r+h+_)}gainToDb(t){return 20*Math.log10(t)}setScheduleGuardOffset(t){}startMidClipSources(t,n){for(const{clipInfo:r}of this.scheduledClips){const s=this.track.startTime+r.startTime,o=s+r.duration;if(s<t&&o>t)for(const a of r.notes){const i=a.time-r.offset,l=s+Math.max(0,i),c=l+a.duration;if(l<t&&c>t){const u=c-t;try{this.triggerNote(a.midi,u,n,a.velocity,a.channel)}catch(f){console.warn(`[waveform-playlist] Failed to start mid-clip SoundFont note on track "${this.id}":`,f)}}}}}stopAllSources(){for(const t of this.activeSources)try{t.stop()}catch(n){console.warn("[waveform-playlist] Error stopping AudioBufferSourceNode:",n)}this.activeSources.clear()}prepareFades(t,n){}cancelFades(){}setVolume(t){this.track.gain=t,this.volumeNode.volume.value=this.gainToDb(t)}setPan(t){this.track.stereoPan=t,this.panNode.pan.value=t}setMute(t){this.track.muted=t;const n=t?0:1;wr(this.muteGain.gain)?.setValueAtTime(n,0),this.muteGain.gain.value=n}setSolo(t){this.track.soloed=t}dispose(){if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during SoundFont track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach(({part:t},n)=>{try{t.dispose()}catch(r){console.warn(`[waveform-playlist] Error disposing Part ${n} on SoundFont track "${this.id}":`,r)}});try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on SoundFont track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on SoundFont track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on SoundFont track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const t=this.scheduledClips[this.scheduledClips.length-1];return t.clipInfo.startTime+t.clipInfo.duration}get muted(){return this.track.muted}get startTime(){return this.track.startTime}};nc._missingSampleWarned=!1;var Nf=nc,zf=class{constructor(e={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this._completionEventId=null,this._loopHandler=null,this._loopEnabled=!1,this._loopStart=0,this._loopEnd=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)}clearCompletionEvent(){if(this._completionEventId!==null){try{F.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await F.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new Wf(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}addMidiTrack(e){const t={...e,destination:this.masterVolume},n=new Vf(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}addSoundFontTrack(e){const t={...e,destination:this.masterVolume},n=new Nf(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)throw new Error("[waveform-playlist] TonePlayout not initialized. Call init() first.");const r=e??F.now(),s=F.getTransport();this.clearCompletionEvent();const o=t??0;this.tracks.forEach(a=>{a.cancelFades(),a.prepareFades(r,o)}),n!==void 0&&(this._completionEventId=s.scheduleOnce(()=>{this._completionEventId=null;try{this.onPlaybackCompleteCallback?.()}catch(a){console.warn("[waveform-playlist] Error in playback completion callback:",a)}},o+n));try{s.state!=="stopped"&&s.stop(),this.tracks.forEach(a=>a.stopAllSources()),s.loopStart=this._loopStart,s.loopEnd=this._loopEnd,s.loop=this._loopEnabled,this.tracks.forEach(a=>a.setScheduleGuardOffset(o)),t!==void 0?s.start(r,t):s.start(r),s._clock._lastUpdate=r,this.tracks.forEach(a=>{a.startMidClipSources(o,r)})}catch(a){throw this.clearCompletionEvent(),this.tracks.forEach(i=>i.cancelFades()),console.warn("[waveform-playlist] Transport.start() failed. Audio playback could not begin.",a),a}}pause(){const e=F.getTransport();try{e.pause()}catch(t){console.warn("[waveform-playlist] Transport.pause() failed:",t)}this.tracks.forEach(t=>t.stopAllSources()),this.tracks.forEach(t=>t.cancelFades()),this.clearCompletionEvent()}stop(){const e=F.getTransport();try{e.stop()}catch(t){console.warn("[waveform-playlist] Transport.stop() failed:",t)}if(this._loopHandler){try{e.off("loop",this._loopHandler)}catch(t){console.warn("[waveform-playlist] Error removing loop handler:",t)}this._loopHandler=null}this.tracks.forEach(t=>t.stopAllSources()),this.tracks.forEach(t=>t.cancelFades()),this.clearCompletionEvent()}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))}setLoop(e,t,n){this._loopEnabled=e,this._loopStart=t,this._loopEnd=n;const r=F.getTransport();try{r.loopStart=t,r.loopEnd=n,r.loop=e}catch(s){console.warn("[waveform-playlist] Error configuring Transport loop:",s);return}e&&!this._loopHandler?(this._loopHandler=()=>{const s=F.now();this.tracks.forEach(o=>{try{o.stopAllSources(),o.cancelFades(),o.setScheduleGuardOffset(this._loopStart),o.startMidClipSources(this._loopStart,s),o.prepareFades(s,this._loopStart)}catch(a){console.warn(`[waveform-playlist] Error re-scheduling track "${o.id}" on loop:`,a)}})},r.on("loop",this._loopHandler)):!e&&this._loopHandler&&(r.off("loop",this._loopHandler),this._loopHandler=null)}getCurrentTime(){return F.getTransport().seconds}seekTo(e){F.getTransport().seconds=e}dispose(){if(this.clearCompletionEvent(),this._loopHandler){try{F.getTransport().off("loop",this._loopHandler)}catch(e){console.warn("[waveform-playlist] Error removing Transport loop handler:",e)}this._loopHandler=null}if(this.tracks.forEach(e=>{try{e.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing track "${e.id}":`,t)}}),this.tracks.clear(),this.effectsCleanup)try{this.effectsCleanup()}catch(e){console.warn("[waveform-playlist] Error during master effects cleanup:",e)}try{this.masterVolume.dispose()}catch(e){console.warn("[waveform-playlist] Error disposing master volume:",e)}}get context(){return F.getContext()}get sampleRate(){return F.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Kr=null;function jf(){return Kr||(Kr=new F.Context,F.setContext(Kr)),Kr}function Zf(){return jf().rawContext}function Hf(e){let t=null,n=!1,r=0,s=!1,o=0,a=0,i=!1;function l(c){if(t){try{t.dispose()}catch(f){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",f)}t=null}r++;const u=r;t=new zf({effects:e?.effects}),i&&t.init().catch(f=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",f),i=!1});for(const f of c){const h=f.clips.filter(p=>p.audioBuffer&&!p.midiNotes),d=f.clips.filter(p=>p.midiNotes&&p.midiNotes.length>0);if(h.length>0){const p=Math.min(...h.map(Yr)),v=Math.max(...h.map(Ji)),y={id:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:p,endTime:v},m=h.map(b=>({buffer:b.audioBuffer,startTime:Yr(b)-p,duration:el(b),offset:Qi(b),fadeIn:b.fadeIn,fadeOut:b.fadeOut,gain:b.gain}));t.addTrack({clips:m,track:y,effects:f.effects})}if(d.length>0){const p=Math.min(...d.map(Yr)),v=Math.max(...d.map(Ji)),m={id:h.length>0?`${f.id}:midi`:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:p,endTime:v},b=d.map(_=>({notes:_.midiNotes,startTime:Yr(_)-p,duration:el(_),offset:Qi(_)}));if(e?.soundFontCache?.isLoaded){const _=d[0],x=_.midiChannel===9,S=_.midiProgram??0;t.addSoundFontTrack({clips:b,track:m,soundFontCache:e.soundFontCache,programNumber:S,isPercussion:x,effects:f.effects})}else e?.soundFontCache&&console.warn(`[waveform-playlist] SoundFont not loaded for track "${f.name}" — falling back to PolySynth.`),t.addMidiTrack({clips:b,track:m,effects:f.effects})}}t.applyInitialSoloState(),t.setLoop(s,o,a),t.setOnPlaybackComplete(()=>{u===r&&(n=!1)})}return{async init(){t&&(await t.init(),i=!0)},setTracks(c){l(c)},play(c,u){if(!t){console.warn("[waveform-playlist] adapter.play() called but no playout is available. Tracks may not have been set, or the adapter was disposed.");return}const f=u!==void 0?u-c:void 0;t.play(F.now(),c,f),n=!0},pause(){t?.pause(),n=!1},stop(){t?.stop(),n=!1},seek(c){t?.seekTo(c)},getCurrentTime(){return t?.getCurrentTime()??0},isPlaying(){return n},setMasterVolume(c){t?.setMasterGain(c)},setTrackVolume(c,u){t?.getTrack(c)?.setVolume(u)},setTrackMute(c,u){t?.setMute(c,u)},setTrackSolo(c,u){t?.setSolo(c,u)},setTrackPan(c,u){t?.getTrack(c)?.setPan(u)},setLoop(c,u,f){s=c,o=u,a=f,t?.setLoop(c,u,f)},dispose(){try{t?.dispose()}catch(c){console.warn("[waveform-playlist] Error disposing playout:",c)}t=null,n=!1}}}function rc(e,t,n,r){let s=t;const o=-e.startSample;if(s=Math.max(s,o),r>0){const a=n[r-1],l=a.startSample+a.durationSamples-e.startSample;s=Math.max(s,l)}if(r<n.length-1){const i=n[r+1].startSample-(e.startSample+e.durationSamples);s=Math.min(s,i)}return s}function ko(e,t,n,r,s,o){let a=t;if(n==="left"){if(a=Math.max(a,-e.startSample),a=Math.max(a,-e.offsetSamples),s>0){const i=r[s-1],l=i.startSample+i.durationSamples;a=Math.max(a,l-e.startSample)}a=Math.min(a,e.durationSamples-o)}else if(a=Math.max(a,o-e.durationSamples),a=Math.min(a,e.sourceDurationSamples-e.offsetSamples-e.durationSamples),s<r.length-1){const i=r[s+1];a=Math.min(a,i.startSample-e.startSample-e.durationSamples)}return a}function Gf(e,t){return Math.floor(e/t)*t}function Uf(e,t){const n=t-e.startSample,r=e.durationSamples-n,s=e.name?`${e.name} (1)`:void 0,o=e.name?`${e.name} (2)`:void 0,a=Co({startSample:e.startSample,durationSamples:n,offsetSamples:e.offsetSamples,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:s,color:e.color,fadeIn:e.fadeIn,audioBuffer:e.audioBuffer,waveformData:e.waveformData}),i=Co({startSample:t,durationSamples:r,offsetSamples:e.offsetSamples+n,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:o,color:e.color,fadeOut:e.fadeOut,audioBuffer:e.audioBuffer,waveformData:e.waveformData});return{left:a,right:i}}function sc(e,t,n){const r=e.startSample+e.durationSamples;if(t<=e.startSample||t>=r)return!1;const s=t-e.startSample,o=r-t;return s>=n&&o>=n}function ao(e){let t=0;for(const n of e)for(const r of n.clips){const o=(r.startSample+r.durationSamples)/r.sampleRate;t=Math.max(t,o)}return t}function Xf(e,t){if(t.length===0)return 0;let n=0,r=Math.abs(t[0]-e);for(let s=1;s<t.length;s++){const o=Math.abs(t[s]-e);o<r&&(r=o,n=s)}return n}function ol(e,t){return Math.max(0,Math.min(e,t))}var Yf=44100,Kf=1024,qf=[256,512,1024,2048,4096,8192],al=.1,Jf=class{constructor(e={}){if(this._tracks=[],this._currentTime=0,this._playStartPosition=0,this._isPlaying=!1,this._selectedTrackId=null,this._selectionStart=0,this._selectionEnd=0,this._masterVolume=1,this._loopStart=0,this._loopEnd=0,this._isLoopEnabled=!1,this._tracksVersion=0,this._animFrameId=null,this._disposed=!1,this._listeners=new Map,this._sampleRate=e.sampleRate??Yf,this._zoomLevels=[...e.zoomLevels??qf],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??Kf,n=this._zoomLevels.indexOf(t);if(n===-1)throw new Error(`PlaylistEngine: samplesPerPixel ${t} is not in zoomLevels [${this._zoomLevels.join(", ")}]. Either pass a samplesPerPixel value that exists in zoomLevels, or include ${t} in your zoomLevels array.`);this._zoomIndex=n}getState(){return{tracks:this._tracks.map(e=>({...e,clips:[...e.clips]})),tracksVersion:this._tracksVersion,duration:ao(this._tracks),currentTime:this._currentTime,isPlaying:this._isPlaying,samplesPerPixel:this._zoomLevels[this._zoomIndex],sampleRate:this._sampleRate,selectedTrackId:this._selectedTrackId,zoomIndex:this._zoomIndex,canZoomIn:this._zoomIndex>0,canZoomOut:this._zoomIndex<this._zoomLevels.length-1,selectionStart:this._selectionStart,selectionEnd:this._selectionEnd,masterVolume:this._masterVolume,loopStart:this._loopStart,loopEnd:this._loopEnd,isLoopEnabled:this._isLoopEnabled}}setTracks(e){this._tracks=[...e],this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}addTrack(e){this._tracks=[...this._tracks,e],this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}removeTrack(e){this._tracks.some(t=>t.id===e)&&(this._tracks=this._tracks.filter(t=>t.id!==e),this._tracksVersion++,this._selectedTrackId===e&&(this._selectedTrackId=null),this._adapter?.setTracks(this._tracks),this._emitStateChange())}selectTrack(e){e!==this._selectedTrackId&&(this._selectedTrackId=e,this._emitStateChange())}moveClip(e,t,n){const r=this._tracks.find(c=>c.id===e);if(!r){console.warn(`[waveform-playlist/engine] moveClip: track "${e}" not found`);return}const s=r.clips.findIndex(c=>c.id===t);if(s===-1){console.warn(`[waveform-playlist/engine] moveClip: clip "${t}" not found in track "${e}"`);return}const o=r.clips[s],a=qi(r.clips),i=a.findIndex(c=>c.id===t),l=rc(o,n,a,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=c.clips.map((f,h)=>h===s?{...f,startSample:Math.floor(f.startSample+l)}:f);return{...c,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}splitClip(e,t,n){const r=this._tracks.find(c=>c.id===e);if(!r){console.warn(`[waveform-playlist/engine] splitClip: track "${e}" not found`);return}const s=r.clips.findIndex(c=>c.id===t);if(s===-1){console.warn(`[waveform-playlist/engine] splitClip: clip "${t}" not found in track "${e}"`);return}const o=r.clips[s],a=Math.floor(al*this._sampleRate);if(!sc(o,n,a)){console.warn(`[waveform-playlist/engine] splitClip: cannot split clip "${t}" at sample ${n} (clip range: ${o.startSample}–${o.startSample+o.durationSamples}, minDuration: ${a})`);return}const{left:i,right:l}=Uf(o,n);this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=[...c.clips];return u.splice(s,1,i,l),{...c,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}trimClip(e,t,n,r){const s=this._tracks.find(f=>f.id===e);if(!s){console.warn(`[waveform-playlist/engine] trimClip: track "${e}" not found`);return}const o=s.clips.findIndex(f=>f.id===t);if(o===-1){console.warn(`[waveform-playlist/engine] trimClip: clip "${t}" not found in track "${e}"`);return}const a=s.clips[o],i=qi(s.clips),l=i.findIndex(f=>f.id===t),c=Math.floor(al*this._sampleRate),u=ko(a,r,n,i,l,c);u!==0&&(this._tracks=this._tracks.map(f=>{if(f.id!==e)return f;const h=f.clips.map((d,p)=>p!==o?d:n==="left"?{...d,startSample:d.startSample+u,offsetSamples:d.offsetSamples+u,durationSamples:d.durationSamples-u}:{...d,durationSamples:d.durationSamples+u});return{...f,clips:h}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}async init(){this._adapter&&await this._adapter.init()}play(e,t){const n=this._currentTime,r=this._playStartPosition;if(e!==void 0){const s=ao(this._tracks);this._currentTime=ol(e,s)}if(this._playStartPosition=this._currentTime,this._adapter){if(t!==void 0)this._adapter.setLoop(!1,this._loopStart,this._loopEnd);else if(this._isLoopEnabled){const s=this._currentTime<this._loopEnd;this._adapter.setLoop(s,this._loopStart,this._loopEnd)}try{this._adapter.play(this._currentTime,t)}catch(s){throw this._currentTime=n,this._playStartPosition=r,s}}this._isPlaying=!0,this._startTimeUpdateLoop(),this._emit("play"),this._emitStateChange()}pause(){this._isPlaying=!1,this._stopTimeUpdateLoop(),this._adapter?.pause(),this._adapter&&(this._currentTime=this._adapter.getCurrentTime()),this._emit("pause"),this._emitStateChange()}stop(){this._isPlaying=!1,this._currentTime=this._playStartPosition,this._stopTimeUpdateLoop(),this._adapter?.setLoop(!1,this._loopStart,this._loopEnd),this._adapter?.stop(),this._emit("stop"),this._emitStateChange()}seek(e){const t=ao(this._tracks);this._currentTime=ol(e,t),this._adapter?.seek(this._currentTime),this._emitStateChange()}setMasterVolume(e){e!==this._masterVolume&&(this._masterVolume=e,this._adapter?.setMasterVolume(e),this._emitStateChange())}getCurrentTime(){return this._isPlaying&&this._adapter?this._adapter.getCurrentTime():this._currentTime}setSelection(e,t){const n=Math.min(e,t),r=Math.max(e,t);n===this._selectionStart&&r===this._selectionEnd||(this._selectionStart=n,this._selectionEnd=r,this._emitStateChange())}setLoopRegion(e,t){const n=Math.min(e,t),r=Math.max(e,t);n===this._loopStart&&r===this._loopEnd||(this._loopStart=n,this._loopEnd=r,this._adapter?.setLoop(this._isLoopEnabled&&this._isBeforeLoopEnd(),this._loopStart,this._loopEnd),this._emitStateChange())}setLoopEnabled(e){e!==this._isLoopEnabled&&(this._isLoopEnabled=e,this._adapter?.setLoop(e&&this._isBeforeLoopEnd(),this._loopStart,this._loopEnd),this._emitStateChange())}setTrackVolume(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.volume=t),this._adapter?.setTrackVolume(e,t)}setTrackMute(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.muted=t),this._adapter?.setTrackMute(e,t)}setTrackSolo(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.soloed=t),this._adapter?.setTrackSolo(e,t)}setTrackPan(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.pan=t),this._adapter?.setTrackPan(e,t)}zoomIn(){this._zoomIndex>0&&(this._zoomIndex--,this._emitStateChange())}zoomOut(){this._zoomIndex<this._zoomLevels.length-1&&(this._zoomIndex++,this._emitStateChange())}setZoomLevel(e){const t=Xf(e,this._zoomLevels);t!==this._zoomIndex&&(this._zoomIndex=t,this._emitStateChange())}on(e,t){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t)}off(e,t){this._listeners.get(e)?.delete(t)}dispose(){if(!this._disposed){this._disposed=!0,this._stopTimeUpdateLoop();try{this._adapter?.dispose()}catch(e){console.warn("[waveform-playlist/engine] Error disposing adapter:",e)}this._listeners.clear()}}_emit(e,...t){const n=this._listeners.get(e);if(n)for(const r of n)try{r(...t)}catch(s){console.warn("[waveform-playlist/engine] Error in event listener:",s)}}_isBeforeLoopEnd(){return this._isPlaying?(this._adapter?.getCurrentTime()??this._currentTime)<this._loopEnd:!0}_emitStateChange(){this._emit("statechange",this.getState())}_startTimeUpdateLoop(){if(typeof requestAnimationFrame>"u")return;this._stopTimeUpdateLoop();const e=()=>{this._disposed||!this._isPlaying||(this._adapter&&(this._currentTime=this._adapter.getCurrentTime(),this._emit("timeupdate",this._currentTime)),this._animFrameId=requestAnimationFrame(e))};this._animFrameId=requestAnimationFrame(e)}_stopTimeUpdateLoop(){this._animFrameId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this._animFrameId),this._animFrameId=null)}},Qf=Symbol.for("preact-signals");function Fs(){if(Jt>1)Jt--;else{for(var e,t=!1;pr!==void 0;){var n=pr;for(pr=void 0,Eo++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&ac(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(Eo=0,Jt--,t)throw e}}function Qt(e){if(Jt>0)return e();Jt++;try{return e()}finally{Fs()}}var me=void 0;function we(e){var t=me;me=void 0;try{return e()}finally{me=t}}var pr=void 0,Jt=0,Eo=0,vs=0;function oc(e){if(me!==void 0){var t=e.n;if(t===void 0||t.t!==me)return t={i:0,S:e,p:me.s,n:void 0,t:me,e:void 0,x:void 0,r:t},me.s!==void 0&&(me.s.n=t),me.s=t,e.n=t,32&me.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=me.s,t.n=void 0,me.s.n=t,me.s=t),t}}function st(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}st.prototype.brand=Qf;st.prototype.h=function(){return!0};st.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:we(function(){var r;(r=t.W)==null||r.call(t)}))};st.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&we(function(){var s;(s=t.Z)==null||s.call(t)}))}};st.prototype.subscribe=function(e){var t=this;return Ct(function(){var n=t.value,r=me;me=void 0;try{e(n)}finally{me=r}},{name:"sub"})};st.prototype.valueOf=function(){return this.value};st.prototype.toString=function(){return this.value+""};st.prototype.toJSON=function(){return this.value};st.prototype.peek=function(){var e=me;me=void 0;try{return this.value}finally{me=e}};Object.defineProperty(st.prototype,"value",{get:function(){var e=oc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Eo>100)throw new Error("Cycle detected");this.v=e,this.i++,vs++,Jt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Fs()}}}});function $r(e,t){return new st(e,t)}function ac(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function ic(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function lc(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function yn(e,t){st.call(this,void 0),this.x=e,this.s=void 0,this.g=vs-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}yn.prototype=new st;yn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===vs))return!0;if(this.g=vs,this.f|=1,this.i>0&&!ac(this))return this.f&=-2,!0;var e=me;try{ic(this),me=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return me=e,lc(this),this.f&=-2,!0};yn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}st.prototype.S.call(this,e)};yn.prototype.U=function(e){if(this.t!==void 0&&(st.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};yn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(yn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=oc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function il(e,t){return new yn(e,t)}function cc(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Jt++;var n=me;me=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,fa(e),r}finally{me=n,Fs()}}}function fa(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,cc(e)}function eh(e){if(me!==this)throw new Error("Out-of-order effect");lc(this),me=e,this.f&=-2,8&this.f&&fa(this),Fs()}function jn(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}jn.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};jn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,cc(this),ic(this),Jt++;var e=me;return me=this,eh.bind(this,e)};jn.prototype.N=function(){2&this.f||(this.f|=2,this.o=pr,pr=this)};jn.prototype.d=function(){this.f|=8,1&this.f||fa(this)};jn.prototype.dispose=function(){this.d()};function Ct(e,t){var n=new jn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var th=Object.create,ha=Object.defineProperty,nh=Object.defineProperties,rh=Object.getOwnPropertyDescriptor,sh=Object.getOwnPropertyDescriptors,ll=Object.getOwnPropertySymbols,oh=Object.prototype.hasOwnProperty,ah=Object.prototype.propertyIsEnumerable,ih=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},Io=(e,t,n)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lh=(e,t)=>{for(var n in t||(t={}))oh.call(t,n)&&Io(e,n,t[n]);if(ll)for(var n of ll(t))ah.call(t,n)&&Io(e,n,t[n]);return e},ch=(e,t)=>nh(e,sh(t)),cl=(e,t)=>ha(e,"name",{value:t,configurable:!0}),uh=e=>{var t;return[,,,th((t=void 0)!=null?t:null)]},uc=["class","method","getter","setter","accessor","field","value","get","set"],rr=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,dh=(e,t,n,r,s)=>({kind:uc[e],name:t,metadata:r,addInitializer:o=>n._?Zn("Already initialized"):s.push(rr(o||null))}),dc=(e,t)=>Io(t,ih("metadata"),e[3]),an=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)t&1?o[s].call(n):r=o[s].call(n,r);return r},Hn=(e,t,n,r,s,o)=>{var a,i,l,c,u,f=t&7,h=!!(t&8),d=!!(t&16),p=f>3?e.length+1:f?h?1:2:0,v=uc[f+5],y=f>3&&(e[p-1]=[]),m=e[p]||(e[p]=[]),b=f&&(!d&&!h&&(s=s.prototype),f<5&&(f>3||!d)&&rh(f<4?s:{get[n](){return pn(this,o)},set[n](w){return Yt(this,o,w)}},n));f?d&&f<4&&cl(o,(f>2?"set ":f>1?"get ":"")+n):cl(s,n);for(var _=r.length-1;_>=0;_--)c=dh(f,n,l={},e[3],m),f&&(c.static=h,c.private=d,u=c.access={has:d?w=>fh(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?pn:hh)(w,s,f^4?o:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>Yt(w,s,x,f^4?o:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?o:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?rr(i)&&(f>4?y.unshift(i):f?d?o=i:b[v]=i:s=i):typeof i!="object"||i===null?Zn("Object expected"):(rr(a=i.get)&&(b.get=a),rr(a=i.set)&&(b.set=a),rr(a=i.init)&&y.unshift(a));return f||dc(e,s),b&&ha(s,n,b),d?f^4?o:b:s},pa=(e,t,n)=>t.has(e)||Zn("Cannot "+n),fh=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),pn=(e,t,n)=>(pa(e,t,"read from private field"),n?n.call(e):t.get(e)),qr=(e,t,n)=>t.has(e)?Zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Yt=(e,t,n,r)=>(pa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),hh=(e,t,n)=>(pa(e,t,"access private method"),n);function ys(e,t){if(t){let n;return il(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return il(e)}function _r(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((r,s)=>!_r(r,t[s]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(o=>!_r(e[o],t[o]))}return!1}function de({get:e},t){return{init(n){return $r(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ie(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=ys(e.bind(this)),n.set(this,r)),r.value}}function io(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),s=Object.getOwnPropertyDescriptor(r,n.name);s&&Object.defineProperty(r,n.name,ch(lh({},s),{enumerable:e}))})}}function Rr(...e){const t=e.map(n=>Ct(n));return()=>t.forEach(n=>n())}var fc,hc,pc,mc,gc,vc,tt,ma,lo,Mo,Ao,qe,ga,co,yc,To,va,uo,$o,Ro;vc=[de],gc=[de],mc=[de],pc=[io()],hc=[io()],fc=[io()];var tn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,an(tt,5,this),qr(this,qe),qr(this,ma,an(tt,8,this)),an(tt,11,this),qr(this,ga,an(tt,12,this)),an(tt,15,this),qr(this,va,an(tt,16,this)),an(tt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return pn(this,qe,$o)}get initial(){return pn(this,qe,Mo)}get previous(){return pn(this,qe,yc)}set current(e){const t=we(()=>pn(this,qe,$o));e&&t&&this.equals(t,e)||Qt(()=>{pn(this,qe,Mo)||Yt(this,qe,e,Ao),Yt(this,qe,t,To),Yt(this,qe,e,Ro)})}reset(e=this.defaultValue){Qt(()=>{Yt(this,qe,void 0,To),Yt(this,qe,e,Ao),Yt(this,qe,e,Ro)})}};tt=uh();ma=new WeakMap;qe=new WeakSet;ga=new WeakMap;va=new WeakMap;lo=Hn(tt,20,"#initial",vc,qe,ma),Mo=lo.get,Ao=lo.set;co=Hn(tt,20,"#previous",gc,qe,ga),yc=co.get,To=co.set;uo=Hn(tt,20,"#current",mc,qe,va),$o=uo.get,Ro=uo.set;Hn(tt,2,"current",pc,tn);Hn(tt,2,"initial",hc,tn);Hn(tt,2,"previous",fc,tn);dc(tt,tn);function fo(e){return we(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var ph=Object.create,bc=Object.defineProperty,mh=Object.getOwnPropertyDescriptor,ul=Object.getOwnPropertySymbols,gh=Object.prototype.hasOwnProperty,vh=Object.prototype.propertyIsEnumerable,wc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Os=e=>{throw TypeError(e)},dl=Math.pow,Do=(e,t,n)=>t in e?bc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yh=(e,t)=>{for(var n in t||(t={}))gh.call(t,n)&&Do(e,n,t[n]);if(ul)for(var n of ul(t))vh.call(t,n)&&Do(e,n,t[n]);return e},bh=e=>{var t;return[,,,ph((t=e?.[wc("metadata")])!=null?t:null)]},_c=["class","method","getter","setter","accessor","field","value","get","set"],xc=e=>e!==void 0&&typeof e!="function"?Os("Function expected"):e,wh=(e,t,n,r,s)=>({kind:_c[e],name:t,metadata:r,addInitializer:o=>n._?Os("Already initialized"):s.push(xc(o||null))}),_h=(e,t)=>Do(t,wc("metadata"),e[3]),xh=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)o[s].call(n);return r},Cc=(e,t,n,r,s,o)=>{for(var a,i,l,c,u=t&7,f=!1,h=!1,d=2,p=_c[u+5],v=e[d]||(e[d]=[]),y=(s=s.prototype,mh(s,n)),m=r.length-1;m>=0;m--)l=wh(u,n,i={},e[3],v),l.static=f,l.private=h,c=l.access={has:b=>n in b},c.get=b=>b[n],a=(0,r[m])(y[p],l),i._=1,xc(a)&&(y[p]=a);return y&&bc(s,n,y),s},Sc=(e,t,n)=>t.has(e)||Os("Cannot "+n),Ch=(e,t,n)=>(Sc(e,t,"read from private field"),t.get(e)),Sh=(e,t,n)=>t.has(e)?Os("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),kh=(e,t,n,r)=>(Sc(e,t,"write to private field"),t.set(e,n),n),Pt=class Po{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Po(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Po(t,n)}},Dr=class cn{constructor(t,n,r,s){this.left=t,this.top=n,this.width=r,this.height=s,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:s,width:o,height:a,scale:i}=this,l=new cn(s+t,r+n,o,a);return l.scale=yh({},i),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:o,bottom:a}=this;return{width:t,height:n,left:r,top:s,right:o,bottom:a}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new Pt((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof cn))return!1;const{left:n,top:r,width:s,height:o}=this;return n===t.left&&r===t.top&&s===t.width&&o===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:o}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=o}intersectionArea(t){return t instanceof cn?Eh(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:s}){return new cn(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(o,a)=>{const i=r[a],l=a==="x"?o.left:o.top,c=a==="x"?o.width:o.height;return i=="start"?l:i=="end"?l+c:l+c/2};return Pt.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return cn.from(t).intersectionRatio(cn.from(n))}};function Eh(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),a=s-r,i=o-n;return r<s&&n<o?a*i:0}var kc,Ec,Fo,ss,Pr,Ls=class extends(Fo=tn,Ec=[Ie],kc=[Ie],Fo){constructor(t){const n=Pt.from(t);super(n,(r,s)=>Pt.equals(r,s)),xh(Pr,5,this),Sh(this,ss,0),this.velocity={x:0,y:0}}get delta(){return Pt.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Pt.from(t),s={x:r.x-n.x,y:r.y-n.y},o=Date.now(),a=o-Ch(this,ss),i=l=>Math.round(l/a*100);Qt(()=>{kh(this,ss,o),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Pt.from(t)),this.velocity={x:0,y:0}}};Pr=bh(Fo);ss=new WeakMap;Cc(Pr,2,"delta",Ec,Ls);Cc(Pr,2,"direction",kc,Ls);_h(Pr,Ls);function Oo({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(dl(r,2)+dl(s,2))>n:"x"in n&&"y"in n?r>n.x&&s>n.y:"x"in n?r>n.x:"y"in n?s>n.y:!1}var Ic=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ic||{}),Mc=Object.values(Ic),Ih=Object.create,ya=Object.defineProperty,Mh=Object.defineProperties,Ah=Object.getOwnPropertyDescriptor,Th=Object.getOwnPropertyDescriptors,bs=Object.getOwnPropertySymbols,Ac=Object.prototype.hasOwnProperty,Tc=Object.prototype.propertyIsEnumerable,$c=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Gn=e=>{throw TypeError(e)},Lo=(e,t,n)=>t in e?ya(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rc=(e,t)=>{for(var n in t||(t={}))Ac.call(t,n)&&Lo(e,n,t[n]);if(bs)for(var n of bs(t))Tc.call(t,n)&&Lo(e,n,t[n]);return e},Dc=(e,t)=>Mh(e,Th(t)),fl=(e,t)=>ya(e,"name",{value:t,configurable:!0}),Pc=(e,t)=>{var n={};for(var r in e)Ac.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&bs)for(var r of bs(e))t.indexOf(r)<0&&Tc.call(e,r)&&(n[r]=e[r]);return n},Un=e=>{var t;return[,,,Ih((t=e?.[$c("metadata")])!=null?t:null)]},Fc=["class","method","getter","setter","accessor","field","value","get","set"],sr=e=>e!==void 0&&typeof e!="function"?Gn("Function expected"):e,$h=(e,t,n,r,s)=>({kind:Fc[e],name:t,metadata:r,addInitializer:o=>n._?Gn("Already initialized"):s.push(sr(o||null))}),bn=(e,t)=>Lo(t,$c("metadata"),e[3]),re=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)t&1?o[s].call(n):r=o[s].call(n,r);return r},ue=(e,t,n,r,s,o)=>{var a,i,l,c,u,f=t&7,h=!!(t&8),d=!!(t&16),p=f>3?e.length+1:f?h?1:2:0,v=Fc[f+5],y=f>3&&(e[p-1]=[]),m=e[p]||(e[p]=[]),b=f&&(!d&&!h&&(s=s.prototype),f<5&&(f>3||!d)&&Ah(f<4?s:{get[n](){return He(this,o)},set[n](w){return wt(this,o,w)}},n));f?d&&f<4&&fl(o,(f>2?"set ":f>1?"get ":"")+n):fl(s,n);for(var _=r.length-1;_>=0;_--)c=$h(f,n,l={},e[3],m),f&&(c.static=h,c.private=d,u=c.access={has:d?w=>Rh(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?He:Dh)(w,s,f^4?o:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>wt(w,s,x,f^4?o:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?o:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?sr(i)&&(f>4?y.unshift(i):f?d?o=i:b[v]=i:s=i):typeof i!="object"||i===null?Gn("Object expected"):(sr(a=i.get)&&(b.get=a),sr(a=i.set)&&(b.set=a),sr(a=i.init)&&y.unshift(a));return f||bn(e,s),b&&ya(s,n,b),d?f^4?o:b:s},ba=(e,t,n)=>t.has(e)||Gn("Cannot "+n),Rh=(e,t)=>Object(t)!==t?Gn('Cannot use the "in" operator on this value'):e.has(t),He=(e,t,n)=>(ba(e,t,"read from private field"),n?n.call(e):t.get(e)),be=(e,t,n)=>t.has(e)?Gn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),wt=(e,t,n,r)=>(ba(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Dh=(e,t,n)=>(ba(e,t,"access private method"),n);function Oc(e,t){return{plugin:e,options:t}}function Xn(e){return t=>Oc(e,t)}function wa(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Lc,xr,_a,os;Lc=[de];var it=class{constructor(e,t){this.manager=e,this.options=t,be(this,_a,re(xr,8,this,!1)),re(xr,11,this),be(this,os,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return we(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=Ct(e.bind(this));return He(this,os).add(t),t}destroy(){He(this,os).forEach(e=>e())}static configure(e){return Oc(this,e)}};xr=Un(null);_a=new WeakMap;os=new WeakMap;ue(xr,4,"disabled",Lc,it,_a);bn(xr,it);var Fr=class extends it{},as,ho=class{constructor(e){this.manager=e,this.instances=new Map,be(this,as,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(wa).reduceRight((r,s)=>r.some(({plugin:o})=>o===s.plugin)?r:[s,...r],[]),n=t.map(({plugin:r})=>r);for(const r of He(this,as))if(!n.includes(r)){if(r.prototype instanceof Fr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);wt(this,as,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};as=new WeakMap;function Ph(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Jr=[],Tn,$n,Fh=class extends it{constructor(e){super(e),be(this,Tn),be(this,$n),this.computeCollisions=this.computeCollisions.bind(this),wt(this,$n,$r(Jr)),this.destroy=Rr(()=>{const t=this.computeCollisions(),n=we(()=>this.manager.dragOperation.position.current);if(t!==Jr){const r=He(this,Tn);if(wt(this,Tn,n),r&&n.x==r.x&&n.y==r.y)return}else wt(this,Tn,void 0);He(this,$n).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){we(()=>{e?He(this,$n).value=this.computeCollisions():wt(this,Tn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:o,status:a}=r;if(!a.initialized||!o)return Jr;const i=[],l=[];for(const c of e??n.droppables){if(c.disabled||s&&!c.accepts(s))continue;const u=t??c.collisionDetector;if(!u)continue;l.push(c),c.shape;const f=we(()=>u({droppable:c,dragOperation:r}));f&&(c.collisionPriority!=null&&(f.priority=c.collisionPriority),i.push(f))}return l.length===0?Jr:(i.sort(Ph),i)}get collisions(){return He(this,$n).value}};Tn=new WeakMap;$n=new WeakMap;var Oh=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const s of r)s(...t)}},Lh=class extends Oh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function is(e,t=!0){let n=!1;return Dc(Rc({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Wh=class extends Fr{constructor(e){super(e);const t=(r,s)=>r.map(({id:o})=>o).join("")===s.map(({id:o})=>o).join("");let n=[];this.destroy=Rr(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:o}=r;if(r.isDisabled())return;const a=is({collisions:o});if(s.dispatch("collision",a),a.defaultPrevented||t(o,n))return;n=o;const[i]=o;we(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},xa=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(xa||{}),Ca=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Ca||{}),Wc,Bc,Vc,Nc,zc,jc,Zc,xt,Sa;Zc=[de],jc=[Ie],zc=[Ie],Nc=[Ie],Vc=[Ie],Bc=[Ie],Wc=[Ie];var jt=class{constructor(){re(xt,5,this),be(this,Sa,re(xt,8,this,"idle")),re(xt,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};xt=Un(null);Sa=new WeakMap;ue(xt,4,"value",Zc,jt,Sa);ue(xt,2,"current",jc,jt);ue(xt,2,"idle",zc,jt);ue(xt,2,"initializing",Nc,jt);ue(xt,2,"initialized",Vc,jt);ue(xt,2,"dragging",Bc,jt);ue(xt,2,"dropped",Wc,jt);bn(xt,jt);var Bh=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return we(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=is({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return we(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const r=new AbortController,{event:s,coordinates:o}=e;Qt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(o)});const a=is({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",a),a.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:i}=t;i.current==="initializing"&&(t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1}))}),r)})}move(e){return we(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:o}=r;if(!s.dragging||!o||o.signal.aborted)return;const a=is({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",a),queueMicrotask(()=>{var i,l,c,u,f;if(a.defaultPrevented)return;const h=(f=e.to)!=null?f:{x:r.position.current.x+((l=(i=e.by)==null?void 0:i.x)!=null?l:0),y:r.position.current.y+((u=(c=e.by)==null?void 0:c.y)!=null?u:0)};r.position.current=h})})}stop(e={}){return we(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let o;const a=()=>{const l={resume:()=>{},abort:()=>{}};return o=new Promise((c,u)=>{l.resume=c,l.abort=u}),l};s.abort();const i=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=we(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),c=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:u}=r,f=Ct(()=>{u?.status==="idle"&&(f(),c())})}else this.manager.renderer.rendering.then(c)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:a}),o?o.then(i).catch(()=>r.reset()):i()})}},Hc,Gc,Uc,Xc,at,ka,Ea,Ia,Ma;Xc=[de],Uc=[de],Gc=[de],Hc=[de];var nn=class{constructor(e,t){be(this,ka,re(at,8,this)),re(at,11,this),be(this,Ea,re(at,12,this)),re(at,15,this),be(this,Ia,re(at,16,this)),re(at,19,this),be(this,Ma,re(at,20,this)),re(at,23,this);const{effects:n,id:r,data:s={},disabled:o=!1,register:a=!0}=e;let i=r;this.manager=t,this.id=r,this.data=s,this.disabled=o,this.effects=()=>{var l;return[()=>{const{id:c,manager:u}=this;if(c!==i)return u?.registry.register(this),()=>u?.registry.unregister(this)},...(l=n?.())!=null?l:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),t&&a&&queueMicrotask(this.register)}register(){var e;return(e=this.manager)==null?void 0:e.registry.register(this)}unregister(){var e;(e=this.manager)==null||e.registry.unregister(this)}destroy(){var e;(e=this.manager)==null||e.registry.unregister(this)}};at=Un(null);ka=new WeakMap;Ea=new WeakMap;Ia=new WeakMap;Ma=new WeakMap;ue(at,4,"manager",Xc,nn,ka);ue(at,4,"id",Uc,nn,Ea);ue(at,4,"data",Gc,nn,Ia);ue(at,4,"disabled",Hc,nn,Ma);bn(at,nn);var hl=class{constructor(){this.map=$r(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,t);if(r===t)return s;if(r){const i=this.cleanupFunctions.get(r);i?.(),this.cleanupFunctions.delete(r)}const o=new Map(n);o.set(e,t),this.map.value=o;const a=Rr(...t.effects());return this.cleanupFunctions.set(t,a),s},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const s=new Map(n);s.delete(e),this.map.value=s}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Yc,Kc,qc,Jc,Qc,eu,Wo,nt,Aa,Ta,$a,Ft=class extends(Wo=nn,eu=[de],Qc=[de],Jc=[de],qc=[Ie],Kc=[Ie],Yc=[Ie],Wo){constructor(t,n){var r=t,{modifiers:s,type:o,sensors:a}=r,i=Pc(r,["modifiers","type","sensors"]);super(i,n),re(nt,5,this),be(this,Aa,re(nt,8,this)),re(nt,11,this),be(this,Ta,re(nt,12,this)),re(nt,15,this),be(this,$a,re(nt,16,this,this.isDragSource?"dragging":"idle")),re(nt,19,this),this.type=o,this.sensors=a,this.modifiers=s,this.alignment=i.alignment}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};nt=Un(Wo);Aa=new WeakMap;Ta=new WeakMap;$a=new WeakMap;ue(nt,4,"type",eu,Ft,Aa);ue(nt,4,"modifiers",Qc,Ft,Ta);ue(nt,4,"status",Jc,Ft,$a);ue(nt,2,"isDropping",qc,Ft);ue(nt,2,"isDragging",Kc,Ft);ue(nt,2,"isDragSource",Yc,Ft);bn(nt,Ft);var tu,nu,ru,su,ou,au,Bo,ze,Ra,Da,Pa,Fa,Oa,Ot=class extends(Bo=nn,au=[de],ou=[de],su=[de],ru=[de],nu=[de],tu=[Ie],Bo){constructor(t,n){var r=t,{accept:s,collisionDetector:o,collisionPriority:a,type:i}=r,l=Pc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),re(ze,5,this),be(this,Ra,re(ze,8,this)),re(ze,11,this),be(this,Da,re(ze,12,this)),re(ze,15,this),be(this,Pa,re(ze,16,this)),re(ze,19,this),be(this,Fa,re(ze,20,this)),re(ze,23,this),be(this,Oa,re(ze,24,this)),re(ze,27,this),this.accept=s,this.collisionDetector=o,this.collisionPriority=a,this.type=i}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};ze=Un(Bo);Ra=new WeakMap;Da=new WeakMap;Pa=new WeakMap;Fa=new WeakMap;Oa=new WeakMap;ue(ze,4,"accept",au,Ot,Ra);ue(ze,4,"type",ou,Ot,Da);ue(ze,4,"collisionDetector",su,Ot,Pa);ue(ze,4,"collisionPriority",ru,Ot,Fa);ue(ze,4,"shape",nu,Ot,Oa);ue(ze,2,"isDropTarget",tu,Ot);bn(ze,Ot);var Wn=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Vh=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},ls,iu=class{constructor(e){this.options=e,be(this,ls)}set controller(e){wt(this,ls,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=He(this,ls))==null||t.activate(e)}};ls=new WeakMap;var Cr=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Nh=class{constructor(e){this.draggables=new hl,this.droppables=new hl,this.plugins=new ho(e),this.sensors=new ho(e),this.modifiers=new ho(e)}register(e,t){if(e instanceof Ft)return this.draggables.register(e.id,e);if(e instanceof Ot)return this.droppables.register(e.id,e);if(e.prototype instanceof Cr)return this.modifiers.register(e,t);if(e.prototype instanceof Wn)return this.sensors.register(e,t);if(e.prototype instanceof it)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof nn)return e instanceof Ft?this.draggables.unregister(e.id,e):e instanceof Ot?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Cr)return this.modifiers.unregister(e);if(e.prototype instanceof Wn)return this.sensors.unregister(e);if(e.prototype instanceof it)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},lu,cu,uu,du,fu,hu,pu,mu,gu,or,cs,Rn,Re,La,Wa,Ba,Va,Na,ar;gu=[Ie],mu=[de],pu=[de],hu=[de],fu=[de],du=[de],uu=[Ie],cu=[Ie],lu=[Ie];var Rt=class{constructor(e){re(Re,5,this),be(this,or),be(this,cs),be(this,Rn,new tn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new jt,be(this,La,re(Re,8,this,!1)),re(Re,11,this),be(this,Wa,re(Re,12,this,null)),re(Re,15,this),be(this,Ba,re(Re,16,this,null)),re(Re,19,this),be(this,Va,re(Re,20,this,null)),re(Re,23,this),be(this,Na,re(Re,24,this,[])),re(Re,27,this),this.position=new Ls({x:0,y:0}),be(this,ar,{x:0,y:0}),wt(this,or,e)}get shape(){const{current:e,initial:t,previous:n}=He(this,Rn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?He(this,Rn).current=e:He(this,Rn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=He(this,or).registry.draggables.get(t);return n&&wt(this,cs,n),(e=n??He(this,cs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=He(this,or).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(Dc(Rc({},this.snapshot()),{transform:n}));return wt(this,ar,n),n}snapshot(){return we(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:He(this,ar),shape:this.shape?fo(this.shape):null,position:fo(this.position),status:fo(this.status),canceled:this.canceled}))}reset(){Qt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,He(this,Rn).reset(),this.position.reset({x:0,y:0}),wt(this,ar,{x:0,y:0}),this.modifiers=[]})}};Re=Un(null);or=new WeakMap;cs=new WeakMap;Rn=new WeakMap;La=new WeakMap;Wa=new WeakMap;Ba=new WeakMap;Va=new WeakMap;Na=new WeakMap;ar=new WeakMap;ue(Re,2,"shape",gu,Rt);ue(Re,4,"canceled",mu,Rt,La);ue(Re,4,"activatorEvent",pu,Rt,Wa);ue(Re,4,"sourceIdentifier",hu,Rt,Ba);ue(Re,4,"targetIdentifier",fu,Rt,Va);ue(Re,4,"modifiers",du,Rt,Na);ue(Re,2,"source",uu,Rt);ue(Re,2,"target",cu,Rt);ue(Re,2,"transform",lu,Rt);bn(Re,Rt);var zh={get rendering(){return Promise.resolve()}};function Vt(e,t){return typeof e=="function"?e(t):e??t}var jh=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(h=>h.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=Vt(r.plugins,[]),o=Vt(r.sensors,[]),a=Vt(r.modifiers,[]),i=(n=r.renderer)!=null?n:zh,l=new Lh(this),c=new Nh(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new Bh(this),this.dragOperation=new Rt(this),this.collisionObserver=new Fh(this),this.plugins=[Wh,...s],this.modifiers=a,this.sensors=o;const{destroy:u}=this,f=Rr(()=>{var h,d,p;const v=we(()=>this.dragOperation.modifiers),y=this.modifiers;for(const m of v)y.includes(m)||m.destroy();this.dragOperation.modifiers=(p=(d=(h=this.dragOperation.source)==null?void 0:h.modifiers)==null?void 0:d.map(m=>{const{plugin:b,options:_}=wa(m);return new b(this,_)}))!=null?p:y});this.destroy=()=>{f(),u()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},vu=e=>{throw TypeError(e)},za=(e,t,n)=>t.has(e)||vu("Cannot "+n),ae=(e,t,n)=>(za(e,t,"read from private field"),t.get(e)),ot=(e,t,n)=>t.has(e)?vu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),pt=(e,t,n,r)=>(za(e,t,"write to private field"),t.set(e,n),n),yu=(e,t,n)=>(za(e,t,"access private method"),n);function Ws(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Zh(e,t){const n=e.getAnimations();if(n.length>0)for(const r of n){if(r.playState!=="running")continue;const{effect:s}=r,a=(Ws(s)?s.getKeyframes():[]).filter(t);if(a.length>0)return[a[a.length-1],r]}return null}function Bs(e){const{width:t,height:n,top:r,left:s,bottom:o,right:a}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:o,right:a}}function ja(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Or(e){return"nodeType"in e}function St(e){var t,n,r;return e?ja(e)?e:Or(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function Za(e){const{Document:t}=St(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function mn(e){return!e||ja(e)?!1:e instanceof St(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function bu(e){return e instanceof St(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function wn(e){return e?ja(e)?e.document:Or(e)?Za(e)?e:mn(e)||bu(e)?e.ownerDocument:document:document:document}function Hh(e){var t,n,r,s;const{documentElement:o}=wn(e),a=St(e).visualViewport,i=(t=a?.width)!=null?t:o.clientWidth,l=(n=a?.height)!=null?n:o.clientHeight,c=(r=a?.offsetTop)!=null?r:0,u=(s=a?.offsetLeft)!=null?s:0;return{top:c,left:u,right:u+i,bottom:c+l,width:i,height:l}}function Gh(e,t){if(Uh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function Uh(e){return e.tagName==="DETAILS"}function ws(e,t=e.getBoundingClientRect(),n=0){var r,s,o,a,i;let l=t;const{ownerDocument:c}=e,u=(r=c.defaultView)!=null?r:window;let f=e.parentElement;for(;f&&f!==c.documentElement;){if(!Gh(f)){const _=f.getBoundingClientRect(),w=n*(_.bottom-_.top),x=n*(_.right-_.left),S=n*(_.bottom-_.top),k=n*(_.right-_.left);l={top:Math.max(l.top,_.top-w),right:Math.min(l.right,_.right+x),bottom:Math.min(l.bottom,_.bottom+S),left:Math.max(l.left,_.left-k),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}f=f.parentElement}const h=u.visualViewport,d=(s=h?.offsetTop)!=null?s:0,p=(o=h?.offsetLeft)!=null?o:0,v=(a=h?.width)!=null?a:u.innerWidth,y=(i=h?.height)!=null?i:u.innerHeight,m=n*y,b=n*v;return l={top:Math.max(l.top,d-m),right:Math.min(l.right,p+v+b),bottom:Math.min(l.bottom,d+y+m),left:Math.max(l.left,p-b),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function Bn(e){return{x:e.clientX,y:e.clientY}}var wu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vo(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const s=r.contentDocument;s&&!t.has(s)&&n.push(...Vo(s,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const s=r.parent;s&&s.document&&s.document!==e&&n.push(...Vo(s.document,t))}}catch{}return n}function Ha(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function _u(){var e,t;const n=Ha()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Ga(e){return!e||!Or(e)?!1:e instanceof St(e).ShadowRoot}function _s(e){if(e&&Or(e)){let t=e.getRootNode();if(Ga(t))return t;if(t instanceof Document)return t}return wn(e)}function xu(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Xh(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((o,a)=>{const i=r[a];if(pl(o)&&pl(i)&&(o.type!=="file"&&(o.value=i.value),o.type==="radio"&&o.name&&(o.name=`Cloned__${o.name}`)),ml(o)&&ml(i)&&i.width>0&&i.height>0){const l=o.getContext("2d");l?.drawImage(i,0,0)}}),n}function pl(e){return"value"in e}function ml(e){return e.tagName==="CANVAS"}function Cu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Yh(r)){const{contentDocument:s}=r;if(s){const{left:o,top:a}=r.getBoundingClientRect();return Cu(s,{x:t-o,y:n-a})}}return r}function Yh(e){return e?.tagName==="IFRAME"}var gl=new WeakMap;function Kh(e){return!!e.closest(`
|
|
2
2
|
input:not([disabled]),
|
|
3
3
|
select:not([disabled]),
|
|
4
4
|
textarea:not([disabled]),
|
|
5
5
|
button:not([disabled]),
|
|
6
6
|
a[href],
|
|
7
7
|
[contenteditable]:not([contenteditable="false"])
|
|
8
|
-
`)}var hu=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:s}]=e;t.removeEventListener(n,r,s)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],s=[];for(const a of n)for(const o of r){const{type:i,listener:l,options:c}=o,u=[a,o];a.addEventListener(i,l,c),this.entries.add(u),s.push(u)}return function(){for(const[o,{type:i,listener:l,options:c}]of s)o.removeEventListener(i,l,c)}}};function Ln(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Lh(e){const t=new Set;let n=Ln(e);for(;n;)t.add(n),n=Ln(n);return t}function Vh(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function pu(e,t){const n=()=>performance.now();let r,s;return function(...a){const o=this;s?(r?.(),r=Vh(()=>{e.apply(o,a),s=n()},t-(n()-s))):(e.apply(o,a),s=n())}}function zh(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function jh(e,t=e.getBoundingClientRect()){const{width:n,height:r}=ys(e,t);return n>0&&r>0}var Zh=cu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},cs,Hh=class extends Zh{constructor(e){super(t=>{if(!te(this,cs)){pt(this,cs,!0);return}e(t,this)}),ot(this,cs,!1)}};cs=new WeakMap;var il=Array.from({length:100},(e,t)=>t/100),mu=75,ln,ws,Ht,cn,or,Ge,pr,ir,_s,gu,vu,yu=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ot(this,_s),this.disconnect=()=>{var a,o,i;pt(this,pr,!0),(a=te(this,Ht))==null||a.disconnect(),(o=te(this,cn))==null||o.disconnect(),te(this,or).disconnect(),(i=te(this,Ge))==null||i.remove()},ot(this,ln,!0),ot(this,ws),ot(this,Ht),ot(this,cn),ot(this,or),ot(this,Ge),ot(this,pr,!1),ot(this,ir,pu(()=>{var a,o,i;const{element:l}=this;if((a=te(this,cn))==null||a.disconnect(),te(this,pr)||!te(this,ln)||!l.isConnected)return;const c=(o=l.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:d}=(i=c.defaultView)!=null?i:window,p=l.getBoundingClientRect(),h=ys(l,p),{top:g,left:b,bottom:y,right:m}=h,w=-Math.floor(g),_=-Math.floor(b),v=-Math.floor(d-m),x=-Math.floor(u-y),S=`${w}px ${v}px ${x}px ${_}px`;this.boundingClientRect=p,pt(this,cn,new IntersectionObserver(k=>{const[E]=k,{intersectionRect:I}=E;(E.intersectionRatio!==1?E.intersectionRatio:Tr.intersectionRatio(I,ys(l)))!==1&&te(this,ir).call(this)},{threshold:il,rootMargin:S,root:c})),te(this,cn).observe(l),iu(this,_s,gu).call(this)},mu)),this.boundingClientRect=e.getBoundingClientRect(),pt(this,ln,jh(e,this.boundingClientRect));let r=!0;this.callback=a=>{r&&(r=!1,n.skipInitial)||t(a)};const s=e.ownerDocument;n?.debug&&(pt(this,Ge,document.createElement("div")),te(this,Ge).style.background="rgba(0,0,0,0.15)",te(this,Ge).style.position="fixed",te(this,Ge).style.pointerEvents="none",s.body.appendChild(te(this,Ge))),pt(this,or,new IntersectionObserver(a=>{var o,i;const l=a[a.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:d,height:p}=c,h=te(this,ln);pt(this,ln,u),!(!d&&!p)&&(h&&!u?((o=te(this,cn))==null||o.disconnect(),this.callback(null),(i=te(this,Ht))==null||i.disconnect(),pt(this,Ht,void 0),te(this,Ge)&&(te(this,Ge).style.visibility="hidden")):te(this,ir).call(this),u&&!te(this,Ht)&&(pt(this,Ht,new Hh(te(this,ir))),te(this,Ht).observe(e)))},{threshold:il,root:s})),te(this,ln)&&!n.skipInitial&&this.callback(this.boundingClientRect),te(this,or).observe(e)}};ln=new WeakMap;ws=new WeakMap;Ht=new WeakMap;cn=new WeakMap;or=new WeakMap;Ge=new WeakMap;pr=new WeakMap;ir=new WeakMap;_s=new WeakSet;gu=function(){te(this,pr)||(iu(this,_s,vu).call(this),!zh(this.boundingClientRect,te(this,ws))&&(this.callback(this.boundingClientRect),pt(this,ws,this.boundingClientRect)))};vu=function(){if(te(this,Ge)){const{top:e,left:t,width:n,height:r}=ys(this.element);te(this,Ge).style.overflow="hidden",te(this,Ge).style.visibility="visible",te(this,Ge).style.top=`${Math.floor(e)}px`,te(this,Ge).style.left=`${Math.floor(t)}px`,te(this,Ge).style.width=`${Math.floor(n)}px`,te(this,Ge).style.height=`${Math.floor(r)}px`}};var Jr=new WeakMap,Qr=new WeakMap;function Nh(e,t){let n=Jr.get(e);return n||(n={disconnect:new yu(e,s=>{const a=Jr.get(e);a&&a.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),Jr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Jr.delete(e),n.disconnect())}}function Xh(e,t){const n=new Set;for(const r of e){const s=Nh(r,t);n.add(s)}return()=>n.forEach(r=>r())}function Gh(e,t){var n;const r=e.ownerDocument;if(!Qr.has(r)){const o=new AbortController,i=new Set;document.addEventListener("scroll",l=>i.forEach(c=>c(l)),{capture:!0,passive:!0,signal:o.signal}),Qr.set(r,{disconnect:()=>o.abort(),listeners:i})}const{listeners:s,disconnect:a}=(n=Qr.get(r))!=null?n:{};return!s||!a?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(a(),Qr.delete(r))})}var lr,cr,us,Ra,Yh=class{constructor(e,t,n){this.callback=t,ot(this,lr),ot(this,cr,!1),ot(this,us),ot(this,Ra,pu(o=>{if(!te(this,cr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const i of te(this,us))if(o.target.contains(i)){this.callback(te(this,lr).boundingClientRect);break}}},mu));const r=Lh(e),s=Xh(r,t),a=Gh(e,te(this,Ra));pt(this,us,r),pt(this,lr,new yu(e,t,n)),this.disconnect=()=>{te(this,cr)||(pt(this,cr,!0),s(),a(),te(this,lr).disconnect())}}};lr=new WeakMap;cr=new WeakMap;us=new WeakMap;Ra=new WeakMap;function Pa(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function xr(e){try{Pa(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function ll(e){return!cu||!e?!1:e===yn(e).scrollingElement}function bu(e){var t,n;const r=kt(e),s=ll(e)?Rh(e):Os(e),a=r.visualViewport,o=ll(e)?{height:(t=a?.height)!=null?t:r.innerHeight,width:(n=a?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},i={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},l=i.current.y<=0,c=i.current.x<=0,u=i.current.y>=i.max.y,d=i.current.x>=i.max.x;return{rect:s,position:i,isTop:l,isLeft:c,isBottom:u,isRight:d}}function Uh(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:a,position:o}=bu(e),{x:i,y:l}=t??{x:0,y:0},c=!n&&o.current.y+l>0,u=!r&&o.current.y+l<o.max.y,d=!s&&o.current.x+i>0,p=!a&&o.current.x+i<o.max.x;return{top:c,bottom:u,left:d,right:p,x:d||p,y:c||u}}var Vo=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const s of n)s();for(const s of r)s()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},xs=new Vo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Kh=new Vo(e=>setTimeout(e,50)),Cs=new Map,qh=Cs.clear.bind(Cs);function jt(e,t=!1){if(!t)return cl(e);let n=Cs.get(e);return n||(n=cl(e),Cs.set(e,n),Kh.schedule(qh),n)}function cl(e){return kt(e).getComputedStyle(e)}function Jh(e,t=jt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Qh(e,t=jt(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const a=t[s];return typeof a=="string"?n.test(a):!1})}var ep={excludeElement:!0,escapeShadowDOM:!0};function Wa(e,t=ep){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,a=new Set;function o(i){if(n!=null&&a.size>=n||!i)return a;if(Oo(i)&&i.scrollingElement!=null&&!a.has(i.scrollingElement))return a.add(i.scrollingElement),a;if(s&&Lo(i))return o(i.host);if(!hn(i))return lu(i)?o(i.parentElement):a;if(a.has(i))return a;const l=jt(i,!0);if(r&&i===e||Qh(i,l)&&a.add(i),Jh(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&a.add(c),a}return o(i.parentNode)}return e?o(e):a}function tp(e){const[t]=Wa(e,{limit:1});return t??null}function Vn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Ln(e);for(;r;){if(r===t)return n;const s=Os(r),{x:a,y:o}=np(r,s);n.x=n.x+s.left,n.y=n.y+s.top,n.scaleX=n.scaleX*a,n.scaleY=n.scaleY*o,r=Ln(r)}return n}function np(e,t=Os(e)){const n=Math.round(t.width),r=Math.round(t.height);if(hn(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=jt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function rp(e){if(e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function zo(e){if(e==="none")return null;const[t,n,r="0"]=e.split(" "),s={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(s.x)&&isNaN(s.y)?null:{x:isNaN(s.x)?0:s.x,y:isNaN(s.y)?0:s.y,z:isNaN(s.z)?0:s.z}}function jo(e){var t,n,r,s,a,o,i,l,c;const{scale:u,transform:d,translate:p}=e,h=rp(u),g=zo(p),b=sp(d);if(!b&&!h&&!g)return null;const y={x:(t=h?.x)!=null?t:1,y:(n=h?.y)!=null?n:1},m={x:(r=g?.x)!=null?r:0,y:(s=g?.y)!=null?s:0},w={x:(a=b?.x)!=null?a:0,y:(o=b?.y)!=null?o:0,scaleX:(i=b?.scaleX)!=null?i:1,scaleY:(l=b?.scaleY)!=null?l:1};return{x:m.x+w.x,y:m.y+w.y,z:(c=g?.z)!=null?c:0,scaleX:y.x*w.scaleX,scaleY:y.y*w.scaleY}}function sp(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var _t=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(_t||{}),ap={x:.2,y:.2},op={x:10,y:10};function ip(e,t,n,r=25,s=ap,a=op){const{x:o,y:i}=t,{rect:l,isTop:c,isBottom:u,isLeft:d,isRight:p}=bu(e),h=Vn(e),g=jt(e,!0),b=jo(g),y=b!==null?b?.scaleX<0:!1,m=b!==null?b?.scaleY<0:!1,w=new Tr(l.left*h.scaleX+h.x,l.top*h.scaleY+h.y,l.width*h.scaleX,l.height*h.scaleY),_={x:0,y:0},v={x:0,y:0},x={height:w.height*s.y,width:w.width*s.x};return(!c||m&&!u)&&i<=w.top+x.height&&n?.y!==1&&o>=w.left-a.x&&o<=w.right+a.x?(_.y=m?1:-1,v.y=r*Math.abs((w.top+x.height-i)/x.height)):(!u||m&&!c)&&i>=w.bottom-x.height&&n?.y!==-1&&o>=w.left-a.x&&o<=w.right+a.x&&(_.y=m?-1:1,v.y=r*Math.abs((w.bottom-x.height-i)/x.height)),(!p||y&&!d)&&o>=w.right-x.width&&n?.x!==-1&&i>=w.top-a.y&&i<=w.bottom+a.y?(_.x=y?-1:1,v.x=r*Math.abs((w.right-x.width-o)/x.width)):(!d||y&&!p)&&o<=w.left+x.width&&n?.x!==1&&i>=w.top-a.y&&i<=w.bottom+a.y&&(_.x=y?1:-1,v.x=r*Math.abs((w.left+x.width-o)/x.width)),{direction:_,speed:v}}function lp(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function cp(e,t=!1){if(lp(e)){e.scrollIntoViewIfNeeded(t);return}if(!hn(e))return e.scrollIntoView();var n=tp(e);if(!hn(n))return;const r=jt(n,!0),s=parseInt(r.getPropertyValue("border-top-width")),a=parseInt(r.getPropertyValue("border-left-width")),o=e.offsetTop-n.offsetTop<n.scrollTop,i=e.offsetTop-n.offsetTop+e.clientHeight-s>n.scrollTop+n.clientHeight,l=e.offsetLeft-n.offsetLeft<n.scrollLeft,c=e.offsetLeft-n.offsetLeft+e.clientWidth-a>n.scrollLeft+n.clientWidth,u=o&&!i;(o||i)&&t&&(n.scrollTop=e.offsetTop-n.offsetTop-n.clientHeight/2-s+e.clientHeight/2),(l||c)&&t&&(n.scrollLeft=e.offsetLeft-n.offsetLeft-n.clientWidth/2-a+e.clientWidth/2),(o||i||l||c)&&!t&&e.scrollIntoView(u)}function up(e,t,n){const{scaleX:r,scaleY:s,x:a,y:o}=t,i=e.left+a+(1-r)*parseFloat(n),l=e.top+o+(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width*r:e.width,u=s?e.height*s:e.height;return{width:c,height:u,top:l,right:i+c,bottom:l+u,left:i}}function dp(e,t,n){const{scaleX:r,scaleY:s,x:a,y:o}=t,i=e.left-a-(1-r)*parseFloat(n),l=e.top-o-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width/r:e.width,u=s?e.height/s:e.height;return{width:c,height:u,top:l,right:i+c,bottom:l+u,left:i}}function fp({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var hp=new Vo(e=>setTimeout(e,0)),mr=new Map,pp=mr.clear.bind(mr);function mp(e){const t=e.ownerDocument;let n=mr.get(t);if(n)return n;n=t.getAnimations(),mr.set(t,n),hp.schedule(pp);const r=n.filter(s=>Fs(s.effect)&&s.effect.target===e);return mr.set(e,r),n}function gp(e,t){const n=mp(e).filter(r=>{var s,a;if(Fs(r.effect)){const{target:o}=r.effect;if((a=o&&((s=t.isValidTarget)==null?void 0:s.call(t,o)))!=null?a:!0)return r.effect.getKeyframes().some(l=>{for(const c of t.properties)if(l[c])return!0})}}).map(r=>{const{effect:s,currentTime:a}=r,o=s?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof a=="number"&&a<o)return r.currentTime=o,()=>{r.currentTime=a}});if(n.length>0)return()=>n.forEach(r=>r?.())}var Lt=class extends Tr{constructor(e,t={}){var n,r,s,a;const{frameTransform:o=Vn(e),ignoreTransforms:i,getBoundingClientRect:l=Os}=t,c=gp(e,{properties:["transform","translate","scale","width","height"],isValidTarget:x=>(x!==e||Bo())&&x.contains(e)}),u=l(e);let{top:d,left:p,width:h,height:g}=u,b;const y=jt(e),m=jo(y),w={x:(n=m?.scaleX)!=null?n:1,y:(r=m?.scaleY)!=null?r:1},_=vp(e,y);c?.(),m&&(b=dp(u,m,y.transformOrigin),(i||_)&&(d=b.top,p=b.left,h=b.width,g=b.height));const v={width:(s=b?.width)!=null?s:h,height:(a=b?.height)!=null?a:g};if(_&&!i&&b){const x=up(b,_,y.transformOrigin);d=x.top,p=x.left,h=x.width,g=x.height,w.x=_.scaleX,w.y=_.scaleY}o&&(i||(p*=o.scaleX,h*=o.scaleX,d*=o.scaleY,g*=o.scaleY),p+=o.x,d+=o.y),super(p,d,h,g),this.scale=w,this.intrinsicWidth=v.width,this.intrinsicHeight=v.height}};function vp(e,t){var n;const r=e.getAnimations();let s=null;if(!r.length)return null;for(const a of r){if(a.playState!=="running")continue;const o=Fs(a.effect)?a.effect.getKeyframes():[],i=o[o.length-1];if(!i)continue;const{transform:l,translate:c,scale:u}=i;if(l||c||u){const d=jo({transform:typeof l=="string"&&l?l:t.transform,translate:typeof c=="string"&&c?c:t.translate,scale:typeof u=="string"&&u?u:t.scale});d&&(s=s?{x:s.x+d.x,y:s.y+d.y,z:(n=s.z)!=null?n:d.z,scaleX:s.scaleX*d.scaleX,scaleY:s.scaleY*d.scaleY}:d)}}return s}function gr(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var yp=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(gr(n))for(const[r,s]of Object.entries(e)){const a=`${t}${r}`;this.initial.has(a)||this.initial.set(a,n.style.getPropertyValue(a)),n.style.setProperty(a,typeof s=="string"?s:`${s}px`)}}remove(e,t=""){const{element:n}=this;if(gr(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(gr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function pn(e){return e?e instanceof kt(e).Element||Pr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function Zo(e){if(!e)return!1;const{KeyboardEvent:t}=kt(e.target);return e instanceof t}function bp(e){if(!e)return!1;const{PointerEvent:t}=kt(e.target);return e instanceof t}function wp(e){if(!pn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||_p(e)}function _p(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var oa={};function Fa(e){const t=oa[e]==null?0:oa[e]+1;return oa[e]=t,`${e}-${t}`}var xp=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=Tt.distance(t.shape.center,n);return{id:r,value:1/s,type:go.PointerIntersection,priority:mo.High}}return null},Cp=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:s}=e,a=Tt.distance(t.shape.center,s.current),i=r/(n.current.area+t.shape.area-r)/a;return{id:t.id,value:i,type:go.ShapeIntersection,priority:mo.Normal}}return null},kp=e=>{var t;return(t=xp(e))!=null?t:Cp(e)},Sp=Object.create,Ho=Object.defineProperty,Ep=Object.defineProperties,Ip=Object.getOwnPropertyDescriptor,Ap=Object.getOwnPropertyDescriptors,ks=Object.getOwnPropertySymbols,wu=Object.prototype.hasOwnProperty,_u=Object.prototype.propertyIsEnumerable,xu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Yn=e=>{throw TypeError(e)},Oa=(e,t,n)=>t in e?Ho(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Cr=(e,t)=>{for(var n in t||(t={}))wu.call(t,n)&&Oa(e,n,t[n]);if(ks)for(var n of ks(t))_u.call(t,n)&&Oa(e,n,t[n]);return e},No=(e,t)=>Ep(e,Ap(t)),ul=(e,t)=>Ho(e,"name",{value:t,configurable:!0}),Cu=(e,t)=>{var n={};for(var r in e)wu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ks)for(var r of ks(e))t.indexOf(r)<0&&_u.call(e,r)&&(n[r]=e[r]);return n},Un=e=>{var t;return[,,,Sp((t=e?.[xu("metadata")])!=null?t:null)]},ku=["class","method","getter","setter","accessor","field","value","get","set"],ur=e=>e!==void 0&&typeof e!="function"?Yn("Function expected"):e,Mp=(e,t,n,r,s)=>({kind:ku[e],name:t,metadata:r,addInitializer:a=>n._?Yn("Already initialized"):s.push(ur(a||null))}),bn=(e,t)=>Oa(t,xu("metadata"),e[3]),Pe=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},gt=(e,t,n,r,s,a)=>{var o,i,l,c,u,d=t&7,p=!!(t&8),h=!!(t&16),g=d>3?e.length+1:d?p?1:2:0,b=ku[d+5],y=d>3&&(e[g-1]=[]),m=e[g]||(e[g]=[]),w=d&&(!h&&!p&&(s=s.prototype),d<5&&(d>3||!h)&&Ip(d<4?s:{get[n](){return Se(this,a)},set[n](v){return rt(this,a,v)}},n));d?h&&d<4&&ul(a,(d>2?"set ":d>1?"get ":"")+n):ul(s,n);for(var _=r.length-1;_>=0;_--)c=Mp(d,n,l={},e[3],m),d&&(c.static=p,c.private=h,u=c.access={has:h?v=>$p(s,v):v=>n in v},d^3&&(u.get=h?v=>(d^1?Se:mn)(v,s,d^4?a:w.get):v=>v[n]),d>2&&(u.set=h?(v,x)=>rt(v,s,x,d^4?a:w.set):(v,x)=>v[n]=x)),i=(0,r[_])(d?d<4?h?a:w[b]:d>4?void 0:{get:w.get,set:w.set}:s,c),l._=1,d^4||i===void 0?ur(i)&&(d>4?y.unshift(i):d?h?a=i:w[b]=i:s=i):typeof i!="object"||i===null?Yn("Object expected"):(ur(o=i.get)&&(w.get=o),ur(o=i.set)&&(w.set=o),ur(o=i.init)&&y.unshift(o));return d||bn(e,s),w&&Ho(s,n,w),h?d^4?a:w:s},Xo=(e,t,n)=>t.has(e)||Yn("Cannot "+n),$p=(e,t)=>Object(t)!==t?Yn('Cannot use the "in" operator on this value'):e.has(t),Se=(e,t,n)=>(Xo(e,t,"read from private field"),n?n.call(e):t.get(e)),$e=(e,t,n)=>t.has(e)?Yn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rt=(e,t,n,r)=>(Xo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),mn=(e,t,n)=>(Xo(e,t,"access private method"),n),dl={role:"button",roleDescription:"draggable"},Tp="dnd-kit-description",Dp="dnd-kit-announcement",Rp={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},Pp={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function Wp(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Fp(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function Op(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var Bp=["dragover","dragmove"],Lp=class extends lt{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Tp,announcement:s=Dp}={},announcements:a=Pp,screenReaderInstructions:o=Rp,debounce:i=500}=t??{},l=n?`${r}-${n}`:Fa(r),c=n?`${s}-${n}`:Fa(s);let u,d,p,h;const g=(x=h)=>{!p||!x||p?.nodeValue!==x&&(p.nodeValue=x)},b=()=>xs.schedule(g),y=Vp(b,i),m=Object.entries(a).map(([x,S])=>this.manager.monitor.addEventListener(x,(k,E)=>{const I=p;if(!I)return;const A=S?.(k,E);A&&I.nodeValue!==A&&(h=A,Bp.includes(x)?y():(b(),y.cancel()))})),w=()=>{let x=[];u?.isConnected||(u=Fp(l,o.draggable),x.push(u)),d?.isConnected||(d=Op(c),p=document.createTextNode(""),d.appendChild(p),x.push(d)),x.length>0&&document.body.append(...x)},_=new Set;function v(){for(const x of _)x()}this.registerEffect(()=>{var x;_.clear();for(const S of this.manager.registry.draggables.value){const k=(x=S.handle)!=null?x:S.element;if(k){(!u||!d)&&_.add(w),(!Wp(k)||Bo())&&!k.hasAttribute("tabindex")&&_.add(()=>k.setAttribute("tabindex","0")),!k.hasAttribute("role")&&k.tagName.toLowerCase()!=="button"&&_.add(()=>k.setAttribute("role",dl.role)),k.hasAttribute("aria-roledescription")||_.add(()=>k.setAttribute("aria-roledescription",dl.roleDescription)),k.hasAttribute("aria-describedby")||_.add(()=>k.setAttribute("aria-describedby",l));for(const I of["aria-pressed","aria-grabbed"]){const A=String(S.isDragging);k.getAttribute(I)!==A&&_.add(()=>k.setAttribute(I,A))}const E=String(S.disabled);k.getAttribute("aria-disabled")!==E&&_.add(()=>k.setAttribute("aria-disabled",E))}}_.size>0&&xs.schedule(v)}),this.destroy=()=>{super.destroy(),u?.remove(),d?.remove(),m.forEach(x=>x())}}};function Vp(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var zp=class extends lt{constructor(e,t){super(e,t),this.manager=e;const n=gs(()=>{var r;return yn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=Ct(()=>{var r;const{dragOperation:s}=this.manager,{cursor:a="grabbing",nonce:o}=(r=this.options)!=null?r:{};if(s.status.initialized){const i=n.value,l=i.createElement("style");return o&&l.setAttribute("nonce",o),l.textContent=`* { cursor: ${a} !important; }`,i.head.appendChild(l),()=>l.remove()}})}},Ss=new Map,Su,Eu,Iu,Au,Ba,vr,Vt,Go,zn,Mu,$u,Tu,Du,wn=class extends(Ba=Rr,Au=[ue],Iu=[Ae],Eu=[Ae],Su=[Ae],Ba){constructor(e){super(e),Pe(Vt,5,this),$e(this,zn),$e(this,vr,new Set),$e(this,Go,Pe(Vt,8,this,new Set)),Pe(Vt,11,this),this.registerEffect(mn(this,zn,Mu))}register(e){return Se(this,vr).add(e),()=>{Se(this,vr).delete(e)}}addRoot(e){return _e(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{_e(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return bs((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return bs((e=t?.element)!=null?e:null)}get roots(){const{status:e}=this.manager.dragOperation;if(e.initializing||e.initialized){const t=[this.sourceRoot,this.targetRoot].filter(n=>n!=null);return new Set([...t,...this.additionalRoots])}return new Set}};Vt=Un(Ba);vr=new WeakMap;Go=new WeakMap;zn=new WeakSet;Mu=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Se(this,vr))t.push(mn(this,zn,$u).call(this,n,r));return()=>{for(const n of t)n()}};$u=function(e,t){let n=Ss.get(e);n||(n=new Map,Ss.set(e,n));let r=n.get(t);if(!r){const a=Oo(e)?mn(this,zn,Tu).call(this,e,n,t):mn(this,zn,Du).call(this,e,n,t);if(!a)return()=>{};r=a,n.set(t,r)}r.refCount++;let s=!1;return()=>{s||(s=!0,r.refCount--,r.refCount===0&&r.cleanup())}};Tu=function(e,t,n){const r=e.createElement("style");r.textContent=n,e.head.prepend(r);const s=new MutationObserver(a=>{for(const o of a)for(const i of Array.from(o.removedNodes))if(i===r){e.head.prepend(r);return}});return s.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{s.disconnect(),r.remove(),t.delete(n),t.size===0&&Ss.delete(e)}}};Du=function(e,t,n){!("adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets))&&process.env.NODE_ENV!=="production"&&console.error("Cannot inject styles: This browser doesn't support adoptedStyleSheets");const r=e.ownerDocument.defaultView,{CSSStyleSheet:s}=r??{};if(!s)return process.env.NODE_ENV!=="production"&&console.error("Cannot inject styles: CSSStyleSheet constructor not available"),null;const a=new s;return a.replaceSync(n),e.adoptedStyleSheets.push(a),{refCount:0,cleanup:()=>{var o;if(Lo(e)&&((o=e.host)!=null&&o.isConnected)){const i=e.adoptedStyleSheets.indexOf(a);i!==-1&&e.adoptedStyleSheets.splice(i,1)}t.delete(n),t.size===0&&Ss.delete(e)}}};gt(Vt,4,"additionalRoots",Au,wn,Go);gt(Vt,2,"sourceRoot",Iu,wn);gt(Vt,2,"targetRoot",Eu,wn);gt(Vt,2,"roots",Su,wn);bn(Vt,wn);var Wr="data-dnd-",La=`${Wr}dropping`,Je="--dnd-",$t=`${Wr}dragging`,Es=`${Wr}placeholder`,jp=[$t,Es,"popover","aria-pressed","aria-grabbing"],Zp=["view-transition-name"],Hp=`
|
|
9
|
-
:is(:root,:host) [${
|
|
8
|
+
`)}var Su=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:s}]=e;t.removeEventListener(n,r,s)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],s=[];for(const o of n)for(const a of r){const{type:i,listener:l,options:c}=a,u=[o,a];o.addEventListener(i,l,c),this.entries.add(u),s.push(u)}return function(){for(const[a,{type:i,listener:l,options:c}]of s)a.removeEventListener(i,l,c)}}};function Vn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function qh(e){const t=new Set;let n=Vn(e);for(;n;)t.add(n),n=Vn(n);return t}function Jh(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function ku(e,t){const n=()=>performance.now();let r,s;return function(...o){const a=this;s?(r?.(),r=Jh(()=>{e.apply(a,o),s=n()},t-(n()-s))):(e.apply(a,o),s=n())}}function Qh(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function ep(e,t=e.getBoundingClientRect()){const{width:n,height:r}=ws(e,t);return n>0&&r>0}var tp=wu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},us,np=class extends tp{constructor(e){super(t=>{if(!ae(this,us)){pt(this,us,!0);return}e(t,this)}),ot(this,us,!1)}};us=new WeakMap;var vl=Array.from({length:100},(e,t)=>t/100),Eu=75,un,xs,Ut,dn,ir,Ye,mr,lr,Cs,Iu,Mu,Au=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ot(this,Cs),this.disconnect=()=>{var o,a,i;pt(this,mr,!0),(o=ae(this,Ut))==null||o.disconnect(),(a=ae(this,dn))==null||a.disconnect(),ae(this,ir).disconnect(),(i=ae(this,Ye))==null||i.remove()},ot(this,un,!0),ot(this,xs),ot(this,Ut),ot(this,dn),ot(this,ir),ot(this,Ye),ot(this,mr,!1),ot(this,lr,ku(()=>{var o,a,i;const{element:l}=this;if((o=ae(this,dn))==null||o.disconnect(),ae(this,mr)||!ae(this,un)||!l.isConnected)return;const c=(a=l.ownerDocument)!=null?a:document,{innerHeight:u,innerWidth:f}=(i=c.defaultView)!=null?i:window,h=l.getBoundingClientRect(),d=ws(l,h),{top:p,left:v,bottom:y,right:m}=d,b=-Math.floor(p),_=-Math.floor(v),w=-Math.floor(f-m),x=-Math.floor(u-y),S=`${b}px ${w}px ${x}px ${_}px`;this.boundingClientRect=h,pt(this,dn,new IntersectionObserver(k=>{const[E]=k,{intersectionRect:T}=E;(E.intersectionRatio!==1?E.intersectionRatio:Dr.intersectionRatio(T,ws(l)))!==1&&ae(this,lr).call(this)},{threshold:vl,rootMargin:S,root:c})),ae(this,dn).observe(l),yu(this,Cs,Iu).call(this)},Eu)),this.boundingClientRect=e.getBoundingClientRect(),pt(this,un,ep(e,this.boundingClientRect));let r=!0;this.callback=o=>{r&&(r=!1,n.skipInitial)||t(o)};const s=e.ownerDocument;n?.debug&&(pt(this,Ye,document.createElement("div")),ae(this,Ye).style.background="rgba(0,0,0,0.15)",ae(this,Ye).style.position="fixed",ae(this,Ye).style.pointerEvents="none",s.body.appendChild(ae(this,Ye))),pt(this,ir,new IntersectionObserver(o=>{var a,i;const l=o[o.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:f,height:h}=c,d=ae(this,un);pt(this,un,u),!(!f&&!h)&&(d&&!u?((a=ae(this,dn))==null||a.disconnect(),this.callback(null),(i=ae(this,Ut))==null||i.disconnect(),pt(this,Ut,void 0),ae(this,Ye)&&(ae(this,Ye).style.visibility="hidden")):ae(this,lr).call(this),u&&!ae(this,Ut)&&(pt(this,Ut,new np(ae(this,lr))),ae(this,Ut).observe(e)))},{threshold:vl,root:s})),ae(this,un)&&!n.skipInitial&&this.callback(this.boundingClientRect),ae(this,ir).observe(e)}};un=new WeakMap;xs=new WeakMap;Ut=new WeakMap;dn=new WeakMap;ir=new WeakMap;Ye=new WeakMap;mr=new WeakMap;lr=new WeakMap;Cs=new WeakSet;Iu=function(){ae(this,mr)||(yu(this,Cs,Mu).call(this),!Qh(this.boundingClientRect,ae(this,xs))&&(this.callback(this.boundingClientRect),pt(this,xs,this.boundingClientRect)))};Mu=function(){if(ae(this,Ye)){const{top:e,left:t,width:n,height:r}=ws(this.element);ae(this,Ye).style.overflow="hidden",ae(this,Ye).style.visibility="visible",ae(this,Ye).style.top=`${Math.floor(e)}px`,ae(this,Ye).style.left=`${Math.floor(t)}px`,ae(this,Ye).style.width=`${Math.floor(n)}px`,ae(this,Ye).style.height=`${Math.floor(r)}px`}};var Qr=new WeakMap,es=new WeakMap;function rp(e,t){let n=Qr.get(e);return n||(n={disconnect:new Au(e,s=>{const o=Qr.get(e);o&&o.callbacks.forEach(a=>a(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),Qr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Qr.delete(e),n.disconnect())}}function sp(e,t){const n=new Set;for(const r of e){const s=rp(r,t);n.add(s)}return()=>n.forEach(r=>r())}function op(e,t){var n;const r=e.ownerDocument;if(!es.has(r)){const a=new AbortController,i=new Set;document.addEventListener("scroll",l=>i.forEach(c=>c(l)),{capture:!0,passive:!0,signal:a.signal}),es.set(r,{disconnect:()=>a.abort(),listeners:i})}const{listeners:s,disconnect:o}=(n=es.get(r))!=null?n:{};return!s||!o?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(o(),es.delete(r))})}var cr,ur,ds,No,ap=class{constructor(e,t,n){this.callback=t,ot(this,cr),ot(this,ur,!1),ot(this,ds),ot(this,No,ku(a=>{if(!ae(this,ur)&&a.target&&"contains"in a.target&&typeof a.target.contains=="function"){for(const i of ae(this,ds))if(a.target.contains(i)){this.callback(ae(this,cr).boundingClientRect);break}}},Eu));const r=qh(e),s=sp(r,t),o=op(e,ae(this,No));pt(this,ds,r),pt(this,cr,new Au(e,t,n)),this.disconnect=()=>{ae(this,ur)||(pt(this,ur,!0),s(),o(),ae(this,cr).disconnect())}}};cr=new WeakMap;ur=new WeakMap;ds=new WeakMap;No=new WeakMap;function zo(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function Sr(e){try{zo(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function yl(e){return!wu||!e?!1:e===wn(e).scrollingElement}function Tu(e){var t,n;const r=St(e),s=yl(e)?Hh(e):Bs(e),o=r.visualViewport,a=yl(e)?{height:(t=o?.height)!=null?t:r.innerHeight,width:(n=o?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},i={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-a.width,y:e.scrollHeight-a.height}},l=i.current.y<=0,c=i.current.x<=0,u=i.current.y>=i.max.y,f=i.current.x>=i.max.x;return{rect:s,position:i,isTop:l,isLeft:c,isBottom:u,isRight:f}}function ip(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:o,position:a}=Tu(e),{x:i,y:l}=t??{x:0,y:0},c=!n&&a.current.y+l>0,u=!r&&a.current.y+l<a.max.y,f=!s&&a.current.x+i>0,h=!o&&a.current.x+i<a.max.x;return{top:c,bottom:u,left:f,right:h,x:f||h,y:c||u}}var Ua=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const s of n)s();for(const s of r)s()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},Ss=new Ua(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),lp=new Ua(e=>setTimeout(e,50)),ks=new Map,cp=ks.clear.bind(ks);function Zt(e,t=!1){if(!t)return bl(e);let n=ks.get(e);return n||(n=bl(e),ks.set(e,n),lp.schedule(cp),n)}function bl(e){return St(e).getComputedStyle(e)}function up(e,t=Zt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function dp(e,t=Zt(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const o=t[s];return typeof o=="string"?n.test(o):!1})}var fp={excludeElement:!0,escapeShadowDOM:!0};function jo(e,t=fp){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,o=new Set;function a(i){if(n!=null&&o.size>=n||!i)return o;if(Za(i)&&i.scrollingElement!=null&&!o.has(i.scrollingElement))return o.add(i.scrollingElement),o;if(s&&Ga(i))return a(i.host);if(!mn(i))return bu(i)?a(i.parentElement):o;if(o.has(i))return o;const l=Zt(i,!0);if(r&&i===e||dp(i,l)&&o.add(i),up(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&o.add(c),o}return a(i.parentNode)}return e?a(e):o}function hp(e){const[t]=jo(e,{limit:1});return t??null}function Nn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Vn(e);for(;r;){if(r===t)return n;const s=Bs(r),{x:o,y:a}=pp(r,s);n.x=n.x+s.left,n.y=n.y+s.top,n.scaleX=n.scaleX*o,n.scaleY=n.scaleY*a,r=Vn(r)}return n}function pp(e,t=Bs(e)){const n=Math.round(t.width),r=Math.round(t.height);if(mn(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=Zt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function mp(e){if(e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function Xa(e){if(e==="none")return null;const[t,n,r="0"]=e.split(" "),s={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(s.x)&&isNaN(s.y)?null:{x:isNaN(s.x)?0:s.x,y:isNaN(s.y)?0:s.y,z:isNaN(s.z)?0:s.z}}function Ya(e){var t,n,r,s,o,a,i,l,c;const{scale:u,transform:f,translate:h}=e,d=mp(u),p=Xa(h),v=gp(f);if(!v&&!d&&!p)return null;const y={x:(t=d?.x)!=null?t:1,y:(n=d?.y)!=null?n:1},m={x:(r=p?.x)!=null?r:0,y:(s=p?.y)!=null?s:0},b={x:(o=v?.x)!=null?o:0,y:(a=v?.y)!=null?a:0,scaleX:(i=v?.scaleX)!=null?i:1,scaleY:(l=v?.scaleY)!=null?l:1};return{x:m.x+b.x,y:m.y+b.y,z:(c=p?.z)!=null?c:0,scaleX:y.x*b.scaleX,scaleY:y.y*b.scaleY}}function gp(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var _t=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(_t||{}),vp={x:.2,y:.2},yp={x:10,y:10};function bp(e,t,n,r=25,s=vp,o=yp){const{x:a,y:i}=t,{rect:l,isTop:c,isBottom:u,isLeft:f,isRight:h}=Tu(e),d=Nn(e),p=Zt(e,!0),v=Ya(p),y=v!==null?v?.scaleX<0:!1,m=v!==null?v?.scaleY<0:!1,b=new Dr(l.left*d.scaleX+d.x,l.top*d.scaleY+d.y,l.width*d.scaleX,l.height*d.scaleY),_={x:0,y:0},w={x:0,y:0},x={height:b.height*s.y,width:b.width*s.x};return(!c||m&&!u)&&i<=b.top+x.height&&n?.y!==1&&a>=b.left-o.x&&a<=b.right+o.x?(_.y=m?1:-1,w.y=r*Math.abs((b.top+x.height-i)/x.height)):(!u||m&&!c)&&i>=b.bottom-x.height&&n?.y!==-1&&a>=b.left-o.x&&a<=b.right+o.x&&(_.y=m?-1:1,w.y=r*Math.abs((b.bottom-x.height-i)/x.height)),(!h||y&&!f)&&a>=b.right-x.width&&n?.x!==-1&&i>=b.top-o.y&&i<=b.bottom+o.y?(_.x=y?-1:1,w.x=r*Math.abs((b.right-x.width-a)/x.width)):(!f||y&&!h)&&a<=b.left+x.width&&n?.x!==1&&i>=b.top-o.y&&i<=b.bottom+o.y&&(_.x=y?1:-1,w.x=r*Math.abs((b.left+x.width-a)/x.width)),{direction:_,speed:w}}function wp(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function _p(e,t=!1){if(wp(e)){e.scrollIntoViewIfNeeded(t);return}if(!mn(e))return e.scrollIntoView();var n=hp(e);if(!mn(n))return;const r=Zt(n,!0),s=parseInt(r.getPropertyValue("border-top-width")),o=parseInt(r.getPropertyValue("border-left-width")),a=e.offsetTop-n.offsetTop<n.scrollTop,i=e.offsetTop-n.offsetTop+e.clientHeight-s>n.scrollTop+n.clientHeight,l=e.offsetLeft-n.offsetLeft<n.scrollLeft,c=e.offsetLeft-n.offsetLeft+e.clientWidth-o>n.scrollLeft+n.clientWidth,u=a&&!i;(a||i)&&t&&(n.scrollTop=e.offsetTop-n.offsetTop-n.clientHeight/2-s+e.clientHeight/2),(l||c)&&t&&(n.scrollLeft=e.offsetLeft-n.offsetLeft-n.clientWidth/2-o+e.clientWidth/2),(a||i||l||c)&&!t&&e.scrollIntoView(u)}function xp(e,t,n){const{scaleX:r,scaleY:s,x:o,y:a}=t,i=e.left+o+(1-r)*parseFloat(n),l=e.top+a+(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width*r:e.width,u=s?e.height*s:e.height;return{width:c,height:u,top:l,right:i+c,bottom:l+u,left:i}}function Cp(e,t,n){const{scaleX:r,scaleY:s,x:o,y:a}=t,i=e.left-o-(1-r)*parseFloat(n),l=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width/r:e.width,u=s?e.height/s:e.height;return{width:c,height:u,top:l,right:i+c,bottom:l+u,left:i}}function Sp({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var kp=new Ua(e=>setTimeout(e,0)),gr=new Map,Ep=gr.clear.bind(gr);function Ip(e){const t=e.ownerDocument;let n=gr.get(t);if(n)return n;n=t.getAnimations(),gr.set(t,n),kp.schedule(Ep);const r=n.filter(s=>Ws(s.effect)&&s.effect.target===e);return gr.set(e,r),n}function Mp(e,t){const n=Ip(e).filter(r=>{var s,o;if(Ws(r.effect)){const{target:a}=r.effect;if((o=a&&((s=t.isValidTarget)==null?void 0:s.call(t,a)))!=null?o:!0)return r.effect.getKeyframes().some(l=>{for(const c of t.properties)if(l[c])return!0})}}).map(r=>{const{effect:s,currentTime:o}=r,a=s?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof a=="number"&&typeof o=="number"&&o<a)return r.currentTime=a,()=>{r.currentTime=o}});if(n.length>0)return()=>n.forEach(r=>r?.())}var Nt=class extends Dr{constructor(e,t={}){var n,r,s,o;const{frameTransform:a=Nn(e),ignoreTransforms:i,getBoundingClientRect:l=Bs}=t,c=Mp(e,{properties:["transform","translate","scale","width","height"],isValidTarget:x=>(x!==e||Ha())&&x.contains(e)}),u=l(e);let{top:f,left:h,width:d,height:p}=u,v;const y=Zt(e),m=Ya(y),b={x:(n=m?.scaleX)!=null?n:1,y:(r=m?.scaleY)!=null?r:1},_=Ap(e,y);c?.(),m&&(v=Cp(u,m,y.transformOrigin),(i||_)&&(f=v.top,h=v.left,d=v.width,p=v.height));const w={width:(s=v?.width)!=null?s:d,height:(o=v?.height)!=null?o:p};if(_&&!i&&v){const x=xp(v,_,y.transformOrigin);f=x.top,h=x.left,d=x.width,p=x.height,b.x=_.scaleX,b.y=_.scaleY}a&&(i||(h*=a.scaleX,d*=a.scaleX,f*=a.scaleY,p*=a.scaleY),h+=a.x,f+=a.y),super(h,f,d,p),this.scale=b,this.intrinsicWidth=w.width,this.intrinsicHeight=w.height}};function Ap(e,t){var n;const r=e.getAnimations();let s=null;if(!r.length)return null;for(const o of r){if(o.playState!=="running")continue;const a=Ws(o.effect)?o.effect.getKeyframes():[],i=a[a.length-1];if(!i)continue;const{transform:l,translate:c,scale:u}=i;if(l||c||u){const f=Ya({transform:typeof l=="string"&&l?l:t.transform,translate:typeof c=="string"&&c?c:t.translate,scale:typeof u=="string"&&u?u:t.scale});f&&(s=s?{x:s.x+f.x,y:s.y+f.y,z:(n=s.z)!=null?n:f.z,scaleX:s.scaleX*f.scaleX,scaleY:s.scaleY*f.scaleY}:f)}}return s}function vr(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var Tp=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(vr(n))for(const[r,s]of Object.entries(e)){const o=`${t}${r}`;this.initial.has(o)||this.initial.set(o,n.style.getPropertyValue(o)),n.style.setProperty(o,typeof s=="string"?s:`${s}px`)}}remove(e,t=""){const{element:n}=this;if(vr(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(vr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function gn(e){return e?e instanceof St(e).Element||Or(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function Ka(e){if(!e)return!1;const{KeyboardEvent:t}=St(e.target);return e instanceof t}function $p(e){if(!e)return!1;const{PointerEvent:t}=St(e.target);return e instanceof t}function Rp(e){if(!gn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||Dp(e)}function Dp(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var po={};function Zo(e){const t=po[e]==null?0:po[e]+1;return po[e]=t,`${e}-${t}`}var Pp=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=Pt.distance(t.shape.center,n);return{id:r,value:1/s,type:Ca.PointerIntersection,priority:xa.High}}return null},Fp=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:s}=e,o=Pt.distance(t.shape.center,s.current),i=r/(n.current.area+t.shape.area-r)/o;return{id:t.id,value:i,type:Ca.ShapeIntersection,priority:xa.Normal}}return null},Op=e=>{var t;return(t=Pp(e))!=null?t:Fp(e)},Lp=Object.create,qa=Object.defineProperty,Wp=Object.defineProperties,Bp=Object.getOwnPropertyDescriptor,Vp=Object.getOwnPropertyDescriptors,Es=Object.getOwnPropertySymbols,$u=Object.prototype.hasOwnProperty,Ru=Object.prototype.propertyIsEnumerable,Du=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Yn=e=>{throw TypeError(e)},Ho=(e,t,n)=>t in e?qa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kr=(e,t)=>{for(var n in t||(t={}))$u.call(t,n)&&Ho(e,n,t[n]);if(Es)for(var n of Es(t))Ru.call(t,n)&&Ho(e,n,t[n]);return e},Ja=(e,t)=>Wp(e,Vp(t)),wl=(e,t)=>qa(e,"name",{value:t,configurable:!0}),Pu=(e,t)=>{var n={};for(var r in e)$u.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Es)for(var r of Es(e))t.indexOf(r)<0&&Ru.call(e,r)&&(n[r]=e[r]);return n},Kn=e=>{var t;return[,,,Lp((t=e?.[Du("metadata")])!=null?t:null)]},Fu=["class","method","getter","setter","accessor","field","value","get","set"],dr=e=>e!==void 0&&typeof e!="function"?Yn("Function expected"):e,Np=(e,t,n,r,s)=>({kind:Fu[e],name:t,metadata:r,addInitializer:o=>n._?Yn("Already initialized"):s.push(dr(o||null))}),_n=(e,t)=>Ho(t,Du("metadata"),e[3]),We=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)t&1?o[s].call(n):r=o[s].call(n,r);return r},gt=(e,t,n,r,s,o)=>{var a,i,l,c,u,f=t&7,h=!!(t&8),d=!!(t&16),p=f>3?e.length+1:f?h?1:2:0,v=Fu[f+5],y=f>3&&(e[p-1]=[]),m=e[p]||(e[p]=[]),b=f&&(!d&&!h&&(s=s.prototype),f<5&&(f>3||!d)&&Bp(f<4?s:{get[n](){return Ce(this,o)},set[n](w){return rt(this,o,w)}},n));f?d&&f<4&&wl(o,(f>2?"set ":f>1?"get ":"")+n):wl(s,n);for(var _=r.length-1;_>=0;_--)c=Np(f,n,l={},e[3],m),f&&(c.static=h,c.private=d,u=c.access={has:d?w=>zp(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?Ce:vn)(w,s,f^4?o:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>rt(w,s,x,f^4?o:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?o:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?dr(i)&&(f>4?y.unshift(i):f?d?o=i:b[v]=i:s=i):typeof i!="object"||i===null?Yn("Object expected"):(dr(a=i.get)&&(b.get=a),dr(a=i.set)&&(b.set=a),dr(a=i.init)&&y.unshift(a));return f||_n(e,s),b&&qa(s,n,b),d?f^4?o:b:s},Qa=(e,t,n)=>t.has(e)||Yn("Cannot "+n),zp=(e,t)=>Object(t)!==t?Yn('Cannot use the "in" operator on this value'):e.has(t),Ce=(e,t,n)=>(Qa(e,t,"read from private field"),n?n.call(e):t.get(e)),De=(e,t,n)=>t.has(e)?Yn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rt=(e,t,n,r)=>(Qa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),vn=(e,t,n)=>(Qa(e,t,"access private method"),n),_l={role:"button",roleDescription:"draggable"},jp="dnd-kit-description",Zp="dnd-kit-announcement",Hp={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},Gp={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function Up(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Xp(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function Yp(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var Kp=["dragover","dragmove"],qp=class extends it{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=jp,announcement:s=Zp}={},announcements:o=Gp,screenReaderInstructions:a=Hp,debounce:i=500}=t??{},l=n?`${r}-${n}`:Zo(r),c=n?`${s}-${n}`:Zo(s);let u,f,h,d;const p=(x=d)=>{!h||!x||h?.nodeValue!==x&&(h.nodeValue=x)},v=()=>Ss.schedule(p),y=Jp(v,i),m=Object.entries(o).map(([x,S])=>this.manager.monitor.addEventListener(x,(k,E)=>{const T=h;if(!T)return;const I=S?.(k,E);I&&T.nodeValue!==I&&(d=I,Kp.includes(x)?y():(v(),y.cancel()))})),b=()=>{let x=[];u?.isConnected||(u=Xp(l,a.draggable),x.push(u)),f?.isConnected||(f=Yp(c),h=document.createTextNode(""),f.appendChild(h),x.push(f)),x.length>0&&document.body.append(...x)},_=new Set;function w(){for(const x of _)x()}this.registerEffect(()=>{var x;_.clear();for(const S of this.manager.registry.draggables.value){const k=(x=S.handle)!=null?x:S.element;if(k){(!u||!f)&&_.add(b),(!Up(k)||Ha())&&!k.hasAttribute("tabindex")&&_.add(()=>k.setAttribute("tabindex","0")),!k.hasAttribute("role")&&k.tagName.toLowerCase()!=="button"&&_.add(()=>k.setAttribute("role",_l.role)),k.hasAttribute("aria-roledescription")||_.add(()=>k.setAttribute("aria-roledescription",_l.roleDescription)),k.hasAttribute("aria-describedby")||_.add(()=>k.setAttribute("aria-describedby",l));for(const T of["aria-pressed","aria-grabbed"]){const I=String(S.isDragging);k.getAttribute(T)!==I&&_.add(()=>k.setAttribute(T,I))}const E=String(S.disabled);k.getAttribute("aria-disabled")!==E&&_.add(()=>k.setAttribute("aria-disabled",E))}}_.size>0&&Ss.schedule(w)}),this.destroy=()=>{super.destroy(),u?.remove(),f?.remove(),m.forEach(x=>x())}}};function Jp(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Qp=class extends it{constructor(e,t){super(e,t),this.manager=e;const n=ys(()=>{var r;return wn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=Ct(()=>{var r;const{dragOperation:s}=this.manager,{cursor:o="grabbing",nonce:a}=(r=this.options)!=null?r:{};if(s.status.initialized){const i=n.value,l=i.createElement("style");return a&&l.setAttribute("nonce",a),l.textContent=`* { cursor: ${o} !important; }`,i.head.appendChild(l),()=>l.remove()}})}},Is=new Map,Ou,Lu,Wu,Bu,Go,yr,zt,ei,zn,Vu,Nu,zu,ju,xn=class extends(Go=Fr,Bu=[de],Wu=[Ie],Lu=[Ie],Ou=[Ie],Go){constructor(e){super(e),We(zt,5,this),De(this,zn),De(this,yr,new Set),De(this,ei,We(zt,8,this,new Set)),We(zt,11,this),this.registerEffect(vn(this,zn,Vu))}register(e){return Ce(this,yr).add(e),()=>{Ce(this,yr).delete(e)}}addRoot(e){return we(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{we(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return _s((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return _s((e=t?.element)!=null?e:null)}get roots(){const{status:e}=this.manager.dragOperation;if(e.initializing||e.initialized){const t=[this.sourceRoot,this.targetRoot].filter(n=>n!=null);return new Set([...t,...this.additionalRoots])}return new Set}};zt=Kn(Go);yr=new WeakMap;ei=new WeakMap;zn=new WeakSet;Vu=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Ce(this,yr))t.push(vn(this,zn,Nu).call(this,n,r));return()=>{for(const n of t)n()}};Nu=function(e,t){let n=Is.get(e);n||(n=new Map,Is.set(e,n));let r=n.get(t);if(!r){const o=Za(e)?vn(this,zn,zu).call(this,e,n,t):vn(this,zn,ju).call(this,e,n,t);if(!o)return()=>{};r=o,n.set(t,r)}r.refCount++;let s=!1;return()=>{s||(s=!0,r.refCount--,r.refCount===0&&r.cleanup())}};zu=function(e,t,n){const r=e.createElement("style");r.textContent=n,e.head.prepend(r);const s=new MutationObserver(o=>{for(const a of o)for(const i of Array.from(a.removedNodes))if(i===r){e.head.prepend(r);return}});return s.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{s.disconnect(),r.remove(),t.delete(n),t.size===0&&Is.delete(e)}}};ju=function(e,t,n){!("adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets))&&process.env.NODE_ENV!=="production"&&console.error("Cannot inject styles: This browser doesn't support adoptedStyleSheets");const r=e.ownerDocument.defaultView,{CSSStyleSheet:s}=r??{};if(!s)return process.env.NODE_ENV!=="production"&&console.error("Cannot inject styles: CSSStyleSheet constructor not available"),null;const o=new s;return o.replaceSync(n),e.adoptedStyleSheets.push(o),{refCount:0,cleanup:()=>{var a;if(Ga(e)&&((a=e.host)!=null&&a.isConnected)){const i=e.adoptedStyleSheets.indexOf(o);i!==-1&&e.adoptedStyleSheets.splice(i,1)}t.delete(n),t.size===0&&Is.delete(e)}}};gt(zt,4,"additionalRoots",Bu,xn,ei);gt(zt,2,"sourceRoot",Wu,xn);gt(zt,2,"targetRoot",Lu,xn);gt(zt,2,"roots",Ou,xn);_n(zt,xn);var Lr="data-dnd-",Uo=`${Lr}dropping`,Je="--dnd-",Dt=`${Lr}dragging`,Ms=`${Lr}placeholder`,em=[Dt,Ms,"popover","aria-pressed","aria-grabbing"],tm=["view-transition-name"],nm=`
|
|
9
|
+
:is(:root,:host) [${Dt}] {
|
|
10
10
|
position: fixed !important;
|
|
11
11
|
pointer-events: none !important;
|
|
12
12
|
touch-action: none;
|
|
@@ -23,29 +23,29 @@
|
|
|
23
23
|
transition: var(${Je}transition) !important;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
:is(:root,:host) [${
|
|
26
|
+
:is(:root,:host) [${Ms}] {
|
|
27
27
|
transition: none;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
:is(:root,:host) [${
|
|
30
|
+
:is(:root,:host) [${Ms}='hidden'] {
|
|
31
31
|
visibility: hidden;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
[${
|
|
34
|
+
[${Dt}] * {
|
|
35
35
|
pointer-events: none !important;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
[${
|
|
38
|
+
[${Dt}]:not([${Uo}]) {
|
|
39
39
|
translate: var(${Je}translate) !important;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
[${
|
|
42
|
+
[${Dt}][style*='${Je}scale'] {
|
|
43
43
|
scale: var(${Je}scale) !important;
|
|
44
44
|
transform-origin: var(${Je}transform-origin) !important;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
@layer dnd-kit {
|
|
48
|
-
:where([${
|
|
48
|
+
:where([${Dt}][popover]) {
|
|
49
49
|
overflow: visible;
|
|
50
50
|
background: unset;
|
|
51
51
|
border: unset;
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
[${
|
|
62
|
+
[${Dt}]::backdrop, [${Lr}overlay]:not([${Dt}]) {
|
|
63
63
|
display: none;
|
|
64
64
|
visibility: hidden;
|
|
65
65
|
}
|
|
66
|
-
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Np(e,t="hidden"){return _e(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Xp(n,r.registry.droppables),a=[],o=Fh(n),{remove:i}=o;return Gp(s,o,a),Yp(o,t),o.remove=()=>{a.forEach(l=>l()),i.call(o)},o})}function Xp(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Wr}${Fa("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function Gp(e,t,n){for(const[r,s]of e){if(!r.element)continue;const a=`[${s}]`,o=t.matches(a)?t:t.querySelector(a);if(r.element.removeAttribute(s),!o)continue;const i=r.element;r.proxy=o,o.removeAttribute(s),ol.set(i,o),n.push(()=>{ol.delete(i),r.proxy=void 0})}}function Yp(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Es,t)}function Ru(e,t){return e===t?!0:Ln(e)===Ln(t)}function fl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&pn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>xr(t))}function Va(e){return e.tagName==="TR"}function Up(e,t,n){const r=new MutationObserver(s=>{let a=!1;for(const o of s){if(o.target!==e){a=!0;continue}if(o.type!=="attributes")continue;const i=o.attributeName;if(i.startsWith("aria-")||jp.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(gr(e)&&gr(t)){const c=e.style;for(const u of Array.from(t.style))c.getPropertyValue(u)===""&&t.style.removeProperty(u);for(const u of Array.from(c)){if(Zp.includes(u)||u.startsWith(Je))continue;const d=c.getPropertyValue(u);t.style.setProperty(u,d)}}}else l!==null?t.setAttribute(i,l):t.removeAttribute(i)}a&&n&&(t.innerHTML=e.innerHTML)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function Kp(e,t,n){const r=new MutationObserver(s=>{for(const a of s)if(a.addedNodes.length!==0)for(const o of Array.from(a.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),xr(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),xr(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function qp(e){return new ResizeObserver(()=>{var t,n;const r=new Lt(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},a=(e.width-r.width)*s.x+e.delta.x,o=(e.height-r.height)*s.y+e.delta.y,i=uu();if(e.styles.set({width:r.width-e.widthOffset,height:r.height-e.heightOffset,top:e.top+o+i.y,left:e.left+a+i.x},Je),(n=e.getElementMutationObserver())==null||n.takeRecords(),Va(e.element)&&Va(e.placeholder)){const l=Array.from(e.element.cells),c=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(l.map(u=>u.style.width));for(const[u,d]of l.entries()){const p=c[u];d.style.width=`${p.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Lt(e.feedbackElement)})}var Jp=250,Qp="ease";function em(e){var t,n,r,s;const{animation:a}=e;if(typeof a=="function"){const w=a({element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(w).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=Jp,easing:i=Qp}=a??{};xr(e.feedbackElement);const[,l]=(t=Dh(e.feedbackElement,w=>"translate"in w))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:Ru(e.feedbackElement,c)?null:void 0},d=new Lt(e.feedbackElement,u),p=(r=zo(jt(e.feedbackElement).translate))!=null?r:e.translate,h=new Lt(c,u),g=Tr.delta(d,h,e.alignment),b={x:p.x-g.x,y:p.y-g.y},y=Math.round(d.intrinsicHeight)!==Math.round(h.intrinsicHeight)?{minHeight:[`${d.intrinsicHeight}px`,`${h.intrinsicHeight}px`],maxHeight:[`${d.intrinsicHeight}px`,`${h.intrinsicHeight}px`]}:{},m=Math.round(d.intrinsicWidth)!==Math.round(h.intrinsicWidth)?{minWidth:[`${d.intrinsicWidth}px`,`${h.intrinsicWidth}px`],maxWidth:[`${d.intrinsicWidth}px`,`${h.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Je),e.feedbackElement.setAttribute(La,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),fp({element:e.feedbackElement,keyframes:No(Cr(Cr({},y),m),{translate:[`${p.x}px ${p.y}px 0`,`${b.x}px ${b.y}px 0`]}),options:{duration:du(kt(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(La),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Pu,za,kr,Yo,ds,Wu,Fu,Sr=class extends(za=lt,Pu=[ue],za){constructor(t,n){super(t,n),$e(this,ds),$e(this,Yo,Pe(kr,8,this)),Pe(kr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(wn),s=r?.register(Hp);if(s){const a=this.destroy.bind(this);this.destroy=()=>{s(),a()}}this.registerEffect(mn(this,ds,Wu).bind(this,r)),this.registerEffect(mn(this,ds,Fu))}};kr=Un(za);Yo=new WeakMap;ds=new WeakSet;Wu=function(e){const{overlay:t}=this;if(!t||!e)return;const n=bs(t);if(n)return e.addRoot(n)};Fu=function(){var e,t,n;const{state:r,manager:s,options:a}=this,{dragOperation:o}=s,{position:i,source:l,status:c}=o;if(c.idle){r.current={},r.initial={};return}if(!l)return;const{element:u,feedback:d}=l;if(!u||d==="none"||!c.initialized||c.initializing)return;const{initial:p}=r,h=(e=this.overlay)!=null?e:u,g=Vn(h),b=Vn(u),y=!Ru(u,h),m=new Lt(u,{frameTransform:y?b:null,ignoreTransforms:!y}),w={x:b.scaleX/g.scaleX,y:b.scaleY/g.scaleY};let{width:_,height:v,top:x,left:S}=m;y&&(_=_/w.x,v=v/w.y);const k=new yp(h),{transition:E,translate:I,boxSizing:A,paddingBlockStart:T,paddingBlockEnd:P,paddingInlineStart:M,paddingInlineEnd:F,borderInlineStartWidth:O,borderInlineEndWidth:H,borderBlockStartWidth:K,borderBlockEndWidth:ne}=jt(u),B=d==="clone",re=A==="content-box",se=re?parseInt(M)+parseInt(F)+parseInt(O)+parseInt(H):0,ae=re?parseInt(T)+parseInt(P)+parseInt(K)+parseInt(ne):0,ie=d!=="move"&&!this.overlay?Np(l,B?"clone":"hidden"):null,me=_e(()=>Zo(s.dragOperation.activatorEvent));if(I!=="none"){const ee=zo(I);ee&&!p.translate&&(p.translate=ee)}if(!p.transformOrigin){const ee=_e(()=>i.current);p.transformOrigin={x:(ee.x-S*g.scaleX-g.x)/(_*g.scaleX),y:(ee.y-x*g.scaleY-g.y)/(v*g.scaleY)}}const{transformOrigin:ye}=p,De=x*g.scaleY+g.y,X=S*g.scaleX+g.x;if(!p.coordinates&&(p.coordinates={x:X,y:De},w.x!==1||w.y!==1)){const{scaleX:ee,scaleY:be}=b,{x:Ee,y:je}=ye;p.coordinates.x+=(_*ee-_)*Ee,p.coordinates.y+=(v*be-v)*je}p.dimensions||(p.dimensions={width:_,height:v}),p.frameTransform||(p.frameTransform=g);const Z={x:p.coordinates.x-X,y:p.coordinates.y-De},de={width:(p.dimensions.width*p.frameTransform.scaleX-_*g.scaleX)*ye.x,height:(p.dimensions.height*p.frameTransform.scaleY-v*g.scaleY)*ye.y},G={x:Z.x/g.scaleX+de.width,y:Z.y/g.scaleY+de.height},$={left:S+G.x,top:x+G.y};h.setAttribute($t,"true");const he=_e(()=>o.transform),We=(t=p.translate)!=null?t:{x:0,y:0},q=he.x*g.scaleX+We.x,ge=he.y*g.scaleY+We.y,Ve=uu();k.set({width:_-se,height:v-ae,top:$.top+Ve.y,left:$.left+Ve.x,translate:`${q}px ${ge}px 0`,transition:E?`${E}, translate 0ms linear`:"",scale:y?`${w.x} ${w.y}`:"","transform-origin":`${ye.x*100}% ${ye.y*100}%`},Je),ie&&(u.insertAdjacentElement("afterend",ie),a?.rootElement&&(typeof a.rootElement=="function"?a.rootElement(l):a.rootElement).appendChild(u)),Pa(h)&&(h.hasAttribute("popover")||h.setAttribute("popover","manual"),xr(h),h.addEventListener("beforetoggle",fl));let Ne,U,Re;const ze=qp({placeholder:ie,element:u,feedbackElement:h,frameTransform:g,transformOrigin:ye,width:_,height:v,top:x,left:S,widthOffset:se,heightOffset:ae,delta:G,styles:k,dragOperation:o,getElementMutationObserver:()=>Ne,getSavedCellWidths:()=>Re,setSavedCellWidths:ee=>{Re=ee}}),xe=new Lt(h);_e(()=>o.shape=xe);const Xe=kt(h),Ue=ee=>{this.manager.actions.stop({event:ee})},at=du(Xe);me&&Xe.addEventListener("resize",Ue),_e(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),ie&&(ze.observe(ie),Ne=Up(u,ie,B),U=Kp(u,ie,h));const yt=(n=s.dragOperation.source)==null?void 0:n.id,At=()=>{var ee;if(!me||yt==null)return;const be=s.registry.draggables.get(yt),Ee=(ee=be?.handle)!=null?ee:be?.element;hn(Ee)&&Ee.focus()},N=()=>{var ee;if(Ne?.disconnect(),U?.disconnect(),ze.disconnect(),Xe.removeEventListener("resize",Ue),Pa(h)&&(h.removeEventListener("beforetoggle",fl),h.removeAttribute("popover")),h.removeAttribute($t),k.reset(),Re&&Va(u)){const Ee=Array.from(u.cells);for(const[je,bt]of Ee.entries())bt.style.width=(ee=Re[je])!=null?ee:""}l.status="idle";const be=r.current.translate!=null;ie&&(be||ie.parentElement!==h.parentElement)&&h.isConnected&&ie.replaceWith(h),ie?.remove()},le=a?.dropAnimation,Fe=this,Ke=$r(()=>{var ee;const{transform:be,status:Ee}=o;if(!(!be.x&&!be.y&&!r.current.translate)&&Ee.dragging){const je=(ee=p.translate)!=null?ee:{x:0,y:0},bt={x:be.x/g.scaleX+je.x,y:be.y/g.scaleY+je.y},V=r.current.translate,Y=_e(()=>o.modifiers),Q=_e(()=>{var ve;return(ve=o.shape)==null?void 0:ve.current}),Ce=me&&!at?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(k.set({transition:`${E}, translate ${Ce}`,translate:`${bt.x}px ${bt.y}px 0`},Je),Ne?.takeRecords(),Q&&Q!==xe&&V&&!Y.length){const ve=Tt.delta(bt,V);o.shape=Tr.from(Q.boundingRectangle).translate(ve.x*g.scaleX,ve.y*g.scaleY)}else o.shape=new Lt(h);r.current.translate=bt}},function(){if(o.status.dropped){this.dispose(),l.status="dropping";const ee=Fe.dropAnimation!==void 0?Fe.dropAnimation:le;let be=r.current.translate;const Ee=be!=null;if(!be&&u!==h&&(be={x:0,y:0}),!be||ee===null){N();return}s.renderer.rendering.then(()=>{em({element:u,feedbackElement:h,placeholder:ie,translate:be,moved:Ee,transition:E,alignment:l.alignment,styles:k,animation:ee??void 0,getElementMutationObserver:()=>Ne,cleanup:N,restoreFocus:At})})}});return()=>{N(),Ke()}};gt(kr,4,"overlay",Pu,Sr,Yo);bn(kr,Sr);Sr.configure=Gn(Sr);var ja=Sr,qn=!0,tm=!1,Ou,Bu,Lu,Vu,Gt,Uo,Ko;Vu=(Lu=[ue],_t.Forward),Bu=(Ou=[ue],_t.Reverse);var Er=class{constructor(){$e(this,Uo,Pe(Gt,8,this,qn)),Pe(Gt,11,this),$e(this,Ko,Pe(Gt,12,this,qn)),Pe(Gt,15,this)}isLocked(e){return e===_t.Idle?!1:e==null?this[_t.Forward]===qn&&this[_t.Reverse]===qn:this[e]===qn}unlock(e){e!==_t.Idle&&(this[e]=tm)}};Gt=Un(null);Uo=new WeakMap;Ko=new WeakMap;gt(Gt,4,Vu,Lu,Er,Uo);gt(Gt,4,Bu,Ou,Er,Ko);bn(Gt,Er);var nm=[_t.Forward,_t.Reverse],hl=class{constructor(){this.x=new Er,this.y=new Er}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},rm=class extends lt{constructor(e){super(e);const t=Mr(new hl);let n=null;this.signal=t,Ct(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new hl;return}const{delta:s}=e.dragOperation.position;if(n){const a={x:pl(s.x,n.x),y:pl(s.y,n.y)},o=t.peek();Kt(()=>{for(const i of vc)for(const l of nm)a[i]===l&&o[i].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function pl(e,t){return Math.sign(e-t)}var zu,Za,Ir,qo,Nt,Ha,Bs=class extends(Za=Rr,zu=[ue],Za){constructor(e){super(e),$e(this,qo,Pe(Ir,8,this,!1)),Pe(Ir,11,this),$e(this,Nt),$e(this,Ha,()=>{if(!Se(this,Nt))return;const{element:a,by:o}=Se(this,Nt);o.y&&(a.scrollTop+=o.y),o.x&&(a.scrollLeft+=o.x)}),this.scroll=a=>{var o;if(this.disabled)return!1;const i=this.getScrollableElements();if(!i)return rt(this,Nt,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:u}=a??{},d=u?{x:ml(u.x),y:ml(u.y)}:void 0,p=d?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const h of i){const g=Uh(h,u);if(g.x||g.y){const{speed:b,direction:y}=ip(h,c,d);if(p)for(const m of vc)p[m].isLocked(y[m])&&(b[m]=0,y[m]=0);if(y.x||y.y){const{x:m,y:w}=u??y,_=m*b.x,v=w*b.y;if(_||v){const x=(o=Se(this,Nt))==null?void 0:o.by;if(this.autoScrolling&&x&&(x.x&&!_||x.y&&!v))continue;return rt(this,Nt,{element:h,by:{x:_,y:v}}),xs.schedule(Se(this,Ha)),!0}}}}}return rt(this,Nt,void 0),!1};let t=null,n=null;const r=gs(()=>{const{position:a,source:o}=e.dragOperation;if(!a)return null;const i=fu(bs(o?.element),a.current);return i&&(t=i),i??t}),s=gs(()=>{const a=r.value,{documentElement:o}=yn(a);if(!a||a===o){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=Wa(l,{excludeElement:!1});return n=c,c}}if(a){const i=Wa(a,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},br);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new rm(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!Zo(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Ir=Un(Za);qo=new WeakMap;Nt=new WeakMap;Ha=new WeakMap;gt(Ir,4,"autoScrolling",zu,Bs,qo);bn(Ir,Bs);function ml(e){return e>0?_t.Forward:e<0?_t.Reverse:_t.Idle}var sm=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},am=new sm(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),om=10,ju=class extends lt{constructor(e,t){super(e);const n=e.registry.plugins.get(Bs);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=Ct(()=>{if(this.disabled)return;const{position:r,status:s}=e.dragOperation;if(s.dragging)if(n.scroll()){n.autoScrolling=!0;const o=setInterval(()=>am.schedule(n.scroll),om);return()=>{clearInterval(o)}}else n.autoScrolling=!1})}},gl={capture:!0,passive:!0},dr,im=class extends Rr{constructor(e){super(e),$e(this,dr),this.handleScroll=()=>{Se(this,dr)==null&&rt(this,dr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),rt(this,dr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=Ct(()=>{var n,r,s;if(t.status.dragging){const o=(s=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?s:document;return o.addEventListener("scroll",this.handleScroll,gl),()=>{o.removeEventListener("scroll",this.handleScroll,gl)}}})}};dr=new WeakMap;var lm=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.destroy=Ct(()=>{var n;const{dragOperation:r}=this.manager,{nonce:s}=(n=this.options)!=null?n:{};if(r.status.initialized){const a=document.createElement("style");return s&&a.setAttribute("nonce",s),a.textContent="* { user-select: none !important; -webkit-user-select: none !important; }",document.head.appendChild(a),ia(),document.addEventListener("selectionchange",ia,{capture:!0}),()=>{document.removeEventListener("selectionchange",ia,{capture:!0}),a.remove()}}})}};function ia(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var fr=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),Dn,Is=class extends On{constructor(t,n){super(t),this.manager=t,this.options=n,$e(this,Dn,[]),this.listeners=new hu,this.handleSourceKeyDown=(r,s,a)=>{if(this.disabled||r.defaultPrevented||!pn(r.target)||s.disabled)return;const{keyboardCodes:o=fr.keyboardCodes,preventActivation:i=fr.preventActivation}=a??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(i?.(r,s)||this.handleStart(r,s,a))}}bind(t,n=this.options){return Ct(()=>{var s;const a=(s=t.handle)!=null?s:t.element,o=i=>{Zo(i)&&this.handleSourceKeyDown(i,t,n)};if(a)return a.addEventListener("keydown",o),()=>{a.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:s}=n;if(!s)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),cp(s);const{center:a}=new Lt(s);if(this.manager.actions.start({event:t,coordinates:{x:a.x,y:a.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const i=yn(s),l=[this.listeners.bind(i,[{type:"keydown",listener:c=>this.handleKeyDown(c,n,r),options:{capture:!0}}])];Se(this,Dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=fr.keyboardCodes}=r??{};if(En(t,[...s.end,...s.cancel])){t.preventDefault();const a=En(t,s.cancel);this.handleEnd(t,a);return}En(t,s.up)?this.handleMove("up",t):En(t,s.down)&&this.handleMove("down",t),En(t,s.left)?this.handleMove("left",t):En(t,s.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,s;const{shape:a}=this.manager.dragOperation,o=n.shiftKey?5:1;let i={x:0,y:0},l=(s=(r=this.options)==null?void 0:r.offset)!=null?s:fr.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!a){switch(t){case"up":i={x:0,y:-l.y*o};break;case"down":i={x:0,y:l.y*o};break;case"left":i={x:-l.x*o,y:0};break;case"right":i={x:l.x*o,y:0};break}(i.x||i.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:i}))}}sideEffects(){const t=this.manager.registry.plugins.get(ju);t?.disabled===!1&&(t.disable(),Se(this,Dn).push(()=>{t.enable()}))}cleanup(){Se(this,Dn).forEach(t=>t()),rt(this,Dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};Dn=new WeakMap;Is.configure=Gn(Is);Is.defaults=fr;var cm=Is;function En(e,t){return t.includes(e.code)}var un,um=class extends Kc{constructor(){super(...arguments),$e(this,un)}onEvent(e){switch(e.type){case"pointerdown":rt(this,un,Bn(e));break;case"pointermove":if(!Se(this,un))return;const{x:t,y:n}=Bn(e),r={x:t-Se(this,un).x,y:n-Se(this,un).y},{tolerance:s}=this.options;if(s&&Aa(r,s)){this.abort();return}Aa(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){rt(this,un,void 0)}};un=new WeakMap;var Rn,dn,dm=class extends Kc{constructor(){super(...arguments),$e(this,Rn),$e(this,dn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,dn,Bn(e)),rt(this,Rn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Se(this,dn))return;const{x:t,y:n}=Bn(e),r={x:t-Se(this,dn).x,y:n-Se(this,dn).y};Aa(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Se(this,Rn)&&(clearTimeout(Se(this,Rn)),rt(this,dn,void 0),rt(this,Rn,void 0))}};Rn=new WeakMap;dn=new WeakMap;var Ot=class{};Ot.Delay=dm;Ot.Distance=um;var Na=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&pn(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Ot.Delay({value:250,tolerance:5})]:wp(s)&&!e.defaultPrevented?[new Ot.Delay({value:200,tolerance:0})]:[new Ot.Delay({value:200,tolerance:10}),new Ot.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;return r===t.element||r===t.handle||!pn(r)||(n=t.handle)!=null&&n.contains(r)?!1:Bh(r)}}),Pn,As=class extends On{constructor(t,n){super(t),this.manager=t,this.options=n,$e(this,Pn,new Set),this.listeners=new hu,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:s}=this.latest;!r||!s||this.manager.actions.move({event:r,to:s})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:s=Na.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return Ct(()=>{var s;const a=new AbortController,{signal:o}=a,i=c=>{bp(c)&&this.handlePointerDown(c,t,n)};let l=[(s=t.handle)!=null?s:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const c of l)c&&(pm(c.ownerDocument.defaultView),c.addEventListener("pointerdown",i,{signal:o}));return()=>a.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!pn(t.target)||n.disabled||fm(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=Na.preventActivation}=r??{};if(s?.(t,n))return;const{target:a}=t,o=hn(a)&&a.draggable&&a.getAttribute("draggable")==="true",i=Vn(n.element),{x:l,y:c}=Bn(t);this.initialCoordinates={x:l*i.scaleX+i.x,y:c*i.scaleY+i.y};const u=this.activationConstraints(t,n,r);t.sensor=this;const d=new Ah(u,b=>this.handleStart(n,b));d.signal.onabort=()=>this.handleCancel(t),d.onEvent(t),this.controller=d;const p=Da(),h=this.listeners.bind(p,[{type:"pointermove",listener:b=>this.handlePointerMove(b,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:es,options:{capture:!0}}]),g=()=>{h(),this.initialCoordinates=void 0};Se(this,Pn).add(g)}handlePointerMove(t,n){var r,s;if(((r=this.controller)==null?void 0:r.activated)===!1){(s=this.controller)==null||s.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const a=Bn(t),o=Vn(n.element);a.x=a.x*o.scaleX+o.x,a.y=a.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=a,xs.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:s}=this;if(!s||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:s,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const i=yn(n.target).body;i.setPointerCapture(n.pointerId);const l=pn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:es,options:{passive:!1}},{type:"click",listener:es},{type:"contextmenu",listener:es},{type:"keydown",listener:this.handleKeyDown}]);Se(this,Pn).add(c)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){this.latest={event:void 0,coordinates:void 0},Se(this,Pn).forEach(t=>t()),Se(this,Pn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};Pn=new WeakMap;As.configure=Gn(As);As.defaults=Na;var Xa=As;function fm(e){return"sensor"in e}function es(e){e.preventDefault()}function hm(){}var vl=new WeakSet;function pm(e){!e||vl.has(e)||(e.addEventListener("touchmove",hm,{capture:!1,passive:!1}),vl.add(e))}var Wn={modifiers:[],plugins:[Lp,ju,zp,ja,lm],sensors:[Xa,cm]},Jo=class extends Th{constructor(e={}){const t=Bt(e.plugins,Wn.plugins),n=Bt(e.sensors,Wn.sensors),r=Bt(e.modifiers,Wn.modifiers);super(No(Cr({},e),{plugins:[im,Bs,wn,...t],sensors:n,modifiers:r}))}},Zu,Hu,Nu,Ga,Et,Qo,ei,ti,Fr=class extends(Ga=Dt,Nu=[ue],Hu=[ue],Zu=[ue],Ga){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:a,feedback:o="default"}=n,i=Cu(n,["element","effects","handle","feedback"]);super(Cr({effects:()=>[...s(),()=>{var l,c;const{manager:u}=this;if(!u)return;const p=((c=(l=this.sensors)==null?void 0:l.map(ho))!=null?c:[...u.sensors]).map(h=>{const g=h instanceof On?h:u.registry.register(h.plugin),b=h instanceof On?void 0:h.options;return g.bind(this,b)});return function(){p.forEach(g=>g())}}]},i),t),$e(this,Qo,Pe(Et,8,this)),Pe(Et,11,this),$e(this,ei,Pe(Et,12,this)),Pe(Et,15,this),$e(this,ti,Pe(Et,16,this)),Pe(Et,19,this),this.element=r,this.handle=a,this.feedback=o}};Et=Un(Ga);Qo=new WeakMap;ei=new WeakMap;ti=new WeakMap;gt(Et,4,"handle",Nu,Fr,Qo);gt(Et,4,"element",Hu,Fr,ei);gt(Et,4,"feedback",Zu,Fr,ti);bn(Et,Fr);var Xu,Gu,Ya,Yt,ni,la,Yu,Uu,yr,ri,Ku=class extends(Ya=Rt,Gu=[ue],Xu=[ue],Ya){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,a=Cu(n,["element","effects"]);const{collisionDetector:o=kp}=a,i=c=>{const{manager:u,element:d}=this;if(!d||c===null){this.shape=void 0;return}if(!u)return;const p=new Lt(d),h=_e(()=>this.shape);return p&&h?.equals(p)?h:(this.shape=p,p)},l=Mr(!1);super(No(Cr({},a),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:c,manager:u}=this;if(!u)return;const{dragOperation:d}=u,{source:p}=d;l.value=!!(p&&d.status.initialized&&c&&!this.disabled&&this.accepts(p))},()=>{const{element:c}=this;if(l.value&&c){const u=new Yh(c,i);return()=>{u.disconnect(),this.shape=void 0}}},()=>{var c;if((c=this.manager)!=null&&c.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),$e(this,yr),$e(this,ni,Pe(Yt,8,this)),Pe(Yt,11,this),$e(this,ri,Pe(Yt,12,this)),Pe(Yt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){rt(this,yr,e,Uu)}get element(){var e;return(e=this.proxy)!=null?e:Se(this,yr,Yu)}};Yt=Un(Ya);ni=new WeakMap;yr=new WeakSet;ri=new WeakMap;la=gt(Yt,20,"#element",Gu,yr,ni),Yu=la.get,Uu=la.set;gt(Yt,4,"proxy",Xu,Ku,ri);bn(Yt,Ku);function mm(e){return e!=null&&typeof e=="object"&&"current"in e}function Ms(e){var t;if(e!=null)return mm(e)?(t=e.current)!=null?t:void 0:e}var gm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ls=gm?f.useLayoutEffect:f.useEffect;function vm(){const e=f.useState(0)[1];return f.useCallback(()=>{e(t=>t+1)},[e])}function ym(e,t){const n=f.useRef(new Map),r=vm();return Ls(()=>{if(!e){n.current.clear();return}return Ct(()=>{var s;let a=!1,o=!1;for(const i of n.current){const[l]=i,c=_e(()=>i[1]),u=e[l];c!==u&&(a=!0,n.current.set(l,u),o=(s=t?.(l,c,u))!=null?s:!1)}a&&(o?ro.flushSync(r):r())})},[e]),f.useMemo(()=>e&&new Proxy(e,{get(s,a){const o=s[a];return n.current.set(a,o),o}}),[e])}function an(e,t,n=f.useEffect,r=Object.is){const s=f.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}function yl(e,t){const n=f.useRef(Ms(e));Ls(()=>{const r=Ms(e);r!==n.current&&(n.current=r,t(r))})}var bm=Object.defineProperty,wm=Object.defineProperties,_m=Object.getOwnPropertyDescriptors,bl=Object.getOwnPropertySymbols,xm=Object.prototype.hasOwnProperty,Cm=Object.prototype.propertyIsEnumerable,wl=(e,t,n)=>t in e?bm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,km=(e,t)=>{for(var n in t||(t={}))xm.call(t,n)&&wl(e,n,t[n]);if(bl)for(var n of bl(t))Cm.call(t,n)&&wl(e,n,t[n]);return e},Sm=(e,t)=>wm(e,_m(t)),Em=new Jo,Im=f.createContext(Em);f.memo(f.forwardRef(({children:e},t)=>{const[n,r]=f.useState(0),s=f.useRef(null),a=f.useRef(null),o=f.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{a.current=l})),f.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Ls(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),f.useImperativeHandle(t,()=>o),null}));function Am(){return f.useContext(Im)}function Mm(e){var t;const n=(t=Am())!=null?t:void 0,[r]=f.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ls(r.register,[n,r]),r}function ca(e){const{disabled:t,data:n,element:r,handle:s,id:a,modifiers:o,sensors:i}=e,l=Mm(u=>new Fr(Sm(km({},e),{register:!1,handle:Ms(s),element:Ms(r)}),u)),c=ym(l,$m);return an(a,()=>l.id=a),yl(s,u=>l.handle=u),yl(r,u=>l.element=u),an(n,()=>n&&(l.data=n)),an(t,()=>l.disabled=t===!0),an(i,()=>l.sensors=i),an(o,()=>l.modifiers=o,void 0,br),an(e.feedback,()=>{var u;return l.feedback=(u=e.feedback)!=null?u:"default"}),an(e.alignment,()=>l.alignment=e.alignment),{draggable:c,get isDragging(){return c.isDragging},get isDropping(){return c.isDropping},get isDragSource(){return c.isDragSource},handleRef:f.useCallback(u=>{l.handle=u??void 0},[l]),ref:f.useCallback(u=>{var d,p;!u&&((d=l.element)!=null&&d.isConnected)&&!((p=l.manager)!=null&&p.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function $m(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var Tm=Object.create,qu=Object.defineProperty,Dm=Object.getOwnPropertyDescriptor,Ju=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Vs=e=>{throw TypeError(e)},Rm=(e,t,n)=>t in e?qu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pm=e=>{var t;return[,,,Tm((t=e?.[Ju("metadata")])!=null?t:null)]},Qu=["class","method","getter","setter","accessor","field","value","get","set"],ed=e=>e!==void 0&&typeof e!="function"?Vs("Function expected"):e,Wm=(e,t,n,r,s)=>({kind:Qu[e],name:t,metadata:r,addInitializer:a=>n._?Vs("Already initialized"):s.push(ed(a||null))}),Fm=(e,t)=>Rm(t,Ju("metadata"),e[3]),Om=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},td=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,d=!1,p=!1,h=2,g=Qu[u+5],b=e[h]||(e[h]=[]),y=(s=s.prototype,Dm(s,n)),m=r.length-1;m>=0;m--)l=Wm(u,n,i={},e[3],b),l.static=d,l.private=p,c=l.access={has:w=>n in w},c.get=w=>w[n],o=(0,r[m])(y[g],l),i._=1,ed(o)&&(y[g]=o);return y&&qu(s,n,y),s},nd=(e,t,n)=>t.has(e)||Vs("Cannot "+n),Bm=(e,t,n)=>(nd(e,t,"read from private field"),t.get(e)),Lm=(e,t,n)=>t.has(e)?Vs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Vm=(e,t,n,r)=>(nd(e,t,"write to private field"),t.set(e,n),n),Jn=class Ua{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ua(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Ua(t,n)}},rd,sd,Ka,fs,Or,si=class extends(Ka=Jt,sd=[Ae],rd=[Ae],Ka){constructor(t){const n=Jn.from(t);super(n,(r,s)=>Jn.equals(r,s)),Om(Or,5,this),Lm(this,fs,0),this.velocity={x:0,y:0}}get delta(){return Jn.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Jn.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-Bm(this,fs),i=l=>Math.round(l/o*100);Kt(()=>{Vm(this,fs,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Jn.from(t)),this.velocity={x:0,y:0}}};Or=Pm(Ka);fs=new WeakMap;td(Or,2,"delta",sd,si);td(Or,2,"direction",rd,si);Fm(Or,si);var ad=(e=>(e.Horizontal="x",e.Vertical="y",e))(ad||{});Object.values(ad);const zm=new Map([["bold",D.createElement(D.Fragment,null,D.createElement("path",{d:"M144,128a16,16,0,1,1-16-16A16,16,0,0,1,144,128ZM60,112a16,16,0,1,0,16,16A16,16,0,0,0,60,112Zm136,0a16,16,0,1,0,16,16A16,16,0,0,0,196,112Z"}))],["duotone",D.createElement(D.Fragment,null,D.createElement("path",{d:"M240,96v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V96A16,16,0,0,1,32,80H224A16,16,0,0,1,240,96Z",opacity:"0.2"}),D.createElement("path",{d:"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"}))],["fill",D.createElement(D.Fragment,null,D.createElement("path",{d:"M224,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V96A16,16,0,0,0,224,80ZM60,140a12,12,0,1,1,12-12A12,12,0,0,1,60,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,196,140Z"}))],["light",D.createElement(D.Fragment,null,D.createElement("path",{d:"M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM60,118a10,10,0,1,0,10,10A10,10,0,0,0,60,118Zm136,0a10,10,0,1,0,10,10A10,10,0,0,0,196,118Z"}))],["regular",D.createElement(D.Fragment,null,D.createElement("path",{d:"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"}))],["thin",D.createElement(D.Fragment,null,D.createElement("path",{d:"M136,128a8,8,0,1,1-8-8A8,8,0,0,1,136,128Zm-76-8a8,8,0,1,0,8,8A8,8,0,0,0,60,120Zm136,0a8,8,0,1,0,8,8A8,8,0,0,0,196,120Z"}))]]),jm=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),Zm=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),Hm=new Map([["bold",D.createElement(D.Fragment,null,D.createElement("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"}))],["duotone",D.createElement(D.Fragment,null,D.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),D.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["fill",D.createElement(D.Fragment,null,D.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["light",D.createElement(D.Fragment,null,D.createElement("path",{d:"M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"}))],["regular",D.createElement(D.Fragment,null,D.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["thin",D.createElement(D.Fragment,null,D.createElement("path",{d:"M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"}))]]),Nm=f.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Br=D.forwardRef((e,t)=>{const{alt:n,color:r,size:s,weight:a,mirrored:o,children:i,weights:l,...c}=e,{color:u="currentColor",size:d,weight:p="regular",mirrored:h=!1,...g}=D.useContext(Nm);return D.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:s??d,height:s??d,fill:r??u,viewBox:"0 0 256 256",transform:o||h?"scale(-1, 1)":void 0,...g,...c},!!n&&D.createElement("title",null,n),i,l.get(a??p))});Br.displayName="IconBase";const od=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:zm}));od.displayName="DotsThreeIcon";const id=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:jm}));id.displayName="SpeakerHighIcon";const ld=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:Zm}));ld.displayName="SpeakerLowIcon";const cd=D.forwardRef((e,t)=>D.createElement(Br,{ref:t,...e,weights:Hm}));cd.displayName="XIcon";const Xm=cd;R.span`
|
|
66
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function rm(e,t="hidden"){return we(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=sm(n,r.registry.droppables),o=[],a=Xh(n),{remove:i}=a;return om(s,a,o),am(a,t),a.remove=()=>{o.forEach(l=>l()),i.call(a)},a})}function sm(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Lr}${Zo("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function om(e,t,n){for(const[r,s]of e){if(!r.element)continue;const o=`[${s}]`,a=t.matches(o)?t:t.querySelector(o);if(r.element.removeAttribute(s),!a)continue;const i=r.element;r.proxy=a,a.removeAttribute(s),gl.set(i,a),n.push(()=>{gl.delete(i),r.proxy=void 0})}}function am(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Ms,t)}function Zu(e,t){return e===t?!0:Vn(e)===Vn(t)}function xl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&gn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>Sr(t))}function Xo(e){return e.tagName==="TR"}function im(e,t,n){const r=new MutationObserver(s=>{let o=!1;for(const a of s){if(a.target!==e){o=!0;continue}if(a.type!=="attributes")continue;const i=a.attributeName;if(i.startsWith("aria-")||em.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(vr(e)&&vr(t)){const c=e.style;for(const u of Array.from(t.style))c.getPropertyValue(u)===""&&t.style.removeProperty(u);for(const u of Array.from(c)){if(tm.includes(u)||u.startsWith(Je))continue;const f=c.getPropertyValue(u);t.style.setProperty(u,f)}}}else l!==null?t.setAttribute(i,l):t.removeAttribute(i)}o&&n&&(t.innerHTML=e.innerHTML)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function lm(e,t,n){const r=new MutationObserver(s=>{for(const o of s)if(o.addedNodes.length!==0)for(const a of Array.from(o.addedNodes)){if(a.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),Sr(n);return}if(a.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),Sr(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function cm(e){return new ResizeObserver(()=>{var t,n;const r=new Nt(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-r.width)*s.x+e.delta.x,a=(e.height-r.height)*s.y+e.delta.y,i=_u();if(e.styles.set({width:r.width-e.widthOffset,height:r.height-e.heightOffset,top:e.top+a+i.y,left:e.left+o+i.x},Je),(n=e.getElementMutationObserver())==null||n.takeRecords(),Xo(e.element)&&Xo(e.placeholder)){const l=Array.from(e.element.cells),c=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(l.map(u=>u.style.width));for(const[u,f]of l.entries()){const h=c[u];f.style.width=`${h.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Nt(e.feedbackElement)})}var um=250,dm="ease";function fm(e){var t,n,r,s;const{animation:o}=e;if(typeof o=="function"){const b=o({element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(b).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:a=um,easing:i=dm}=o??{};Sr(e.feedbackElement);const[,l]=(t=Zh(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:Zu(e.feedbackElement,c)?null:void 0},f=new Nt(e.feedbackElement,u),h=(r=Xa(Zt(e.feedbackElement).translate))!=null?r:e.translate,d=new Nt(c,u),p=Dr.delta(f,d,e.alignment),v={x:h.x-p.x,y:h.y-p.y},y=Math.round(f.intrinsicHeight)!==Math.round(d.intrinsicHeight)?{minHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`],maxHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`]}:{},m=Math.round(f.intrinsicWidth)!==Math.round(d.intrinsicWidth)?{minWidth:[`${f.intrinsicWidth}px`,`${d.intrinsicWidth}px`],maxWidth:[`${f.intrinsicWidth}px`,`${d.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Je),e.feedbackElement.setAttribute(Uo,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),Sp({element:e.feedbackElement,keyframes:Ja(kr(kr({},y),m),{translate:[`${h.x}px ${h.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:xu(St(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?a:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(Uo),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Hu,Yo,Er,ti,fs,Gu,Uu,Ir=class extends(Yo=it,Hu=[de],Yo){constructor(t,n){super(t,n),De(this,fs),De(this,ti,We(Er,8,this)),We(Er,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(xn),s=r?.register(nm);if(s){const o=this.destroy.bind(this);this.destroy=()=>{s(),o()}}this.registerEffect(vn(this,fs,Gu).bind(this,r)),this.registerEffect(vn(this,fs,Uu))}};Er=Kn(Yo);ti=new WeakMap;fs=new WeakSet;Gu=function(e){const{overlay:t}=this;if(!t||!e)return;const n=_s(t);if(n)return e.addRoot(n)};Uu=function(){var e,t,n;const{state:r,manager:s,options:o}=this,{dragOperation:a}=s,{position:i,source:l,status:c}=a;if(c.idle){r.current={},r.initial={};return}if(!l)return;const{element:u,feedback:f}=l;if(!u||f==="none"||!c.initialized||c.initializing)return;const{initial:h}=r,d=(e=this.overlay)!=null?e:u,p=Nn(d),v=Nn(u),y=!Zu(u,d),m=new Nt(u,{frameTransform:y?v:null,ignoreTransforms:!y}),b={x:v.scaleX/p.scaleX,y:v.scaleY/p.scaleY};let{width:_,height:w,top:x,left:S}=m;y&&(_=_/b.x,w=w/b.y);const k=new Tp(d),{transition:E,translate:T,boxSizing:I,paddingBlockStart:M,paddingBlockEnd:$,paddingInlineStart:A,paddingInlineEnd:R,borderInlineStartWidth:W,borderInlineEndWidth:q,borderBlockStartWidth:z,borderBlockEndWidth:J}=Zt(u),ee=f==="clone",j=I==="content-box",se=j?parseInt(A)+parseInt(R)+parseInt(W)+parseInt(q):0,U=j?parseInt(M)+parseInt($)+parseInt(z)+parseInt(J):0,ie=f!=="move"&&!this.overlay?rm(l,ee?"clone":"hidden"):null,le=we(()=>Ka(s.dragOperation.activatorEvent));if(T!=="none"){const oe=Xa(T);oe&&!h.translate&&(h.translate=oe)}if(!h.transformOrigin){const oe=we(()=>i.current);h.transformOrigin={x:(oe.x-S*p.scaleX-p.x)/(_*p.scaleX),y:(oe.y-x*p.scaleY-p.y)/(w*p.scaleY)}}const{transformOrigin:ge}=h,Se=x*p.scaleY+p.y,N=S*p.scaleX+p.x;if(!h.coordinates&&(h.coordinates={x:N,y:Se},b.x!==1||b.y!==1)){const{scaleX:oe,scaleY:he}=v,{x:Xe,y:At}=ge;h.coordinates.x+=(_*oe-_)*Xe,h.coordinates.y+=(w*he-w)*At}h.dimensions||(h.dimensions={width:_,height:w}),h.frameTransform||(h.frameTransform=p);const G={x:h.coordinates.x-N,y:h.coordinates.y-Se},ye={width:(h.dimensions.width*h.frameTransform.scaleX-_*p.scaleX)*ge.x,height:(h.dimensions.height*h.frameTransform.scaleY-w*p.scaleY)*ge.y},Z={x:G.x/p.scaleX+ye.width,y:G.y/p.scaleY+ye.height},Q={left:S+Z.x,top:x+Z.y};d.setAttribute(Dt,"true");const O=we(()=>a.transform),_e=(t=h.translate)!=null?t:{x:0,y:0},Ne=O.x*p.scaleX+_e.x,Be=O.y*p.scaleY+_e.y,ve=_u();k.set({width:_-se,height:w-U,top:Q.top+ve.y,left:Q.left+ve.x,translate:`${Ne}px ${Be}px 0`,transition:E?`${E}, translate 0ms linear`:"",scale:y?`${b.x} ${b.y}`:"","transform-origin":`${ge.x*100}% ${ge.y*100}%`},Je),ie&&(u.insertAdjacentElement("afterend",ie),o?.rootElement&&(typeof o.rootElement=="function"?o.rootElement(l):o.rootElement).appendChild(u)),zo(d)&&(d.hasAttribute("popover")||d.setAttribute("popover","manual"),Sr(d),d.addEventListener("beforetoggle",xl));let Ve,ne,Ge;const je=cm({placeholder:ie,element:u,feedbackElement:d,frameTransform:p,transformOrigin:ge,width:_,height:w,top:x,left:S,widthOffset:se,heightOffset:U,delta:Z,styles:k,dragOperation:a,getElementMutationObserver:()=>Ve,getSavedCellWidths:()=>Ge,setSavedCellWidths:oe=>{Ge=oe}}),xe=new Nt(d);we(()=>a.shape=xe);const Fe=St(d),Oe=oe=>{this.manager.actions.stop({event:oe})},Et=xu(Fe);le&&Fe.addEventListener("resize",Oe),we(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),ie&&(je.observe(ie),Ve=im(u,ie,ee),ne=lm(u,ie,d));const It=(n=s.dragOperation.source)==null?void 0:n.id,Mt=()=>{var oe;if(!le||It==null)return;const he=s.registry.draggables.get(It),Xe=(oe=he?.handle)!=null?oe:he?.element;mn(Xe)&&Xe.focus()},X=()=>{var oe;if(Ve?.disconnect(),ne?.disconnect(),je.disconnect(),Fe.removeEventListener("resize",Oe),zo(d)&&(d.removeEventListener("beforetoggle",xl),d.removeAttribute("popover")),d.removeAttribute(Dt),k.reset(),Ge&&Xo(u)){const Xe=Array.from(u.cells);for(const[At,Tt]of Xe.entries())Tt.style.width=(oe=Ge[At])!=null?oe:""}l.status="idle";const he=r.current.translate!=null;ie&&(he||ie.parentElement!==d.parentElement)&&d.isConnected&&ie.replaceWith(d),ie?.remove()},fe=o?.dropAnimation,Ue=this,Me=Rr(()=>{var oe;const{transform:he,status:Xe}=a;if(!(!he.x&&!he.y&&!r.current.translate)&&Xe.dragging){const At=(oe=h.translate)!=null?oe:{x:0,y:0},Tt={x:he.x/p.scaleX+At.x,y:he.y/p.scaleY+At.y},ut=r.current.translate,yt=we(()=>a.modifiers),V=we(()=>{var K;return(K=a.shape)==null?void 0:K.current}),Y=le&&!Et?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(k.set({transition:`${E}, translate ${Y}`,translate:`${Tt.x}px ${Tt.y}px 0`},Je),Ve?.takeRecords(),V&&V!==xe&&ut&&!yt.length){const K=Pt.delta(Tt,ut);a.shape=Dr.from(V.boundingRectangle).translate(K.x*p.scaleX,K.y*p.scaleY)}else a.shape=new Nt(d);r.current.translate=Tt}},function(){if(a.status.dropped){this.dispose(),l.status="dropping";const oe=Ue.dropAnimation!==void 0?Ue.dropAnimation:fe;let he=r.current.translate;const Xe=he!=null;if(!he&&u!==d&&(he={x:0,y:0}),!he||oe===null){X();return}s.renderer.rendering.then(()=>{fm({element:u,feedbackElement:d,placeholder:ie,translate:he,moved:Xe,transition:E,alignment:l.alignment,styles:k,animation:oe??void 0,getElementMutationObserver:()=>Ve,cleanup:X,restoreFocus:Mt})})}});return()=>{X(),Me()}};gt(Er,4,"overlay",Hu,Ir,ti);_n(Er,Ir);Ir.configure=Xn(Ir);var Ko=Ir,Jn=!0,hm=!1,Xu,Yu,Ku,qu,Kt,ni,ri;qu=(Ku=[de],_t.Forward),Yu=(Xu=[de],_t.Reverse);var Mr=class{constructor(){De(this,ni,We(Kt,8,this,Jn)),We(Kt,11,this),De(this,ri,We(Kt,12,this,Jn)),We(Kt,15,this)}isLocked(e){return e===_t.Idle?!1:e==null?this[_t.Forward]===Jn&&this[_t.Reverse]===Jn:this[e]===Jn}unlock(e){e!==_t.Idle&&(this[e]=hm)}};Kt=Kn(null);ni=new WeakMap;ri=new WeakMap;gt(Kt,4,qu,Ku,Mr,ni);gt(Kt,4,Yu,Xu,Mr,ri);_n(Kt,Mr);var pm=[_t.Forward,_t.Reverse],Cl=class{constructor(){this.x=new Mr,this.y=new Mr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},mm=class extends it{constructor(e){super(e);const t=$r(new Cl);let n=null;this.signal=t,Ct(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Cl;return}const{delta:s}=e.dragOperation.position;if(n){const o={x:Sl(s.x,n.x),y:Sl(s.y,n.y)},a=t.peek();Qt(()=>{for(const i of Mc)for(const l of pm)o[i]===l&&a[i].unlock(l);t.value=a})}n=s})}get current(){return this.signal.peek()}};function Sl(e,t){return Math.sign(e-t)}var Ju,qo,Ar,si,Xt,Jo,Vs=class extends(qo=Fr,Ju=[de],qo){constructor(e){super(e),De(this,si,We(Ar,8,this,!1)),We(Ar,11,this),De(this,Xt),De(this,Jo,()=>{if(!Ce(this,Xt))return;const{element:o,by:a}=Ce(this,Xt);a.y&&(o.scrollTop+=a.y),a.x&&(o.scrollLeft+=a.x)}),this.scroll=o=>{var a;if(this.disabled)return!1;const i=this.getScrollableElements();if(!i)return rt(this,Xt,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:u}=o??{},f=u?{x:kl(u.x),y:kl(u.y)}:void 0,h=f?void 0:this.scrollIntentTracker.current;if(h?.isLocked())return!1;for(const d of i){const p=ip(d,u);if(p.x||p.y){const{speed:v,direction:y}=bp(d,c,f);if(h)for(const m of Mc)h[m].isLocked(y[m])&&(v[m]=0,y[m]=0);if(y.x||y.y){const{x:m,y:b}=u??y,_=m*v.x,w=b*v.y;if(_||w){const x=(a=Ce(this,Xt))==null?void 0:a.by;if(this.autoScrolling&&x&&(x.x&&!_||x.y&&!w))continue;return rt(this,Xt,{element:d,by:{x:_,y:w}}),Ss.schedule(Ce(this,Jo)),!0}}}}}return rt(this,Xt,void 0),!1};let t=null,n=null;const r=ys(()=>{const{position:o,source:a}=e.dragOperation;if(!o)return null;const i=Cu(_s(a?.element),o.current);return i&&(t=i),i??t}),s=ys(()=>{const o=r.value,{documentElement:a}=wn(o);if(!o||o===a){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=jo(l,{excludeElement:!1});return n=c,c}}if(o){const i=jo(o,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},_r);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new mm(e),this.destroy=e.monitor.addEventListener("dragmove",o=>{this.disabled||o.defaultPrevented||!Ka(e.dragOperation.activatorEvent)||!o.by||this.scroll({by:o.by})&&o.preventDefault()})}};Ar=Kn(qo);si=new WeakMap;Xt=new WeakMap;Jo=new WeakMap;gt(Ar,4,"autoScrolling",Ju,Vs,si);_n(Ar,Vs);function kl(e){return e>0?_t.Forward:e<0?_t.Reverse:_t.Idle}var gm=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},vm=new gm(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),ym=10,Qu=class extends it{constructor(e,t){super(e);const n=e.registry.plugins.get(Vs);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=Ct(()=>{if(this.disabled)return;const{position:r,status:s}=e.dragOperation;if(s.dragging)if(n.scroll()){n.autoScrolling=!0;const a=setInterval(()=>vm.schedule(n.scroll),ym);return()=>{clearInterval(a)}}else n.autoScrolling=!1})}},El={capture:!0,passive:!0},fr,bm=class extends Fr{constructor(e){super(e),De(this,fr),this.handleScroll=()=>{Ce(this,fr)==null&&rt(this,fr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),rt(this,fr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=Ct(()=>{var n,r,s;if(t.status.dragging){const a=(s=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?s:document;return a.addEventListener("scroll",this.handleScroll,El),()=>{a.removeEventListener("scroll",this.handleScroll,El)}}})}};fr=new WeakMap;var wm=class extends it{constructor(e,t){super(e,t),this.manager=e,this.destroy=Ct(()=>{var n;const{dragOperation:r}=this.manager,{nonce:s}=(n=this.options)!=null?n:{};if(r.status.initialized){const o=document.createElement("style");return s&&o.setAttribute("nonce",s),o.textContent="* { user-select: none !important; -webkit-user-select: none !important; }",document.head.appendChild(o),mo(),document.addEventListener("selectionchange",mo,{capture:!0}),()=>{document.removeEventListener("selectionchange",mo,{capture:!0}),o.remove()}}})}};function mo(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var hr=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),Dn,As=class extends Wn{constructor(t,n){super(t),this.manager=t,this.options=n,De(this,Dn,[]),this.listeners=new Su,this.handleSourceKeyDown=(r,s,o)=>{if(this.disabled||r.defaultPrevented||!gn(r.target)||s.disabled)return;const{keyboardCodes:a=hr.keyboardCodes,preventActivation:i=hr.preventActivation}=o??{};a.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(i?.(r,s)||this.handleStart(r,s,o))}}bind(t,n=this.options){return Ct(()=>{var s;const o=(s=t.handle)!=null?s:t.element,a=i=>{Ka(i)&&this.handleSourceKeyDown(i,t,n)};if(o)return o.addEventListener("keydown",a),()=>{o.removeEventListener("keydown",a)}})}handleStart(t,n,r){const{element:s}=n;if(!s)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),_p(s);const{center:o}=new Nt(s);if(this.manager.actions.start({event:t,coordinates:{x:o.x,y:o.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const i=wn(s),l=[this.listeners.bind(i,[{type:"keydown",listener:c=>this.handleKeyDown(c,n,r),options:{capture:!0}}])];Ce(this,Dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=hr.keyboardCodes}=r??{};if(In(t,[...s.end,...s.cancel])){t.preventDefault();const o=In(t,s.cancel);this.handleEnd(t,o);return}In(t,s.up)?this.handleMove("up",t):In(t,s.down)&&this.handleMove("down",t),In(t,s.left)?this.handleMove("left",t):In(t,s.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,s;const{shape:o}=this.manager.dragOperation,a=n.shiftKey?5:1;let i={x:0,y:0},l=(s=(r=this.options)==null?void 0:r.offset)!=null?s:hr.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!o){switch(t){case"up":i={x:0,y:-l.y*a};break;case"down":i={x:0,y:l.y*a};break;case"left":i={x:-l.x*a,y:0};break;case"right":i={x:l.x*a,y:0};break}(i.x||i.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:i}))}}sideEffects(){const t=this.manager.registry.plugins.get(Qu);t?.disabled===!1&&(t.disable(),Ce(this,Dn).push(()=>{t.enable()}))}cleanup(){Ce(this,Dn).forEach(t=>t()),rt(this,Dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};Dn=new WeakMap;As.configure=Xn(As);As.defaults=hr;var _m=As;function In(e,t){return t.includes(e.code)}var fn,xm=class extends iu{constructor(){super(...arguments),De(this,fn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,fn,Bn(e));break;case"pointermove":if(!Ce(this,fn))return;const{x:t,y:n}=Bn(e),r={x:t-Ce(this,fn).x,y:n-Ce(this,fn).y},{tolerance:s}=this.options;if(s&&Oo(r,s)){this.abort();return}Oo(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){rt(this,fn,void 0)}};fn=new WeakMap;var Pn,hn,Cm=class extends iu{constructor(){super(...arguments),De(this,Pn),De(this,hn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,hn,Bn(e)),rt(this,Pn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Ce(this,hn))return;const{x:t,y:n}=Bn(e),r={x:t-Ce(this,hn).x,y:n-Ce(this,hn).y};Oo(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Ce(this,Pn)&&(clearTimeout(Ce(this,Pn)),rt(this,hn,void 0),rt(this,Pn,void 0))}};Pn=new WeakMap;hn=new WeakMap;var Bt=class{};Bt.Delay=Cm;Bt.Distance=xm;var Qo=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&gn(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Bt.Delay({value:250,tolerance:5})]:Rp(s)&&!e.defaultPrevented?[new Bt.Delay({value:200,tolerance:0})]:[new Bt.Delay({value:200,tolerance:10}),new Bt.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;return r===t.element||r===t.handle||!gn(r)||(n=t.handle)!=null&&n.contains(r)?!1:Kh(r)}}),Fn,Ts=class extends Wn{constructor(t,n){super(t),this.manager=t,this.options=n,De(this,Fn,new Set),this.listeners=new Su,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:s}=this.latest;!r||!s||this.manager.actions.move({event:r,to:s})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:s=Qo.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return Ct(()=>{var s;const o=new AbortController,{signal:a}=o,i=c=>{$p(c)&&this.handlePointerDown(c,t,n)};let l=[(s=t.handle)!=null?s:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const c of l)c&&(Em(c.ownerDocument.defaultView),c.addEventListener("pointerdown",i,{signal:a}));return()=>o.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!gn(t.target)||n.disabled||Sm(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=Qo.preventActivation}=r??{};if(s?.(t,n))return;const{target:o}=t,a=mn(o)&&o.draggable&&o.getAttribute("draggable")==="true",i=Nn(n.element),{x:l,y:c}=Bn(t);this.initialCoordinates={x:l*i.scaleX+i.x,y:c*i.scaleY+i.y};const u=this.activationConstraints(t,n,r);t.sensor=this;const f=new Vh(u,v=>this.handleStart(n,v));f.signal.onabort=()=>this.handleCancel(t),f.onEvent(t),this.controller=f;const h=Vo(),d=this.listeners.bind(h,[{type:"pointermove",listener:v=>this.handlePointerMove(v,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:a?this.handleCancel:ts,options:{capture:!0}}]),p=()=>{d(),this.initialCoordinates=void 0};Ce(this,Fn).add(p)}handlePointerMove(t,n){var r,s;if(((r=this.controller)==null?void 0:r.activated)===!1){(s=this.controller)==null||s.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const o=Bn(t),a=Nn(n.element);o.x=o.x*a.scaleX+a.x,o.y=o.y*a.scaleY+a.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=o,Ss.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:s}=this;if(!s||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:s,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const i=wn(n.target).body;i.setPointerCapture(n.pointerId);const l=gn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:ts,options:{passive:!1}},{type:"click",listener:ts},{type:"contextmenu",listener:ts},{type:"keydown",listener:this.handleKeyDown}]);Ce(this,Fn).add(c)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){this.latest={event:void 0,coordinates:void 0},Ce(this,Fn).forEach(t=>t()),Ce(this,Fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};Fn=new WeakMap;Ts.configure=Xn(Ts);Ts.defaults=Qo;var ea=Ts;function Sm(e){return"sensor"in e}function ts(e){e.preventDefault()}function km(){}var Il=new WeakSet;function Em(e){!e||Il.has(e)||(e.addEventListener("touchmove",km,{capture:!1,passive:!1}),Il.add(e))}var On={modifiers:[],plugins:[qp,Qu,Qp,Ko,wm],sensors:[ea,_m]},oi=class extends jh{constructor(e={}){const t=Vt(e.plugins,On.plugins),n=Vt(e.sensors,On.sensors),r=Vt(e.modifiers,On.modifiers);super(Ja(kr({},e),{plugins:[bm,Vs,xn,...t],sensors:n,modifiers:r}))}},ed,td,nd,ta,$t,ai,ii,li,Wr=class extends(ta=Ft,nd=[de],td=[de],ed=[de],ta){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:o,feedback:a="default"}=n,i=Pu(n,["element","effects","handle","feedback"]);super(kr({effects:()=>[...s(),()=>{var l,c;const{manager:u}=this;if(!u)return;const h=((c=(l=this.sensors)==null?void 0:l.map(wa))!=null?c:[...u.sensors]).map(d=>{const p=d instanceof Wn?d:u.registry.register(d.plugin),v=d instanceof Wn?void 0:d.options;return p.bind(this,v)});return function(){h.forEach(p=>p())}}]},i),t),De(this,ai,We($t,8,this)),We($t,11,this),De(this,ii,We($t,12,this)),We($t,15,this),De(this,li,We($t,16,this)),We($t,19,this),this.element=r,this.handle=o,this.feedback=a}};$t=Kn(ta);ai=new WeakMap;ii=new WeakMap;li=new WeakMap;gt($t,4,"handle",nd,Wr,ai);gt($t,4,"element",td,Wr,ii);gt($t,4,"feedback",ed,Wr,li);_n($t,Wr);var rd,sd,na,qt,ci,go,od,ad,br,ui,id=class extends(na=Ot,sd=[de],rd=[de],na){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,o=Pu(n,["element","effects"]);const{collisionDetector:a=Op}=o,i=c=>{const{manager:u,element:f}=this;if(!f||c===null){this.shape=void 0;return}if(!u)return;const h=new Nt(f),d=we(()=>this.shape);return h&&d?.equals(h)?d:(this.shape=h,h)},l=$r(!1);super(Ja(kr({},o),{collisionDetector:a,effects:()=>[...s(),()=>{const{element:c,manager:u}=this;if(!u)return;const{dragOperation:f}=u,{source:h}=f;l.value=!!(h&&f.status.initialized&&c&&!this.disabled&&this.accepts(h))},()=>{const{element:c}=this;if(l.value&&c){const u=new ap(c,i);return()=>{u.disconnect(),this.shape=void 0}}},()=>{var c;if((c=this.manager)!=null&&c.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),De(this,br),De(this,ci,We(qt,8,this)),We(qt,11,this),De(this,ui,We(qt,12,this)),We(qt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){rt(this,br,e,ad)}get element(){var e;return(e=this.proxy)!=null?e:Ce(this,br,od)}};qt=Kn(na);ci=new WeakMap;br=new WeakSet;ui=new WeakMap;go=gt(qt,20,"#element",sd,br,ci),od=go.get,ad=go.set;gt(qt,4,"proxy",rd,id,ui);_n(qt,id);function Im(e){return e!=null&&typeof e=="object"&&"current"in e}function $s(e){var t;if(e!=null)return Im(e)?(t=e.current)!=null?t:void 0:e}var Mm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ns=Mm?g.useLayoutEffect:g.useEffect;function Am(){const e=g.useState(0)[1];return g.useCallback(()=>{e(t=>t+1)},[e])}function Tm(e,t){const n=g.useRef(new Map),r=Am();return Ns(()=>{if(!e){n.current.clear();return}return Ct(()=>{var s;let o=!1,a=!1;for(const i of n.current){const[l]=i,c=we(()=>i[1]),u=e[l];c!==u&&(o=!0,n.current.set(l,u),a=(s=t?.(l,c,u))!=null?s:!1)}o&&(a?da.flushSync(r):r())})},[e]),g.useMemo(()=>e&&new Proxy(e,{get(s,o){const a=s[o];return n.current.set(o,a),a}}),[e])}function ln(e,t,n=g.useEffect,r=Object.is){const s=g.useRef(e);n(()=>{const o=s.current;r(e,o)||(s.current=e,t(e,o))},[t,e])}function Ml(e,t){const n=g.useRef($s(e));Ns(()=>{const r=$s(e);r!==n.current&&(n.current=r,t(r))})}var $m=Object.defineProperty,Rm=Object.defineProperties,Dm=Object.getOwnPropertyDescriptors,Al=Object.getOwnPropertySymbols,Pm=Object.prototype.hasOwnProperty,Fm=Object.prototype.propertyIsEnumerable,Tl=(e,t,n)=>t in e?$m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Om=(e,t)=>{for(var n in t||(t={}))Pm.call(t,n)&&Tl(e,n,t[n]);if(Al)for(var n of Al(t))Fm.call(t,n)&&Tl(e,n,t[n]);return e},Lm=(e,t)=>Rm(e,Dm(t)),Wm=new oi,Bm=g.createContext(Wm);g.memo(g.forwardRef(({children:e},t)=>{const[n,r]=g.useState(0),s=g.useRef(null),o=g.useRef(null),a=g.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{o.current=l})),g.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Ns(()=>{var i;(i=o.current)==null||i.call(o),s.current=null},[e,n]),g.useImperativeHandle(t,()=>a),null}));function Vm(){return g.useContext(Bm)}function Nm(e){var t;const n=(t=Vm())!=null?t:void 0,[r]=g.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ns(r.register,[n,r]),r}function vo(e){const{disabled:t,data:n,element:r,handle:s,id:o,modifiers:a,sensors:i}=e,l=Nm(u=>new Wr(Lm(Om({},e),{register:!1,handle:$s(s),element:$s(r)}),u)),c=Tm(l,zm);return ln(o,()=>l.id=o),Ml(s,u=>l.handle=u),Ml(r,u=>l.element=u),ln(n,()=>n&&(l.data=n)),ln(t,()=>l.disabled=t===!0),ln(i,()=>l.sensors=i),ln(a,()=>l.modifiers=a,void 0,_r),ln(e.feedback,()=>{var u;return l.feedback=(u=e.feedback)!=null?u:"default"}),ln(e.alignment,()=>l.alignment=e.alignment),{draggable:c,get isDragging(){return c.isDragging},get isDropping(){return c.isDropping},get isDragSource(){return c.isDragSource},handleRef:g.useCallback(u=>{l.handle=u??void 0},[l]),ref:g.useCallback(u=>{var f,h;!u&&((f=l.element)!=null&&f.isConnected)&&!((h=l.manager)!=null&&h.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function zm(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var jm=Object.create,ld=Object.defineProperty,Zm=Object.getOwnPropertyDescriptor,cd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),zs=e=>{throw TypeError(e)},Hm=(e,t,n)=>t in e?ld(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gm=e=>{var t;return[,,,jm((t=e?.[cd("metadata")])!=null?t:null)]},ud=["class","method","getter","setter","accessor","field","value","get","set"],dd=e=>e!==void 0&&typeof e!="function"?zs("Function expected"):e,Um=(e,t,n,r,s)=>({kind:ud[e],name:t,metadata:r,addInitializer:o=>n._?zs("Already initialized"):s.push(dd(o||null))}),Xm=(e,t)=>Hm(t,cd("metadata"),e[3]),Ym=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)o[s].call(n);return r},fd=(e,t,n,r,s,o)=>{for(var a,i,l,c,u=t&7,f=!1,h=!1,d=2,p=ud[u+5],v=e[d]||(e[d]=[]),y=(s=s.prototype,Zm(s,n)),m=r.length-1;m>=0;m--)l=Um(u,n,i={},e[3],v),l.static=f,l.private=h,c=l.access={has:b=>n in b},c.get=b=>b[n],a=(0,r[m])(y[p],l),i._=1,dd(a)&&(y[p]=a);return y&&ld(s,n,y),s},hd=(e,t,n)=>t.has(e)||zs("Cannot "+n),Km=(e,t,n)=>(hd(e,t,"read from private field"),t.get(e)),qm=(e,t,n)=>t.has(e)?zs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Jm=(e,t,n,r)=>(hd(e,t,"write to private field"),t.set(e,n),n),Qn=class ra{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ra(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new ra(t,n)}},pd,md,sa,hs,Br,di=class extends(sa=tn,md=[Ie],pd=[Ie],sa){constructor(t){const n=Qn.from(t);super(n,(r,s)=>Qn.equals(r,s)),Ym(Br,5,this),qm(this,hs,0),this.velocity={x:0,y:0}}get delta(){return Qn.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Qn.from(t),s={x:r.x-n.x,y:r.y-n.y},o=Date.now(),a=o-Km(this,hs),i=l=>Math.round(l/a*100);Qt(()=>{Jm(this,hs,o),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Qn.from(t)),this.velocity={x:0,y:0}}};Br=Gm(sa);hs=new WeakMap;fd(Br,2,"delta",md,di);fd(Br,2,"direction",pd,di);Xm(Br,di);var gd=(e=>(e.Horizontal="x",e.Vertical="y",e))(gd||{});Object.values(gd);const Qm=new Map([["bold",D.createElement(D.Fragment,null,D.createElement("path",{d:"M144,128a16,16,0,1,1-16-16A16,16,0,0,1,144,128ZM60,112a16,16,0,1,0,16,16A16,16,0,0,0,60,112Zm136,0a16,16,0,1,0,16,16A16,16,0,0,0,196,112Z"}))],["duotone",D.createElement(D.Fragment,null,D.createElement("path",{d:"M240,96v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V96A16,16,0,0,1,32,80H224A16,16,0,0,1,240,96Z",opacity:"0.2"}),D.createElement("path",{d:"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"}))],["fill",D.createElement(D.Fragment,null,D.createElement("path",{d:"M224,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V96A16,16,0,0,0,224,80ZM60,140a12,12,0,1,1,12-12A12,12,0,0,1,60,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,196,140Z"}))],["light",D.createElement(D.Fragment,null,D.createElement("path",{d:"M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM60,118a10,10,0,1,0,10,10A10,10,0,0,0,60,118Zm136,0a10,10,0,1,0,10,10A10,10,0,0,0,196,118Z"}))],["regular",D.createElement(D.Fragment,null,D.createElement("path",{d:"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"}))],["thin",D.createElement(D.Fragment,null,D.createElement("path",{d:"M136,128a8,8,0,1,1-8-8A8,8,0,0,1,136,128Zm-76-8a8,8,0,1,0,8,8A8,8,0,0,0,60,120Zm136,0a8,8,0,1,0,8,8A8,8,0,0,0,196,120Z"}))]]),eg=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),tg=new Map([["bold",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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",D.createElement(D.Fragment,null,D.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"}))]]),ng=new Map([["bold",D.createElement(D.Fragment,null,D.createElement("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"}))],["duotone",D.createElement(D.Fragment,null,D.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),D.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["fill",D.createElement(D.Fragment,null,D.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["light",D.createElement(D.Fragment,null,D.createElement("path",{d:"M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"}))],["regular",D.createElement(D.Fragment,null,D.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["thin",D.createElement(D.Fragment,null,D.createElement("path",{d:"M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"}))]]),rg=g.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Vr=D.forwardRef((e,t)=>{const{alt:n,color:r,size:s,weight:o,mirrored:a,children:i,weights:l,...c}=e,{color:u="currentColor",size:f,weight:h="regular",mirrored:d=!1,...p}=D.useContext(rg);return D.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:s??f,height:s??f,fill:r??u,viewBox:"0 0 256 256",transform:a||d?"scale(-1, 1)":void 0,...p,...c},!!n&&D.createElement("title",null,n),i,l.get(o??h))});Vr.displayName="IconBase";const vd=D.forwardRef((e,t)=>D.createElement(Vr,{ref:t,...e,weights:Qm}));vd.displayName="DotsThreeIcon";const yd=D.forwardRef((e,t)=>D.createElement(Vr,{ref:t,...e,weights:eg}));yd.displayName="SpeakerHighIcon";const bd=D.forwardRef((e,t)=>D.createElement(Vr,{ref:t,...e,weights:tg}));bd.displayName="SpeakerLowIcon";const wd=D.forwardRef((e,t)=>D.createElement(Vr,{ref:t,...e,weights:ng}));wd.displayName="XIcon";const sg=wd;P.span`
|
|
67
67
|
font-family: 'Courier New', Monaco, monospace;
|
|
68
68
|
font-size: 1rem;
|
|
69
69
|
font-weight: 600;
|
|
70
70
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
71
71
|
user-select: none;
|
|
72
|
-
`;var
|
|
72
|
+
`;var fi=P.button`
|
|
73
73
|
display: inline-flex;
|
|
74
74
|
align-items: center;
|
|
75
75
|
justify-content: center;
|
|
@@ -100,37 +100,37 @@
|
|
|
100
100
|
opacity: 0.6;
|
|
101
101
|
cursor: not-allowed;
|
|
102
102
|
}
|
|
103
|
-
`;
|
|
103
|
+
`;P(fi)`
|
|
104
104
|
padding: 0.25rem 0.5rem;
|
|
105
105
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
106
|
-
`;
|
|
106
|
+
`;P(fi)`
|
|
107
107
|
padding: 0.5rem;
|
|
108
108
|
min-width: 2.25rem;
|
|
109
109
|
min-height: 2.25rem;
|
|
110
|
-
`;
|
|
110
|
+
`;P(fi)`
|
|
111
111
|
padding: 0.25rem;
|
|
112
112
|
min-width: 1.75rem;
|
|
113
113
|
min-height: 1.75rem;
|
|
114
114
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
115
|
-
`;var
|
|
115
|
+
`;var og=P.div`
|
|
116
116
|
display: inline-flex;
|
|
117
117
|
align-items: center;
|
|
118
118
|
gap: 0.5rem;
|
|
119
|
-
`,
|
|
119
|
+
`,ag=P.input`
|
|
120
120
|
cursor: pointer;
|
|
121
121
|
accent-color: ${e=>e.theme.inputFocusBorder};
|
|
122
122
|
|
|
123
123
|
&:disabled {
|
|
124
124
|
cursor: not-allowed;
|
|
125
125
|
}
|
|
126
|
-
`,
|
|
126
|
+
`,ig=P.label`
|
|
127
127
|
margin: 0;
|
|
128
128
|
cursor: pointer;
|
|
129
129
|
user-select: none;
|
|
130
130
|
font-family: ${e=>e.theme.fontFamily};
|
|
131
131
|
font-size: ${e=>e.theme.fontSize};
|
|
132
132
|
color: ${e=>e.theme.textColor};
|
|
133
|
-
`,
|
|
133
|
+
`,kt=P.button`
|
|
134
134
|
padding: 0.5rem 1rem;
|
|
135
135
|
background: ${e=>e.theme.buttonBackground||"#007bff"};
|
|
136
136
|
color: ${e=>e.theme.buttonText||"white"};
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
cursor: not-allowed;
|
|
157
157
|
opacity: 0.6;
|
|
158
158
|
}
|
|
159
|
-
`,
|
|
159
|
+
`,_d=P.input`
|
|
160
160
|
padding: 0.5rem 0.75rem;
|
|
161
161
|
font-family: ${e=>e.theme.fontFamily};
|
|
162
162
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -182,17 +182,17 @@
|
|
|
182
182
|
opacity: 0.6;
|
|
183
183
|
cursor: not-allowed;
|
|
184
184
|
}
|
|
185
|
-
`;
|
|
185
|
+
`;P(_d)`
|
|
186
186
|
padding: 0.25rem 0.5rem;
|
|
187
187
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
188
|
-
`;var
|
|
188
|
+
`;var lg=P.label`
|
|
189
189
|
font-family: ${e=>e.theme.fontFamily};
|
|
190
190
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
191
191
|
font-weight: 500;
|
|
192
192
|
color: ${e=>e.theme.textColorMuted};
|
|
193
193
|
margin-bottom: 0.25rem;
|
|
194
194
|
display: block;
|
|
195
|
-
`;
|
|
195
|
+
`;P.label`
|
|
196
196
|
font-family: ${e=>e.theme.fontFamily};
|
|
197
197
|
font-size: ${e=>e.theme.fontSize};
|
|
198
198
|
color: ${e=>e.theme.textColor};
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
align-items: center;
|
|
201
201
|
gap: 0.5rem;
|
|
202
202
|
cursor: pointer;
|
|
203
|
-
`;var
|
|
203
|
+
`;var cg=P.span`
|
|
204
204
|
position: absolute;
|
|
205
205
|
width: 1px;
|
|
206
206
|
height: 1px;
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
clip: rect(0, 0, 0, 0);
|
|
211
211
|
white-space: nowrap;
|
|
212
212
|
border: 0;
|
|
213
|
-
`,
|
|
213
|
+
`,xd=P.select`
|
|
214
214
|
padding: 0.5rem 2rem 0.5rem 0.75rem;
|
|
215
215
|
font-family: ${e=>e.theme.fontFamily};
|
|
216
216
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -243,10 +243,10 @@
|
|
|
243
243
|
color: ${e=>e.theme.inputText};
|
|
244
244
|
background-color: ${e=>e.theme.inputBackground};
|
|
245
245
|
}
|
|
246
|
-
`;
|
|
246
|
+
`;P(xd)`
|
|
247
247
|
padding: 0.25rem 1.75rem 0.25rem 0.5rem;
|
|
248
248
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
249
|
-
`;var
|
|
249
|
+
`;var Cd=P.input.attrs({type:"range"})`
|
|
250
250
|
-webkit-appearance: none;
|
|
251
251
|
appearance: none;
|
|
252
252
|
width: 100%;
|
|
@@ -326,23 +326,21 @@
|
|
|
326
326
|
&:disabled::-moz-range-thumb {
|
|
327
327
|
cursor: not-allowed;
|
|
328
328
|
}
|
|
329
|
-
`,
|
|
329
|
+
`,ug=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const s=o=>{t(o.target.checked)};return C.jsxs(og,{className:r,children:[C.jsx(ag,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:s,disabled:n}),C.jsx(ig,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Sd(e){return typeof e=="object"&&e!==null&&"type"in e}function en(e){if(!Sd(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 kd={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)",pianoRollNoteColor:"#2a7070",pianoRollSelectedNoteColor:"#3d9e9e",pianoRollBackgroundColor:"#1a1a2e",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},dg=class{constructor(e){this._listeners=new Set,this._notifyRafId=null,this.subscribe=r=>(this._listeners.add(r),()=>this._listeners.delete(r)),this.getSnapshot=()=>this._state;const t=e?.clientWidth??(typeof window<"u"?window.innerWidth:1024),n=t*1.5;this._state={scrollLeft:0,containerWidth:t,visibleStart:0,visibleEnd:t+n}}update(e,t){const n=t*1.5,r=Math.max(0,e-n),s=e+t+n;this._state&&this._state.containerWidth===t&&Math.abs(this._state.scrollLeft-e)<100||(this._state={scrollLeft:e,containerWidth:t,visibleStart:r,visibleEnd:s},this._notifyRafId===null&&(this._notifyRafId=requestAnimationFrame(()=>{this._notifyRafId=null;for(const o of this._listeners)o()})))}cancelPendingNotification(){this._notifyRafId!==null&&(cancelAnimationFrame(this._notifyRafId),this._notifyRafId=null)}},Ed=g.createContext(null),fg=()=>()=>{},hg=({containerRef:e,children:t})=>{const n=g.useRef(null);n.current===null&&(n.current=new dg(e.current));const r=n.current,s=g.useRef(null),o=g.useCallback(()=>{const i=e.current;i&&r.update(i.scrollLeft,i.clientWidth)},[e,r]),a=g.useCallback(()=>{s.current===null&&(s.current=requestAnimationFrame(()=>{s.current=null,o()}))},[o]);return g.useLayoutEffect(()=>{o()},[o]),g.useEffect(()=>{const i=e.current;if(!i)return;i.addEventListener("scroll",a,{passive:!0});const l=new ResizeObserver(()=>{a()});return l.observe(i),()=>{i.removeEventListener("scroll",a),l.disconnect(),s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),r.cancelPendingNotification()}},[e,a,r]),C.jsx(Ed.Provider,{value:r,children:t})};function pg(e){const t=g.useContext(Ed);return g.useSyncExternalStore(t?t.subscribe:fg,()=>e(t?t.getSnapshot():null),()=>e(null))}function js(e,t,n=0){const r=pg(s=>{const o=Math.ceil(e/t),a=[];for(let i=0;i<o;i++){const l=i*t,c=Math.min(e-l,t);if(s){const u=n+l;if(u+c<=s.visibleStart||u>=s.visibleEnd)continue}a.push(i)}return a.join(",")});return g.useMemo(()=>r?r.split(",").map(Number):[],[r])}var Id=g.createContext(0),mg=({originX:e,children:t})=>C.jsx(Id.Provider,{value:e,children:t}),hi=()=>g.useContext(Id);function Zs(){const e=g.useRef(new Map),t=g.useCallback(n=>{if(n!==null){const r=parseInt(n.dataset.index,10);e.current.set(r,n)}},[]);return g.useEffect(()=>{const n=e.current;for(const[r,s]of n.entries())s.isConnected||n.delete(r)}),{canvasRef:t,canvasMapRef:e}}function gg(e,t,n,r){if(n*2+1>=e.length)return null;const s=2**(t-1);let o=e[n*2]/s,a=e[n*2+1]/s;for(let i=n+1;i<r&&!(i*2+1>=e.length);i++){const l=e[i*2]/s,c=e[i*2+1]/s;l<o&&(o=l),c>a&&(a=c)}return{min:o,max:a}}function vg(e,t,n,r,s,o){const a=Math.abs(r*n),i=Math.abs(s*n);return o==="normal"?[{x:e,y:n-i,width:t,height:i+a}]:[{x:e,y:0,width:t,height:n-i},{x:e,y:n+a,width:t,height:n-a}]}function yg(e,t,n){return Math.floor((e-t+n)/n)*n}function bg(e,t,n,r){if(!Sd(t))return t;let s;t.direction==="vertical"?s=e.createLinearGradient(0,0,0,r):s=e.createLinearGradient(0,0,n,0);for(const o of t.stops)s.addColorStop(o.offset,o.color);return s}var wg=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
330
330
|
position: absolute;
|
|
331
331
|
top: 0;
|
|
332
|
-
/* Promote to own compositing layer for smoother scrolling */
|
|
333
|
-
will-change: transform;
|
|
334
332
|
/* Disable image rendering interpolation */
|
|
335
333
|
image-rendering: pixelated;
|
|
336
334
|
image-rendering: crisp-edges;
|
|
337
|
-
`,
|
|
335
|
+
`,_g=P.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
338
336
|
position: absolute;
|
|
339
337
|
background: ${e=>e.$waveFillColor};
|
|
340
338
|
/* Force GPU compositing layer to reduce scroll flickering */
|
|
341
339
|
transform: translateZ(0);
|
|
342
340
|
backface-visibility: hidden;
|
|
343
|
-
|
|
341
|
+
`,$l=e=>{const{data:t,bits:n,length:r,index:s,className:o,devicePixelRatio:a=1,waveHeight:i=80,waveOutlineColor:l="#E0EFF1",waveFillColor:c="grey",barWidth:u=1,barGap:f=0,transparentBackground:h=!1,drawMode:d="inverted"}=e,{canvasRef:p,canvasMapRef:v}=Zs(),y=hi(),m=js(r,Le,y);g.useEffect(()=>{const x=performance.now(),S=u+f;for(const[k,E]of v.current.entries()){const T=k*Le,I=E.getContext("2d"),M=Math.floor(i/2);if(I){I.resetTransform(),I.clearRect(0,0,E.width,E.height),I.imageSmoothingEnabled=!1,I.scale(a,a);const $=E.width/a;let A;d==="normal"?A=c:A=l,I.fillStyle=bg(I,A,$,i);const R=T,W=T+$,q=yg(R,u,S);for(let z=Math.max(0,q);z<W;z+=S){const J=z-R;if(J+u<=0)continue;const ee=Math.min(z+S,r),j=gg(t,n,z,ee);if(j){const se=vg(J,u,M,j.min,j.max,d);for(const U of se)I.fillRect(U.x,U.y,U.width,U.height)}}}}console.log(`[waveform] draw ch${s}: ${v.current.size} chunks, ${(performance.now()-x).toFixed(1)}ms`)},[v,t,n,i,l,c,a,r,u,f,d,m,s]);const b=m.map(x=>{const S=x*Le,k=Math.min(r-S,Le);return C.jsx(wg,{$cssWidth:k,$left:S,width:k*a,height:i*a,$waveHeight:i,"data-index":x,ref:p},`${r}-${x}`)}),w=h?"transparent":en(c);return C.jsx(_g,{$index:s,$cssWidth:r,className:o,$waveHeight:i,$waveFillColor:w,children:b})},xg={padding:"16px",background:"#1a1a2e",color:"#e0e0e0",border:"1px solid #d08070",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px",minHeight:"60px",display:"flex",alignItems:"center",justifyContent:"center"};(class extends g.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[waveform-playlist] Render error:",e,t.componentStack)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:C.jsx("div",{style:xg,children:"Waveform playlist encountered an error. Check console for details."}):this.props.children}});var pi=22,Md=P.div`
|
|
344
342
|
position: relative;
|
|
345
|
-
height: ${
|
|
343
|
+
height: ${pi}px;
|
|
346
344
|
background: ${e=>e.$isSelected?e.theme.selectedClipHeaderBackgroundColor:e.theme.clipHeaderBackgroundColor};
|
|
347
345
|
border-bottom: 1px solid ${e=>e.theme.clipHeaderBorderColor};
|
|
348
346
|
display: flex;
|
|
@@ -364,7 +362,7 @@
|
|
|
364
362
|
cursor: grabbing;
|
|
365
363
|
}
|
|
366
364
|
`}
|
|
367
|
-
`,
|
|
365
|
+
`,Ad=P.span`
|
|
368
366
|
font-size: 11px;
|
|
369
367
|
font-weight: 600;
|
|
370
368
|
font-family: ${e=>e.theme.clipHeaderFontFamily};
|
|
@@ -372,12 +370,12 @@
|
|
|
372
370
|
white-space: nowrap;
|
|
373
371
|
overflow: hidden;
|
|
374
372
|
text-overflow: ellipsis;
|
|
375
|
-
`,
|
|
373
|
+
`,Cg=({trackName:e,isSelected:t=!1})=>C.jsx(Md,{$interactive:!1,$isSelected:t,children:C.jsx(Ad,{title:e,children:e})}),Sg=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:s=!1,disableDrag:o=!1,dragHandleProps:a})=>{if(o||!a)return C.jsx(Cg,{trackName:r,isSelected:s});const{handleRef:i}=a;return C.jsx(Md,{ref:i,"data-clip-id":e,$interactive:!0,$isSelected:s,children:C.jsx(Ad,{title:r,children:r})})},kg=8,Eg=24,Ig=P.div`
|
|
376
374
|
position: absolute;
|
|
377
375
|
${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
|
|
378
376
|
top: 0;
|
|
379
377
|
bottom: 0;
|
|
380
|
-
width: ${e=>e.$touchOptimized?
|
|
378
|
+
width: ${e=>e.$touchOptimized?Eg:kg}px;
|
|
381
379
|
cursor: col-resize;
|
|
382
380
|
user-select: none;
|
|
383
381
|
z-index: 105; /* Above waveform, below header */
|
|
@@ -400,19 +398,19 @@
|
|
|
400
398
|
background: rgba(255, 255, 255, 0.4);
|
|
401
399
|
${e=>e.$edge==="left"?"border-left: 2px solid rgba(255, 255, 255, 0.8);":"border-right: 2px solid rgba(255, 255, 255, 0.8);"}
|
|
402
400
|
}
|
|
403
|
-
`,
|
|
401
|
+
`,Rl=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:s,touchOptimized:o=!1})=>{const[a,i]=g.useState(!1);if(!s)return null;const{ref:l,isDragging:c}=s;return C.jsx(Ig,{ref:l,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:c,$isHovered:a,$touchOptimized:o,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1)})},Mg=P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
404
402
|
position: absolute;
|
|
405
403
|
top: 0;
|
|
406
404
|
bottom: 0;
|
|
407
405
|
pointer-events: none;
|
|
408
406
|
z-index: 50;
|
|
409
|
-
`,
|
|
407
|
+
`,Ag=P.svg`
|
|
410
408
|
width: 100%;
|
|
411
409
|
height: 100%;
|
|
412
410
|
display: block;
|
|
413
411
|
/* Flip horizontally for fadeOut - makes it mirror of fadeIn */
|
|
414
412
|
transform: ${e=>e.$type==="fadeOut"?"scaleX(-1)":"none"};
|
|
415
|
-
`;function
|
|
413
|
+
`;function Tg(e,t,n="logarithmic"){const r=[],s=Math.max(20,Math.min(e,100));for(let o=0;o<=s;o++){const a=o/s*e,i=o/s;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 c=(1-l)*t;r.push(`${a},${c}`)}return`M 0,${t} L ${r.join(" L ")} L ${e},0 L 0,0 Z`}var Dl=({left:e,width:t,type:n,curveType:r="logarithmic",color:s})=>{const o=P.useTheme();if(t<1)return null;const a=s||o?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return C.jsx(Mg,{$left:e,$width:t,$type:n,children:C.jsx(Ag,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:C.jsx("path",{d:Tg(t,100,r),fill:a})})})},$g=P.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
416
414
|
position: ${e=>e.$isOverlay?"relative":"absolute"};
|
|
417
415
|
top: 0;
|
|
418
416
|
height: ${e=>e.$isOverlay?"auto":"100%"};
|
|
@@ -426,20 +424,30 @@
|
|
|
426
424
|
&:hover {
|
|
427
425
|
background: rgba(255, 255, 255, 0.08);
|
|
428
426
|
}
|
|
429
|
-
`,
|
|
427
|
+
`,Rg=P.div`
|
|
430
428
|
flex: 1;
|
|
431
429
|
position: relative;
|
|
432
430
|
overflow: ${e=>e.$isOverlay?"visible":"hidden"};
|
|
433
|
-
`,
|
|
431
|
+
`,oa=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:s,trackName:o,startSample:a,durationSamples:i,samplesPerPixel:l,showHeader:c=!1,disableHeaderDrag:u=!1,isOverlay:f=!1,isSelected:h=!1,onMouseDown:d,trackId:p,fadeIn:v,fadeOut:y,sampleRate:m=44100,showFades:b=!1,touchOptimized:_=!1})=>{const w=Math.floor(a/l),S=Math.floor((a+i)/l)-w,k=c&&!u&&!f,E=`clip-${r}-${s}`,{ref:T,handleRef:I,isDragSource:M}=vo({id:E,data:{clipId:n,trackIndex:r,clipIndex:s},disabled:!k}),$=`clip-boundary-left-${r}-${s}`,{ref:A,isDragSource:R}=vo({id:$,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"left"},disabled:!k,feedback:"none"}),W=`clip-boundary-right-${r}-${s}`,{ref:q,isDragSource:z}=vo({id:W,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"right"},disabled:!k,feedback:"none"}),J=M?{zIndex:100}:void 0;return C.jsxs($g,{ref:T,style:J,className:t,$left:w,$width:S,$isOverlay:f,"data-clip-container":"true","data-track-id":p,onMouseDown:d,tabIndex:-1,children:[c&&C.jsx(Sg,{clipId:n,trackIndex:r,clipIndex:s,trackName:o,isSelected:h,disableDrag:u,dragHandleProps:k?{handleRef:I}:void 0}),C.jsx(mg,{originX:w,children:C.jsxs(Rg,{$isOverlay:f,children:[e,b&&v&&v.duration>0&&C.jsx(Dl,{left:0,width:Math.floor(v.duration*m/l),type:"fadeIn",curveType:v.type}),b&&y&&y.duration>0&&C.jsx(Dl,{left:S-Math.floor(y.duration*m/l),width:Math.floor(y.duration*m/l),type:"fadeOut",curveType:y.type})]})}),c&&!u&&!f&&C.jsxs(C.Fragment,{children:[C.jsx(Rl,{clipId:n,trackIndex:r,clipIndex:s,edge:"left",touchOptimized:_,dragHandleProps:{ref:A,isDragging:R}}),C.jsx(Rl,{clipId:n,trackIndex:r,clipIndex:s,edge:"right",touchOptimized:_,dragHandleProps:{ref:q,isDragging:z}})]})]})},Dg=P.div`
|
|
434
432
|
display: inline-flex;
|
|
435
433
|
align-items: center;
|
|
436
434
|
gap: 0.5rem;
|
|
437
|
-
`,
|
|
435
|
+
`,Pg=P(lg)`
|
|
438
436
|
margin: 0;
|
|
439
437
|
white-space: nowrap;
|
|
440
|
-
`,
|
|
438
|
+
`,Fg=P(Cd)`
|
|
441
439
|
width: 120px;
|
|
442
|
-
`,
|
|
440
|
+
`,Og=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const s=o=>{t(parseFloat(o.target.value)/100)};return C.jsxs(Dg,{className:r,children:[C.jsx(Pg,{htmlFor:"master-gain",children:"Master Volume"}),C.jsx(Fg,{min:"0",max:"100",value:e*100,onChange:s,disabled:n,id:"master-gain"})]})},Lg=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
441
|
+
position: absolute;
|
|
442
|
+
top: 0;
|
|
443
|
+
image-rendering: pixelated;
|
|
444
|
+
image-rendering: crisp-edges;
|
|
445
|
+
`,Wg=P.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
446
|
+
position: absolute;
|
|
447
|
+
background: ${e=>e.$backgroundColor};
|
|
448
|
+
transform: translateZ(0);
|
|
449
|
+
backface-visibility: hidden;
|
|
450
|
+
`,Bg=({index:e,midiNotes:t,length:n,waveHeight:r,devicePixelRatio:s,samplesPerPixel:o,sampleRate:a,clipOffsetSeconds:i,noteColor:l="#2a7070",selectedNoteColor:c="#3d9e9e",isSelected:u=!1,transparentBackground:f=!1,backgroundColor:h="#1a1a2e"})=>{const{canvasRef:d,canvasMapRef:p}=Zs(),v=hi(),y=js(n,Le,v),{minMidi:m,maxMidi:b}=g.useMemo(()=>{if(t.length===0)return{minMidi:0,maxMidi:127};let S=127,k=0;for(const E of t)E.midi<S&&(S=E.midi),E.midi>k&&(k=E.midi);return{minMidi:Math.max(0,S-1),maxMidi:Math.min(127,k+1)}},[t]),_=u?c:l;g.useEffect(()=>{const S=performance.now(),k=b-m+1,E=Math.max(2,r/k),T=a/o;for(const[I,M]of p.current.entries()){const $=I*Le,A=M.width/s,R=M.getContext("2d");if(!R)continue;R.resetTransform(),R.clearRect(0,0,M.width,M.height),R.imageSmoothingEnabled=!1,R.scale(s,s);const W=$*o/a,q=($+A)*o/a;for(const z of t){const J=z.time-i;if(J+z.duration<=W||J>=q)continue;const j=J*T-$,se=Math.max(2,z.duration*T),U=(b-z.midi)/k*r,ie=.3+z.velocity*.7;R.fillStyle=_,R.globalAlpha=ie;const le=1;R.beginPath(),R.roundRect(j,U,se,E,le),R.fill()}R.globalAlpha=1}console.log(`[piano-roll] draw ch${e}: ${p.current.size} chunks, ${t.length} notes, ${(performance.now()-S).toFixed(1)}ms`)},[p,t,r,s,o,a,i,_,m,b,n,y,e]);const w=y.map(S=>{const k=S*Le,E=Math.min(n-k,Le);return C.jsx(Lg,{$cssWidth:E,$left:k,width:E*s,height:r*s,$waveHeight:r,"data-index":S,ref:d},`${n}-${S}`)}),x=f?"transparent":h;return C.jsx(Wg,{$index:e,$cssWidth:n,$waveHeight:r,$backgroundColor:x,children:w})};P.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
|
|
443
451
|
position: absolute;
|
|
444
452
|
top: 0;
|
|
445
453
|
left: 0;
|
|
@@ -449,7 +457,7 @@
|
|
|
449
457
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
450
458
|
pointer-events: none;
|
|
451
459
|
will-change: transform;
|
|
452
|
-
`;
|
|
460
|
+
`;P.div`
|
|
453
461
|
position: absolute;
|
|
454
462
|
top: 0;
|
|
455
463
|
left: 0;
|
|
@@ -457,7 +465,7 @@
|
|
|
457
465
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
458
466
|
pointer-events: none;
|
|
459
467
|
will-change: transform;
|
|
460
|
-
`;
|
|
468
|
+
`;P.div`
|
|
461
469
|
position: absolute;
|
|
462
470
|
top: -10px;
|
|
463
471
|
left: -6px;
|
|
@@ -466,30 +474,39 @@
|
|
|
466
474
|
border-left: 7px solid transparent;
|
|
467
475
|
border-right: 7px solid transparent;
|
|
468
476
|
border-top: 10px solid ${e=>e.$color};
|
|
469
|
-
`;
|
|
477
|
+
`;P.div`
|
|
470
478
|
position: absolute;
|
|
471
479
|
top: 0;
|
|
472
480
|
left: 0;
|
|
473
481
|
width: 2px;
|
|
474
482
|
height: 100%;
|
|
475
483
|
background: ${e=>e.$color};
|
|
476
|
-
`;var
|
|
484
|
+
`;var Vg=P.div`
|
|
485
|
+
display: flex;
|
|
477
486
|
overflow-y: hidden;
|
|
487
|
+
position: relative;
|
|
488
|
+
`,Ng=P.div.attrs(e=>({style:{width:`${e.$width}px`}}))`
|
|
489
|
+
flex-shrink: 0;
|
|
490
|
+
overflow: hidden;
|
|
491
|
+
`,zg=P.div.attrs(e=>({style:{height:`${e.$height}px`}}))``,jg=P.div`
|
|
478
492
|
overflow-x: auto;
|
|
493
|
+
overflow-y: hidden;
|
|
494
|
+
overflow-anchor: none;
|
|
495
|
+
flex: 1;
|
|
479
496
|
position: relative;
|
|
480
|
-
`,
|
|
497
|
+
`,Zg=P.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
|
|
481
498
|
position: relative;
|
|
482
499
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
483
|
-
`,
|
|
500
|
+
`,Hg=P.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
|
|
484
501
|
background: ${e=>e.$backgroundColor||"white"};
|
|
485
502
|
width: 100%;
|
|
486
503
|
position: relative;
|
|
487
504
|
overflow: hidden; /* Constrain loop region to timescale area */
|
|
488
|
-
`,
|
|
505
|
+
`,Gg=P.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
|
|
489
506
|
position: relative;
|
|
490
507
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
491
508
|
width: 100%;
|
|
492
|
-
`,
|
|
509
|
+
`,Ug=P.div`
|
|
493
510
|
position: absolute;
|
|
494
511
|
top: 0;
|
|
495
512
|
left: 0;
|
|
@@ -498,7 +515,7 @@
|
|
|
498
515
|
cursor: crosshair;
|
|
499
516
|
/* When selecting, raise z-index above clip boundaries (z-index: 105) to prevent interference */
|
|
500
517
|
z-index: ${e=>e.$isSelecting?110:1};
|
|
501
|
-
`,
|
|
518
|
+
`,mi=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:s,tracksWidth:o,controlsWidth:a,onTracksClick:i,onTracksMouseDown:l,onTracksMouseMove:c,onTracksMouseUp:u,scrollContainerRef:f,isSelecting:h,"data-playlist-state":d,trackControlsSlots:p,timescaleGapHeight:v=0})=>{const y=g.useRef(null),m=g.useCallback(_=>{y.current=_,f?.(_)},[f]),b=a!==void 0&&a>0;return C.jsxs(Vg,{"data-playlist-state":d,children:[b&&C.jsxs(Ng,{$width:a,children:[v>0&&C.jsx(zg,{$height:v}),p]}),C.jsx(jg,{"data-scroll-container":"true",ref:m,children:C.jsx(hg,{containerRef:y,children:C.jsxs(Zg,{$backgroundColor:t,$width:o,children:[r&&C.jsx(Hg,{$width:s,$backgroundColor:n,children:r}),C.jsxs(Gg,{$width:o,$backgroundColor:t,children:[e,(i||l)&&C.jsx(Ug,{$isSelecting:h,onClick:i,onMouseDown:l,onMouseMove:c,onMouseUp:u})]})]})})})]})};P.withTheme(mi);var Xg=P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
502
519
|
position: absolute;
|
|
503
520
|
top: 0;
|
|
504
521
|
background: ${e=>e.$color};
|
|
@@ -506,14 +523,14 @@
|
|
|
506
523
|
z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
|
|
507
524
|
pointer-events: none;
|
|
508
525
|
opacity: 0.3;
|
|
509
|
-
`,
|
|
526
|
+
`,Td=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:C.jsx(Xg,{$left:e,$width:r,$color:n,"data-selection":!0})};P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
510
527
|
position: absolute;
|
|
511
528
|
top: 0;
|
|
512
529
|
background: ${e=>e.$color};
|
|
513
530
|
height: 100%;
|
|
514
531
|
z-index: 55; /* Between clips (z-index: 50) and selection (z-index: 60) */
|
|
515
532
|
pointer-events: none;
|
|
516
|
-
`;
|
|
533
|
+
`;P.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
|
|
517
534
|
position: absolute;
|
|
518
535
|
top: 0;
|
|
519
536
|
width: 2px;
|
|
@@ -533,7 +550,7 @@
|
|
|
533
550
|
border-top: 8px solid ${e=>e.$color};
|
|
534
551
|
${e=>e.$isStart?"border-right: 8px solid transparent;":"border-left: 8px solid transparent;"}
|
|
535
552
|
}
|
|
536
|
-
`;var
|
|
553
|
+
`;var Pl=P.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
|
|
537
554
|
position: absolute;
|
|
538
555
|
top: 0;
|
|
539
556
|
width: 12px;
|
|
@@ -570,7 +587,7 @@
|
|
|
570
587
|
&:hover::before {
|
|
571
588
|
opacity: 1;
|
|
572
589
|
}
|
|
573
|
-
`,
|
|
590
|
+
`,Yg=P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
574
591
|
position: absolute;
|
|
575
592
|
top: 0;
|
|
576
593
|
height: 100%;
|
|
@@ -581,26 +598,25 @@
|
|
|
581
598
|
&:active {
|
|
582
599
|
cursor: grabbing;
|
|
583
600
|
}
|
|
584
|
-
`,
|
|
601
|
+
`,Kg=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopStartChange:s,onLoopEndChange:o,onLoopRegionMove:a,minPosition:i=0,maxPosition:l=1/0})=>{const[c,u]=g.useState(null),f=g.useRef(0),h=g.useRef(0),d=g.useRef(0),p=Math.max(0,t-e),v=g.useCallback((m,b)=>{m.preventDefault(),m.stopPropagation(),u(b),f.current=m.clientX,h.current=b==="start"?e:t;const _=x=>{const S=x.clientX-f.current,k=h.current+S;if(b==="start"){const E=Math.max(i,Math.min(t-10,k));s?.(E)}else{const E=Math.max(e+10,Math.min(l,k));o?.(E)}},w=()=>{u(null),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",w)},[e,t,i,l,s,o]),y=g.useCallback(m=>{m.preventDefault(),m.stopPropagation(),u("region"),f.current=m.clientX,h.current=e,d.current=t;const b=t-e,_=x=>{const S=x.clientX-f.current;let k=h.current+S,E=d.current+S;k<i&&(k=i,E=i+b),E>l&&(E=l,k=l-b),a?.(k,E)},w=()=>{u(null),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",w)},[e,t,i,l,a]);return p<=0?null:C.jsxs(C.Fragment,{children:[C.jsx(Yg,{$left:e,$width:p,$color:r,$isDragging:c==="region",onMouseDown:y,"data-loop-region-timescale":!0}),C.jsx(Pl,{$left:e,$color:n,$isStart:!0,$isDragging:c==="start",onMouseDown:m=>v(m,"start"),"data-loop-marker-handle":"start"}),C.jsx(Pl,{$left:t,$color:n,$isStart:!1,$isDragging:c==="end",onMouseDown:m=>v(m,"end"),"data-loop-marker-handle":"end"})]})},qg=P.div`
|
|
585
602
|
position: absolute;
|
|
586
603
|
top: 0;
|
|
604
|
+
left: 0;
|
|
587
605
|
right: 0;
|
|
588
606
|
height: 100%; /* Stay within timescale bounds, don't extend into tracks */
|
|
589
607
|
cursor: crosshair;
|
|
590
608
|
z-index: 40; /* Below markers and shading */
|
|
591
|
-
`,
|
|
609
|
+
`,Jg=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopRegionChange:s,minPosition:o=0,maxPosition:a=1/0})=>{const[,i]=g.useState(!1),l=g.useRef(0),c=g.useRef(null),u=t>e,f=g.useCallback(h=>{const d=h.target;if(d.closest("[data-loop-marker-handle]")||d.closest("[data-loop-region-timescale]"))return;h.preventDefault(),i(!0);const p=c.current?.getBoundingClientRect();if(!p)return;const v=h.clientX-p.left,y=Math.max(o,Math.min(a,v));l.current=y,s?.(y,y);const m=_=>{const w=_.clientX-p.left,x=Math.max(o,Math.min(a,w)),S=Math.min(l.current,x),k=Math.max(l.current,x);s?.(S,k)},b=()=>{i(!1),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",b)},[o,a,s]);return C.jsx(qg,{ref:c,onMouseDown:f,"data-timescale-loop-creator":!0,children:u&&C.jsx(Kg,{startPosition:e,endPosition:t,markerColor:n,regionColor:r,minPosition:o,maxPosition:a,onLoopStartChange:h=>s?.(h,t),onLoopEndChange:h=>s?.(e,h),onLoopRegionMove:(h,d)=>s?.(h,d)})})};function er(e,t){const n=Math.floor(e/3600)%24,r=Math.floor(e/60)%60,s=(e%60).toFixed(t);return String(n).padStart(2,"0")+":"+String(r).padStart(2,"0")+":"+s.padStart(t+3,"0")}function Ln(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return er(e,0);case"hh:mm:ss.u":return er(e,1);case"hh:mm:ss.uu":return er(e,2);case"hh:mm:ss.uuu":return er(e,3);default:return er(e,3)}}function $d(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,s=parseInt(n[1],10)||0,o=parseFloat(n[2])||0;return r*3600+s*60+o}default:return 0}}var Fl=({id:e,label:t,value:n,format:r,className:s,onChange:o,readOnly:a=!1})=>{const[i,l]=g.useState("");g.useEffect(()=>{const h=Ln(n,r);l(h)},[n,r,e]);const c=h=>{const d=h.target.value;l(d)},u=()=>{if(o){const h=$d(i,r);o(h)}l(Ln(n,r))},f=h=>{h.key==="Enter"&&h.currentTarget.blur()};return C.jsxs(C.Fragment,{children:[C.jsx(cg,{as:"label",htmlFor:e,children:t}),C.jsx(_d,{type:"text",className:s,id:e,value:i,onChange:c,onBlur:u,onKeyDown:f,readOnly:a})]})},Qg=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[s,o]=g.useState("hh:mm:ss.uuu");g.useEffect(()=>{const l=document.querySelector(".time-format"),c=()=>{l&&o(l.value)};return l&&(o(l.value),l.addEventListener("change",c)),()=>{l?.removeEventListener("change",c)}},[]);const a=l=>{n&&n(l,t)},i=l=>{n&&n(e,l)};return C.jsxs("div",{className:r,children:[C.jsx(Fl,{id:"audio_start",label:"Start of audio selection",value:e,format:s,className:"audio-start form-control mr-sm-2",onChange:a}),C.jsx(Fl,{id:"audio_end",label:"End of audio selection",value:t,format:s,className:"audio-end form-control mr-sm-2",onChange:i})]})};function ps(){return window.devicePixelRatio}var Rd=g.createContext(ps()),Dd=({children:e})=>{const[t,n]=g.useState(ps());return matchMedia(`(resolution: ${ps()}dppx)`).addEventListener("change",()=>{n(ps())},{once:!0}),C.jsx(Rd.Provider,{value:Math.ceil(t),children:e})},gi=()=>g.useContext(Rd),Nr=g.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}),Hs=()=>g.useContext(Nr),zr=()=>g.useContext(P.ThemeContext);g.createContext(C.jsx(g.Fragment,{}));var ev=0,tv=!1,nv=0,rv=0,sv={progress:ev,isPlaying:tv,selectionStart:nv,selectionEnd:rv};g.createContext(sv);g.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var ov=(e,t,n)=>(e-t)/(n-t),av=P.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
592
610
|
position: absolute;
|
|
593
611
|
background: #000;
|
|
594
612
|
transform: translateZ(0);
|
|
595
613
|
backface-visibility: hidden;
|
|
596
|
-
`,
|
|
614
|
+
`,iv=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
597
615
|
position: absolute;
|
|
598
616
|
top: 0;
|
|
599
|
-
/* Promote to own compositing layer for smoother scrolling */
|
|
600
|
-
will-change: transform;
|
|
601
617
|
image-rendering: pixelated;
|
|
602
618
|
image-rendering: crisp-edges;
|
|
603
|
-
`;function
|
|
619
|
+
`;function lv(){const e=new Uint8Array(768);for(let t=0;t<256;t++)e[t*3]=e[t*3+1]=e[t*3+2]=t;return e}var cv=lv(),Ol=({index:e,channelIndex:t,data:n,length:r,waveHeight:s,devicePixelRatio:o=1,samplesPerPixel:a,colorLUT:i,frequencyScaleFn:l,minFrequency:c=0,maxFrequency:u,workerApi:f,clipId:h,onCanvasesReady:d})=>{const p=t??e,{canvasRef:v,canvasMapRef:y}=Zs(),m=g.useRef([]),b=g.useRef(new WeakSet),_=g.useRef(f),w=g.useRef(d),x=!!(f&&h),S=hi(),k=js(r,Le,S),E=i??cv,T=u??(n?n.sampleRate/2:22050),I=l??ov,M=!!l;g.useEffect(()=>{_.current=f},[f]),g.useEffect(()=>{w.current=d},[d]),g.useEffect(()=>{if(!x)return;const A=_.current;if(!A||!h)return;const R=m.current.length,W=[];for(const J of m.current){const ee=J.match(/chunk(\d+)$/);if(!ee){W.push(J);continue}const j=parseInt(ee[1],10),se=y.current.get(j);if(se&&se.isConnected)W.push(J);else try{A.unregisterCanvas(J)}catch(U){console.warn(`[spectrogram] unregisterCanvas failed for ${J}:`,U)}}m.current=W;const q=[];for(const[J,ee]of y.current.entries()){if(b.current.has(ee))continue;const j=`${h}-ch${p}-chunk${J}`;let se;try{se=ee.transferControlToOffscreen()}catch(U){console.warn(`[spectrogram] transferControlToOffscreen failed for ${j}:`,U);continue}b.current.add(ee);try{A.registerCanvas(j,se),q.push(j)}catch(U){console.warn(`[spectrogram] registerCanvas failed for ${j}:`,U);continue}}if(q.length>0&&(m.current=[...m.current,...q]),q.length>0||W.length<R){const J=m.current,ee=J.map(j=>{const se=j.match(/chunk(\d+)$/);if(!se)return console.warn(`[spectrogram] Unexpected canvas ID format: ${j}`),Le;const U=parseInt(se[1],10);return Math.min(r-U*Le,Le)});w.current?.(J,ee)}},[y,x,h,p,r,k]),g.useEffect(()=>()=>{const A=_.current;if(A){for(const R of m.current)try{A.unregisterCanvas(R)}catch(W){console.warn(`[spectrogram] unregisterCanvas failed for ${R}:`,W)}m.current=[]}},[]),g.useEffect(()=>{if(x||!n)return;const{frequencyBinCount:A,frameCount:R,hopSize:W,sampleRate:q,gainDb:z,rangeDb:J}=n,ee=J===0?1:J,j=se=>se/A*(q/2);for(const[se,U]of y.current.entries()){const ie=se*Le,le=U.getContext("2d");if(!le)continue;const ge=U.width/o,Se=s;le.resetTransform(),le.clearRect(0,0,U.width,U.height),le.imageSmoothingEnabled=!1,le.scale(o,o);const N=le.createImageData(ge,Se),G=N.data;for(let ye=0;ye<ge;ye++){const Q=(ie+ye)*a,O=Math.floor(Q/W);if(O<0||O>=R)continue;const _e=O*A;for(let Ne=0;Ne<Se;Ne++){const Be=1-Ne/Se;let ve=Math.floor(Be*A);if(M){let xe=0,Fe=A-1;for(;xe<Fe;){const Oe=xe+Fe>>1,Et=j(Oe);I(Et,c,T)<Be?xe=Oe+1:Fe=Oe}ve=xe}if(ve<0||ve>=A)continue;const Ve=n.data[_e+ve],ne=Math.max(0,Math.min(1,(Ve+ee+z)/ee)),Ge=Math.floor(ne*255),je=(Ne*ge+ye)*4;G[je]=E[Ge*3],G[je+1]=E[Ge*3+1],G[je+2]=E[Ge*3+2],G[je+3]=255}}if(le.resetTransform(),le.putImageData(N,0,0),o!==1){const ye=document.createElement("canvas");ye.width=ge,ye.height=Se;const Z=ye.getContext("2d");if(!Z)continue;Z.putImageData(N,0,0),le.clearRect(0,0,U.width,U.height),le.imageSmoothingEnabled=!1,le.drawImage(ye,0,0,U.width,U.height)}}},[y,x,n,r,s,o,a,E,c,T,I,M,k]);const $=k.map(A=>{const R=A*Le,W=Math.min(r-R,Le);return C.jsx(iv,{$cssWidth:W,$left:R,width:W*o,height:s*o,$waveHeight:s,"data-index":A,ref:v},`${r}-${A}`)});return C.jsx(av,{$index:e,$cssWidth:r,$waveHeight:s,children:$})},Pd=({isSelected:e,transparentBackground:t,renderMode:n="waveform",spectrogramData:r,spectrogramColorLUT:s,samplesPerPixel:o,spectrogramFrequencyScaleFn:a,spectrogramMinFrequency:i,spectrogramMaxFrequency:l,spectrogramWorkerApi:c,spectrogramClipId:u,spectrogramOnCanvasesReady:f,midiNotes:h,sampleRate:d,clipOffsetSeconds:p,...v})=>{const y=zr(),{waveHeight:m,barWidth:b,barGap:_,samplesPerPixel:w,sampleRate:x}=Hs(),S=gi(),k=o??w,E=e&&y?y.selectedWaveOutlineColor:y?.waveOutlineColor,T=e&&y?y.selectedWaveFillColor:y?.waveFillColor,I=y?.waveformDrawMode||"inverted",M=r||c;if(n==="spectrogram"&&M)return C.jsx(Ol,{index:v.index,data:r,length:v.length,waveHeight:m,devicePixelRatio:S,samplesPerPixel:k,colorLUT:s,frequencyScaleFn:a,minFrequency:i,maxFrequency:l,workerApi:c,clipId:u,onCanvasesReady:f});if(n==="both"&&M){const $=Math.floor(m/2);return C.jsxs(C.Fragment,{children:[C.jsx(Ol,{index:v.index*2,channelIndex:v.index,data:r,length:v.length,waveHeight:$,devicePixelRatio:S,samplesPerPixel:k,colorLUT:s,frequencyScaleFn:a,minFrequency:i,maxFrequency:l,workerApi:c,clipId:u,onCanvasesReady:f}),C.jsx("div",{style:{position:"absolute",top:(v.index*2+1)*$,width:v.length,height:$},children:C.jsx($l,{...v,index:0,waveOutlineColor:E,waveFillColor:T,waveHeight:$,devicePixelRatio:S,barWidth:b,barGap:_,transparentBackground:t,drawMode:I})})]})}return n==="piano-roll"?C.jsx(Bg,{index:v.index,midiNotes:h??[],length:v.length,waveHeight:m,devicePixelRatio:S,samplesPerPixel:k,sampleRate:d??x,clipOffsetSeconds:p??0,noteColor:y?.pianoRollNoteColor,selectedNoteColor:y?.pianoRollSelectedNoteColor,isSelected:e,transparentBackground:t,backgroundColor:y?.pianoRollBackgroundColor}):C.jsx($l,{...v,waveOutlineColor:E,waveFillColor:T,waveHeight:m,devicePixelRatio:S,barWidth:b,barGap:_,transparentBackground:t,drawMode:I})},Ll=72,uv=P.div`
|
|
604
620
|
position: sticky;
|
|
605
621
|
left: 0;
|
|
606
622
|
z-index: 101;
|
|
@@ -608,48 +624,31 @@
|
|
|
608
624
|
height: 0;
|
|
609
625
|
width: 0;
|
|
610
626
|
overflow: visible;
|
|
611
|
-
`;function
|
|
627
|
+
`;function dv(e,t,n){const s=[20,50,100,200,500,1e3,2e3,3e3,4e3,5e3,8e3,1e4,12e3,16e3,2e4].filter(l=>l>=e&&l<=t),o=Math.max(2,Math.floor(n/20));if(s.length<=o)return s;const a=(s.length-1)/(o-1),i=[];for(let l=0;l<o;l++)i.push(s[Math.round(l*a)]);return i}var fv=({waveHeight:e,numChannels:t,frequencyScaleFn:n,minFrequency:r,maxFrequency:s,labelsColor:o="#ccc",labelsBackground:a="rgba(0,0,0,0.6)",renderMode:i="spectrogram",hasClipHeaders:l=!1})=>{const c=g.useRef(null),u=gi(),f=i==="both"?Math.floor(e/2):e,h=t*e,d=l?22:0;return g.useLayoutEffect(()=>{const p=c.current;if(!p)return;const v=p.getContext("2d");if(!v)return;v.resetTransform(),v.clearRect(0,0,p.width,p.height),v.scale(u,u);const y=dv(r,s,f);for(let m=0;m<t;m++){const b=m*e+d;v.font="11px monospace",v.textBaseline="middle";for(const _ of y){const w=n(_,r,s);if(w<0||w>1)continue;const x=b+f*(1-w),S=_>=1e3?`${(_/1e3).toFixed(1)}k`:`${_} Hz`,k=v.measureText(S),E=3;v.fillStyle=a,v.fillRect(0,x-7,k.width+E*2,14),v.fillStyle=o,v.fillText(S,E,x)}}},[e,t,n,r,s,o,a,u,f,d]),C.jsx(uv,{$height:h+d,children:C.jsx("canvas",{ref:c,width:Ll*u,height:(h+d)*u,style:{width:Ll,height:h+d,pointerEvents:"none"}})})};function hv(e,t,n){return Math.ceil(e*n/t)}function pv(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var mv=P.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
|
|
612
628
|
position: relative;
|
|
613
629
|
overflow: visible; /* Allow time labels to render above the container */
|
|
614
630
|
border-bottom: 1px solid ${e=>e.theme.timeColor};
|
|
615
631
|
box-sizing: border-box;
|
|
616
|
-
`,
|
|
632
|
+
`,gv=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`,left:`${e.$left}px`}}))`
|
|
617
633
|
position: absolute;
|
|
618
634
|
bottom: 0;
|
|
619
|
-
|
|
620
|
-
will-change: transform;
|
|
621
|
-
`,e0=R.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
|
|
635
|
+
`,vv=P.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
|
|
622
636
|
position: absolute;
|
|
623
637
|
font-size: 0.75rem; /* Smaller font to prevent overflow */
|
|
624
638
|
white-space: nowrap; /* Prevent text wrapping */
|
|
625
639
|
color: ${e=>e.theme.timeColor}; /* Use theme color instead of inheriting */
|
|
626
|
-
`,
|
|
640
|
+
`,yv=e=>{const{theme:{timeColor:t},duration:n,marker:r,bigStep:s,secondStep:o,renderTimestamp:a}=e,{canvasRef:i,canvasMapRef:l}=Zs(),{sampleRate:c,samplesPerPixel:u,timeScaleHeight:f}=g.useContext(Nr),h=gi(),{widthX:d,canvasInfo:p,timeMarkersWithPositions:v}=g.useMemo(()=>{const x=new Map,S=[],k=hv(n/1e3,u,c),E=c/u;let T=0;for(let I=0;I<k;I+=E*o/1e3){const M=Math.floor(I);if(T%r===0){const $=T,A=pv($),R=a?C.jsx(g.Fragment,{children:a($,M)},`timestamp-${T}`):C.jsx(vv,{$left:M,children:A},A);S.push({pix:M,element:R}),x.set(M,f)}else T%s===0?x.set(M,Math.floor(f/2)):T%o===0&&x.set(M,Math.floor(f/5));T+=o}return{widthX:k,canvasInfo:x,timeMarkersWithPositions:S}},[n,u,c,r,s,o,a,f]),y=js(d,Le),m=y.map(x=>{const S=x*Le,k=Math.min(d-S,Le);return C.jsx(gv,{$cssWidth:k,$left:S,$timeScaleHeight:f,width:k*h,height:f*h,"data-index":x,ref:i},`timescale-${x}`)}),b=y.length>0?y[0]*Le:0,_=y.length>0?(y[y.length-1]+1)*Le:1/0,w=y.length>0?v.filter(({pix:x})=>x>=b&&x<_).map(({element:x})=>x):v.map(({element:x})=>x);return g.useLayoutEffect(()=>{for(const[x,S]of l.current.entries()){const k=S.getContext("2d");if(!k)continue;const E=x*Le,T=S.width/h;k.resetTransform(),k.clearRect(0,0,S.width,S.height),k.imageSmoothingEnabled=!1,k.fillStyle=t,k.scale(h,h);for(const[I,M]of p.entries()){if(I<E||I>=E+T)continue;const $=I-E,A=f-M;k.fillRect($,A,1,M)}}},[l,n,h,t,f,p,y]),C.jsxs(mv,{$cssWidth:d,$timeScaleHeight:f,children:[w,m]})},bv=P.withTheme(yv),Wl=new Map([[700,{marker:1e3,bigStep:500,smallStep:100}],[1500,{marker:2e3,bigStep:1e3,smallStep:200}],[2500,{marker:2e3,bigStep:1e3,smallStep:500}],[5e3,{marker:5e3,bigStep:1e3,smallStep:500}],[1e4,{marker:1e4,bigStep:5e3,smallStep:1e3}],[12e3,{marker:15e3,bigStep:5e3,smallStep:1e3}],[1/0,{marker:3e4,bigStep:1e4,smallStep:5e3}]]);function wv(e){const t=Wl.keys();let n;for(const r of t)if(e<r){n=Wl.get(r);break}return n===void 0&&(n={marker:3e4,bigStep:1e4,smallStep:5e3}),n}var Fd=({renderTimestamp:e})=>{const{samplesPerPixel:t,duration:n}=g.useContext(Nr);let r=wv(t);return C.jsx(bv,{marker:r.marker,bigStep:r.bigStep,secondStep:r.smallStep,duration:n,renderTimestamp:e})},_v=P.div`
|
|
627
641
|
display: inline-flex;
|
|
628
642
|
align-items: center;
|
|
629
643
|
gap: 0.5rem;
|
|
630
|
-
`,
|
|
644
|
+
`,xv=[{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"}],Cv=({value:e,onChange:t,disabled:n=!1,className:r})=>{const s=o=>{t(o.target.value)};return C.jsx(_v,{className:r,children:C.jsx(xd,{className:"time-format",value:e,onChange:s,disabled:n,"aria-label":"Time format selection",children:xv.map(o=>C.jsx("option",{value:o.value,children:o.label},o.value))})})},Sv=P.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?pi:0)}px`}}))`
|
|
631
645
|
position: relative;
|
|
632
|
-
display: flex;
|
|
633
646
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
634
|
-
`,
|
|
647
|
+
`,kv=P.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
|
|
635
648
|
position: relative;
|
|
636
649
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
637
|
-
flex: 1;
|
|
638
|
-
`,c0=R.div.attrs(e=>({style:{width:`${e.$controlWidth}px`}}))`
|
|
639
|
-
position: sticky;
|
|
640
|
-
z-index: 102; /* Above waveform content and spectrogram labels (101), below Docusaurus navbar (200) */
|
|
641
|
-
left: 0;
|
|
642
650
|
height: 100%;
|
|
643
|
-
|
|
644
|
-
pointer-events: auto;
|
|
645
|
-
background: ${e=>e.theme.surfaceColor};
|
|
646
|
-
transition: background 0.15s ease-in-out;
|
|
647
|
-
|
|
648
|
-
/* Selected track: highlighted background */
|
|
649
|
-
${e=>e.$isSelected&&`
|
|
650
|
-
background: ${e.theme.selectedTrackControlsBackground};
|
|
651
|
-
`}
|
|
652
|
-
`,Id=({numChannels:e,children:t,className:n,backgroundColor:r,offset:s=0,width:a,hasClipHeaders:o=!1,onClick:i,trackId:l,isSelected:c=!1})=>{const{waveHeight:u,controls:{show:d,width:p}}=zs(),h=Fg();return C.jsxs(i0,{$numChannels:e,className:n,$waveHeight:u,$controlWidth:d?p:0,$width:a,$hasClipHeaders:o,$isSelected:c,children:[C.jsx(c0,{$controlWidth:d?p:0,$isSelected:c,children:h}),C.jsx(l0,{$controlWidth:d?p:0,$backgroundColor:r,$offset:s,onClick:i,"data-track-id":l,children:t})]})},Ml=R.button.attrs({type:"button"})`
|
|
651
|
+
`,Od=({numChannels:e,children:t,className:n,backgroundColor:r,offset:s=0,width:o,hasClipHeaders:a=!1,onClick:i,trackId:l,isSelected:c=!1})=>{const{waveHeight:u}=Hs();return C.jsx(Sv,{$numChannels:e,className:n,$waveHeight:u,$width:o,$hasClipHeaders:a,children:C.jsx(kv,{$backgroundColor:r,$offset:s,onClick:i,"data-track-id":l,children:t})})},Bl=P.button.attrs({type:"button"})`
|
|
653
652
|
display: inline-block;
|
|
654
653
|
font-family: ${e=>e.theme.fontFamily};
|
|
655
654
|
font-weight: 500;
|
|
@@ -711,7 +710,7 @@
|
|
|
711
710
|
box-shadow: 0 0 0 0.2rem ${e.theme.inputFocusBorder}33;
|
|
712
711
|
}
|
|
713
712
|
`}
|
|
714
|
-
`,
|
|
713
|
+
`,Ev=P.div`
|
|
715
714
|
margin-bottom: 0.3rem;
|
|
716
715
|
|
|
717
716
|
button:not(:first-child) {
|
|
@@ -723,7 +722,7 @@
|
|
|
723
722
|
border-top-right-radius: 0;
|
|
724
723
|
border-bottom-right-radius: 0;
|
|
725
724
|
}
|
|
726
|
-
`,
|
|
725
|
+
`,Iv=P.button`
|
|
727
726
|
position: absolute;
|
|
728
727
|
left: 0;
|
|
729
728
|
top: 0;
|
|
@@ -745,7 +744,7 @@
|
|
|
745
744
|
opacity: 1;
|
|
746
745
|
color: #dc3545;
|
|
747
746
|
}
|
|
748
|
-
`,
|
|
747
|
+
`,Mv=({onClick:e,title:t="Remove track"})=>C.jsx(Iv,{onClick:e,title:t,children:C.jsx(sg,{size:12,weight:"bold"})}),Av=P.div`
|
|
749
748
|
background: transparent;
|
|
750
749
|
width: 100%;
|
|
751
750
|
height: 100%;
|
|
@@ -758,7 +757,7 @@
|
|
|
758
757
|
text-align: center;
|
|
759
758
|
border: 1px solid ${e=>e.theme.borderColor};
|
|
760
759
|
border-radius: ${e=>e.theme.borderRadius};
|
|
761
|
-
`,
|
|
760
|
+
`,Tv=P.header`
|
|
762
761
|
overflow: hidden;
|
|
763
762
|
height: 26px;
|
|
764
763
|
width: 100%;
|
|
@@ -769,7 +768,7 @@
|
|
|
769
768
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
770
769
|
color: ${e=>e.theme.textColor};
|
|
771
770
|
background-color: transparent;
|
|
772
|
-
|
|
771
|
+
`,$v=e=>C.jsx(bd,{weight:"light",...e}),Rv=e=>C.jsx(yd,{weight:"light",...e}),Dv=e=>C.jsx(vd,{weight:"bold",...e}),Vl=P(Cd)`
|
|
773
772
|
width: 75%;
|
|
774
773
|
height: 5px;
|
|
775
774
|
background: ${e=>e.theme.sliderTrackColor};
|
|
@@ -818,7 +817,7 @@
|
|
|
818
817
|
&:focus::-moz-range-thumb {
|
|
819
818
|
border: 2px solid ${e=>e.theme.textColor};
|
|
820
819
|
}
|
|
821
|
-
`,
|
|
820
|
+
`,Nl=P.label`
|
|
822
821
|
width: 100%;
|
|
823
822
|
display: flex;
|
|
824
823
|
justify-content: space-between;
|
|
@@ -826,10 +825,10 @@
|
|
|
826
825
|
padding: 0 1rem;
|
|
827
826
|
margin-bottom: 0.2rem;
|
|
828
827
|
font-size: 14px;
|
|
829
|
-
`,
|
|
828
|
+
`,Pv=P.div`
|
|
830
829
|
position: relative;
|
|
831
830
|
display: inline-block;
|
|
832
|
-
`,
|
|
831
|
+
`,Fv=P.button`
|
|
833
832
|
background: none;
|
|
834
833
|
border: none;
|
|
835
834
|
cursor: pointer;
|
|
@@ -843,7 +842,7 @@
|
|
|
843
842
|
&:hover {
|
|
844
843
|
opacity: 1;
|
|
845
844
|
}
|
|
846
|
-
`,
|
|
845
|
+
`,ms=180,Ov=P.div`
|
|
847
846
|
position: fixed;
|
|
848
847
|
top: ${e=>e.$top}px;
|
|
849
848
|
left: ${e=>e.$left}px;
|
|
@@ -853,14 +852,14 @@
|
|
|
853
852
|
border: 1px solid rgba(128, 128, 128, 0.4);
|
|
854
853
|
border-radius: 6px;
|
|
855
854
|
padding: 0.5rem 0;
|
|
856
|
-
min-width:
|
|
855
|
+
min-width: ${ms}px;
|
|
857
856
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
858
|
-
`,
|
|
857
|
+
`,Lv=P.hr`
|
|
859
858
|
border: none;
|
|
860
859
|
border-top: 1px solid rgba(128, 128, 128, 0.3);
|
|
861
860
|
margin: 0.35rem 0;
|
|
862
|
-
`,
|
|
863
|
-
`,10)+1,a=r.substring(s)+"",o=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(o)}function P0(e,t,n){var r;return function(a){return r=r||R0(e),new Worker(r,a)}}var W0=P0("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function mt(e){if(M0(e)&&(e=T0(e)),$0(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 _n(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var er={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function F0(e){var t={scale:e.scale||er.scale,bits:e.bits||er.bits,amplitude_scale:e.amplitude_scale||er.amplitude_scale,split_channels:e.split_channels||er.split_channels,disable_worker:e.disable_worker||er.disable_worker};return t}function O0(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Ad(e,t,n){var r=O0(e);if(t.disable_worker){var s=A0({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 mt(s),e)}else{var a=new W0;a.onmessage=function(o){n(void 0,new mt(o.data),e)},a.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 B0(e,t,n,r){function s(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var a=e.decodeAudioData(t,function(o){Ad(o,n,r)},s);a&&a.catch(s)}mt.create=function(t){return new mt(t)};mt.createFromAudio=function(e,t){var n=F0(e);if(e.audio_context&&e.array_buffer)return B0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Ad(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function js(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,s=this._inputData.bits===8?1:2,a=r+n*2*this._inputData.channels*s;this._output_data=new ArrayBuffer(a),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 mt(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}js.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};js.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 s=0;s<n;++s)r=this._outputWaveformData.channel(s),r.set_min_sample(this._output_index-1,this._min[s]),r.set_max_sample(this._output_index-1,this._max[s]);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 a=0;a<n;++a)this._min[a]=this._max_value,this._max[a]=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};js.prototype.getOutputData=function(){return this._output_data};mt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!In(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!In(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 js(t);!n.next(););return new mt(n.getOutputData())},concat:function(){var t=this,n=Array.prototype.slice.call(arguments);n.forEach(function(s){if(t.channels!==s.channels||t.sample_rate!==s.sample_rate||t.bits!==s.bits||t.scale!==s.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")});var r=this._concatBuffers.apply(this,n);return mt.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,s=0,a=[this].concat(t).map(function(m){return m._data.buffer}),o=0;o<a.length;o++){var i=a[o],l=new DataView(i).getInt32(16,!0);r+=i.byteLength-n,s+=l}for(var c=new ArrayBuffer(r),u=new DataView(a[0]),d=new DataView(c),p=0;p<n;p++)d.setUint8(p,u.getUint8(p));d.setInt32(16,s,!0);for(var h=0,g=new Uint8Array(c,n),b=0;b<a.length;b++){var y=a[b];g.set(new Uint8Array(y,n),h),h+=y.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!In(t.startIndex)&&!In(t.endIndex)?(n=t.startIndex,r=t.endIndex):!In(t.startTime)&&!In(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 s=r-n,a=24,o=this.bits===8?1:2,i=a+s*2*this.channels*o,l=new ArrayBuffer(i),c=new DataView(l);c.setInt32(0,2,!0),c.setUint32(4,this.bits===8,!0),c.setInt32(8,this.sample_rate,!0),c.setInt32(12,this.scale,!0),c.setInt32(16,s,!0),c.setInt32(20,this.channels,!0);for(var u=0;u<s*this.channels*2;u++){var d=this._at(n*this.channels*2+u);this.bits===8?c.setInt8(a+u,d):c.setInt16(a+u*2,d,!0)}return new mt(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 di(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 mt.create(r)}else{const r=await t.json();return mt.create(r)}}function Md(e,t=0){const n=e.channel(t),r=e.bits,s=n.min_array(),a=n.max_array(),o=s.length,i=r===8?new Int8Array(o*2):new Int16Array(o*2);for(let l=0;l<o;l++)i[l*2]=s[l],i[l*2+1]=a[l];return{data:i,bits:r,length:o,sampleRate:e.sample_rate}}async function L0(e,t=0){const n=await di(e);return Md(n,t)}async function V0(e){const t=await di(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function $d(e,t,n,r){let s=e;if(n!==void 0&&r!==void 0)if(s.scale!==t){const a=e.scale,o=t/a,i=Math.floor(n/t),l=Math.ceil((n+r)/t),c=Math.floor(i*o),u=Math.min(e.length,Math.ceil(l*o));if(c>=u)return null;s=s.slice({startIndex:c,endIndex:u}),s=s.resample({scale:t})}else{const a=Math.floor(n/t),o=Math.ceil((n+r)/t);s=s.slice({startIndex:a,endIndex:o})}else s.scale!==t&&(s=s.resample({scale:t}));return s}function z0(e,t,n=0,r,s){const a=$d(e,t,r,s);if(a===null){const p=e.bits;return{data:p===8?new Int8Array(0):new Int16Array(0),bits:p,length:0}}const o=a.channel(n),i=a.bits,l=o.min_array(),c=o.max_array(),u=l.length,d=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let p=0;p<u;p++)d[p*2]=l[p],d[p*2+1]=c[p];return{data:d,bits:i,length:u}}function Dl(e,t,n,r,s){const a=$d(e,t,r,s);if(a===null){const u=e.bits;return{length:0,data:[],bits:u}}const o=a.channels,i=a.bits,l=[];for(let u=0;u<o;u++){const d=a.channel(u),p=d.min_array(),h=d.max_array(),g=p.length,b=i===8?new Int8Array(g*2):new Int16Array(g*2);for(let y=0;y<g;y++)b[y*2]=p[y],b[y*2+1]=h[y];l.push(b)}if(n&&l.length>1){const u=1/l.length,d=l[0].length/2,p=i===8?new Int8Array(d*2):new Int16Array(d*2);for(let h=0;h<d;h++){let g=0,b=0;for(let y=0;y<l.length;y++)g+=u*l[y][h*2],b+=u*l[y][h*2+1];p[h*2]=g,p[h*2+1]=b}return{length:d,data:[p],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function Td(){const[e,t]=f.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Fn(s,e),parseTime:s=>xd(s,e)}}function Dd({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=f.useState(t),[s,a]=f.useState(!0),[o,i]=f.useState(!0),l=f.useRef(!0),c=f.useRef(!0),u=f.useRef(t),d=f.useCallback(()=>{e.current?.zoomIn()},[e]),p=f.useCallback(()=>{e.current?.zoomOut()},[e]),h=f.useCallback(g=>{g.samplesPerPixel!==u.current&&(u.current=g.samplesPerPixel,f.startTransition(()=>{r(g.samplesPerPixel)})),g.canZoomIn!==l.current&&(l.current=g.canZoomIn,a(g.canZoomIn)),g.canZoomOut!==c.current&&(c.current=g.canZoomOut,i(g.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:d,zoomOut:p,canZoomIn:s,canZoomOut:o,onEngineState:h}}function Rd({engineRef:e,initialVolume:t=1}){const[n,r]=f.useState(t),s=f.useRef(t),a=f.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),o=f.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:a,masterVolumeRef:s,onEngineState:o}}function j0({engineRef:e}){const[t,n]=f.useState(0),[r,s]=f.useState(0),a=f.useRef(0),o=f.useRef(0),i=f.useCallback((c,u)=>{e.current?.setSelection(c,u)},[e]),l=f.useCallback(c=>{c.selectionStart!==a.current&&(a.current=c.selectionStart,n(c.selectionStart)),c.selectionEnd!==o.current&&(o.current=c.selectionEnd,s(c.selectionEnd))},[]);return{selectionStart:t,selectionEnd:r,setSelection:i,selectionStartRef:a,selectionEndRef:o,onEngineState:l}}function Z0({engineRef:e}){const[t,n]=f.useState(!1),[r,s]=f.useState(0),[a,o]=f.useState(0),i=f.useRef(!1),l=f.useRef(0),c=f.useRef(0),u=f.useCallback(g=>{e.current?.setLoopEnabled(g)},[e]),d=f.useCallback((g,b)=>{e.current?.setLoopRegion(g,b)},[e]),p=f.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),h=f.useCallback(g=>{g.isLoopEnabled!==i.current&&(i.current=g.isLoopEnabled,n(g.isLoopEnabled)),g.loopStart!==l.current&&(l.current=g.loopStart,s(g.loopStart)),g.loopEnd!==c.current&&(c.current=g.loopEnd,o(g.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:a,setLoopEnabled:u,setLoopRegion:d,clearLoopRegion:p,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:h}}function H0({engineRef:e}){const[t,n]=f.useState(null),r=f.useRef(null),s=f.useCallback(o=>{e.current?.selectTrack(o)},[e]),a=f.useCallback(o=>{o.selectedTrackId!==r.current&&(r.current=o.selectedTrackId,n(o.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:a,selectedTrackIdRef:r}}const N0=(e=256)=>{const t=f.useRef(null),n=f.useCallback((r,s,a)=>{const o=new j.Analyser("fft",e);return r.connect(o),r.connect(s),t.current=o,function(){o.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:n}};function X0(e,t={}){const{progressive:n=!1}=t,[r,s]=f.useState([]),[a,o]=f.useState(!0),[i,l]=f.useState(null),[c,u]=f.useState(0),d=e.length;return f.useEffect(()=>{if(e.length===0){s([]),o(!1),u(0);return}let p=!1;const h=new AbortController,g=new Map,b=(m,w,_)=>{const v=_??m.audioBuffer;if(!v&&!m.waveformData)throw new Error(`Track ${w+1}: Must provide src, audioBuffer, or waveformData`);const x=v?.duration??m.waveformData?.duration,S=jl({audioBuffer:v,startTime:m.startTime??0,duration:m.duration??x,offset:m.offset??0,name:m.name||`Track ${w+1}`,fadeIn:m.fadeIn,fadeOut:m.fadeOut,waveformData:m.waveformData});if(isNaN(S.startSample)||isNaN(S.durationSamples)||isNaN(S.offsetSamples))throw console.error("Invalid clip values:",S),new Error(`Invalid clip values for track ${w+1}`);return{...Zl({name:m.name||`Track ${w+1}`,clips:[S],muted:m.muted??!1,soloed:m.soloed??!1,volume:m.volume??1,pan:m.pan??0,color:m.color}),effects:m.effects,renderMode:m.renderMode,spectrogramConfig:m.spectrogramConfig,spectrogramColorMap:m.spectrogramColorMap}};return(async()=>{try{o(!0),l(null),u(0);const m=zl.getContext().rawContext,w=e.map(async(v,x)=>{if(v.audioBuffer){const A=b(v,x,v.audioBuffer);return n&&!p&&(g.set(x,A),u(T=>T+1),s(Array.from({length:e.length},(T,P)=>g.get(P)).filter(T=>T!==void 0))),A}if(!v.src&&v.waveformData){const A=b(v,x);return n&&!p&&(g.set(x,A),u(T=>T+1),s(Array.from({length:e.length},(T,P)=>g.get(P)).filter(T=>T!==void 0))),A}if(!v.src)throw new Error(`Track ${x+1}: Must provide src, audioBuffer, or waveformData`);const S=await fetch(v.src,{signal:h.signal});if(!S.ok)throw new Error(`Failed to fetch ${v.src}: ${S.statusText}`);const k=await S.arrayBuffer(),E=await m.decodeAudioData(k);if(!E||!E.sampleRate||!E.duration)throw new Error(`Invalid audio buffer for ${v.src}`);const I=b(v,x,E);return n&&!p&&(g.set(x,I),u(A=>A+1),s(Array.from({length:e.length},(A,T)=>g.get(T)).filter(A=>A!==void 0))),I}),_=await Promise.all(w);p||(n||(s(_),u(_.length)),o(!1))}catch(m){if(!p){const w=m instanceof Error?m.message:"Unknown error loading audio";l(w),o(!1),console.error("Error loading audio tracks:",m)}}})(),()=>{p=!0,h.abort()}},[e,n]),{tracks:r,loading:a,error:i,loadedCount:c,totalCount:d}}function G0({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:a}){const o=f.useRef(null),i=f.useRef(0),l=f.useCallback(d=>{const p=d.operation.source?.data;if(!p)return;if(!p.boundary){o.current=null;return}const g=e[p.trackIndex]?.clips[p.clipIndex];g&&(o.current={offsetSamples:g.offsetSamples,durationSamples:g.durationSamples,startSample:g.startSample},a.current=!0)},[e,a]),c=f.useCallback(d=>{const p=d.operation.source?.data;if(!p||!p.boundary||!o.current)return;const{boundary:h,trackIndex:g,clipIndex:b}=p,w=((d.to?.x??d.operation.position.current.x)-d.operation.position.initial.x)*n,_=Math.floor(.1*r),v=o.current,x=e.map((S,k)=>{if(k!==g)return S;const E=[...S.clips].sort((T,P)=>T.startSample-P.startSample),I=E.findIndex(T=>T===S.clips[b]),A=S.clips.map((T,P)=>{if(P!==b)return T;if(h==="left"){const M={...T,startSample:v.startSample,offsetSamples:v.offsetSamples,durationSamples:v.durationSamples},F=va(M,Math.floor(w),"left",E,I,_),O=v.offsetSamples+F,H=v.durationSamples-F,K=v.startSample+F;return{...T,offsetSamples:O,durationSamples:H,startSample:K}}else{const M={...T,startSample:v.startSample,offsetSamples:v.offsetSamples,durationSamples:v.durationSamples},F=va(M,Math.floor(w),"right",E,I,_),O=v.durationSamples+F;return{...T,durationSamples:O}}});return{...S,clips:A}});i.current=w,t(x)},[e,t,n,r]),u=f.useCallback(d=>{if(d.canceled){if(o.current){const w=d.operation.source?.data;if(w){const{trackIndex:_,clipIndex:v}=w,x=o.current,S=e.map((k,E)=>{if(E!==_)return k;const I=k.clips.map((A,T)=>T!==v?A:{...A,offsetSamples:x.offsetSamples,durationSamples:x.durationSamples,startSample:x.startSample});return{...k,clips:I}});t(S)}}a.current=!1,o.current=null,i.current=0;return}const p=d.operation.source?.data;if(!p)return;const{trackIndex:h,clipId:g,boundary:b}=p,y=b?i.current:d.operation.transform.x*n,m=e[h]?.id;if(b){a.current=!1,m?s.current?s.current.trimClip(m,g,b,Math.floor(y)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${h} not found — trim not synced to adapter`),o.current=null,i.current=0;return}m?s.current?s.current.moveClip(m,g,Math.floor(y)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${h} not found — move not synced to adapter`)},[e,t,n,s,a]);return{onDragStart:l,onDragMove:c,onDragEnd:u}}const ua=.01;function Pd({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:a}){const o=f.useRef(null),i=f.useCallback(u=>{const d=u.operation.source?.data;if(!d||d.annotationIndex===void 0){o.current=null;return}const p=e[d.annotationIndex];p&&(o.current={start:p.start,end:p.end,annotationIndex:d.annotationIndex})},[e]),l=f.useCallback(u=>{if(!o.current)return;const d=u.operation.source?.data;if(!d)return;const{edge:p,annotationIndex:h}=d,g=o.current,m=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n/r,w=p==="start"?g.start+m:g.end+m,_=Y0({annotationIndex:h,newTime:w,isDraggingStart:p==="start",annotations:e,duration:s,linkEndpoints:a});t(_)},[e,t,n,r,s,a]),c=f.useCallback(u=>{if(u.canceled&&o.current){const{annotationIndex:d,start:p,end:h}=o.current,g=e.map((b,y)=>y!==d?b:{...b,start:p,end:h});t(g)}o.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function Y0({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:s,linkEndpoints:a}){const o=[...r],i=r[e];if(n){const l=Math.min(i.end-.1,Math.max(0,t)),c=l-i.start;if(o[e]={...i,start:l},a&&e>0){const u=o[e-1];Math.abs(u.end-i.start)<ua?o[e-1]={...u,end:Math.max(u.start+.1,u.end+c)}:l<=u.end&&(o[e]={...o[e],start:u.end})}else!a&&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,s)),c=l-i.end;if(o[e]={...i,end:l},a&&e<o.length-1){const u=o[e+1];if(Math.abs(u.start-i.end)<ua){const d=u.start+c;o[e+1]={...u,start:Math.min(u.end-.1,d)};let p=e+1;for(;p<o.length-1;){const h=o[p],g=o[p+1];if(Math.abs(g.start-h.end)<ua){const b=h.end-r[p].end;o[p+1]={...g,start:Math.min(g.end-.1,g.start+b)},p++}else break}}else l>=u.start&&(o[e]={...o[e],end:u.start})}else if(!a&&e<o.length-1&&l>o[e+1].start){const u=o[e+1];o[e+1]={...u,start:l};let d=e+1;for(;d<o.length-1;){const p=o[d],h=o[d+1];if(p.end>h.start)o[d+1]={...h,start:p.end},d++;else break}}}return o}function U0(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return f.useMemo(()=>t?[Xa.configure({activationConstraints(a){return a.pointerType==="touch"?[new Ot.Delay({value:n,tolerance:r})]:[new Ot.Distance({value:s})]}})]:[Xa.configure({activationConstraints:[new Ot.Distance({value:s})]})],[t,n,r,s])}const K0=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=ct(),{selectedTrackId:a}=ut(),o=f.useCallback((l,c,u)=>{const{samplesPerPixel:d}=e,p=t[l];if(!p)return!1;const h=p.clips[c];if(!h)return!1;const g=Math.round(u*n),b=Wf(g,d),y=Math.floor(.1*n);if(!Gl(h,b,y))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const m=r.current;return m?(m.splitClip(p.id,h.id,b),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:f.useCallback(()=>{if(!a)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const l=t.findIndex(d=>d.id===a);if(l===-1)return console.warn("Selected track not found"),!1;const c=t[l],u=s.current??0;for(let d=0;d<c.clips.length;d++){const p=c.clips[d],h=p.startSample/n,g=(p.startSample+p.durationSamples)/n;if(u>h&&u<g)return o(l,d,u)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${c.name}"`),!1},[t,s,a,o,n]),splitClipAt:o}},Ts=e=>{const{shortcuts:t,enabled:n=!0}=e,r=f.useCallback(s=>{if(!n)return;const a=s.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const o=t.find(i=>{const l=s.key.toLowerCase()===i.key.toLowerCase()||s.key===i.key,c=i.ctrlKey===void 0||s.ctrlKey===i.ctrlKey,u=i.shiftKey===void 0||s.shiftKey===i.shiftKey,d=i.metaKey===void 0||s.metaKey===i.metaKey,p=i.altKey===void 0||s.altKey===i.altKey;return l&&c&&u&&d&&p});o&&(o.preventDefault!==!1&&s.preventDefault(),o.action())},[t,n]);f.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},q0=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("+")},J0=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=ct(),{setCurrentTime:a,play:o,pause:i,stop:l}=Te(),c=f.useCallback(()=>{s?i():o()},[s,o,i]),u=f.useCallback(()=>{l()},[l]),d=f.useCallback(()=>{a(0),s&&o(0)},[s,a,o]),h=r??[...[{key:" ",action:c,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:u,description:"Stop",preventDefault:!0},{key:"0",action:d,description:"Rewind to start",preventDefault:!0}],...n];return Ts({shortcuts:h,enabled:t}),{rewindToStart:d,togglePlayPause:c,stopPlayback:u,shortcuts:h}},da=.01,ts=.01;function Q0({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:s,linkEndpoints:a,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:c,sampleRate:u,controlsWidth:d=0,onPlay:p}){const h=f.useMemo(()=>t?e.findIndex(I=>I.id===t):-1,[e,t]),g=f.useCallback(I=>{if(!l?.current||!c||!u)return;const A=e.find(B=>B.id===I);if(!A)return;const T=l.current,P=T.clientWidth,M=A.start*u/c+d,F=A.end*u/c+d,O=(M+F)/2,H=T.scrollLeft,K=H,ne=H+P;if(M<K||F>ne){const B=Math.max(0,O-P/2);T.scrollTo({left:B,behavior:"smooth"})}},[e,l,c,u,d]);f.useEffect(()=>{t&&l?.current&&c&&u&&g(t)},[t,g,l,c,u]);const b=f.useCallback(I=>{if(h<0)return;const A=e[h],T=Math.max(0,Math.min(A.end-.1,A.start+I)),P=T-A.start,M=[...e];if(M[h]={...A,start:T},a&&h>0){const F=M[h-1];Math.abs(F.end-A.start)<da&&(M[h-1]={...F,end:Math.max(F.start+.1,F.end+P)})}else if(!a&&h>0){const F=M[h-1];T<F.end&&(M[h-1]={...F,end:T})}n(M)},[e,h,a,n]),y=f.useCallback(I=>{if(h<0)return;const A=e[h],T=Math.max(A.start+.1,Math.min(s,A.end+I)),P=T-A.end,M=[...e];if(M[h]={...A,end:T},a&&h<e.length-1){const F=M[h+1];if(Math.abs(F.start-A.end)<da){const O=Math.min(F.end-.1,F.start+P);M[h+1]={...F,start:O};let H=h+1;for(;H<M.length-1;){const K=M[H],ne=M[H+1];if(Math.abs(ne.start-e[H].end)<da){const B=K.end-e[H].end;M[H+1]={...ne,start:Math.min(ne.end-.1,ne.start+B)},H++}else break}}}else if(!a&&h<e.length-1){const F=M[h+1];if(T>F.start){M[h+1]={...F,start:T};let O=h+1;for(;O<M.length-1;){const H=M[O],K=M[O+1];if(H.end>K.start)M[O+1]={...K,start:H.end},O++;else break}}}n(M)},[e,h,s,a,n]),m=f.useCallback(()=>{!r||e.length===0||(h<=0?r(e[e.length-1].id):r(e[h-1].id))},[e,h,r]),w=f.useCallback(()=>{!r||e.length===0||(h<0||h>=e.length-1?r(e[0].id):r(e[h+1].id))},[e,h,r]),_=f.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),v=f.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),x=f.useCallback(()=>{r&&r(null)},[r]),S=f.useCallback(()=>{if(h<0||!p)return;const I=e[h],A=o?void 0:I.end-I.start;p(I.start,A)},[e,h,o,p]),k=f.useMemo(()=>[{key:"[",action:()=>b(-ts),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>b(ts),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>y(-ts),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>y(ts),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:S,description:"Play selected annotation",preventDefault:!0}],[b,y,S]),E=f.useMemo(()=>[{key:"ArrowUp",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:m,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:w,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:w,description:"Select next annotation",preventDefault:!0},{key:"Home",action:_,description:"Select first annotation",preventDefault:!0},{key:"End",action:v,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:x,description:"Deselect annotation",preventDefault:!0}],[m,w,_,v,x]);return Ts({shortcuts:k,enabled:i&&h>=0}),Ts({shortcuts:E,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:b,moveEndBoundary:y,selectPrevious:m,selectNext:w,selectFirst:_,selectLast:v,clearSelection:x,scrollToAnnotation:g,playActiveAnnotation:S}}const zr=[{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}]}],fi=e=>zr.find(t=>t.id===e),ev=e=>zr.filter(t=>t.category===e),tv=[{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"}];const nv={reverb:j.Reverb,freeverb:j.Freeverb,jcReverb:j.JCReverb,feedbackDelay:j.FeedbackDelay,pingPongDelay:j.PingPongDelay,chorus:j.Chorus,phaser:j.Phaser,tremolo:j.Tremolo,vibrato:j.Vibrato,autoPanner:j.AutoPanner,autoFilter:j.AutoFilter,autoWah:j.AutoWah,eq3:j.EQ3,distortion:j.Distortion,bitCrusher:j.BitCrusher,chebyshev:j.Chebyshev,compressor:j.Compressor,limiter:j.Limiter,gate:j.Gate,stereoWidener:j.StereoWidener};let rv=0;const sv=()=>`effect_${Date.now()}_${++rv}`;function Ar(e,t){const n=nv[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(i=>{const l=t?.[i.name]??i.default;r[i.name]=l});const s=new n(r),a=sv(),o=s;return{effect:s,id:e.id,instanceId:a,dispose(){try{s.disconnect(),s.dispose()}catch(i){console.warn(`[waveform-playlist] Error disposing effect "${e.id}" (${a}):`,i)}},setParameter(i,l){const c=o[i];if(i==="wet"){const u=o.wet;if(u&&typeof u=="object"&&"value"in u){u.value=l;return}}c!==void 0&&(c&&typeof c=="object"&&"value"in c?c.value=l:o[i]=l)},getParameter(i){if(i==="wet"){const c=o.wet;if(c&&typeof c=="object"&&"value"in c)return c.value}const l=o[i];if(l!==void 0)return l&&typeof l=="object"&&"value"in l?l.value:l},connect(i){s.connect(i)},disconnect(){try{s.disconnect()}catch(i){console.warn(`[waveform-playlist] Error disconnecting effect "${e.id}" (${a}):`,i)}}}}function av(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 ov(e=256){const[t,n]=f.useState([]),r=f.useRef(t);r.current=t;const s=f.useRef(new Map),a=f.useRef(null),o=f.useRef(null),i=f.useCallback(y=>{const m=o.current;if(!m)return;const{masterGainNode:w,destination:_,analyserNode:v}=m;try{w.disconnect()}catch(S){console.warn("[waveform-playlist] Error disconnecting master effects chain:",S)}const x=y.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)w.connect(v),v.connect(_);else{let S=w;x.forEach(k=>{try{k.disconnect()}catch(E){console.warn(`[waveform-playlist] Error disconnecting effect "${k.id}":`,E)}S.connect(k.effect),S=k.effect}),S.connect(v),v.connect(_)}},[]),l=f.useCallback(y=>{const m=fi(y);if(!m){console.error(`Unknown effect: ${y}`);return}const w={};m.parameters.forEach(x=>{w[x.name]=x.default});const _=Ar(m,w);s.current.set(_.instanceId,_);const v={instanceId:_.instanceId,effectId:m.id,definition:m,params:w,bypassed:!1};n(x=>[...x,v])},[]),c=f.useCallback(y=>{const m=s.current.get(y);m&&(m.dispose(),s.current.delete(y)),n(w=>w.filter(_=>_.instanceId!==y))},[]),u=f.useCallback((y,m,w)=>{const _=s.current.get(y);_&&_.setParameter(m,w),n(v=>v.map(x=>x.instanceId===y?{...x,params:{...x.params,[m]:w}}:x))},[]),d=f.useCallback(y=>{const m=r.current.find(v=>v.instanceId===y);if(!m)return;const w=!m.bypassed,_=s.current.get(y);if(_){const v=m.params.wet??1;_.setParameter("wet",w?0:v)}n(v=>v.map(x=>x.instanceId===y?{...x,bypassed:w}:x))},[]),p=f.useCallback((y,m)=>{n(w=>{const _=[...w],[v]=_.splice(y,1);return _.splice(m,0,v),_})},[]),h=f.useCallback(()=>{s.current.forEach(y=>y.dispose()),s.current.clear(),n([])},[]);f.useEffect(()=>{i(t)},[t,i]);const g=f.useCallback((y,m,w)=>{const _=new j.Analyser("fft",e);a.current=_,o.current={masterGainNode:y,destination:m,analyserNode:_};const x=r.current.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)y.connect(_),_.connect(m);else{let S=y;x.forEach(k=>{S.connect(k.effect),S=k.effect}),S.connect(_),_.connect(m)}return function(){_.dispose(),a.current=null,o.current=null}},[e]);f.useEffect(()=>{const y=s.current;return()=>{y.forEach(m=>m.dispose()),y.clear()}},[]);const b=f.useCallback(()=>{const y=t.filter(m=>!m.bypassed);if(y.length!==0)return(m,w,_)=>{const v=[];for(const x of y){const S=Ar(x.definition,x.params);v.push(S)}if(v.length===0)m.connect(w);else{let x=m;v.forEach(S=>{x.connect(S.effect),x=S.effect}),x.connect(w)}return function(){v.forEach(S=>S.dispose())}}},[t]);return{activeEffects:t,availableEffects:zr,addEffect:l,removeEffect:c,updateParameter:u,toggleBypass:d,reorderEffects:p,clearAllEffects:h,masterEffects:g,createOfflineEffectsFunction:b,analyserRef:a}}function iv(){const[e,t]=f.useState(new Map),n=f.useRef(new Map),r=f.useRef(new Map),s=f.useCallback((h,g)=>{const b=r.current.get(h);if(!b)return;const{graphEnd:y,masterGainNode:m}=b,w=n.current.get(h);try{y.disconnect()}catch(v){console.warn(`[waveform-playlist] Error disconnecting track "${h}" effect chain:`,v)}const _=g.map(v=>w?.get(v.instanceId)).filter(v=>v!==void 0);if(_.length===0)y.connect(m);else{let v=y;_.forEach(x=>{try{x.disconnect()}catch(S){console.warn(`[waveform-playlist] Error disconnecting effect "${x.id}" on track "${h}":`,S)}v.connect(x.effect),v=x.effect}),v.connect(m)}},[]),a=f.useCallback((h,g)=>{const b=fi(g);if(!b){console.error(`Unknown effect: ${g}`);return}const y={};b.parameters.forEach(_=>{y[_.name]=_.default});const m=Ar(b,y);n.current.has(h)||n.current.set(h,new Map),n.current.get(h).set(m.instanceId,m);const w={instanceId:m.instanceId,effectId:b.id,definition:b,params:y,bypassed:!1};t(_=>{const v=new Map(_),x=v.get(h)||[];return v.set(h,[...x,w]),v})},[]),o=f.useCallback((h,g)=>{const b=n.current.get(h),y=b?.get(g);y&&(y.dispose(),b?.delete(g)),t(m=>{const w=new Map(m),_=w.get(h)||[];return w.set(h,_.filter(v=>v.instanceId!==g)),w})},[]),i=f.useCallback((h,g,b,y)=>{const w=n.current.get(h)?.get(g);w&&w.setParameter(b,y),t(_=>{const v=new Map(_),x=v.get(h)||[];return v.set(h,x.map(S=>S.instanceId===g?{...S,params:{...S.params,[b]:y}}:S)),v})},[]),l=f.useCallback((h,g)=>{const y=(u.current.get(h)||[]).find(v=>v.instanceId===g);if(!y)return;const m=!y.bypassed,_=n.current.get(h)?.get(g);if(_){const v=y.params.wet??1;_.setParameter("wet",m?0:v)}t(v=>{const x=new Map(v),S=x.get(h)||[];return x.set(h,S.map(k=>k.instanceId===g?{...k,bypassed:m}:k)),x})},[]),c=f.useCallback(h=>{const g=n.current.get(h);g&&(g.forEach(b=>b.dispose()),g.clear()),t(b=>{const y=new Map(b);return y.set(h,[]),y})},[]),u=f.useRef(e);u.current=e;const d=f.useCallback(h=>(g,b,y)=>{r.current.set(h,{graphEnd:g,masterGainNode:b});const m=u.current.get(h)||[],w=n.current.get(h),_=m.map(v=>w?.get(v.instanceId)).filter(v=>v!==void 0);if(_.length===0)g.connect(b);else{let v=g;_.forEach(x=>{v.connect(x.effect),v=x.effect}),v.connect(b)}return function(){r.current.delete(h)}},[]);f.useEffect(()=>{e.forEach((h,g)=>{s(g,h)})},[e,s]),f.useEffect(()=>{const h=n.current;return()=>{h.forEach(g=>{g.forEach(b=>b.dispose()),g.clear()}),h.clear()}},[]);const p=f.useCallback(h=>{const b=(e.get(h)||[]).filter(y=>!y.bypassed);if(b.length!==0)return(y,m,w)=>{const _=[];for(const v of b){const x=Ar(v.definition,v.params);_.push(x)}if(_.length===0)y.connect(m);else{let v=y;_.forEach(x=>{v.connect(x.effect),v=x.effect}),v.connect(m)}return function(){_.forEach(x=>x.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:a,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:d,createOfflineTrackEffectsFunction:p,availableEffects:zr}}function lv(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,s=e.sampleRate,a=e.length,o=n/8,i=r*o,l=s*i,c=a*i,u=44,d=u+c,p=new ArrayBuffer(d),h=new DataView(p);ns(h,0,"RIFF"),h.setUint32(4,d-8,!0),ns(h,8,"WAVE"),ns(h,12,"fmt "),h.setUint32(16,16,!0),h.setUint16(20,n===32?3:1,!0),h.setUint16(22,r,!0),h.setUint32(24,s,!0),h.setUint32(28,l,!0),h.setUint16(32,i,!0),h.setUint16(34,n,!0),ns(h,36,"data"),h.setUint32(40,c,!0);const g=[];for(let y=0;y<r;y++)g.push(e.getChannelData(y));let b=u;if(n===16)for(let y=0;y<a;y++)for(let m=0;m<r;m++){const w=g[m][y],_=Math.max(-1,Math.min(1,w)),v=_<0?_*32768:_*32767;h.setInt16(b,v,!0),b+=2}else for(let y=0;y<a;y++)for(let m=0;m<r;m++)h.setFloat32(b,g[m][y],!0),b+=4;return new Blob([p],{type:"audio/wav"})}function ns(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function cv(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 Wd(){const[e,t]=f.useState(!1),[n,r]=f.useState(0),[s,a]=f.useState(null);return{exportWav:f.useCallback(async(i,l,c={})=>{const{filename:u="export",mode:d="master",trackIndex:p,autoDownload:h=!0,applyEffects:g=!0,effectsFunction:b,createOfflineTrackEffects:y,bitDepth:m=16,onProgress:w}=c;t(!0),r(0),a(null);try{if(i.length===0)throw new Error("No tracks to export");if(d==="individual"&&(p===void 0||p<0||p>=i.length))throw new Error("Invalid track index for individual export");const _=i[0].clips[0]?.sampleRate||44100;let v=0;for(const T of i)for(const P of T.clips){const M=P.startSample+P.durationSamples;v=Math.max(v,M)}v+=Math.round(_*.1);const x=v/_,S=d==="individual"?[{track:i[p],state:l[p],index:p}]:i.map((T,P)=>({track:T,state:l[P],index:P})),k=l.some(T=>T.soloed),E=!!y;let I;if((b||E)&&g)I=await uv(S,l,k,x,_,b,y,T=>{r(T),w?.(T)});else{const T=new OfflineAudioContext(2,v,_);let P=0;const M=S.reduce((F,{track:O})=>F+O.clips.length,0);for(const{track:F,state:O}of S)if(!(O.muted&&!O.soloed)&&!(k&&!O.soloed))for(const H of F.clips){await fv(T,H,O,_,g),P++;const K=P/M*.5;r(K),w?.(K)}r(.5),w?.(.5),I=await T.startRendering()}r(.9),w?.(.9);const A=lv(I,{bitDepth:m});if(r(1),w?.(1),h){const T=d==="individual"?`${u}_${i[p].name}`:u;cv(A,`${T}.wav`)}return{audioBuffer:I,blob:A,duration:x}}catch(_){const v=_ instanceof Error?_.message:"Export failed";throw a(v),_}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function uv(e,t,n,r,s,a,o,i){const{Offline:l,Volume:c,Gain:u,Panner:d,Player:p,ToneAudioBuffer:h}=await import("tone");i(.1);let g;try{g=await l(async({transport:b,destination:y})=>{const m=new c(0);let w;a?w=a(m,y,!0):m.connect(y);for(const{track:_,state:v}of e){if(v.muted&&!v.soloed||n&&!v.soloed)continue;const x=new c(dv(v.volume)),S=new d(v.pan),k=new u(v.muted?0:1),E=o?.(_.id);E?E(k,m,!0):k.connect(m),S.connect(k),x.connect(S);for(const I of _.clips){const{audioBuffer:A,startSample:T,durationSamples:P,offsetSamples:M,gain:F,fadeIn:O,fadeOut:H}=I,K=T/s,ne=P/s,B=M/s,re=new h(A),se=new p(re),ae=new u(F);if(se.connect(ae),ae.connect(x),O){const ie=K,me=K+O.duration,ye=ga(ae.gain);ye&&(ye.setValueAtTime(0,ie),ye.linearRampToValueAtTime(F,me))}if(H){const ie=K+ne-H.duration,me=K+ne,ye=ga(ae.gain);ye&&(ye.setValueAtTime(F,ie),ye.linearRampToValueAtTime(0,me))}se.start(K,B,ne)}}b.start(0)},r,2,s)}catch(b){throw b instanceof Error?b:new Error(`Tone.Offline rendering failed: ${String(b)}`)}return i(.9),g.get()}function dv(e){return 20*Math.log10(Math.max(e,1e-4))}async function fv(e,t,n,r,s){const{audioBuffer:a,startSample:o,durationSamples:i,offsetSamples:l,gain:c,fadeIn:u,fadeOut:d}=t;if(!a){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const p=o/r,h=i/r,g=l/r,b=e.createBufferSource();b.buffer=a;const y=e.createGain(),m=c*n.volume,w=e.createStereoPanner();if(w.pan.value=n.pan,b.connect(y),y.connect(w),w.connect(e.destination),s){if(u?y.gain.setValueAtTime(0,p):y.gain.setValueAtTime(m,p),u){const _=p,v=p+u.duration;Rl(y.gain,_,v,0,m,u.type||"linear")}if(d){const _=p+h-d.duration,v=p+h;(!u||u.duration<h-d.duration)&&y.gain.setValueAtTime(m,_),Rl(y.gain,_,v,m,0,d.type||"linear")}}else y.gain.setValueAtTime(m,p);b.start(p,g,h)}function Rl(e,t,n,r,s,a){const o=n-t;if(!(o<=0))switch(a){case"linear":e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n);break;case"exponential":{const i=Math.max(r,1e-4),l=Math.max(s,1e-4);e.setValueAtTime(i,t),e.exponentialRampToValueAtTime(l,n),s===0&&e.setValueAtTime(0,n);break}case"logarithmic":{const i=Pl(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,o);break}case"sCurve":{const i=Pl(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,o);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function Pl(e,t,n,r){const s=new Float32Array(n),a=t-e;for(let o=0;o<n;o++){const i=o/(n-1);let l;r==="logarithmic"?a>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),s[o]=e+a*l}return s}const Fd=()=>{const e=f.useRef(null),t=f.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=f.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return f.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},hv=`
|
|
861
|
+
`,Wv=({items:e})=>{const[t,n]=g.useState(!1),r=g.useCallback(()=>n(!1),[]),s=typeof e=="function"?e(r):e,[o,a]=g.useState({top:0,left:0}),i=g.useRef(null),l=g.useRef(null),c=g.useCallback(()=>{if(!i.current)return;const u=i.current.getBoundingClientRect(),f=window.innerWidth,h=window.innerHeight,d=l.current?.offsetHeight??160;let p=u.right+4;p+ms>f&&(p=u.left-ms-4),p=Math.max(4,Math.min(p,f-ms-4));let v=u.top;v+d>h-4&&(v=Math.max(4,u.bottom-d)),a({top:v,left:p})},[]);return g.useEffect(()=>{if(!t)return;c();const u=requestAnimationFrame(()=>c()),f=()=>c(),h=()=>c();return window.addEventListener("scroll",f,!0),window.addEventListener("resize",h),()=>{cancelAnimationFrame(u),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",h)}},[t,c]),g.useEffect(()=>{if(!t)return;const u=h=>{const d=h.target;i.current&&!i.current.contains(d)&&l.current&&!l.current.contains(d)&&n(!1)},f=h=>{h.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[t]),C.jsxs(Pv,{children:[C.jsx(Fv,{ref:i,onClick:u=>{u.stopPropagation(),n(f=>!f)},onMouseDown:u=>u.stopPropagation(),title:"Track menu","aria-label":"Track menu",children:C.jsx(Dv,{size:16})}),t&&typeof document<"u"&&da.createPortal(C.jsx(Ov,{ref:l,$top:o.top,$left:o.left,onMouseDown:u=>u.stopPropagation(),children:s.map((u,f)=>C.jsxs(g.Fragment,{children:[f>0&&C.jsx(Lv,{}),u.content]},u.id))}),document.body)]})};function Cn(e,t){this._waveformData=e,this._channelIndex=t}Cn.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};Cn.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};Cn.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};Cn.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};Cn.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};Cn.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 Bv=127,Vv=-128,Nv=32767,zv=-32768;function jv(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function Zv(e){for(var t=e.scale,n=e.amplitude_scale,r=e.split_channels,s=e.length,o=e.sample_rate,a=e.channels.map(function(M){return new Float32Array(M)}),i=r?a.length:1,l=24,c=jv(s,t),u=e.bits===8?1:2,f=l+c*2*u*i,h=new ArrayBuffer(f),d=new DataView(h),p=0,v=l,y=new Array(i),m=new Array(i),b=0;b<i;b++)y[b]=1/0,m[b]=-1/0;var _=e.bits===8?Vv:zv,w=e.bits===8?Bv:Nv;d.setInt32(0,2,!0),d.setUint32(4,e.bits===8,!0),d.setInt32(8,o,!0),d.setInt32(12,t,!0),d.setInt32(16,c,!0),d.setInt32(20,i,!0);for(var x=0;x<s;x++){var S=0;if(i===1){for(var k=0;k<a.length;++k)S+=a[k][x];S=Math.floor(w*S*n/a.length),S<y[0]&&(y[0]=S,y[0]<_&&(y[0]=_)),S>m[0]&&(m[0]=S,m[0]>w&&(m[0]=w))}else for(var E=0;E<i;++E)S=Math.floor(w*a[E][x]*n),S<y[E]&&(y[E]=S,y[E]<_&&(y[E]=_)),S>m[E]&&(m[E]=S,m[E]>w&&(m[E]=w));if(++p===t){for(var T=0;T<i;T++)e.bits===8?(d.setInt8(v++,y[T]),d.setInt8(v++,m[T])):(d.setInt16(v,y[T],!0),d.setInt16(v+2,m[T],!0),v+=4),y[T]=1/0,m[T]=-1/0;p=0}}if(p>0)for(var I=0;I<i;I++)e.bits===8?(d.setInt8(v++,y[I]),d.setInt8(v++,m[I])):(d.setInt16(v,y[I],!0),d.setInt16(v+2,m[I],!0));return h}function Rs(e){"@babel/helpers - typeof";return Rs=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},Rs(e)}function Hv(e){return e&&Rs(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function Gv(e){var t=e&&Rs(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 Uv(e){var t=e.data,n=e.channels||1,r=24,s=e.bits===8?1:2,o=e.length*2*n;if(t.length!==o)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var a=r+t.length*s,i=new ArrayBuffer(a),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 c=r;if(e.bits===8)for(var u=0;u<t.length;u++)l.setInt8(c++,t[u],!0);else for(var f=0;f<t.length;f++)l.setInt16(c,t[f],!0),c+=2;return i}function Mn(e){return e==null}function Xv(e,t){var n=atob(e);return n}function Yv(e,t,n){var r=Xv(e),s=r.indexOf(`
|
|
862
|
+
`,10)+1,o=r.substring(s)+"",a=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(a)}function Kv(e,t,n){var r;return function(o){return r=r||Yv(e),new Worker(r,o)}}var qv=Kv("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function mt(e){if(Hv(e)&&(e=Uv(e)),Gv(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 Cn(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var tr={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function Jv(e){var t={scale:e.scale||tr.scale,bits:e.bits||tr.bits,amplitude_scale:e.amplitude_scale||tr.amplitude_scale,split_channels:e.split_channels||tr.split_channels,disable_worker:e.disable_worker||tr.disable_worker};return t}function Qv(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Ld(e,t,n){var r=Qv(e);if(t.disable_worker){var s=Zv({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 mt(s),e)}else{var o=new qv;o.onmessage=function(a){n(void 0,new mt(a.data),e)},o.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 e0(e,t,n,r){function s(a){a||(a=new DOMException("EncodingError")),r(a),r=function(){}}var o=e.decodeAudioData(t,function(a){Ld(a,n,r)},s);o&&o.catch(s)}mt.create=function(t){return new mt(t)};mt.createFromAudio=function(e,t){var n=Jv(e);if(e.audio_context&&e.array_buffer)return e0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Ld(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Gs(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,s=this._inputData.bits===8?1:2,o=r+n*2*this._inputData.channels*s;this._output_data=new ArrayBuffer(o),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 mt(this._output_data),this._input_index=0,this._output_index=0;var a=this._inputData.channels;this._min=new Array(a),this._max=new Array(a);for(var i=0;i<a;++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}Gs.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};Gs.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 s=0;s<n;++s)r=this._outputWaveformData.channel(s),r.set_min_sample(this._output_index-1,this._min[s]),r.set_max_sample(this._output_index-1,this._max[s]);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 o=0;o<n;++o)this._min[o]=this._max_value,this._max[o]=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 a=0;a<n;++a){r=this._inputData.channel(a);var i=r.min_sample(this._input_index);i<this._min[a]&&(this._min[a]=i),i=r.max_sample(this._input_index),i>this._max[a]&&(this._max[a]=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};Gs.prototype.getOutputData=function(){return this._output_data};mt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Mn(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Mn(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 Gs(t);!n.next(););return new mt(n.getOutputData())},concat:function(){var t=this,n=Array.prototype.slice.call(arguments);n.forEach(function(s){if(t.channels!==s.channels||t.sample_rate!==s.sample_rate||t.bits!==s.bits||t.scale!==s.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")});var r=this._concatBuffers.apply(this,n);return mt.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,s=0,o=[this].concat(t).map(function(m){return m._data.buffer}),a=0;a<o.length;a++){var i=o[a],l=new DataView(i).getInt32(16,!0);r+=i.byteLength-n,s+=l}for(var c=new ArrayBuffer(r),u=new DataView(o[0]),f=new DataView(c),h=0;h<n;h++)f.setUint8(h,u.getUint8(h));f.setInt32(16,s,!0);for(var d=0,p=new Uint8Array(c,n),v=0;v<o.length;v++){var y=o[v];p.set(new Uint8Array(y,n),d),d+=y.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!Mn(t.startIndex)&&!Mn(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Mn(t.startTime)&&!Mn(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 s=r-n,o=24,a=this.bits===8?1:2,i=o+s*2*this.channels*a,l=new ArrayBuffer(i),c=new DataView(l);c.setInt32(0,2,!0),c.setUint32(4,this.bits===8,!0),c.setInt32(8,this.sample_rate,!0),c.setInt32(12,this.scale,!0),c.setInt32(16,s,!0),c.setInt32(20,this.channels,!0);for(var u=0;u<s*this.channels*2;u++){var f=this._at(n*this.channels*2+u);this.bits===8?c.setInt8(o+u,f):c.setInt16(o+u*2,f,!0)}return new mt(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 vi(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 mt.create(r)}else{const r=await t.json();return mt.create(r)}}function Wd(e,t=0){const n=e.channel(t),r=e.bits,s=n.min_array(),o=n.max_array(),a=s.length,i=r===8?new Int8Array(a*2):new Int16Array(a*2);for(let l=0;l<a;l++)i[l*2]=s[l],i[l*2+1]=o[l];return{data:i,bits:r,length:a,sampleRate:e.sample_rate}}async function t0(e,t=0){const n=await vi(e);return Wd(n,t)}async function n0(e){const t=await vi(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function Bd(e,t,n,r){let s=e;if(n!==void 0&&r!==void 0)if(s.scale!==t){const o=e.scale,a=t/o,i=Math.floor(n/t),l=Math.ceil((n+r)/t),c=Math.floor(i*a),u=Math.min(e.length,Math.ceil(l*a));if(c>=u)return null;s=s.slice({startIndex:c,endIndex:u}),s=s.resample({scale:t})}else{const o=Math.floor(n/t),a=Math.ceil((n+r)/t);s=s.slice({startIndex:o,endIndex:a})}else s.scale!==t&&(s=s.resample({scale:t}));return s}function r0(e,t,n=0,r,s){const o=Bd(e,t,r,s);if(o===null){const h=e.bits;return{data:h===8?new Int8Array(0):new Int16Array(0),bits:h,length:0}}const a=o.channel(n),i=o.bits,l=a.min_array(),c=a.max_array(),u=l.length,f=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let h=0;h<u;h++)f[h*2]=l[h],f[h*2+1]=c[h];return{data:f,bits:i,length:u}}function zl(e,t,n,r,s){const o=Bd(e,t,r,s);if(o===null){const u=e.bits;return{length:0,data:[],bits:u}}const a=o.channels,i=o.bits,l=[];for(let u=0;u<a;u++){const f=o.channel(u),h=f.min_array(),d=f.max_array(),p=h.length,v=i===8?new Int8Array(p*2):new Int16Array(p*2);for(let y=0;y<p;y++)v[y*2]=h[y],v[y*2+1]=d[y];l.push(v)}if(n&&l.length>1){const u=1/l.length,f=l[0].length/2,h=i===8?new Int8Array(f*2):new Int16Array(f*2);for(let d=0;d<f;d++){let p=0,v=0;for(let y=0;y<l.length;y++)p+=u*l[y][d*2],v+=u*l[y][d*2+1];h[d*2]=p,h[d*2+1]=v}return{length:f,data:[h],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function Vd(){const[e,t]=g.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Ln(s,e),parseTime:s=>$d(s,e)}}function Nd({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=g.useState(t),[s,o]=g.useState(!0),[a,i]=g.useState(!0),l=g.useRef(!0),c=g.useRef(!0),u=g.useRef(t),f=g.useCallback(()=>{e.current?.zoomIn()},[e]),h=g.useCallback(()=>{e.current?.zoomOut()},[e]),d=g.useCallback(p=>{p.samplesPerPixel!==u.current&&(u.current=p.samplesPerPixel,g.startTransition(()=>{r(p.samplesPerPixel)})),p.canZoomIn!==l.current&&(l.current=p.canZoomIn,o(p.canZoomIn)),p.canZoomOut!==c.current&&(c.current=p.canZoomOut,i(p.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:f,zoomOut:h,canZoomIn:s,canZoomOut:a,onEngineState:d}}function zd({engineRef:e,initialVolume:t=1}){const[n,r]=g.useState(t),s=g.useRef(t),o=g.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),a=g.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:o,masterVolumeRef:s,onEngineState:a}}function s0({engineRef:e}){const[t,n]=g.useState(0),[r,s]=g.useState(0),o=g.useRef(0),a=g.useRef(0),i=g.useCallback((c,u)=>{e.current?.setSelection(c,u)},[e]),l=g.useCallback(c=>{c.selectionStart!==o.current&&(o.current=c.selectionStart,n(c.selectionStart)),c.selectionEnd!==a.current&&(a.current=c.selectionEnd,s(c.selectionEnd))},[]);return{selectionStart:t,selectionEnd:r,setSelection:i,selectionStartRef:o,selectionEndRef:a,onEngineState:l}}function o0({engineRef:e}){const[t,n]=g.useState(!1),[r,s]=g.useState(0),[o,a]=g.useState(0),i=g.useRef(!1),l=g.useRef(0),c=g.useRef(0),u=g.useCallback(p=>{e.current?.setLoopEnabled(p)},[e]),f=g.useCallback((p,v)=>{e.current?.setLoopRegion(p,v)},[e]),h=g.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),d=g.useCallback(p=>{p.isLoopEnabled!==i.current&&(i.current=p.isLoopEnabled,n(p.isLoopEnabled)),p.loopStart!==l.current&&(l.current=p.loopStart,s(p.loopStart)),p.loopEnd!==c.current&&(c.current=p.loopEnd,a(p.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:o,setLoopEnabled:u,setLoopRegion:f,clearLoopRegion:h,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:d}}function a0({engineRef:e}){const[t,n]=g.useState(null),r=g.useRef(null),s=g.useCallback(a=>{e.current?.selectTrack(a)},[e]),o=g.useCallback(a=>{a.selectedTrackId!==r.current&&(r.current=a.selectedTrackId,n(a.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:o,selectedTrackIdRef:r}}const i0=(e=256)=>{const t=g.useRef(null),n=g.useCallback((r,s,o)=>{const a=new F.Analyser("fft",e);return r.connect(a),r.connect(s),t.current=a,function(){a.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:n}};function l0(e,t={}){const{progressive:n=!1}=t,[r,s]=g.useState([]),[o,a]=g.useState(!0),[i,l]=g.useState(null),[c,u]=g.useState(0),f=e.length;return g.useEffect(()=>{if(e.length===0){s([]),a(!1),u(0);return}let h=!1;const d=new AbortController,p=new Map,v=(m,b,_)=>{const w=_??m.audioBuffer;if(!w&&!m.waveformData)throw new Error(`Track ${b+1}: Must provide src, audioBuffer, or waveformData`);const x=w?.duration??m.waveformData?.duration,S=Jl({audioBuffer:w,startTime:m.startTime??0,duration:m.duration??x,offset:m.offset??0,name:m.name||`Track ${b+1}`,fadeIn:m.fadeIn,fadeOut:m.fadeOut,waveformData:m.waveformData});if(isNaN(S.startSample)||isNaN(S.durationSamples)||isNaN(S.offsetSamples))throw console.error("Invalid clip values:",S),new Error(`Invalid clip values for track ${b+1}`);return{...Ql({name:m.name||`Track ${b+1}`,clips:[S],muted:m.muted??!1,soloed:m.soloed??!1,volume:m.volume??1,pan:m.pan??0,color:m.color}),effects:m.effects,renderMode:m.renderMode,spectrogramConfig:m.spectrogramConfig,spectrogramColorMap:m.spectrogramColorMap}};return(async()=>{try{a(!0),l(null),u(0);const m=ql.getContext().rawContext,b=e.map(async(w,x)=>{if(w.audioBuffer){const I=v(w,x,w.audioBuffer);return n&&!h&&(p.set(x,I),u(M=>M+1),s(Array.from({length:e.length},(M,$)=>p.get($)).filter(M=>M!==void 0))),I}if(!w.src&&w.waveformData){const I=v(w,x);return n&&!h&&(p.set(x,I),u(M=>M+1),s(Array.from({length:e.length},(M,$)=>p.get($)).filter(M=>M!==void 0))),I}if(!w.src)throw new Error(`Track ${x+1}: Must provide src, audioBuffer, or waveformData`);const S=await fetch(w.src,{signal:d.signal});if(!S.ok)throw new Error(`Failed to fetch ${w.src}: ${S.statusText}`);const k=await S.arrayBuffer(),E=await m.decodeAudioData(k);if(!E||!E.sampleRate||!E.duration)throw new Error(`Invalid audio buffer for ${w.src}`);const T=v(w,x,E);return n&&!h&&(p.set(x,T),u(I=>I+1),s(Array.from({length:e.length},(I,M)=>p.get(M)).filter(I=>I!==void 0))),T}),_=await Promise.all(b);h||(n||(s(_),u(_.length)),a(!1))}catch(m){if(!h){const b=m instanceof Error?m.message:"Unknown error loading audio";l(b),a(!1),console.error("Error loading audio tracks:",m)}}})(),()=>{h=!0,d.abort()}},[e,n]),{tracks:r,loading:o,error:i,loadedCount:c,totalCount:f}}function c0({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:o}){const a=g.useRef(null),i=g.useRef(0),l=g.useCallback(f=>{const h=f.operation.source?.data;if(!h)return;if(!h.boundary){a.current=null;return}const p=e[h.trackIndex]?.clips[h.clipIndex];p&&(a.current={offsetSamples:p.offsetSamples,durationSamples:p.durationSamples,startSample:p.startSample},o.current=!0)},[e,o]),c=g.useCallback(f=>{const h=f.operation.source?.data;if(!h||!h.boundary||!a.current)return;const{boundary:d,trackIndex:p,clipIndex:v}=h,b=((f.to?.x??f.operation.position.current.x)-f.operation.position.initial.x)*n,_=Math.floor(.1*r),w=a.current,x=e.map((S,k)=>{if(k!==p)return S;const E=[...S.clips].sort((M,$)=>M.startSample-$.startSample),T=E.findIndex(M=>M===S.clips[v]),I=S.clips.map((M,$)=>{if($!==v)return M;if(d==="left"){const A={...M,startSample:w.startSample,offsetSamples:w.offsetSamples,durationSamples:w.durationSamples},R=ko(A,Math.floor(b),"left",E,T,_),W=w.offsetSamples+R,q=w.durationSamples-R,z=w.startSample+R;return{...M,offsetSamples:W,durationSamples:q,startSample:z}}else{const A={...M,startSample:w.startSample,offsetSamples:w.offsetSamples,durationSamples:w.durationSamples},R=ko(A,Math.floor(b),"right",E,T,_),W=w.durationSamples+R;return{...M,durationSamples:W}}});return{...S,clips:I}});i.current=b,t(x)},[e,t,n,r]),u=g.useCallback(f=>{if(f.canceled){if(a.current){const b=f.operation.source?.data;if(b){const{trackIndex:_,clipIndex:w}=b,x=a.current,S=e.map((k,E)=>{if(E!==_)return k;const T=k.clips.map((I,M)=>M!==w?I:{...I,offsetSamples:x.offsetSamples,durationSamples:x.durationSamples,startSample:x.startSample});return{...k,clips:T}});t(S)}}o.current=!1,a.current=null,i.current=0;return}const h=f.operation.source?.data;if(!h)return;const{trackIndex:d,clipId:p,boundary:v}=h,y=v?i.current:f.operation.transform.x*n,m=e[d]?.id;if(v){o.current=!1,m?s.current?s.current.trimClip(m,p,v,Math.floor(y)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${d} not found — trim not synced to adapter`),a.current=null,i.current=0;return}m?s.current?s.current.moveClip(m,p,Math.floor(y)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${d} not found — move not synced to adapter`)},[e,t,n,s,o]);return{onDragStart:l,onDragMove:c,onDragEnd:u}}const yo=.01;function jd({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:o}){const a=g.useRef(null),i=g.useCallback(u=>{const f=u.operation.source?.data;if(!f||f.annotationIndex===void 0){a.current=null;return}const h=e[f.annotationIndex];h&&(a.current={start:h.start,end:h.end,annotationIndex:f.annotationIndex})},[e]),l=g.useCallback(u=>{if(!a.current)return;const f=u.operation.source?.data;if(!f)return;const{edge:h,annotationIndex:d}=f,p=a.current,m=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n/r,b=h==="start"?p.start+m:p.end+m,_=u0({annotationIndex:d,newTime:b,isDraggingStart:h==="start",annotations:e,duration:s,linkEndpoints:o});t(_)},[e,t,n,r,s,o]),c=g.useCallback(u=>{if(u.canceled&&a.current){const{annotationIndex:f,start:h,end:d}=a.current,p=e.map((v,y)=>y!==f?v:{...v,start:h,end:d});t(p)}a.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function u0({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:s,linkEndpoints:o}){const a=[...r],i=r[e];if(n){const l=Math.min(i.end-.1,Math.max(0,t)),c=l-i.start;if(a[e]={...i,start:l},o&&e>0){const u=a[e-1];Math.abs(u.end-i.start)<yo?a[e-1]={...u,end:Math.max(u.start+.1,u.end+c)}:l<=u.end&&(a[e]={...a[e],start:u.end})}else!o&&e>0&&l<a[e-1].end&&(a[e-1]={...a[e-1],end:l})}else{const l=Math.max(i.start+.1,Math.min(t,s)),c=l-i.end;if(a[e]={...i,end:l},o&&e<a.length-1){const u=a[e+1];if(Math.abs(u.start-i.end)<yo){const f=u.start+c;a[e+1]={...u,start:Math.min(u.end-.1,f)};let h=e+1;for(;h<a.length-1;){const d=a[h],p=a[h+1];if(Math.abs(p.start-d.end)<yo){const v=d.end-r[h].end;a[h+1]={...p,start:Math.min(p.end-.1,p.start+v)},h++}else break}}else l>=u.start&&(a[e]={...a[e],end:u.start})}else if(!o&&e<a.length-1&&l>a[e+1].start){const u=a[e+1];a[e+1]={...u,start:l};let f=e+1;for(;f<a.length-1;){const h=a[f],d=a[f+1];if(h.end>d.start)a[f+1]={...d,start:h.end},f++;else break}}}return a}function d0(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return g.useMemo(()=>t?[ea.configure({activationConstraints(o){return o.pointerType==="touch"?[new Bt.Delay({value:n,tolerance:r})]:[new Bt.Distance({value:s})]}})]:[ea.configure({activationConstraints:[new Bt.Distance({value:s})]})],[t,n,r,s])}const f0=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=lt(),{selectedTrackId:o}=ct(),a=g.useCallback((l,c,u)=>{const{samplesPerPixel:f}=e,h=t[l];if(!h)return!1;const d=h.clips[c];if(!d)return!1;const p=Math.round(u*n),v=Gf(p,f),y=Math.floor(.1*n);if(!sc(d,v,y))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const m=r.current;return m?(m.splitClip(h.id,d.id,v),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:g.useCallback(()=>{if(!o)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const l=t.findIndex(f=>f.id===o);if(l===-1)return console.warn("Selected track not found"),!1;const c=t[l],u=s.current??0;for(let f=0;f<c.clips.length;f++){const h=c.clips[f],d=h.startSample/n,p=(h.startSample+h.durationSamples)/n;if(u>d&&u<p)return a(l,f,u)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${c.name}"`),!1},[t,s,o,a,n]),splitClipAt:a}},Ds=e=>{const{shortcuts:t,enabled:n=!0}=e,r=g.useCallback(s=>{if(!n)return;const o=s.target;if(o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;const a=t.find(i=>{const l=s.key.toLowerCase()===i.key.toLowerCase()||s.key===i.key,c=i.ctrlKey===void 0||s.ctrlKey===i.ctrlKey,u=i.shiftKey===void 0||s.shiftKey===i.shiftKey,f=i.metaKey===void 0||s.metaKey===i.metaKey,h=i.altKey===void 0||s.altKey===i.altKey;return l&&c&&u&&f&&h});a&&(a.preventDefault!==!1&&s.preventDefault(),a.action())},[t,n]);g.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},h0=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("+")},p0=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=lt(),{setCurrentTime:o,play:a,pause:i,stop:l}=Pe(),c=g.useCallback(()=>{s?i():a()},[s,a,i]),u=g.useCallback(()=>{l()},[l]),f=g.useCallback(()=>{o(0),s&&a(0)},[s,o,a]),d=r??[...[{key:" ",action:c,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:u,description:"Stop",preventDefault:!0},{key:"0",action:f,description:"Rewind to start",preventDefault:!0}],...n];return Ds({shortcuts:d,enabled:t}),{rewindToStart:f,togglePlayPause:c,stopPlayback:u,shortcuts:d}},bo=.01,ns=.01;function m0({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:s,linkEndpoints:o,continuousPlay:a=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:c,sampleRate:u,onPlay:f}){const h=g.useMemo(()=>t?e.findIndex(E=>E.id===t):-1,[e,t]),d=g.useCallback(E=>{if(!l?.current||!c||!u)return;const T=e.find(J=>J.id===E);if(!T)return;const I=l.current,M=I.clientWidth,$=T.start*u/c,A=T.end*u/c,R=($+A)/2,W=I.scrollLeft,q=W,z=W+M;if($<q||A>z){const J=Math.max(0,R-M/2);I.scrollTo({left:J,behavior:"smooth"})}},[e,l,c,u]);g.useEffect(()=>{t&&l?.current&&c&&u&&d(t)},[t,d,l,c,u]);const p=g.useCallback(E=>{if(h<0)return;const T=e[h],I=Math.max(0,Math.min(T.end-.1,T.start+E)),M=I-T.start,$=[...e];if($[h]={...T,start:I},o&&h>0){const A=$[h-1];Math.abs(A.end-T.start)<bo&&($[h-1]={...A,end:Math.max(A.start+.1,A.end+M)})}else if(!o&&h>0){const A=$[h-1];I<A.end&&($[h-1]={...A,end:I})}n($)},[e,h,o,n]),v=g.useCallback(E=>{if(h<0)return;const T=e[h],I=Math.max(T.start+.1,Math.min(s,T.end+E)),M=I-T.end,$=[...e];if($[h]={...T,end:I},o&&h<e.length-1){const A=$[h+1];if(Math.abs(A.start-T.end)<bo){const R=Math.min(A.end-.1,A.start+M);$[h+1]={...A,start:R};let W=h+1;for(;W<$.length-1;){const q=$[W],z=$[W+1];if(Math.abs(z.start-e[W].end)<bo){const J=q.end-e[W].end;$[W+1]={...z,start:Math.min(z.end-.1,z.start+J)},W++}else break}}}else if(!o&&h<e.length-1){const A=$[h+1];if(I>A.start){$[h+1]={...A,start:I};let R=h+1;for(;R<$.length-1;){const W=$[R],q=$[R+1];if(W.end>q.start)$[R+1]={...q,start:W.end},R++;else break}}}n($)},[e,h,s,o,n]),y=g.useCallback(()=>{!r||e.length===0||(h<=0?r(e[e.length-1].id):r(e[h-1].id))},[e,h,r]),m=g.useCallback(()=>{!r||e.length===0||(h<0||h>=e.length-1?r(e[0].id):r(e[h+1].id))},[e,h,r]),b=g.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),_=g.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),w=g.useCallback(()=>{r&&r(null)},[r]),x=g.useCallback(()=>{if(h<0||!f)return;const E=e[h],T=a?void 0:E.end-E.start;f(E.start,T)},[e,h,a,f]),S=g.useMemo(()=>[{key:"[",action:()=>p(-ns),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>p(ns),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-ns),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(ns),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:x,description:"Play selected annotation",preventDefault:!0}],[p,v,x]),k=g.useMemo(()=>[{key:"ArrowUp",action:y,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:y,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:m,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:m,description:"Select next annotation",preventDefault:!0},{key:"Home",action:b,description:"Select first annotation",preventDefault:!0},{key:"End",action:_,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:w,description:"Deselect annotation",preventDefault:!0}],[y,m,b,_,w]);return Ds({shortcuts:S,enabled:i&&h>=0}),Ds({shortcuts:k,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:p,moveEndBoundary:v,selectPrevious:y,selectNext:m,selectFirst:b,selectLast:_,clearSelection:w,scrollToAnnotation:d,playActiveAnnotation:x}}const jr=[{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}]}],yi=e=>jr.find(t=>t.id===e),g0=e=>jr.filter(t=>t.category===e),v0=[{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"}];const y0={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 b0=0;const w0=()=>`effect_${Date.now()}_${++b0}`;function Tr(e,t){const n=y0[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(i=>{const l=t?.[i.name]??i.default;r[i.name]=l});const s=new n(r),o=w0(),a=s;return{effect:s,id:e.id,instanceId:o,dispose(){try{s.disconnect(),s.dispose()}catch(i){console.warn(`[waveform-playlist] Error disposing effect "${e.id}" (${o}):`,i)}},setParameter(i,l){const c=a[i];if(i==="wet"){const u=a.wet;if(u&&typeof u=="object"&&"value"in u){u.value=l;return}}c!==void 0&&(c&&typeof c=="object"&&"value"in c?c.value=l:a[i]=l)},getParameter(i){if(i==="wet"){const c=a.wet;if(c&&typeof c=="object"&&"value"in c)return c.value}const l=a[i];if(l!==void 0)return l&&typeof l=="object"&&"value"in l?l.value:l},connect(i){s.connect(i)},disconnect(){try{s.disconnect()}catch(i){console.warn(`[waveform-playlist] Error disconnecting effect "${e.id}" (${o}):`,i)}}}}function _0(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 x0(e=256){const[t,n]=g.useState([]),r=g.useRef(t);r.current=t;const s=g.useRef(new Map),o=g.useRef(null),a=g.useRef(null),i=g.useCallback(y=>{const m=a.current;if(!m)return;const{masterGainNode:b,destination:_,analyserNode:w}=m;try{b.disconnect()}catch(S){console.warn("[waveform-playlist] Error disconnecting master effects chain:",S)}const x=y.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)b.connect(w),w.connect(_);else{let S=b;x.forEach(k=>{try{k.disconnect()}catch(E){console.warn(`[waveform-playlist] Error disconnecting effect "${k.id}":`,E)}S.connect(k.effect),S=k.effect}),S.connect(w),w.connect(_)}},[]),l=g.useCallback(y=>{const m=yi(y);if(!m){console.error(`Unknown effect: ${y}`);return}const b={};m.parameters.forEach(x=>{b[x.name]=x.default});const _=Tr(m,b);s.current.set(_.instanceId,_);const w={instanceId:_.instanceId,effectId:m.id,definition:m,params:b,bypassed:!1};n(x=>[...x,w])},[]),c=g.useCallback(y=>{const m=s.current.get(y);m&&(m.dispose(),s.current.delete(y)),n(b=>b.filter(_=>_.instanceId!==y))},[]),u=g.useCallback((y,m,b)=>{const _=s.current.get(y);_&&_.setParameter(m,b),n(w=>w.map(x=>x.instanceId===y?{...x,params:{...x.params,[m]:b}}:x))},[]),f=g.useCallback(y=>{const m=r.current.find(w=>w.instanceId===y);if(!m)return;const b=!m.bypassed,_=s.current.get(y);if(_){const w=m.params.wet??1;_.setParameter("wet",b?0:w)}n(w=>w.map(x=>x.instanceId===y?{...x,bypassed:b}:x))},[]),h=g.useCallback((y,m)=>{n(b=>{const _=[...b],[w]=_.splice(y,1);return _.splice(m,0,w),_})},[]),d=g.useCallback(()=>{s.current.forEach(y=>y.dispose()),s.current.clear(),n([])},[]);g.useEffect(()=>{i(t)},[t,i]);const p=g.useCallback((y,m,b)=>{const _=new F.Analyser("fft",e);o.current=_,a.current={masterGainNode:y,destination:m,analyserNode:_};const x=r.current.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)y.connect(_),_.connect(m);else{let S=y;x.forEach(k=>{S.connect(k.effect),S=k.effect}),S.connect(_),_.connect(m)}return function(){_.dispose(),o.current=null,a.current=null}},[e]);g.useEffect(()=>{const y=s.current;return()=>{y.forEach(m=>m.dispose()),y.clear()}},[]);const v=g.useCallback(()=>{const y=t.filter(m=>!m.bypassed);if(y.length!==0)return(m,b,_)=>{const w=[];for(const x of y){const S=Tr(x.definition,x.params);w.push(S)}if(w.length===0)m.connect(b);else{let x=m;w.forEach(S=>{x.connect(S.effect),x=S.effect}),x.connect(b)}return function(){w.forEach(S=>S.dispose())}}},[t]);return{activeEffects:t,availableEffects:jr,addEffect:l,removeEffect:c,updateParameter:u,toggleBypass:f,reorderEffects:h,clearAllEffects:d,masterEffects:p,createOfflineEffectsFunction:v,analyserRef:o}}function C0(){const[e,t]=g.useState(new Map),n=g.useRef(new Map),r=g.useRef(new Map),s=g.useCallback((d,p)=>{const v=r.current.get(d);if(!v)return;const{graphEnd:y,masterGainNode:m}=v,b=n.current.get(d);try{y.disconnect()}catch(w){console.warn(`[waveform-playlist] Error disconnecting track "${d}" effect chain:`,w)}const _=p.map(w=>b?.get(w.instanceId)).filter(w=>w!==void 0);if(_.length===0)y.connect(m);else{let w=y;_.forEach(x=>{try{x.disconnect()}catch(S){console.warn(`[waveform-playlist] Error disconnecting effect "${x.id}" on track "${d}":`,S)}w.connect(x.effect),w=x.effect}),w.connect(m)}},[]),o=g.useCallback((d,p)=>{const v=yi(p);if(!v){console.error(`Unknown effect: ${p}`);return}const y={};v.parameters.forEach(_=>{y[_.name]=_.default});const m=Tr(v,y);n.current.has(d)||n.current.set(d,new Map),n.current.get(d).set(m.instanceId,m);const b={instanceId:m.instanceId,effectId:v.id,definition:v,params:y,bypassed:!1};t(_=>{const w=new Map(_),x=w.get(d)||[];return w.set(d,[...x,b]),w})},[]),a=g.useCallback((d,p)=>{const v=n.current.get(d),y=v?.get(p);y&&(y.dispose(),v?.delete(p)),t(m=>{const b=new Map(m),_=b.get(d)||[];return b.set(d,_.filter(w=>w.instanceId!==p)),b})},[]),i=g.useCallback((d,p,v,y)=>{const b=n.current.get(d)?.get(p);b&&b.setParameter(v,y),t(_=>{const w=new Map(_),x=w.get(d)||[];return w.set(d,x.map(S=>S.instanceId===p?{...S,params:{...S.params,[v]:y}}:S)),w})},[]),l=g.useCallback((d,p)=>{const y=(u.current.get(d)||[]).find(w=>w.instanceId===p);if(!y)return;const m=!y.bypassed,_=n.current.get(d)?.get(p);if(_){const w=y.params.wet??1;_.setParameter("wet",m?0:w)}t(w=>{const x=new Map(w),S=x.get(d)||[];return x.set(d,S.map(k=>k.instanceId===p?{...k,bypassed:m}:k)),x})},[]),c=g.useCallback(d=>{const p=n.current.get(d);p&&(p.forEach(v=>v.dispose()),p.clear()),t(v=>{const y=new Map(v);return y.set(d,[]),y})},[]),u=g.useRef(e);u.current=e;const f=g.useCallback(d=>(p,v,y)=>{r.current.set(d,{graphEnd:p,masterGainNode:v});const m=u.current.get(d)||[],b=n.current.get(d),_=m.map(w=>b?.get(w.instanceId)).filter(w=>w!==void 0);if(_.length===0)p.connect(v);else{let w=p;_.forEach(x=>{w.connect(x.effect),w=x.effect}),w.connect(v)}return function(){r.current.delete(d)}},[]);g.useEffect(()=>{e.forEach((d,p)=>{s(p,d)})},[e,s]),g.useEffect(()=>{const d=n.current;return()=>{d.forEach(p=>{p.forEach(v=>v.dispose()),p.clear()}),d.clear()}},[]);const h=g.useCallback(d=>{const v=(e.get(d)||[]).filter(y=>!y.bypassed);if(v.length!==0)return(y,m,b)=>{const _=[];for(const w of v){const x=Tr(w.definition,w.params);_.push(x)}if(_.length===0)y.connect(m);else{let w=y;_.forEach(x=>{w.connect(x.effect),w=x.effect}),w.connect(m)}return function(){_.forEach(x=>x.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:o,removeEffectFromTrack:a,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:f,createOfflineTrackEffectsFunction:h,availableEffects:jr}}function S0(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,s=e.sampleRate,o=e.length,a=n/8,i=r*a,l=s*i,c=o*i,u=44,f=u+c,h=new ArrayBuffer(f),d=new DataView(h);rs(d,0,"RIFF"),d.setUint32(4,f-8,!0),rs(d,8,"WAVE"),rs(d,12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,n===32?3:1,!0),d.setUint16(22,r,!0),d.setUint32(24,s,!0),d.setUint32(28,l,!0),d.setUint16(32,i,!0),d.setUint16(34,n,!0),rs(d,36,"data"),d.setUint32(40,c,!0);const p=[];for(let y=0;y<r;y++)p.push(e.getChannelData(y));let v=u;if(n===16)for(let y=0;y<o;y++)for(let m=0;m<r;m++){const b=p[m][y],_=Math.max(-1,Math.min(1,b)),w=_<0?_*32768:_*32767;d.setInt16(v,w,!0),v+=2}else for(let y=0;y<o;y++)for(let m=0;m<r;m++)d.setFloat32(v,p[m][y],!0),v+=4;return new Blob([h],{type:"audio/wav"})}function rs(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function k0(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 Zd(){const[e,t]=g.useState(!1),[n,r]=g.useState(0),[s,o]=g.useState(null);return{exportWav:g.useCallback(async(i,l,c={})=>{const{filename:u="export",mode:f="master",trackIndex:h,autoDownload:d=!0,applyEffects:p=!0,effectsFunction:v,createOfflineTrackEffects:y,bitDepth:m=16,onProgress:b}=c;t(!0),r(0),o(null);try{if(i.length===0)throw new Error("No tracks to export");if(f==="individual"&&(h===void 0||h<0||h>=i.length))throw new Error("Invalid track index for individual export");const _=i[0].clips[0]?.sampleRate||44100;let w=0;for(const M of i)for(const $ of M.clips){const A=$.startSample+$.durationSamples;w=Math.max(w,A)}w+=Math.round(_*.1);const x=w/_,S=f==="individual"?[{track:i[h],state:l[h],index:h}]:i.map((M,$)=>({track:M,state:l[$],index:$})),k=l.some(M=>M.soloed),E=!!y;let T;if((v||E)&&p)T=await E0(S,l,k,x,_,v,y,M=>{r(M),b?.(M)});else{const M=new OfflineAudioContext(2,w,_);let $=0;const A=S.reduce((R,{track:W})=>R+W.clips.length,0);for(const{track:R,state:W}of S)if(!(W.muted&&!W.soloed)&&!(k&&!W.soloed))for(const q of R.clips){await M0(M,q,W,_,p),$++;const z=$/A*.5;r(z),b?.(z)}r(.5),b?.(.5),T=await M.startRendering()}r(.9),b?.(.9);const I=S0(T,{bitDepth:m});if(r(1),b?.(1),d){const M=f==="individual"?`${u}_${i[h].name}`:u;k0(I,`${M}.wav`)}return{audioBuffer:T,blob:I,duration:x}}catch(_){const w=_ instanceof Error?_.message:"Export failed";throw o(w),_}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function E0(e,t,n,r,s,o,a,i){const{Offline:l,Volume:c,Gain:u,Panner:f,Player:h,ToneAudioBuffer:d}=await import("tone");i(.1);let p;try{p=await l(async({transport:v,destination:y})=>{const m=new c(0);let b;o?b=o(m,y,!0):m.connect(y);for(const{track:_,state:w}of e){if(w.muted&&!w.soloed||n&&!w.soloed)continue;const x=new c(I0(w.volume)),S=new f(w.pan),k=new u(w.muted?0:1),E=a?.(_.id);E?E(k,m,!0):k.connect(m),S.connect(k),x.connect(S);for(const T of _.clips){const{audioBuffer:I,startSample:M,durationSamples:$,offsetSamples:A,gain:R,fadeIn:W,fadeOut:q}=T,z=M/s,J=$/s,ee=A/s,j=new d(I),se=new h(j),U=new u(R);if(se.connect(U),U.connect(x),W){const ie=z,le=z+W.duration,ge=wr(U.gain);ge&&(ge.setValueAtTime(0,ie),ge.linearRampToValueAtTime(R,le))}if(q){const ie=z+J-q.duration,le=z+J,ge=wr(U.gain);ge&&(ge.setValueAtTime(R,ie),ge.linearRampToValueAtTime(0,le))}se.start(z,ee,J)}}v.start(0)},r,2,s)}catch(v){throw v instanceof Error?v:new Error(`Tone.Offline rendering failed: ${String(v)}`)}return i(.9),p.get()}function I0(e){return 20*Math.log10(Math.max(e,1e-4))}async function M0(e,t,n,r,s){const{audioBuffer:o,startSample:a,durationSamples:i,offsetSamples:l,gain:c,fadeIn:u,fadeOut:f}=t;if(!o){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const h=a/r,d=i/r,p=l/r,v=e.createBufferSource();v.buffer=o;const y=e.createGain(),m=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,v.connect(y),y.connect(b),b.connect(e.destination),s){if(u?y.gain.setValueAtTime(0,h):y.gain.setValueAtTime(m,h),u){const _=h,w=h+u.duration;jl(y.gain,_,w,0,m,u.type||"linear")}if(f){const _=h+d-f.duration,w=h+d;(!u||u.duration<d-f.duration)&&y.gain.setValueAtTime(m,_),jl(y.gain,_,w,m,0,f.type||"linear")}}else y.gain.setValueAtTime(m,h);v.start(h,p,d)}function jl(e,t,n,r,s,o){const a=n-t;if(!(a<=0))switch(o){case"linear":e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n);break;case"exponential":{const i=Math.max(r,1e-4),l=Math.max(s,1e-4);e.setValueAtTime(i,t),e.exponentialRampToValueAtTime(l,n),s===0&&e.setValueAtTime(0,n);break}case"logarithmic":{const i=Zl(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,a);break}case"sCurve":{const i=Zl(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,a);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function Zl(e,t,n,r){const s=new Float32Array(n),o=t-e;for(let a=0;a<n;a++){const i=a/(n-1);let l;r==="logarithmic"?o>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),s[a]=e+o*l}return s}const Hd=()=>{const e=g.useRef(null),t=g.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=g.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return g.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},A0=`
|
|
864
863
|
"use strict";
|
|
865
864
|
|
|
866
865
|
var INT8_MAX = 127;
|
|
@@ -1007,13 +1006,13 @@ self.onmessage = function(e) {
|
|
|
1007
1006
|
self.postMessage({ id: msg.id, error: err.message || String(err) });
|
|
1008
1007
|
}
|
|
1009
1008
|
};
|
|
1010
|
-
`;let pv=0;function mv(){let e;try{const r=new Blob([hv],{type:"application/javascript"}),s=URL.createObjectURL(r);e=new Worker(s),URL.revokeObjectURL(s)}catch(r){return console.warn("[waveform-playlist] Failed to create peaks worker (CSP restriction?):",r),{generate(){return Promise.reject(new Error("Worker creation failed"))},terminate(){}}}const t=new Map;let n=!1;return e.onmessage=r=>{const s=r.data,a=t.get(s.id);if(a)if(t.delete(s.id),s.error)a.reject(new Error(s.error));else try{const o=mt.create(s.buffer);a.resolve(o)}catch(o){a.reject(o)}},e.onerror=r=>{n=!0,e.terminate();for(const[,s]of t)s.reject(r.error??new Error(r.message));t.clear()},{generate(r){if(n)return Promise.reject(new Error("Worker terminated"));const s=String(++pv);return new Promise((a,o)=>{t.set(s,{resolve:a,reject:o}),e.postMessage({id:s,scale:r.scale,bits:r.bits,amplitude_scale:1,split_channels:r.splitChannels,length:r.length,sample_rate:r.sampleRate,channels:r.channels},r.channels)})},terminate(){n=!0,e.terminate();for(const[,r]of t)r.reject(new Error("Worker terminated"));t.clear()}}}function gv(e,t){const[n,r]=f.useState(()=>new Map),[s,a]=f.useState(!1),o=f.useRef(null),i=f.useRef(new WeakMap),l=f.useRef(new WeakMap),c=f.useRef(new WeakMap),u=f.useRef(0),d=f.useCallback(()=>(o.current||(o.current=mv()),o.current),[]);return f.useEffect(()=>{let p=!1;const h=i.current,g=l.current,b=c.current,y=[],m=new Map;for(const _ of e)for(const v of _.clips){if(!v.audioBuffer||v.waveformData)continue;const x=h.get(v.audioBuffer);if(x){y.push({clipId:v.id,waveformData:x});continue}if(g.get(v.audioBuffer)){const k=b.get(v.audioBuffer);k?k.add(v.id):b.set(v.audioBuffer,new Set([v.id]));continue}const S=m.get(v.audioBuffer);S?S.add(v.id):m.set(v.audioBuffer,new Set([v.id]))}if(y.length>0&&r(_=>{const v=new Map(_);for(const x of y)v.set(x.clipId,x.waveformData);return v}),m.size===0)return;u.current+=m.size,a(!0);const w=d();for(const[_,v]of m){b.set(_,new Set(v));const x=[];for(let E=0;E<_.numberOfChannels;E++)x.push(_.getChannelData(E).slice().buffer);const S=`buffer-${Math.random().toString(36).slice(2,11)}`,k=w.generate({id:S,channels:x,length:_.length,sampleRate:_.sampleRate,scale:t,bits:16,splitChannels:!0}).then(E=>{h.set(_,E);const I=b.get(_)??new Set;b.delete(_),g.delete(_),!p&&(r(A=>{const T=new Map(A);for(const P of I)T.set(P,E);return T}),u.current--,u.current<=0&&(u.current=0,a(!1)))}).catch(E=>{b.delete(_),g.delete(_),!p&&(console.warn("[waveform-playlist] Worker peak generation failed:",E),u.current--,u.current<=0&&(u.current=0,a(!1)))});g.set(_,k)}return()=>{p=!0,l.current=new WeakMap,c.current=new WeakMap,u.current=0,a(!1)}},[e,t,d]),f.useEffect(()=>()=>{o.current?.terminate(),o.current=null},[]),{cache:n,isGenerating:s}}function Ja(e){return e instanceof File?e.name.replace(/\.[^/.]+$/,""):e instanceof Blob?"Untitled":typeof e=="string"?e.split("/").pop()?.replace(/\.[^/.]+$/,"")??"Untitled":e.name??e.src.split("/").pop()?.replace(/\.[^/.]+$/,"")??"Untitled"}async function vv(e,t,n){const r=Ja(e);if(e instanceof Blob){const l=await e.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(l),name:r}}const s=typeof e=="string"?e:e.src,a=await fetch(s,{signal:n});if(!a.ok)throw new Error(`Failed to fetch ${s}: ${a.statusText}`);const o=await a.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(o),name:r}}function yv(){const[e,t]=f.useState([]),[n,r]=f.useState(0),[s,a]=f.useState([]),o=f.useRef(!1),i=f.useRef(new Set),l=f.useRef(new Map);f.useEffect(()=>{const d=l.current;return()=>{o.current=!0;for(const p of d.values())p.abort();d.clear()}},[]);const c=f.useCallback(d=>{if(d.length===0)return;const p=Rf(),h=d.map(g=>({track:Zl({name:`${Ja(g)} (loading...)`,clips:[]}),source:g}));t(g=>[...g,...h.map(b=>b.track)]),r(g=>g+d.length);for(const{track:g,source:b}of h){i.current.add(g.id);const y=new AbortController;l.current.set(g.id,y),(async()=>{try{const{audioBuffer:m,name:w}=await vv(b,p,y.signal),_=jl({audioBuffer:m,startTime:0,duration:m.duration,offset:0,name:w});!o.current&&i.current.has(g.id)&&t(v=>v.map(x=>x.id===g.id?{...x,name:w,clips:[_]}:x))}catch(m){if(m instanceof DOMException&&m.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",m),!o.current&&i.current.has(g.id)&&(t(w=>w.filter(_=>_.id!==g.id)),a(w=>[...w,{name:Ja(b),error:m instanceof Error?m:new Error(String(m))}]))}finally{l.current.delete(g.id),!o.current&&i.current.delete(g.id)&&r(m=>m-1)}})()}},[]),u=f.useCallback(d=>{t(h=>h.filter(g=>g.id!==d));const p=l.current.get(d);p&&(p.abort(),l.current.delete(d)),i.current.delete(d)&&r(h=>h-1)},[]);return{tracks:e,addTracks:c,removeTrack:u,loadingCount:n,isLoading:n>0,errors:s}}const Od=f.createContext(null),Bd=f.createContext(null),Ld=f.createContext(null),Vd=f.createContext(null),bv=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:s=1024,zoomLevels:a,automaticScroll:o=!1,theme:i,controls:l={show:!1,width:0},annotationList:c,effects:u,onReady:d,onAnnotationUpdate:p,onAnnotationsChange:h,barWidth:g=1,barGap:b=0,progressBarWidth:y,onTracksChange:m,children:w})=>{const _=y??g+b,v=f.useMemo(()=>a,[a?.join(",")]),x=f.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const W=c.annotations[0];if(typeof W.start!="number"||typeof W.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof W.start),[]}return c.annotations},[c?.annotations]),S=f.useRef(x);S.current=x;const[k,E]=f.useState(null),[I,A]=f.useState(!1),[T,P]=f.useState(0),[M,F]=f.useState(0),[O,H]=f.useState([]),[K,ne]=f.useState([]),[B,re]=f.useState([]),[se,ae]=f.useState(o),[ie,me]=f.useState(c?.isContinuousPlay??!1),[ye,De]=f.useState(c?.linkEndpoints??!1),[X,Z]=f.useState(c?.editable??!1),[de,G]=f.useState(!1),$=f.useRef(null),he=f.useRef(!1),We=f.useRef(!1);We.current=I;const q=f.useRef(0),ge=f.useRef(0),Ve=f.useRef(e),Ne=f.useRef(B),U=f.useRef(0),Re=f.useRef(0),ze=f.useRef(null),xe=f.useRef(null),Xe=f.useRef(!1),Ue=f.useRef(c?.isContinuousPlay??!1),at=f.useRef(null),yt=f.useRef(null),At=f.useRef(0),N=f.useRef(!1),le=f.useRef(!1),Fe=f.useRef(s),{timeFormat:Ke,setTimeFormat:ee,formatTime:be}=Td(),Ee=Dd({engineRef:$,initialSamplesPerPixel:s}),{samplesPerPixel:je,onEngineState:bt}=Ee,V=Rd({engineRef:$,initialVolume:1}),{masterVolume:Y,setMasterVolume:Q,masterVolumeRef:Ce,onEngineState:ve}=V,{selectionStart:Qe,selectionEnd:dt,setSelection:oe,selectionStartRef:Ze,selectionEndRef:et,onEngineState:en}=j0({engineRef:$}),{isLoopEnabled:Pt,loopStart:Wt,loopEnd:tn,setLoopEnabled:nn,setLoopRegion:Mt,clearLoopRegion:Kn,isLoopEnabledRef:Zr,loopStartRef:Hr,loopEndRef:gi,onEngineState:vi}=Z0({engineRef:$}),{selectedTrackId:yi,setSelectedTrackId:bi,onEngineState:wi,selectedTrackIdRef:_i}=H0({engineRef:$}),{animationFrameRef:xi,startAnimationFrameLoop:Ys,stopAnimationFrameLoop:Nr}=Fd(),uf=f.useMemo(()=>Math.min(...v??[256,512,1024,2048,4096,8192]),[v]),{cache:Ci}=gv(e,uf),ki=f.useCallback(W=>{Ue.current=W,me(W)},[]),Ft=f.useCallback(W=>{at.current=W,E(W)},[]),Si=f.useCallback(()=>{const W=Ze.current??0,z=et.current??0;W!==z&&z>W&&Mt(W,z)},[Mt,Ze,et]);f.useEffect(()=>{Xe.current=se},[se]),f.useEffect(()=>{Ne.current=B},[B]),Ve.current=e;const Us=e===yt.current;N.current=Us||le.current,f.useEffect(()=>{if(!xe.current||!O.length)return;const W=xe.current,z=Fe.current,fe=je;if(z===fe)return;const L=l.show?l.width:0,ke=W.clientWidth,Be=W.scrollLeft+ke/2-L,kn=O[0].sampleRate,Sn=Be*z/kn*kn/fe,Js=Math.max(0,Sn+L-ke/2);W.scrollLeft=Js,Fe.current=fe},[je,O,l]);const Xr=f.useRef(null);f.useEffect(()=>{if(Us||le.current){Us&&(yt.current=null);let L=0;e.forEach(ke=>{ke.clips.forEach(Oe=>{const Be=(Oe.startSample+Oe.durationSamples)/Oe.sampleRate;L=Math.max(L,Be)})}),F(L);return}if(G(!1),e.length===0){H([]),F(0),re([]),ne([]),$.current&&($.current.dispose(),$.current=null);return}const W=We.current,z=ge.current;return $.current&&W&&($.current.stop(),Nr(),Xr.current={position:z}),(async()=>{try{const L=[];e.forEach(Ie=>{Ie.clips.length>0&&Ie.clips[0].audioBuffer&&L.push(Ie.clips[0].audioBuffer)});let ke=0;e.forEach(Ie=>{Ie.clips.forEach(ht=>{const Zt=ht.sampleRate,gf=(ht.startSample+ht.durationSamples)/Zt;ke=Math.max(ke,gf)})}),H(L),F(ke),re(Ie=>Ie.length===e.length?Ie.map((ht,Zt)=>({...ht,name:e[Zt].name})):e.map(ht=>({name:ht.name,muted:ht.muted,soloed:ht.soloed,volume:ht.volume,pan:ht.pan}))),$.current&&$.current.dispose(),At.current=0,yt.current=null,he.current=!1;const Oe=Pf({effects:u}),Be=new Vf({adapter:Oe,samplesPerPixel:Fe.current,zoomLevels:v});Be.setSelection(Ze.current??0,et.current??0),Be.setLoopRegion(Hr.current??0,gi.current??0),Zr.current&&Be.setLoopEnabled(!0),Be.setMasterVolume(Ce.current??1),_i.current&&Be.selectTrack(_i.current);const kn=Ne.current,Yr=e.map((Ie,ht)=>{const Zt=kn[ht];return{...Ie,volume:Zt?.volume??Ie.volume,muted:Zt?.muted??Ie.muted,soloed:Zt?.soloed??Ie.soloed,pan:Zt?.pan??Ie.pan}});let Sn=!0;Be.on("statechange",Ie=>{en(Ie),vi(Ie),wi(Ie),bt(Ie),ve(Ie),!Sn&&Ie.tracksVersion!==At.current&&(At.current=Ie.tracksVersion,yt.current=Ie.tracks,m?m(Ie.tracks):console.warn("[waveform-playlist] Engine tracks changed but onTracksChange prop is not set — UI will revert on next render. Pass onTracksChange to WaveformPlaylistProvider."))}),Be.setTracks(Yr),Sn=!1,At.current=Be.getState().tracksVersion,$.current=Be,G(!0);const Js=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:ke}});window.dispatchEvent(Js),d?.()}catch(L){console.error("Error loading audio:",L)}})(),()=>{if(N.current){N.current=!1;return}Nr(),$.current&&$.current.dispose()}},[e,d,u,Nr,en,vi,wi,bt,ve,m,Ce,Ze,et,Hr,gi,Zr,v]),f.useEffect(()=>{if(e.length===0)return;const W=e.map(z=>z.clips.map(L=>{let ke;if(L.waveformData)try{ke=Dl(L.waveformData,je,n,L.offsetSamples,L.durationSamples)}catch(Oe){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",Oe)}if(!ke){const Oe=Ci.get(L.id);if(Oe)try{ke=Dl(Oe,je,n,L.offsetSamples,L.durationSamples)}catch(Be){console.warn("[waveform-playlist] Failed to extract peaks from cache:",Be)}}if(!ke){!L.audioBuffer&&!L.waveformData&&console.warn(`[waveform-playlist] Clip "${L.id}" has no audio data or waveform data`);const Oe=n?1:L.audioBuffer?.numberOfChannels??1;ke={length:0,data:Array.from({length:Oe},()=>new Int16Array(0)),bits:16}}return{clipId:L.id,trackName:z.name,peaks:ke,startSample:L.startSample,durationSamples:L.durationSamples,fadeIn:L.fadeIn,fadeOut:L.fadeOut}}));ne(W)},[e,je,n,Ci]);const Ei=f.useRef(!1),Cn=f.useCallback(()=>{if($.current)return $.current.getCurrentTime();Ei.current||(Ei.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const W=j.getContext().currentTime-(U.current??0);return(Re.current??0)+W},[]),rn=f.useCallback(()=>{const W=()=>{const z=Cn();ge.current=z;const fe=S.current;if(fe.length>0){const L=fe.find(ke=>z>=ke.start&&z<ke.end);if(Ue.current)L&&L.id!==at.current?Ft(L.id):!L&&at.current!==null&&Ft(null);else if(at.current){const ke=fe.find(Oe=>Oe.id===at.current);if(ke&&z>=ke.end){$.current&&$.current.stop(),A(!1),ge.current=q.current,P(q.current);return}}else L&&Ft(L.id)}if(Xe.current&&xe.current&&O.length>0){const L=xe.current,ke=O[0].sampleRate,Oe=z*ke/Fe.current,Be=L.clientWidth,kn=l.show?l.width:0,Yr=Oe+kn,Sn=Math.max(0,Yr-Be/2);L.scrollLeft=Sn}if(ze.current!==null&&z>=ze.current){$.current&&$.current.stop(),A(!1),ge.current=ze.current,P(ze.current),ze.current=null;return}if(z>=M){$.current&&$.current.stop(),A(!1),ge.current=q.current,P(q.current),Ft(null);return}Ys(W)};Ys(W)},[M,O,l.show,l.width,Ft,Ys,Cn]),ft=Nr;f.useEffect(()=>{(async()=>{if(I&&xi.current&&$.current)if(ie){const z=ge.current;$.current.stop(),ft();const L=j.getContext().currentTime;U.current=L,Re.current=z,$.current.play(z),rn()}else ft(),rn()})().catch(z=>{console.warn("[waveform-playlist] Failed to reschedule playback:",z),A(!1),ft()})},[ie,I,rn,ft,xi]),f.useEffect(()=>{(async()=>{if(Xr.current&&$.current){const{position:z}=Xr.current;Xr.current=null;const L=j.getContext().currentTime;U.current=L,Re.current=z,he.current||(await $.current.init(),he.current=!0),$.current.play(z),A(!0),rn()}})().catch(z=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",z),A(!1),ft()})},[e,rn,ft]);const Gr=f.useCallback(async(W,z)=>{if(!$.current||O.length===0)return;const fe=W??ge.current;q.current=fe,ge.current=fe,$.current.stop(),$.current.seek(fe),ft();const ke=j.getContext().currentTime;U.current=ke,Re.current=fe,ze.current=z!==void 0?fe+z:null,he.current||(await $.current.init(),he.current=!0);const Oe=z!==void 0?fe+z:void 0;try{$.current.play(fe,Oe)}catch(Be){console.warn("[waveform-playlist] Playback failed to start:",Be),ft();return}A(!0),rn()},[O.length,rn,ft]),Ii=f.useCallback(()=>{if(!$.current)return;const W=Cn();$.current.pause(),A(!1),ft(),ge.current=W,P(W)},[ft,Cn]),Ai=f.useCallback(()=>{$.current&&($.current.stop(),A(!1),ft(),ge.current=q.current,P(q.current),Ft(null))},[ft,Ft]),Mi=f.useCallback(W=>{const z=Math.max(0,Math.min(W,M));ge.current=z,P(z),I&&$.current&&Gr(z)},[M,I,Gr]),$i=f.useCallback((W,z)=>{const fe=Ve.current[W]?.id;if(!fe)return;const L=[...B];L[W]={...L[W],muted:z},re(L),$.current&&$.current.setTrackMute(fe,z)},[B]),Ti=f.useCallback((W,z)=>{const fe=Ve.current[W]?.id;if(!fe)return;const L=[...B];L[W]={...L[W],soloed:z},re(L),$.current&&$.current.setTrackSolo(fe,z)},[B]),Di=f.useCallback((W,z)=>{const fe=Ve.current[W]?.id;if(!fe)return;const L=[...B];L[W]={...L[W],volume:z},re(L),$.current&&$.current.setTrackVolume(fe,z)},[B]),Ri=f.useCallback((W,z)=>{const fe=Ve.current[W]?.id;if(!fe)return;const L=[...B];L[W]={...L[W],pan:z},re(L),$.current&&$.current.setTrackPan(fe,z)},[B]),Pi=f.useCallback((W,z)=>{oe(W,z),ge.current=W,P(W),I&&$.current&&($.current.stop(),$.current.seek(W),$.current.play(W))},[I,oe]),Wi=f.useCallback(W=>{xe.current=W},[]),Ks=f.useRef(h);Ks.current=h;const Fi=f.useCallback(W=>{const z=typeof W=="function"?W(S.current):W;if(!Ks.current){process.env.NODE_ENV!=="production"&&console.warn("waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to WaveformPlaylistProvider to handle annotation updates.");return}Ks.current(z)},[]),Oi=O[0]?.sampleRate||44100,qs=t?30:0,Bi=e.length*r+qs,df=f.useMemo(()=>({isPlaying:I,currentTime:T,currentTimeRef:ge,playbackStartTimeRef:U,audioStartPositionRef:Re,getPlaybackTime:Cn}),[I,T,ge,U,Re,Cn]),ff=f.useMemo(()=>({continuousPlay:ie,linkEndpoints:ye,annotationsEditable:X,isAutomaticScroll:se,isLoopEnabled:Pt,annotations:x,activeAnnotationId:k,selectionStart:Qe,selectionEnd:dt,selectedTrackId:yi,loopStart:Wt,loopEnd:tn}),[ie,ye,X,se,Pt,x,k,Qe,dt,yi,Wt,tn]),Li=f.useCallback(W=>{ge.current=W,P(W)},[ge]),Vi=f.useCallback(W=>{ae(W)},[]),hf=f.useMemo(()=>({play:Gr,pause:Ii,stop:Ai,seekTo:Mi,setCurrentTime:Li,setTrackMute:$i,setTrackSolo:Ti,setTrackVolume:Di,setTrackPan:Ri,setSelection:Pi,setSelectedTrackId:bi,setTimeFormat:ee,formatTime:be,zoomIn:Ee.zoomIn,zoomOut:Ee.zoomOut,setMasterVolume:Q,setAutomaticScroll:Vi,setScrollContainer:Wi,scrollContainerRef:xe,setContinuousPlay:ki,setLinkEndpoints:De,setAnnotationsEditable:Z,setAnnotations:Fi,setActiveAnnotationId:Ft,setLoopEnabled:nn,setLoopRegion:Mt,setLoopRegionFromSelection:Si,clearLoopRegion:Kn}),[Gr,Ii,Ai,Mi,Li,$i,Ti,Di,Ri,Pi,bi,ee,be,Ee.zoomIn,Ee.zoomOut,Q,Vi,Wi,xe,ki,De,Z,Fi,Ft,nn,Mt,Si,Kn]),pf=f.useMemo(()=>({duration:M,audioBuffers:O,peaksDataArray:K,trackStates:B,tracks:e,sampleRate:Oi,waveHeight:r,timeScaleHeight:qs,minimumPlaylistHeight:Bi,controls:l,playoutRef:$,samplesPerPixel:je,timeFormat:Ke,masterVolume:Y,canZoomIn:Ee.canZoomIn,canZoomOut:Ee.canZoomOut,barWidth:g,barGap:b,progressBarWidth:_,isReady:de,mono:n,isDraggingRef:le}),[M,O,K,B,e,Oi,r,qs,Bi,l,$,je,Ke,Y,Ee.canZoomIn,Ee.canZoomOut,g,b,_,de,n,le]),mf={...pd,...i};return C.jsx(R.ThemeProvider,{theme:mf,children:C.jsx(Od.Provider,{value:df,children:C.jsx(Bd.Provider,{value:ff,children:C.jsx(Ld.Provider,{value:hf,children:C.jsx(Vd.Provider,{value:pf,children:w})})})})})},ct=()=>{const e=f.useContext(Od);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},ut=()=>{const e=f.useContext(Bd);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},Te=()=>{const e=f.useContext(Ld);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},vt=()=>{const e=f.useContext(Vd);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var wv=class{constructor(e){this._playbackRate=1,this.handleEnded=()=>{this.onStopCallback&&this.onStopCallback()},this.handleTimeUpdate=()=>{this.onTimeUpdateCallback&&this.onTimeUpdateCallback(this.audioElement.currentTime)},this._peaks=e.peaks,this._id=e.id??`track-${Date.now()}`,this._name=e.name??"Track",this._playbackRate=e.playbackRate??1,typeof e.source=="string"?(this.audioElement=new Audio(e.source),this.ownsElement=!0):(this.audioElement=e.source,this.ownsElement=!1),this.audioElement.preload="auto",this.audioElement.volume=e.volume??1,this.audioElement.playbackRate=this._playbackRate;const t=this.audioElement;"preservesPitch"in this.audioElement?t.preservesPitch=!0:"mozPreservesPitch"in this.audioElement?t.mozPreservesPitch=!0:"webkitPreservesPitch"in this.audioElement&&(t.webkitPreservesPitch=!0),this.audioElement.addEventListener("ended",this.handleEnded),this.audioElement.addEventListener("timeupdate",this.handleTimeUpdate)}play(e=0){this.audioElement.currentTime=e,this.audioElement.play().catch(t=>{console.warn("MediaElementTrack: play() failed:",t)})}pause(){this.audioElement.pause()}stop(){this.audioElement.pause(),this.audioElement.currentTime=0}seekTo(e){this.audioElement.currentTime=Math.max(0,Math.min(e,this.duration))}setVolume(e){this.audioElement.volume=Math.max(0,Math.min(1,e))}setPlaybackRate(e){const t=Math.max(.5,Math.min(2,e));this._playbackRate=t,this.audioElement.playbackRate=t}setMuted(e){this.audioElement.muted=e}setOnStopCallback(e){this.onStopCallback=e}setOnTimeUpdateCallback(e){this.onTimeUpdateCallback=e}dispose(){this.audioElement.removeEventListener("ended",this.handleEnded),this.audioElement.removeEventListener("timeupdate",this.handleTimeUpdate),this.audioElement.pause(),this.ownsElement&&(this.audioElement.src="",this.audioElement.load())}get id(){return this._id}get name(){return this._name}get peaks(){return this._peaks}get currentTime(){return this.audioElement.currentTime}get duration(){return this.audioElement.duration||this._peaks.duration}get isPlaying(){return!this.audioElement.paused&&!this.audioElement.ended}get volume(){return this.audioElement.volume}get playbackRate(){return this._playbackRate}get muted(){return this.audioElement.muted}get element(){return this.audioElement}},_v=class{constructor(e={}){this.track=null,this._isPlaying=!1,this._masterVolume=e.masterVolume??1,this._playbackRate=e.playbackRate??1}async init(){}addTrack(e){return this.track&&(console.warn("MediaElementPlayout: Only one track is supported. Disposing previous track. For multi-track, use TonePlayout."),this.track.dispose()),this.track=new wv({...e,volume:this._masterVolume*(e.volume??1),playbackRate:this._playbackRate}),this.track.setOnStopCallback(()=>{this._isPlaying=!1,this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback()}),this.track}removeTrack(e){this.track&&this.track.id===e&&(this.track.dispose(),this.track=null)}getTrack(e){if(this.track&&this.track.id===e)return this.track}play(e,t,n){if(!this.track){console.warn("MediaElementPlayout: No track to play");return}const r=t??0;if(this._isPlaying=!0,this.track.play(r),n!==void 0){const s=n/this._playbackRate;setTimeout(()=>{this._isPlaying&&(this.pause(),this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())},s*1e3)}}pause(){this.track&&this.track.pause(),this._isPlaying=!1}stop(){this.track&&this.track.stop(),this._isPlaying=!1}seekTo(e){this.track&&this.track.seekTo(e)}getCurrentTime(){return this.track?this.track.currentTime:0}setMasterVolume(e){this._masterVolume=Math.max(0,Math.min(1,e)),this.track&&this.track.setVolume(this._masterVolume)}setPlaybackRate(e){this._playbackRate=Math.max(.5,Math.min(2,e)),this.track&&this.track.setPlaybackRate(this._playbackRate)}setMute(e,t){const n=this.getTrack(e);n&&n.setMuted(t)}setSolo(e,t){console.warn("MediaElementPlayout: Solo is not applicable for single-track playback")}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}dispose(){this.track&&(this.track.dispose(),this.track=null)}get isPlaying(){return this._isPlaying}get masterVolume(){return this._masterVolume}get playbackRate(){return this._playbackRate}get duration(){return this.track?.duration??0}get sampleRate(){return this.track?.peaks.sample_rate??44100}};const zd=f.createContext(null),jd=f.createContext(null),Zd=f.createContext(null),Hd=f.createContext(null),xv=({track:e,samplesPerPixel:t=1024,waveHeight:n=100,timescale:r=!1,playbackRate:s=1,automaticScroll:a=!1,theme:o,controls:i={show:!1,width:0},annotationList:l,barWidth:c=1,barGap:u=0,progressBarWidth:d,onAnnotationsChange:p,onReady:h,children:g})=>{const b=d??c+u,[y,m]=f.useState(!1),[w,_]=f.useState(0),[v,x]=f.useState(0),[S,k]=f.useState([]),[E,I]=f.useState(s),A=f.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const N=l.annotations[0];if(typeof N.start!="number"||typeof N.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof N.start),[]}return l.annotations},[l?.annotations]),T=f.useRef(A);T.current=A;const[P,M]=f.useState(null),[F,O]=f.useState(l?.isContinuousPlay??!1),[H]=f.useState(t),[K,ne]=f.useState(a),B=f.useRef(null),re=f.useRef(0),se=f.useRef(F),ae=f.useRef(null),ie=f.useRef(null),me=f.useRef(a),ye=f.useRef(t),{startAnimationFrameLoop:De,stopAnimationFrameLoop:X}=Fd();f.useEffect(()=>{se.current=F},[F]),f.useEffect(()=>{me.current=K},[K]);const Z=f.useCallback(N=>{ae.current=N,M(N)},[]),de=f.useCallback(N=>{se.current=N,O(N)},[]),G=f.useCallback(N=>{ie.current=N},[]),$=e.waveformData.sample_rate;f.useEffect(()=>{const N=new _v({playbackRate:s});N.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const le=N.getTrack(N.track?.id??"");return le&&le.setOnTimeUpdateCallback(Fe=>{re.current=Fe}),N.setOnPlaybackComplete(()=>{X(),m(!1),Z(null),re.current=0,_(0)}),B.current=N,x(e.waveformData.duration),h?.(),()=>{X(),N.dispose()}},[e.source,e.waveformData,e.name,s,h,X,Z]),f.useEffect(()=>{try{const N=z0(e.waveformData,H,0,0,Math.ceil(e.waveformData.duration*$)),le={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:N.length,data:[N.data],bits:N.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*$)};k([[le]])}catch(N){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",N)}},[e.waveformData,e.name,H,$]);const he=f.useCallback(()=>{const N=()=>{const le=B.current?.getCurrentTime()??0;re.current=le;const Fe=T.current;if(Fe.length>0){const Ke=Fe.find(ee=>le>=ee.start&&le<ee.end);if(se.current)Ke&&Ke.id!==ae.current?Z(Ke.id):!Ke&&ae.current!==null&&Z(null);else if(ae.current){const ee=Fe.find(be=>be.id===ae.current);if(ee&&le>=ee.end){B.current?.stop(),m(!1);return}}else Ke&&Z(Ke.id)}if(me.current&&ie.current){const Ke=ie.current,ee=le*$/ye.current,be=Ke.clientWidth,Ee=i.show?i.width:0,je=ee+Ee,bt=Math.max(0,je-be/2);Ke.scrollLeft=bt}De(N)};De(N)},[Z,$,i,De]),We=X,q=f.useCallback(N=>{if(!B.current)return;const le=N??re.current;B.current.play(void 0,le),m(!0),he()},[he]),ge=f.useCallback(()=>{B.current&&(B.current.pause(),m(!1),We(),_(B.current.getCurrentTime()))},[We]),Ve=f.useCallback(()=>{B.current&&(B.current.stop(),m(!1),We(),re.current=0,_(0),Z(null))},[We,Z]),Ne=f.useCallback(N=>{const le=Math.max(0,Math.min(N,v));re.current=le,_(le),B.current&&B.current.seekTo(le)},[v]),U=f.useCallback(N=>{const le=Math.max(.5,Math.min(2,N));I(le),B.current&&B.current.setPlaybackRate(le)},[]),Re=r?30:0,ze=f.useMemo(()=>({isPlaying:y,currentTime:w,currentTimeRef:re}),[y,w]),xe=f.useMemo(()=>({continuousPlay:F,annotations:A,activeAnnotationId:P,playbackRate:E,isAutomaticScroll:K}),[F,A,P,E,K]),Xe=f.useRef(p);Xe.current=p;const Ue=f.useCallback(N=>{const le=typeof N=="function"?N(T.current):N;if(!Xe.current){process.env.NODE_ENV!=="production"&&console.warn("waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to MediaElementPlaylistProvider to handle annotation updates.");return}Xe.current(le)},[]),at=f.useMemo(()=>({play:q,pause:ge,stop:Ve,seekTo:Ne,setPlaybackRate:U,setContinuousPlay:de,setAnnotations:Ue,setActiveAnnotationId:Z,setAutomaticScroll:N=>{ne(N)},setScrollContainer:G,scrollContainerRef:ie}),[q,ge,Ve,Ne,U,de,Ue,Z,G]),yt=f.useMemo(()=>({duration:v,peaksDataArray:S,sampleRate:$,waveHeight:n,timeScaleHeight:Re,samplesPerPixel:H,playoutRef:B,controls:i,barWidth:c,barGap:u,progressBarWidth:b}),[v,S,$,n,Re,H,i,c,u,b]),At={...pd,...o};return C.jsx(R.ThemeProvider,{theme:At,children:C.jsx(zd.Provider,{value:ze,children:C.jsx(jd.Provider,{value:xe,children:C.jsx(Zd.Provider,{value:at,children:C.jsx(Hd.Provider,{value:yt,children:g})})})})})},Zs=()=>{const e=f.useContext(zd);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},Hs=()=>{const e=f.useContext(jd);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},hi=()=>{const e=f.useContext(Zd);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},Ns=()=>{const e=f.useContext(Hd);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},Cv=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=ct(),{selectionStart:r,selectionEnd:s,isLoopEnabled:a}=ut(),{play:o}=Te(),i=async()=>{if(r!==s&&s>r&&!a){const c=s-r;await o(r,c)}else await o(n.current??0)};return C.jsx(St,{onClick:i,disabled:t,className:e,children:"Play"})},kv=({className:e})=>{const{isPlaying:t}=ct(),{pause:n}=Te();return C.jsx(St,{onClick:n,disabled:!t,className:e,children:"Pause"})},Sv=({className:e})=>{const{isPlaying:t}=ct(),{stop:n}=Te();return C.jsx(St,{onClick:n,disabled:!t,className:e,children:"Stop"})},Ev=({className:e})=>{const{isPlaying:t}=ct(),{play:n,setCurrentTime:r}=Te(),s=()=>{r(0),t&&n(0)};return C.jsx(St,{onClick:s,className:e,children:"Rewind"})},Iv=({className:e})=>{const{isPlaying:t}=ct(),{play:n,setCurrentTime:r}=Te(),{duration:s}=vt(),a=()=>{r(s),t&&n(s)};return C.jsx(St,{onClick:a,className:e,children:"Fast Forward"})},Av=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ct(),{play:s,setCurrentTime:a}=Te(),o=()=>{const i=Math.max(0,(n.current??0)-e);a(i),r&&s(i)};return C.jsx(St,{onClick:o,className:t,children:"Skip Backward"})},Mv=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ct(),{play:s,setCurrentTime:a}=Te(),{duration:o}=vt(),i=()=>{const l=Math.min(o,(n.current??0)+e);a(l),r&&s(l)};return C.jsx(St,{onClick:i,className:t,children:"Skip Forward"})},$v=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=ut(),{setLoopEnabled:s,setLoopRegion:a}=Te(),{duration:o}=vt(),i=n!==r&&r>n,l=()=>{if(!t&&!i){const c=Math.min(10,o*.25);a(0,Math.max(1,c))}s(!t)};return C.jsx(St,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},Tv=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=ut(),{setLoopRegionFromSelection:a,clearLoopRegion:o}=Te(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?o():a()};return C.jsx(St,{onClick:c,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"})},Dv=({className:e,disabled:t})=>{const{zoomIn:n}=Te(),{canZoomIn:r}=vt();return C.jsx(St,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},Rv=({className:e,disabled:t})=>{const{zoomOut:n}=Te(),{canZoomOut:r}=vt();return C.jsx(St,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},Pv=({className:e})=>{const{masterVolume:t}=vt(),{setMasterVolume:n}=Te();return C.jsx(kg,{volume:t,onChange:n,className:e})},Wv=({className:e})=>{const{timeFormat:t}=vt(),{setTimeFormat:n}=Te();return C.jsx(o0,{value:t,onChange:n,className:e})},Fv=R.span`
|
|
1009
|
+
`;let T0=0;function $0(){let e;try{const r=new Blob([A0],{type:"application/javascript"}),s=URL.createObjectURL(r);e=new Worker(s),URL.revokeObjectURL(s)}catch(r){return console.warn("[waveform-playlist] Failed to create peaks worker (CSP restriction?):",r),{generate(){return Promise.reject(new Error("Worker creation failed"))},terminate(){}}}const t=new Map;let n=!1;return e.onmessage=r=>{const s=r.data,o=t.get(s.id);if(o)if(t.delete(s.id),s.error)o.reject(new Error(s.error));else try{const a=mt.create(s.buffer);o.resolve(a)}catch(a){o.reject(a)}},e.onerror=r=>{n=!0,e.terminate();for(const[,s]of t)s.reject(r.error??new Error(r.message));t.clear()},{generate(r){if(n)return Promise.reject(new Error("Worker terminated"));const s=String(++T0);return new Promise((o,a)=>{t.set(s,{resolve:o,reject:a}),e.postMessage({id:s,scale:r.scale,bits:r.bits,amplitude_scale:1,split_channels:r.splitChannels,length:r.length,sample_rate:r.sampleRate,channels:r.channels},r.channels)})},terminate(){n=!0,e.terminate();for(const[,r]of t)r.reject(new Error("Worker terminated"));t.clear()}}}function R0(e,t){const[n,r]=g.useState(()=>new Map),[s,o]=g.useState(!1),a=g.useRef(null),i=g.useRef(new WeakMap),l=g.useRef(new WeakMap),c=g.useRef(new WeakMap),u=g.useRef(0),f=g.useCallback(()=>(a.current||(a.current=$0()),a.current),[]);return g.useEffect(()=>{let h=!1;const d=i.current,p=l.current,v=c.current,y=[],m=new Map;for(const _ of e)for(const w of _.clips){if(!w.audioBuffer||w.waveformData)continue;const x=d.get(w.audioBuffer);if(x){y.push({clipId:w.id,waveformData:x});continue}if(p.get(w.audioBuffer)){const k=v.get(w.audioBuffer);k?k.add(w.id):v.set(w.audioBuffer,new Set([w.id]));continue}const S=m.get(w.audioBuffer);S?S.add(w.id):m.set(w.audioBuffer,new Set([w.id]))}if(y.length>0&&r(_=>{const w=new Map(_);for(const x of y)w.set(x.clipId,x.waveformData);return w}),m.size===0)return;u.current+=m.size,o(!0);const b=f();for(const[_,w]of m){v.set(_,new Set(w));const x=[];for(let E=0;E<_.numberOfChannels;E++)x.push(_.getChannelData(E).slice().buffer);const S=`buffer-${Math.random().toString(36).slice(2,11)}`,k=b.generate({id:S,channels:x,length:_.length,sampleRate:_.sampleRate,scale:t,bits:16,splitChannels:!0}).then(E=>{d.set(_,E);const T=v.get(_)??new Set;v.delete(_),p.delete(_),!h&&(r(I=>{const M=new Map(I);for(const $ of T)M.set($,E);return M}),u.current--,u.current<=0&&(u.current=0,o(!1)))}).catch(E=>{v.delete(_),p.delete(_),!h&&(console.warn("[waveform-playlist] Worker peak generation failed:",E),u.current--,u.current<=0&&(u.current=0,o(!1)))});p.set(_,k)}return()=>{h=!0,l.current=new WeakMap,c.current=new WeakMap,u.current=0,o(!1)}},[e,t,f]),g.useEffect(()=>()=>{a.current?.terminate(),a.current=null},[]),{cache:n,isGenerating:s}}function aa(e){return e instanceof File?e.name.replace(/\.[^/.]+$/,""):e instanceof Blob?"Untitled":typeof e=="string"?e.split("/").pop()?.replace(/\.[^/.]+$/,"")??"Untitled":e.name??e.src.split("/").pop()?.replace(/\.[^/.]+$/,"")??"Untitled"}async function D0(e,t,n){const r=aa(e);if(e instanceof Blob){const l=await e.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(l),name:r}}const s=typeof e=="string"?e:e.src,o=await fetch(s,{signal:n});if(!o.ok)throw new Error(`Failed to fetch ${s}: ${o.statusText}`);const a=await o.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(a),name:r}}function P0(){const[e,t]=g.useState([]),[n,r]=g.useState(0),[s,o]=g.useState([]),a=g.useRef(!1),i=g.useRef(new Set),l=g.useRef(new Map);g.useEffect(()=>{const f=l.current;return()=>{a.current=!0;for(const h of f.values())h.abort();f.clear()}},[]);const c=g.useCallback(f=>{if(f.length===0)return;const h=Zf(),d=f.map(p=>({track:Ql({name:`${aa(p)} (loading...)`,clips:[]}),source:p}));t(p=>[...p,...d.map(v=>v.track)]),r(p=>p+f.length);for(const{track:p,source:v}of d){i.current.add(p.id);const y=new AbortController;l.current.set(p.id,y),(async()=>{try{const{audioBuffer:m,name:b}=await D0(v,h,y.signal),_=Jl({audioBuffer:m,startTime:0,duration:m.duration,offset:0,name:b});!a.current&&i.current.has(p.id)&&t(w=>w.map(x=>x.id===p.id?{...x,name:b,clips:[_]}:x))}catch(m){if(m instanceof DOMException&&m.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",m),!a.current&&i.current.has(p.id)&&(t(b=>b.filter(_=>_.id!==p.id)),o(b=>[...b,{name:aa(v),error:m instanceof Error?m:new Error(String(m))}]))}finally{l.current.delete(p.id),!a.current&&i.current.delete(p.id)&&r(m=>m-1)}})()}},[]),u=g.useCallback(f=>{t(d=>d.filter(p=>p.id!==f));const h=l.current.get(f);h&&(h.abort(),l.current.delete(f)),i.current.delete(f)&&r(d=>d-1)},[]);return{tracks:e,addTracks:c,removeTrack:u,loadingCount:n,isLoading:n>0,errors:s}}const Gd=g.createContext(null),Ud=g.createContext(null),Xd=g.createContext(null),Yd=g.createContext(null),F0=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:s=1024,zoomLevels:o,automaticScroll:a=!1,theme:i,controls:l={show:!1,width:0},annotationList:c,effects:u,onReady:f,onAnnotationUpdate:h,onAnnotationsChange:d,barWidth:p=1,barGap:v=0,progressBarWidth:y,onTracksChange:m,soundFontCache:b,children:_})=>{const w=y??p+v,x=g.useMemo(()=>o,[o?.join(",")]),S=g.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const L=c.annotations[0];if(typeof L.start!="number"||typeof L.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof L.start),[]}return c.annotations},[c?.annotations]),k=g.useRef(S);k.current=S;const[E,T]=g.useState(null),[I,M]=g.useState(!1),[$,A]=g.useState(0),[R,W]=g.useState(0),[q,z]=g.useState([]),[J,ee]=g.useState([]),[j,se]=g.useState([]),[U,ie]=g.useState(a),[le,ge]=g.useState(c?.isContinuousPlay??!1),[Se,N]=g.useState(c?.linkEndpoints??!1),[G,ye]=g.useState(c?.editable??!1),[Z,Q]=g.useState(!1),O=g.useRef(null),_e=g.useRef(!1),Ne=g.useRef(!1);Ne.current=I;const Be=g.useRef(0),ve=g.useRef(0),Ve=g.useRef(e),ne=g.useRef(b);ne.current=b;const Ge=g.useRef(j),je=g.useRef(0),xe=g.useRef(0),Fe=g.useRef(null),Oe=g.useRef(null),Et=g.useRef(!1),It=g.useRef(c?.isContinuousPlay??!1),Mt=g.useRef(null),X=g.useRef(null),fe=g.useRef(0),Ue=g.useRef(!1),Me=g.useRef(!1),oe=g.useRef(s),he=g.useRef(44100),{timeFormat:Xe,setTimeFormat:At,formatTime:Tt}=Vd(),ut=Nd({engineRef:O,initialSamplesPerPixel:s}),{samplesPerPixel:yt,onEngineState:V}=ut,Y=zd({engineRef:O,initialVolume:1}),{masterVolume:K,setMasterVolume:ce,masterVolumeRef:Ae,onEngineState:Ze}=Y,{selectionStart:te,selectionEnd:Ke,setSelection:Qe,selectionStartRef:Te,selectionEndRef:dt,onEngineState:Lt}=s0({engineRef:O}),{isLoopEnabled:rn,loopStart:sn,loopEnd:Ht,setLoopEnabled:qn,setLoopRegion:kn,clearLoopRegion:Hr,isLoopEnabledRef:xi,loopStartRef:Ci,loopEndRef:Si,onEngineState:ki}=o0({engineRef:O}),{selectedTrackId:Ei,setSelectedTrackId:Ii,onEngineState:Mi,selectedTrackIdRef:Ai}=a0({engineRef:O}),{animationFrameRef:Ti,startAnimationFrameLoop:Js,stopAnimationFrameLoop:Gr}=Hd(),bf=g.useMemo(()=>Math.min(...x??[256,512,1024,2048,4096,8192]),[x]),{cache:$i}=R0(e,bf),Ri=g.useCallback(L=>{It.current=L,ge(L)},[]),Wt=g.useCallback(L=>{Mt.current=L,T(L)},[]),Di=g.useCallback(()=>{const L=Te.current??0,H=dt.current??0;L!==H&&H>L&&kn(L,H)},[kn,Te,dt]);g.useEffect(()=>{Et.current=U},[U]),g.useEffect(()=>{Ge.current=j},[j]),Ve.current=e;const Qs=e===X.current;Ue.current=Qs||Me.current,g.useEffect(()=>{if(!Oe.current||R===0)return;const L=Oe.current,H=oe.current,pe=yt;if(H===pe)return;const B=L.clientWidth,Ee=L.scrollLeft+B/2,et=he.current,ro=Ee*H/et*et/pe,so=Math.max(0,ro-B/2);L.scrollLeft=so,oe.current=pe},[yt,R]);const Ur=g.useRef(null);g.useEffect(()=>{if(Qs||Me.current){Qs&&(X.current=null);let B=0;e.forEach($e=>{$e.clips.forEach(Ee=>{const et=(Ee.startSample+Ee.durationSamples)/Ee.sampleRate;B=Math.max(B,et)})}),W(B);return}if(Q(!1),e.length===0){z([]),W(0),se([]),ee([]),O.current&&(O.current.dispose(),O.current=null);return}const L=Ne.current,H=ve.current;return O.current&&L&&(O.current.stop(),Gr(),Ur.current={position:H}),(async()=>{try{const B=performance.now(),$e=[];e.forEach(ke=>{ke.clips.length>0&&ke.clips[0].audioBuffer&&$e.push(ke.clips[0].audioBuffer)});let Ee=0;e.forEach(ke=>{ke.clips.forEach(ht=>{const Gt=ht.sampleRate,Ef=(ht.startSample+ht.durationSamples)/Gt;Ee=Math.max(Ee,Ef)})}),z($e),W(Ee),se(ke=>ke.length===e.length?ke.map((ht,Gt)=>({...ht,name:e[Gt].name})):e.map(ht=>({name:ht.name,muted:ht.muted,soloed:ht.soloed,volume:ht.volume,pan:ht.pan}))),O.current&&O.current.dispose(),fe.current=0,X.current=null,_e.current=!1;const et=Hf({effects:u,soundFontCache:ne.current}),bt=new Jf({adapter:et,samplesPerPixel:oe.current,zoomLevels:x});bt.setSelection(Te.current??0,dt.current??0),bt.setLoopRegion(Ci.current??0,Si.current??0),xi.current&&bt.setLoopEnabled(!0),bt.setMasterVolume(Ae.current??1),Ai.current&&bt.selectTrack(Ai.current);const ro=Ge.current,so=e.map((ke,ht)=>{const Gt=ro[ht];return{...ke,volume:Gt?.volume??ke.volume,muted:Gt?.muted??ke.muted,soloed:Gt?.soloed??ke.soloed,pan:Gt?.pan??ke.pan}});let Xi=!0;bt.on("statechange",ke=>{Lt(ke),ki(ke),Mi(ke),V(ke),Ze(ke),!Xi&&ke.tracksVersion!==fe.current&&(fe.current=ke.tracksVersion,X.current=ke.tracks,m?m(ke.tracks):console.warn("[waveform-playlist] Engine tracks changed but onTracksChange prop is not set — UI will revert on next render. Pass onTracksChange to WaveformPlaylistProvider."))}),bt.setTracks(so),Xi=!1,fe.current=bt.getState().tracksVersion,O.current=bt,Q(!0),console.log(`[engine] rebuild: ${e.length} tracks, ${(performance.now()-B).toFixed(1)}ms`);const kf=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:Ee}});window.dispatchEvent(kf),f?.()}catch(B){console.error("Error loading audio:",B)}})(),()=>{if(Ue.current){Ue.current=!1;return}Gr(),O.current&&O.current.dispose()}},[e,f,u,Gr,Lt,ki,Mi,V,Ze,m,Ae,Te,dt,Ci,Si,xi,x,b]),g.useEffect(()=>{if(e.length===0)return;const L=e.map(H=>H.clips.map(B=>{let $e;if(B.waveformData)try{$e=zl(B.waveformData,yt,n,B.offsetSamples,B.durationSamples)}catch(Ee){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",Ee)}if(!$e){const Ee=$i.get(B.id);if(Ee)try{$e=zl(Ee,yt,n,B.offsetSamples,B.durationSamples)}catch(et){console.warn("[waveform-playlist] Failed to extract peaks from cache:",et)}}if(!$e){!B.audioBuffer&&!B.waveformData&&!B.midiNotes&&console.warn(`[waveform-playlist] Clip "${B.id}" has no audio data or waveform data`);const Ee=n?1:B.audioBuffer?.numberOfChannels??1,et=B.midiNotes?Math.ceil(B.durationSamples/yt):0;$e={length:et,data:Array.from({length:Ee},()=>new Int16Array(et*2)),bits:16}}return{clipId:B.id,trackName:H.name,peaks:$e,startSample:B.startSample,durationSamples:B.durationSamples,fadeIn:B.fadeIn,fadeOut:B.fadeOut,midiNotes:B.midiNotes,sampleRate:B.sampleRate,offsetSamples:B.offsetSamples}}));ee(L)},[e,yt,n,$i]);const Pi=g.useRef(!1),En=g.useCallback(()=>{if(O.current)return O.current.getCurrentTime();Pi.current||(Pi.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const L=F.getContext().currentTime-(je.current??0);return(xe.current??0)+L},[]),on=g.useCallback(()=>{const L=()=>{const H=En();ve.current=H;const pe=k.current;if(pe.length>0){const B=pe.find($e=>H>=$e.start&&H<$e.end);if(It.current)B&&B.id!==Mt.current?Wt(B.id):!B&&Mt.current!==null&&Wt(null);else if(Mt.current){const $e=pe.find(Ee=>Ee.id===Mt.current);if($e&&H>=$e.end){O.current&&O.current.stop(),M(!1),ve.current=Be.current,A(Be.current);return}}else B&&Wt(B.id)}if(Et.current&&Oe.current&&R>0){const B=Oe.current,$e=he.current,Ee=H*$e/oe.current,et=B.clientWidth,bt=Math.max(0,Ee-et/2);B.scrollLeft=bt}if(Fe.current!==null&&H>=Fe.current){O.current&&O.current.stop(),M(!1),ve.current=Fe.current,A(Fe.current),Fe.current=null;return}if(H>=R){O.current&&O.current.stop(),M(!1),ve.current=Be.current,A(Be.current),Wt(null);return}Js(L)};Js(L)},[R,Wt,Js,En]),ft=Gr;g.useEffect(()=>{(async()=>{if(I&&Ti.current&&O.current)if(le){const H=ve.current;O.current.stop(),ft();const B=F.getContext().currentTime;je.current=B,xe.current=H,O.current.play(H),on()}else ft(),on()})().catch(H=>{console.warn("[waveform-playlist] Failed to reschedule playback:",H),M(!1),ft()})},[le,I,on,ft,Ti]),g.useEffect(()=>{(async()=>{if(Ur.current&&O.current){const{position:H}=Ur.current;Ur.current=null;const B=F.getContext().currentTime;je.current=B,xe.current=H,_e.current||(await O.current.init(),_e.current=!0),O.current.play(H),M(!0),on()}})().catch(H=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",H),M(!1),ft()})},[e,on,ft]);const Xr=g.useCallback(async(L,H)=>{if(!O.current||R===0)return;const pe=L??ve.current;Be.current=pe,ve.current=pe,O.current.stop(),O.current.seek(pe),ft();const $e=F.getContext().currentTime;je.current=$e,xe.current=pe,Fe.current=H!==void 0?pe+H:null,_e.current||(await O.current.init(),_e.current=!0);const Ee=H!==void 0?pe+H:void 0;try{O.current.play(pe,Ee)}catch(et){console.warn("[waveform-playlist] Playback failed to start:",et),ft();return}M(!0),on()},[R,on,ft]),Fi=g.useCallback(()=>{if(!O.current)return;const L=En();O.current.pause(),M(!1),ft(),ve.current=L,A(L)},[ft,En]),Oi=g.useCallback(()=>{O.current&&(O.current.stop(),M(!1),ft(),ve.current=Be.current,A(Be.current),Wt(null))},[ft,Wt]),Li=g.useCallback(L=>{const H=Math.max(0,Math.min(L,R));ve.current=H,A(H),I&&O.current&&Xr(H)},[R,I,Xr]),Wi=g.useCallback((L,H)=>{const pe=Ve.current[L]?.id;if(!pe)return;const B=[...j];B[L]={...B[L],muted:H},se(B),O.current&&O.current.setTrackMute(pe,H)},[j]),Bi=g.useCallback((L,H)=>{const pe=Ve.current[L]?.id;if(!pe)return;const B=[...j];B[L]={...B[L],soloed:H},se(B),O.current&&O.current.setTrackSolo(pe,H)},[j]),Vi=g.useCallback((L,H)=>{const pe=Ve.current[L]?.id;if(!pe)return;const B=[...j];B[L]={...B[L],volume:H},se(B),O.current&&O.current.setTrackVolume(pe,H)},[j]),Ni=g.useCallback((L,H)=>{const pe=Ve.current[L]?.id;if(!pe)return;const B=[...j];B[L]={...B[L],pan:H},se(B),O.current&&O.current.setTrackPan(pe,H)},[j]),zi=g.useCallback((L,H)=>{Qe(L,H),ve.current=L,A(L),I&&O.current&&(O.current.stop(),O.current.seek(L),O.current.play(L))},[I,Qe]),ji=g.useCallback(L=>{Oe.current=L},[]),eo=g.useRef(d);eo.current=d;const Zi=g.useCallback(L=>{const H=typeof L=="function"?L(k.current):L;if(!eo.current){process.env.NODE_ENV!=="production"&&console.warn("waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to WaveformPlaylistProvider to handle annotation updates.");return}eo.current(H)},[]),to=q[0]?.sampleRate||e[0]?.clips[0]?.sampleRate||44100;he.current=to;const no=t?30:0,Hi=e.length*r+no,wf=g.useMemo(()=>({isPlaying:I,currentTime:$,currentTimeRef:ve,playbackStartTimeRef:je,audioStartPositionRef:xe,getPlaybackTime:En}),[I,$,ve,je,xe,En]),_f=g.useMemo(()=>({continuousPlay:le,linkEndpoints:Se,annotationsEditable:G,isAutomaticScroll:U,isLoopEnabled:rn,annotations:S,activeAnnotationId:E,selectionStart:te,selectionEnd:Ke,selectedTrackId:Ei,loopStart:sn,loopEnd:Ht}),[le,Se,G,U,rn,S,E,te,Ke,Ei,sn,Ht]),Gi=g.useCallback(L=>{ve.current=L,A(L)},[ve]),Ui=g.useCallback(L=>{ie(L)},[]),xf=g.useMemo(()=>({play:Xr,pause:Fi,stop:Oi,seekTo:Li,setCurrentTime:Gi,setTrackMute:Wi,setTrackSolo:Bi,setTrackVolume:Vi,setTrackPan:Ni,setSelection:zi,setSelectedTrackId:Ii,setTimeFormat:At,formatTime:Tt,zoomIn:ut.zoomIn,zoomOut:ut.zoomOut,setMasterVolume:ce,setAutomaticScroll:Ui,setScrollContainer:ji,scrollContainerRef:Oe,setContinuousPlay:Ri,setLinkEndpoints:N,setAnnotationsEditable:ye,setAnnotations:Zi,setActiveAnnotationId:Wt,setLoopEnabled:qn,setLoopRegion:kn,setLoopRegionFromSelection:Di,clearLoopRegion:Hr}),[Xr,Fi,Oi,Li,Gi,Wi,Bi,Vi,Ni,zi,Ii,At,Tt,ut.zoomIn,ut.zoomOut,ce,Ui,ji,Oe,Ri,N,ye,Zi,Wt,qn,kn,Di,Hr]),Cf=g.useMemo(()=>({duration:R,audioBuffers:q,peaksDataArray:J,trackStates:j,tracks:e,sampleRate:to,waveHeight:r,timeScaleHeight:no,minimumPlaylistHeight:Hi,controls:l,playoutRef:O,samplesPerPixel:yt,timeFormat:Xe,masterVolume:K,canZoomIn:ut.canZoomIn,canZoomOut:ut.canZoomOut,barWidth:p,barGap:v,progressBarWidth:w,isReady:Z,mono:n,isDraggingRef:Me}),[R,q,J,j,e,to,r,no,Hi,l,O,yt,Xe,K,ut.canZoomIn,ut.canZoomOut,p,v,w,Z,n,Me]),Sf={...kd,...i};return C.jsx(P.ThemeProvider,{theme:Sf,children:C.jsx(Gd.Provider,{value:wf,children:C.jsx(Ud.Provider,{value:_f,children:C.jsx(Xd.Provider,{value:xf,children:C.jsx(Yd.Provider,{value:Cf,children:_})})})})})},lt=()=>{const e=g.useContext(Gd);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},ct=()=>{const e=g.useContext(Ud);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},Pe=()=>{const e=g.useContext(Xd);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},vt=()=>{const e=g.useContext(Yd);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var O0=class{constructor(e){this._playbackRate=1,this.handleEnded=()=>{this.onStopCallback&&this.onStopCallback()},this.handleTimeUpdate=()=>{this.onTimeUpdateCallback&&this.onTimeUpdateCallback(this.audioElement.currentTime)},this._peaks=e.peaks,this._id=e.id??`track-${Date.now()}`,this._name=e.name??"Track",this._playbackRate=e.playbackRate??1,typeof e.source=="string"?(this.audioElement=new Audio(e.source),this.ownsElement=!0):(this.audioElement=e.source,this.ownsElement=!1),this.audioElement.preload="auto",this.audioElement.volume=e.volume??1,this.audioElement.playbackRate=this._playbackRate;const t=this.audioElement;"preservesPitch"in this.audioElement?t.preservesPitch=!0:"mozPreservesPitch"in this.audioElement?t.mozPreservesPitch=!0:"webkitPreservesPitch"in this.audioElement&&(t.webkitPreservesPitch=!0),this.audioElement.addEventListener("ended",this.handleEnded),this.audioElement.addEventListener("timeupdate",this.handleTimeUpdate)}play(e=0){this.audioElement.currentTime=e,this.audioElement.play().catch(t=>{console.warn("MediaElementTrack: play() failed:",t)})}pause(){this.audioElement.pause()}stop(){this.audioElement.pause(),this.audioElement.currentTime=0}seekTo(e){this.audioElement.currentTime=Math.max(0,Math.min(e,this.duration))}setVolume(e){this.audioElement.volume=Math.max(0,Math.min(1,e))}setPlaybackRate(e){const t=Math.max(.5,Math.min(2,e));this._playbackRate=t,this.audioElement.playbackRate=t}setMuted(e){this.audioElement.muted=e}setOnStopCallback(e){this.onStopCallback=e}setOnTimeUpdateCallback(e){this.onTimeUpdateCallback=e}dispose(){this.audioElement.removeEventListener("ended",this.handleEnded),this.audioElement.removeEventListener("timeupdate",this.handleTimeUpdate),this.audioElement.pause(),this.ownsElement&&(this.audioElement.src="",this.audioElement.load())}get id(){return this._id}get name(){return this._name}get peaks(){return this._peaks}get currentTime(){return this.audioElement.currentTime}get duration(){return this.audioElement.duration||this._peaks.duration}get isPlaying(){return!this.audioElement.paused&&!this.audioElement.ended}get volume(){return this.audioElement.volume}get playbackRate(){return this._playbackRate}get muted(){return this.audioElement.muted}get element(){return this.audioElement}},L0=class{constructor(e={}){this.track=null,this._isPlaying=!1,this._masterVolume=e.masterVolume??1,this._playbackRate=e.playbackRate??1}async init(){}addTrack(e){return this.track&&(console.warn("MediaElementPlayout: Only one track is supported. Disposing previous track. For multi-track, use TonePlayout."),this.track.dispose()),this.track=new O0({...e,volume:this._masterVolume*(e.volume??1),playbackRate:this._playbackRate}),this.track.setOnStopCallback(()=>{this._isPlaying=!1,this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback()}),this.track}removeTrack(e){this.track&&this.track.id===e&&(this.track.dispose(),this.track=null)}getTrack(e){if(this.track&&this.track.id===e)return this.track}play(e,t,n){if(!this.track){console.warn("MediaElementPlayout: No track to play");return}const r=t??0;if(this._isPlaying=!0,this.track.play(r),n!==void 0){const s=n/this._playbackRate;setTimeout(()=>{this._isPlaying&&(this.pause(),this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())},s*1e3)}}pause(){this.track&&this.track.pause(),this._isPlaying=!1}stop(){this.track&&this.track.stop(),this._isPlaying=!1}seekTo(e){this.track&&this.track.seekTo(e)}getCurrentTime(){return this.track?this.track.currentTime:0}setMasterVolume(e){this._masterVolume=Math.max(0,Math.min(1,e)),this.track&&this.track.setVolume(this._masterVolume)}setPlaybackRate(e){this._playbackRate=Math.max(.5,Math.min(2,e)),this.track&&this.track.setPlaybackRate(this._playbackRate)}setMute(e,t){const n=this.getTrack(e);n&&n.setMuted(t)}setSolo(e,t){console.warn("MediaElementPlayout: Solo is not applicable for single-track playback")}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}dispose(){this.track&&(this.track.dispose(),this.track=null)}get isPlaying(){return this._isPlaying}get masterVolume(){return this._masterVolume}get playbackRate(){return this._playbackRate}get duration(){return this.track?.duration??0}get sampleRate(){return this.track?.peaks.sample_rate??44100}};const Kd=g.createContext(null),qd=g.createContext(null),Jd=g.createContext(null),Qd=g.createContext(null),W0=({track:e,samplesPerPixel:t=1024,waveHeight:n=100,timescale:r=!1,playbackRate:s=1,automaticScroll:o=!1,theme:a,controls:i={show:!1,width:0},annotationList:l,barWidth:c=1,barGap:u=0,progressBarWidth:f,onAnnotationsChange:h,onReady:d,children:p})=>{const v=f??c+u,[y,m]=g.useState(!1),[b,_]=g.useState(0),[w,x]=g.useState(0),[S,k]=g.useState([]),[E,T]=g.useState(s),I=g.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const X=l.annotations[0];if(typeof X.start!="number"||typeof X.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof X.start),[]}return l.annotations},[l?.annotations]),M=g.useRef(I);M.current=I;const[$,A]=g.useState(null),[R,W]=g.useState(l?.isContinuousPlay??!1),[q]=g.useState(t),[z,J]=g.useState(o),ee=g.useRef(null),j=g.useRef(0),se=g.useRef(R),U=g.useRef(null),ie=g.useRef(null),le=g.useRef(o),ge=g.useRef(t),{startAnimationFrameLoop:Se,stopAnimationFrameLoop:N}=Hd();g.useEffect(()=>{se.current=R},[R]),g.useEffect(()=>{le.current=z},[z]);const G=g.useCallback(X=>{U.current=X,A(X)},[]),ye=g.useCallback(X=>{se.current=X,W(X)},[]),Z=g.useCallback(X=>{ie.current=X},[]),Q=e.waveformData.sample_rate;g.useEffect(()=>{const X=new L0({playbackRate:s});X.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const fe=X.getTrack(X.track?.id??"");return fe&&fe.setOnTimeUpdateCallback(Ue=>{j.current=Ue}),X.setOnPlaybackComplete(()=>{N(),m(!1),G(null),j.current=0,_(0)}),ee.current=X,x(e.waveformData.duration),d?.(),()=>{N(),X.dispose()}},[e.source,e.waveformData,e.name,s,d,N,G]),g.useEffect(()=>{try{const X=r0(e.waveformData,q,0,0,Math.ceil(e.waveformData.duration*Q)),fe={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:X.length,data:[X.data],bits:X.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*Q)};k([[fe]])}catch(X){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",X)}},[e.waveformData,e.name,q,Q]);const O=g.useCallback(()=>{const X=()=>{const fe=ee.current?.getCurrentTime()??0;j.current=fe;const Ue=M.current;if(Ue.length>0){const Me=Ue.find(oe=>fe>=oe.start&&fe<oe.end);if(se.current)Me&&Me.id!==U.current?G(Me.id):!Me&&U.current!==null&&G(null);else if(U.current){const oe=Ue.find(he=>he.id===U.current);if(oe&&fe>=oe.end){ee.current?.stop(),m(!1);return}}else Me&&G(Me.id)}if(le.current&&ie.current){const Me=ie.current,oe=fe*Q/ge.current,he=Me.clientWidth,Xe=Math.max(0,oe-he/2);Me.scrollLeft=Xe}Se(X)};Se(X)},[G,Q,Se]),_e=N,Ne=g.useCallback(X=>{if(!ee.current)return;const fe=X??j.current;ee.current.play(void 0,fe),m(!0),O()},[O]),Be=g.useCallback(()=>{ee.current&&(ee.current.pause(),m(!1),_e(),_(ee.current.getCurrentTime()))},[_e]),ve=g.useCallback(()=>{ee.current&&(ee.current.stop(),m(!1),_e(),j.current=0,_(0),G(null))},[_e,G]),Ve=g.useCallback(X=>{const fe=Math.max(0,Math.min(X,w));j.current=fe,_(fe),ee.current&&ee.current.seekTo(fe)},[w]),ne=g.useCallback(X=>{const fe=Math.max(.5,Math.min(2,X));T(fe),ee.current&&ee.current.setPlaybackRate(fe)},[]),Ge=r?30:0,je=g.useMemo(()=>({isPlaying:y,currentTime:b,currentTimeRef:j}),[y,b]),xe=g.useMemo(()=>({continuousPlay:R,annotations:I,activeAnnotationId:$,playbackRate:E,isAutomaticScroll:z}),[R,I,$,E,z]),Fe=g.useRef(h);Fe.current=h;const Oe=g.useCallback(X=>{const fe=typeof X=="function"?X(M.current):X;if(!Fe.current){process.env.NODE_ENV!=="production"&&console.warn("waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to MediaElementPlaylistProvider to handle annotation updates.");return}Fe.current(fe)},[]),Et=g.useMemo(()=>({play:Ne,pause:Be,stop:ve,seekTo:Ve,setPlaybackRate:ne,setContinuousPlay:ye,setAnnotations:Oe,setActiveAnnotationId:G,setAutomaticScroll:X=>{J(X)},setScrollContainer:Z,scrollContainerRef:ie}),[Ne,Be,ve,Ve,ne,ye,Oe,G,Z]),It=g.useMemo(()=>({duration:w,peaksDataArray:S,sampleRate:Q,waveHeight:n,timeScaleHeight:Ge,samplesPerPixel:q,playoutRef:ee,controls:i,barWidth:c,barGap:u,progressBarWidth:v}),[w,S,Q,n,Ge,q,i,c,u,v]),Mt={...kd,...a};return C.jsx(P.ThemeProvider,{theme:Mt,children:C.jsx(Kd.Provider,{value:je,children:C.jsx(qd.Provider,{value:xe,children:C.jsx(Jd.Provider,{value:Et,children:C.jsx(Qd.Provider,{value:It,children:p})})})})})},Us=()=>{const e=g.useContext(Kd);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},Xs=()=>{const e=g.useContext(qd);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},bi=()=>{const e=g.useContext(Jd);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},Ys=()=>{const e=g.useContext(Qd);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},B0=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=lt(),{selectionStart:r,selectionEnd:s,isLoopEnabled:o}=ct(),{play:a}=Pe(),i=async()=>{if(r!==s&&s>r&&!o){const c=s-r;await a(r,c)}else await a(n.current??0)};return C.jsx(kt,{onClick:i,disabled:t,className:e,children:"Play"})},V0=({className:e})=>{const{isPlaying:t}=lt(),{pause:n}=Pe();return C.jsx(kt,{onClick:n,disabled:!t,className:e,children:"Pause"})},N0=({className:e})=>{const{isPlaying:t}=lt(),{stop:n}=Pe();return C.jsx(kt,{onClick:n,disabled:!t,className:e,children:"Stop"})},z0=({className:e})=>{const{isPlaying:t}=lt(),{play:n,setCurrentTime:r}=Pe(),s=()=>{r(0),t&&n(0)};return C.jsx(kt,{onClick:s,className:e,children:"Rewind"})},j0=({className:e})=>{const{isPlaying:t}=lt(),{play:n,setCurrentTime:r}=Pe(),{duration:s}=vt(),o=()=>{r(s),t&&n(s)};return C.jsx(kt,{onClick:o,className:e,children:"Fast Forward"})},Z0=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=lt(),{play:s,setCurrentTime:o}=Pe(),a=()=>{const i=Math.max(0,(n.current??0)-e);o(i),r&&s(i)};return C.jsx(kt,{onClick:a,className:t,children:"Skip Backward"})},H0=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=lt(),{play:s,setCurrentTime:o}=Pe(),{duration:a}=vt(),i=()=>{const l=Math.min(a,(n.current??0)+e);o(l),r&&s(l)};return C.jsx(kt,{onClick:i,className:t,children:"Skip Forward"})},G0=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=ct(),{setLoopEnabled:s,setLoopRegion:o}=Pe(),{duration:a}=vt(),i=n!==r&&r>n,l=()=>{if(!t&&!i){const c=Math.min(10,a*.25);o(0,Math.max(1,c))}s(!t)};return C.jsx(kt,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},U0=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=ct(),{setLoopRegionFromSelection:o,clearLoopRegion:a}=Pe(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?a():o()};return C.jsx(kt,{onClick:c,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"})},X0=({className:e,disabled:t})=>{const{zoomIn:n}=Pe(),{canZoomIn:r}=vt();return C.jsx(kt,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},Y0=({className:e,disabled:t})=>{const{zoomOut:n}=Pe(),{canZoomOut:r}=vt();return C.jsx(kt,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},K0=({className:e})=>{const{masterVolume:t}=vt(),{setMasterVolume:n}=Pe();return C.jsx(Og,{volume:t,onChange:n,className:e})},q0=({className:e})=>{const{timeFormat:t}=vt(),{setTimeFormat:n}=Pe();return C.jsx(Cv,{value:t,onChange:n,className:e})},J0=P.span`
|
|
1011
1010
|
font-family: 'Courier New', Monaco, monospace;
|
|
1012
1011
|
font-size: 1rem;
|
|
1013
1012
|
font-weight: 600;
|
|
1014
1013
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
1015
1014
|
user-select: none;
|
|
1016
|
-
`,
|
|
1015
|
+
`,Q0=({className:e})=>{const t=g.useRef(null),n=g.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:o}=lt(),{timeFormat:a}=vt();return g.useEffect(()=>{const i=()=>{if(t.current){const l=r?o():s.current??0;t.current.textContent=Ln(l,a)}r&&(n.current=requestAnimationFrame(i))};return r?n.current=requestAnimationFrame(i):i(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,a,s,o]),g.useEffect(()=>{!r&&t.current&&(t.current.textContent=Ln(s.current??0,a))}),C.jsx(J0,{ref:t,className:e,"aria-label":"Audio position",children:Ln(s.current??0,a)})},ey=({className:e})=>{const{selectionStart:t,selectionEnd:n}=ct(),{setSelection:r}=Pe();return C.jsx(Qg,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},ty=({className:e})=>{const{isAutomaticScroll:t}=ct(),{setAutomaticScroll:n}=Pe();return C.jsx(ug,{checked:t,onChange:n,className:e})},Ks=g.createContext(null),ny=Ks.Provider;function Sn(){const e=g.useContext(Ks);if(!e)throw new Error("useAnnotationIntegration must be used within <AnnotationProvider>. Install @waveform-playlist/annotations and wrap your app with <AnnotationProvider>. See: https://waveform-playlist.naomiaro.com/docs/guides/annotations");return e}const ry=({className:e})=>{const{ContinuousPlayCheckbox:t}=Sn(),{continuousPlay:n}=ct(),{setContinuousPlay:r}=Pe();return C.jsx(t,{checked:n,onChange:r,className:e})},sy=({className:e})=>{const{LinkEndpointsCheckbox:t}=Sn(),{linkEndpoints:n}=ct(),{setLinkEndpoints:r}=Pe();return C.jsx(t,{checked:n,onChange:r,className:e})},oy=({className:e})=>{const{EditableCheckbox:t}=Sn(),{annotationsEditable:n}=ct(),{setAnnotationsEditable:r}=Pe();return C.jsx(t,{checked:n,onChange:r,className:e})},ay=({filename:e,className:t})=>{const{DownloadAnnotationsButton:n}=Sn(),{annotations:r}=ct();return C.jsx(n,{annotations:r,filename:e,className:t})},iy=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:r,bitDepth:s=16,applyEffects:o=!0,effectsFunction:a,createOfflineTrackEffects:i,className:l,onExportComplete:c,onExportError:u})=>{const{tracks:f,trackStates:h}=vt(),{exportWav:d,isExporting:p,progress:v}=Zd(),y=async()=>{try{const b=await d(f,h,{filename:t,mode:n,trackIndex:r,bitDepth:s,applyEffects:o,effectsFunction:a,createOfflineTrackEffects:i,autoDownload:!0});c?.(b.blob)}catch(b){u?.(b instanceof Error?b:new Error("Export failed"))}},m=p?`Exporting ${Math.round(v*100)}%`:e;return C.jsx(kt,{onClick:y,disabled:p||f.length===0,className:l,children:m})},ly=P.div.attrs(e=>({style:{width:`${e.$width}px`,background:e.$color}}))`
|
|
1017
1016
|
position: absolute;
|
|
1018
1017
|
top: 0;
|
|
1019
1018
|
left: 0;
|
|
@@ -1021,17 +1020,16 @@ self.onmessage = function(e) {
|
|
|
1021
1020
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
1022
1021
|
pointer-events: none;
|
|
1023
1022
|
will-change: transform;
|
|
1024
|
-
`,
|
|
1023
|
+
`,cy=({color:e="#ff0000"})=>{const t=g.useRef(null),n=g.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:o}=lt(),{samplesPerPixel:a,sampleRate:i,progressBarWidth:l}=vt();return g.useEffect(()=>{const c=()=>{if(t.current){const f=(r?o():s.current??0)*i/a;t.current.style.transform=`translate3d(${f}px, 0, 0)`}r&&(n.current=requestAnimationFrame(c))};return r?n.current=requestAnimationFrame(c):c(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,i,a,s,o]),g.useEffect(()=>{if(!r&&t.current){const u=(s.current??0)*i/a;t.current.style.transform=`translate3d(${u}px, 0, 0)`}}),C.jsx(ly,{ref:t,$color:e,$width:l,"data-playhead":!0})},uy=P.div`
|
|
1025
1024
|
position: relative;
|
|
1026
|
-
`,
|
|
1025
|
+
`,wo=P.div.attrs(e=>({style:{top:`${e.$top}px`,width:`${e.$width}px`,height:`${e.$height}px`,background:e.$color}}))`
|
|
1027
1026
|
position: absolute;
|
|
1028
1027
|
left: 0;
|
|
1029
1028
|
z-index: 0;
|
|
1030
1029
|
/* Force GPU compositing layer to prevent gradient flickering during scroll */
|
|
1031
1030
|
transform: translateZ(0);
|
|
1032
1031
|
backface-visibility: hidden;
|
|
1033
|
-
|
|
1034
|
-
`,Uv=R.div.attrs(e=>({style:{top:`${e.$top}px`,height:`${e.$height}px`,width:`${e.$width}px`,background:e.$color,transform:"scaleX(0)"}}))`
|
|
1032
|
+
`,dy=P.div.attrs(e=>({style:{top:`${e.$top}px`,height:`${e.$height}px`,width:`${e.$width}px`,background:e.$color,transform:"scaleX(0)"}}))`
|
|
1035
1033
|
position: absolute;
|
|
1036
1034
|
left: 0;
|
|
1037
1035
|
pointer-events: none;
|
|
@@ -1039,10 +1037,16 @@ self.onmessage = function(e) {
|
|
|
1039
1037
|
transform-origin: left;
|
|
1040
1038
|
/* scaleX changes are composite-only (GPU) — no layout reflow per frame */
|
|
1041
1039
|
will-change: transform;
|
|
1042
|
-
`,
|
|
1040
|
+
`,fy=P.div`
|
|
1043
1041
|
position: relative;
|
|
1044
1042
|
z-index: 2;
|
|
1045
|
-
`,Wl=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=f.useRef(null),s=f.useRef(null),a=Vr(),{waveHeight:o}=zs(),{isPlaying:i,currentTimeRef:l,getPlaybackTime:c}=ct(),{samplesPerPixel:u,sampleRate:d}=vt(),p=a?.waveProgressColor||"rgba(0, 0, 0, 0.1)";f.useEffect(()=>{const S=()=>{if(r.current){const E=(i?c():l.current??0)*d,I=e+t;let A=0;E<=e?A=0:E>=I?A=1:A=(E-e)/t,r.current.style.transform=`scaleX(${A})`}i&&(s.current=requestAnimationFrame(S))};return i?s.current=requestAnimationFrame(S):S(),()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i,d,u,e,t,n.length,l,c]),f.useEffect(()=>{if(!i&&r.current){const k=(l.current??0)*d,E=e+t;let I=0;k<=e?I=0:k>=E?I=1:I=(k-e)/t,r.current.style.transform=`scaleX(${I})`}});const h=a?.waveformDrawMode||"inverted";let g;h==="inverted"?g=n.isSelected&&a?a.selectedWaveFillColor:a?.waveFillColor||"white":g=n.isSelected&&a?a.selectedWaveOutlineColor:a?.waveOutlineColor||"grey";const b=n.renderMode==="spectrogram"||n.renderMode==="both",y=n.renderMode==="both",m=b?"#000":qt(g),w=Math.floor(o/2),_=o,v=n.index*o,x=qt(g);return C.jsxs(Yv,{children:[y?C.jsxs(C.Fragment,{children:[C.jsx(fa,{$color:"#000",$height:w,$top:v,$width:n.length}),C.jsx(fa,{$color:x,$height:w,$top:v+w,$width:n.length})]}):C.jsx(fa,{$color:m,$height:_,$top:v,$width:n.length}),C.jsx(Uv,{ref:r,$color:p,$height:_,$top:v,$width:n.length}),C.jsx(Kv,{children:C.jsx(Sd,{...n,transparentBackground:!0})})]})},pi=f.createContext(null),qv=pi.Provider;function Jv(){const e=f.useContext(pi);if(!e)throw new Error("useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>.");return e}const Qv=60,Nd=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:s,className:a,showClipHeaders:o=!1,interactiveClips:i=!1,showFades:l=!1,touchOptimized:c=!1,onRemoveTrack:u,recordingState:d})=>{const p=Vr(),{isPlaying:h,currentTimeRef:g,playbackStartTimeRef:b,audioStartPositionRef:y,getPlaybackTime:m}=ct(),{selectionStart:w,selectionEnd:_,annotations:v,activeAnnotationId:x,annotationsEditable:S,linkEndpoints:k,continuousPlay:E,selectedTrackId:I,loopStart:A,loopEnd:T,isLoopEnabled:P}=ut(),M=f.useContext(Xs),{setAnnotations:F,setActiveAnnotationId:O,setTrackMute:H,setTrackSolo:K,setTrackVolume:ne,setTrackPan:B,setSelection:re,play:se,setScrollContainer:ae,setSelectedTrackId:ie,setCurrentTime:me,setLoopRegion:ye}=Te(),{peaksDataArray:De,trackStates:X,tracks:Z,duration:de,samplesPerPixel:G,sampleRate:$,waveHeight:he,timeScaleHeight:We,controls:q,barWidth:ge,barGap:Ve,isReady:Ne}=vt(),U=f.useContext(pi),Re=f.useMemo(()=>{if(!U)return new Map;const V=new Map;return Z.forEach(Y=>{if((U.trackSpectrogramOverrides.get(Y.id)?.renderMode??Y.renderMode??"waveform")==="waveform")return;const Ce=U.trackSpectrogramOverrides.get(Y.id),ve=Ce?.colorMap??Y.spectrogramColorMap??U.spectrogramColorMap??"viridis",Qe=Ce?.config??Y.spectrogramConfig??U.spectrogramConfig;V.set(Y.id,{colorLUT:U.getColorMap(ve),frequencyScaleFn:U.getFrequencyScale(Qe?.frequencyScale??"mel"),config:Qe})}),V},[Z,U]),ze=f.useMemo(()=>{if(U?.spectrogramWorkerApi)return{registerCanvas:U.spectrogramWorkerApi.registerCanvas.bind(U.spectrogramWorkerApi),unregisterCanvas:U.spectrogramWorkerApi.unregisterCanvas.bind(U.spectrogramWorkerApi)}},[U?.spectrogramWorkerApi]),[xe,Xe]=f.useState(null),[Ue,at]=f.useState(!1),yt=f.useRef(null),At=f.useCallback(V=>{yt.current=V,ae(V)},[ae]),N=Z.reduce((V,Y)=>Y.clips.reduce((Q,Ce)=>{const ve=(Ce.startSample+Ce.durationSamples)/Ce.sampleRate;return Math.max(Q,ve)},V),0);let le=N>0?N:de>0?de:Qv;if(d?.isRecording){const Y=(d.startSample+d.durationSamples)/$;le=Math.max(le,Y+10)}const Fe=Math.floor(le*$/G),Ke=async V=>{O(V.id);const Y=E?void 0:V.end-V.start;try{await se(V.start,Y)}catch(Q){console.error("waveform-playlist: Failed to start playback for annotation",V.id,Q)}},ee=f.useCallback(V=>{if(V>=0&&V<Z.length){const Y=Z[V];ie(Y.id)}},[Z,ie]),be=V=>{const Y=V.currentTarget.getBoundingClientRect(),Q=q.show?q.width:0,ve=(V.clientX-Y.left-Q)*G/$,dt=V.clientY-Y.top;let oe=0,Ze=-1;for(let et=0;et<De.length;et++){const en=De[et],Pt=en.length>0?Math.max(1,...en.map(Mt=>Mt.peaks.data.length)):1,nn=((U?.trackSpectrogramOverrides.get(Z[et]?.id)?.renderMode??Z[et]?.renderMode??"waveform")==="both"?Pt*2:Pt)*he+(o?22:0);if(dt>=oe&&dt<oe+nn){Ze=et;break}oe+=nn}Ze!==-1&&ee(Ze),at(!0),me(ve),re(ve,ve)},Ee=V=>{if(!Ue)return;const Y=V.currentTarget.getBoundingClientRect(),Q=q.show?q.width:0,ve=(V.clientX-Y.left-Q)*G/$,Qe=Math.min(w,ve),dt=Math.max(w,ve);re(Qe,dt)},je=V=>{if(!Ue)return;at(!1);const Y=V.currentTarget.getBoundingClientRect(),Q=q.show?q.width:0,ve=(V.clientX-Y.left-Q)*G/$,Qe=Math.min(w,ve),dt=Math.max(w,ve);Math.abs(dt-Qe)<.1?(me(Qe),h&&se(Qe)):re(Qe,dt)};return Z.some(V=>V.clips.length>0)&&De.length===0?C.jsx("div",{className:a,children:"Loading waveform..."}):C.jsxs(kd,{children:[C.jsx(Lr.Provider,{value:{samplesPerPixel:G,sampleRate:$,zoomLevels:[G],waveHeight:he,timeScaleHeight:We,duration:le*1e3,controls:q,barWidth:ge,barGap:Ve},children:C.jsx(li,{theme:p,backgroundColor:qt(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,scrollContainerWidth:Fe+(q.show?q.width:0),timescaleWidth:Fe,tracksWidth:Fe,controlsWidth:q.show?q.width:0,onTracksMouseDown:be,onTracksMouseMove:Ee,onTracksMouseUp:je,scrollContainerRef:At,isSelecting:Ue,"data-playlist-state":Ne?"ready":"loading",timescale:We>0?C.jsxs(C.Fragment,{children:[C.jsx(Ed,{renderTimestamp:t}),P&&C.jsx(Pg,{startPosition:Math.min(A,T)*$/G,endPosition:Math.max(A,T)*$/G,markerColor:p.loopMarkerColor,regionColor:p.loopRegionColor,minPosition:0,maxPosition:Fe,controlsOffset:q.show?q.width:0,onLoopRegionChange:(V,Y)=>{const Q=V*G/$,Ce=Y*G/$;ye(Q,Ce)}})]}):void 0,children:C.jsxs(C.Fragment,{children:[De.map((V,Y)=>{const Q=Z[Y];if(!Q)return null;const Ce=X[Y]||{name:`Track ${Y+1}`,muted:!1,soloed:!1,volume:1,pan:0},ve=U?.trackSpectrogramOverrides.get(Q.id)?.renderMode??Q.renderMode??"waveform",Qe=e?e(Y):C.jsxs(h0,{onClick:()=>ee(Y),children:[C.jsxs(p0,{style:{justifyContent:"center",position:"relative"},children:[u&&C.jsx(f0,{onClick:oe=>{oe.stopPropagation(),u(Y)}}),C.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:Ce.name||`Track ${Y+1}`}),U?.renderMenuItems&&C.jsx("span",{style:{position:"absolute",right:0,top:0},children:C.jsx(x0,{items:oe=>U.renderMenuItems({renderMode:ve,onRenderModeChange:Ze=>U.setTrackRenderMode(Q.id,Ze),onOpenSettings:()=>Xe(Q.id),onClose:oe})})})]}),C.jsxs(u0,{children:[C.jsx(Ml,{$variant:Ce.muted?"danger":"outline",onClick:()=>H(Y,!Ce.muted),children:"Mute"}),C.jsx(Ml,{$variant:Ce.soloed?"info":"outline",onClick:()=>K(Y,!Ce.soloed),children:"Solo"})]}),C.jsxs(Tl,{children:[C.jsx(m0,{}),C.jsx($l,{min:"0",max:"1",step:"0.01",value:Ce.volume,onChange:oe=>ne(Y,parseFloat(oe.target.value))}),C.jsx(g0,{})]}),C.jsxs(Tl,{children:[C.jsx("span",{children:"L"}),C.jsx($l,{min:"-1",max:"1",step:"0.01",value:Ce.pan,onChange:oe=>B(Y,parseFloat(oe.target.value))}),C.jsx("span",{children:"R"})]})]}),dt=V.length>0?Math.max(1,...V.map(oe=>oe.peaks.data.length)):1;return C.jsx(ui.Provider,{value:Qe,children:C.jsxs(Id,{numChannels:dt,backgroundColor:qt(p.waveOutlineColor),offset:0,width:Fe,hasClipHeaders:o,trackId:Q.id,isSelected:Q.id===I,children:[ve!=="waveform"&&(()=>{const oe=Re.get(Q.id),Ze=oe?.config;return!Ze?.labels||!oe?null:C.jsx(Ug,{waveHeight:he,numChannels:dt,frequencyScaleFn:oe.frequencyScaleFn,minFrequency:Ze.minFrequency??0,maxFrequency:Ze.maxFrequency??$/2,labelsColor:Ze.labelsColor,labelsBackground:Ze.labelsBackground,renderMode:ve,hasClipHeaders:o})})(),V.map((oe,Ze)=>{const et=oe.peaks,en=et.length;return C.jsx(qa,{clipId:oe.clipId,trackIndex:Y,clipIndex:Ze,trackName:oe.trackName,startSample:oe.startSample,durationSamples:oe.durationSamples,samplesPerPixel:G,showHeader:o,disableHeaderDrag:!i,isSelected:Q.id===I,trackId:Q.id,fadeIn:oe.fadeIn,fadeOut:oe.fadeOut,sampleRate:$,showFades:l,touchOptimized:c,onMouseDown:Pt=>{Pt.target.closest('[role="button"][aria-roledescription="draggable"]')||ee(Y)},children:et.data.map((Pt,Wt)=>{const tn=U?.spectrogramDataMap.get(oe.clipId),nn=tn?.[Wt]??tn?.[0],Mt=Re.get(Q.id),Kn=Mt?.config;return C.jsx(Wl,{index:Wt,data:Pt,bits:et.bits,length:en,isSelected:Q.id===I,clipStartSample:oe.startSample,clipDurationSamples:oe.durationSamples,renderMode:ve,spectrogramData:nn,samplesPerPixel:G,spectrogramColorLUT:Mt?.colorLUT,spectrogramFrequencyScaleFn:Mt?.frequencyScaleFn,spectrogramMinFrequency:Kn?.minFrequency,spectrogramMaxFrequency:Kn?.maxFrequency,spectrogramWorkerApi:ze,spectrogramClipId:oe.clipId,spectrogramOnCanvasesReady:U?(Zr,Hr)=>{U.registerSpectrogramCanvases(oe.clipId,Wt,Zr,Hr)}:void 0},`${oe.clipId}-${Wt}`)})},oe.clipId)}),d?.isRecording&&d.trackId===Q.id&&d.peaks.length>0&&C.jsx(qa,{clipId:"recording-preview",trackIndex:Y,clipIndex:V.length,trackName:"Recording...",startSample:d.startSample,durationSamples:d.durationSamples,samplesPerPixel:G,showHeader:o,disableHeaderDrag:!0,isSelected:Q.id===I,trackId:Q.id,children:C.jsx(Wl,{index:0,data:d.peaks,bits:16,length:Math.floor(d.peaks.length/2),isSelected:Q.id===I,clipStartSample:d.startSample,clipDurationSamples:d.durationSamples},`${Q.id}-recording-0`)},`${Q.id}-recording`)]})},Q.id)}),v.length>0&&M&&C.jsx(M.AnnotationBoxesWrapper,{height:30,width:Fe,children:v.map((V,Y)=>{const Q=V.start*$/G,Ce=V.end*$/G,ve=s?s(V,Y):V.id;return C.jsx(M.AnnotationBox,{annotationId:V.id,annotationIndex:Y,startPosition:Q,endPosition:Ce,label:ve,color:"#ff9800",isActive:V.id===x,onClick:()=>Ke(V),editable:S},V.id)})}),w!==_&&C.jsx(_d,{startPosition:Math.min(w,_)*$/G+(q.show?q.width:0),endPosition:Math.max(w,_)*$/G+(q.show?q.width:0),color:p.selectionColor}),(h||w===_)&&(n?n({position:(g.current??0)*$/G+(q.show?q.width:0),color:p.playheadColor,isPlaying:h,currentTimeRef:g,playbackStartTimeRef:b,audioStartPositionRef:y,samplesPerPixel:G,sampleRate:$,controlsOffset:q.show?q.width:0,getAudioContextTime:()=>j.getContext().currentTime,getPlaybackTime:m}):C.jsx(Gv,{color:p.playheadColor,controlsOffset:q.show?q.width:0}))]})})}),U?.SettingsModal&&typeof document<"u"&&ro.createPortal(C.jsx(U.SettingsModal,{open:xe!==null,onClose:()=>Xe(null),config:xe!==null?U.trackSpectrogramOverrides.get(xe)?.config??Z.find(V=>V.id===xe)?.spectrogramConfig??U.spectrogramConfig??{}:{},colorMap:xe!==null?U.trackSpectrogramOverrides.get(xe)?.colorMap??Z.find(V=>V.id===xe)?.spectrogramColorMap??U.spectrogramColorMap??"viridis":"viridis",onApply:(V,Y)=>{xe!==null&&U.setTrackSpectrogramConfig(xe,V,Y)}}),document.body)]})},Xd=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,controls:r,annotationListConfig:s,scrollActivePosition:a="center",scrollActiveContainer:o="nearest"})=>{const{annotations:i,activeAnnotationId:l,annotationsEditable:c,linkEndpoints:u,continuousPlay:d}=ut(),p=xn(),{setAnnotations:h}=Te(),g=s??{linkEndpoints:u,continuousPlay:d},b=f.useCallback(m=>{h(m),n?.(m)},[h,n]),{AnnotationText:y}=p;return C.jsx(y,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:a,scrollActiveContainer:o,editable:c,controls:c?r:void 0,annotationListConfig:g,height:e,onAnnotationUpdate:b,renderAnnotationItem:t})},ey=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:s,annotationTextHeight:a,renderAnnotationItem:o,getAnnotationBoxLabel:i,scrollActivePosition:l="center",scrollActiveContainer:c="nearest",className:u,showClipHeaders:d=!1,interactiveClips:p=!1,showFades:h=!1,touchOptimized:g=!1,onRemoveTrack:b,recordingState:y})=>{const{annotations:m}=ut();return C.jsxs(C.Fragment,{children:[C.jsx(Nd,{renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:i,className:u,showClipHeaders:d,interactiveClips:p,showFades:h,touchOptimized:g,onRemoveTrack:b,recordingState:y}),m.length>0&&C.jsx(Xd,{height:a,renderAnnotationItem:o,controls:r,annotationListConfig:s,scrollActivePosition:l,scrollActiveContainer:c})]})};var ty=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Gd=ty?f.useLayoutEffect:f.useEffect;function An(e){const t=f.useRef(e);return Gd(()=>{t.current=e},[e]),t}function ha(e,t,n=f.useEffect,r=Object.is){const s=f.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}var Fl=Object.getOwnPropertySymbols,ny=Object.prototype.hasOwnProperty,ry=Object.prototype.propertyIsEnumerable,sy=(e,t)=>{var n={};for(var r in e)ny.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Fl)for(var r of Fl(e))t.indexOf(r)<0&&ry.call(e,r)&&(n[r]=e[r]);return n},ay=new Jo,oy=f.createContext(ay),iy=f.memo(f.forwardRef(({children:e},t)=>{const[n,r]=f.useState(0),s=f.useRef(null),a=f.useRef(null),o=f.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{a.current=l})),f.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Gd(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),f.useImperativeHandle(t,()=>o),null})),pa=[void 0,br];function ly(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:a,onDragMove:o,onDragOver:i,onDragEnd:l}=t,c=sy(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=f.useRef(null),{plugins:d,modifiers:p,sensors:h}=c,g=Bt(d,Wn.plugins),b=Bt(h,Wn.sensors),y=Bt(p,Wn.modifiers),m=An(s),w=An(a),_=An(i),v=An(o),x=An(l),S=An(r),k=cy(()=>{var E;return(E=c.manager)!=null?E:new Jo(c)});return f.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:E,trackRendering:I}=u.current,{monitor:A}=k;k.renderer=E;const T=[A.addEventListener("beforedragstart",P=>{const M=m.current;M&&I(()=>M(P,k))}),A.addEventListener("dragstart",P=>{var M;return(M=w.current)==null?void 0:M.call(w,P,k)}),A.addEventListener("dragover",P=>{const M=_.current;M&&I(()=>M(P,k))}),A.addEventListener("dragmove",P=>{const M=v.current;M&&I(()=>M(P,k))}),A.addEventListener("dragend",P=>{const M=x.current;M&&I(()=>M(P,k))}),A.addEventListener("collision",P=>{var M;return(M=S.current)==null?void 0:M.call(S,P,k)})];return()=>T.forEach(P=>P())},[k]),ha(g,()=>k&&(k.plugins=g),...pa),ha(b,()=>k&&(k.sensors=b),...pa),ha(y,()=>k&&(k.modifiers=y),...pa),C.jsxs(oy.Provider,{value:k,children:[C.jsx(iy,{ref:u,children:n}),n]})}function cy(e){const t=f.useRef(null);return t.current||(t.current=e()),f.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var uy=Object.create,Yd=Object.defineProperty,dy=Object.getOwnPropertyDescriptor,Ud=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Gs=e=>{throw TypeError(e)},fy=(e,t,n)=>t in e?Yd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hy=e=>{var t;return[,,,uy((t=e?.[Ud("metadata")])!=null?t:null)]},Kd=["class","method","getter","setter","accessor","field","value","get","set"],qd=e=>e!==void 0&&typeof e!="function"?Gs("Function expected"):e,py=(e,t,n,r,s)=>({kind:Kd[e],name:t,metadata:r,addInitializer:a=>n._?Gs("Already initialized"):s.push(qd(a||null))}),my=(e,t)=>fy(t,Ud("metadata"),e[3]),gy=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},Jd=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,d=!1,p=!1,h=2,g=Kd[u+5],b=e[h]||(e[h]=[]),y=(s=s.prototype,dy(s,n)),m=r.length-1;m>=0;m--)l=py(u,n,i={},e[3],b),l.static=d,l.private=p,c=l.access={has:w=>n in w},c.get=w=>w[n],o=(0,r[m])(y[g],l),i._=1,qd(o)&&(y[g]=o);return y&&Yd(s,n,y),s},Qd=(e,t,n)=>t.has(e)||Gs("Cannot "+n),vy=(e,t,n)=>(Qd(e,t,"read from private field"),t.get(e)),yy=(e,t,n)=>t.has(e)?Gs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),by=(e,t,n,r)=>(Qd(e,t,"write to private field"),t.set(e,n),n),tr=class Qa{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Qa(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Qa(t,n)}},ef,tf,eo,ps,jr,mi=class extends(eo=Jt,tf=[Ae],ef=[Ae],eo){constructor(e){const t=tr.from(e);super(t,(n,r)=>tr.equals(n,r)),gy(jr,5,this),yy(this,ps,0),this.velocity={x:0,y:0}}get delta(){return tr.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=tr.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),a=s-vy(this,ps),o=i=>Math.round(i/a*100);Kt(()=>{by(this,ps,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(tr.from(e)),this.velocity={x:0,y:0}}};jr=hy(eo);ps=new WeakMap;Jd(jr,2,"delta",tf,mi);Jd(jr,2,"direction",ef,mi);my(jr,mi);var nf=(e=>(e.Horizontal="x",e.Vertical="y",e))(nf||{});Object.values(nf);var wy=Object.defineProperty,_y=Object.defineProperties,xy=Object.getOwnPropertyDescriptors,Ol=Object.getOwnPropertySymbols,Cy=Object.prototype.hasOwnProperty,ky=Object.prototype.propertyIsEnumerable,Bl=(e,t,n)=>t in e?wy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rf=(e,t)=>{for(var n in t||(t={}))Cy.call(t,n)&&Bl(e,n,t[n]);if(Ol)for(var n of Ol(t))ky.call(t,n)&&Bl(e,n,t[n]);return e},sf=(e,t)=>_y(e,xy(t)),to=class extends _r{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return sf(rf({},t),{[n]:r})}};to.configure=Gn(to);var af=to;af.configure({axis:"x",value:0});var Sy=af.configure({axis:"y",value:0}),Ll=class extends _r{apply({transform:t}){var n;const{size:r=20}=(n=this.options)!=null?n:{},s=typeof r=="number"?r:r.x,a=typeof r=="number"?r:r.y;return sf(rf({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/a)*a})}};Ll.configure=Gn(Ll);const of=e=>{let t=!1;const n=e.map(r=>r===ja?(t=!0,ja.configure({dropAnimation:null})):r);return t||console.warn("[waveform-playlist] noDropAnimationPlugins: Feedback plugin not found in defaults — drop animation may not be disabled. Check @dnd-kit/dom version."),n},Ey=R.div`
|
|
1043
|
+
`,Hl=({clipStartSample:e,clipDurationSamples:t,midiNotes:n,clipSampleRate:r,clipOffsetSeconds:s,...o})=>{const a=g.useRef(null),i=g.useRef(null),l=zr(),{waveHeight:c}=Hs(),{isPlaying:u,currentTimeRef:f,getPlaybackTime:h}=lt(),{samplesPerPixel:d,sampleRate:p}=vt(),v=l?.waveProgressColor||"rgba(0, 0, 0, 0.1)";g.useEffect(()=>{const I=()=>{if(a.current){const $=(u?h():f.current??0)*p,A=e+t;let R=0;$<=e?R=0:$>=A?R=1:R=($-e)/t,a.current.style.transform=`scaleX(${R})`}u&&(i.current=requestAnimationFrame(I))};return u?i.current=requestAnimationFrame(I):I(),()=>{i.current&&(cancelAnimationFrame(i.current),i.current=null)}},[u,p,d,e,t,o.length,f,h]),g.useEffect(()=>{if(!u&&a.current){const M=(f.current??0)*p,$=e+t;let A=0;M<=e?A=0:M>=$?A=1:A=(M-e)/t,a.current.style.transform=`scaleX(${A})`}});const y=l?.waveformDrawMode||"inverted";let m;y==="inverted"?m=o.isSelected&&l?l.selectedWaveFillColor:l?.waveFillColor||"white":m=o.isSelected&&l?l.selectedWaveOutlineColor:l?.waveOutlineColor||"grey";const b=o.renderMode==="spectrogram"||o.renderMode==="both",_=o.renderMode==="piano-roll",w=o.renderMode==="both",x=b?"#000":_?l?.pianoRollBackgroundColor||"#1a1a2e":en(m),S=Math.floor(c/2),k=c,E=o.index*c,T=en(m);return C.jsxs(uy,{children:[w?C.jsxs(C.Fragment,{children:[C.jsx(wo,{$color:"#000",$height:S,$top:E,$width:o.length}),C.jsx(wo,{$color:T,$height:S,$top:E+S,$width:o.length})]}):C.jsx(wo,{$color:x,$height:k,$top:E,$width:o.length}),!_&&C.jsx(dy,{ref:a,$color:v,$height:k,$top:E,$width:o.length}),C.jsx(fy,{children:C.jsx(Pd,{...o,transparentBackground:!0,midiNotes:n,sampleRate:r,clipOffsetSeconds:s})})]})},wi=g.createContext(null),hy=wi.Provider;function py(){const e=g.useContext(wi);if(!e)throw new Error("useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>.");return e}const my=60,gy=P.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
|
|
1044
|
+
overflow: hidden;
|
|
1045
|
+
pointer-events: auto;
|
|
1046
|
+
background: ${e=>e.theme.surfaceColor};
|
|
1047
|
+
transition: background 0.15s ease-in-out;
|
|
1048
|
+
${e=>e.$isSelected&&`background: ${e.theme.selectedTrackControlsBackground};`}
|
|
1049
|
+
`,ef=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:s,className:o,showClipHeaders:a=!1,interactiveClips:i=!1,showFades:l=!1,touchOptimized:c=!1,onRemoveTrack:u,recordingState:f})=>{const h=zr(),{isPlaying:d,currentTimeRef:p,playbackStartTimeRef:v,audioStartPositionRef:y,getPlaybackTime:m}=lt(),{selectionStart:b,selectionEnd:_,annotations:w,activeAnnotationId:x,annotationsEditable:S,linkEndpoints:k,continuousPlay:E,selectedTrackId:T,loopStart:I,loopEnd:M,isLoopEnabled:$}=ct(),A=g.useContext(Ks),{setAnnotations:R,setActiveAnnotationId:W,setTrackMute:q,setTrackSolo:z,setTrackVolume:J,setTrackPan:ee,setSelection:j,play:se,setScrollContainer:U,setSelectedTrackId:ie,setCurrentTime:le,setLoopRegion:ge}=Pe(),{peaksDataArray:Se,trackStates:N,tracks:G,duration:ye,samplesPerPixel:Z,sampleRate:Q,waveHeight:O,timeScaleHeight:_e,controls:Ne,barWidth:Be,barGap:ve,isReady:Ve}=vt(),ne=g.useContext(wi),Ge=g.useMemo(()=>{if(!ne)return new Map;const V=new Map;return G.forEach(Y=>{if((ne.trackSpectrogramOverrides.get(Y.id)?.renderMode??Y.renderMode??"waveform")==="waveform")return;const ce=ne.trackSpectrogramOverrides.get(Y.id),Ae=ce?.colorMap??Y.spectrogramColorMap??ne.spectrogramColorMap??"viridis",Ze=ce?.config??Y.spectrogramConfig??ne.spectrogramConfig;V.set(Y.id,{colorLUT:ne.getColorMap(Ae),frequencyScaleFn:ne.getFrequencyScale(Ze?.frequencyScale??"mel"),config:Ze})}),V},[G,ne]),je=g.useMemo(()=>{if(ne?.spectrogramWorkerApi)return{registerCanvas:ne.spectrogramWorkerApi.registerCanvas.bind(ne.spectrogramWorkerApi),unregisterCanvas:ne.spectrogramWorkerApi.unregisterCanvas.bind(ne.spectrogramWorkerApi)}},[ne?.spectrogramWorkerApi]),[xe,Fe]=g.useState(null),[Oe,Et]=g.useState(!1),It=g.useRef(0),Mt=g.useRef(null),X=g.useCallback(V=>{Mt.current=V,U(V)},[U]),fe=G.reduce((V,Y)=>Y.clips.reduce((K,ce)=>{const Ae=(ce.startSample+ce.durationSamples)/ce.sampleRate;return Math.max(K,Ae)},V),0);let Ue=fe>0?fe:ye>0?ye:my;if(f?.isRecording){const Y=(f.startSample+f.durationSamples)/Q;Ue=Math.max(Ue,Y+10)}const Me=Math.floor(Ue*Q/Z),oe=async V=>{W(V.id);const Y=E?void 0:V.end-V.start;try{await se(V.start,Y)}catch(K){console.error("waveform-playlist: Failed to start playback for annotation",V.id,K)}},he=g.useCallback(V=>{if(V>=0&&V<G.length){const Y=G[V];ie(Y.id)}},[G,ie]),Xe=V=>{const Y=V.currentTarget.getBoundingClientRect(),ce=(V.clientX-Y.left)*Z/Q,Ze=V.clientY-Y.top;let te=0,Ke=-1;for(let Qe=0;Qe<Se.length;Qe++){const Te=Se[Qe],dt=Te.length>0?Math.max(1,...Te.map(Ht=>Ht.peaks.data.length)):1,sn=((ne?.trackSpectrogramOverrides.get(G[Qe]?.id)?.renderMode??G[Qe]?.renderMode??"waveform")==="both"?dt*2:dt)*O+(a?22:0);if(Ze>=te&&Ze<te+sn){Ke=Qe;break}te+=sn}Ke!==-1&&he(Ke),It.current=ce,Et(!0),le(ce),j(ce,ce)},At=V=>{if(!Oe||d)return;const Y=V.currentTarget.getBoundingClientRect(),ce=(V.clientX-Y.left)*Z/Q,Ae=Math.min(b,ce),Ze=Math.max(b,ce);j(Ae,Ze)},Tt=V=>{if(!Oe)return;if(Et(!1),d){const te=Math.max(0,It.current);le(te),j(te,te),se(te);return}const Y=V.currentTarget.getBoundingClientRect(),ce=(V.clientX-Y.left)*Z/Q,Ae=Math.min(b,ce),Ze=Math.max(b,ce);Math.abs(Ze-Ae)<.1?le(Ae):j(Ae,Ze)};if(G.some(V=>V.clips.length>0)&&Se.length===0)return C.jsx("div",{className:o,children:"Loading waveform..."});const yt=Ne.show?Se.map((V,Y)=>{const K=G[Y];if(!K)return null;const ce=N[Y]||{name:`Track ${Y+1}`,muted:!1,soloed:!1,volume:1,pan:0},Ae=K.clips.some(Te=>Te.midiNotes&&Te.midiNotes.length>0),Ze=ne?.trackSpectrogramOverrides.get(K.id)?.renderMode??K.renderMode??(Ae?"piano-roll":"waveform"),te=V.length>0?Math.max(1,...V.map(Te=>Te.peaks.data.length)):1,Ke=O*te+(a?pi:0),Qe=e?e(Y):C.jsxs(Av,{onClick:()=>he(Y),children:[C.jsxs(Tv,{style:{justifyContent:"center",position:"relative"},children:[u&&C.jsx(Mv,{onClick:Te=>{Te.stopPropagation(),u(Y)}}),C.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:ce.name||`Track ${Y+1}`}),ne?.renderMenuItems&&C.jsx("span",{style:{position:"absolute",right:0,top:0},children:C.jsx(Wv,{items:Te=>ne.renderMenuItems({renderMode:Ze,onRenderModeChange:dt=>ne.setTrackRenderMode(K.id,dt),onOpenSettings:()=>Fe(K.id),onClose:Te})})})]}),C.jsxs(Ev,{children:[C.jsx(Bl,{$variant:ce.muted?"danger":"outline",onClick:()=>q(Y,!ce.muted),children:"Mute"}),C.jsx(Bl,{$variant:ce.soloed?"info":"outline",onClick:()=>z(Y,!ce.soloed),children:"Solo"})]}),C.jsxs(Nl,{children:[C.jsx($v,{}),C.jsx(Vl,{min:"0",max:"1",step:"0.01",value:ce.volume,onChange:Te=>J(Y,parseFloat(Te.target.value))}),C.jsx(Rv,{})]}),C.jsxs(Nl,{children:[C.jsx("span",{children:"L"}),C.jsx(Vl,{min:"-1",max:"1",step:"0.01",value:ce.pan,onChange:Te=>ee(Y,parseFloat(Te.target.value))}),C.jsx("span",{children:"R"})]})]});return C.jsx(gy,{$height:Ke,$isSelected:K.id===T,children:Qe},K.id)}):void 0;return C.jsxs(Dd,{children:[C.jsx(Nr.Provider,{value:{samplesPerPixel:Z,sampleRate:Q,zoomLevels:[Z],waveHeight:O,timeScaleHeight:_e,duration:Ue*1e3,controls:Ne,barWidth:Be,barGap:ve},children:C.jsx(mi,{theme:h,backgroundColor:h.playlistBackgroundColor||en(h.waveOutlineColor),timescaleBackgroundColor:h.timescaleBackgroundColor,timescaleWidth:Me,tracksWidth:Me,controlsWidth:Ne.show?Ne.width:0,onTracksMouseDown:Xe,onTracksMouseMove:At,onTracksMouseUp:Tt,scrollContainerRef:X,isSelecting:Oe,"data-playlist-state":Ve?"ready":"loading",trackControlsSlots:yt,timescaleGapHeight:_e>0?_e+1:0,timescale:_e>0?C.jsxs(C.Fragment,{children:[C.jsx(Fd,{renderTimestamp:t}),$&&C.jsx(Jg,{startPosition:Math.min(I,M)*Q/Z,endPosition:Math.max(I,M)*Q/Z,markerColor:h.loopMarkerColor,regionColor:h.loopRegionColor,minPosition:0,maxPosition:Me,onLoopRegionChange:(V,Y)=>{const K=V*Z/Q,ce=Y*Z/Q;ge(K,ce)}})]}):void 0,children:C.jsxs(C.Fragment,{children:[Se.map((V,Y)=>{const K=G[Y];if(!K)return null;const ce=K.clips.some(te=>te.midiNotes&&te.midiNotes.length>0),Ae=ne?.trackSpectrogramOverrides.get(K.id)?.renderMode??K.renderMode??(ce?"piano-roll":"waveform"),Ze=V.length>0?Math.max(1,...V.map(te=>te.peaks.data.length)):1;return C.jsxs(Od,{numChannels:Ze,backgroundColor:Ae==="piano-roll"?h.pianoRollBackgroundColor||"#1a1a2e":en(h.waveOutlineColor),offset:0,width:Me,hasClipHeaders:a,trackId:K.id,isSelected:K.id===T,children:[Ae!=="waveform"&&(()=>{const te=Ge.get(K.id),Ke=te?.config;return!Ke?.labels||!te?null:C.jsx(fv,{waveHeight:O,numChannels:Ze,frequencyScaleFn:te.frequencyScaleFn,minFrequency:Ke.minFrequency??0,maxFrequency:Ke.maxFrequency??Q/2,labelsColor:Ke.labelsColor,labelsBackground:Ke.labelsBackground,renderMode:Ae,hasClipHeaders:a})})(),V.map((te,Ke)=>{const Qe=te.peaks,Te=Qe.length;return C.jsx(oa,{clipId:te.clipId,trackIndex:Y,clipIndex:Ke,trackName:te.trackName,startSample:te.startSample,durationSamples:te.durationSamples,samplesPerPixel:Z,showHeader:a,disableHeaderDrag:!i,isSelected:K.id===T,trackId:K.id,fadeIn:te.fadeIn,fadeOut:te.fadeOut,sampleRate:Q,showFades:l,touchOptimized:c,onMouseDown:dt=>{dt.target.closest('[role="button"][aria-roledescription="draggable"]')||he(Y)},children:Qe.data.map((dt,Lt)=>{const rn=ne?.spectrogramDataMap.get(te.clipId),sn=rn?.[Lt]??rn?.[0],Ht=Ge.get(K.id),qn=Ht?.config;return C.jsx(Hl,{index:Lt,data:dt,bits:Qe.bits,length:Te,isSelected:K.id===T,clipStartSample:te.startSample,clipDurationSamples:te.durationSamples,renderMode:te.midiNotes?"piano-roll":Ae,midiNotes:te.midiNotes,clipSampleRate:te.sampleRate,clipOffsetSeconds:te.offsetSamples!=null?te.offsetSamples/(te.sampleRate||Q):0,spectrogramData:sn,samplesPerPixel:Z,spectrogramColorLUT:Ht?.colorLUT,spectrogramFrequencyScaleFn:Ht?.frequencyScaleFn,spectrogramMinFrequency:qn?.minFrequency,spectrogramMaxFrequency:qn?.maxFrequency,spectrogramWorkerApi:je,spectrogramClipId:te.clipId,spectrogramOnCanvasesReady:ne?(kn,Hr)=>{ne.registerSpectrogramCanvases(te.clipId,Lt,kn,Hr)}:void 0},`${te.clipId}-${Lt}`)})},te.clipId)}),f?.isRecording&&f.trackId===K.id&&f.peaks.length>0&&C.jsx(oa,{clipId:"recording-preview",trackIndex:Y,clipIndex:V.length,trackName:"Recording...",startSample:f.startSample,durationSamples:f.durationSamples,samplesPerPixel:Z,showHeader:a,disableHeaderDrag:!0,isSelected:K.id===T,trackId:K.id,children:C.jsx(Hl,{index:0,data:f.peaks,bits:16,length:Math.floor(f.peaks.length/2),isSelected:K.id===T,clipStartSample:f.startSample,clipDurationSamples:f.durationSamples},`${K.id}-recording-0`)},`${K.id}-recording`)]},K.id)}),w.length>0&&A&&C.jsx(A.AnnotationBoxesWrapper,{height:30,width:Me,children:w.map((V,Y)=>{const K=V.start*Q/Z,ce=V.end*Q/Z,Ae=s?s(V,Y):V.id;return C.jsx(A.AnnotationBox,{annotationId:V.id,annotationIndex:Y,startPosition:K,endPosition:ce,label:Ae,color:"#ff9800",isActive:V.id===x,onClick:()=>oe(V),editable:S},V.id)})}),b!==_&&C.jsx(Td,{startPosition:Math.min(b,_)*Q/Z,endPosition:Math.max(b,_)*Q/Z,color:h.selectionColor}),(d||b===_)&&(n?n({position:(p.current??0)*Q/Z,color:h.playheadColor,isPlaying:d,currentTimeRef:p,playbackStartTimeRef:v,audioStartPositionRef:y,samplesPerPixel:Z,sampleRate:Q,controlsOffset:0,getAudioContextTime:()=>F.getContext().currentTime,getPlaybackTime:m}):C.jsx(cy,{color:h.playheadColor}))]})})}),ne?.SettingsModal&&typeof document<"u"&&da.createPortal(C.jsx(ne.SettingsModal,{open:xe!==null,onClose:()=>Fe(null),config:xe!==null?ne.trackSpectrogramOverrides.get(xe)?.config??G.find(V=>V.id===xe)?.spectrogramConfig??ne.spectrogramConfig??{}:{},colorMap:xe!==null?ne.trackSpectrogramOverrides.get(xe)?.colorMap??G.find(V=>V.id===xe)?.spectrogramColorMap??ne.spectrogramColorMap??"viridis":"viridis",onApply:(V,Y)=>{xe!==null&&ne.setTrackSpectrogramConfig(xe,V,Y)}}),document.body)]})},tf=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,controls:r,annotationListConfig:s,scrollActivePosition:o="center",scrollActiveContainer:a="nearest"})=>{const{annotations:i,activeAnnotationId:l,annotationsEditable:c,linkEndpoints:u,continuousPlay:f}=ct(),h=Sn(),{setAnnotations:d}=Pe(),p=s??{linkEndpoints:u,continuousPlay:f},v=g.useCallback(m=>{d(m),n?.(m)},[d,n]),{AnnotationText:y}=h;return C.jsx(y,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:o,scrollActiveContainer:a,editable:c,controls:c?r:void 0,annotationListConfig:p,height:e,onAnnotationUpdate:v,renderAnnotationItem:t})},vy=({renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,annotationListConfig:s,annotationTextHeight:o,renderAnnotationItem:a,getAnnotationBoxLabel:i,scrollActivePosition:l="center",scrollActiveContainer:c="nearest",className:u,showClipHeaders:f=!1,interactiveClips:h=!1,showFades:d=!1,touchOptimized:p=!1,onRemoveTrack:v,recordingState:y})=>{const{annotations:m}=ct();return C.jsxs(C.Fragment,{children:[C.jsx(ef,{renderTrackControls:e,renderTimestamp:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:i,className:u,showClipHeaders:f,interactiveClips:h,showFades:d,touchOptimized:p,onRemoveTrack:v,recordingState:y}),m.length>0&&C.jsx(tf,{height:o,renderAnnotationItem:a,controls:r,annotationListConfig:s,scrollActivePosition:l,scrollActiveContainer:c})]})};var yy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",nf=yy?g.useLayoutEffect:g.useEffect;function An(e){const t=g.useRef(e);return nf(()=>{t.current=e},[e]),t}function _o(e,t,n=g.useEffect,r=Object.is){const s=g.useRef(e);n(()=>{const o=s.current;r(e,o)||(s.current=e,t(e,o))},[t,e])}var Gl=Object.getOwnPropertySymbols,by=Object.prototype.hasOwnProperty,wy=Object.prototype.propertyIsEnumerable,_y=(e,t)=>{var n={};for(var r in e)by.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Gl)for(var r of Gl(e))t.indexOf(r)<0&&wy.call(e,r)&&(n[r]=e[r]);return n},xy=new oi,Cy=g.createContext(xy),Sy=g.memo(g.forwardRef(({children:e},t)=>{const[n,r]=g.useState(0),s=g.useRef(null),o=g.useRef(null),a=g.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{o.current=l})),g.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return nf(()=>{var i;(i=o.current)==null||i.call(o),s.current=null},[e,n]),g.useImperativeHandle(t,()=>a),null})),xo=[void 0,_r];function ky(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:o,onDragMove:a,onDragOver:i,onDragEnd:l}=t,c=_y(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=g.useRef(null),{plugins:f,modifiers:h,sensors:d}=c,p=Vt(f,On.plugins),v=Vt(d,On.sensors),y=Vt(h,On.modifiers),m=An(s),b=An(o),_=An(i),w=An(a),x=An(l),S=An(r),k=Ey(()=>{var E;return(E=c.manager)!=null?E:new oi(c)});return g.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:E,trackRendering:T}=u.current,{monitor:I}=k;k.renderer=E;const M=[I.addEventListener("beforedragstart",$=>{const A=m.current;A&&T(()=>A($,k))}),I.addEventListener("dragstart",$=>{var A;return(A=b.current)==null?void 0:A.call(b,$,k)}),I.addEventListener("dragover",$=>{const A=_.current;A&&T(()=>A($,k))}),I.addEventListener("dragmove",$=>{const A=w.current;A&&T(()=>A($,k))}),I.addEventListener("dragend",$=>{const A=x.current;A&&T(()=>A($,k))}),I.addEventListener("collision",$=>{var A;return(A=S.current)==null?void 0:A.call(S,$,k)})];return()=>M.forEach($=>$())},[k]),_o(p,()=>k&&(k.plugins=p),...xo),_o(v,()=>k&&(k.sensors=v),...xo),_o(y,()=>k&&(k.modifiers=y),...xo),C.jsxs(Cy.Provider,{value:k,children:[C.jsx(Sy,{ref:u,children:n}),n]})}function Ey(e){const t=g.useRef(null);return t.current||(t.current=e()),g.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var Iy=Object.create,rf=Object.defineProperty,My=Object.getOwnPropertyDescriptor,sf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),qs=e=>{throw TypeError(e)},Ay=(e,t,n)=>t in e?rf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ty=e=>{var t;return[,,,Iy((t=e?.[sf("metadata")])!=null?t:null)]},of=["class","method","getter","setter","accessor","field","value","get","set"],af=e=>e!==void 0&&typeof e!="function"?qs("Function expected"):e,$y=(e,t,n,r,s)=>({kind:of[e],name:t,metadata:r,addInitializer:o=>n._?qs("Already initialized"):s.push(af(o||null))}),Ry=(e,t)=>Ay(t,sf("metadata"),e[3]),Dy=(e,t,n,r)=>{for(var s=0,o=e[t>>1],a=o&&o.length;s<a;s++)o[s].call(n);return r},lf=(e,t,n,r,s,o)=>{for(var a,i,l,c,u=t&7,f=!1,h=!1,d=2,p=of[u+5],v=e[d]||(e[d]=[]),y=(s=s.prototype,My(s,n)),m=r.length-1;m>=0;m--)l=$y(u,n,i={},e[3],v),l.static=f,l.private=h,c=l.access={has:b=>n in b},c.get=b=>b[n],a=(0,r[m])(y[p],l),i._=1,af(a)&&(y[p]=a);return y&&rf(s,n,y),s},cf=(e,t,n)=>t.has(e)||qs("Cannot "+n),Py=(e,t,n)=>(cf(e,t,"read from private field"),t.get(e)),Fy=(e,t,n)=>t.has(e)?qs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Oy=(e,t,n,r)=>(cf(e,t,"write to private field"),t.set(e,n),n),nr=class ia{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ia(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new ia(t,n)}},uf,df,la,gs,Zr,_i=class extends(la=tn,df=[Ie],uf=[Ie],la){constructor(e){const t=nr.from(e);super(t,(n,r)=>nr.equals(n,r)),Dy(Zr,5,this),Fy(this,gs,0),this.velocity={x:0,y:0}}get delta(){return nr.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=nr.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),o=s-Py(this,gs),a=i=>Math.round(i/o*100);Qt(()=>{Oy(this,gs,s),this.velocity={x:a(r.x),y:a(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(nr.from(e)),this.velocity={x:0,y:0}}};Zr=Ty(la);gs=new WeakMap;lf(Zr,2,"delta",df,_i);lf(Zr,2,"direction",uf,_i);Ry(Zr,_i);var ff=(e=>(e.Horizontal="x",e.Vertical="y",e))(ff||{});Object.values(ff);var Ly=Object.defineProperty,Wy=Object.defineProperties,By=Object.getOwnPropertyDescriptors,Ul=Object.getOwnPropertySymbols,Vy=Object.prototype.hasOwnProperty,Ny=Object.prototype.propertyIsEnumerable,Xl=(e,t,n)=>t in e?Ly(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hf=(e,t)=>{for(var n in t||(t={}))Vy.call(t,n)&&Xl(e,n,t[n]);if(Ul)for(var n of Ul(t))Ny.call(t,n)&&Xl(e,n,t[n]);return e},pf=(e,t)=>Wy(e,By(t)),ca=class extends Cr{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return pf(hf({},t),{[n]:r})}};ca.configure=Xn(ca);var mf=ca;mf.configure({axis:"x",value:0});var zy=mf.configure({axis:"y",value:0}),Yl=class extends Cr{apply({transform:t}){var n;const{size:r=20}=(n=this.options)!=null?n:{},s=typeof r=="number"?r:r.x,o=typeof r=="number"?r:r.y;return pf(hf({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/o)*o})}};Yl.configure=Xn(Yl);const gf=e=>{let t=!1;const n=e.map(r=>r===Ko?(t=!0,Ko.configure({dropAnimation:null})):r);return t||console.warn("[waveform-playlist] noDropAnimationPlugins: Feedback plugin not found in defaults — drop animation may not be disabled. Check @dnd-kit/dom version."),n},jy=P.div`
|
|
1046
1050
|
position: absolute;
|
|
1047
1051
|
top: 0;
|
|
1048
1052
|
left: 0;
|
|
@@ -1052,9 +1056,9 @@ self.onmessage = function(e) {
|
|
|
1052
1056
|
z-index: 100;
|
|
1053
1057
|
pointer-events: none;
|
|
1054
1058
|
will-change: transform;
|
|
1055
|
-
`,
|
|
1059
|
+
`,Zy=({color:e="#ff0000"})=>{const t=g.useRef(null),n=g.useRef(null),{isPlaying:r,currentTimeRef:s}=Us(),{samplesPerPixel:o,sampleRate:a,progressBarWidth:i}=Ys();return g.useEffect(()=>{const l=()=>{if(t.current){const u=(s.current??0)*a/o;t.current.style.transform=`translate3d(${u}px, 0, 0)`}r&&(n.current=requestAnimationFrame(l))};return r?n.current=requestAnimationFrame(l):l(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,a,o,s]),g.useEffect(()=>{if(!r&&t.current){const c=(s.current??0)*a/o;t.current.style.transform=`translate3d(${c}px, 0, 0)`}}),C.jsx(jy,{ref:t,$color:e,$width:i,"data-playhead":!0})},Hy=P.div`
|
|
1056
1060
|
position: relative;
|
|
1057
|
-
`,
|
|
1061
|
+
`,Gy=P.div`
|
|
1058
1062
|
position: absolute;
|
|
1059
1063
|
top: ${e=>e.$top}px;
|
|
1060
1064
|
left: 0;
|
|
@@ -1064,8 +1068,7 @@ self.onmessage = function(e) {
|
|
|
1064
1068
|
z-index: 0;
|
|
1065
1069
|
transform: translateZ(0);
|
|
1066
1070
|
backface-visibility: hidden;
|
|
1067
|
-
|
|
1068
|
-
`,$y=R.div`
|
|
1071
|
+
`,Uy=P.div`
|
|
1069
1072
|
position: absolute;
|
|
1070
1073
|
top: ${e=>e.$top}px;
|
|
1071
1074
|
left: 0;
|
|
@@ -1074,8 +1077,8 @@ self.onmessage = function(e) {
|
|
|
1074
1077
|
pointer-events: none;
|
|
1075
1078
|
z-index: 1;
|
|
1076
1079
|
will-change: width;
|
|
1077
|
-
`,
|
|
1080
|
+
`,Xy=P.div`
|
|
1078
1081
|
position: relative;
|
|
1079
1082
|
z-index: 2;
|
|
1080
|
-
`,
|
|
1083
|
+
`,Yy=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=g.useRef(null),s=g.useRef(null),o=zr(),{waveHeight:a}=Hs(),{isPlaying:i,currentTimeRef:l}=Us(),{samplesPerPixel:c,sampleRate:u}=Ys(),f=o?.waveProgressColor||"rgba(0, 0, 0, 0.1)";g.useEffect(()=>{const v=()=>{if(r.current){const m=(l.current??0)*u,b=e+t;let _=0;if(m<=e)_=0;else if(m>=b)_=n.length;else{const w=m-e;_=Math.floor(w/c)}r.current.style.width=`${_}px`}i&&(s.current=requestAnimationFrame(v))};return i?s.current=requestAnimationFrame(v):v(),()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i,u,c,e,t,n.length,l]),g.useEffect(()=>{if(!i&&r.current){const y=(l.current??0)*u,m=e+t;let b=0;if(y<=e)b=0;else if(y>=m)b=n.length;else{const _=y-e;b=Math.floor(_/c)}r.current.style.width=`${b}px`}});const h=o?.waveformDrawMode||"inverted";let d;h==="inverted"?d=o?.selectedWaveFillColor||o?.waveFillColor||"white":d=o?.selectedWaveOutlineColor||o?.waveOutlineColor||"grey";const p=en(d);return C.jsxs(Hy,{children:[C.jsx(Gy,{$color:p,$height:a,$top:n.index*a,$width:n.length}),C.jsx(Uy,{ref:r,$color:f,$height:a,$top:n.index*a}),C.jsx(Xy,{children:C.jsx(Pd,{...n,isSelected:!0,transparentBackground:!0})})]})},vf=({getAnnotationBoxLabel:e,editable:t=!1,linkEndpoints:n=!1,onAnnotationUpdate:r,className:s})=>{const o=zr(),{isPlaying:a}=Us(),{annotations:i,activeAnnotationId:l}=Xs(),c=g.useContext(Ks),{play:u,seekTo:f,setActiveAnnotationId:h,setAnnotations:d,setScrollContainer:p}=bi(),{duration:v,peaksDataArray:y,sampleRate:m,waveHeight:b,timeScaleHeight:_,samplesPerPixel:w,controls:x,playoutRef:S,barWidth:k,barGap:E}=Ys(),[T,I]=g.useState(0),[M,$]=g.useState(0),[A,R]=g.useState(!1),W=g.useRef(null),q=g.useCallback(N=>{W.current=N,p(N)},[p]),z=Math.floor(v*m/w),J=g.useCallback(async N=>{h(N.id);try{await u(N.start)}catch(G){console.error("waveform-playlist: Failed to start playback for annotation",N.id,G)}},[h,u]),ee=g.useCallback(N=>{d(N),r?.(N)},[d,r]),{onDragStart:j,onDragMove:se,onDragEnd:U}=jd({annotations:i,onAnnotationsChange:ee,samplesPerPixel:w,sampleRate:m,duration:v,linkEndpoints:n}),ie=g.useRef(0),le=g.useCallback(N=>{const G=N.currentTarget.getBoundingClientRect(),Z=(N.clientX-G.left)*w/m;ie.current=Z,R(!0),I(Z),$(Z)},[w,m]),ge=g.useCallback(N=>{if(!A)return;const G=N.currentTarget.getBoundingClientRect(),Z=(N.clientX-G.left)*w/m;$(Z)},[A,w,m]),Se=g.useCallback(N=>{if(!A)return;if(R(!1),a&&S.current){const _e=Math.max(0,ie.current);f(_e),I(_e),$(_e),S.current.stop(),u(_e);return}const G=N.currentTarget.getBoundingClientRect(),Z=(N.clientX-G.left)*w/m,Q=Math.min(T,Z),O=Math.max(T,Z);Math.abs(O-Q)<.1?(f(Q),I(Q),$(Q)):(I(Q),$(O))},[A,T,w,m,f,a,S,u]);return y.length===0?C.jsx("div",{className:s,children:"Loading waveform..."}):C.jsx(Dd,{children:C.jsx(Nr.Provider,{value:{samplesPerPixel:w,sampleRate:m,zoomLevels:[w],waveHeight:b,timeScaleHeight:_,duration:v*1e3,controls:x,barWidth:k,barGap:E},children:C.jsx(mi,{theme:o,backgroundColor:en(o.waveOutlineColor),timescaleBackgroundColor:o.timescaleBackgroundColor,timescaleWidth:z,tracksWidth:z,controlsWidth:x.show?x.width:0,onTracksMouseDown:le,onTracksMouseMove:ge,onTracksMouseUp:Se,scrollContainerRef:q,isSelecting:A,timescale:_>0?C.jsx(Fd,{}):void 0,children:C.jsxs(C.Fragment,{children:[y.map((N,G)=>{const ye=N.length>0?Math.max(...N.map(Z=>Z.peaks.data.length)):1;return C.jsx(Od,{numChannels:ye,backgroundColor:en(o.waveOutlineColor),offset:0,width:z,hasClipHeaders:!1,trackId:`media-element-track-${G}`,isSelected:!0,children:N.map((Z,Q)=>{const O=Z.peaks,_e=O.length;return C.jsx(oa,{clipId:Z.clipId,trackIndex:G,clipIndex:Q,trackName:Z.trackName,startSample:Z.startSample,durationSamples:Z.durationSamples,samplesPerPixel:w,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${G}`,children:O.data.map((Ne,Be)=>C.jsx(Yy,{index:Be,data:Ne,bits:O.bits,length:_e,clipStartSample:Z.startSample,clipDurationSamples:Z.durationSamples},`${G}-${Q}-${Be}`))},`${G}-${Q}`)})},G)}),i.length>0&&c&&C.jsx(ky,{onDragStart:j,onDragMove:se,onDragEnd:U,modifiers:t?[zy]:[],plugins:gf,children:C.jsx(c.AnnotationBoxesWrapper,{height:30,width:z,children:i.map((N,G)=>{const ye=N.start*m/w,Z=N.end*m/w,Q=e?e(N,G):N.id;return C.jsx(c.AnnotationBox,{annotationId:N.id,annotationIndex:G,startPosition:ye,endPosition:Z,label:Q,color:"#ff9800",isActive:N.id===l,onClick:()=>J(N),editable:t},N.id)})})}),T!==M&&C.jsx(Td,{startPosition:Math.min(T,M)*m/w,endPosition:Math.max(T,M)*m/w,color:o.selectionColor}),C.jsx(Zy,{color:o.playheadColor})]})})})})},yf=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,editable:r=!1,controls:s,annotationListConfig:o,scrollActivePosition:a="center",scrollActiveContainer:i="nearest"})=>{const{annotations:l,activeAnnotationId:c,continuousPlay:u}=Xs(),f=Sn(),{setAnnotations:h}=bi(),d=o??{linkEndpoints:!1,continuousPlay:u},p=g.useCallback(y=>{h(y),n?.(y)},[h,n]),{AnnotationText:v}=f;return C.jsx(v,{annotations:l,activeAnnotationId:c??void 0,shouldScrollToActive:!0,scrollActivePosition:a,scrollActiveContainer:i,editable:r,controls:r?s:void 0,annotationListConfig:d,height:e,onAnnotationUpdate:p,renderAnnotationItem:t})},Ky=({annotationTextHeight:e,getAnnotationBoxLabel:t,renderAnnotationItem:n,editable:r=!1,linkEndpoints:s=!1,onAnnotationUpdate:o,scrollActivePosition:a="center",scrollActiveContainer:i="nearest",className:l})=>{const{annotations:c}=Xs();return C.jsxs(C.Fragment,{children:[C.jsx(vf,{getAnnotationBoxLabel:t,editable:r,linkEndpoints:s,onAnnotationUpdate:o,className:l}),c.length>0&&C.jsx(yf,{height:e,renderAnnotationItem:n,onAnnotationUpdate:o,editable:r,annotationListConfig:{linkEndpoints:s,continuousPlay:!1},scrollActivePosition:a,scrollActiveContainer:i})]})},Ps=class Ps extends Cr{apply(t){const{transform:n,source:r}=t;if(!r?.data||!this.options)return n;const{boundary:s,trackIndex:o,clipIndex:a}=r.data;if(s)return{x:0,y:0};const{tracks:i,samplesPerPixel:l}=this.options,c=i[o];if(!c)return n;const u=c.clips[a];if(!u)return n;const f=n.x*l,h=[...c.clips].sort((v,y)=>v.startSample-y.startSample),d=h.findIndex(v=>v.id===u.id);return{x:rc(u,f,h,d)/l,y:0}}};Ps.configure=Xn(Ps);let ua=Ps;exports.Tone=ql;exports.AnnotationIntegrationProvider=ny;exports.AudioPosition=Q0;exports.AutomaticScrollCheckbox=ty;exports.ClipCollisionModifier=ua;exports.ContinuousPlayCheckbox=ry;exports.DownloadAnnotationsButton=ay;exports.EditableCheckbox=oy;exports.ExportWavButton=iy;exports.FastForwardButton=j0;exports.LinkEndpointsCheckbox=sy;exports.LoopButton=G0;exports.MasterVolumeControl=K0;exports.MediaElementAnnotationList=yf;exports.MediaElementPlaylist=vf;exports.MediaElementPlaylistProvider=W0;exports.MediaElementWaveform=Ky;exports.PauseButton=V0;exports.PlayButton=B0;exports.PlaylistAnnotationList=tf;exports.PlaylistVisualization=ef;exports.RewindButton=z0;exports.SelectionTimeInputs=ey;exports.SetLoopRegionButton=U0;exports.SkipBackwardButton=Z0;exports.SkipForwardButton=H0;exports.SpectrogramIntegrationProvider=hy;exports.StopButton=N0;exports.TimeFormatSelect=q0;exports.Waveform=vy;exports.WaveformPlaylistProvider=F0;exports.ZoomInButton=X0;exports.ZoomOutButton=Y0;exports.createEffectChain=_0;exports.createEffectInstance=Tr;exports.effectCategories=v0;exports.effectDefinitions=jr;exports.getEffectDefinition=yi;exports.getEffectsByCategory=g0;exports.getShortcutLabel=h0;exports.getWaveformDataMetadata=n0;exports.loadPeaksFromWaveformData=t0;exports.loadWaveformData=vi;exports.noDropAnimationPlugins=gf;exports.useAnnotationDragHandlers=jd;exports.useAnnotationIntegration=Sn;exports.useAnnotationKeyboardControls=m0;exports.useAudioTracks=l0;exports.useClipDragHandlers=c0;exports.useClipSplitting=f0;exports.useDragSensors=d0;exports.useDynamicEffects=x0;exports.useDynamicTracks=P0;exports.useExportWav=Zd;exports.useKeyboardShortcuts=Ds;exports.useMasterAnalyser=i0;exports.useMasterVolume=zd;exports.useMediaElementAnimation=Us;exports.useMediaElementControls=bi;exports.useMediaElementData=Ys;exports.useMediaElementState=Xs;exports.usePlaybackAnimation=lt;exports.usePlaybackShortcuts=p0;exports.usePlaylistControls=Pe;exports.usePlaylistData=vt;exports.usePlaylistState=ct;exports.useSpectrogramIntegration=py;exports.useTimeFormat=Vd;exports.useTrackDynamicEffects=C0;exports.useZoomControls=Nd;exports.waveformDataToPeaks=Wd;
|
|
1081
1084
|
//# sourceMappingURL=index.js.map
|