@waveform-playlist/browser 9.5.0 → 9.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,33 +1,33 @@
1
- "use strict";var Kf=Object.create;var ol=Object.defineProperty;var qf=Object.getOwnPropertyDescriptor;var Jf=Object.getOwnPropertyNames;var Qf=Object.getPrototypeOf,eh=Object.prototype.hasOwnProperty;var th=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Jf(t))!eh.call(e,s)&&s!==n&&ol(e,s,{get:()=>t[s],enumerable:!(r=qf(t,s))||r.enumerable});return e};var nh=(e,t,n)=>(n=e!=null?Kf(Qf(e)):{},th(t||!e||!e.__esModule?ol(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("tone"),C=require("react/jsx-runtime"),p=require("react"),F=require("styled-components"),yo=require("react-dom");function lc(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 cc=lc(L),P=lc(p);var ua={exports:{}},il;function rh(){return il||(il=1,(function(e,t){(function(n,r){e.exports=r()})(window,(function(){return(function(n){var r={};function s(a){if(r[a])return r[a].exports;var o=r[a]={i:a,l:!1,exports:{}};return n[a].call(o.exports,o,o.exports,s),o.l=!0,o.exports}return s.m=n,s.c=r,s.d=function(a,o,i){s.o(a,o)||Object.defineProperty(a,o,{enumerable:!0,get:i})},s.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},s.t=function(a,o){if(1&o&&(a=s(a)),8&o||4&o&&typeof a=="object"&&a&&a.__esModule)return a;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:a}),2&o&&typeof a!="string")for(var l in a)s.d(i,l,(function(c){return a[c]}).bind(null,l));return i},s.n=function(a){var o=a&&a.__esModule?function(){return a.default}:function(){return a};return s.d(o,"a",o),o},s.o=function(a,o){return Object.prototype.hasOwnProperty.call(a,o)},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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=s("./src/chunks/index.ts");function l(h){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})(h)}function c(h,v){for(var g=0;g<v.length;g++){var y=v[g];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(h,y.key,y)}}function u(h){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)})(h)}function f(h,v){return(f=Object.setPrototypeOf||function(g,y){return g.__proto__=y,g})(h,v)}function m(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}var d=(function(h){function v(b){var _,w,x,S,k,E;return(function(M,T){if(!(M instanceof T))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"?m(w):x,S=m(m(_)),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(M){return new v(M)})),_}var g,y;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,h),g=v,(y=[{key:"getMetaData",value:function(){if(this.id!=="LIST")throw new a.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!==o.SF_VERSION_LENGTH)throw new a.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 a.ParseError("Missing required 'ifil' sub-chunk");if(!b.INAM)throw new a.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 a.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks[0];if(b.id!=="smpl")throw new a.ParseError("Invalid chunk signature","'smpl'","'".concat(b.id,"'"));return b.buffer}},{key:"getPresetData",value:function(){if(this.id!=="LIST")throw new a.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(g.prototype,y),v})(a.RIFFChunk)},"./src/chunks/generators.ts":function(n,r,s){s.r(r),s.d(r,"getGenerators",(function(){return f}));var a=s("./src/riff/index.ts"),o=s("./src/types/index.ts"),i=s("./src/constants.ts"),l=[o.GeneratorType.StartAddrsOffset,o.GeneratorType.EndAddrsOffset,o.GeneratorType.StartLoopAddrsOffset,o.GeneratorType.EndLoopAddrsOffset,o.GeneratorType.StartAddrsCoarseOffset,o.GeneratorType.EndAddrsCoarseOffset,o.GeneratorType.StartLoopAddrsCoarseOffset,o.GeneratorType.KeyNum,o.GeneratorType.Velocity,o.GeneratorType.EndLoopAddrsCoarseOffset,o.GeneratorType.SampleModes,o.GeneratorType.ExclusiveClass,o.GeneratorType.OverridingRootKey],c=[o.GeneratorType.Unused1,o.GeneratorType.Unused2,o.GeneratorType.Unused3,o.GeneratorType.Unused4,o.GeneratorType.Reserved1,o.GeneratorType.Reserved2,o.GeneratorType.Reserved3],u=[o.GeneratorType.KeyRange,o.GeneratorType.VelRange],f=function(m,d){if(m.id!==d)throw new a.ParseError("Unexpected chunk ID","'".concat(d,"'"),"'".concat(m.id,"'"));if(m.length%i.SF_GENERATOR_SIZE)throw new a.ParseError("Invalid size for the '".concat(d,"' sub-chunk"));return m.iterate((function(h){var v=h.getInt16();return o.GeneratorType[v]?d==="pgen"&&l.includes(v)||d==="igen"&&c.includes(v)?null:u.includes(v)?{id:v,range:{lo:h.getByte(),hi:h.getByte()}}:{id:v,value:h.getInt16BE()}:null}))}},"./src/chunks/index.ts":function(n,r,s){s.r(r);var a=s("./src/chunks/instruments/index.ts");s.d(r,"getInstrumentHeaders",(function(){return a.getInstrumentHeaders}));var o=s("./src/chunks/presets/index.ts");s.d(r,"getPresetHeaders",(function(){return o.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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="inst")throw new a.ParseError("Unexpected chunk ID","'inst'","'".concat(l.id,"'"));if(l.length%o.SF_INSTRUMENT_HEADER_SIZE)throw new a.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 a=s("./src/chunks/instruments/headers.ts");s.d(r,"getInstrumentHeaders",(function(){return a.getInstrumentHeaders}))},"./src/chunks/modulators.ts":function(n,r,s){s.r(r),s.d(r,"getModulators",(function(){return l}));var a=s("./src/riff/index.ts"),o=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 a.ParseError("Unexpected chunk ID","'".concat(u,"'"),"'".concat(c.id,"'"));if(c.length%o.SF_MODULATOR_SIZE)throw new a.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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="phdr")throw new a.ParseError("Invalid chunk ID","'phdr'","'".concat(l.id,"'"));if(l.length%o.SF_PRESET_HEADER_SIZE)throw new a.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 a=s("./src/chunks/presets/headers.ts");s.d(r,"getPresetHeaders",(function(){return a.getPresetHeaders}))},"./src/chunks/samples/headers.ts":function(n,r,s){s.r(r),s.d(r,"getSampleHeaders",(function(){return i}));var a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="shdr")throw new a.ParseError("Unexpected chunk ID","'shdr'","'".concat(l.id,"'"));if(l.length%o.SF_SAMPLE_HEADER_SIZE)throw new a.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 a=s("./src/chunks/samples/headers.ts");s.d(r,"getSampleHeaders",(function(){return a.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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=s("./src/types/index.ts"),l=function(d,h){if(d.id!==h)throw new a.ParseError("Unexpected chunk ID","'".concat(h,"'"),"'".concat(d.id,"'"));if(d.length%o.SF_BAG_SIZE)throw new a.ParseError("Invalid size for the '".concat(h,"' sub-chunk"));return d.iterate((function(v){return{generatorIndex:v.getInt16(),modulatorIndex:v.getInt16()}}))},c=function(d,h,v,g,y,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:h.length,M=[],T=void 0,$=k;$<E;$++){var A=u($,h,v),I=f($,h,g),R=I[i.GeneratorType.KeyRange]&&I[i.GeneratorType.KeyRange].range,D=I[b];if(D){var O=y[D.value];O&&M.push({keyRange:R,modulators:A,generators:I,reference:O})}else $-k==0&&(T={keyRange:R,modulators:A,generators:I})}_.push({header:x,globalZone:T,zones:M})}return _},u=function(d,h,v){var g=h[d],y=h[d+1],b=g.modulatorIndex,_=y?y.modulatorIndex:h.length;return m(b,_,v)},f=function(d,h,v){var g=h[d],y=h[d+1],b=g.generatorIndex,_=y?y.generatorIndex:h.length;return m(b,_,v)},m=function(d,h,v){for(var g={},y=d;y<h;y++){var b=v[y];b&&(g[b.id]=b)}return g}},"./src/constants.ts":function(n,r,s){s.r(r),s.d(r,"SF_VERSION_LENGTH",(function(){return a})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return o})),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 m}));var a=4,o=38,i=4,l=10,c=4,u=22,f=46,m=22050},"./src/index.ts":function(n,r,s){s.r(r);var a=s("./src/types/index.ts");for(var o in a)["default"].indexOf(o)<0&&(function(u){s.d(r,u,(function(){return a[u]}))})(o);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 a=s("./src/utils/index.ts");function o(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function i(u,f){for(var m=0;m<f.length;m++){var d=f[m];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,m){return f in u?Object.defineProperty(u,f,{value:m,enumerable:!0,configurable:!0,writable:!0}):u[f]=m,u}var c=(function(){function u(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;o(this,u),l(this,"target",[]),l(this,"chunk",void 0),l(this,"position",0),this.chunk=d,this.position=h}var f,m;return f=u,(m=[{key:"iterate",value:function(d){for(;this.position<this.chunk.length;){var h=d(this);h&&this.target.push(h)}}},{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,h=Object(a.getStringFromBuffer)(this.getBuffer(this.position,d));return this.position+=d,h}},{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,h){return this.chunk.buffer.subarray(d,d+h)}},{key:"currentPosition",get:function(){return this.position}}])&&i(f.prototype,m),u})()},"./src/riff/index.ts":function(n,r,s){s.r(r);var a=s("./src/riff/chunkIterator.ts");s.d(r,"ChunkIterator",(function(){return a.ChunkIterator}));var o=s("./src/riff/parseError.ts");s.d(r,"ParseError",(function(){return o.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 a(d){return(a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h})(d)}function o(d,h){return!h||a(h)!=="object"&&typeof h!="function"?(function(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v})(d):h}function i(d){var h=typeof Map=="function"?new Map:void 0;return(i=function(v){if(v===null||(g=v,Function.toString.call(g).indexOf("[native code]")===-1))return v;var g;if(typeof v!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(v))return h.get(v);h.set(v,y)}function y(){return c(v,arguments,f(this).constructor)}return y.prototype=Object.create(v.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),u(y,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,h,v){return(c=l()?Reflect.construct:function(g,y,b){var _=[null];_.push.apply(_,y);var w=new(Function.bind.apply(g,_));return b&&u(w,b.prototype),w}).apply(null,arguments)}function u(d,h){return(u=Object.setPrototypeOf||function(v,g){return v.__proto__=g,v})(d,h)}function f(d){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(h){return h.__proto__||Object.getPrototypeOf(h)})(d)}s.r(r),s.d(r,"ParseError",(function(){return m}));var m=(function(d){function h(v,g,y){return(function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,h),o(this,f(h).call(this,"".concat(v).concat(g&&y?", expected ".concat(g,", received ").concat(y):"")))}return(function(v,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(g&&g.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),g&&u(v,g)})(h,d),h})(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 m}));var a=s("./src/riff/parseError.ts"),o=s("./src/utils/buffer.ts"),i=s("./src/riff/riffChunk.ts"),l=function(d){var h=m(d);if(h!=="RIFF")throw new a.ParseError("Invalid file format","RIFF",h);var v=m(d,8);if(v!=="sfbk")throw new a.ParseError("Invalid signature","sfbk",v);var g=d.subarray(8),y=f(g.subarray(4));return new i.RIFFChunk(h,g.length,g,y)},c=function(d,h){var v=m(d,h),g=u(d,h+4),y=[];return v!=="RIFF"&&v!=="LIST"||(y=f(d.subarray(h+12))),new i.RIFFChunk(v,g,d.subarray(h+8),y)},u=function(d,h){return((d=d.subarray(h,h+4))[0]|d[1]<<8|d[2]<<16|d[3]<<24)>>>0},f=function(d){for(var h=[],v=0;v<=d.length-8;){var g=c(d,v);h.push(g),v=(v+=8+g.length)%2?v+1:v}return h},m=function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return Object(o.getStringFromBuffer)(d.subarray(h,h+4))}},"./src/riff/riffChunk.ts":function(n,r,s){s.r(r),s.d(r,"RIFFChunk",(function(){return c}));var a=s("./src/riff/chunkIterator.ts"),o=s("./src/utils/index.ts");function i(u,f){for(var m=0;m<f.length;m++){var d=f[m];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,m){return f in u?Object.defineProperty(u,f,{value:m,enumerable:!0,configurable:!0,writable:!0}):u[f]=m,u}var c=(function(){function u(d,h,v,g){(function(y,b){if(!(y 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=h,this.buffer=v,this.subChunks=g}var f,m;return f=u,(m=[{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,h=arguments.length>1?arguments[1]:void 0;return Object(o.getStringFromBuffer)(this.getBuffer(d,h||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 a.ChunkIterator(this,d)}},{key:"iterate",value:function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,v=new a.ChunkIterator(this,h);return v.iterate(d),v.target}},{key:"getBuffer",value:function(d,h){return this.buffer.subarray(d,d+h)}}])&&i(f.prototype,m),u})()},"./src/soundFont2.ts":function(n,r,s){s.r(r),s.d(r,"SoundFont2",(function(){return h}));var a=s("./src/types/index.ts"),o=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 g=1;g<arguments.length;g++){var y=arguments[g]!=null?arguments[g]:{},b=Object.keys(y);typeof Object.getOwnPropertySymbols=="function"&&(b=b.concat(Object.getOwnPropertySymbols(y).filter((function(_){return Object.getOwnPropertyDescriptor(y,_).enumerable})))),b.forEach((function(_){d(v,_,y[_])}))}return v}function f(v,g){for(var y=0;y<g.length;y++){var b=g[y];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function m(v,g,y){return g&&f(v.prototype,g),y&&f(v,y),v}function d(v,g,y){return g in v?Object.defineProperty(v,g,{value:y,enumerable:!0,configurable:!0,writable:!0}):v[g]=y,v}var h=(function(){function v(g){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),!(g instanceof o.SF2Chunk)){var y=Object(i.parseBuffer)(g);g=new o.SF2Chunk(y)}if(g.subChunks.length!==3)throw new i.ParseError("Invalid sfbk structure","3 chunks","".concat(g.subChunks.length," chunks"));this.chunk=g,this.metaData=g.subChunks[0].getMetaData(),this.sampleData=g.subChunks[1].getSampleData(),this.presetData=g.subChunks[2].getPresetData(),this.samples=this.getSamples(),this.instruments=this.getInstruments(),this.presets=this.getPresets(),this.banks=this.getBanks()}return m(v,null,[{key:"from",value:function(g){return new v(g)}}]),m(v,[{key:"getKeyData",value:function(g){var y=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=y.banks[x];if(k){var E=k.presets[S];if(E){var M=E.zones.filter((function(ne){return y.isKeyInRange(ne,w)}));if(M.length>0){var T=!0,$=!1,A=void 0;try{for(var I,R=M[Symbol.iterator]();!(T=(I=R.next()).done);T=!0){var D=I.value,O=D.instrument,Z=O.zones.filter((function(ne){return y.isKeyInRange(ne,w)}));if(Z.length>0){var G=!0,Y=!1,te=void 0;try{for(var X,K=Z[Symbol.iterator]();!(G=(X=K.next()).done);G=!0){var le=X.value,J=le.sample,de=u({},D.generators,le.generators),ue=u({},D.modulators,le.modulators);return{keyNumber:w,preset:E,instrument:O,sample:J,generators:de,modulators:ue}}}catch(ne){Y=!0,te=ne}finally{try{G||K.return==null||K.return()}finally{if(Y)throw te}}}}}catch(ne){$=!0,A=ne}finally{try{T||R.return==null||R.return()}finally{if($)throw A}}}}}return null}))(g,b,_)}},{key:"isKeyInRange",value:function(g,y){return g.keyRange===void 0||g.keyRange.lo<=y&&g.keyRange.hi>=y}},{key:"getBanks",value:function(){return this.presets.reduce((function(g,y){var b=y.header.bank;return g[b]||(g[b]={presets:[]}),g[b].presets[y.header.preset]=y,g}),[])}},{key:"getPresets",value:function(){var g=this.presetData,y=g.presetHeaders,b=g.presetZones,_=g.presetGenerators,w=g.presetModulators;return Object(l.getItemsInZone)(y,b,w,_,this.instruments,a.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 g=this.presetData,y=g.instrumentHeaders,b=g.instrumentZones,_=g.instrumentModulators,w=g.instrumentGenerators;return Object(l.getItemsInZone)(y,b,_,w,this.samples,a.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 g=this;return this.presetData.sampleHeaders.filter((function(y){return y.name!=="EOS"})).map((function(y){if(y.name!=="EOS"&&y.sampleRate<=0)throw new Error("Illegal sample rate of ".concat(y.sampleRate," hz in sample '").concat(y.name,"'"));return y.originalPitch>=128&&y.originalPitch<=254&&(y.originalPitch=60),y.startLoop-=y.start,y.endLoop-=y.start,{header:y,data:new Int16Array(new Uint8Array(g.sampleData.subarray(2*y.start,2*y.end)).buffer)}}))}}]),v})()},"./src/types/bank.ts":function(n,r){},"./src/types/generator.ts":function(n,r,s){var a,o;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 o})),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"})(o||(o={}));var l=(i(a={},o.StartAddrsOffset,0),i(a,o.EndAddrsOffset,0),i(a,o.StartLoopAddrsOffset,0),i(a,o.EndLoopAddrsOffset,0),i(a,o.StartAddrsCoarseOffset,0),i(a,o.ModLFOToPitch,0),i(a,o.VibLFOToPitch,0),i(a,o.ModEnvToPitch,0),i(a,o.InitialFilterFc,13500),i(a,o.InitialFilterQ,0),i(a,o.ModLFOToFilterFc,0),i(a,o.ModEnvToFilterFc,0),i(a,o.EndAddrsCoarseOffset,0),i(a,o.ModLFOToVolume,0),i(a,o.ChorusEffectsSend,0),i(a,o.ReverbEffectsSend,0),i(a,o.Pan,0),i(a,o.DelayModLFO,-12e3),i(a,o.FreqModLFO,0),i(a,o.DelayVibLFO,-12e3),i(a,o.FreqVibLFO,0),i(a,o.DelayModEnv,-12e3),i(a,o.AttackModEnv,-12e3),i(a,o.HoldModEnv,-12e3),i(a,o.DecayModEnv,-12e3),i(a,o.SustainModEnv,0),i(a,o.ReleaseModEnv,-12e3),i(a,o.KeyNumToModEnvHold,0),i(a,o.KeyNumToModEnvDecay,0),i(a,o.DelayVolEnv,-12e3),i(a,o.AttackVolEnv,-12e3),i(a,o.HoldVolEnv,-12e3),i(a,o.DecayVolEnv,-12e3),i(a,o.SustainVolEnv,0),i(a,o.ReleaseVolEnv,-12e3),i(a,o.KeyNumToVolEnvHold,0),i(a,o.KeyNumToVolEnvDecay,0),i(a,o.StartLoopAddrsCoarseOffset,0),i(a,o.KeyNum,-1),i(a,o.Velocity,-1),i(a,o.InitialAttenuation,0),i(a,o.EndLoopAddrsCoarseOffset,0),i(a,o.CoarseTune,0),i(a,o.FineTune,0),i(a,o.SampleModes,0),i(a,o.ScaleTuning,100),i(a,o.ExclusiveClass,0),i(a,o.OverridingRootKey,-1),a)},"./src/types/index.ts":function(n,r,s){s.r(r);var a=s("./src/types/bank.ts");for(var o in a)["default"].indexOf(o)<0&&(function(g){s.d(r,g,(function(){return a[g]}))})(o);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 o in l)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return l[y]}))})(o);var c=s("./src/types/key.ts");for(var o in c)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return c[y]}))})(o);var u=s("./src/types/metaData.ts");for(var o in u)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return u[y]}))})(o);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 m=s("./src/types/preset.ts");for(var o in m)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return m[y]}))})(o);var d=s("./src/types/presetData.ts");for(var o in d)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return d[y]}))})(o);var h=s("./src/types/sample.ts");s.d(r,"SampleType",(function(){return h.SampleType}));var v=s("./src/types/zone.ts");for(var o in v)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS","SampleType"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return v[y]}))})(o)},"./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 a})),s.d(r,"ControllerPolarity",(function(){return o})),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 m}));var a,o,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"})(a||(a={})),(function(d){d[d.Unipolar=0]="Unipolar",d[d.Bipolar=1]="Bipolar"})(o||(o={})),(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 m=[{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialFilterFc,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:-2400,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.ChannelPressure},value:50,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:1},value:50,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:7},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:l.MidiController,index:10},value:1e3,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:11},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ReverbEffectsSend,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:91},value:200,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ChorusEffectsSend,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:93},value:200,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.CoarseTune,source:{type:a.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheel},value:12700,valueSource:{type:a.Linear,polarity:o.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 a;s.r(r),s.d(r,"SampleType",(function(){return a})),(function(o){o[o.EOS=0]="EOS",o[o.Mono=1]="Mono",o[o.Right=2]="Right",o[o.Left=4]="Left",o[o.Linked=8]="Linked",o[o.RomMono=32769]="RomMono",o[o.RomRight=32770]="RomRight",o[o.RomLeft=32772]="RomLeft",o[o.RomLinked=32776]="RomLinked"})(a||(a={}))},"./src/types/zone.ts":function(n,r){},"./src/utils/buffer.ts":function(n,r,s){s.r(r),s.d(r,"getStringFromBuffer",(function(){return a}));var a=function(o){var i=new TextDecoder("utf8").decode(o),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 a=s("./src/utils/buffer.ts");s.d(r,"getStringFromBuffer",(function(){return a.getStringFromBuffer}));var o=s("./src/utils/memoize.ts");s.d(r,"memoize",(function(){return o.memoize}))},"./src/utils/memoize.ts":function(n,r,s){s.r(r),s.d(r,"memoize",(function(){return a}));var a=function(o){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 m=o.apply(void 0,c);return i[f]=m,m}}}})}))})(ua)),ua.exports}rh();var Be=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,midiNotes:u,midiChannel:f,midiProgram:m}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate,h=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(h===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??h;return{id:fc(),audioBuffer:t,startSample:n,durationSamples:v,offsetSamples:r,sampleRate:d,sourceDurationSamples:h,gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m}}function uc(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m}=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 h=t?.duration??e.sourceDuration??c?.duration;if(h===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??h;return Ma({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(v*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(h*d),gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m})}function dc(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:fc(),name:t,clips:n,muted:r,soloed:s,volume:a,pan:o,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}}function fc(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function ll(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function sh(e,t){return Math.floor(e/t)}function ah(e,t,n){return Math.ceil(e*n/t)}var Nn=192;function Ns(e,t=Nn){const[,n]=e;return t*(4/n)}function bo(e,t=Nn){const[n]=e;return n*Ns(e,t)}function Rn(e,t,n,r=Nn){return Math.round(e*60*n/(t*r))}function Aa(e,t,n,r=Nn){return Math.round(e*r*t/(60*n))}function Ta(e,t){return Math.round(e/t)*t}function oh(e,t,n=Nn){const r=bo(t,n),s=Ns(t,n),a=Math.floor(e/r)+1,o=Math.floor(e%r/s)+1;return o===1?`${a}`:`${a}.${o}`}function Jr(e){return e.startSample/e.sampleRate}function cl(e){return(e.startSample+e.durationSamples)/e.sampleRate}function ul(e){return e.offsetSamples/e.sampleRate}function dl(e){return e.durationSamples/e.sampleRate}function hc(e,t,n){return Math.floor((e+t)/n)-Math.floor(e/n)}var fl=!1;function yr(e){const t=e._param;return!t&&!fl&&(fl=!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 hl(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 ih(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 lh(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 ch(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 pc(e,t,n){switch(e){case"linear":return hl(t,n);case"exponential":return ih(t,n);case"sCurve":return lh(t,n);case"logarithmic":return ch(t,n);default:return hl(t,n)}}function pl(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=pc(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 ml(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=pc(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 uh=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new L.Volume(this.gainToDb(e.track.gain)),this.panNode=new L.Panner(e.track.stereoPan),this.muteGain=new L.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||L.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=L.getTransport(),s=L.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=L.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)pl(a,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,c=o/i,u=r.gain*c;pl(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;ml(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,f=c/r.fadeOut.duration,m=r.gain*(1-f);ml(a,t,u,r.fadeOut.type||"linear",m,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;yr(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=L.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 dh(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 fh=class{constructor(e){this.track=e.track,this.volumeNode=new L.Volume(this.gainToDb(e.track.gain)),this.panNode=new L.Panner(e.track.stereoPan),this.muteGain=new L.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain),this.synth=new L.PolySynth(L.Synth,e.synthOptions),this.synth.connect(this.volumeNode),this.kickSynth=new L.PolySynth(L.MembraneSynth,{voice:L.MembraneSynth,options:{pitchDecay:.05,octaves:6,envelope:{attack:.001,decay:.4,sustain:0,release:.1}}}),this.snareSynth=new L.NoiseSynth({noise:{type:"white"},envelope:{attack:.001,decay:.15,sustain:0,release:.05}}),this.cymbalSynth=new L.PolySynth(L.MetalSynth,{voice:L.MetalSynth,options:{envelope:{attack:.001,decay:.3,release:.1},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5}}),this.tomSynth=new L.PolySynth(L.MembraneSynth,{voice:L.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||L.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,a=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}}),o=new L.Part((i,l)=>{l.duration>0&&this.triggerNote(l.midi,l.note,l.duration,i,l.velocity,l.channel)},a);return o.start(0),{clipInfo:n,part:o}})}triggerNote(e,t,n,r,s,a){if(a===9)switch(dh(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 a of n.notes){const o=a.time-n.offset,i=r+Math.max(0,o),l=i+a.duration;if(i<e&&l>e){const c=l-e;try{this.triggerNote(a.midi,a.name,c,t,a.velocity,a.channel)}catch(u){console.warn(`[waveform-playlist] Failed to start mid-clip MIDI note "${a.name}" on track "${this.id}":`,u)}}}}}stopAllSources(){const e=L.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;yr(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}},mc=class $a{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 L.Volume(this.gainToDb(t.track.gain)),this.panNode=new L.Panner(t.track.stereoPan),this.muteGain=new L.Gain(t.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const n=t.destination||L.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}),a=this.track.startTime+r.startTime,o=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:a+u,note:l.name,midi:l.midi,duration:Math.max(0,f),velocity:l.velocity,channel:l.channel}}),i=new L.Part((l,c)=>{c.duration>0&&this.triggerNote(c.midi,c.duration,l,c.velocity,c.channel)},o);return i.start(0),{clipInfo:r,part:i}})}triggerNote(t,n,r,s,a){const o=a===9?128:this.bankNumber,i=a===9?0:this.programNumber,l=this.soundFontCache.getAudioBuffer(t,o,i);if(!l){$a._missingSampleWarned||(console.warn(`[waveform-playlist] SoundFont sample not found for MIDI note ${t} (bank ${o}, preset ${i}). Subsequent missing samples will be silent.`),$a._missingSampleWarned=!0);return}const c=L.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,m=l.loopMode===0?Math.max(n,f):n,d=s*s,h=c.createGain(),{attackVolEnv:v,holdVolEnv:g,decayVolEnv:y,sustainVolEnv:b,releaseVolEnv:_}=l,w=d*b;h.gain.setValueAtTime(0,r),h.gain.linearRampToValueAtTime(d,r+v),g>.001&&h.gain.setValueAtTime(d,r+v+g);const x=r+v+g;h.gain.linearRampToValueAtTime(w,x+y),h.gain.setValueAtTime(w,r+m),h.gain.linearRampToValueAtTime(0,r+m+_),u.connect(h),h.connect(this.volumeNode.input.input),this.activeSources.add(u),u.onended=()=>{this.activeSources.delete(u);try{h.disconnect()}catch(S){console.warn("[waveform-playlist] GainNode already disconnected:",S)}},u.start(r),u.stop(r+m+_)}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,a=s+r.duration;if(s<t&&a>t)for(const o of r.notes){const i=o.time-r.offset,l=s+Math.max(0,i),c=l+o.duration;if(l<t&&c>t){const u=c-t;try{this.triggerNote(o.midi,u,n,o.velocity,o.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;yr(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}};mc._missingSampleWarned=!1;var hh=mc,ph=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 L.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,L.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{L.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await L.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new uh(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 fh(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 hh(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??L.now(),s=L.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=L.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=L.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=>{try{t.stopAllSources()}catch(n){console.warn(`[waveform-playlist] Error stopping sources for track "${t.id}":`,n)}}),this.tracks.forEach(t=>{try{t.cancelFades()}catch(n){console.warn(`[waveform-playlist] Error canceling fades for track "${t.id}":`,n)}}),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=L.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=L.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 L.getTransport().seconds}seekTo(e){L.getTransport().seconds=e}dispose(){try{this.stop()}catch(e){console.warn("[waveform-playlist] Error stopping Transport during dispose:",e)}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 L.getContext()}get sampleRate(){return L.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Qr=null;function mh(){return Qr||(Qr=new L.Context,L.setContext(Qr)),Qr}function gh(){return mh().rawContext}function vh(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(f){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",f)}t=null}r++;const u=r;t=new ph({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 m=f.clips.filter(h=>h.audioBuffer&&!h.midiNotes),d=f.clips.filter(h=>h.midiNotes&&h.midiNotes.length>0);if(m.length>0){const h=Math.min(...m.map(Jr)),v=Math.max(...m.map(cl)),g={id:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:v},y=m.map(b=>({buffer:b.audioBuffer,startTime:Jr(b)-h,duration:dl(b),offset:ul(b),fadeIn:b.fadeIn,fadeOut:b.fadeOut,gain:b.gain}));t.addTrack({clips:y,track:g,effects:f.effects})}if(d.length>0){const h=Math.min(...d.map(Jr)),v=Math.max(...d.map(cl)),y={id:m.length>0?`${f.id}:midi`:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:v},b=d.map(_=>({notes:_.midiNotes,startTime:Jr(_)-h,duration:dl(_),offset:ul(_)}));if(e?.soundFontCache?.isLoaded){const _=d[0],x=_.midiChannel===9,S=_.midiProgram??0;t.addSoundFontTrack({clips:b,track:y,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:y,effects:f.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 f=u!==void 0?u-c:void 0;t.play(L.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,a=u,o=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 gc(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 vc(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 yh(e,t){return Math.floor(e/t)*t}function bh(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 yc(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 da(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 wh(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 gl(e,t){return Math.max(0,Math.min(e,t))}var _h=44100,xh=1024,Ch=[256,512,1024,2048,4096,8192],vl=.1,Sh=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??_h,this._zoomLevels=[...e.zoomLevels??Ch],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??xh,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:da(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=ll(r.clips),i=o.findIndex(c=>c.id===t),l=gc(a,n,o,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=c.clips.map((f,m)=>m===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 a=r.clips[s],o=Math.floor(vl*this._sampleRate);if(!yc(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}=bh(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(f=>f.id===e);if(!s){console.warn(`[waveform-playlist/engine] trimClip: track "${e}" not found`);return}const a=s.clips.findIndex(f=>f.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=ll(s.clips),l=i.findIndex(f=>f.id===t),c=Math.floor(vl*this._sampleRate),u=vc(o,r,n,i,l,c);u!==0&&(this._tracks=this._tracks.map(f=>{if(f.id!==e)return f;const m=f.clips.map((d,h)=>h!==a?d:n==="left"?{...d,startSample:d.startSample+u,offsetSamples:d.offsetSamples+u,durationSamples:d.durationSamples-u}:{...d,durationSamples:d.durationSamples+u});return{...f,clips:m}}),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=da(this._tracks);this._currentTime=gl(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=da(this._tracks);this._currentTime=gl(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=wh(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)}},kh=Symbol.for("preact-signals");function zs(){if(Yt>1)Yt--;else{for(var e,t=!1;fr!==void 0;){var n=fr;for(fr=void 0,Ra++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&wc(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(Ra=0,Yt--,t)throw e}}function Kt(e){if(Yt>0)return e();Yt++;try{return e()}finally{zs()}}var ye=void 0;function we(e){var t=ye;ye=void 0;try{return e()}finally{ye=t}}var fr=void 0,Yt=0,Ra=0,_s=0;function bc(e){if(ye!==void 0){var t=e.n;if(t===void 0||t.t!==ye)return t={i:0,S:e,p:ye.s,n:void 0,t:ye,e:void 0,x:void 0,r:t},ye.s!==void 0&&(ye.s.n=t),ye.s=t,e.n=t,32&ye.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=ye.s,t.n=void 0,ye.s.n=t,ye.s=t),t}}function at(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}at.prototype.brand=kh;at.prototype.h=function(){return!0};at.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)}))};at.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)}))}};at.prototype.subscribe=function(e){var t=this;return _t(function(){var n=t.value,r=ye;ye=void 0;try{e(n)}finally{ye=r}},{name:"sub"})};at.prototype.valueOf=function(){return this.value};at.prototype.toString=function(){return this.value+""};at.prototype.toJSON=function(){return this.value};at.prototype.peek=function(){var e=ye;ye=void 0;try{return this.value}finally{ye=e}};Object.defineProperty(at.prototype,"value",{get:function(){var e=bc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ra>100)throw new Error("Cycle detected");this.v=e,this.i++,_s++,Yt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{zs()}}}});function Ar(e,t){return new at(e,t)}function wc(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 _c(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 xc(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 pn(e,t){at.call(this,void 0),this.x=e,this.s=void 0,this.g=_s-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}pn.prototype=new at;pn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===_s))return!0;if(this.g=_s,this.f|=1,this.i>0&&!wc(this))return this.f&=-2,!0;var e=ye;try{_c(this),ye=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 ye=e,xc(this),this.f&=-2,!0};pn.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)}at.prototype.S.call(this,e)};pn.prototype.U=function(e){if(this.t!==void 0&&(at.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)}};pn.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(pn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=bc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function yl(e,t){return new pn(e,t)}function Cc(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Yt++;var n=ye;ye=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,wo(e),r}finally{ye=n,zs()}}}function wo(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(ye!==this)throw new Error("Out-of-order effect");xc(this),ye=e,this.f&=-2,8&this.f&&wo(this),zs()}function zn(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}zn.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()}};zn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Cc(this),_c(this),Yt++;var e=ye;return ye=this,Eh.bind(this,e)};zn.prototype.N=function(){2&this.f||(this.f|=2,this.o=fr,fr=this)};zn.prototype.d=function(){this.f|=8,1&this.f||wo(this)};zn.prototype.dispose=function(){this.d()};function _t(e,t){var n=new zn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Ih=Object.create,_o=Object.defineProperty,Mh=Object.defineProperties,Ah=Object.getOwnPropertyDescriptor,Th=Object.getOwnPropertyDescriptors,bl=Object.getOwnPropertySymbols,$h=Object.prototype.hasOwnProperty,Rh=Object.prototype.propertyIsEnumerable,Dh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),jn=e=>{throw TypeError(e)},Da=(e,t,n)=>t in e?_o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ph=(e,t)=>{for(var n in t||(t={}))$h.call(t,n)&&Da(e,n,t[n]);if(bl)for(var n of bl(t))Rh.call(t,n)&&Da(e,n,t[n]);return e},Fh=(e,t)=>Mh(e,Th(t)),wl=(e,t)=>_o(e,"name",{value:t,configurable:!0}),Oh=e=>{var t;return[,,,Ih((t=void 0)!=null?t:null)]},Sc=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?jn("Function expected"):e,Lh=(e,t,n,r,s)=>({kind:Sc[e],name:t,metadata:r,addInitializer:a=>n._?jn("Already initialized"):s.push(tr(a||null))}),kc=(e,t)=>Da(t,Dh("metadata"),e[3]),nn=(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},Zn=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,v=Sc[f+5],g=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&Ah(f<4?s:{get[n](){return un(this,a)},set[n](w){return Gt(this,a,w)}},n));f?d&&f<4&&wl(a,(f>2?"set ":f>1?"get ":"")+n):wl(s,n);for(var _=r.length-1;_>=0;_--)c=Lh(f,n,l={},e[3],y),f&&(c.static=m,c.private=d,u=c.access={has:d?w=>Bh(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?un:Wh)(w,s,f^4?a:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>Gt(w,s,x,f^4?a:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?tr(i)&&(f>4?g.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?jn("Object expected"):(tr(o=i.get)&&(b.get=o),tr(o=i.set)&&(b.set=o),tr(o=i.init)&&g.unshift(o));return f||kc(e,s),b&&_o(s,n,b),d?f^4?a:b:s},xo=(e,t,n)=>t.has(e)||jn("Cannot "+n),Bh=(e,t)=>Object(t)!==t?jn('Cannot use the "in" operator on this value'):e.has(t),un=(e,t,n)=>(xo(e,t,"read from private field"),n?n.call(e):t.get(e)),es=(e,t,n)=>t.has(e)?jn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Gt=(e,t,n,r)=>(xo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Wh=(e,t,n)=>(xo(e,t,"access private method"),n);function xs(e,t){if(t){let n;return yl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return yl(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 he({get:e},t){return{init(n){return Ar(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Pe(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=xs(e.bind(this)),n.set(this,r)),r.value}}function fa(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,Fh(Ph({},s),{enumerable:e}))})}}function Tr(...e){const t=e.map(n=>_t(n));return()=>t.forEach(n=>n())}var Ec,Ic,Mc,Ac,Tc,$c,nt,Co,ha,Pa,Fa,Qe,So,pa,Rc,Oa,ko,ma,La,Ba;$c=[he],Tc=[he],Ac=[he],Mc=[fa()],Ic=[fa()],Ec=[fa()];var Jt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,nn(nt,5,this),es(this,Qe),es(this,Co,nn(nt,8,this)),nn(nt,11,this),es(this,So,nn(nt,12,this)),nn(nt,15,this),es(this,ko,nn(nt,16,this)),nn(nt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return un(this,Qe,La)}get initial(){return un(this,Qe,Pa)}get previous(){return un(this,Qe,Rc)}set current(e){const t=we(()=>un(this,Qe,La));e&&t&&this.equals(t,e)||Kt(()=>{un(this,Qe,Pa)||Gt(this,Qe,e,Fa),Gt(this,Qe,t,Oa),Gt(this,Qe,e,Ba)})}reset(e=this.defaultValue){Kt(()=>{Gt(this,Qe,void 0,Oa),Gt(this,Qe,e,Fa),Gt(this,Qe,e,Ba)})}};nt=Oh();Co=new WeakMap;Qe=new WeakSet;So=new WeakMap;ko=new WeakMap;ha=Zn(nt,20,"#initial",$c,Qe,Co),Pa=ha.get,Fa=ha.set;pa=Zn(nt,20,"#previous",Tc,Qe,So),Rc=pa.get,Oa=pa.set;ma=Zn(nt,20,"#current",Ac,Qe,ko),La=ma.get,Ba=ma.set;Zn(nt,2,"current",Mc,Jt);Zn(nt,2,"initial",Ic,Jt);Zn(nt,2,"previous",Ec,Jt);kc(nt,Jt);function ga(e){return we(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Vh=Object.create,Dc=Object.defineProperty,Nh=Object.getOwnPropertyDescriptor,_l=Object.getOwnPropertySymbols,zh=Object.prototype.hasOwnProperty,jh=Object.prototype.propertyIsEnumerable,Pc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),js=e=>{throw TypeError(e)},xl=Math.pow,Wa=(e,t,n)=>t in e?Dc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zh=(e,t)=>{for(var n in t||(t={}))zh.call(t,n)&&Wa(e,n,t[n]);if(_l)for(var n of _l(t))jh.call(t,n)&&Wa(e,n,t[n]);return e},Hh=e=>{var t;return[,,,Vh((t=e?.[Pc("metadata")])!=null?t:null)]},Fc=["class","method","getter","setter","accessor","field","value","get","set"],Oc=e=>e!==void 0&&typeof e!="function"?js("Function expected"):e,Gh=(e,t,n,r,s)=>({kind:Fc[e],name:t,metadata:r,addInitializer:a=>n._?js("Already initialized"):s.push(Oc(a||null))}),Uh=(e,t)=>Wa(t,Pc("metadata"),e[3]),Xh=(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},Lc=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=Fc[u+5],v=e[d]||(e[d]=[]),g=(s=s.prototype,Nh(s,n)),y=r.length-1;y>=0;y--)l=Gh(u,n,i={},e[3],v),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(g[h],l),i._=1,Oc(o)&&(g[h]=o);return g&&Dc(s,n,g),s},Bc=(e,t,n)=>t.has(e)||js("Cannot "+n),Yh=(e,t,n)=>(Bc(e,t,"read from private field"),t.get(e)),Kh=(e,t,n)=>t.has(e)?js("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qh=(e,t,n,r)=>(Bc(e,t,"write to private field"),t.set(e,n),n),Tt=class Va{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Va(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 Va(t,n)}},$r=class sn{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 sn(s+t,r+n,a,o);return l.scale=Zh({},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 sn))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 sn?Jh(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 sn(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 sn.from(t).intersectionRatio(sn.from(n))}};function Jh(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 Wc,Vc,Na,ls,Rr,Zs=class extends(Na=Jt,Vc=[Pe],Wc=[Pe],Na){constructor(t){const n=Tt.from(t);super(n,(r,s)=>Tt.equals(r,s)),Xh(Rr,5,this),Kh(this,ls,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-Yh(this,ls),i=l=>Math.round(l/o*100);Kt(()=>{qh(this,ls,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}}};Rr=Hh(Na);ls=new WeakMap;Lc(Rr,2,"delta",Vc,Zs);Lc(Rr,2,"direction",Wc,Zs);Uh(Rr,Zs);function za({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(xl(r,2)+xl(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 Nc=(e=>(e.Horizontal="x",e.Vertical="y",e))(Nc||{}),zc=Object.values(Nc),Qh=Object.create,Eo=Object.defineProperty,ep=Object.defineProperties,tp=Object.getOwnPropertyDescriptor,np=Object.getOwnPropertyDescriptors,Cs=Object.getOwnPropertySymbols,jc=Object.prototype.hasOwnProperty,Zc=Object.prototype.propertyIsEnumerable,Hc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Hn=e=>{throw TypeError(e)},ja=(e,t,n)=>t in e?Eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gc=(e,t)=>{for(var n in t||(t={}))jc.call(t,n)&&ja(e,n,t[n]);if(Cs)for(var n of Cs(t))Zc.call(t,n)&&ja(e,n,t[n]);return e},Uc=(e,t)=>ep(e,np(t)),Cl=(e,t)=>Eo(e,"name",{value:t,configurable:!0}),Xc=(e,t)=>{var n={};for(var r in e)jc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Cs)for(var r of Cs(e))t.indexOf(r)<0&&Zc.call(e,r)&&(n[r]=e[r]);return n},Gn=e=>{var t;return[,,,Qh((t=e?.[Hc("metadata")])!=null?t:null)]},Yc=["class","method","getter","setter","accessor","field","value","get","set"],nr=e=>e!==void 0&&typeof e!="function"?Hn("Function expected"):e,rp=(e,t,n,r,s)=>({kind:Yc[e],name:t,metadata:r,addInitializer:a=>n._?Hn("Already initialized"):s.push(nr(a||null))}),mn=(e,t)=>ja(t,Hc("metadata"),e[3]),se=(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},fe=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,v=Yc[f+5],g=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&tp(f<4?s:{get[n](){return Ze(this,a)},set[n](w){return yt(this,a,w)}},n));f?d&&f<4&&Cl(a,(f>2?"set ":f>1?"get ":"")+n):Cl(s,n);for(var _=r.length-1;_>=0;_--)c=rp(f,n,l={},e[3],y),f&&(c.static=m,c.private=d,u=c.access={has:d?w=>sp(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?Ze:ap)(w,s,f^4?a:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>yt(w,s,x,f^4?a:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?nr(i)&&(f>4?g.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?Hn("Object expected"):(nr(o=i.get)&&(b.get=o),nr(o=i.set)&&(b.set=o),nr(o=i.init)&&g.unshift(o));return f||mn(e,s),b&&Eo(s,n,b),d?f^4?a:b:s},Io=(e,t,n)=>t.has(e)||Hn("Cannot "+n),sp=(e,t)=>Object(t)!==t?Hn('Cannot use the "in" operator on this value'):e.has(t),Ze=(e,t,n)=>(Io(e,t,"read from private field"),n?n.call(e):t.get(e)),be=(e,t,n)=>t.has(e)?Hn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),yt=(e,t,n,r)=>(Io(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ap=(e,t,n)=>(Io(e,t,"access private method"),n);function Kc(e,t){return{plugin:e,options:t}}function gn(e){return t=>Kc(e,t)}function Mo(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var qc,wr,Ao,cs;qc=[he];var dt=class{constructor(e,t){this.manager=e,this.options=t,be(this,Ao,se(wr,8,this,!1)),se(wr,11,this),be(this,cs,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return we(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=_t(e.bind(this));return Ze(this,cs).add(t),t}destroy(){Ze(this,cs).forEach(e=>e())}static configure(e){return Kc(this,e)}};wr=Gn(null);Ao=new WeakMap;cs=new WeakMap;fe(wr,4,"disabled",qc,dt,Ao);mn(wr,dt);var Dr=class extends dt{},us,va=class{constructor(e){this.manager=e,this.instances=new Map,be(this,us,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(Mo).reduceRight((r,s)=>r.some(({plugin:a})=>a===s.plugin)?r:[s,...r],[]),n=t.map(({plugin:r})=>r);for(const r of Ze(this,us))if(!n.includes(r)){if(r.prototype instanceof Dr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);yt(this,us,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()}};us=new WeakMap;function op(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var ts=[],En,In,ip=class extends dt{constructor(e){super(e),be(this,En),be(this,In),this.computeCollisions=this.computeCollisions.bind(this),yt(this,In,Ar(ts)),this.destroy=Tr(()=>{const t=this.computeCollisions(),n=we(()=>this.manager.dragOperation.position.current);if(t!==ts){const r=Ze(this,En);if(yt(this,En,n),r&&n.x==r.x&&n.y==r.y)return}else yt(this,En,void 0);Ze(this,In).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){we(()=>{e?Ze(this,In).value=this.computeCollisions():yt(this,En,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:a,status:o}=r;if(!o.initialized||!a)return ts;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?ts:(i.sort(op),i)}get collisions(){return Ze(this,In).value}};En=new WeakMap;In=new WeakMap;var lp=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)}},cp=class extends lp{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ds(e,t=!0){let n=!1;return Uc(Gc({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var up=class extends Dr{constructor(e){super(e);const t=(r,s)=>r.map(({id:a})=>a).join("")===s.map(({id:a})=>a).join("");let n=[];this.destroy=Tr(()=>{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=ds({collisions:a});if(s.dispatch("collision",o),o.defaultPrevented||t(a,n))return;n=a;const[i]=a;we(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},To=(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))(To||{}),$o=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))($o||{}),Jc,Qc,eu,tu,nu,ru,su,wt,Ro;su=[he],ru=[Pe],nu=[Pe],tu=[Pe],eu=[Pe],Qc=[Pe],Jc=[Pe];var Vt=class{constructor(){se(wt,5,this),be(this,Ro,se(wt,8,this,"idle")),se(wt,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}};wt=Gn(null);Ro=new WeakMap;fe(wt,4,"value",su,Vt,Ro);fe(wt,2,"current",ru,Vt);fe(wt,2,"idle",nu,Vt);fe(wt,2,"initializing",tu,Vt);fe(wt,2,"initialized",eu,Vt);fe(wt,2,"dragging",Qc,Vt);fe(wt,2,"dropped",Jc,Vt);mn(wt,Vt);var dp=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=ds({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:a}=e;Kt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(a)});const o=ds({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 we(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:a}=r;if(!s.dragging||!a||a.signal.aborted)return;const o=ds({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,f;if(o.defaultPrevented)return;const m=(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=m})})}stop(e={}){return we(()=>{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=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=_t(()=>{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:o}),a?a.then(i).catch(()=>r.reset()):i()})}},au,ou,iu,lu,ut,Do,Po,Fo,Oo;lu=[he],iu=[he],ou=[he],au=[he];var Qt=class{constructor(e,t){be(this,Do,se(ut,8,this)),se(ut,11,this),be(this,Po,se(ut,12,this)),se(ut,15,this),be(this,Fo,se(ut,16,this)),se(ut,19,this),be(this,Oo,se(ut,20,this)),se(ut,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)}};ut=Gn(null);Do=new WeakMap;Po=new WeakMap;Fo=new WeakMap;Oo=new WeakMap;fe(ut,4,"manager",lu,Qt,Do);fe(ut,4,"id",iu,Qt,Po);fe(ut,4,"data",ou,Qt,Fo);fe(ut,4,"disabled",au,Qt,Oo);mn(ut,Qt);var Sl=class{constructor(){this.map=Ar(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=Tr(...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}},cu,uu,du,fu,hu,pu,Za,rt,Lo,Bo,Wo,$t=class extends(Za=Qt,pu=[he],hu=[he],fu=[he],du=[Pe],uu=[Pe],cu=[Pe],Za){constructor(t,n){var r=t,{modifiers:s,type:a,sensors:o}=r,i=Xc(r,["modifiers","type","sensors"]);super(i,n),se(rt,5,this),be(this,Lo,se(rt,8,this)),se(rt,11,this),be(this,Bo,se(rt,12,this)),se(rt,15,this),be(this,Wo,se(rt,16,this,this.isDragSource?"dragging":"idle")),se(rt,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}};rt=Gn(Za);Lo=new WeakMap;Bo=new WeakMap;Wo=new WeakMap;fe(rt,4,"type",pu,$t,Lo);fe(rt,4,"modifiers",hu,$t,Bo);fe(rt,4,"status",fu,$t,Wo);fe(rt,2,"isDropping",du,$t);fe(rt,2,"isDragging",uu,$t);fe(rt,2,"isDragSource",cu,$t);mn(rt,$t);var mu,gu,vu,yu,bu,wu,Ha,ze,Vo,No,zo,jo,Zo,Rt=class extends(Ha=Qt,wu=[he],bu=[he],yu=[he],vu=[he],gu=[he],mu=[Pe],Ha){constructor(t,n){var r=t,{accept:s,collisionDetector:a,collisionPriority:o,type:i}=r,l=Xc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),se(ze,5,this),be(this,Vo,se(ze,8,this)),se(ze,11,this),be(this,No,se(ze,12,this)),se(ze,15,this),be(this,zo,se(ze,16,this)),se(ze,19,this),be(this,jo,se(ze,20,this)),se(ze,23,this),be(this,Zo,se(ze,24,this)),se(ze,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}};ze=Gn(Ha);Vo=new WeakMap;No=new WeakMap;zo=new WeakMap;jo=new WeakMap;Zo=new WeakMap;fe(ze,4,"accept",wu,Rt,Vo);fe(ze,4,"type",bu,Rt,No);fe(ze,4,"collisionDetector",yu,Rt,zo);fe(ze,4,"collisionPriority",vu,Rt,jo);fe(ze,4,"shape",gu,Rt,Zo);fe(ze,2,"isDropTarget",mu,Rt);mn(ze,Rt);var Fn=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},fp=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)}},fs,_u=class{constructor(e){this.options=e,be(this,fs)}set controller(e){yt(this,fs,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ze(this,fs))==null||t.activate(e)}};fs=new WeakMap;var On=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},hp=class{constructor(e){this.draggables=new Sl,this.droppables=new Sl,this.plugins=new va(e),this.sensors=new va(e),this.modifiers=new va(e)}register(e,t){if(e instanceof $t)return this.draggables.register(e.id,e);if(e instanceof Rt)return this.droppables.register(e.id,e);if(e.prototype instanceof On)return this.modifiers.register(e,t);if(e.prototype instanceof Fn)return this.sensors.register(e,t);if(e.prototype instanceof dt)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Qt)return e instanceof $t?this.draggables.unregister(e.id,e):e instanceof Rt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof On)return this.modifiers.unregister(e);if(e.prototype instanceof Fn)return this.sensors.unregister(e);if(e.prototype instanceof dt)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()}},xu,Cu,Su,ku,Eu,Iu,Mu,Au,Tu,rr,hs,Mn,Fe,Ho,Go,Uo,Xo,Yo,sr;Tu=[Pe],Au=[he],Mu=[he],Iu=[he],Eu=[he],ku=[he],Su=[Pe],Cu=[Pe],xu=[Pe];var Mt=class{constructor(e){se(Fe,5,this),be(this,rr),be(this,hs),be(this,Mn,new Jt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Vt,be(this,Ho,se(Fe,8,this,!1)),se(Fe,11,this),be(this,Go,se(Fe,12,this,null)),se(Fe,15,this),be(this,Uo,se(Fe,16,this,null)),se(Fe,19,this),be(this,Xo,se(Fe,20,this,null)),se(Fe,23,this),be(this,Yo,se(Fe,24,this,[])),se(Fe,27,this),this.position=new Zs({x:0,y:0}),be(this,sr,{x:0,y:0}),yt(this,rr,e)}get shape(){const{current:e,initial:t,previous:n}=Ze(this,Mn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ze(this,Mn).current=e:Ze(this,Mn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ze(this,rr).registry.draggables.get(t);return n&&yt(this,hs,n),(e=n??Ze(this,hs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ze(this,rr).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(Uc(Gc({},this.snapshot()),{transform:n}));return yt(this,sr,n),n}snapshot(){return we(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ze(this,sr),shape:this.shape?ga(this.shape):null,position:ga(this.position),status:ga(this.status),canceled:this.canceled}))}reset(){Kt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ze(this,Mn).reset(),this.position.reset({x:0,y:0}),yt(this,sr,{x:0,y:0}),this.modifiers=[]})}};Fe=Gn(null);rr=new WeakMap;hs=new WeakMap;Mn=new WeakMap;Ho=new WeakMap;Go=new WeakMap;Uo=new WeakMap;Xo=new WeakMap;Yo=new WeakMap;sr=new WeakMap;fe(Fe,2,"shape",Tu,Mt);fe(Fe,4,"canceled",Au,Mt,Ho);fe(Fe,4,"activatorEvent",Mu,Mt,Go);fe(Fe,4,"sourceIdentifier",Iu,Mt,Uo);fe(Fe,4,"targetIdentifier",Eu,Mt,Xo);fe(Fe,4,"modifiers",ku,Mt,Yo);fe(Fe,2,"source",Su,Mt);fe(Fe,2,"target",Cu,Mt);fe(Fe,2,"transform",xu,Mt);mn(Fe,Mt);var pp={get rendering(){return Promise.resolve()}};function Lt(e,t){return typeof e=="function"?e(t):e??t}var mp=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(m=>m.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=Lt(r.plugins,[]),a=Lt(r.sensors,[]),o=Lt(r.modifiers,[]),i=(n=r.renderer)!=null?n:pp,l=new cp(this),c=new hp(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new dp(this),this.dragOperation=new Mt(this),this.collisionObserver=new ip(this),this.plugins=[up,...s],this.modifiers=o,this.sensors=a;const{destroy:u}=this,f=Tr(()=>{var m,d,h;const v=we(()=>this.dragOperation.modifiers),g=this.modifiers;for(const y of v)g.includes(y)||y.destroy();this.dragOperation.modifiers=(h=(d=(m=this.dragOperation.source)==null?void 0:m.modifiers)==null?void 0:d.map(y=>{const{plugin:b,options:_}=Mo(y);return new b(this,_)}))!=null?h:g});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}},$u=e=>{throw TypeError(e)},Ko=(e,t,n)=>t.has(e)||$u("Cannot "+n),ie=(e,t,n)=>(Ko(e,t,"read from private field"),t.get(e)),ct=(e,t,n)=>t.has(e)?$u("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),pt=(e,t,n,r)=>(Ko(e,t,"write to private field"),t.set(e,n),n),Ru=(e,t,n)=>(Ko(e,t,"access private method"),n);function Hs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function gp(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=(Hs(s)?s.getKeyframes():[]).filter(t);if(o.length>0)return[o[o.length-1],r]}return null}function Gs(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 qo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Pr(e){return"nodeType"in e}function xt(e){var t,n,r;return e?qo(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 Jo(e){const{Document:t}=xt(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function dn(e){return!e||qo(e)?!1:e instanceof xt(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Du(e){return e instanceof xt(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function vn(e){return e?qo(e)?e.document:Pr(e)?Jo(e)?e:dn(e)||Du(e)?e.ownerDocument:document:document:document}function vp(e){var t,n,r,s;const{documentElement:a}=vn(e),o=xt(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 yp(e,t){if(bp(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function bp(e){return e.tagName==="DETAILS"}function Ss(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 f=e.parentElement;for(;f&&f!==c.documentElement;){if(!yp(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 m=u.visualViewport,d=(s=m?.offsetTop)!=null?s:0,h=(a=m?.offsetLeft)!=null?a:0,v=(o=m?.width)!=null?o:u.innerWidth,g=(i=m?.height)!=null?i:u.innerHeight,y=n*g,b=n*v;return l={top:Math.max(l.top,d-y),right:Math.min(l.right,h+v+b),bottom:Math.min(l.bottom,d+g+y),left:Math.max(l.left,h-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 Ln(e){return{x:e.clientX,y:e.clientY}}var Pu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ga(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(...Ga(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(...Ga(s.document,t))}}catch{}return n}function Qo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Fu(){var e,t;const n=Qo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function ei(e){return!e||!Pr(e)?!1:e instanceof xt(e).ShadowRoot}function ks(e){if(e&&Pr(e)){let t=e.getRootNode();if(ei(t))return t;if(t instanceof Document)return t}return vn(e)}function Ou(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function wp(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(kl(a)&&kl(i)&&(a.type!=="file"&&(a.value=i.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),El(a)&&El(i)&&i.width>0&&i.height>0){const l=a.getContext("2d");l?.drawImage(i,0,0)}}),n}function kl(e){return"value"in e}function El(e){return e.tagName==="CANVAS"}function Lu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(_p(r)){const{contentDocument:s}=r;if(s){const{left:a,top:o}=r.getBoundingClientRect();return Lu(s,{x:t-a,y:n-o})}}return r}function _p(e){return e?.tagName==="IFRAME"}var Il=new WeakMap;function xp(e){return!!e.closest(`
1
+ "use strict";var Kf=Object.create;var ol=Object.defineProperty;var qf=Object.getOwnPropertyDescriptor;var Jf=Object.getOwnPropertyNames;var Qf=Object.getPrototypeOf,eh=Object.prototype.hasOwnProperty;var th=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Jf(t))!eh.call(e,s)&&s!==n&&ol(e,s,{get:()=>t[s],enumerable:!(r=qf(t,s))||r.enumerable});return e};var nh=(e,t,n)=>(n=e!=null?Kf(Qf(e)):{},th(t||!e||!e.__esModule?ol(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("tone"),C=require("react/jsx-runtime"),m=require("react"),P=require("styled-components"),mo=require("react-dom");function lc(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 cc=lc(L),D=lc(m);var ia={exports:{}},il;function rh(){return il||(il=1,(function(e,t){(function(n,r){e.exports=r()})(window,(function(){return(function(n){var r={};function s(a){if(r[a])return r[a].exports;var o=r[a]={i:a,l:!1,exports:{}};return n[a].call(o.exports,o,o.exports,s),o.l=!0,o.exports}return s.m=n,s.c=r,s.d=function(a,o,i){s.o(a,o)||Object.defineProperty(a,o,{enumerable:!0,get:i})},s.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},s.t=function(a,o){if(1&o&&(a=s(a)),8&o||4&o&&typeof a=="object"&&a&&a.__esModule)return a;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:a}),2&o&&typeof a!="string")for(var l in a)s.d(i,l,(function(c){return a[c]}).bind(null,l));return i},s.n=function(a){var o=a&&a.__esModule?function(){return a.default}:function(){return a};return s.d(o,"a",o),o},s.o=function(a,o){return Object.prototype.hasOwnProperty.call(a,o)},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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=s("./src/chunks/index.ts");function l(h){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})(h)}function c(h,v){for(var g=0;g<v.length;g++){var y=v[g];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(h,y.key,y)}}function u(h){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)})(h)}function f(h,v){return(f=Object.setPrototypeOf||function(g,y){return g.__proto__=y,g})(h,v)}function p(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}var d=(function(h){function v(b){var w,_,x,S,k,E;return(function(I,M){if(!(I instanceof M))throw new TypeError("Cannot call a class as a function")})(this,v),_=this,w=!(x=u(v).call(this,b.id,b.length,b.buffer,b.subChunks))||l(x)!=="object"&&typeof x!="function"?p(_):x,S=p(p(w)),E=void 0,(k="subChunks")in S?Object.defineProperty(S,k,{value:E,enumerable:!0,configurable:!0,writable:!0}):S[k]=E,w.subChunks=b.subChunks.map((function(I){return new v(I)})),w}var g,y;return(function(b,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(w&&w.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),w&&f(b,w)})(v,h),g=v,(y=[{key:"getMetaData",value:function(){if(this.id!=="LIST")throw new a.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks.reduce((function(w,_){if(_.id==="ifil"||_.id==="iver"){if(_.length!==o.SF_VERSION_LENGTH)throw new a.ParseError("Invalid size for the '".concat(_.id,"' sub-chunk"));w[_.id]="".concat(_.getInt16(),".").concat(_.getInt16(2))}else w[_.id]=_.getString();return w}),{});if(!b.ifil)throw new a.ParseError("Missing required 'ifil' sub-chunk");if(!b.INAM)throw new a.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 a.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks[0];if(b.id!=="smpl")throw new a.ParseError("Invalid chunk signature","'smpl'","'".concat(b.id,"'"));return b.buffer}},{key:"getPresetData",value:function(){if(this.id!=="LIST")throw new a.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(g.prototype,y),v})(a.RIFFChunk)},"./src/chunks/generators.ts":function(n,r,s){s.r(r),s.d(r,"getGenerators",(function(){return f}));var a=s("./src/riff/index.ts"),o=s("./src/types/index.ts"),i=s("./src/constants.ts"),l=[o.GeneratorType.StartAddrsOffset,o.GeneratorType.EndAddrsOffset,o.GeneratorType.StartLoopAddrsOffset,o.GeneratorType.EndLoopAddrsOffset,o.GeneratorType.StartAddrsCoarseOffset,o.GeneratorType.EndAddrsCoarseOffset,o.GeneratorType.StartLoopAddrsCoarseOffset,o.GeneratorType.KeyNum,o.GeneratorType.Velocity,o.GeneratorType.EndLoopAddrsCoarseOffset,o.GeneratorType.SampleModes,o.GeneratorType.ExclusiveClass,o.GeneratorType.OverridingRootKey],c=[o.GeneratorType.Unused1,o.GeneratorType.Unused2,o.GeneratorType.Unused3,o.GeneratorType.Unused4,o.GeneratorType.Reserved1,o.GeneratorType.Reserved2,o.GeneratorType.Reserved3],u=[o.GeneratorType.KeyRange,o.GeneratorType.VelRange],f=function(p,d){if(p.id!==d)throw new a.ParseError("Unexpected chunk ID","'".concat(d,"'"),"'".concat(p.id,"'"));if(p.length%i.SF_GENERATOR_SIZE)throw new a.ParseError("Invalid size for the '".concat(d,"' sub-chunk"));return p.iterate((function(h){var v=h.getInt16();return o.GeneratorType[v]?d==="pgen"&&l.includes(v)||d==="igen"&&c.includes(v)?null:u.includes(v)?{id:v,range:{lo:h.getByte(),hi:h.getByte()}}:{id:v,value:h.getInt16BE()}:null}))}},"./src/chunks/index.ts":function(n,r,s){s.r(r);var a=s("./src/chunks/instruments/index.ts");s.d(r,"getInstrumentHeaders",(function(){return a.getInstrumentHeaders}));var o=s("./src/chunks/presets/index.ts");s.d(r,"getPresetHeaders",(function(){return o.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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="inst")throw new a.ParseError("Unexpected chunk ID","'inst'","'".concat(l.id,"'"));if(l.length%o.SF_INSTRUMENT_HEADER_SIZE)throw new a.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 a=s("./src/chunks/instruments/headers.ts");s.d(r,"getInstrumentHeaders",(function(){return a.getInstrumentHeaders}))},"./src/chunks/modulators.ts":function(n,r,s){s.r(r),s.d(r,"getModulators",(function(){return l}));var a=s("./src/riff/index.ts"),o=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 a.ParseError("Unexpected chunk ID","'".concat(u,"'"),"'".concat(c.id,"'"));if(c.length%o.SF_MODULATOR_SIZE)throw new a.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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="phdr")throw new a.ParseError("Invalid chunk ID","'phdr'","'".concat(l.id,"'"));if(l.length%o.SF_PRESET_HEADER_SIZE)throw new a.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 a=s("./src/chunks/presets/headers.ts");s.d(r,"getPresetHeaders",(function(){return a.getPresetHeaders}))},"./src/chunks/samples/headers.ts":function(n,r,s){s.r(r),s.d(r,"getSampleHeaders",(function(){return i}));var a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="shdr")throw new a.ParseError("Unexpected chunk ID","'shdr'","'".concat(l.id,"'"));if(l.length%o.SF_SAMPLE_HEADER_SIZE)throw new a.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 a=s("./src/chunks/samples/headers.ts");s.d(r,"getSampleHeaders",(function(){return a.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 a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=s("./src/types/index.ts"),l=function(d,h){if(d.id!==h)throw new a.ParseError("Unexpected chunk ID","'".concat(h,"'"),"'".concat(d.id,"'"));if(d.length%o.SF_BAG_SIZE)throw new a.ParseError("Invalid size for the '".concat(h,"' sub-chunk"));return d.iterate((function(v){return{generatorIndex:v.getInt16(),modulatorIndex:v.getInt16()}}))},c=function(d,h,v,g,y,b){for(var w=[],_=0;_<d.length;_++){for(var x=d[_],S=d[_+1],k=x.bagIndex,E=S?S.bagIndex:h.length,I=[],M=void 0,T=k;T<E;T++){var A=u(T,h,v),$=f(T,h,g),R=$[i.GeneratorType.KeyRange]&&$[i.GeneratorType.KeyRange].range,F=$[b];if(F){var O=y[F.value];O&&I.push({keyRange:R,modulators:A,generators:$,reference:O})}else T-k==0&&(M={keyRange:R,modulators:A,generators:$})}w.push({header:x,globalZone:M,zones:I})}return w},u=function(d,h,v){var g=h[d],y=h[d+1],b=g.modulatorIndex,w=y?y.modulatorIndex:h.length;return p(b,w,v)},f=function(d,h,v){var g=h[d],y=h[d+1],b=g.generatorIndex,w=y?y.generatorIndex:h.length;return p(b,w,v)},p=function(d,h,v){for(var g={},y=d;y<h;y++){var b=v[y];b&&(g[b.id]=b)}return g}},"./src/constants.ts":function(n,r,s){s.r(r),s.d(r,"SF_VERSION_LENGTH",(function(){return a})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return o})),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 p}));var a=4,o=38,i=4,l=10,c=4,u=22,f=46,p=22050},"./src/index.ts":function(n,r,s){s.r(r);var a=s("./src/types/index.ts");for(var o in a)["default"].indexOf(o)<0&&(function(u){s.d(r,u,(function(){return a[u]}))})(o);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 a=s("./src/utils/index.ts");function o(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function i(u,f){for(var p=0;p<f.length;p++){var d=f[p];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,p){return f in u?Object.defineProperty(u,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):u[f]=p,u}var c=(function(){function u(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;o(this,u),l(this,"target",[]),l(this,"chunk",void 0),l(this,"position",0),this.chunk=d,this.position=h}var f,p;return f=u,(p=[{key:"iterate",value:function(d){for(;this.position<this.chunk.length;){var h=d(this);h&&this.target.push(h)}}},{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,h=Object(a.getStringFromBuffer)(this.getBuffer(this.position,d));return this.position+=d,h}},{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,h){return this.chunk.buffer.subarray(d,d+h)}},{key:"currentPosition",get:function(){return this.position}}])&&i(f.prototype,p),u})()},"./src/riff/index.ts":function(n,r,s){s.r(r);var a=s("./src/riff/chunkIterator.ts");s.d(r,"ChunkIterator",(function(){return a.ChunkIterator}));var o=s("./src/riff/parseError.ts");s.d(r,"ParseError",(function(){return o.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 a(d){return(a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h})(d)}function o(d,h){return!h||a(h)!=="object"&&typeof h!="function"?(function(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v})(d):h}function i(d){var h=typeof Map=="function"?new Map:void 0;return(i=function(v){if(v===null||(g=v,Function.toString.call(g).indexOf("[native code]")===-1))return v;var g;if(typeof v!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(v))return h.get(v);h.set(v,y)}function y(){return c(v,arguments,f(this).constructor)}return y.prototype=Object.create(v.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),u(y,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,h,v){return(c=l()?Reflect.construct:function(g,y,b){var w=[null];w.push.apply(w,y);var _=new(Function.bind.apply(g,w));return b&&u(_,b.prototype),_}).apply(null,arguments)}function u(d,h){return(u=Object.setPrototypeOf||function(v,g){return v.__proto__=g,v})(d,h)}function f(d){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(h){return h.__proto__||Object.getPrototypeOf(h)})(d)}s.r(r),s.d(r,"ParseError",(function(){return p}));var p=(function(d){function h(v,g,y){return(function(b,w){if(!(b instanceof w))throw new TypeError("Cannot call a class as a function")})(this,h),o(this,f(h).call(this,"".concat(v).concat(g&&y?", expected ".concat(g,", received ").concat(y):"")))}return(function(v,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(g&&g.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),g&&u(v,g)})(h,d),h})(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 p}));var a=s("./src/riff/parseError.ts"),o=s("./src/utils/buffer.ts"),i=s("./src/riff/riffChunk.ts"),l=function(d){var h=p(d);if(h!=="RIFF")throw new a.ParseError("Invalid file format","RIFF",h);var v=p(d,8);if(v!=="sfbk")throw new a.ParseError("Invalid signature","sfbk",v);var g=d.subarray(8),y=f(g.subarray(4));return new i.RIFFChunk(h,g.length,g,y)},c=function(d,h){var v=p(d,h),g=u(d,h+4),y=[];return v!=="RIFF"&&v!=="LIST"||(y=f(d.subarray(h+12))),new i.RIFFChunk(v,g,d.subarray(h+8),y)},u=function(d,h){return((d=d.subarray(h,h+4))[0]|d[1]<<8|d[2]<<16|d[3]<<24)>>>0},f=function(d){for(var h=[],v=0;v<=d.length-8;){var g=c(d,v);h.push(g),v=(v+=8+g.length)%2?v+1:v}return h},p=function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return Object(o.getStringFromBuffer)(d.subarray(h,h+4))}},"./src/riff/riffChunk.ts":function(n,r,s){s.r(r),s.d(r,"RIFFChunk",(function(){return c}));var a=s("./src/riff/chunkIterator.ts"),o=s("./src/utils/index.ts");function i(u,f){for(var p=0;p<f.length;p++){var d=f[p];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,p){return f in u?Object.defineProperty(u,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):u[f]=p,u}var c=(function(){function u(d,h,v,g){(function(y,b){if(!(y 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=h,this.buffer=v,this.subChunks=g}var f,p;return f=u,(p=[{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,h=arguments.length>1?arguments[1]:void 0;return Object(o.getStringFromBuffer)(this.getBuffer(d,h||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 a.ChunkIterator(this,d)}},{key:"iterate",value:function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,v=new a.ChunkIterator(this,h);return v.iterate(d),v.target}},{key:"getBuffer",value:function(d,h){return this.buffer.subarray(d,d+h)}}])&&i(f.prototype,p),u})()},"./src/soundFont2.ts":function(n,r,s){s.r(r),s.d(r,"SoundFont2",(function(){return h}));var a=s("./src/types/index.ts"),o=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 g=1;g<arguments.length;g++){var y=arguments[g]!=null?arguments[g]:{},b=Object.keys(y);typeof Object.getOwnPropertySymbols=="function"&&(b=b.concat(Object.getOwnPropertySymbols(y).filter((function(w){return Object.getOwnPropertyDescriptor(y,w).enumerable})))),b.forEach((function(w){d(v,w,y[w])}))}return v}function f(v,g){for(var y=0;y<g.length;y++){var b=g[y];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function p(v,g,y){return g&&f(v.prototype,g),y&&f(v,y),v}function d(v,g,y){return g in v?Object.defineProperty(v,g,{value:y,enumerable:!0,configurable:!0,writable:!0}):v[g]=y,v}var h=(function(){function v(g){if((function(b,w){if(!(b instanceof w))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),!(g instanceof o.SF2Chunk)){var y=Object(i.parseBuffer)(g);g=new o.SF2Chunk(y)}if(g.subChunks.length!==3)throw new i.ParseError("Invalid sfbk structure","3 chunks","".concat(g.subChunks.length," chunks"));this.chunk=g,this.metaData=g.subChunks[0].getMetaData(),this.sampleData=g.subChunks[1].getSampleData(),this.presetData=g.subChunks[2].getPresetData(),this.samples=this.getSamples(),this.instruments=this.getInstruments(),this.presets=this.getPresets(),this.banks=this.getBanks()}return p(v,null,[{key:"from",value:function(g){return new v(g)}}]),p(v,[{key:"getKeyData",value:function(g){var y=this,b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return Object(c.memoize)((function(_,x,S){var k=y.banks[x];if(k){var E=k.presets[S];if(E){var I=E.zones.filter((function(ne){return y.isKeyInRange(ne,_)}));if(I.length>0){var M=!0,T=!1,A=void 0;try{for(var $,R=I[Symbol.iterator]();!(M=($=R.next()).done);M=!0){var F=$.value,O=F.instrument,G=O.zones.filter((function(ne){return y.isKeyInRange(ne,_)}));if(G.length>0){var Q=!0,ee=!1,ue=void 0;try{for(var te,oe=G[Symbol.iterator]();!(Q=(te=oe.next()).done);Q=!0){var se=te.value,le=se.sample,ye=u({},F.generators,se.generators),de=u({},F.modulators,se.modulators);return{keyNumber:_,preset:E,instrument:O,sample:le,generators:ye,modulators:de}}}catch(ne){ee=!0,ue=ne}finally{try{Q||oe.return==null||oe.return()}finally{if(ee)throw ue}}}}}catch(ne){T=!0,A=ne}finally{try{M||R.return==null||R.return()}finally{if(T)throw A}}}}}return null}))(g,b,w)}},{key:"isKeyInRange",value:function(g,y){return g.keyRange===void 0||g.keyRange.lo<=y&&g.keyRange.hi>=y}},{key:"getBanks",value:function(){return this.presets.reduce((function(g,y){var b=y.header.bank;return g[b]||(g[b]={presets:[]}),g[b].presets[y.header.preset]=y,g}),[])}},{key:"getPresets",value:function(){var g=this.presetData,y=g.presetHeaders,b=g.presetZones,w=g.presetGenerators,_=g.presetModulators;return Object(l.getItemsInZone)(y,b,_,w,this.instruments,a.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 g=this.presetData,y=g.instrumentHeaders,b=g.instrumentZones,w=g.instrumentModulators,_=g.instrumentGenerators;return Object(l.getItemsInZone)(y,b,w,_,this.samples,a.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 g=this;return this.presetData.sampleHeaders.filter((function(y){return y.name!=="EOS"})).map((function(y){if(y.name!=="EOS"&&y.sampleRate<=0)throw new Error("Illegal sample rate of ".concat(y.sampleRate," hz in sample '").concat(y.name,"'"));return y.originalPitch>=128&&y.originalPitch<=254&&(y.originalPitch=60),y.startLoop-=y.start,y.endLoop-=y.start,{header:y,data:new Int16Array(new Uint8Array(g.sampleData.subarray(2*y.start,2*y.end)).buffer)}}))}}]),v})()},"./src/types/bank.ts":function(n,r){},"./src/types/generator.ts":function(n,r,s){var a,o;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 o})),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"})(o||(o={}));var l=(i(a={},o.StartAddrsOffset,0),i(a,o.EndAddrsOffset,0),i(a,o.StartLoopAddrsOffset,0),i(a,o.EndLoopAddrsOffset,0),i(a,o.StartAddrsCoarseOffset,0),i(a,o.ModLFOToPitch,0),i(a,o.VibLFOToPitch,0),i(a,o.ModEnvToPitch,0),i(a,o.InitialFilterFc,13500),i(a,o.InitialFilterQ,0),i(a,o.ModLFOToFilterFc,0),i(a,o.ModEnvToFilterFc,0),i(a,o.EndAddrsCoarseOffset,0),i(a,o.ModLFOToVolume,0),i(a,o.ChorusEffectsSend,0),i(a,o.ReverbEffectsSend,0),i(a,o.Pan,0),i(a,o.DelayModLFO,-12e3),i(a,o.FreqModLFO,0),i(a,o.DelayVibLFO,-12e3),i(a,o.FreqVibLFO,0),i(a,o.DelayModEnv,-12e3),i(a,o.AttackModEnv,-12e3),i(a,o.HoldModEnv,-12e3),i(a,o.DecayModEnv,-12e3),i(a,o.SustainModEnv,0),i(a,o.ReleaseModEnv,-12e3),i(a,o.KeyNumToModEnvHold,0),i(a,o.KeyNumToModEnvDecay,0),i(a,o.DelayVolEnv,-12e3),i(a,o.AttackVolEnv,-12e3),i(a,o.HoldVolEnv,-12e3),i(a,o.DecayVolEnv,-12e3),i(a,o.SustainVolEnv,0),i(a,o.ReleaseVolEnv,-12e3),i(a,o.KeyNumToVolEnvHold,0),i(a,o.KeyNumToVolEnvDecay,0),i(a,o.StartLoopAddrsCoarseOffset,0),i(a,o.KeyNum,-1),i(a,o.Velocity,-1),i(a,o.InitialAttenuation,0),i(a,o.EndLoopAddrsCoarseOffset,0),i(a,o.CoarseTune,0),i(a,o.FineTune,0),i(a,o.SampleModes,0),i(a,o.ScaleTuning,100),i(a,o.ExclusiveClass,0),i(a,o.OverridingRootKey,-1),a)},"./src/types/index.ts":function(n,r,s){s.r(r);var a=s("./src/types/bank.ts");for(var o in a)["default"].indexOf(o)<0&&(function(g){s.d(r,g,(function(){return a[g]}))})(o);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 o in l)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return l[y]}))})(o);var c=s("./src/types/key.ts");for(var o in c)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return c[y]}))})(o);var u=s("./src/types/metaData.ts");for(var o in u)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return u[y]}))})(o);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 p=s("./src/types/preset.ts");for(var o in p)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return p[y]}))})(o);var d=s("./src/types/presetData.ts");for(var o in d)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return d[y]}))})(o);var h=s("./src/types/sample.ts");s.d(r,"SampleType",(function(){return h.SampleType}));var v=s("./src/types/zone.ts");for(var o in v)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS","SampleType"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return v[y]}))})(o)},"./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 a})),s.d(r,"ControllerPolarity",(function(){return o})),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 p}));var a,o,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"})(a||(a={})),(function(d){d[d.Unipolar=0]="Unipolar",d[d.Bipolar=1]="Bipolar"})(o||(o={})),(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 p=[{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialFilterFc,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:-2400,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.ChannelPressure},value:50,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:1},value:50,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:7},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:l.MidiController,index:10},value:1e3,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:11},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ReverbEffectsSend,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:91},value:200,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ChorusEffectsSend,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:93},value:200,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.CoarseTune,source:{type:a.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheel},value:12700,valueSource:{type:a.Linear,polarity:o.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 a;s.r(r),s.d(r,"SampleType",(function(){return a})),(function(o){o[o.EOS=0]="EOS",o[o.Mono=1]="Mono",o[o.Right=2]="Right",o[o.Left=4]="Left",o[o.Linked=8]="Linked",o[o.RomMono=32769]="RomMono",o[o.RomRight=32770]="RomRight",o[o.RomLeft=32772]="RomLeft",o[o.RomLinked=32776]="RomLinked"})(a||(a={}))},"./src/types/zone.ts":function(n,r){},"./src/utils/buffer.ts":function(n,r,s){s.r(r),s.d(r,"getStringFromBuffer",(function(){return a}));var a=function(o){var i=new TextDecoder("utf8").decode(o),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 a=s("./src/utils/buffer.ts");s.d(r,"getStringFromBuffer",(function(){return a.getStringFromBuffer}));var o=s("./src/utils/memoize.ts");s.d(r,"memoize",(function(){return o.memoize}))},"./src/utils/memoize.ts":function(n,r,s){s.r(r),s.d(r,"memoize",(function(){return a}));var a=function(o){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 p=o.apply(void 0,c);return i[f]=p,p}}}})}))})(ia)),ia.exports}rh();var Le=1e3;function ka(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:p}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate,h=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(h===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??h;return{id:fc(),audioBuffer:t,startSample:n,durationSamples:v,offsetSamples:r,sampleRate:d,sourceDurationSamples:h,gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:p}}function uc(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:p}=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 h=t?.duration??e.sourceDuration??c?.duration;if(h===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??h;return ka({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(v*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(h*d),gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:p})}function dc(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:fc(),name:t,clips:n,muted:r,soloed:s,volume:a,pan:o,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}}function fc(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function ll(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function sh(e,t){return Math.floor(e/t)}function ah(e,t,n){return Math.ceil(e*n/t)}var Vn=192;function Bs(e,t=Vn){const[,n]=e;return t*(4/n)}function go(e,t=Vn){const[n]=e;return n*Bs(e,t)}function $n(e,t,n,r=Vn){return Math.round(e*60*n/(t*r))}function Ea(e,t,n,r=Vn){return Math.round(e*r*t/(60*n))}function Ia(e,t){return Math.round(e/t)*t}function oh(e,t,n=Vn){const r=go(t,n),s=Bs(t,n),a=Math.floor(e/r)+1,o=Math.floor(e%r/s)+1;return o===1?`${a}`:`${a}.${o}`}function Yr(e){return e.startSample/e.sampleRate}function cl(e){return(e.startSample+e.durationSamples)/e.sampleRate}function ul(e){return e.offsetSamples/e.sampleRate}function dl(e){return e.durationSamples/e.sampleRate}function hc(e,t,n){return Math.floor((e+t)/n)-Math.floor(e/n)}var fl=!1;function gr(e){const t=e._param;return!t&&!fl&&(fl=!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 hl(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 ih(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 lh(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 ch(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 pc(e,t,n){switch(e){case"linear":return hl(t,n);case"exponential":return ih(t,n);case"sCurve":return lh(t,n);case"logarithmic":return ch(t,n);default:return hl(t,n)}}function pl(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=pc(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 ml(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=pc(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 uh=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new L.Volume(this.gainToDb(e.track.gain)),this.panNode=new L.Panner(e.track.stereoPan),this.muteGain=new L.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||L.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=L.getTransport(),s=L.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=L.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)pl(a,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,c=o/i,u=r.gain*c;pl(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;ml(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,f=c/r.fadeOut.duration,p=r.gain*(1-f);ml(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;gr(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=L.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 dh(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 fh=class{constructor(e){this.track=e.track,this.volumeNode=new L.Volume(this.gainToDb(e.track.gain)),this.panNode=new L.Panner(e.track.stereoPan),this.muteGain=new L.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain),this.synth=new L.PolySynth(L.Synth,e.synthOptions),this.synth.connect(this.volumeNode),this.kickSynth=new L.PolySynth(L.MembraneSynth,{voice:L.MembraneSynth,options:{pitchDecay:.05,octaves:6,envelope:{attack:.001,decay:.4,sustain:0,release:.1}}}),this.snareSynth=new L.NoiseSynth({noise:{type:"white"},envelope:{attack:.001,decay:.15,sustain:0,release:.05}}),this.cymbalSynth=new L.PolySynth(L.MetalSynth,{voice:L.MetalSynth,options:{envelope:{attack:.001,decay:.3,release:.1},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5}}),this.tomSynth=new L.PolySynth(L.MembraneSynth,{voice:L.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||L.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,a=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}}),o=new L.Part((i,l)=>{l.duration>0&&this.triggerNote(l.midi,l.note,l.duration,i,l.velocity,l.channel)},a);return o.start(0),{clipInfo:n,part:o}})}triggerNote(e,t,n,r,s,a){if(a===9)switch(dh(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 a of n.notes){const o=a.time-n.offset,i=r+Math.max(0,o),l=i+a.duration;if(i<e&&l>e){const c=l-e;try{this.triggerNote(a.midi,a.name,c,t,a.velocity,a.channel)}catch(u){console.warn(`[waveform-playlist] Failed to start mid-clip MIDI note "${a.name}" on track "${this.id}":`,u)}}}}}stopAllSources(){const e=L.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;gr(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}},mc=class Ma{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 L.Volume(this.gainToDb(t.track.gain)),this.panNode=new L.Panner(t.track.stereoPan),this.muteGain=new L.Gain(t.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const n=t.destination||L.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}),a=this.track.startTime+r.startTime,o=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:a+u,note:l.name,midi:l.midi,duration:Math.max(0,f),velocity:l.velocity,channel:l.channel}}),i=new L.Part((l,c)=>{c.duration>0&&this.triggerNote(c.midi,c.duration,l,c.velocity,c.channel)},o);return i.start(0),{clipInfo:r,part:i}})}triggerNote(t,n,r,s,a){const o=a===9?128:this.bankNumber,i=a===9?0:this.programNumber,l=this.soundFontCache.getAudioBuffer(t,o,i);if(!l){Ma._missingSampleWarned||(console.warn(`[waveform-playlist] SoundFont sample not found for MIDI note ${t} (bank ${o}, preset ${i}). Subsequent missing samples will be silent.`),Ma._missingSampleWarned=!0);return}const c=L.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,p=l.loopMode===0?Math.max(n,f):n,d=s*s,h=c.createGain(),{attackVolEnv:v,holdVolEnv:g,decayVolEnv:y,sustainVolEnv:b,releaseVolEnv:w}=l,_=d*b;h.gain.setValueAtTime(0,r),h.gain.linearRampToValueAtTime(d,r+v),g>.001&&h.gain.setValueAtTime(d,r+v+g);const x=r+v+g;h.gain.linearRampToValueAtTime(_,x+y),h.gain.setValueAtTime(_,r+p),h.gain.linearRampToValueAtTime(0,r+p+w),u.connect(h),h.connect(this.volumeNode.input.input),this.activeSources.add(u),u.onended=()=>{this.activeSources.delete(u);try{h.disconnect()}catch(S){console.warn("[waveform-playlist] GainNode already disconnected:",S)}},u.start(r),u.stop(r+p+w)}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,a=s+r.duration;if(s<t&&a>t)for(const o of r.notes){const i=o.time-r.offset,l=s+Math.max(0,i),c=l+o.duration;if(l<t&&c>t){const u=c-t;try{this.triggerNote(o.midi,u,n,o.velocity,o.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;gr(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}};mc._missingSampleWarned=!1;var hh=mc,ph=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 L.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,L.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{L.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await L.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new uh(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 fh(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 hh(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??L.now(),s=L.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=L.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=L.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=>{try{t.stopAllSources()}catch(n){console.warn(`[waveform-playlist] Error stopping sources for track "${t.id}":`,n)}}),this.tracks.forEach(t=>{try{t.cancelFades()}catch(n){console.warn(`[waveform-playlist] Error canceling fades for track "${t.id}":`,n)}}),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=L.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=L.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 L.getTransport().seconds}seekTo(e){L.getTransport().seconds=e}dispose(){try{this.stop()}catch(e){console.warn("[waveform-playlist] Error stopping Transport during dispose:",e)}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 L.getContext()}get sampleRate(){return L.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Kr=null;function mh(){return Kr||(Kr=new L.Context,L.setContext(Kr)),Kr}function gh(){return mh().rawContext}function vh(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(f){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",f)}t=null}r++;const u=r;t=new ph({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 p=f.clips.filter(h=>h.audioBuffer&&!h.midiNotes),d=f.clips.filter(h=>h.midiNotes&&h.midiNotes.length>0);if(p.length>0){const h=Math.min(...p.map(Yr)),v=Math.max(...p.map(cl)),g={id:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:v},y=p.map(b=>({buffer:b.audioBuffer,startTime:Yr(b)-h,duration:dl(b),offset:ul(b),fadeIn:b.fadeIn,fadeOut:b.fadeOut,gain:b.gain}));t.addTrack({clips:y,track:g,effects:f.effects})}if(d.length>0){const h=Math.min(...d.map(Yr)),v=Math.max(...d.map(cl)),y={id:p.length>0?`${f.id}:midi`:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:v},b=d.map(w=>({notes:w.midiNotes,startTime:Yr(w)-h,duration:dl(w),offset:ul(w)}));if(e?.soundFontCache?.isLoaded){const w=d[0],x=w.midiChannel===9,S=w.midiProgram??0;t.addSoundFontTrack({clips:b,track:y,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:y,effects:f.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 f=u!==void 0?u-c:void 0;t.play(L.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,a=u,o=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 gc(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 vc(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 yh(e,t){return Math.floor(e/t)*t}function bh(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=ka({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=ka({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 yc(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 la(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 wh(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 gl(e,t){return Math.max(0,Math.min(e,t))}var _h=44100,xh=1024,Ch=[256,512,1024,2048,4096,8192],vl=.1,Sh=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??_h,this._zoomLevels=[...e.zoomLevels??Ch],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??xh,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:la(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=ll(r.clips),i=o.findIndex(c=>c.id===t),l=gc(a,n,o,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=c.clips.map((f,p)=>p===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 a=r.clips[s],o=Math.floor(vl*this._sampleRate);if(!yc(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}=bh(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(f=>f.id===e);if(!s){console.warn(`[waveform-playlist/engine] trimClip: track "${e}" not found`);return}const a=s.clips.findIndex(f=>f.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=ll(s.clips),l=i.findIndex(f=>f.id===t),c=Math.floor(vl*this._sampleRate),u=vc(o,r,n,i,l,c);u!==0&&(this._tracks=this._tracks.map(f=>{if(f.id!==e)return f;const p=f.clips.map((d,h)=>h!==a?d:n==="left"?{...d,startSample:d.startSample+u,offsetSamples:d.offsetSamples+u,durationSamples:d.durationSamples-u}:{...d,durationSamples:d.durationSamples+u});return{...f,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=la(this._tracks);this._currentTime=gl(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=la(this._tracks);this._currentTime=gl(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=wh(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)}},kh=Symbol.for("preact-signals");function Ws(){if(Xt>1)Xt--;else{for(var e,t=!1;ur!==void 0;){var n=ur;for(ur=void 0,Aa++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&wc(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(Aa=0,Xt--,t)throw e}}function Yt(e){if(Xt>0)return e();Xt++;try{return e()}finally{Ws()}}var ge=void 0;function we(e){var t=ge;ge=void 0;try{return e()}finally{ge=t}}var ur=void 0,Xt=0,Aa=0,ys=0;function bc(e){if(ge!==void 0){var t=e.n;if(t===void 0||t.t!==ge)return t={i:0,S:e,p:ge.s,n:void 0,t:ge,e:void 0,x:void 0,r:t},ge.s!==void 0&&(ge.s.n=t),ge.s=t,e.n=t,32&ge.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=ge.s,t.n=void 0,ge.s.n=t,ge.s=t),t}}function et(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}et.prototype.brand=kh;et.prototype.h=function(){return!0};et.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)}))};et.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)}))}};et.prototype.subscribe=function(e){var t=this;return wt(function(){var n=t.value,r=ge;ge=void 0;try{e(n)}finally{ge=r}},{name:"sub"})};et.prototype.valueOf=function(){return this.value};et.prototype.toString=function(){return this.value+""};et.prototype.toJSON=function(){return this.value};et.prototype.peek=function(){var e=ge;ge=void 0;try{return this.value}finally{ge=e}};Object.defineProperty(et.prototype,"value",{get:function(){var e=bc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Aa>100)throw new Error("Cycle detected");this.v=e,this.i++,ys++,Xt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Ws()}}}});function Ir(e,t){return new et(e,t)}function wc(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 _c(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 xc(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 fn(e,t){et.call(this,void 0),this.x=e,this.s=void 0,this.g=ys-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}fn.prototype=new et;fn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ys))return!0;if(this.g=ys,this.f|=1,this.i>0&&!wc(this))return this.f&=-2,!0;var e=ge;try{_c(this),ge=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 ge=e,xc(this),this.f&=-2,!0};fn.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)}et.prototype.S.call(this,e)};fn.prototype.U=function(e){if(this.t!==void 0&&(et.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)}};fn.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(fn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=bc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function yl(e,t){return new fn(e,t)}function Cc(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Xt++;var n=ge;ge=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,vo(e),r}finally{ge=n,Ws()}}}function vo(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(ge!==this)throw new Error("Out-of-order effect");xc(this),ge=e,this.f&=-2,8&this.f&&vo(this),Ws()}function Nn(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}Nn.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()}};Nn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Cc(this),_c(this),Xt++;var e=ge;return ge=this,Eh.bind(this,e)};Nn.prototype.N=function(){2&this.f||(this.f|=2,this.o=ur,ur=this)};Nn.prototype.d=function(){this.f|=8,1&this.f||vo(this)};Nn.prototype.dispose=function(){this.d()};function wt(e,t){var n=new Nn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Ih=Object.create,yo=Object.defineProperty,Mh=Object.defineProperties,Ah=Object.getOwnPropertyDescriptor,Th=Object.getOwnPropertyDescriptors,bl=Object.getOwnPropertySymbols,$h=Object.prototype.hasOwnProperty,Rh=Object.prototype.propertyIsEnumerable,Dh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),jn=e=>{throw TypeError(e)},Ta=(e,t,n)=>t in e?yo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ph=(e,t)=>{for(var n in t||(t={}))$h.call(t,n)&&Ta(e,n,t[n]);if(bl)for(var n of bl(t))Rh.call(t,n)&&Ta(e,n,t[n]);return e},Fh=(e,t)=>Mh(e,Th(t)),wl=(e,t)=>yo(e,"name",{value:t,configurable:!0}),Oh=e=>{var t;return[,,,Ih((t=void 0)!=null?t:null)]},Sc=["class","method","getter","setter","accessor","field","value","get","set"],Qn=e=>e!==void 0&&typeof e!="function"?jn("Function expected"):e,Lh=(e,t,n,r,s)=>({kind:Sc[e],name:t,metadata:r,addInitializer:a=>n._?jn("Already initialized"):s.push(Qn(a||null))}),kc=(e,t)=>Ta(t,Dh("metadata"),e[3]),en=(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},zn=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,p=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?p?1:2:0,v=Sc[f+5],g=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!p&&(s=s.prototype),f<5&&(f>3||!d)&&Ah(f<4?s:{get[n](){return ln(this,a)},set[n](_){return Ht(this,a,_)}},n));f?d&&f<4&&wl(a,(f>2?"set ":f>1?"get ":"")+n):wl(s,n);for(var w=r.length-1;w>=0;w--)c=Lh(f,n,l={},e[3],y),f&&(c.static=p,c.private=d,u=c.access={has:d?_=>Bh(s,_):_=>n in _},f^3&&(u.get=d?_=>(f^1?ln:Wh)(_,s,f^4?a:b.get):_=>_[n]),f>2&&(u.set=d?(_,x)=>Ht(_,s,x,f^4?a:b.set):(_,x)=>_[n]=x)),i=(0,r[w])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?Qn(i)&&(f>4?g.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?jn("Object expected"):(Qn(o=i.get)&&(b.get=o),Qn(o=i.set)&&(b.set=o),Qn(o=i.init)&&g.unshift(o));return f||kc(e,s),b&&yo(s,n,b),d?f^4?a:b:s},bo=(e,t,n)=>t.has(e)||jn("Cannot "+n),Bh=(e,t)=>Object(t)!==t?jn('Cannot use the "in" operator on this value'):e.has(t),ln=(e,t,n)=>(bo(e,t,"read from private field"),n?n.call(e):t.get(e)),qr=(e,t,n)=>t.has(e)?jn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ht=(e,t,n,r)=>(bo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Wh=(e,t,n)=>(bo(e,t,"access private method"),n);function bs(e,t){if(t){let n;return yl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return yl(e)}function vr(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)=>!vr(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=>!vr(e[a],t[a]))}return!1}function ce({get:e},t){return{init(n){return Ir(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=bs(e.bind(this)),n.set(this,r)),r.value}}function ca(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,Fh(Ph({},s),{enumerable:e}))})}}function Mr(...e){const t=e.map(n=>wt(n));return()=>t.forEach(n=>n())}var Ec,Ic,Mc,Ac,Tc,$c,qe,wo,ua,$a,Ra,Ye,_o,da,Rc,Da,xo,fa,Pa,Fa;$c=[ce],Tc=[ce],Ac=[ce],Mc=[ca()],Ic=[ca()],Ec=[ca()];var qt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,en(qe,5,this),qr(this,Ye),qr(this,wo,en(qe,8,this)),en(qe,11,this),qr(this,_o,en(qe,12,this)),en(qe,15,this),qr(this,xo,en(qe,16,this)),en(qe,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return ln(this,Ye,Pa)}get initial(){return ln(this,Ye,$a)}get previous(){return ln(this,Ye,Rc)}set current(e){const t=we(()=>ln(this,Ye,Pa));e&&t&&this.equals(t,e)||Yt(()=>{ln(this,Ye,$a)||Ht(this,Ye,e,Ra),Ht(this,Ye,t,Da),Ht(this,Ye,e,Fa)})}reset(e=this.defaultValue){Yt(()=>{Ht(this,Ye,void 0,Da),Ht(this,Ye,e,Ra),Ht(this,Ye,e,Fa)})}};qe=Oh();wo=new WeakMap;Ye=new WeakSet;_o=new WeakMap;xo=new WeakMap;ua=zn(qe,20,"#initial",$c,Ye,wo),$a=ua.get,Ra=ua.set;da=zn(qe,20,"#previous",Tc,Ye,_o),Rc=da.get,Da=da.set;fa=zn(qe,20,"#current",Ac,Ye,xo),Pa=fa.get,Fa=fa.set;zn(qe,2,"current",Mc,qt);zn(qe,2,"initial",Ic,qt);zn(qe,2,"previous",Ec,qt);kc(qe,qt);function ha(e){return we(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Vh=Object.create,Dc=Object.defineProperty,Nh=Object.getOwnPropertyDescriptor,_l=Object.getOwnPropertySymbols,jh=Object.prototype.hasOwnProperty,zh=Object.prototype.propertyIsEnumerable,Pc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Vs=e=>{throw TypeError(e)},xl=Math.pow,Oa=(e,t,n)=>t in e?Dc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zh=(e,t)=>{for(var n in t||(t={}))jh.call(t,n)&&Oa(e,n,t[n]);if(_l)for(var n of _l(t))zh.call(t,n)&&Oa(e,n,t[n]);return e},Hh=e=>{var t;return[,,,Vh((t=e?.[Pc("metadata")])!=null?t:null)]},Fc=["class","method","getter","setter","accessor","field","value","get","set"],Oc=e=>e!==void 0&&typeof e!="function"?Vs("Function expected"):e,Gh=(e,t,n,r,s)=>({kind:Fc[e],name:t,metadata:r,addInitializer:a=>n._?Vs("Already initialized"):s.push(Oc(a||null))}),Uh=(e,t)=>Oa(t,Pc("metadata"),e[3]),Xh=(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},Lc=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,p=!1,d=2,h=Fc[u+5],v=e[d]||(e[d]=[]),g=(s=s.prototype,Nh(s,n)),y=r.length-1;y>=0;y--)l=Gh(u,n,i={},e[3],v),l.static=f,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(g[h],l),i._=1,Oc(o)&&(g[h]=o);return g&&Dc(s,n,g),s},Bc=(e,t,n)=>t.has(e)||Vs("Cannot "+n),Yh=(e,t,n)=>(Bc(e,t,"read from private field"),t.get(e)),Kh=(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),qh=(e,t,n,r)=>(Bc(e,t,"write to private field"),t.set(e,n),n),Tt=class La{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new La(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 La(t,n)}},Ar=class nn{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 nn(s+t,r+n,a,o);return l.scale=Zh({},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 nn))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 nn?Jh(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 nn(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 nn.from(t).intersectionRatio(nn.from(n))}};function Jh(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 Wc,Vc,Ba,as,Tr,Ns=class extends(Ba=qt,Vc=[Ae],Wc=[Ae],Ba){constructor(t){const n=Tt.from(t);super(n,(r,s)=>Tt.equals(r,s)),Xh(Tr,5,this),Kh(this,as,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-Yh(this,as),i=l=>Math.round(l/o*100);Yt(()=>{qh(this,as,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}}};Tr=Hh(Ba);as=new WeakMap;Lc(Tr,2,"delta",Vc,Ns);Lc(Tr,2,"direction",Wc,Ns);Uh(Tr,Ns);function Wa({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(xl(r,2)+xl(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 Nc=(e=>(e.Horizontal="x",e.Vertical="y",e))(Nc||{}),jc=Object.values(Nc),Qh=Object.create,Co=Object.defineProperty,ep=Object.defineProperties,tp=Object.getOwnPropertyDescriptor,np=Object.getOwnPropertyDescriptors,ws=Object.getOwnPropertySymbols,zc=Object.prototype.hasOwnProperty,Zc=Object.prototype.propertyIsEnumerable,Hc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},Va=(e,t,n)=>t in e?Co(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gc=(e,t)=>{for(var n in t||(t={}))zc.call(t,n)&&Va(e,n,t[n]);if(ws)for(var n of ws(t))Zc.call(t,n)&&Va(e,n,t[n]);return e},Uc=(e,t)=>ep(e,np(t)),Cl=(e,t)=>Co(e,"name",{value:t,configurable:!0}),Xc=(e,t)=>{var n={};for(var r in e)zc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ws)for(var r of ws(e))t.indexOf(r)<0&&Zc.call(e,r)&&(n[r]=e[r]);return n},Hn=e=>{var t;return[,,,Qh((t=e?.[Hc("metadata")])!=null?t:null)]},Yc=["class","method","getter","setter","accessor","field","value","get","set"],er=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,rp=(e,t,n,r,s)=>({kind:Yc[e],name:t,metadata:r,addInitializer:a=>n._?Zn("Already initialized"):s.push(er(a||null))}),hn=(e,t)=>Va(t,Hc("metadata"),e[3]),K=(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},ie=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,p=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?p?1:2:0,v=Yc[f+5],g=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!p&&(s=s.prototype),f<5&&(f>3||!d)&&tp(f<4?s:{get[n](){return Ne(this,a)},set[n](_){return vt(this,a,_)}},n));f?d&&f<4&&Cl(a,(f>2?"set ":f>1?"get ":"")+n):Cl(s,n);for(var w=r.length-1;w>=0;w--)c=rp(f,n,l={},e[3],y),f&&(c.static=p,c.private=d,u=c.access={has:d?_=>sp(s,_):_=>n in _},f^3&&(u.get=d?_=>(f^1?Ne:ap)(_,s,f^4?a:b.get):_=>_[n]),f>2&&(u.set=d?(_,x)=>vt(_,s,x,f^4?a:b.set):(_,x)=>_[n]=x)),i=(0,r[w])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?er(i)&&(f>4?g.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?Zn("Object expected"):(er(o=i.get)&&(b.get=o),er(o=i.set)&&(b.set=o),er(o=i.init)&&g.unshift(o));return f||hn(e,s),b&&Co(s,n,b),d?f^4?a:b:s},So=(e,t,n)=>t.has(e)||Zn("Cannot "+n),sp=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),Ne=(e,t,n)=>(So(e,t,"read from private field"),n?n.call(e):t.get(e)),be=(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),vt=(e,t,n,r)=>(So(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ap=(e,t,n)=>(So(e,t,"access private method"),n);function Kc(e,t){return{plugin:e,options:t}}function pn(e){return t=>Kc(e,t)}function ko(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var qc,yr,Eo,os;qc=[ce];var lt=class{constructor(e,t){this.manager=e,this.options=t,be(this,Eo,K(yr,8,this,!1)),K(yr,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=wt(e.bind(this));return Ne(this,os).add(t),t}destroy(){Ne(this,os).forEach(e=>e())}static configure(e){return Kc(this,e)}};yr=Hn(null);Eo=new WeakMap;os=new WeakMap;ie(yr,4,"disabled",qc,lt,Eo);hn(yr,lt);var $r=class extends lt{},is,pa=class{constructor(e){this.manager=e,this.instances=new Map,be(this,is,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(ko).reduceRight((r,s)=>r.some(({plugin:a})=>a===s.plugin)?r:[s,...r],[]),n=t.map(({plugin:r})=>r);for(const r of Ne(this,is))if(!n.includes(r)){if(r.prototype instanceof $r)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);vt(this,is,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()}};is=new WeakMap;function op(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=[],kn,En,ip=class extends lt{constructor(e){super(e),be(this,kn),be(this,En),this.computeCollisions=this.computeCollisions.bind(this),vt(this,En,Ir(Jr)),this.destroy=Mr(()=>{const t=this.computeCollisions(),n=we(()=>this.manager.dragOperation.position.current);if(t!==Jr){const r=Ne(this,kn);if(vt(this,kn,n),r&&n.x==r.x&&n.y==r.y)return}else vt(this,kn,void 0);Ne(this,En).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){we(()=>{e?Ne(this,En).value=this.computeCollisions():vt(this,kn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:a,status:o}=r;if(!o.initialized||!a)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(op),i)}get collisions(){return Ne(this,En).value}};kn=new WeakMap;En=new WeakMap;var lp=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)}},cp=class extends lp{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ls(e,t=!0){let n=!1;return Uc(Gc({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var up=class extends $r{constructor(e){super(e);const t=(r,s)=>r.map(({id:a})=>a).join("")===s.map(({id:a})=>a).join("");let n=[];this.destroy=Mr(()=>{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=ls({collisions:a});if(s.dispatch("collision",o),o.defaultPrevented||t(a,n))return;n=a;const[i]=a;we(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},Io=(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))(Io||{}),Mo=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Mo||{}),Jc,Qc,eu,tu,nu,ru,su,bt,Ao;su=[ce],ru=[Ae],nu=[Ae],tu=[Ae],eu=[Ae],Qc=[Ae],Jc=[Ae];var Wt=class{constructor(){K(bt,5,this),be(this,Ao,K(bt,8,this,"idle")),K(bt,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}};bt=Hn(null);Ao=new WeakMap;ie(bt,4,"value",su,Wt,Ao);ie(bt,2,"current",ru,Wt);ie(bt,2,"idle",nu,Wt);ie(bt,2,"initializing",tu,Wt);ie(bt,2,"initialized",eu,Wt);ie(bt,2,"dragging",Qc,Wt);ie(bt,2,"dropped",Jc,Wt);hn(bt,Wt);var dp=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=ls({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:a}=e;Yt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(a)});const o=ls({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 we(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:a}=r;if(!s.dragging||!a||a.signal.aborted)return;const o=ls({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,f;if(o.defaultPrevented)return;const p=(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=p})})}stop(e={}){return we(()=>{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=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=wt(()=>{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:o}),a?a.then(i).catch(()=>r.reset()):i()})}},au,ou,iu,lu,it,To,$o,Ro,Do;lu=[ce],iu=[ce],ou=[ce],au=[ce];var Jt=class{constructor(e,t){be(this,To,K(it,8,this)),K(it,11,this),be(this,$o,K(it,12,this)),K(it,15,this),be(this,Ro,K(it,16,this)),K(it,19,this),be(this,Do,K(it,20,this)),K(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=Hn(null);To=new WeakMap;$o=new WeakMap;Ro=new WeakMap;Do=new WeakMap;ie(it,4,"manager",lu,Jt,To);ie(it,4,"id",iu,Jt,$o);ie(it,4,"data",ou,Jt,Ro);ie(it,4,"disabled",au,Jt,Do);hn(it,Jt);var Sl=class{constructor(){this.map=Ir(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=Mr(...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}},cu,uu,du,fu,hu,pu,Na,Je,Po,Fo,Oo,$t=class extends(Na=Jt,pu=[ce],hu=[ce],fu=[ce],du=[Ae],uu=[Ae],cu=[Ae],Na){constructor(t,n){var r=t,{modifiers:s,type:a,sensors:o}=r,i=Xc(r,["modifiers","type","sensors"]);super(i,n),K(Je,5,this),be(this,Po,K(Je,8,this)),K(Je,11,this),be(this,Fo,K(Je,12,this)),K(Je,15,this),be(this,Oo,K(Je,16,this,this.isDragSource?"dragging":"idle")),K(Je,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}};Je=Hn(Na);Po=new WeakMap;Fo=new WeakMap;Oo=new WeakMap;ie(Je,4,"type",pu,$t,Po);ie(Je,4,"modifiers",hu,$t,Fo);ie(Je,4,"status",fu,$t,Oo);ie(Je,2,"isDropping",du,$t);ie(Je,2,"isDragging",uu,$t);ie(Je,2,"isDragSource",cu,$t);hn(Je,$t);var mu,gu,vu,yu,bu,wu,ja,We,Lo,Bo,Wo,Vo,No,Rt=class extends(ja=Jt,wu=[ce],bu=[ce],yu=[ce],vu=[ce],gu=[ce],mu=[Ae],ja){constructor(t,n){var r=t,{accept:s,collisionDetector:a,collisionPriority:o,type:i}=r,l=Xc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),K(We,5,this),be(this,Lo,K(We,8,this)),K(We,11,this),be(this,Bo,K(We,12,this)),K(We,15,this),be(this,Wo,K(We,16,this)),K(We,19,this),be(this,Vo,K(We,20,this)),K(We,23,this),be(this,No,K(We,24,this)),K(We,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}};We=Hn(ja);Lo=new WeakMap;Bo=new WeakMap;Wo=new WeakMap;Vo=new WeakMap;No=new WeakMap;ie(We,4,"accept",wu,Rt,Lo);ie(We,4,"type",bu,Rt,Bo);ie(We,4,"collisionDetector",yu,Rt,Wo);ie(We,4,"collisionPriority",vu,Rt,Vo);ie(We,4,"shape",gu,Rt,No);ie(We,2,"isDropTarget",mu,Rt);hn(We,Rt);var Pn=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},fp=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)}},cs,_u=class{constructor(e){this.options=e,be(this,cs)}set controller(e){vt(this,cs,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ne(this,cs))==null||t.activate(e)}};cs=new WeakMap;var Fn=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},hp=class{constructor(e){this.draggables=new Sl,this.droppables=new Sl,this.plugins=new pa(e),this.sensors=new pa(e),this.modifiers=new pa(e)}register(e,t){if(e instanceof $t)return this.draggables.register(e.id,e);if(e instanceof Rt)return this.droppables.register(e.id,e);if(e.prototype instanceof Fn)return this.modifiers.register(e,t);if(e.prototype instanceof Pn)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 Jt)return e instanceof $t?this.draggables.unregister(e.id,e):e instanceof Rt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Fn)return this.modifiers.unregister(e);if(e.prototype instanceof Pn)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()}},xu,Cu,Su,ku,Eu,Iu,Mu,Au,Tu,tr,us,In,De,jo,zo,Zo,Ho,Go,nr;Tu=[Ae],Au=[ce],Mu=[ce],Iu=[ce],Eu=[ce],ku=[ce],Su=[Ae],Cu=[Ae],xu=[Ae];var It=class{constructor(e){K(De,5,this),be(this,tr),be(this,us),be(this,In,new qt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Wt,be(this,jo,K(De,8,this,!1)),K(De,11,this),be(this,zo,K(De,12,this,null)),K(De,15,this),be(this,Zo,K(De,16,this,null)),K(De,19,this),be(this,Ho,K(De,20,this,null)),K(De,23,this),be(this,Go,K(De,24,this,[])),K(De,27,this),this.position=new Ns({x:0,y:0}),be(this,nr,{x:0,y:0}),vt(this,tr,e)}get shape(){const{current:e,initial:t,previous:n}=Ne(this,In);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ne(this,In).current=e:Ne(this,In).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ne(this,tr).registry.draggables.get(t);return n&&vt(this,us,n),(e=n??Ne(this,us))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ne(this,tr).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(Uc(Gc({},this.snapshot()),{transform:n}));return vt(this,nr,n),n}snapshot(){return we(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ne(this,nr),shape:this.shape?ha(this.shape):null,position:ha(this.position),status:ha(this.status),canceled:this.canceled}))}reset(){Yt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ne(this,In).reset(),this.position.reset({x:0,y:0}),vt(this,nr,{x:0,y:0}),this.modifiers=[]})}};De=Hn(null);tr=new WeakMap;us=new WeakMap;In=new WeakMap;jo=new WeakMap;zo=new WeakMap;Zo=new WeakMap;Ho=new WeakMap;Go=new WeakMap;nr=new WeakMap;ie(De,2,"shape",Tu,It);ie(De,4,"canceled",Au,It,jo);ie(De,4,"activatorEvent",Mu,It,zo);ie(De,4,"sourceIdentifier",Iu,It,Zo);ie(De,4,"targetIdentifier",Eu,It,Ho);ie(De,4,"modifiers",ku,It,Go);ie(De,2,"source",Su,It);ie(De,2,"target",Cu,It);ie(De,2,"transform",xu,It);hn(De,It);var pp={get rendering(){return Promise.resolve()}};function Ot(e,t){return typeof e=="function"?e(t):e??t}var mp=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=Ot(r.plugins,[]),a=Ot(r.sensors,[]),o=Ot(r.modifiers,[]),i=(n=r.renderer)!=null?n:pp,l=new cp(this),c=new hp(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new dp(this),this.dragOperation=new It(this),this.collisionObserver=new ip(this),this.plugins=[up,...s],this.modifiers=o,this.sensors=a;const{destroy:u}=this,f=Mr(()=>{var p,d,h;const v=we(()=>this.dragOperation.modifiers),g=this.modifiers;for(const y of v)g.includes(y)||y.destroy();this.dragOperation.modifiers=(h=(d=(p=this.dragOperation.source)==null?void 0:p.modifiers)==null?void 0:d.map(y=>{const{plugin:b,options:w}=ko(y);return new b(this,w)}))!=null?h:g});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}},$u=e=>{throw TypeError(e)},Uo=(e,t,n)=>t.has(e)||$u("Cannot "+n),J=(e,t,n)=>(Uo(e,t,"read from private field"),t.get(e)),ot=(e,t,n)=>t.has(e)?$u("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ht=(e,t,n,r)=>(Uo(e,t,"write to private field"),t.set(e,n),n),Ru=(e,t,n)=>(Uo(e,t,"access private method"),n);function js(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function gp(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=(js(s)?s.getKeyframes():[]).filter(t);if(o.length>0)return[o[o.length-1],r]}return null}function zs(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 Xo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Rr(e){return"nodeType"in e}function _t(e){var t,n,r;return e?Xo(e)?e:Rr(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 Yo(e){const{Document:t}=_t(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function cn(e){return!e||Xo(e)?!1:e instanceof _t(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Du(e){return e instanceof _t(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function mn(e){return e?Xo(e)?e.document:Rr(e)?Yo(e)?e:cn(e)||Du(e)?e.ownerDocument:document:document:document}function vp(e){var t,n,r,s;const{documentElement:a}=mn(e),o=_t(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 yp(e,t){if(bp(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function bp(e){return e.tagName==="DETAILS"}function _s(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 f=e.parentElement;for(;f&&f!==c.documentElement;){if(!yp(f)){const w=f.getBoundingClientRect(),_=n*(w.bottom-w.top),x=n*(w.right-w.left),S=n*(w.bottom-w.top),k=n*(w.right-w.left);l={top:Math.max(l.top,w.top-_),right:Math.min(l.right,w.right+x),bottom:Math.min(l.bottom,w.bottom+S),left:Math.max(l.left,w.left-k),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}f=f.parentElement}const p=u.visualViewport,d=(s=p?.offsetTop)!=null?s:0,h=(a=p?.offsetLeft)!=null?a:0,v=(o=p?.width)!=null?o:u.innerWidth,g=(i=p?.height)!=null?i:u.innerHeight,y=n*g,b=n*v;return l={top:Math.max(l.top,d-y),right:Math.min(l.right,h+v+b),bottom:Math.min(l.bottom,d+g+y),left:Math.max(l.left,h-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 On(e){return{x:e.clientX,y:e.clientY}}var Pu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function za(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(...za(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(...za(s.document,t))}}catch{}return n}function Ko(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Fu(){var e,t;const n=Ko()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function qo(e){return!e||!Rr(e)?!1:e instanceof _t(e).ShadowRoot}function xs(e){if(e&&Rr(e)){let t=e.getRootNode();if(qo(t))return t;if(t instanceof Document)return t}return mn(e)}function Ou(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function wp(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(kl(a)&&kl(i)&&(a.type!=="file"&&(a.value=i.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),El(a)&&El(i)&&i.width>0&&i.height>0){const l=a.getContext("2d");l?.drawImage(i,0,0)}}),n}function kl(e){return"value"in e}function El(e){return e.tagName==="CANVAS"}function Lu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(_p(r)){const{contentDocument:s}=r;if(s){const{left:a,top:o}=r.getBoundingClientRect();return Lu(s,{x:t-a,y:n-o})}}return r}function _p(e){return e?.tagName==="IFRAME"}var Il=new WeakMap;function xp(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 Bu=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 Bn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Cp(e){const t=new Set;let n=Bn(e);for(;n;)t.add(n),n=Bn(n);return t}function Sp(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Wu(e,t){const n=()=>performance.now();let r,s;return function(...a){const o=this;s?(r?.(),r=Sp(()=>{e.apply(o,a),s=n()},t-(n()-s))):(e.apply(o,a),s=n())}}function kp(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}=Ss(e,t);return n>0&&r>0}var Ip=Pu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ps,Mp=class extends Ip{constructor(e){super(t=>{if(!ie(this,ps)){pt(this,ps,!0);return}e(t,this)}),ct(this,ps,!1)}};ps=new WeakMap;var Ml=Array.from({length:100},(e,t)=>t/100),Vu=75,an,Es,Zt,on,ar,Ke,hr,or,Is,Nu,zu,ju=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ct(this,Is),this.disconnect=()=>{var a,o,i;pt(this,hr,!0),(a=ie(this,Zt))==null||a.disconnect(),(o=ie(this,on))==null||o.disconnect(),ie(this,ar).disconnect(),(i=ie(this,Ke))==null||i.remove()},ct(this,an,!0),ct(this,Es),ct(this,Zt),ct(this,on),ct(this,ar),ct(this,Ke),ct(this,hr,!1),ct(this,or,Wu(()=>{var a,o,i;const{element:l}=this;if((a=ie(this,on))==null||a.disconnect(),ie(this,hr)||!ie(this,an)||!l.isConnected)return;const c=(o=l.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:f}=(i=c.defaultView)!=null?i:window,m=l.getBoundingClientRect(),d=Ss(l,m),{top:h,left:v,bottom:g,right:y}=d,b=-Math.floor(h),_=-Math.floor(v),w=-Math.floor(f-y),x=-Math.floor(u-g),S=`${b}px ${w}px ${x}px ${_}px`;this.boundingClientRect=m,pt(this,on,new IntersectionObserver(k=>{const[E]=k,{intersectionRect:M}=E;(E.intersectionRatio!==1?E.intersectionRatio:$r.intersectionRatio(M,Ss(l)))!==1&&ie(this,or).call(this)},{threshold:Ml,rootMargin:S,root:c})),ie(this,on).observe(l),Ru(this,Is,Nu).call(this)},Vu)),this.boundingClientRect=e.getBoundingClientRect(),pt(this,an,Ep(e,this.boundingClientRect));let r=!0;this.callback=a=>{r&&(r=!1,n.skipInitial)||t(a)};const s=e.ownerDocument;n?.debug&&(pt(this,Ke,document.createElement("div")),ie(this,Ke).style.background="rgba(0,0,0,0.15)",ie(this,Ke).style.position="fixed",ie(this,Ke).style.pointerEvents="none",s.body.appendChild(ie(this,Ke))),pt(this,ar,new IntersectionObserver(a=>{var o,i;const l=a[a.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:f,height:m}=c,d=ie(this,an);pt(this,an,u),!(!f&&!m)&&(d&&!u?((o=ie(this,on))==null||o.disconnect(),this.callback(null),(i=ie(this,Zt))==null||i.disconnect(),pt(this,Zt,void 0),ie(this,Ke)&&(ie(this,Ke).style.visibility="hidden")):ie(this,or).call(this),u&&!ie(this,Zt)&&(pt(this,Zt,new Mp(ie(this,or))),ie(this,Zt).observe(e)))},{threshold:Ml,root:s})),ie(this,an)&&!n.skipInitial&&this.callback(this.boundingClientRect),ie(this,ar).observe(e)}};an=new WeakMap;Es=new WeakMap;Zt=new WeakMap;on=new WeakMap;ar=new WeakMap;Ke=new WeakMap;hr=new WeakMap;or=new WeakMap;Is=new WeakSet;Nu=function(){ie(this,hr)||(Ru(this,Is,zu).call(this),!kp(this.boundingClientRect,ie(this,Es))&&(this.callback(this.boundingClientRect),pt(this,Es,this.boundingClientRect)))};zu=function(){if(ie(this,Ke)){const{top:e,left:t,width:n,height:r}=Ss(this.element);ie(this,Ke).style.overflow="hidden",ie(this,Ke).style.visibility="visible",ie(this,Ke).style.top=`${Math.floor(e)}px`,ie(this,Ke).style.left=`${Math.floor(t)}px`,ie(this,Ke).style.width=`${Math.floor(n)}px`,ie(this,Ke).style.height=`${Math.floor(r)}px`}};var ns=new WeakMap,rs=new WeakMap;function Ap(e,t){let n=ns.get(e);return n||(n={disconnect:new ju(e,s=>{const a=ns.get(e);a&&a.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),ns.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(ns.delete(e),n.disconnect())}}function Tp(e,t){const n=new Set;for(const r of e){const s=Ap(r,t);n.add(s)}return()=>n.forEach(r=>r())}function $p(e,t){var n;const r=e.ownerDocument;if(!rs.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}),rs.set(r,{disconnect:()=>o.abort(),listeners:i})}const{listeners:s,disconnect:a}=(n=rs.get(r))!=null?n:{};return!s||!a?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(a(),rs.delete(r))})}var ir,lr,ms,Ua,Rp=class{constructor(e,t,n){this.callback=t,ct(this,ir),ct(this,lr,!1),ct(this,ms),ct(this,Ua,Wu(o=>{if(!ie(this,lr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const i of ie(this,ms))if(o.target.contains(i)){this.callback(ie(this,ir).boundingClientRect);break}}},Vu));const r=Cp(e),s=Tp(r,t),a=$p(e,ie(this,Ua));pt(this,ms,r),pt(this,ir,new ju(e,t,n)),this.disconnect=()=>{ie(this,lr)||(pt(this,lr,!0),s(),a(),ie(this,ir).disconnect())}}};ir=new WeakMap;lr=new WeakMap;ms=new WeakMap;Ua=new WeakMap;function Xa(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function _r(e){try{Xa(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function Al(e){return!Pu||!e?!1:e===vn(e).scrollingElement}function Zu(e){var t,n;const r=xt(e),s=Al(e)?vp(e):Gs(e),a=r.visualViewport,o=Al(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,f=i.current.x>=i.max.x;return{rect:s,position:i,isTop:l,isLeft:c,isBottom:u,isRight:f}}function Dp(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:a,position:o}=Zu(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,f=!s&&o.current.x+i>0,m=!a&&o.current.x+i<o.max.x;return{top:c,bottom:u,left:f,right:m,x:f||m,y:c||u}}var ti=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))}},Ms=new ti(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Pp=new ti(e=>setTimeout(e,50)),As=new Map,Fp=As.clear.bind(As);function Nt(e,t=!1){if(!t)return Tl(e);let n=As.get(e);return n||(n=Tl(e),As.set(e,n),Pp.schedule(Fp),n)}function Tl(e){return xt(e).getComputedStyle(e)}function Op(e,t=Nt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Lp(e,t=Nt(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 Bp={excludeElement:!0,escapeShadowDOM:!0};function Ya(e,t=Bp){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,a=new Set;function o(i){if(n!=null&&a.size>=n||!i)return a;if(Jo(i)&&i.scrollingElement!=null&&!a.has(i.scrollingElement))return a.add(i.scrollingElement),a;if(s&&ei(i))return o(i.host);if(!dn(i))return Du(i)?o(i.parentElement):a;if(a.has(i))return a;const l=Nt(i,!0);if(r&&i===e||Lp(i,l)&&a.add(i),Op(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&a.add(c),a}return o(i.parentNode)}return e?o(e):a}function Wp(e){const[t]=Ya(e,{limit:1});return t??null}function Wn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Bn(e);for(;r;){if(r===t)return n;const s=Gs(r),{x:a,y:o}=Vp(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=Bn(r)}return n}function Vp(e,t=Gs(e)){const n=Math.round(t.width),r=Math.round(t.height);if(dn(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=Nt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function Np(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 ni(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 ri(e){var t,n,r,s,a,o,i,l,c;const{scale:u,transform:f,translate:m}=e,d=Np(u),h=ni(m),v=zp(f);if(!v&&!d&&!h)return null;const g={x:(t=d?.x)!=null?t:1,y:(n=d?.y)!=null?n:1},y={x:(r=h?.x)!=null?r:0,y:(s=h?.y)!=null?s:0},b={x:(a=v?.x)!=null?a:0,y:(o=v?.y)!=null?o:0,scaleX:(i=v?.scaleX)!=null?i:1,scaleY:(l=v?.scaleY)!=null?l:1};return{x:y.x+b.x,y:y.y+b.y,z:(c=h?.z)!=null?c:0,scaleX:g.x*b.scaleX,scaleY:g.y*b.scaleY}}function zp(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 bt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(bt||{}),jp={x:.2,y:.2},Zp={x:10,y:10};function Hp(e,t,n,r=25,s=jp,a=Zp){const{x:o,y:i}=t,{rect:l,isTop:c,isBottom:u,isLeft:f,isRight:m}=Zu(e),d=Wn(e),h=Nt(e,!0),v=ri(h),g=v!==null?v?.scaleX<0:!1,y=v!==null?v?.scaleY<0:!1,b=new $r(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||y&&!u)&&i<=b.top+x.height&&n?.y!==1&&o>=b.left-a.x&&o<=b.right+a.x?(_.y=y?1:-1,w.y=r*Math.abs((b.top+x.height-i)/x.height)):(!u||y&&!c)&&i>=b.bottom-x.height&&n?.y!==-1&&o>=b.left-a.x&&o<=b.right+a.x&&(_.y=y?-1:1,w.y=r*Math.abs((b.bottom-x.height-i)/x.height)),(!m||g&&!f)&&o>=b.right-x.width&&n?.x!==-1&&i>=b.top-a.y&&i<=b.bottom+a.y?(_.x=g?-1:1,w.x=r*Math.abs((b.right-x.width-o)/x.width)):(!f||g&&!m)&&o<=b.left+x.width&&n?.x!==1&&i>=b.top-a.y&&i<=b.bottom+a.y&&(_.x=g?1:-1,w.x=r*Math.abs((b.left+x.width-o)/x.width)),{direction:_,speed:w}}function Gp(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function Up(e,t=!1){if(Gp(e)){e.scrollIntoViewIfNeeded(t);return}if(!dn(e))return e.scrollIntoView();var n=Wp(e);if(!dn(n))return;const r=Nt(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 Xp(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 Yp(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 Kp({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var qp=new ti(e=>setTimeout(e,0)),pr=new Map,Jp=pr.clear.bind(pr);function Qp(e){const t=e.ownerDocument;let n=pr.get(t);if(n)return n;n=t.getAnimations(),pr.set(t,n),qp.schedule(Jp);const r=n.filter(s=>Hs(s.effect)&&s.effect.target===e);return pr.set(e,r),n}function em(e,t){const n=Qp(e).filter(r=>{var s,a;if(Hs(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 Bt=class extends $r{constructor(e,t={}){var n,r,s,a;const{frameTransform:o=Wn(e),ignoreTransforms:i,getBoundingClientRect:l=Gs}=t,c=em(e,{properties:["transform","translate","scale","width","height"],isValidTarget:x=>(x!==e||Qo())&&x.contains(e)}),u=l(e);let{top:f,left:m,width:d,height:h}=u,v;const g=Nt(e),y=ri(g),b={x:(n=y?.scaleX)!=null?n:1,y:(r=y?.scaleY)!=null?r:1},_=tm(e,g);c?.(),y&&(v=Yp(u,y,g.transformOrigin),(i||_)&&(f=v.top,m=v.left,d=v.width,h=v.height));const w={width:(s=v?.width)!=null?s:d,height:(a=v?.height)!=null?a:h};if(_&&!i&&v){const x=Xp(v,_,g.transformOrigin);f=x.top,m=x.left,d=x.width,h=x.height,b.x=_.scaleX,b.y=_.scaleY}o&&(i||(m*=o.scaleX,d*=o.scaleX,f*=o.scaleY,h*=o.scaleY),m+=o.x,f+=o.y),super(m,f,d,h),this.scale=b,this.intrinsicWidth=w.width,this.intrinsicHeight=w.height}};function tm(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=Hs(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 f=ri({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 mr(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 nm=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(mr(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(mr(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(mr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function fn(e){return e?e instanceof xt(e).Element||Pr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function si(e){if(!e)return!1;const{KeyboardEvent:t}=xt(e.target);return e instanceof t}function rm(e){if(!e)return!1;const{PointerEvent:t}=xt(e.target);return e instanceof t}function sm(e){if(!fn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||am(e)}function am(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var ya={};function Ka(e){const t=ya[e]==null?0:ya[e]+1;return ya[e]=t,`${e}-${t}`}var om=({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:$o.PointerIntersection,priority:To.High}}return null},im=({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:$o.ShapeIntersection,priority:To.Normal}}return null},lm=e=>{var t;return(t=om(e))!=null?t:im(e)},cm=Object.create,ai=Object.defineProperty,um=Object.defineProperties,dm=Object.getOwnPropertyDescriptor,fm=Object.getOwnPropertyDescriptors,Ts=Object.getOwnPropertySymbols,Hu=Object.prototype.hasOwnProperty,Gu=Object.prototype.propertyIsEnumerable,Uu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Un=e=>{throw TypeError(e)},qa=(e,t,n)=>t in e?ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xr=(e,t)=>{for(var n in t||(t={}))Hu.call(t,n)&&qa(e,n,t[n]);if(Ts)for(var n of Ts(t))Gu.call(t,n)&&qa(e,n,t[n]);return e},oi=(e,t)=>um(e,fm(t)),$l=(e,t)=>ai(e,"name",{value:t,configurable:!0}),Xu=(e,t)=>{var n={};for(var r in e)Hu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ts)for(var r of Ts(e))t.indexOf(r)<0&&Gu.call(e,r)&&(n[r]=e[r]);return n},Xn=e=>{var t;return[,,,cm((t=e?.[Uu("metadata")])!=null?t:null)]},Yu=["class","method","getter","setter","accessor","field","value","get","set"],cr=e=>e!==void 0&&typeof e!="function"?Un("Function expected"):e,hm=(e,t,n,r,s)=>({kind:Yu[e],name:t,metadata:r,addInitializer:a=>n._?Un("Already initialized"):s.push(cr(a||null))}),yn=(e,t)=>qa(t,Uu("metadata"),e[3]),We=(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,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,v=Yu[f+5],g=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&dm(f<4?s:{get[n](){return Se(this,a)},set[n](w){return st(this,a,w)}},n));f?d&&f<4&&$l(a,(f>2?"set ":f>1?"get ":"")+n):$l(s,n);for(var _=r.length-1;_>=0;_--)c=hm(f,n,l={},e[3],y),f&&(c.static=m,c.private=d,u=c.access={has:d?w=>pm(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?Se:hn)(w,s,f^4?a:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>st(w,s,x,f^4?a:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?cr(i)&&(f>4?g.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?Un("Object expected"):(cr(o=i.get)&&(b.get=o),cr(o=i.set)&&(b.set=o),cr(o=i.init)&&g.unshift(o));return f||yn(e,s),b&&ai(s,n,b),d?f^4?a:b:s},ii=(e,t,n)=>t.has(e)||Un("Cannot "+n),pm=(e,t)=>Object(t)!==t?Un('Cannot use the "in" operator on this value'):e.has(t),Se=(e,t,n)=>(ii(e,t,"read from private field"),n?n.call(e):t.get(e)),Oe=(e,t,n)=>t.has(e)?Un("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(ii(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),hn=(e,t,n)=>(ii(e,t,"access private method"),n),Rl={role:"button",roleDescription:"draggable"},mm="dnd-kit-description",gm="dnd-kit-announcement",vm={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."},ym={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 bm(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function wm(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function _m(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 xm=["dragover","dragmove"],Cm=class extends dt{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=mm,announcement:s=gm}={},announcements:a=ym,screenReaderInstructions:o=vm,debounce:i=500}=t??{},l=n?`${r}-${n}`:Ka(r),c=n?`${s}-${n}`:Ka(s);let u,f,m,d;const h=(x=d)=>{!m||!x||m?.nodeValue!==x&&(m.nodeValue=x)},v=()=>Ms.schedule(h),g=Sm(v,i),y=Object.entries(a).map(([x,S])=>this.manager.monitor.addEventListener(x,(k,E)=>{const M=m;if(!M)return;const T=S?.(k,E);T&&M.nodeValue!==T&&(d=T,xm.includes(x)?g():(v(),g.cancel()))})),b=()=>{let x=[];u?.isConnected||(u=wm(l,o.draggable),x.push(u)),f?.isConnected||(f=_m(c),m=document.createTextNode(""),f.appendChild(m),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),(!bm(k)||Qo())&&!k.hasAttribute("tabindex")&&_.add(()=>k.setAttribute("tabindex","0")),!k.hasAttribute("role")&&k.tagName.toLowerCase()!=="button"&&_.add(()=>k.setAttribute("role",Rl.role)),k.hasAttribute("aria-roledescription")||_.add(()=>k.setAttribute("aria-roledescription",Rl.roleDescription)),k.hasAttribute("aria-describedby")||_.add(()=>k.setAttribute("aria-describedby",l));for(const M of["aria-pressed","aria-grabbed"]){const T=String(S.isDragging);k.getAttribute(M)!==T&&_.add(()=>k.setAttribute(M,T))}const E=String(S.disabled);k.getAttribute("aria-disabled")!==E&&_.add(()=>k.setAttribute("aria-disabled",E))}}_.size>0&&Ms.schedule(w)}),this.destroy=()=>{super.destroy(),u?.remove(),f?.remove(),y.forEach(x=>x())}}};function Sm(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var km=class extends dt{constructor(e,t){super(e,t),this.manager=e;const n=xs(()=>{var r;return vn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=_t(()=>{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()}})}},$s=new Map,Ku,qu,Ju,Qu,Ja,gr,Wt,li,Vn,ed,td,nd,rd,bn=class extends(Ja=Dr,Qu=[he],Ju=[Pe],qu=[Pe],Ku=[Pe],Ja){constructor(e){super(e),We(Wt,5,this),Oe(this,Vn),Oe(this,gr,new Set),Oe(this,li,We(Wt,8,this,new Set)),We(Wt,11,this),this.registerEffect(hn(this,Vn,ed))}register(e){return Se(this,gr).add(e),()=>{Se(this,gr).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 ks((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return ks((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}};Wt=Xn(Ja);gr=new WeakMap;li=new WeakMap;Vn=new WeakSet;ed=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Se(this,gr))t.push(hn(this,Vn,td).call(this,n,r));return()=>{for(const n of t)n()}};td=function(e,t){let n=$s.get(e);n||(n=new Map,$s.set(e,n));let r=n.get(t);if(!r){const a=Jo(e)?hn(this,Vn,nd).call(this,e,n,t):hn(this,Vn,rd).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())}};nd=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&&$s.delete(e)}}};rd=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(ei(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&&$s.delete(e)}}};gt(Wt,4,"additionalRoots",Qu,bn,li);gt(Wt,2,"sourceRoot",Ju,bn);gt(Wt,2,"targetRoot",qu,bn);gt(Wt,2,"roots",Ku,bn);yn(Wt,bn);var Fr="data-dnd-",Qa=`${Fr}dropping`,et="--dnd-",At=`${Fr}dragging`,Rs=`${Fr}placeholder`,Em=[At,Rs,"popover","aria-pressed","aria-grabbing"],Im=["view-transition-name"],Mm=`
8
+ `)}var Bu=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 Cp(e){const t=new Set;let n=Ln(e);for(;n;)t.add(n),n=Ln(n);return t}function Sp(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Wu(e,t){const n=()=>performance.now();let r,s;return function(...a){const o=this;s?(r?.(),r=Sp(()=>{e.apply(o,a),s=n()},t-(n()-s))):(e.apply(o,a),s=n())}}function kp(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}=_s(e,t);return n>0&&r>0}var Ip=Pu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ds,Mp=class extends Ip{constructor(e){super(t=>{if(!J(this,ds)){ht(this,ds,!0);return}e(t,this)}),ot(this,ds,!1)}};ds=new WeakMap;var Ml=Array.from({length:100},(e,t)=>t/100),Vu=75,rn,Cs,zt,sn,rr,Ue,dr,sr,Ss,Nu,ju,zu=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ot(this,Ss),this.disconnect=()=>{var a,o,i;ht(this,dr,!0),(a=J(this,zt))==null||a.disconnect(),(o=J(this,sn))==null||o.disconnect(),J(this,rr).disconnect(),(i=J(this,Ue))==null||i.remove()},ot(this,rn,!0),ot(this,Cs),ot(this,zt),ot(this,sn),ot(this,rr),ot(this,Ue),ot(this,dr,!1),ot(this,sr,Wu(()=>{var a,o,i;const{element:l}=this;if((a=J(this,sn))==null||a.disconnect(),J(this,dr)||!J(this,rn)||!l.isConnected)return;const c=(o=l.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:f}=(i=c.defaultView)!=null?i:window,p=l.getBoundingClientRect(),d=_s(l,p),{top:h,left:v,bottom:g,right:y}=d,b=-Math.floor(h),w=-Math.floor(v),_=-Math.floor(f-y),x=-Math.floor(u-g),S=`${b}px ${_}px ${x}px ${w}px`;this.boundingClientRect=p,ht(this,sn,new IntersectionObserver(k=>{const[E]=k,{intersectionRect:I}=E;(E.intersectionRatio!==1?E.intersectionRatio:Ar.intersectionRatio(I,_s(l)))!==1&&J(this,sr).call(this)},{threshold:Ml,rootMargin:S,root:c})),J(this,sn).observe(l),Ru(this,Ss,Nu).call(this)},Vu)),this.boundingClientRect=e.getBoundingClientRect(),ht(this,rn,Ep(e,this.boundingClientRect));let r=!0;this.callback=a=>{r&&(r=!1,n.skipInitial)||t(a)};const s=e.ownerDocument;n?.debug&&(ht(this,Ue,document.createElement("div")),J(this,Ue).style.background="rgba(0,0,0,0.15)",J(this,Ue).style.position="fixed",J(this,Ue).style.pointerEvents="none",s.body.appendChild(J(this,Ue))),ht(this,rr,new IntersectionObserver(a=>{var o,i;const l=a[a.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:f,height:p}=c,d=J(this,rn);ht(this,rn,u),!(!f&&!p)&&(d&&!u?((o=J(this,sn))==null||o.disconnect(),this.callback(null),(i=J(this,zt))==null||i.disconnect(),ht(this,zt,void 0),J(this,Ue)&&(J(this,Ue).style.visibility="hidden")):J(this,sr).call(this),u&&!J(this,zt)&&(ht(this,zt,new Mp(J(this,sr))),J(this,zt).observe(e)))},{threshold:Ml,root:s})),J(this,rn)&&!n.skipInitial&&this.callback(this.boundingClientRect),J(this,rr).observe(e)}};rn=new WeakMap;Cs=new WeakMap;zt=new WeakMap;sn=new WeakMap;rr=new WeakMap;Ue=new WeakMap;dr=new WeakMap;sr=new WeakMap;Ss=new WeakSet;Nu=function(){J(this,dr)||(Ru(this,Ss,ju).call(this),!kp(this.boundingClientRect,J(this,Cs))&&(this.callback(this.boundingClientRect),ht(this,Cs,this.boundingClientRect)))};ju=function(){if(J(this,Ue)){const{top:e,left:t,width:n,height:r}=_s(this.element);J(this,Ue).style.overflow="hidden",J(this,Ue).style.visibility="visible",J(this,Ue).style.top=`${Math.floor(e)}px`,J(this,Ue).style.left=`${Math.floor(t)}px`,J(this,Ue).style.width=`${Math.floor(n)}px`,J(this,Ue).style.height=`${Math.floor(r)}px`}};var Qr=new WeakMap,es=new WeakMap;function Ap(e,t){let n=Qr.get(e);return n||(n={disconnect:new zu(e,s=>{const a=Qr.get(e);a&&a.callbacks.forEach(o=>o(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 Tp(e,t){const n=new Set;for(const r of e){const s=Ap(r,t);n.add(s)}return()=>n.forEach(r=>r())}function $p(e,t){var n;const r=e.ownerDocument;if(!es.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}),es.set(r,{disconnect:()=>o.abort(),listeners:i})}const{listeners:s,disconnect:a}=(n=es.get(r))!=null?n:{};return!s||!a?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(a(),es.delete(r))})}var ar,or,fs,Za,Rp=class{constructor(e,t,n){this.callback=t,ot(this,ar),ot(this,or,!1),ot(this,fs),ot(this,Za,Wu(o=>{if(!J(this,or)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const i of J(this,fs))if(o.target.contains(i)){this.callback(J(this,ar).boundingClientRect);break}}},Vu));const r=Cp(e),s=Tp(r,t),a=$p(e,J(this,Za));ht(this,fs,r),ht(this,ar,new zu(e,t,n)),this.disconnect=()=>{J(this,or)||(ht(this,or,!0),s(),a(),J(this,ar).disconnect())}}};ar=new WeakMap;or=new WeakMap;fs=new WeakMap;Za=new WeakMap;function Ha(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function br(e){try{Ha(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function Al(e){return!Pu||!e?!1:e===mn(e).scrollingElement}function Zu(e){var t,n;const r=_t(e),s=Al(e)?vp(e):zs(e),a=r.visualViewport,o=Al(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,f=i.current.x>=i.max.x;return{rect:s,position:i,isTop:l,isLeft:c,isBottom:u,isRight:f}}function Dp(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:a,position:o}=Zu(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,f=!s&&o.current.x+i>0,p=!a&&o.current.x+i<o.max.x;return{top:c,bottom:u,left:f,right:p,x:f||p,y:c||u}}var Jo=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))}},ks=new Jo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Pp=new Jo(e=>setTimeout(e,50)),Es=new Map,Fp=Es.clear.bind(Es);function Vt(e,t=!1){if(!t)return Tl(e);let n=Es.get(e);return n||(n=Tl(e),Es.set(e,n),Pp.schedule(Fp),n)}function Tl(e){return _t(e).getComputedStyle(e)}function Op(e,t=Vt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Lp(e,t=Vt(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 Bp={excludeElement:!0,escapeShadowDOM:!0};function Ga(e,t=Bp){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,a=new Set;function o(i){if(n!=null&&a.size>=n||!i)return a;if(Yo(i)&&i.scrollingElement!=null&&!a.has(i.scrollingElement))return a.add(i.scrollingElement),a;if(s&&qo(i))return o(i.host);if(!cn(i))return Du(i)?o(i.parentElement):a;if(a.has(i))return a;const l=Vt(i,!0);if(r&&i===e||Lp(i,l)&&a.add(i),Op(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&a.add(c),a}return o(i.parentNode)}return e?o(e):a}function Wp(e){const[t]=Ga(e,{limit:1});return t??null}function Bn(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=zs(r),{x:a,y:o}=Vp(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 Vp(e,t=zs(e)){const n=Math.round(t.width),r=Math.round(t.height);if(cn(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=Vt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function Np(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 Qo(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 ei(e){var t,n,r,s,a,o,i,l,c;const{scale:u,transform:f,translate:p}=e,d=Np(u),h=Qo(p),v=jp(f);if(!v&&!d&&!h)return null;const g={x:(t=d?.x)!=null?t:1,y:(n=d?.y)!=null?n:1},y={x:(r=h?.x)!=null?r:0,y:(s=h?.y)!=null?s:0},b={x:(a=v?.x)!=null?a:0,y:(o=v?.y)!=null?o:0,scaleX:(i=v?.scaleX)!=null?i:1,scaleY:(l=v?.scaleY)!=null?l:1};return{x:y.x+b.x,y:y.y+b.y,z:(c=h?.z)!=null?c:0,scaleX:g.x*b.scaleX,scaleY:g.y*b.scaleY}}function jp(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 yt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(yt||{}),zp={x:.2,y:.2},Zp={x:10,y:10};function Hp(e,t,n,r=25,s=zp,a=Zp){const{x:o,y:i}=t,{rect:l,isTop:c,isBottom:u,isLeft:f,isRight:p}=Zu(e),d=Bn(e),h=Vt(e,!0),v=ei(h),g=v!==null?v?.scaleX<0:!1,y=v!==null?v?.scaleY<0:!1,b=new Ar(l.left*d.scaleX+d.x,l.top*d.scaleY+d.y,l.width*d.scaleX,l.height*d.scaleY),w={x:0,y:0},_={x:0,y:0},x={height:b.height*s.y,width:b.width*s.x};return(!c||y&&!u)&&i<=b.top+x.height&&n?.y!==1&&o>=b.left-a.x&&o<=b.right+a.x?(w.y=y?1:-1,_.y=r*Math.abs((b.top+x.height-i)/x.height)):(!u||y&&!c)&&i>=b.bottom-x.height&&n?.y!==-1&&o>=b.left-a.x&&o<=b.right+a.x&&(w.y=y?-1:1,_.y=r*Math.abs((b.bottom-x.height-i)/x.height)),(!p||g&&!f)&&o>=b.right-x.width&&n?.x!==-1&&i>=b.top-a.y&&i<=b.bottom+a.y?(w.x=g?-1:1,_.x=r*Math.abs((b.right-x.width-o)/x.width)):(!f||g&&!p)&&o<=b.left+x.width&&n?.x!==1&&i>=b.top-a.y&&i<=b.bottom+a.y&&(w.x=g?1:-1,_.x=r*Math.abs((b.left+x.width-o)/x.width)),{direction:w,speed:_}}function Gp(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function Up(e,t=!1){if(Gp(e)){e.scrollIntoViewIfNeeded(t);return}if(!cn(e))return e.scrollIntoView();var n=Wp(e);if(!cn(n))return;const r=Vt(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 Xp(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 Yp(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 Kp({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var qp=new Jo(e=>setTimeout(e,0)),fr=new Map,Jp=fr.clear.bind(fr);function Qp(e){const t=e.ownerDocument;let n=fr.get(t);if(n)return n;n=t.getAnimations(),fr.set(t,n),qp.schedule(Jp);const r=n.filter(s=>js(s.effect)&&s.effect.target===e);return fr.set(e,r),n}function em(e,t){const n=Qp(e).filter(r=>{var s,a;if(js(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 Ar{constructor(e,t={}){var n,r,s,a;const{frameTransform:o=Bn(e),ignoreTransforms:i,getBoundingClientRect:l=zs}=t,c=em(e,{properties:["transform","translate","scale","width","height"],isValidTarget:x=>(x!==e||Ko())&&x.contains(e)}),u=l(e);let{top:f,left:p,width:d,height:h}=u,v;const g=Vt(e),y=ei(g),b={x:(n=y?.scaleX)!=null?n:1,y:(r=y?.scaleY)!=null?r:1},w=tm(e,g);c?.(),y&&(v=Yp(u,y,g.transformOrigin),(i||w)&&(f=v.top,p=v.left,d=v.width,h=v.height));const _={width:(s=v?.width)!=null?s:d,height:(a=v?.height)!=null?a:h};if(w&&!i&&v){const x=Xp(v,w,g.transformOrigin);f=x.top,p=x.left,d=x.width,h=x.height,b.x=w.scaleX,b.y=w.scaleY}o&&(i||(p*=o.scaleX,d*=o.scaleX,f*=o.scaleY,h*=o.scaleY),p+=o.x,f+=o.y),super(p,f,d,h),this.scale=b,this.intrinsicWidth=_.width,this.intrinsicHeight=_.height}};function tm(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=js(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 f=ei({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 hr(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 nm=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(hr(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(hr(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(hr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function un(e){return e?e instanceof _t(e).Element||Rr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function ti(e){if(!e)return!1;const{KeyboardEvent:t}=_t(e.target);return e instanceof t}function rm(e){if(!e)return!1;const{PointerEvent:t}=_t(e.target);return e instanceof t}function sm(e){if(!un(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||am(e)}function am(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var ma={};function Ua(e){const t=ma[e]==null?0:ma[e]+1;return ma[e]=t,`${e}-${t}`}var om=({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:Mo.PointerIntersection,priority:Io.High}}return null},im=({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:Mo.ShapeIntersection,priority:Io.Normal}}return null},lm=e=>{var t;return(t=om(e))!=null?t:im(e)},cm=Object.create,ni=Object.defineProperty,um=Object.defineProperties,dm=Object.getOwnPropertyDescriptor,fm=Object.getOwnPropertyDescriptors,Is=Object.getOwnPropertySymbols,Hu=Object.prototype.hasOwnProperty,Gu=Object.prototype.propertyIsEnumerable,Uu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Gn=e=>{throw TypeError(e)},Xa=(e,t,n)=>t in e?ni(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wr=(e,t)=>{for(var n in t||(t={}))Hu.call(t,n)&&Xa(e,n,t[n]);if(Is)for(var n of Is(t))Gu.call(t,n)&&Xa(e,n,t[n]);return e},ri=(e,t)=>um(e,fm(t)),$l=(e,t)=>ni(e,"name",{value:t,configurable:!0}),Xu=(e,t)=>{var n={};for(var r in e)Hu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Is)for(var r of Is(e))t.indexOf(r)<0&&Gu.call(e,r)&&(n[r]=e[r]);return n},Un=e=>{var t;return[,,,cm((t=e?.[Uu("metadata")])!=null?t:null)]},Yu=["class","method","getter","setter","accessor","field","value","get","set"],ir=e=>e!==void 0&&typeof e!="function"?Gn("Function expected"):e,hm=(e,t,n,r,s)=>({kind:Yu[e],name:t,metadata:r,addInitializer:a=>n._?Gn("Already initialized"):s.push(ir(a||null))}),gn=(e,t)=>Xa(t,Uu("metadata"),e[3]),Oe=(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},mt=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,p=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?p?1:2:0,v=Yu[f+5],g=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!p&&(s=s.prototype),f<5&&(f>3||!d)&&dm(f<4?s:{get[n](){return xe(this,a)},set[n](_){return Qe(this,a,_)}},n));f?d&&f<4&&$l(a,(f>2?"set ":f>1?"get ":"")+n):$l(s,n);for(var w=r.length-1;w>=0;w--)c=hm(f,n,l={},e[3],y),f&&(c.static=p,c.private=d,u=c.access={has:d?_=>pm(s,_):_=>n in _},f^3&&(u.get=d?_=>(f^1?xe:dn)(_,s,f^4?a:b.get):_=>_[n]),f>2&&(u.set=d?(_,x)=>Qe(_,s,x,f^4?a:b.set):(_,x)=>_[n]=x)),i=(0,r[w])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?ir(i)&&(f>4?g.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?Gn("Object expected"):(ir(o=i.get)&&(b.get=o),ir(o=i.set)&&(b.set=o),ir(o=i.init)&&g.unshift(o));return f||gn(e,s),b&&ni(s,n,b),d?f^4?a:b:s},si=(e,t,n)=>t.has(e)||Gn("Cannot "+n),pm=(e,t)=>Object(t)!==t?Gn('Cannot use the "in" operator on this value'):e.has(t),xe=(e,t,n)=>(si(e,t,"read from private field"),n?n.call(e):t.get(e)),Pe=(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),Qe=(e,t,n,r)=>(si(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),dn=(e,t,n)=>(si(e,t,"access private method"),n),Rl={role:"button",roleDescription:"draggable"},mm="dnd-kit-description",gm="dnd-kit-announcement",vm={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."},ym={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 bm(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function wm(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function _m(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 xm=["dragover","dragmove"],Cm=class extends lt{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=mm,announcement:s=gm}={},announcements:a=ym,screenReaderInstructions:o=vm,debounce:i=500}=t??{},l=n?`${r}-${n}`:Ua(r),c=n?`${s}-${n}`:Ua(s);let u,f,p,d;const h=(x=d)=>{!p||!x||p?.nodeValue!==x&&(p.nodeValue=x)},v=()=>ks.schedule(h),g=Sm(v,i),y=Object.entries(a).map(([x,S])=>this.manager.monitor.addEventListener(x,(k,E)=>{const I=p;if(!I)return;const M=S?.(k,E);M&&I.nodeValue!==M&&(d=M,xm.includes(x)?g():(v(),g.cancel()))})),b=()=>{let x=[];u?.isConnected||(u=wm(l,o.draggable),x.push(u)),f?.isConnected||(f=_m(c),p=document.createTextNode(""),f.appendChild(p),x.push(f)),x.length>0&&document.body.append(...x)},w=new Set;function _(){for(const x of w)x()}this.registerEffect(()=>{var x;w.clear();for(const S of this.manager.registry.draggables.value){const k=(x=S.handle)!=null?x:S.element;if(k){(!u||!f)&&w.add(b),(!bm(k)||Ko())&&!k.hasAttribute("tabindex")&&w.add(()=>k.setAttribute("tabindex","0")),!k.hasAttribute("role")&&k.tagName.toLowerCase()!=="button"&&w.add(()=>k.setAttribute("role",Rl.role)),k.hasAttribute("aria-roledescription")||w.add(()=>k.setAttribute("aria-roledescription",Rl.roleDescription)),k.hasAttribute("aria-describedby")||w.add(()=>k.setAttribute("aria-describedby",l));for(const I of["aria-pressed","aria-grabbed"]){const M=String(S.isDragging);k.getAttribute(I)!==M&&w.add(()=>k.setAttribute(I,M))}const E=String(S.disabled);k.getAttribute("aria-disabled")!==E&&w.add(()=>k.setAttribute("aria-disabled",E))}}w.size>0&&ks.schedule(_)}),this.destroy=()=>{super.destroy(),u?.remove(),f?.remove(),y.forEach(x=>x())}}};function Sm(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var km=class extends lt{constructor(e,t){super(e,t),this.manager=e;const n=bs(()=>{var r;return mn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=wt(()=>{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()}})}},Ms=new Map,Ku,qu,Ju,Qu,Ya,pr,Bt,ai,Wn,ed,td,nd,rd,vn=class extends(Ya=$r,Qu=[ce],Ju=[Ae],qu=[Ae],Ku=[Ae],Ya){constructor(e){super(e),Oe(Bt,5,this),Pe(this,Wn),Pe(this,pr,new Set),Pe(this,ai,Oe(Bt,8,this,new Set)),Oe(Bt,11,this),this.registerEffect(dn(this,Wn,ed))}register(e){return xe(this,pr).add(e),()=>{xe(this,pr).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 xs((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return xs((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}};Bt=Un(Ya);pr=new WeakMap;ai=new WeakMap;Wn=new WeakSet;ed=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of xe(this,pr))t.push(dn(this,Wn,td).call(this,n,r));return()=>{for(const n of t)n()}};td=function(e,t){let n=Ms.get(e);n||(n=new Map,Ms.set(e,n));let r=n.get(t);if(!r){const a=Yo(e)?dn(this,Wn,nd).call(this,e,n,t):dn(this,Wn,rd).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())}};nd=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&&Ms.delete(e)}}};rd=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(qo(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&&Ms.delete(e)}}};mt(Bt,4,"additionalRoots",Qu,vn,ai);mt(Bt,2,"sourceRoot",Ju,vn);mt(Bt,2,"targetRoot",qu,vn);mt(Bt,2,"roots",Ku,vn);gn(Bt,vn);var Dr="data-dnd-",Ka=`${Dr}dropping`,Ke="--dnd-",At=`${Dr}dragging`,As=`${Dr}placeholder`,Em=[At,As,"popover","aria-pressed","aria-grabbing"],Im=["view-transition-name"],Mm=`
9
9
  :is(:root,:host) [${At}] {
10
10
  position: fixed !important;
11
11
  pointer-events: none !important;
12
12
  touch-action: none;
13
13
  z-index: calc(infinity);
14
14
  will-change: translate;
15
- top: var(${et}top, 0px) !important;
16
- left: var(${et}left, 0px) !important;
15
+ top: var(${Ke}top, 0px) !important;
16
+ left: var(${Ke}left, 0px) !important;
17
17
  right: unset !important;
18
18
  bottom: unset !important;
19
- width: var(${et}width, auto);
20
- max-width: var(${et}width, auto);
21
- height: var(${et}height, auto);
22
- max-height: var(${et}height, auto);
23
- transition: var(${et}transition) !important;
19
+ width: var(${Ke}width, auto);
20
+ max-width: var(${Ke}width, auto);
21
+ height: var(${Ke}height, auto);
22
+ max-height: var(${Ke}height, auto);
23
+ transition: var(${Ke}transition) !important;
24
24
  }
25
25
 
26
- :is(:root,:host) [${Rs}] {
26
+ :is(:root,:host) [${As}] {
27
27
  transition: none;
28
28
  }
29
29
 
30
- :is(:root,:host) [${Rs}='hidden'] {
30
+ :is(:root,:host) [${As}='hidden'] {
31
31
  visibility: hidden;
32
32
  }
33
33
 
@@ -35,13 +35,13 @@
35
35
  pointer-events: none !important;
36
36
  }
37
37
 
38
- [${At}]:not([${Qa}]) {
39
- translate: var(${et}translate) !important;
38
+ [${At}]:not([${Ka}]) {
39
+ translate: var(${Ke}translate) !important;
40
40
  }
41
41
 
42
- [${At}][style*='${et}scale'] {
43
- scale: var(${et}scale) !important;
44
- transform-origin: var(${et}transform-origin) !important;
42
+ [${At}][style*='${Ke}scale'] {
43
+ scale: var(${Ke}scale) !important;
44
+ transform-origin: var(${Ke}transform-origin) !important;
45
45
  }
46
46
 
47
47
  @layer dnd-kit {
@@ -59,17 +59,17 @@
59
59
  }
60
60
  }
61
61
  }
62
- [${At}]::backdrop, [${Fr}overlay]:not([${At}]) {
62
+ [${At}]::backdrop, [${Dr}overlay]:not([${At}]) {
63
63
  display: none;
64
64
  visibility: hidden;
65
65
  }
66
- `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Am(e,t="hidden"){return we(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Tm(n,r.registry.droppables),a=[],o=wp(n),{remove:i}=o;return $m(s,o,a),Rm(o,t),o.remove=()=>{a.forEach(l=>l()),i.call(o)},o})}function Tm(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Fr}${Ka("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function $m(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),Il.set(i,o),n.push(()=>{Il.delete(i),r.proxy=void 0})}}function Rm(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Rs,t)}function sd(e,t){return e===t?!0:Bn(e)===Bn(t)}function Dl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&fn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>_r(t))}function eo(e){return e.tagName==="TR"}function Dm(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-")||Em.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(mr(e)&&mr(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(Im.includes(u)||u.startsWith(et))continue;const f=c.getPropertyValue(u);t.style.setProperty(u,f)}}}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 Pm(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),_r(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),_r(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Fm(e){return new ResizeObserver(()=>{var t,n;const r=new Bt(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=Fu();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},et),(n=e.getElementMutationObserver())==null||n.takeRecords(),eo(e.element)&&eo(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 m=c[u];f.style.width=`${m.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Bt(e.feedbackElement)})}var Om=250,Lm="ease";function Bm(e){var t,n,r,s;const{animation:a}=e;if(typeof a=="function"){const b=a({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:o=Om,easing:i=Lm}=a??{};_r(e.feedbackElement);const[,l]=(t=gp(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:sd(e.feedbackElement,c)?null:void 0},f=new Bt(e.feedbackElement,u),m=(r=ni(Nt(e.feedbackElement).translate))!=null?r:e.translate,d=new Bt(c,u),h=$r.delta(f,d,e.alignment),v={x:m.x-h.x,y:m.y-h.y},g=Math.round(f.intrinsicHeight)!==Math.round(d.intrinsicHeight)?{minHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`],maxHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`]}:{},y=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},et),e.feedbackElement.setAttribute(Qa,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),Kp({element:e.feedbackElement,keyframes:oi(xr(xr({},g),y),{translate:[`${m.x}px ${m.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:Ou(xt(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(Qa),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var ad,to,Cr,ci,gs,od,id,Sr=class extends(to=dt,ad=[he],to){constructor(t,n){super(t,n),Oe(this,gs),Oe(this,ci,We(Cr,8,this)),We(Cr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(bn),s=r?.register(Mm);if(s){const a=this.destroy.bind(this);this.destroy=()=>{s(),a()}}this.registerEffect(hn(this,gs,od).bind(this,r)),this.registerEffect(hn(this,gs,id))}};Cr=Xn(to);ci=new WeakMap;gs=new WeakSet;od=function(e){const{overlay:t}=this;if(!t||!e)return;const n=ks(t);if(n)return e.addRoot(n)};id=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:f}=l;if(!u||f==="none"||!c.initialized||c.initializing)return;const{initial:m}=r,d=(e=this.overlay)!=null?e:u,h=Wn(d),v=Wn(u),g=!sd(u,d),y=new Bt(u,{frameTransform:g?v:null,ignoreTransforms:!g}),b={x:v.scaleX/h.scaleX,y:v.scaleY/h.scaleY};let{width:_,height:w,top:x,left:S}=y;g&&(_=_/b.x,w=w/b.y);const k=new nm(d),{transition:E,translate:M,boxSizing:T,paddingBlockStart:$,paddingBlockEnd:A,paddingInlineStart:I,paddingInlineEnd:R,borderInlineStartWidth:D,borderInlineEndWidth:O,borderBlockStartWidth:Z,borderBlockEndWidth:G}=Nt(u),Y=f==="clone",te=T==="content-box",X=te?parseInt(I)+parseInt(R)+parseInt(D)+parseInt(O):0,K=te?parseInt($)+parseInt(A)+parseInt(Z)+parseInt(G):0,le=f!=="move"&&!this.overlay?Am(l,Y?"clone":"hidden"):null,J=we(()=>si(s.dragOperation.activatorEvent));if(M!=="none"){const oe=ni(M);oe&&!m.translate&&(m.translate=oe)}if(!m.transformOrigin){const oe=we(()=>i.current);m.transformOrigin={x:(oe.x-S*h.scaleX-h.x)/(_*h.scaleX),y:(oe.y-x*h.scaleY-h.y)/(w*h.scaleY)}}const{transformOrigin:de}=m,ue=x*h.scaleY+h.y,ne=S*h.scaleX+h.x;if(!m.coordinates&&(m.coordinates={x:ne,y:ue},b.x!==1||b.y!==1)){const{scaleX:oe,scaleY:ve}=v,{x:Xe,y:kt}=de;m.coordinates.x+=(_*oe-_)*Xe,m.coordinates.y+=(w*ve-w)*kt}m.dimensions||(m.dimensions={width:_,height:w}),m.frameTransform||(m.frameTransform=h);const z={x:m.coordinates.x-ne,y:m.coordinates.y-ue},ae={width:(m.dimensions.width*m.frameTransform.scaleX-_*h.scaleX)*de.x,height:(m.dimensions.height*m.frameTransform.scaleY-w*h.scaleY)*de.y},ke={x:z.x/h.scaleX+ae.width,y:z.y/h.scaleY+ae.height},ce={left:S+ke.x,top:x+ke.y};d.setAttribute(At,"true");const xe=we(()=>o.transform),B=(t=m.translate)!=null?t:{x:0,y:0},_e=xe.x*h.scaleX+B.x,re=xe.y*h.scaleY+B.y,Me=Fu();k.set({width:_-X,height:w-K,top:ce.top+Me.y,left:ce.left+Me.x,translate:`${_e}px ${re}px 0`,transition:E?`${E}, translate 0ms linear`:"",scale:g?`${b.x} ${b.y}`:"","transform-origin":`${de.x*100}% ${de.y*100}%`},et),le&&(u.insertAdjacentElement("afterend",le),a?.rootElement&&(typeof a.rootElement=="function"?a.rootElement(l):a.rootElement).appendChild(u)),Xa(d)&&(d.hasAttribute("popover")||d.setAttribute("popover","manual"),_r(d),d.addEventListener("beforetoggle",Dl));let pe,Ae,He;const qe=Fm({placeholder:le,element:u,feedbackElement:d,frameTransform:h,transformOrigin:de,width:_,height:w,top:x,left:S,widthOffset:X,heightOffset:K,delta:ke,styles:k,dragOperation:o,getElementMutationObserver:()=>pe,getSavedCellWidths:()=>He,setSavedCellWidths:oe=>{He=oe}}),Ve=new Bt(d);we(()=>o.shape=Ve);const Le=xt(d),je=oe=>{this.manager.actions.stop({event:oe})},tt=Ou(Le);J&&Le.addEventListener("resize",je),we(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),le&&(qe.observe(le),pe=Dm(u,le,Y),Ae=Pm(u,le,d));const Ct=(n=s.dragOperation.source)==null?void 0:n.id,St=()=>{var oe;if(!J||Ct==null)return;const ve=s.registry.draggables.get(Ct),Xe=(oe=ve?.handle)!=null?oe:ve?.element;dn(Xe)&&Xe.focus()},j=()=>{var oe;if(pe?.disconnect(),Ae?.disconnect(),qe.disconnect(),Le.removeEventListener("resize",je),Xa(d)&&(d.removeEventListener("beforetoggle",Dl),d.removeAttribute("popover")),d.removeAttribute(At),k.reset(),He&&eo(u)){const Xe=Array.from(u.cells);for(const[kt,N]of Xe.entries())N.style.width=(oe=He[kt])!=null?oe:""}l.status="idle";const ve=r.current.translate!=null;le&&(ve||le.parentElement!==d.parentElement)&&d.isConnected&&le.replaceWith(d),le?.remove()},ge=a?.dropAnimation,Ge=this,Ue=Tr(()=>{var oe;const{transform:ve,status:Xe}=o;if(!(!ve.x&&!ve.y&&!r.current.translate)&&Xe.dragging){const kt=(oe=m.translate)!=null?oe:{x:0,y:0},N={x:ve.x/h.scaleX+kt.x,y:ve.y/h.scaleY+kt.y},q=r.current.translate,U=we(()=>o.modifiers),Q=we(()=>{var De;return(De=o.shape)==null?void 0:De.current}),Te=J&&!tt?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(k.set({transition:`${E}, translate ${Te}`,translate:`${N.x}px ${N.y}px 0`},et),pe?.takeRecords(),Q&&Q!==Ve&&q&&!U.length){const De=Tt.delta(N,q);o.shape=$r.from(Q.boundingRectangle).translate(De.x*h.scaleX,De.y*h.scaleY)}else o.shape=new Bt(d);r.current.translate=N}},function(){if(o.status.dropped){this.dispose(),l.status="dropping";const oe=Ge.dropAnimation!==void 0?Ge.dropAnimation:ge;let ve=r.current.translate;const Xe=ve!=null;if(!ve&&u!==d&&(ve={x:0,y:0}),!ve||oe===null){j();return}s.renderer.rendering.then(()=>{Bm({element:u,feedbackElement:d,placeholder:le,translate:ve,moved:Xe,transition:E,alignment:l.alignment,styles:k,animation:oe??void 0,getElementMutationObserver:()=>pe,cleanup:j,restoreFocus:St})})}});return()=>{j(),Ue()}};gt(Cr,4,"overlay",ad,Sr,ci);yn(Cr,Sr);Sr.configure=gn(Sr);var no=Sr,Kn=!0,Wm=!1,ld,cd,ud,dd,Ut,ui,di;dd=(ud=[he],bt.Forward),cd=(ld=[he],bt.Reverse);var kr=class{constructor(){Oe(this,ui,We(Ut,8,this,Kn)),We(Ut,11,this),Oe(this,di,We(Ut,12,this,Kn)),We(Ut,15,this)}isLocked(e){return e===bt.Idle?!1:e==null?this[bt.Forward]===Kn&&this[bt.Reverse]===Kn:this[e]===Kn}unlock(e){e!==bt.Idle&&(this[e]=Wm)}};Ut=Xn(null);ui=new WeakMap;di=new WeakMap;gt(Ut,4,dd,ud,kr,ui);gt(Ut,4,cd,ld,kr,di);yn(Ut,kr);var Vm=[bt.Forward,bt.Reverse],Pl=class{constructor(){this.x=new kr,this.y=new kr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Nm=class extends dt{constructor(e){super(e);const t=Ar(new Pl);let n=null;this.signal=t,_t(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Pl;return}const{delta:s}=e.dragOperation.position;if(n){const a={x:Fl(s.x,n.x),y:Fl(s.y,n.y)},o=t.peek();Kt(()=>{for(const i of zc)for(const l of Vm)a[i]===l&&o[i].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function Fl(e,t){return Math.sign(e-t)}var fd,ro,Er,fi,Ht,so,Us=class extends(ro=Dr,fd=[he],ro){constructor(e){super(e),Oe(this,fi,We(Er,8,this,!1)),We(Er,11,this),Oe(this,Ht),Oe(this,so,()=>{if(!Se(this,Ht))return;const{element:a,by:o}=Se(this,Ht);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 st(this,Ht,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:u}=a??{},f=u?{x:Ol(u.x),y:Ol(u.y)}:void 0,m=f?void 0:this.scrollIntentTracker.current;if(m?.isLocked())return!1;for(const d of i){const h=Dp(d,u);if(h.x||h.y){const{speed:v,direction:g}=Hp(d,c,f);if(m)for(const y of zc)m[y].isLocked(g[y])&&(v[y]=0,g[y]=0);if(g.x||g.y){const{x:y,y:b}=u??g,_=y*v.x,w=b*v.y;if(_||w){const x=(o=Se(this,Ht))==null?void 0:o.by;if(this.autoScrolling&&x&&(x.x&&!_||x.y&&!w))continue;return st(this,Ht,{element:d,by:{x:_,y:w}}),Ms.schedule(Se(this,so)),!0}}}}}return st(this,Ht,void 0),!1};let t=null,n=null;const r=xs(()=>{const{position:a,source:o}=e.dragOperation;if(!a)return null;const i=Lu(ks(o?.element),a.current);return i&&(t=i),i??t}),s=xs(()=>{const a=r.value,{documentElement:o}=vn(a);if(!a||a===o){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=Ya(l,{excludeElement:!1});return n=c,c}}if(a){const i=Ya(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 Nm(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!si(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Er=Xn(ro);fi=new WeakMap;Ht=new WeakMap;so=new WeakMap;gt(Er,4,"autoScrolling",fd,Us,fi);yn(Er,Us);function Ol(e){return e>0?bt.Forward:e<0?bt.Reverse:bt.Idle}var zm=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))}},jm=new zm(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Zm=10,hd=class extends dt{constructor(e,t){super(e);const n=e.registry.plugins.get(Us);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=_t(()=>{if(this.disabled)return;const{position:r,status:s}=e.dragOperation;if(s.dragging)if(n.scroll()){n.autoScrolling=!0;const o=setInterval(()=>jm.schedule(n.scroll),Zm);return()=>{clearInterval(o)}}else n.autoScrolling=!1})}},Ll={capture:!0,passive:!0},ur,Hm=class extends Dr{constructor(e){super(e),Oe(this,ur),this.handleScroll=()=>{Se(this,ur)==null&&st(this,ur,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),st(this,ur,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=_t(()=>{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,Ll),()=>{o.removeEventListener("scroll",this.handleScroll,Ll)}}})}};ur=new WeakMap;var Gm=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.destroy=_t(()=>{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),ba(),document.addEventListener("selectionchange",ba,{capture:!0}),()=>{document.removeEventListener("selectionchange",ba,{capture:!0}),a.remove()}}})}};function ba(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var dr=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}}),An,Ds=class extends Fn{constructor(t,n){super(t),this.manager=t,this.options=n,Oe(this,An,[]),this.listeners=new Bu,this.handleSourceKeyDown=(r,s,a)=>{if(this.disabled||r.defaultPrevented||!fn(r.target)||s.disabled)return;const{keyboardCodes:o=dr.keyboardCodes,preventActivation:i=dr.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 _t(()=>{var s;const a=(s=t.handle)!=null?s:t.element,o=i=>{si(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(),Up(s);const{center:a}=new Bt(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=vn(s),l=[this.listeners.bind(i,[{type:"keydown",listener:c=>this.handleKeyDown(c,n,r),options:{capture:!0}}])];Se(this,An).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=dr.keyboardCodes}=r??{};if(Cn(t,[...s.end,...s.cancel])){t.preventDefault();const a=Cn(t,s.cancel);this.handleEnd(t,a);return}Cn(t,s.up)?this.handleMove("up",t):Cn(t,s.down)&&this.handleMove("down",t),Cn(t,s.left)?this.handleMove("left",t):Cn(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:dr.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(hd);t?.disabled===!1&&(t.disable(),Se(this,An).push(()=>{t.enable()}))}cleanup(){Se(this,An).forEach(t=>t()),st(this,An,[])}destroy(){this.cleanup(),this.listeners.clear()}};An=new WeakMap;Ds.configure=gn(Ds);Ds.defaults=dr;var Um=Ds;function Cn(e,t){return t.includes(e.code)}var ln,Xm=class extends _u{constructor(){super(...arguments),Oe(this,ln)}onEvent(e){switch(e.type){case"pointerdown":st(this,ln,Ln(e));break;case"pointermove":if(!Se(this,ln))return;const{x:t,y:n}=Ln(e),r={x:t-Se(this,ln).x,y:n-Se(this,ln).y},{tolerance:s}=this.options;if(s&&za(r,s)){this.abort();return}za(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){st(this,ln,void 0)}};ln=new WeakMap;var Tn,cn,Ym=class extends _u{constructor(){super(...arguments),Oe(this,Tn),Oe(this,cn)}onEvent(e){switch(e.type){case"pointerdown":st(this,cn,Ln(e)),st(this,Tn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Se(this,cn))return;const{x:t,y:n}=Ln(e),r={x:t-Se(this,cn).x,y:n-Se(this,cn).y};za(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Se(this,Tn)&&(clearTimeout(Se(this,Tn)),st(this,cn,void 0),st(this,Tn,void 0))}};Tn=new WeakMap;cn=new WeakMap;var Ot=class{};Ot.Delay=Ym;Ot.Distance=Xm;var ao=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&fn(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Ot.Delay({value:250,tolerance:5})]:sm(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||!fn(r)||(n=t.handle)!=null&&n.contains(r)?!1:xp(r)}}),$n,Ps=class extends Fn{constructor(t,n){super(t),this.manager=t,this.options=n,Oe(this,$n,new Set),this.listeners=new Bu,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=ao.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return _t(()=>{var s;const a=new AbortController,{signal:o}=a,i=c=>{rm(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&&(Jm(c.ownerDocument.defaultView),c.addEventListener("pointerdown",i,{signal:o}));return()=>a.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!fn(t.target)||n.disabled||Km(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=ao.preventActivation}=r??{};if(s?.(t,n))return;const{target:a}=t,o=dn(a)&&a.draggable&&a.getAttribute("draggable")==="true",i=Wn(n.element),{x:l,y:c}=Ln(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 fp(u,v=>this.handleStart(n,v));f.signal.onabort=()=>this.handleCancel(t),f.onEvent(t),this.controller=f;const m=Ga(),d=this.listeners.bind(m,[{type:"pointermove",listener:v=>this.handlePointerMove(v,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:ss,options:{capture:!0}}]),h=()=>{d(),this.initialCoordinates=void 0};Se(this,$n).add(h)}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=Ln(t),o=Wn(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,Ms.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=vn(n.target).body;i.setPointerCapture(n.pointerId);const l=fn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:ss,options:{passive:!1}},{type:"click",listener:ss},{type:"contextmenu",listener:ss},{type:"keydown",listener:this.handleKeyDown}]);Se(this,$n).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,$n).forEach(t=>t()),Se(this,$n).clear()}destroy(){this.cleanup(),this.listeners.clear()}};$n=new WeakMap;Ps.configure=gn(Ps);Ps.defaults=ao;var oo=Ps;function Km(e){return"sensor"in e}function ss(e){e.preventDefault()}function qm(){}var Bl=new WeakSet;function Jm(e){!e||Bl.has(e)||(e.addEventListener("touchmove",qm,{capture:!1,passive:!1}),Bl.add(e))}var Dn={modifiers:[],plugins:[Cm,hd,km,no,Gm],sensors:[oo,Um]},hi=class extends mp{constructor(e={}){const t=Lt(e.plugins,Dn.plugins),n=Lt(e.sensors,Dn.sensors),r=Lt(e.modifiers,Dn.modifiers);super(oi(xr({},e),{plugins:[Hm,Us,bn,...t],sensors:n,modifiers:r}))}},pd,md,gd,io,It,pi,mi,gi,Or=class extends(io=$t,gd=[he],md=[he],pd=[he],io){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:a,feedback:o="default"}=n,i=Xu(n,["element","effects","handle","feedback"]);super(xr({effects:()=>[...s(),()=>{var l,c;const{manager:u}=this;if(!u)return;const m=((c=(l=this.sensors)==null?void 0:l.map(Mo))!=null?c:[...u.sensors]).map(d=>{const h=d instanceof Fn?d:u.registry.register(d.plugin),v=d instanceof Fn?void 0:d.options;return h.bind(this,v)});return function(){m.forEach(h=>h())}}]},i),t),Oe(this,pi,We(It,8,this)),We(It,11,this),Oe(this,mi,We(It,12,this)),We(It,15,this),Oe(this,gi,We(It,16,this)),We(It,19,this),this.element=r,this.handle=a,this.feedback=o}};It=Xn(io);pi=new WeakMap;mi=new WeakMap;gi=new WeakMap;gt(It,4,"handle",gd,Or,pi);gt(It,4,"element",md,Or,mi);gt(It,4,"feedback",pd,Or,gi);yn(It,Or);var vd,yd,lo,Xt,vi,wa,bd,wd,vr,yi,_d=class extends(lo=Rt,yd=[he],vd=[he],lo){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,a=Xu(n,["element","effects"]);const{collisionDetector:o=lm}=a,i=c=>{const{manager:u,element:f}=this;if(!f||c===null){this.shape=void 0;return}if(!u)return;const m=new Bt(f),d=we(()=>this.shape);return m&&d?.equals(m)?d:(this.shape=m,m)},l=Ar(!1);super(oi(xr({},a),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:c,manager:u}=this;if(!u)return;const{dragOperation:f}=u,{source:m}=f;l.value=!!(m&&f.status.initialized&&c&&!this.disabled&&this.accepts(m))},()=>{const{element:c}=this;if(l.value&&c){const u=new Rp(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),Oe(this,vr),Oe(this,vi,We(Xt,8,this)),We(Xt,11,this),Oe(this,yi,We(Xt,12,this)),We(Xt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){st(this,vr,e,wd)}get element(){var e;return(e=this.proxy)!=null?e:Se(this,vr,bd)}};Xt=Xn(lo);vi=new WeakMap;vr=new WeakSet;yi=new WeakMap;wa=gt(Xt,20,"#element",yd,vr,vi),bd=wa.get,wd=wa.set;gt(Xt,4,"proxy",vd,_d,yi);yn(Xt,_d);function Qm(e){return e!=null&&typeof e=="object"&&"current"in e}function Fs(e){var t;if(e!=null)return Qm(e)?(t=e.current)!=null?t:void 0:e}var eg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Xs=eg?p.useLayoutEffect:p.useEffect;function tg(){const e=p.useState(0)[1];return p.useCallback(()=>{e(t=>t+1)},[e])}function ng(e,t){const n=p.useRef(new Map),r=tg();return Xs(()=>{if(!e){n.current.clear();return}return _t(()=>{var s;let a=!1,o=!1;for(const i of n.current){const[l]=i,c=we(()=>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?yo.flushSync(r):r())})},[e]),p.useMemo(()=>e&&new Proxy(e,{get(s,a){const o=s[a];return n.current.set(a,o),o}}),[e])}function rn(e,t,n=p.useEffect,r=Object.is){const s=p.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}function Wl(e,t){const n=p.useRef(Fs(e));Xs(()=>{const r=Fs(e);r!==n.current&&(n.current=r,t(r))})}var rg=Object.defineProperty,sg=Object.defineProperties,ag=Object.getOwnPropertyDescriptors,Vl=Object.getOwnPropertySymbols,og=Object.prototype.hasOwnProperty,ig=Object.prototype.propertyIsEnumerable,Nl=(e,t,n)=>t in e?rg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lg=(e,t)=>{for(var n in t||(t={}))og.call(t,n)&&Nl(e,n,t[n]);if(Vl)for(var n of Vl(t))ig.call(t,n)&&Nl(e,n,t[n]);return e},cg=(e,t)=>sg(e,ag(t)),ug=new hi,dg=p.createContext(ug);p.memo(p.forwardRef(({children:e},t)=>{const[n,r]=p.useState(0),s=p.useRef(null),a=p.useRef(null),o=p.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})),p.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Xs(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),p.useImperativeHandle(t,()=>o),null}));function fg(){return p.useContext(dg)}function hg(e){var t;const n=(t=fg())!=null?t:void 0,[r]=p.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Xs(r.register,[n,r]),r}function _a(e){const{disabled:t,data:n,element:r,handle:s,id:a,modifiers:o,sensors:i}=e,l=hg(u=>new Or(cg(lg({},e),{register:!1,handle:Fs(s),element:Fs(r)}),u)),c=ng(l,pg);return rn(a,()=>l.id=a),Wl(s,u=>l.handle=u),Wl(r,u=>l.element=u),rn(n,()=>n&&(l.data=n)),rn(t,()=>l.disabled=t===!0),rn(i,()=>l.sensors=i),rn(o,()=>l.modifiers=o,void 0,br),rn(e.feedback,()=>{var u;return l.feedback=(u=e.feedback)!=null?u:"default"}),rn(e.alignment,()=>l.alignment=e.alignment),{draggable:c,get isDragging(){return c.isDragging},get isDropping(){return c.isDropping},get isDragSource(){return c.isDragSource},handleRef:p.useCallback(u=>{l.handle=u??void 0},[l]),ref:p.useCallback(u=>{var f,m;!u&&((f=l.element)!=null&&f.isConnected)&&!((m=l.manager)!=null&&m.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function pg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var mg=Object.create,xd=Object.defineProperty,gg=Object.getOwnPropertyDescriptor,Cd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ys=e=>{throw TypeError(e)},vg=(e,t,n)=>t in e?xd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yg=e=>{var t;return[,,,mg((t=e?.[Cd("metadata")])!=null?t:null)]},Sd=["class","method","getter","setter","accessor","field","value","get","set"],kd=e=>e!==void 0&&typeof e!="function"?Ys("Function expected"):e,bg=(e,t,n,r,s)=>({kind:Sd[e],name:t,metadata:r,addInitializer:a=>n._?Ys("Already initialized"):s.push(kd(a||null))}),wg=(e,t)=>vg(t,Cd("metadata"),e[3]),_g=(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},Ed=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=Sd[u+5],v=e[d]||(e[d]=[]),g=(s=s.prototype,gg(s,n)),y=r.length-1;y>=0;y--)l=bg(u,n,i={},e[3],v),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(g[h],l),i._=1,kd(o)&&(g[h]=o);return g&&xd(s,n,g),s},Id=(e,t,n)=>t.has(e)||Ys("Cannot "+n),xg=(e,t,n)=>(Id(e,t,"read from private field"),t.get(e)),Cg=(e,t,n)=>t.has(e)?Ys("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Sg=(e,t,n,r)=>(Id(e,t,"write to private field"),t.set(e,n),n),qn=class co{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new co(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 co(t,n)}},Md,Ad,uo,vs,Lr,bi=class extends(uo=Jt,Ad=[Pe],Md=[Pe],uo){constructor(t){const n=qn.from(t);super(n,(r,s)=>qn.equals(r,s)),_g(Lr,5,this),Cg(this,vs,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},a=Date.now(),o=a-xg(this,vs),i=l=>Math.round(l/o*100);Kt(()=>{Sg(this,vs,a),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}}};Lr=yg(uo);vs=new WeakMap;Ed(Lr,2,"delta",Ad,bi);Ed(Lr,2,"direction",Md,bi);wg(Lr,bi);var Td=(e=>(e.Horizontal="x",e.Vertical="y",e))(Td||{});Object.values(Td);const kg=new Map([["bold",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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"}),P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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"}))]]),Ig=new Map([["bold",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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"}))]]),Mg=new Map([["bold",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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"}),P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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",P.createElement(P.Fragment,null,P.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"}))]]),Ag=p.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Br=P.forwardRef((e,t)=>{const{alt:n,color:r,size:s,weight:a,mirrored:o,children:i,weights:l,...c}=e,{color:u="currentColor",size:f,weight:m="regular",mirrored:d=!1,...h}=P.useContext(Ag);return P.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:o||d?"scale(-1, 1)":void 0,...h,...c},!!n&&P.createElement("title",null,n),i,l.get(a??m))});Br.displayName="IconBase";const $d=P.forwardRef((e,t)=>P.createElement(Br,{ref:t,...e,weights:kg}));$d.displayName="DotsThreeIcon";const Rd=P.forwardRef((e,t)=>P.createElement(Br,{ref:t,...e,weights:Eg}));Rd.displayName="SpeakerHighIcon";const Dd=P.forwardRef((e,t)=>P.createElement(Br,{ref:t,...e,weights:Ig}));Dd.displayName="SpeakerLowIcon";const Pd=P.forwardRef((e,t)=>P.createElement(Br,{ref:t,...e,weights:Mg}));Pd.displayName="XIcon";const Tg=Pd;F.span`
66
+ `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Am(e,t="hidden"){return we(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Tm(n,r.registry.droppables),a=[],o=wp(n),{remove:i}=o;return $m(s,o,a),Rm(o,t),o.remove=()=>{a.forEach(l=>l()),i.call(o)},o})}function Tm(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Dr}${Ua("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function $m(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),Il.set(i,o),n.push(()=>{Il.delete(i),r.proxy=void 0})}}function Rm(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(As,t)}function sd(e,t){return e===t?!0:Ln(e)===Ln(t)}function Dl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&un(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>br(t))}function qa(e){return e.tagName==="TR"}function Dm(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-")||Em.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(hr(e)&&hr(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(Im.includes(u)||u.startsWith(Ke))continue;const f=c.getPropertyValue(u);t.style.setProperty(u,f)}}}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 Pm(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),br(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),br(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Fm(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=Fu();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},Ke),(n=e.getElementMutationObserver())==null||n.takeRecords(),qa(e.element)&&qa(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 p=c[u];f.style.width=`${p.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Lt(e.feedbackElement)})}var Om=250,Lm="ease";function Bm(e){var t,n,r,s;const{animation:a}=e;if(typeof a=="function"){const b=a({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:o=Om,easing:i=Lm}=a??{};br(e.feedbackElement);const[,l]=(t=gp(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:sd(e.feedbackElement,c)?null:void 0},f=new Lt(e.feedbackElement,u),p=(r=Qo(Vt(e.feedbackElement).translate))!=null?r:e.translate,d=new Lt(c,u),h=Ar.delta(f,d,e.alignment),v={x:p.x-h.x,y:p.y-h.y},g=Math.round(f.intrinsicHeight)!==Math.round(d.intrinsicHeight)?{minHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`],maxHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`]}:{},y=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},Ke),e.feedbackElement.setAttribute(Ka,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),Kp({element:e.feedbackElement,keyframes:ri(wr(wr({},g),y),{translate:[`${p.x}px ${p.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:Ou(_t(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(Ka),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var ad,Ja,_r,oi,hs,od,id,xr=class extends(Ja=lt,ad=[ce],Ja){constructor(t,n){super(t,n),Pe(this,hs),Pe(this,oi,Oe(_r,8,this)),Oe(_r,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(vn),s=r?.register(Mm);if(s){const a=this.destroy.bind(this);this.destroy=()=>{s(),a()}}this.registerEffect(dn(this,hs,od).bind(this,r)),this.registerEffect(dn(this,hs,id))}};_r=Un(Ja);oi=new WeakMap;hs=new WeakSet;od=function(e){const{overlay:t}=this;if(!t||!e)return;const n=xs(t);if(n)return e.addRoot(n)};id=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:f}=l;if(!u||f==="none"||!c.initialized||c.initializing)return;const{initial:p}=r,d=(e=this.overlay)!=null?e:u,h=Bn(d),v=Bn(u),g=!sd(u,d),y=new Lt(u,{frameTransform:g?v:null,ignoreTransforms:!g}),b={x:v.scaleX/h.scaleX,y:v.scaleY/h.scaleY};let{width:w,height:_,top:x,left:S}=y;g&&(w=w/b.x,_=_/b.y);const k=new nm(d),{transition:E,translate:I,boxSizing:M,paddingBlockStart:T,paddingBlockEnd:A,paddingInlineStart:$,paddingInlineEnd:R,borderInlineStartWidth:F,borderInlineEndWidth:O,borderBlockStartWidth:G,borderBlockEndWidth:Q}=Vt(u),ee=f==="clone",ue=M==="content-box",te=ue?parseInt($)+parseInt(R)+parseInt(F)+parseInt(O):0,oe=ue?parseInt(T)+parseInt(A)+parseInt(G)+parseInt(Q):0,se=f!=="move"&&!this.overlay?Am(l,ee?"clone":"hidden"):null,le=we(()=>ti(s.dragOperation.activatorEvent));if(I!=="none"){const q=Qo(I);q&&!p.translate&&(p.translate=q)}if(!p.transformOrigin){const q=we(()=>i.current);p.transformOrigin={x:(q.x-S*h.scaleX-h.x)/(w*h.scaleX),y:(q.y-x*h.scaleY-h.y)/(_*h.scaleY)}}const{transformOrigin:ye}=p,de=x*h.scaleY+h.y,ne=S*h.scaleX+h.x;if(!p.coordinates&&(p.coordinates={x:ne,y:de},b.x!==1||b.y!==1)){const{scaleX:q,scaleY:me}=v,{x:He,y:St}=ye;p.coordinates.x+=(w*q-w)*He,p.coordinates.y+=(_*me-_)*St}p.dimensions||(p.dimensions={width:w,height:_}),p.frameTransform||(p.frameTransform=h);const Z={x:p.coordinates.x-ne,y:p.coordinates.y-de},fe={width:(p.dimensions.width*p.frameTransform.scaleX-w*h.scaleX)*ye.x,height:(p.dimensions.height*p.frameTransform.scaleY-_*h.scaleY)*ye.y},Fe={x:Z.x/h.scaleX+fe.width,y:Z.y/h.scaleY+fe.height},ae={left:S+Fe.x,top:x+Fe.y};d.setAttribute(At,"true");const Te=we(()=>o.transform),B=(t=p.translate)!=null?t:{x:0,y:0},$e=Te.x*h.scaleX+B.x,re=Te.y*h.scaleY+B.y,Ve=Fu();k.set({width:w-te,height:_-oe,top:ae.top+Ve.y,left:ae.left+Ve.x,translate:`${$e}px ${re}px 0`,transition:E?`${E}, translate 0ms linear`:"",scale:g?`${b.x} ${b.y}`:"","transform-origin":`${ye.x*100}% ${ye.y*100}%`},Ke),se&&(u.insertAdjacentElement("afterend",se),a?.rootElement&&(typeof a.rootElement=="function"?a.rootElement(l):a.rootElement).appendChild(u)),Ha(d)&&(d.hasAttribute("popover")||d.setAttribute("popover","manual"),br(d),d.addEventListener("beforetoggle",Dl));let ve,Re,ct;const xt=Fm({placeholder:se,element:u,feedbackElement:d,frameTransform:h,transformOrigin:ye,width:w,height:_,top:x,left:S,widthOffset:te,heightOffset:oe,delta:Fe,styles:k,dragOperation:o,getElementMutationObserver:()=>ve,getSavedCellWidths:()=>ct,setSavedCellWidths:q=>{ct=q}}),st=new Lt(d);we(()=>o.shape=st);const je=_t(d),at=q=>{this.manager.actions.stop({event:q})},ut=Ou(je);le&&je.addEventListener("resize",at),we(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),se&&(xt.observe(se),ve=Dm(u,se,ee),Re=Pm(u,se,d));const Mt=(n=s.dragOperation.source)==null?void 0:n.id,Ct=()=>{var q;if(!le||Mt==null)return;const me=s.registry.draggables.get(Mt),He=(q=me?.handle)!=null?q:me?.element;cn(He)&&He.focus()},j=()=>{var q;if(ve?.disconnect(),Re?.disconnect(),xt.disconnect(),je.removeEventListener("resize",at),Ha(d)&&(d.removeEventListener("beforetoggle",Dl),d.removeAttribute("popover")),d.removeAttribute(At),k.reset(),ct&&qa(u)){const He=Array.from(u.cells);for(const[St,N]of He.entries())N.style.width=(q=ct[St])!=null?q:""}l.status="idle";const me=r.current.translate!=null;se&&(me||se.parentElement!==d.parentElement)&&d.isConnected&&se.replaceWith(d),se?.remove()},pe=a?.dropAnimation,ze=this,Ze=Mr(()=>{var q;const{transform:me,status:He}=o;if(!(!me.x&&!me.y&&!r.current.translate)&&He.dragging){const St=(q=p.translate)!=null?q:{x:0,y:0},N={x:me.x/h.scaleX+St.x,y:me.y/h.scaleY+St.y},U=r.current.translate,H=we(()=>o.modifiers),X=we(()=>{var Me;return(Me=o.shape)==null?void 0:Me.current}),ke=le&&!ut?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(k.set({transition:`${E}, translate ${ke}`,translate:`${N.x}px ${N.y}px 0`},Ke),ve?.takeRecords(),X&&X!==st&&U&&!H.length){const Me=Tt.delta(N,U);o.shape=Ar.from(X.boundingRectangle).translate(Me.x*h.scaleX,Me.y*h.scaleY)}else o.shape=new Lt(d);r.current.translate=N}},function(){if(o.status.dropped){this.dispose(),l.status="dropping";const q=ze.dropAnimation!==void 0?ze.dropAnimation:pe;let me=r.current.translate;const He=me!=null;if(!me&&u!==d&&(me={x:0,y:0}),!me||q===null){j();return}s.renderer.rendering.then(()=>{Bm({element:u,feedbackElement:d,placeholder:se,translate:me,moved:He,transition:E,alignment:l.alignment,styles:k,animation:q??void 0,getElementMutationObserver:()=>ve,cleanup:j,restoreFocus:Ct})})}});return()=>{j(),Ze()}};mt(_r,4,"overlay",ad,xr,oi);gn(_r,xr);xr.configure=pn(xr);var Qa=xr,Xn=!0,Wm=!1,ld,cd,ud,dd,Gt,ii,li;dd=(ud=[ce],yt.Forward),cd=(ld=[ce],yt.Reverse);var Cr=class{constructor(){Pe(this,ii,Oe(Gt,8,this,Xn)),Oe(Gt,11,this),Pe(this,li,Oe(Gt,12,this,Xn)),Oe(Gt,15,this)}isLocked(e){return e===yt.Idle?!1:e==null?this[yt.Forward]===Xn&&this[yt.Reverse]===Xn:this[e]===Xn}unlock(e){e!==yt.Idle&&(this[e]=Wm)}};Gt=Un(null);ii=new WeakMap;li=new WeakMap;mt(Gt,4,dd,ud,Cr,ii);mt(Gt,4,cd,ld,Cr,li);gn(Gt,Cr);var Vm=[yt.Forward,yt.Reverse],Pl=class{constructor(){this.x=new Cr,this.y=new Cr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Nm=class extends lt{constructor(e){super(e);const t=Ir(new Pl);let n=null;this.signal=t,wt(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Pl;return}const{delta:s}=e.dragOperation.position;if(n){const a={x:Fl(s.x,n.x),y:Fl(s.y,n.y)},o=t.peek();Yt(()=>{for(const i of jc)for(const l of Vm)a[i]===l&&o[i].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function Fl(e,t){return Math.sign(e-t)}var fd,eo,Sr,ci,Zt,to,Zs=class extends(eo=$r,fd=[ce],eo){constructor(e){super(e),Pe(this,ci,Oe(Sr,8,this,!1)),Oe(Sr,11,this),Pe(this,Zt),Pe(this,to,()=>{if(!xe(this,Zt))return;const{element:a,by:o}=xe(this,Zt);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 Qe(this,Zt,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:u}=a??{},f=u?{x:Ol(u.x),y:Ol(u.y)}:void 0,p=f?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const d of i){const h=Dp(d,u);if(h.x||h.y){const{speed:v,direction:g}=Hp(d,c,f);if(p)for(const y of jc)p[y].isLocked(g[y])&&(v[y]=0,g[y]=0);if(g.x||g.y){const{x:y,y:b}=u??g,w=y*v.x,_=b*v.y;if(w||_){const x=(o=xe(this,Zt))==null?void 0:o.by;if(this.autoScrolling&&x&&(x.x&&!w||x.y&&!_))continue;return Qe(this,Zt,{element:d,by:{x:w,y:_}}),ks.schedule(xe(this,to)),!0}}}}}return Qe(this,Zt,void 0),!1};let t=null,n=null;const r=bs(()=>{const{position:a,source:o}=e.dragOperation;if(!a)return null;const i=Lu(xs(o?.element),a.current);return i&&(t=i),i??t}),s=bs(()=>{const a=r.value,{documentElement:o}=mn(a);if(!a||a===o){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=Ga(l,{excludeElement:!1});return n=c,c}}if(a){const i=Ga(a,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},vr);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new Nm(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!ti(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Sr=Un(eo);ci=new WeakMap;Zt=new WeakMap;to=new WeakMap;mt(Sr,4,"autoScrolling",fd,Zs,ci);gn(Sr,Zs);function Ol(e){return e>0?yt.Forward:e<0?yt.Reverse:yt.Idle}var jm=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))}},zm=new jm(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Zm=10,hd=class extends lt{constructor(e,t){super(e);const n=e.registry.plugins.get(Zs);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=wt(()=>{if(this.disabled)return;const{position:r,status:s}=e.dragOperation;if(s.dragging)if(n.scroll()){n.autoScrolling=!0;const o=setInterval(()=>zm.schedule(n.scroll),Zm);return()=>{clearInterval(o)}}else n.autoScrolling=!1})}},Ll={capture:!0,passive:!0},lr,Hm=class extends $r{constructor(e){super(e),Pe(this,lr),this.handleScroll=()=>{xe(this,lr)==null&&Qe(this,lr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),Qe(this,lr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=wt(()=>{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,Ll),()=>{o.removeEventListener("scroll",this.handleScroll,Ll)}}})}};lr=new WeakMap;var Gm=class extends lt{constructor(e,t){super(e,t),this.manager=e,this.destroy=wt(()=>{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),ga(),document.addEventListener("selectionchange",ga,{capture:!0}),()=>{document.removeEventListener("selectionchange",ga,{capture:!0}),a.remove()}}})}};function ga(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var cr=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}}),Mn,Ts=class extends Pn{constructor(t,n){super(t),this.manager=t,this.options=n,Pe(this,Mn,[]),this.listeners=new Bu,this.handleSourceKeyDown=(r,s,a)=>{if(this.disabled||r.defaultPrevented||!un(r.target)||s.disabled)return;const{keyboardCodes:o=cr.keyboardCodes,preventActivation:i=cr.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 wt(()=>{var s;const a=(s=t.handle)!=null?s:t.element,o=i=>{ti(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(),Up(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=mn(s),l=[this.listeners.bind(i,[{type:"keydown",listener:c=>this.handleKeyDown(c,n,r),options:{capture:!0}}])];xe(this,Mn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=cr.keyboardCodes}=r??{};if(xn(t,[...s.end,...s.cancel])){t.preventDefault();const a=xn(t,s.cancel);this.handleEnd(t,a);return}xn(t,s.up)?this.handleMove("up",t):xn(t,s.down)&&this.handleMove("down",t),xn(t,s.left)?this.handleMove("left",t):xn(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:cr.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(hd);t?.disabled===!1&&(t.disable(),xe(this,Mn).push(()=>{t.enable()}))}cleanup(){xe(this,Mn).forEach(t=>t()),Qe(this,Mn,[])}destroy(){this.cleanup(),this.listeners.clear()}};Mn=new WeakMap;Ts.configure=pn(Ts);Ts.defaults=cr;var Um=Ts;function xn(e,t){return t.includes(e.code)}var an,Xm=class extends _u{constructor(){super(...arguments),Pe(this,an)}onEvent(e){switch(e.type){case"pointerdown":Qe(this,an,On(e));break;case"pointermove":if(!xe(this,an))return;const{x:t,y:n}=On(e),r={x:t-xe(this,an).x,y:n-xe(this,an).y},{tolerance:s}=this.options;if(s&&Wa(r,s)){this.abort();return}Wa(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){Qe(this,an,void 0)}};an=new WeakMap;var An,on,Ym=class extends _u{constructor(){super(...arguments),Pe(this,An),Pe(this,on)}onEvent(e){switch(e.type){case"pointerdown":Qe(this,on,On(e)),Qe(this,An,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!xe(this,on))return;const{x:t,y:n}=On(e),r={x:t-xe(this,on).x,y:n-xe(this,on).y};Wa(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){xe(this,An)&&(clearTimeout(xe(this,An)),Qe(this,on,void 0),Qe(this,An,void 0))}};An=new WeakMap;on=new WeakMap;var Ft=class{};Ft.Delay=Ym;Ft.Distance=Xm;var no=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&un(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Ft.Delay({value:250,tolerance:5})]:sm(s)&&!e.defaultPrevented?[new Ft.Delay({value:200,tolerance:0})]:[new Ft.Delay({value:200,tolerance:10}),new Ft.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;return r===t.element||r===t.handle||!un(r)||(n=t.handle)!=null&&n.contains(r)?!1:xp(r)}}),Tn,$s=class extends Pn{constructor(t,n){super(t),this.manager=t,this.options=n,Pe(this,Tn,new Set),this.listeners=new Bu,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=no.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return wt(()=>{var s;const a=new AbortController,{signal:o}=a,i=c=>{rm(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&&(Jm(c.ownerDocument.defaultView),c.addEventListener("pointerdown",i,{signal:o}));return()=>a.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!un(t.target)||n.disabled||Km(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=no.preventActivation}=r??{};if(s?.(t,n))return;const{target:a}=t,o=cn(a)&&a.draggable&&a.getAttribute("draggable")==="true",i=Bn(n.element),{x:l,y:c}=On(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 fp(u,v=>this.handleStart(n,v));f.signal.onabort=()=>this.handleCancel(t),f.onEvent(t),this.controller=f;const p=za(),d=this.listeners.bind(p,[{type:"pointermove",listener:v=>this.handlePointerMove(v,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:ts,options:{capture:!0}}]),h=()=>{d(),this.initialCoordinates=void 0};xe(this,Tn).add(h)}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=On(t),o=Bn(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,ks.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=mn(n.target).body;i.setPointerCapture(n.pointerId);const l=un(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}]);xe(this,Tn).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},xe(this,Tn).forEach(t=>t()),xe(this,Tn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};Tn=new WeakMap;$s.configure=pn($s);$s.defaults=no;var ro=$s;function Km(e){return"sensor"in e}function ts(e){e.preventDefault()}function qm(){}var Bl=new WeakSet;function Jm(e){!e||Bl.has(e)||(e.addEventListener("touchmove",qm,{capture:!1,passive:!1}),Bl.add(e))}var Rn={modifiers:[],plugins:[Cm,hd,km,Qa,Gm],sensors:[ro,Um]},ui=class extends mp{constructor(e={}){const t=Ot(e.plugins,Rn.plugins),n=Ot(e.sensors,Rn.sensors),r=Ot(e.modifiers,Rn.modifiers);super(ri(wr({},e),{plugins:[Hm,Zs,vn,...t],sensors:n,modifiers:r}))}},pd,md,gd,so,Et,di,fi,hi,Pr=class extends(so=$t,gd=[ce],md=[ce],pd=[ce],so){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:a,feedback:o="default"}=n,i=Xu(n,["element","effects","handle","feedback"]);super(wr({effects:()=>[...s(),()=>{var l,c;const{manager:u}=this;if(!u)return;const p=((c=(l=this.sensors)==null?void 0:l.map(ko))!=null?c:[...u.sensors]).map(d=>{const h=d instanceof Pn?d:u.registry.register(d.plugin),v=d instanceof Pn?void 0:d.options;return h.bind(this,v)});return function(){p.forEach(h=>h())}}]},i),t),Pe(this,di,Oe(Et,8,this)),Oe(Et,11,this),Pe(this,fi,Oe(Et,12,this)),Oe(Et,15,this),Pe(this,hi,Oe(Et,16,this)),Oe(Et,19,this),this.element=r,this.handle=a,this.feedback=o}};Et=Un(so);di=new WeakMap;fi=new WeakMap;hi=new WeakMap;mt(Et,4,"handle",gd,Pr,di);mt(Et,4,"element",md,Pr,fi);mt(Et,4,"feedback",pd,Pr,hi);gn(Et,Pr);var vd,yd,ao,Ut,pi,va,bd,wd,mr,mi,_d=class extends(ao=Rt,yd=[ce],vd=[ce],ao){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,a=Xu(n,["element","effects"]);const{collisionDetector:o=lm}=a,i=c=>{const{manager:u,element:f}=this;if(!f||c===null){this.shape=void 0;return}if(!u)return;const p=new Lt(f),d=we(()=>this.shape);return p&&d?.equals(p)?d:(this.shape=p,p)},l=Ir(!1);super(ri(wr({},a),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:c,manager:u}=this;if(!u)return;const{dragOperation:f}=u,{source:p}=f;l.value=!!(p&&f.status.initialized&&c&&!this.disabled&&this.accepts(p))},()=>{const{element:c}=this;if(l.value&&c){const u=new Rp(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),Pe(this,mr),Pe(this,pi,Oe(Ut,8,this)),Oe(Ut,11,this),Pe(this,mi,Oe(Ut,12,this)),Oe(Ut,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){Qe(this,mr,e,wd)}get element(){var e;return(e=this.proxy)!=null?e:xe(this,mr,bd)}};Ut=Un(ao);pi=new WeakMap;mr=new WeakSet;mi=new WeakMap;va=mt(Ut,20,"#element",yd,mr,pi),bd=va.get,wd=va.set;mt(Ut,4,"proxy",vd,_d,mi);gn(Ut,_d);function Qm(e){return e!=null&&typeof e=="object"&&"current"in e}function Rs(e){var t;if(e!=null)return Qm(e)?(t=e.current)!=null?t:void 0:e}var eg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Hs=eg?m.useLayoutEffect:m.useEffect;function tg(){const e=m.useState(0)[1];return m.useCallback(()=>{e(t=>t+1)},[e])}function ng(e,t){const n=m.useRef(new Map),r=tg();return Hs(()=>{if(!e){n.current.clear();return}return wt(()=>{var s;let a=!1,o=!1;for(const i of n.current){const[l]=i,c=we(()=>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?mo.flushSync(r):r())})},[e]),m.useMemo(()=>e&&new Proxy(e,{get(s,a){const o=s[a];return n.current.set(a,o),o}}),[e])}function tn(e,t,n=m.useEffect,r=Object.is){const s=m.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}function Wl(e,t){const n=m.useRef(Rs(e));Hs(()=>{const r=Rs(e);r!==n.current&&(n.current=r,t(r))})}var rg=Object.defineProperty,sg=Object.defineProperties,ag=Object.getOwnPropertyDescriptors,Vl=Object.getOwnPropertySymbols,og=Object.prototype.hasOwnProperty,ig=Object.prototype.propertyIsEnumerable,Nl=(e,t,n)=>t in e?rg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lg=(e,t)=>{for(var n in t||(t={}))og.call(t,n)&&Nl(e,n,t[n]);if(Vl)for(var n of Vl(t))ig.call(t,n)&&Nl(e,n,t[n]);return e},cg=(e,t)=>sg(e,ag(t)),ug=new ui,dg=m.createContext(ug);m.memo(m.forwardRef(({children:e},t)=>{const[n,r]=m.useState(0),s=m.useRef(null),a=m.useRef(null),o=m.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})),m.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Hs(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),m.useImperativeHandle(t,()=>o),null}));function fg(){return m.useContext(dg)}function hg(e){var t;const n=(t=fg())!=null?t:void 0,[r]=m.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Hs(r.register,[n,r]),r}function ya(e){const{disabled:t,data:n,element:r,handle:s,id:a,modifiers:o,sensors:i}=e,l=hg(u=>new Pr(cg(lg({},e),{register:!1,handle:Rs(s),element:Rs(r)}),u)),c=ng(l,pg);return tn(a,()=>l.id=a),Wl(s,u=>l.handle=u),Wl(r,u=>l.element=u),tn(n,()=>n&&(l.data=n)),tn(t,()=>l.disabled=t===!0),tn(i,()=>l.sensors=i),tn(o,()=>l.modifiers=o,void 0,vr),tn(e.feedback,()=>{var u;return l.feedback=(u=e.feedback)!=null?u:"default"}),tn(e.alignment,()=>l.alignment=e.alignment),{draggable:c,get isDragging(){return c.isDragging},get isDropping(){return c.isDropping},get isDragSource(){return c.isDragSource},handleRef:m.useCallback(u=>{l.handle=u??void 0},[l]),ref:m.useCallback(u=>{var f,p;!u&&((f=l.element)!=null&&f.isConnected)&&!((p=l.manager)!=null&&p.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function pg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var mg=Object.create,xd=Object.defineProperty,gg=Object.getOwnPropertyDescriptor,Cd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Gs=e=>{throw TypeError(e)},vg=(e,t,n)=>t in e?xd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yg=e=>{var t;return[,,,mg((t=e?.[Cd("metadata")])!=null?t:null)]},Sd=["class","method","getter","setter","accessor","field","value","get","set"],kd=e=>e!==void 0&&typeof e!="function"?Gs("Function expected"):e,bg=(e,t,n,r,s)=>({kind:Sd[e],name:t,metadata:r,addInitializer:a=>n._?Gs("Already initialized"):s.push(kd(a||null))}),wg=(e,t)=>vg(t,Cd("metadata"),e[3]),_g=(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},Ed=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,p=!1,d=2,h=Sd[u+5],v=e[d]||(e[d]=[]),g=(s=s.prototype,gg(s,n)),y=r.length-1;y>=0;y--)l=bg(u,n,i={},e[3],v),l.static=f,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(g[h],l),i._=1,kd(o)&&(g[h]=o);return g&&xd(s,n,g),s},Id=(e,t,n)=>t.has(e)||Gs("Cannot "+n),xg=(e,t,n)=>(Id(e,t,"read from private field"),t.get(e)),Cg=(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),Sg=(e,t,n,r)=>(Id(e,t,"write to private field"),t.set(e,n),n),Yn=class oo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new oo(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 oo(t,n)}},Md,Ad,io,ps,Fr,gi=class extends(io=qt,Ad=[Ae],Md=[Ae],io){constructor(t){const n=Yn.from(t);super(n,(r,s)=>Yn.equals(r,s)),_g(Fr,5,this),Cg(this,ps,0),this.velocity={x:0,y:0}}get delta(){return Yn.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=Yn.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-xg(this,ps),i=l=>Math.round(l/o*100);Yt(()=>{Sg(this,ps,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Yn.from(t)),this.velocity={x:0,y:0}}};Fr=yg(io);ps=new WeakMap;Ed(Fr,2,"delta",Ad,gi);Ed(Fr,2,"direction",Md,gi);wg(Fr,gi);var Td=(e=>(e.Horizontal="x",e.Vertical="y",e))(Td||{});Object.values(Td);const kg=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"}))]]),Ig=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"}))]]),Mg=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"}))]]),Ag=m.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Or=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:f,weight:p="regular",mirrored:d=!1,...h}=D.useContext(Ag);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:o||d?"scale(-1, 1)":void 0,...h,...c},!!n&&D.createElement("title",null,n),i,l.get(a??p))});Or.displayName="IconBase";const $d=D.forwardRef((e,t)=>D.createElement(Or,{ref:t,...e,weights:kg}));$d.displayName="DotsThreeIcon";const Rd=D.forwardRef((e,t)=>D.createElement(Or,{ref:t,...e,weights:Eg}));Rd.displayName="SpeakerHighIcon";const Dd=D.forwardRef((e,t)=>D.createElement(Or,{ref:t,...e,weights:Ig}));Dd.displayName="SpeakerLowIcon";const Pd=D.forwardRef((e,t)=>D.createElement(Or,{ref:t,...e,weights:Mg}));Pd.displayName="XIcon";const Tg=Pd;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 wi=F.button`
72
+ `;var vi=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
- `;F(wi)`
103
+ `;P(vi)`
104
104
  padding: 0.25rem 0.5rem;
105
105
  font-size: ${e=>e.theme.fontSizeSmall};
106
- `;F(wi)`
106
+ `;P(vi)`
107
107
  padding: 0.5rem;
108
108
  min-width: 2.25rem;
109
109
  min-height: 2.25rem;
110
- `;F(wi)`
110
+ `;P(vi)`
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 $g=F.div`
115
+ `;var $g=P.div`
116
116
  display: inline-flex;
117
117
  align-items: center;
118
118
  gap: 0.5rem;
119
- `,Rg=F.input`
119
+ `,Rg=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
- `,Dg=F.label`
126
+ `,Dg=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
- `,vt=F.button`
133
+ `,gt=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
- `,Fd=F.input`
159
+ `,Fd=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
- `;F(Fd)`
185
+ `;P(Fd)`
186
186
  padding: 0.25rem 0.5rem;
187
187
  font-size: ${e=>e.theme.fontSizeSmall};
188
- `;var Pg=F.label`
188
+ `;var Pg=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
- `;F.label`
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 Fg=F.span`
203
+ `;var Fg=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
- `,Od=F.select`
213
+ `,Od=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
- `;F(Od)`
246
+ `;P(Od)`
247
247
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
248
248
  font-size: ${e=>e.theme.fontSizeSmall};
249
- `;var Ld=F.input.attrs({type:"range"})`
249
+ `;var Ld=P.input.attrs({type:"range"})`
250
250
  -webkit-appearance: none;
251
251
  appearance: none;
252
252
  width: 100%;
@@ -326,21 +326,21 @@
326
326
  &:disabled::-moz-range-thumb {
327
327
  cursor: not-allowed;
328
328
  }
329
- `,Og=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.checked)};return C.jsxs($g,{className:r,children:[C.jsx(Rg,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:s,disabled:n}),C.jsx(Dg,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Bd(e){return typeof e=="object"&&e!==null&&"type"in e}function qt(e){if(!Bd(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 Wd={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"},Lg=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 a of this._listeners)a()})))}cancelPendingNotification(){this._notifyRafId!==null&&(cancelAnimationFrame(this._notifyRafId),this._notifyRafId=null)}},Vd=p.createContext(null),Bg=()=>()=>{},Wg=({containerRef:e,children:t})=>{const n=p.useRef(null);n.current===null&&(n.current=new Lg(e.current));const r=n.current,s=p.useRef(null),a=p.useCallback(()=>{const i=e.current;i&&r.update(i.scrollLeft,i.clientWidth)},[e,r]),o=p.useCallback(()=>{s.current===null&&(s.current=requestAnimationFrame(()=>{s.current=null,a()}))},[a]);return p.useLayoutEffect(()=>{a()},[a]),p.useEffect(()=>{const i=e.current;if(!i)return;i.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(()=>{o()});return l.observe(i),()=>{i.removeEventListener("scroll",o),l.disconnect(),s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),r.cancelPendingNotification()}},[e,o,r]),C.jsx(Vd.Provider,{value:r,children:t})};function Vg(e){const t=p.useContext(Vd);return p.useSyncExternalStore(t?t.subscribe:Bg,()=>e(t?t.getSnapshot():null),()=>e(null))}function Ks(e,t,n=0){const r=Vg(s=>{const a=Math.ceil(e/t),o=[];for(let i=0;i<a;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}o.push(i)}return o.join(",")});return p.useMemo(()=>r?r.split(",").map(Number):[],[r])}var Nd=p.createContext(0),Ng=({originX:e,children:t})=>C.jsx(Nd.Provider,{value:e,children:t}),_i=()=>p.useContext(Nd);function qs(){const e=p.useRef(new Map),t=p.useCallback(n=>{if(n!==null){const r=parseInt(n.dataset.index,10);e.current.set(r,n)}},[]);return p.useEffect(()=>{const n=e.current;for(const[r,s]of n.entries())s.isConnected||n.delete(r)}),{canvasRef:t,canvasMapRef:e}}function zg(e,t,n,r){if(n*2+1>=e.length)return null;const s=2**(t-1);let a=e[n*2]/s,o=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<a&&(a=l),c>o&&(o=c)}return{min:a,max:o}}function jg(e,t,n,r,s,a){const o=Math.abs(r*n),i=Math.abs(s*n);return a==="normal"?[{x:e,y:n-i,width:t,height:i+o}]:[{x:e,y:0,width:t,height:n-i},{x:e,y:n+o,width:t,height:n-o}]}function Zg(e,t,n){return Math.floor((e-t+n)/n)*n}function Hg(e,t,n,r){if(!Bd(t))return t;let s;t.direction==="vertical"?s=e.createLinearGradient(0,0,0,r):s=e.createLinearGradient(0,0,n,0);for(const a of t.stops)s.addColorStop(a.offset,a.color);return s}var Gg=F.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
329
+ `,Og=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.checked)};return C.jsxs($g,{className:r,children:[C.jsx(Rg,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:s,disabled:n}),C.jsx(Dg,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Bd(e){return typeof e=="object"&&e!==null&&"type"in e}function Kt(e){if(!Bd(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 Wd={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"},Lg=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 a of this._listeners)a()})))}cancelPendingNotification(){this._notifyRafId!==null&&(cancelAnimationFrame(this._notifyRafId),this._notifyRafId=null)}},Vd=m.createContext(null),Bg=()=>()=>{},Wg=({containerRef:e,children:t})=>{const n=m.useRef(null);n.current===null&&(n.current=new Lg(e.current));const r=n.current,s=m.useRef(null),a=m.useCallback(()=>{const i=e.current;i&&r.update(i.scrollLeft,i.clientWidth)},[e,r]),o=m.useCallback(()=>{s.current===null&&(s.current=requestAnimationFrame(()=>{s.current=null,a()}))},[a]);return m.useLayoutEffect(()=>{a()},[a]),m.useEffect(()=>{const i=e.current;if(!i)return;i.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(()=>{o()});return l.observe(i),()=>{i.removeEventListener("scroll",o),l.disconnect(),s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),r.cancelPendingNotification()}},[e,o,r]),C.jsx(Vd.Provider,{value:r,children:t})};function Vg(e){const t=m.useContext(Vd);return m.useSyncExternalStore(t?t.subscribe:Bg,()=>e(t?t.getSnapshot():null),()=>e(null))}function Us(e,t,n=0){const r=Vg(s=>{const a=Math.ceil(e/t),o=[];for(let i=0;i<a;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}o.push(i)}return o.join(",")});return m.useMemo(()=>r?r.split(",").map(Number):[],[r])}var Nd=m.createContext(0),Ng=({originX:e,children:t})=>C.jsx(Nd.Provider,{value:e,children:t}),yi=()=>m.useContext(Nd);function Xs(){const e=m.useRef(new Map),t=m.useCallback(n=>{if(n!==null){const r=parseInt(n.dataset.index,10);e.current.set(r,n)}},[]);return m.useEffect(()=>{const n=e.current;for(const[r,s]of n.entries())s.isConnected||n.delete(r)}),{canvasRef:t,canvasMapRef:e}}function jg(e,t,n,r){if(n*2+1>=e.length)return null;const s=2**(t-1);let a=e[n*2]/s,o=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<a&&(a=l),c>o&&(o=c)}return{min:a,max:o}}function zg(e,t,n,r,s,a){const o=Math.abs(r*n),i=Math.abs(s*n);return a==="normal"?[{x:e,y:n-i,width:t,height:i+o}]:[{x:e,y:0,width:t,height:n-i},{x:e,y:n+o,width:t,height:n-o}]}function Zg(e,t,n){return Math.floor((e-t+n)/n)*n}function Hg(e,t,n,r){if(!Bd(t))return t;let s;t.direction==="vertical"?s=e.createLinearGradient(0,0,0,r):s=e.createLinearGradient(0,0,n,0);for(const a of t.stops)s.addColorStop(a.offset,a.color);return s}var Gg=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
332
  /* Disable image rendering interpolation */
333
333
  image-rendering: pixelated;
334
334
  image-rendering: crisp-edges;
335
- `,Ug=F.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
335
+ `,Ug=P.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
336
336
  position: absolute;
337
337
  background: ${e=>e.$waveFillColor};
338
338
  /* Force GPU compositing layer to reduce scroll flickering */
339
339
  transform: translateZ(0);
340
340
  backface-visibility: hidden;
341
- `,zl=e=>{const{data:t,bits:n,length:r,index:s,className:a,devicePixelRatio:o=1,waveHeight:i=80,waveOutlineColor:l="#E0EFF1",waveFillColor:c="grey",barWidth:u=1,barGap:f=0,transparentBackground:m=!1,drawMode:d="inverted"}=e,{canvasRef:h,canvasMapRef:v}=qs(),g=_i(),y=Ks(r,Be,g);p.useLayoutEffect(()=>{const x=u+f;for(const[S,k]of v.current.entries()){const E=S*Be,M=k.getContext("2d"),T=Math.floor(i/2);if(M){M.resetTransform(),M.clearRect(0,0,k.width,k.height),M.imageSmoothingEnabled=!1,M.scale(o,o);const $=k.width/o;let A;d==="normal"?A=c:A=l,M.fillStyle=Hg(M,A,$,i);const I=E,R=E+$,D=Zg(I,u,x);for(let O=Math.max(0,D);O<R;O+=x){const Z=O-I;if(Z+u<=0)continue;const G=Math.min(O+x,r),Y=zg(t,n,O,G);if(Y){const te=jg(Z,u,T,Y.min,Y.max,d);for(const X of te)M.fillRect(X.x,X.y,X.width,X.height)}}}}},[v,t,n,i,l,c,o,r,u,f,d,y,s]);const b=y.map(x=>{const S=x*Be,k=Math.min(r-S,Be);return C.jsx(Gg,{$cssWidth:k,$left:S,width:k*o,height:i*o,$waveHeight:i,"data-index":x,ref:h},`${r}-${x}`)}),w=m?"transparent":qt(c);return C.jsx(Ug,{$index:s,$cssWidth:r,className:a,$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 p.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 xi=22,zd=F.div`
341
+ `,jl=e=>{const{data:t,bits:n,length:r,index:s,className:a,devicePixelRatio:o=1,waveHeight:i=80,waveOutlineColor:l="#E0EFF1",waveFillColor:c="grey",barWidth:u=1,barGap:f=0,transparentBackground:p=!1,drawMode:d="inverted"}=e,{canvasRef:h,canvasMapRef:v}=Xs(),g=yi(),y=Us(r,Le,g);m.useLayoutEffect(()=>{const x=u+f;for(const[S,k]of v.current.entries()){const E=S*Le,I=k.getContext("2d"),M=Math.floor(i/2);if(I){I.resetTransform(),I.clearRect(0,0,k.width,k.height),I.imageSmoothingEnabled=!1,I.scale(o,o);const T=k.width/o;let A;d==="normal"?A=c:A=l,I.fillStyle=Hg(I,A,T,i);const $=E,R=E+T,F=Zg($,u,x);for(let O=Math.max(0,F);O<R;O+=x){const G=O-$;if(G+u<=0)continue;const Q=Math.min(O+x,r),ee=jg(t,n,O,Q);if(ee){const ue=zg(G,u,M,ee.min,ee.max,d);for(const te of ue)I.fillRect(te.x,te.y,te.width,te.height)}}}}},[v,t,n,i,l,c,o,r,u,f,d,y,s]);const b=y.map(x=>{const S=x*Le,k=Math.min(r-S,Le);return C.jsx(Gg,{$cssWidth:k,$left:S,width:k*o,height:i*o,$waveHeight:i,"data-index":x,ref:h},`${r}-${x}`)}),_=p?"transparent":Kt(c);return C.jsx(Ug,{$index:s,$cssWidth:r,className:a,$waveHeight:i,$waveFillColor:_,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 m.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 bi=22,jd=P.div`
342
342
  position: relative;
343
- height: ${xi}px;
343
+ height: ${bi}px;
344
344
  background: ${e=>e.$isSelected?e.theme.selectedClipHeaderBackgroundColor:e.theme.clipHeaderBackgroundColor};
345
345
  border-bottom: 1px solid ${e=>e.theme.clipHeaderBorderColor};
346
346
  display: flex;
@@ -362,7 +362,7 @@
362
362
  cursor: grabbing;
363
363
  }
364
364
  `}
365
- `,jd=F.span`
365
+ `,zd=P.span`
366
366
  font-size: 11px;
367
367
  font-weight: 600;
368
368
  font-family: ${e=>e.theme.clipHeaderFontFamily};
@@ -370,7 +370,7 @@
370
370
  white-space: nowrap;
371
371
  overflow: hidden;
372
372
  text-overflow: ellipsis;
373
- `,Yg=({trackName:e,isSelected:t=!1})=>C.jsx(zd,{$interactive:!1,$isSelected:t,children:C.jsx(jd,{title:e,children:e})}),Kg=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:s=!1,disableDrag:a=!1,dragHandleProps:o})=>{if(a||!o)return C.jsx(Yg,{trackName:r,isSelected:s});const{handleRef:i}=o;return C.jsx(zd,{ref:i,"data-clip-id":e,$interactive:!0,$isSelected:s,children:C.jsx(jd,{title:r,children:r})})},qg=8,Jg=24,Qg=F.div`
373
+ `,Yg=({trackName:e,isSelected:t=!1})=>C.jsx(jd,{$interactive:!1,$isSelected:t,children:C.jsx(zd,{title:e,children:e})}),Kg=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:s=!1,disableDrag:a=!1,dragHandleProps:o})=>{if(a||!o)return C.jsx(Yg,{trackName:r,isSelected:s});const{handleRef:i}=o;return C.jsx(jd,{ref:i,"data-clip-id":e,$interactive:!0,$isSelected:s,children:C.jsx(zd,{title:r,children:r})})},qg=8,Jg=24,Qg=P.div`
374
374
  position: absolute;
375
375
  ${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
376
376
  top: 0;
@@ -398,19 +398,19 @@
398
398
  background: rgba(255, 255, 255, 0.4);
399
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);"}
400
400
  }
401
- `,jl=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:s,touchOptimized:a=!1})=>{const[o,i]=p.useState(!1);if(!s)return null;const{ref:l,isDragging:c}=s;return C.jsx(Qg,{ref:l,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:c,$isHovered:o,$touchOptimized:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1)})},ev=F.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
401
+ `,zl=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:s,touchOptimized:a=!1})=>{const[o,i]=m.useState(!1);if(!s)return null;const{ref:l,isDragging:c}=s;return C.jsx(Qg,{ref:l,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:c,$isHovered:o,$touchOptimized:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1)})},ev=P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
402
402
  position: absolute;
403
403
  top: 0;
404
404
  bottom: 0;
405
405
  pointer-events: none;
406
406
  z-index: 50;
407
- `,tv=F.svg`
407
+ `,tv=P.svg`
408
408
  width: 100%;
409
409
  height: 100%;
410
410
  display: block;
411
411
  /* Flip horizontally for fadeOut - makes it mirror of fadeIn */
412
412
  transform: ${e=>e.$type==="fadeOut"?"scaleX(-1)":"none"};
413
- `;function nv(e,t,n="logarithmic"){const r=[],s=Math.max(20,Math.min(e,100));for(let a=0;a<=s;a++){const o=a/s*e,i=a/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(`${o},${c}`)}return`M 0,${t} L ${r.join(" L ")} L ${e},0 L 0,0 Z`}var Zl=({left:e,width:t,type:n,curveType:r="logarithmic",color:s})=>{const a=F.useTheme();if(t<1)return null;const o=s||a?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return C.jsx(ev,{$left:e,$width:t,$type:n,children:C.jsx(tv,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:C.jsx("path",{d:nv(t,100,r),fill:o})})})},rv=F.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
413
+ `;function nv(e,t,n="logarithmic"){const r=[],s=Math.max(20,Math.min(e,100));for(let a=0;a<=s;a++){const o=a/s*e,i=a/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(`${o},${c}`)}return`M 0,${t} L ${r.join(" L ")} L ${e},0 L 0,0 Z`}var Zl=({left:e,width:t,type:n,curveType:r="logarithmic",color:s})=>{const a=P.useTheme();if(t<1)return null;const o=s||a?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return C.jsx(ev,{$left:e,$width:t,$type:n,children:C.jsx(tv,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:C.jsx("path",{d:nv(t,100,r),fill:o})})})},rv=P.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
414
414
  position: ${e=>e.$isOverlay?"relative":"absolute"};
415
415
  top: 0;
416
416
  height: ${e=>e.$isOverlay?"auto":"100%"};
@@ -419,30 +419,30 @@
419
419
  flex-direction: column;
420
420
  z-index: 10; /* Above progress overlay (z-index: 2) but below controls/playhead */
421
421
  pointer-events: none; /* Let clicks pass through to ClickOverlay for playhead positioning */
422
- `,sv=F.div`
422
+ `,sv=P.div`
423
423
  flex: 1;
424
424
  position: relative;
425
425
  overflow: ${e=>e.$isOverlay?"visible":"hidden"};
426
- `,fo=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:s,trackName:a,startSample:o,durationSamples:i,samplesPerPixel:l,showHeader:c=!1,disableHeaderDrag:u=!1,isOverlay:f=!1,isSelected:m=!1,onMouseDown:d,trackId:h,fadeIn:v,fadeOut:g,sampleRate:y=44100,showFades:b=!1,touchOptimized:_=!1})=>{const w=Math.floor(o/l),x=hc(o,i,l),S=c&&!u&&!f,k=`clip-${r}-${s}`,{ref:E,handleRef:M,isDragSource:T}=_a({id:k,data:{clipId:n,trackIndex:r,clipIndex:s,startSample:o,durationSamples:i},disabled:!S}),$=`clip-boundary-left-${r}-${s}`,{ref:A,isDragSource:I}=_a({id:$,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"left",startSample:o,durationSamples:i},disabled:!S,feedback:"none"}),R=`clip-boundary-right-${r}-${s}`,{ref:D,isDragSource:O}=_a({id:R,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"right",startSample:o,durationSamples:i},disabled:!S,feedback:"none"}),Z=T?{zIndex:100}:void 0;return C.jsxs(rv,{ref:E,style:Z,className:t,$left:w,$width:x,$isOverlay:f,"data-clip-container":"true","data-track-id":h,onMouseDown:d,tabIndex:-1,children:[c&&C.jsx(Kg,{clipId:n,trackIndex:r,clipIndex:s,trackName:a,isSelected:m,disableDrag:u,dragHandleProps:S?{handleRef:M}:void 0}),C.jsx(Ng,{originX:w,children:C.jsxs(sv,{$isOverlay:f,children:[e,b&&v&&v.duration>0&&C.jsx(Zl,{left:0,width:Math.floor(v.duration*y/l),type:"fadeIn",curveType:v.type}),b&&g&&g.duration>0&&C.jsx(Zl,{left:x-Math.floor(g.duration*y/l),width:Math.floor(g.duration*y/l),type:"fadeOut",curveType:g.type})]})}),c&&!u&&!f&&C.jsxs(C.Fragment,{children:[C.jsx(jl,{clipId:n,trackIndex:r,clipIndex:s,edge:"left",touchOptimized:_,dragHandleProps:{ref:A,isDragging:I}}),C.jsx(jl,{clipId:n,trackIndex:r,clipIndex:s,edge:"right",touchOptimized:_,dragHandleProps:{ref:D,isDragging:O}})]})]})},av=F.div`
426
+ `,lo=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:s,trackName:a,startSample:o,durationSamples:i,samplesPerPixel:l,showHeader:c=!1,disableHeaderDrag:u=!1,isOverlay:f=!1,isSelected:p=!1,onMouseDown:d,trackId:h,fadeIn:v,fadeOut:g,sampleRate:y=44100,showFades:b=!1,touchOptimized:w=!1})=>{const _=Math.floor(o/l),x=hc(o,i,l),S=c&&!u&&!f,k=`clip-${r}-${s}`,{ref:E,handleRef:I,isDragSource:M}=ya({id:k,data:{clipId:n,trackIndex:r,clipIndex:s,startSample:o,durationSamples:i},disabled:!S}),T=`clip-boundary-left-${r}-${s}`,{ref:A,isDragSource:$}=ya({id:T,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"left",startSample:o,durationSamples:i},disabled:!S,feedback:"none"}),R=`clip-boundary-right-${r}-${s}`,{ref:F,isDragSource:O}=ya({id:R,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"right",startSample:o,durationSamples:i},disabled:!S,feedback:"none"}),G=M?{zIndex:100}:void 0;return C.jsxs(rv,{ref:E,style:G,className:t,$left:_,$width:x,$isOverlay:f,"data-clip-container":"true","data-track-id":h,onMouseDown:d,tabIndex:-1,children:[c&&C.jsx(Kg,{clipId:n,trackIndex:r,clipIndex:s,trackName:a,isSelected:p,disableDrag:u,dragHandleProps:S?{handleRef:I}:void 0}),C.jsx(Ng,{originX:_,children:C.jsxs(sv,{$isOverlay:f,children:[e,b&&v&&v.duration>0&&C.jsx(Zl,{left:0,width:Math.floor(v.duration*y/l),type:"fadeIn",curveType:v.type}),b&&g&&g.duration>0&&C.jsx(Zl,{left:x-Math.floor(g.duration*y/l),width:Math.floor(g.duration*y/l),type:"fadeOut",curveType:g.type})]})}),c&&!u&&!f&&C.jsxs(C.Fragment,{children:[C.jsx(zl,{clipId:n,trackIndex:r,clipIndex:s,edge:"left",touchOptimized:w,dragHandleProps:{ref:A,isDragging:$}}),C.jsx(zl,{clipId:n,trackIndex:r,clipIndex:s,edge:"right",touchOptimized:w,dragHandleProps:{ref:F,isDragging:O}})]})]})},av=P.div`
427
427
  display: inline-flex;
428
428
  align-items: center;
429
429
  gap: 0.5rem;
430
- `,ov=F(Pg)`
430
+ `,ov=P(Pg)`
431
431
  margin: 0;
432
432
  white-space: nowrap;
433
- `,iv=F(Ld)`
433
+ `,iv=P(Ld)`
434
434
  width: 120px;
435
- `,lv=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(parseFloat(a.target.value)/100)};return C.jsxs(av,{className:r,children:[C.jsx(ov,{htmlFor:"master-gain",children:"Master Volume"}),C.jsx(iv,{min:"0",max:"100",value:e*100,onChange:s,disabled:n,id:"master-gain"})]})},cv=F.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
435
+ `,lv=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(parseFloat(a.target.value)/100)};return C.jsxs(av,{className:r,children:[C.jsx(ov,{htmlFor:"master-gain",children:"Master Volume"}),C.jsx(iv,{min:"0",max:"100",value:e*100,onChange:s,disabled:n,id:"master-gain"})]})},cv=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
436
436
  position: absolute;
437
437
  top: 0;
438
438
  image-rendering: pixelated;
439
439
  image-rendering: crisp-edges;
440
- `,uv=F.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
440
+ `,uv=P.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
441
441
  position: absolute;
442
442
  background: ${e=>e.$backgroundColor};
443
443
  transform: translateZ(0);
444
444
  backface-visibility: hidden;
445
- `,dv=({index:e,midiNotes:t,length:n,waveHeight:r,devicePixelRatio:s,samplesPerPixel:a,sampleRate:o,clipOffsetSeconds:i,noteColor:l="#2a7070",selectedNoteColor:c="#3d9e9e",isSelected:u=!1,transparentBackground:f=!1,backgroundColor:m="#1a1a2e"})=>{const{canvasRef:d,canvasMapRef:h}=qs(),v=_i(),g=Ks(n,Be,v),{minMidi:y,maxMidi:b}=p.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;p.useLayoutEffect(()=>{const S=b-y+1,k=Math.max(2,r/S),E=o/a;for(const[M,T]of h.current.entries()){const $=M*Be,A=T.width/s,I=T.getContext("2d");if(!I)continue;I.resetTransform(),I.clearRect(0,0,T.width,T.height),I.imageSmoothingEnabled=!1,I.scale(s,s);const R=$*a/o,D=($+A)*a/o;for(const O of t){const Z=O.time-i;if(Z+O.duration<=R||Z>=D)continue;const Y=Z*E-$,te=Math.max(2,O.duration*E),X=(b-O.midi)/S*r,K=.3+O.velocity*.7;I.fillStyle=_,I.globalAlpha=K;const le=1;I.beginPath(),I.roundRect(Y,X,te,k,le),I.fill()}I.globalAlpha=1}},[h,t,r,s,a,o,i,_,y,b,n,g,e]);const w=g.map(S=>{const k=S*Be,E=Math.min(n-k,Be);return C.jsx(cv,{$cssWidth:E,$left:k,width:E*s,height:r*s,$waveHeight:r,"data-index":S,ref:d},`${n}-${S}`)}),x=f?"transparent":m;return C.jsx(uv,{$index:e,$cssWidth:n,$waveHeight:r,$backgroundColor:x,children:w})};F.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
445
+ `,dv=({index:e,midiNotes:t,length:n,waveHeight:r,devicePixelRatio:s,samplesPerPixel:a,sampleRate:o,clipOffsetSeconds:i,noteColor:l="#2a7070",selectedNoteColor:c="#3d9e9e",isSelected:u=!1,transparentBackground:f=!1,backgroundColor:p="#1a1a2e"})=>{const{canvasRef:d,canvasMapRef:h}=Xs(),v=yi(),g=Us(n,Le,v),{minMidi:y,maxMidi:b}=m.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]),w=u?c:l;m.useLayoutEffect(()=>{const S=b-y+1,k=Math.max(2,r/S),E=o/a;for(const[I,M]of h.current.entries()){const T=I*Le,A=M.width/s,$=M.getContext("2d");if(!$)continue;$.resetTransform(),$.clearRect(0,0,M.width,M.height),$.imageSmoothingEnabled=!1,$.scale(s,s);const R=T*a/o,F=(T+A)*a/o;for(const O of t){const G=O.time-i;if(G+O.duration<=R||G>=F)continue;const ee=G*E-T,ue=Math.max(2,O.duration*E),te=(b-O.midi)/S*r,oe=.3+O.velocity*.7;$.fillStyle=w,$.globalAlpha=oe;const se=1;$.beginPath(),$.roundRect(ee,te,ue,k,se),$.fill()}$.globalAlpha=1}},[h,t,r,s,a,o,i,w,y,b,n,g,e]);const _=g.map(S=>{const k=S*Le,E=Math.min(n-k,Le);return C.jsx(cv,{$cssWidth:E,$left:k,width:E*s,height:r*s,$waveHeight:r,"data-index":S,ref:d},`${n}-${S}`)}),x=f?"transparent":p;return C.jsx(uv,{$index:e,$cssWidth:n,$waveHeight:r,$backgroundColor:x,children:_})};P.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
446
446
  position: absolute;
447
447
  top: 0;
448
448
  left: 0;
@@ -452,7 +452,7 @@
452
452
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
453
453
  pointer-events: none;
454
454
  will-change: transform;
455
- `;F.div`
455
+ `;P.div`
456
456
  position: absolute;
457
457
  top: 0;
458
458
  left: 0;
@@ -460,7 +460,7 @@
460
460
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
461
461
  pointer-events: none;
462
462
  will-change: transform;
463
- `;F.div`
463
+ `;P.div`
464
464
  position: absolute;
465
465
  top: -10px;
466
466
  left: -6px;
@@ -469,39 +469,39 @@
469
469
  border-left: 7px solid transparent;
470
470
  border-right: 7px solid transparent;
471
471
  border-top: 10px solid ${e=>e.$color};
472
- `;F.div`
472
+ `;P.div`
473
473
  position: absolute;
474
474
  top: 0;
475
475
  left: 0;
476
476
  width: 2px;
477
477
  height: 100%;
478
478
  background: ${e=>e.$color};
479
- `;var fv=F.div`
479
+ `;var fv=P.div`
480
480
  display: flex;
481
481
  overflow-y: hidden;
482
482
  position: relative;
483
- `,hv=F.div.attrs(e=>({style:{width:`${e.$width}px`}}))`
483
+ `,hv=P.div.attrs(e=>({style:{width:`${e.$width}px`}}))`
484
484
  flex-shrink: 0;
485
485
  overflow: hidden;
486
- `,pv=F.div.attrs(e=>({style:{height:`${e.$height}px`}}))``,mv=F.div`
486
+ `,pv=P.div.attrs(e=>({style:{height:`${e.$height}px`}}))``,mv=P.div`
487
487
  overflow-x: auto;
488
488
  overflow-y: hidden;
489
489
  overflow-anchor: none;
490
490
  flex: 1;
491
491
  position: relative;
492
- `,gv=F.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
492
+ `,gv=P.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
493
493
  position: relative;
494
494
  background: ${e=>e.$backgroundColor||"transparent"};
495
- `,vv=F.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
495
+ `,vv=P.div.attrs(e=>({style:e.$width?{minWidth:`${e.$width}px`}:{}}))`
496
496
  background: ${e=>e.$backgroundColor||"white"};
497
497
  width: 100%;
498
498
  position: relative;
499
499
  overflow: hidden; /* Constrain loop region to timescale area */
500
- `,yv=F.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
500
+ `,yv=P.div.attrs(e=>({style:e.$width!==void 0?{minWidth:`${e.$width}px`}:{}}))`
501
501
  position: relative;
502
502
  background: ${e=>e.$backgroundColor||"transparent"};
503
503
  width: 100%;
504
- `,bv=F.div`
504
+ `,bv=P.div`
505
505
  position: absolute;
506
506
  top: 0;
507
507
  left: 0;
@@ -510,7 +510,7 @@
510
510
  cursor: crosshair;
511
511
  /* When selecting, raise z-index above clip boundaries (z-index: 105) to prevent interference */
512
512
  z-index: ${e=>e.$isSelecting?110:1};
513
- `,Ci=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:s,tracksWidth:a,controlsWidth:o,onTracksClick:i,onTracksMouseDown:l,onTracksMouseMove:c,onTracksMouseUp:u,scrollContainerRef:f,isSelecting:m,"data-playlist-state":d,trackControlsSlots:h,timescaleGapHeight:v=0})=>{const g=p.useRef(null),y=p.useCallback(_=>{g.current=_,f?.(_)},[f]),b=o!==void 0&&o>0;return C.jsxs(fv,{"data-playlist-state":d,children:[b&&C.jsxs(hv,{$width:o,children:[v>0&&C.jsx(pv,{$height:v}),h]}),C.jsx(mv,{"data-scroll-container":"true",ref:y,children:C.jsx(Wg,{containerRef:g,children:C.jsxs(gv,{$backgroundColor:t,$width:a,children:[r&&C.jsx(vv,{$width:s,$backgroundColor:n,children:r}),C.jsxs(yv,{$width:a,$backgroundColor:t,children:[e,(i||l)&&C.jsx(bv,{$isSelecting:m,onClick:i,onMouseDown:l,onMouseMove:c,onMouseUp:u})]})]})})})]})};F.withTheme(Ci);var wv=F.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
513
+ `,wi=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:s,tracksWidth:a,controlsWidth:o,onTracksClick:i,onTracksMouseDown:l,onTracksMouseMove:c,onTracksMouseUp:u,scrollContainerRef:f,isSelecting:p,"data-playlist-state":d,trackControlsSlots:h,timescaleGapHeight:v=0})=>{const g=m.useRef(null),y=m.useCallback(w=>{g.current=w,f?.(w)},[f]),b=o!==void 0&&o>0;return C.jsxs(fv,{"data-playlist-state":d,children:[b&&C.jsxs(hv,{$width:o,children:[v>0&&C.jsx(pv,{$height:v}),h]}),C.jsx(mv,{"data-scroll-container":"true",ref:y,children:C.jsx(Wg,{containerRef:g,children:C.jsxs(gv,{$backgroundColor:t,$width:a,children:[r&&C.jsx(vv,{$width:s,$backgroundColor:n,children:r}),C.jsxs(yv,{$width:a,$backgroundColor:t,children:[e,(i||l)&&C.jsx(bv,{$isSelecting:p,onClick:i,onMouseDown:l,onMouseMove:c,onMouseUp:u})]})]})})})]})};P.withTheme(wi);var wv=P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
514
514
  position: absolute;
515
515
  top: 0;
516
516
  background: ${e=>e.$color};
@@ -518,14 +518,14 @@
518
518
  z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
519
519
  pointer-events: none;
520
520
  opacity: 0.3;
521
- `,Zd=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:C.jsx(wv,{$left:e,$width:r,$color:n,"data-selection":!0})};F.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
521
+ `,Zd=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:C.jsx(wv,{$left:e,$width:r,$color:n,"data-selection":!0})};P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
522
522
  position: absolute;
523
523
  top: 0;
524
524
  background: ${e=>e.$color};
525
525
  height: 100%;
526
526
  z-index: 55; /* Between clips (z-index: 50) and selection (z-index: 60) */
527
527
  pointer-events: none;
528
- `;F.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
528
+ `;P.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
529
529
  position: absolute;
530
530
  top: 0;
531
531
  width: 2px;
@@ -545,7 +545,7 @@
545
545
  border-top: 8px solid ${e=>e.$color};
546
546
  ${e=>e.$isStart?"border-right: 8px solid transparent;":"border-left: 8px solid transparent;"}
547
547
  }
548
- `;var Hl=F.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
548
+ `;var Hl=P.div.attrs(e=>({style:{left:`${e.$left}px`}}))`
549
549
  position: absolute;
550
550
  top: 0;
551
551
  width: 12px;
@@ -582,7 +582,7 @@
582
582
  &:hover::before {
583
583
  opacity: 1;
584
584
  }
585
- `,_v=F.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
585
+ `,_v=P.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
586
586
  position: absolute;
587
587
  top: 0;
588
588
  height: 100%;
@@ -593,7 +593,7 @@
593
593
  &:active {
594
594
  cursor: grabbing;
595
595
  }
596
- `,xv=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopStartChange:s,onLoopEndChange:a,onLoopRegionMove:o,minPosition:i=0,maxPosition:l=1/0})=>{const[c,u]=p.useState(null),f=p.useRef(0),m=p.useRef(0),d=p.useRef(0),h=Math.max(0,t-e),v=p.useCallback((y,b)=>{y.preventDefault(),y.stopPropagation(),u(b),f.current=y.clientX,m.current=b==="start"?e:t;const _=x=>{const S=x.clientX-f.current,k=m.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));a?.(E)}},w=()=>{u(null),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",w)},[e,t,i,l,s,a]),g=p.useCallback(y=>{y.preventDefault(),y.stopPropagation(),u("region"),f.current=y.clientX,m.current=e,d.current=t;const b=t-e,_=x=>{const S=x.clientX-f.current;let k=m.current+S,E=d.current+S;k<i&&(k=i,E=i+b),E>l&&(E=l,k=l-b),o?.(k,E)},w=()=>{u(null),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",w)},[e,t,i,l,o]);return h<=0?null:C.jsxs(C.Fragment,{children:[C.jsx(_v,{$left:e,$width:h,$color:r,$isDragging:c==="region",onMouseDown:g,"data-loop-region-timescale":!0}),C.jsx(Hl,{$left:e,$color:n,$isStart:!0,$isDragging:c==="start",onMouseDown:y=>v(y,"start"),"data-loop-marker-handle":"start"}),C.jsx(Hl,{$left:t,$color:n,$isStart:!1,$isDragging:c==="end",onMouseDown:y=>v(y,"end"),"data-loop-marker-handle":"end"})]})},Cv=F.div`
596
+ `,xv=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopStartChange:s,onLoopEndChange:a,onLoopRegionMove:o,minPosition:i=0,maxPosition:l=1/0})=>{const[c,u]=m.useState(null),f=m.useRef(0),p=m.useRef(0),d=m.useRef(0),h=Math.max(0,t-e),v=m.useCallback((y,b)=>{y.preventDefault(),y.stopPropagation(),u(b),f.current=y.clientX,p.current=b==="start"?e:t;const w=x=>{const S=x.clientX-f.current,k=p.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));a?.(E)}},_=()=>{u(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",_)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",_)},[e,t,i,l,s,a]),g=m.useCallback(y=>{y.preventDefault(),y.stopPropagation(),u("region"),f.current=y.clientX,p.current=e,d.current=t;const b=t-e,w=x=>{const S=x.clientX-f.current;let k=p.current+S,E=d.current+S;k<i&&(k=i,E=i+b),E>l&&(E=l,k=l-b),o?.(k,E)},_=()=>{u(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",_)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",_)},[e,t,i,l,o]);return h<=0?null:C.jsxs(C.Fragment,{children:[C.jsx(_v,{$left:e,$width:h,$color:r,$isDragging:c==="region",onMouseDown:g,"data-loop-region-timescale":!0}),C.jsx(Hl,{$left:e,$color:n,$isStart:!0,$isDragging:c==="start",onMouseDown:y=>v(y,"start"),"data-loop-marker-handle":"start"}),C.jsx(Hl,{$left:t,$color:n,$isStart:!1,$isDragging:c==="end",onMouseDown:y=>v(y,"end"),"data-loop-marker-handle":"end"})]})},Cv=P.div`
597
597
  position: absolute;
598
598
  top: 0;
599
599
  left: 0;
@@ -601,17 +601,17 @@
601
601
  height: 100%; /* Stay within timescale bounds, don't extend into tracks */
602
602
  cursor: crosshair;
603
603
  z-index: 40; /* Below markers and shading */
604
- `,Sv=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopRegionChange:s,minPosition:a=0,maxPosition:o=1/0})=>{const[,i]=p.useState(!1),l=p.useRef(0),c=p.useRef(null),u=t>e,f=p.useCallback(m=>{const d=m.target;if(d.closest("[data-loop-marker-handle]")||d.closest("[data-loop-region-timescale]"))return;m.preventDefault(),i(!0);const h=c.current?.getBoundingClientRect();if(!h)return;const v=m.clientX-h.left,g=Math.max(a,Math.min(o,v));l.current=g,s?.(g,g);const y=_=>{const w=_.clientX-h.left,x=Math.max(a,Math.min(o,w)),S=Math.min(l.current,x),k=Math.max(l.current,x);s?.(S,k)},b=()=>{i(!1),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",y),document.addEventListener("mouseup",b)},[a,o,s]);return C.jsx(Cv,{ref:c,onMouseDown:f,"data-timescale-loop-creator":!0,children:u&&C.jsx(xv,{startPosition:e,endPosition:t,markerColor:n,regionColor:r,minPosition:a,maxPosition:o,onLoopStartChange:m=>s?.(m,t),onLoopEndChange:m=>s?.(e,m),onLoopRegionMove:(m,d)=>s?.(m,d)})})};function Jn(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>0?t+3:2,"0")}function Pn(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return Jn(e,0);case"hh:mm:ss.u":return Jn(e,1);case"hh:mm:ss.uu":return Jn(e,2);case"hh:mm:ss.uuu":return Jn(e,3);default:return Jn(e,3)}}function Hd(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,a=parseFloat(n[2])||0;return r*3600+s*60+a}default:return 0}}var Gl=({id:e,label:t,value:n,format:r,className:s,onChange:a,readOnly:o=!1})=>{const[i,l]=p.useState("");p.useEffect(()=>{const m=Pn(n,r);l(m)},[n,r,e]);const c=m=>{const d=m.target.value;l(d)},u=()=>{if(a){const m=Hd(i,r);a(m)}l(Pn(n,r))},f=m=>{m.key==="Enter"&&m.currentTarget.blur()};return C.jsxs(C.Fragment,{children:[C.jsx(Fg,{as:"label",htmlFor:e,children:t}),C.jsx(Fd,{type:"text",className:s,id:e,value:i,onChange:c,onBlur:u,onKeyDown:f,readOnly:o})]})},kv=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[s,a]=p.useState("hh:mm:ss.uuu");p.useEffect(()=>{const l=document.querySelector(".time-format"),c=()=>{l&&a(l.value)};return l&&(a(l.value),l.addEventListener("change",c)),()=>{l?.removeEventListener("change",c)}},[]);const o=l=>{n&&n(l,t)},i=l=>{n&&n(e,l)};return C.jsxs("div",{className:r,children:[C.jsx(Gl,{id:"audio_start",label:"Start of audio selection",value:e,format:s,className:"audio-start form-control mr-sm-2",onChange:o}),C.jsx(Gl,{id:"audio_end",label:"End of audio selection",value:t,format:s,className:"audio-end form-control mr-sm-2",onChange:i})]})},Ev=p.createContext(null);function Gd(){return p.useContext(Ev)}function ys(){return window.devicePixelRatio}var Ud=p.createContext(ys()),Xd=({children:e})=>{const[t,n]=p.useState(ys());return matchMedia(`(resolution: ${ys()}dppx)`).addEventListener("change",()=>{n(ys())},{once:!0}),C.jsx(Ud.Provider,{value:Math.ceil(t),children:e})},Si=()=>p.useContext(Ud),Wr=p.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}),Js=()=>p.useContext(Wr),Vr=()=>p.useContext(F.ThemeContext);p.createContext(C.jsx(p.Fragment,{}));var Iv=0,Mv=!1,Av=0,Tv=0,$v={progress:Iv,isPlaying:Mv,selectionStart:Av,selectionEnd:Tv};p.createContext($v);p.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var Rv=(e,t,n)=>(e-t)/(n-t),Dv=F.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
604
+ `,Sv=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopRegionChange:s,minPosition:a=0,maxPosition:o=1/0})=>{const[,i]=m.useState(!1),l=m.useRef(0),c=m.useRef(null),u=t>e,f=m.useCallback(p=>{const d=p.target;if(d.closest("[data-loop-marker-handle]")||d.closest("[data-loop-region-timescale]"))return;p.preventDefault(),i(!0);const h=c.current?.getBoundingClientRect();if(!h)return;const v=p.clientX-h.left,g=Math.max(a,Math.min(o,v));l.current=g,s?.(g,g);const y=w=>{const _=w.clientX-h.left,x=Math.max(a,Math.min(o,_)),S=Math.min(l.current,x),k=Math.max(l.current,x);s?.(S,k)},b=()=>{i(!1),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",y),document.addEventListener("mouseup",b)},[a,o,s]);return C.jsx(Cv,{ref:c,onMouseDown:f,"data-timescale-loop-creator":!0,children:u&&C.jsx(xv,{startPosition:e,endPosition:t,markerColor:n,regionColor:r,minPosition:a,maxPosition:o,onLoopStartChange:p=>s?.(p,t),onLoopEndChange:p=>s?.(e,p),onLoopRegionMove:(p,d)=>s?.(p,d)})})};function Kn(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>0?t+3:2,"0")}function Dn(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return Kn(e,0);case"hh:mm:ss.u":return Kn(e,1);case"hh:mm:ss.uu":return Kn(e,2);case"hh:mm:ss.uuu":return Kn(e,3);default:return Kn(e,3)}}function Hd(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,a=parseFloat(n[2])||0;return r*3600+s*60+a}default:return 0}}var Gl=({id:e,label:t,value:n,format:r,className:s,onChange:a,readOnly:o=!1})=>{const[i,l]=m.useState("");m.useEffect(()=>{const p=Dn(n,r);l(p)},[n,r,e]);const c=p=>{const d=p.target.value;l(d)},u=()=>{if(a){const p=Hd(i,r);a(p)}l(Dn(n,r))},f=p=>{p.key==="Enter"&&p.currentTarget.blur()};return C.jsxs(C.Fragment,{children:[C.jsx(Fg,{as:"label",htmlFor:e,children:t}),C.jsx(Fd,{type:"text",className:s,id:e,value:i,onChange:c,onBlur:u,onKeyDown:f,readOnly:o})]})},kv=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[s,a]=m.useState("hh:mm:ss.uuu");m.useEffect(()=>{const l=document.querySelector(".time-format"),c=()=>{l&&a(l.value)};return l&&(a(l.value),l.addEventListener("change",c)),()=>{l?.removeEventListener("change",c)}},[]);const o=l=>{n&&n(l,t)},i=l=>{n&&n(e,l)};return C.jsxs("div",{className:r,children:[C.jsx(Gl,{id:"audio_start",label:"Start of audio selection",value:e,format:s,className:"audio-start form-control mr-sm-2",onChange:o}),C.jsx(Gl,{id:"audio_end",label:"End of audio selection",value:t,format:s,className:"audio-end form-control mr-sm-2",onChange:i})]})},Ev=m.createContext(null);function Gd(){return m.useContext(Ev)}function ms(){return window.devicePixelRatio}var Ud=m.createContext(ms()),Xd=({children:e})=>{const[t,n]=m.useState(ms());return matchMedia(`(resolution: ${ms()}dppx)`).addEventListener("change",()=>{n(ms())},{once:!0}),C.jsx(Ud.Provider,{value:Math.ceil(t),children:e})},_i=()=>m.useContext(Ud),Lr=m.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}),Ys=()=>m.useContext(Lr),Br=()=>m.useContext(P.ThemeContext);m.createContext(C.jsx(m.Fragment,{}));var Iv=0,Mv=!1,Av=0,Tv=0,$v={progress:Iv,isPlaying:Mv,selectionStart:Av,selectionEnd:Tv};m.createContext($v);m.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var Rv=P.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
605
605
  position: absolute;
606
606
  background: #000;
607
607
  transform: translateZ(0);
608
608
  backface-visibility: hidden;
609
- `,Pv=F.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
609
+ `,Dv=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
610
610
  position: absolute;
611
611
  top: 0;
612
612
  image-rendering: pixelated;
613
613
  image-rendering: crisp-edges;
614
- `;function Fv(){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 Ov=Fv(),Ul=({index:e,channelIndex:t,data:n,length:r,waveHeight:s,devicePixelRatio:a=1,samplesPerPixel:o,colorLUT:i,frequencyScaleFn:l,minFrequency:c=0,maxFrequency:u,workerApi:f,clipId:m,onCanvasesReady:d})=>{const h=t??e,{canvasRef:v,canvasMapRef:g}=qs(),y=p.useRef([]),b=p.useRef(new WeakSet),_=p.useRef(f),w=p.useRef(d),x=!!(f&&m),S=_i(),k=Ks(r,Be,S),E=i??Ov,M=u??(n?n.sampleRate/2:22050),T=l??Rv,$=!!l;p.useEffect(()=>{_.current=f},[f]),p.useEffect(()=>{w.current=d},[d]),p.useEffect(()=>{if(!x)return;const I=_.current;if(!I||!m)return;const R=y.current.length,D=[];for(const G of y.current){const Y=G.match(/chunk(\d+)$/);if(!Y){D.push(G);continue}const te=parseInt(Y[1],10),X=g.current.get(te);if(X&&X.isConnected)D.push(G);else try{I.unregisterCanvas(G)}catch(K){console.warn(`[spectrogram] unregisterCanvas failed for ${G}:`,K)}}y.current=D;const O=[];for(const[G,Y]of g.current.entries()){if(b.current.has(Y))continue;const te=`${m}-ch${h}-chunk${G}`;let X;try{X=Y.transferControlToOffscreen()}catch(K){console.warn(`[spectrogram] transferControlToOffscreen failed for ${te}:`,K);continue}b.current.add(Y);try{I.registerCanvas(te,X),O.push(te)}catch(K){console.warn(`[spectrogram] registerCanvas failed for ${te}:`,K);continue}}if(O.length>0&&(y.current=[...y.current,...O]),O.length>0||D.length<R){const G=y.current,Y=G.map(te=>{const X=te.match(/chunk(\d+)$/);if(!X)return console.warn(`[spectrogram] Unexpected canvas ID format: ${te}`),Be;const K=parseInt(X[1],10);return Math.min(r-K*Be,Be)});w.current?.(G,Y)}},[g,x,m,h,r,k]),p.useEffect(()=>()=>{const I=_.current;if(I){for(const R of y.current)try{I.unregisterCanvas(R)}catch(D){console.warn(`[spectrogram] unregisterCanvas failed for ${R}:`,D)}y.current=[]}},[]),p.useLayoutEffect(()=>{if(x||!n)return;const{frequencyBinCount:I,frameCount:R,hopSize:D,sampleRate:O,gainDb:Z,rangeDb:G}=n,Y=G===0?1:G,te=X=>X/I*(O/2);for(const[X,K]of g.current.entries()){const le=X*Be,J=K.getContext("2d");if(!J)continue;const de=K.width/a,ue=s;J.resetTransform(),J.clearRect(0,0,K.width,K.height),J.imageSmoothingEnabled=!1,J.scale(a,a);const ne=J.createImageData(de,ue),z=ne.data;for(let ae=0;ae<de;ae++){const ce=(le+ae)*o,xe=Math.floor(ce/D);if(xe<0||xe>=R)continue;const B=xe*I;for(let _e=0;_e<ue;_e++){const re=1-_e/ue;let Me=Math.floor(re*I);if($){let Ve=0,Le=I-1;for(;Ve<Le;){const je=Ve+Le>>1,tt=te(je);T(tt,c,M)<re?Ve=je+1:Le=je}Me=Ve}if(Me<0||Me>=I)continue;const pe=n.data[B+Me],Ae=Math.max(0,Math.min(1,(pe+Y+Z)/Y)),He=Math.floor(Ae*255),qe=(_e*de+ae)*4;z[qe]=E[He*3],z[qe+1]=E[He*3+1],z[qe+2]=E[He*3+2],z[qe+3]=255}}if(J.resetTransform(),J.putImageData(ne,0,0),a!==1){const ae=document.createElement("canvas");ae.width=de,ae.height=ue;const ke=ae.getContext("2d");if(!ke)continue;ke.putImageData(ne,0,0),J.clearRect(0,0,K.width,K.height),J.imageSmoothingEnabled=!1,J.drawImage(ae,0,0,K.width,K.height)}}},[g,x,n,r,s,a,o,E,c,M,T,$,k]);const A=k.map(I=>{const R=I*Be,D=Math.min(r-R,Be);return C.jsx(Pv,{$cssWidth:D,$left:R,width:D*a,height:s*a,$waveHeight:s,"data-index":I,ref:v},`${r}-${I}`)});return C.jsx(Dv,{$index:e,$cssWidth:r,$waveHeight:s,children:A})},Yd=({isSelected:e,transparentBackground:t,renderMode:n="waveform",spectrogramData:r,spectrogramColorLUT:s,samplesPerPixel:a,spectrogramFrequencyScaleFn:o,spectrogramMinFrequency:i,spectrogramMaxFrequency:l,spectrogramWorkerApi:c,spectrogramClipId:u,spectrogramOnCanvasesReady:f,midiNotes:m,sampleRate:d,clipOffsetSeconds:h,...v})=>{const g=Vr(),{waveHeight:y,barWidth:b,barGap:_,samplesPerPixel:w,sampleRate:x}=Js(),S=Si(),k=a??w,E=e&&g?g.selectedWaveOutlineColor:g?.waveOutlineColor,M=e&&g?g.selectedWaveFillColor:g?.waveFillColor,T=g?.waveformDrawMode||"inverted",$=r||c;if(n==="spectrogram"&&$)return C.jsx(Ul,{index:v.index,data:r,length:v.length,waveHeight:y,devicePixelRatio:S,samplesPerPixel:k,colorLUT:s,frequencyScaleFn:o,minFrequency:i,maxFrequency:l,workerApi:c,clipId:u,onCanvasesReady:f});if(n==="both"&&$){const A=Math.floor(y/2);return C.jsxs(C.Fragment,{children:[C.jsx(Ul,{index:v.index*2,channelIndex:v.index,data:r,length:v.length,waveHeight:A,devicePixelRatio:S,samplesPerPixel:k,colorLUT:s,frequencyScaleFn:o,minFrequency:i,maxFrequency:l,workerApi:c,clipId:u,onCanvasesReady:f}),C.jsx("div",{style:{position:"absolute",top:(v.index*2+1)*A,width:v.length,height:A},children:C.jsx(zl,{...v,index:0,waveOutlineColor:E,waveFillColor:M,waveHeight:A,devicePixelRatio:S,barWidth:b,barGap:_,transparentBackground:t,drawMode:T})})]})}return n==="piano-roll"?C.jsx(dv,{index:v.index,midiNotes:m??[],length:v.length,waveHeight:y,devicePixelRatio:S,samplesPerPixel:k,sampleRate:d??x,clipOffsetSeconds:h??0,noteColor:g?.pianoRollNoteColor,selectedNoteColor:g?.pianoRollSelectedNoteColor,isSelected:e,transparentBackground:t,backgroundColor:g?.pianoRollBackgroundColor}):C.jsx(zl,{...v,waveOutlineColor:E,waveFillColor:M,waveHeight:y,devicePixelRatio:S,barWidth:b,barGap:_,transparentBackground:t,drawMode:T})},Xl=72,Lv=F.div`
614
+ `,Ul=({index:e,channelIndex:t,length:n,waveHeight:r,devicePixelRatio:s=1,samplesPerPixel:a,workerApi:o,clipId:i,onCanvasesReady:l})=>{const c=t??e,{canvasRef:u,canvasMapRef:f}=Xs(),p=m.useRef([]),d=m.useRef(new WeakSet),h=m.useRef(o),v=m.useRef(l),g=yi(),y=Us(n,Le,g);m.useEffect(()=>{h.current=o},[o]),m.useEffect(()=>{v.current=l},[l]),m.useEffect(()=>{const w=h.current;if(!w||!i)return;const _=p.current.length,x=[];for(const E of p.current){const I=E.match(/chunk(\d+)$/);if(!I){x.push(E);continue}const M=parseInt(I[1],10),T=f.current.get(M);if(T&&T.isConnected)x.push(E);else try{w.unregisterCanvas(E)}catch(A){console.warn(`[spectrogram] unregisterCanvas failed for ${E}:`,A)}}p.current=x;const S=[];for(const[E,I]of f.current.entries()){if(d.current.has(I))continue;const M=`${i}-ch${c}-chunk${E}`;let T;try{T=I.transferControlToOffscreen()}catch(A){console.warn(`[spectrogram] transferControlToOffscreen failed for ${M}:`,A);continue}d.current.add(I);try{w.registerCanvas(M,T),S.push(M)}catch(A){console.warn(`[spectrogram] registerCanvas failed for ${M}:`,A);continue}}if(S.length>0&&(p.current=[...p.current,...S]),S.length>0||x.length<_){const E=p.current,I=E.map(M=>{const T=M.match(/chunk(\d+)$/);if(!T)return console.warn(`[spectrogram] Unexpected canvas ID format: ${M}`),Le;const A=parseInt(T[1],10);return Math.min(n-A*Le,Le)});v.current?.(E,I)}},[f,i,c,n,y]),m.useEffect(()=>()=>{const w=h.current;if(w){for(const _ of p.current)try{w.unregisterCanvas(_)}catch(x){console.warn(`[spectrogram] unregisterCanvas failed for ${_}:`,x)}p.current=[]}},[]);const b=y.map(w=>{const _=w*Le,x=Math.min(n-_,Le);return C.jsx(Dv,{$cssWidth:x,$left:_,width:x*s,height:r*s,$waveHeight:r,"data-index":w,ref:u},`${n}-${w}`)});return C.jsx(Rv,{$index:e,$cssWidth:n,$waveHeight:r,children:b})},Yd=({isSelected:e,transparentBackground:t,renderMode:n="waveform",samplesPerPixel:r,spectrogramWorkerApi:s,spectrogramClipId:a,spectrogramOnCanvasesReady:o,midiNotes:i,sampleRate:l,clipOffsetSeconds:c,...u})=>{const f=Br(),{waveHeight:p,barWidth:d,barGap:h,samplesPerPixel:v,sampleRate:g}=Ys(),y=_i(),b=r??v,w=e&&f?f.selectedWaveOutlineColor:f?.waveOutlineColor,_=e&&f?f.selectedWaveFillColor:f?.waveFillColor,x=f?.waveformDrawMode||"inverted",S=s&&a;if(n==="spectrogram"&&S)return C.jsx(Ul,{index:u.index,length:u.length,waveHeight:p,devicePixelRatio:y,samplesPerPixel:b,workerApi:s,clipId:a,onCanvasesReady:o});if(n==="both"&&S){const k=Math.floor(p/2);return C.jsxs(C.Fragment,{children:[C.jsx(Ul,{index:u.index*2,channelIndex:u.index,length:u.length,waveHeight:k,devicePixelRatio:y,samplesPerPixel:b,workerApi:s,clipId:a,onCanvasesReady:o}),C.jsx("div",{style:{position:"absolute",top:(u.index*2+1)*k,width:u.length,height:k},children:C.jsx(jl,{...u,index:0,waveOutlineColor:w,waveFillColor:_,waveHeight:k,devicePixelRatio:y,barWidth:d,barGap:h,transparentBackground:t,drawMode:x})})]})}return n==="piano-roll"?C.jsx(dv,{index:u.index,midiNotes:i??[],length:u.length,waveHeight:p,devicePixelRatio:y,samplesPerPixel:b,sampleRate:l??g,clipOffsetSeconds:c??0,noteColor:f?.pianoRollNoteColor,selectedNoteColor:f?.pianoRollSelectedNoteColor,isSelected:e,transparentBackground:t,backgroundColor:f?.pianoRollBackgroundColor}):C.jsx(jl,{...u,waveOutlineColor:w,waveFillColor:_,waveHeight:p,devicePixelRatio:y,barWidth:d,barGap:h,transparentBackground:t,drawMode:x})},Xl=72,Pv=P.div`
615
615
  position: sticky;
616
616
  left: 0;
617
617
  z-index: 101;
@@ -619,31 +619,31 @@
619
619
  height: 0;
620
620
  width: 0;
621
621
  overflow: visible;
622
- `;function Bv(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),a=Math.max(2,Math.floor(n/20));if(s.length<=a)return s;const o=(s.length-1)/(a-1),i=[];for(let l=0;l<a;l++)i.push(s[Math.round(l*o)]);return i}var Wv=({waveHeight:e,numChannels:t,frequencyScaleFn:n,minFrequency:r,maxFrequency:s,labelsColor:a="#ccc",labelsBackground:o="rgba(0,0,0,0.6)",renderMode:i="spectrogram",hasClipHeaders:l=!1})=>{const c=p.useRef(null),u=Si(),f=i==="both"?Math.floor(e/2):e,m=t*e,d=l?22:0;return p.useLayoutEffect(()=>{const h=c.current;if(!h)return;const v=h.getContext("2d");if(!v)return;v.resetTransform(),v.clearRect(0,0,h.width,h.height),v.scale(u,u);const g=Bv(r,s,f);for(let y=0;y<t;y++){const b=y*e+d;v.font="11px monospace",v.textBaseline="middle";for(const _ of g){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=o,v.fillRect(0,x-7,k.width+E*2,14),v.fillStyle=a,v.fillText(S,E,x)}}},[e,t,n,r,s,a,o,u,f,d]),C.jsx(Lv,{$height:m+d,children:C.jsx("canvas",{ref:c,width:Xl*u,height:(m+d)*u,style:{width:Xl,height:m+d,pointerEvents:"none"}})})},Vv=F.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
622
+ `;function Fv(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),a=Math.max(2,Math.floor(n/20));if(s.length<=a)return s;const o=(s.length-1)/(a-1),i=[];for(let l=0;l<a;l++)i.push(s[Math.round(l*o)]);return i}var Ov=({waveHeight:e,numChannels:t,frequencyScaleFn:n,minFrequency:r,maxFrequency:s,labelsColor:a="#ccc",labelsBackground:o="rgba(0,0,0,0.6)",renderMode:i="spectrogram",hasClipHeaders:l=!1})=>{const c=m.useRef(null),u=_i(),f=i==="both"?Math.floor(e/2):e,p=t*e,d=l?22:0;return m.useLayoutEffect(()=>{const h=c.current;if(!h)return;const v=h.getContext("2d");if(!v)return;v.resetTransform(),v.clearRect(0,0,h.width,h.height),v.scale(u,u);const g=Fv(r,s,f);for(let y=0;y<t;y++){const b=y*e+d;v.font="11px monospace",v.textBaseline="middle";for(const w of g){const _=n(w,r,s);if(_<0||_>1)continue;const x=b+f*(1-_),S=w>=1e3?`${(w/1e3).toFixed(1)}k`:`${w} Hz`,k=v.measureText(S),E=3;v.fillStyle=o,v.fillRect(0,x-7,k.width+E*2,14),v.fillStyle=a,v.fillText(S,E,x)}}},[e,t,n,r,s,a,o,u,f,d]),C.jsx(Pv,{$height:p+d,children:C.jsx("canvas",{ref:c,width:Xl*u,height:(p+d)*u,style:{width:Xl,height:p+d,pointerEvents:"none"}})})},Lv=P.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
623
623
  position: relative;
624
624
  overflow: visible; /* Allow time labels to render above the container */
625
625
  border-bottom: 1px solid ${e=>e.theme.timeColor};
626
626
  box-sizing: border-box;
627
- `,Nv=F.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`,left:`${e.$left}px`}}))`
627
+ `,Bv=P.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`,left:`${e.$left}px`}}))`
628
628
  position: absolute;
629
629
  bottom: 0;
630
- `,zv=e=>{const{theme:{timeColor:t},tickData:n}=e,{canvasRef:r,canvasMapRef:s}=qs(),{timeScaleHeight:a}=p.useContext(Wr),o=Si(),{widthX:i,canvasInfo:l,timeMarkersWithPositions:c}=n,u=Ks(i,Be),f=u.map(v=>{const g=v*Be,y=Math.min(i-g,Be);return C.jsx(Nv,{$cssWidth:y,$left:g,$timeScaleHeight:a,width:y*o,height:a*o,"data-index":v,ref:r},`timescale-${v}`)}),m=u.length>0?u[0]*Be:0,d=u.length>0?(u[u.length-1]+1)*Be:1/0,h=u.length>0?c.filter(({pix:v})=>v>=m&&v<d).map(({element:v})=>v):c.map(({element:v})=>v);return p.useLayoutEffect(()=>{for(const[v,g]of s.current.entries()){const y=g.getContext("2d");if(!y)continue;const b=v*Be,_=g.width/o;y.resetTransform(),y.clearRect(0,0,g.width,g.height),y.imageSmoothingEnabled=!1,y.fillStyle=t,y.scale(o,o);for(const[w,x]of l.entries()){if(w<b||w>=b+_)continue;const S=w-b,k=a-x;y.fillRect(S,k,1,x)}}},[s,o,t,a,l,u]),C.jsxs(Vv,{$cssWidth:i,$timeScaleHeight:a,children:[h,f]})},jv=F.withTheme(zv),Yl=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 ho(e){const t=Yl.keys();let n;for(const r of t)if(e<r){n=Yl.get(r);break}return n===void 0&&(n={marker:3e4,bigStep:1e4,smallStep:5e3}),n}function Zv(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var Hv=F.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
630
+ `,Wv=e=>{const{theme:{timeColor:t},tickData:n}=e,{canvasRef:r,canvasMapRef:s}=Xs(),{timeScaleHeight:a}=m.useContext(Lr),o=_i(),{widthX:i,canvasInfo:l,timeMarkersWithPositions:c}=n,u=Us(i,Le),f=u.map(v=>{const g=v*Le,y=Math.min(i-g,Le);return C.jsx(Bv,{$cssWidth:y,$left:g,$timeScaleHeight:a,width:y*o,height:a*o,"data-index":v,ref:r},`timescale-${v}`)}),p=u.length>0?u[0]*Le:0,d=u.length>0?(u[u.length-1]+1)*Le:1/0,h=u.length>0?c.filter(({pix:v})=>v>=p&&v<d).map(({element:v})=>v):c.map(({element:v})=>v);return m.useLayoutEffect(()=>{for(const[v,g]of s.current.entries()){const y=g.getContext("2d");if(!y)continue;const b=v*Le,w=g.width/o;y.resetTransform(),y.clearRect(0,0,g.width,g.height),y.imageSmoothingEnabled=!1,y.fillStyle=t,y.scale(o,o);for(const[_,x]of l.entries()){if(_<b||_>=b+w)continue;const S=_-b,k=a-x;y.fillRect(S,k,1,x)}}},[s,o,t,a,l,u]),C.jsxs(Lv,{$cssWidth:i,$timeScaleHeight:a,children:[h,f]})},Vv=P.withTheme(Wv),Yl=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 co(e){const t=Yl.keys();let n;for(const r of t)if(e<r){n=Yl.get(r);break}return n===void 0&&(n={marker:3e4,bigStep:1e4,smallStep:5e3}),n}function Nv(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var jv=P.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
631
631
  position: absolute;
632
632
  font-size: 0.75rem; /* Smaller font to prevent overflow */
633
633
  white-space: nowrap; /* Prevent text wrapping */
634
634
  color: ${e=>e.theme.timeColor}; /* Use theme color instead of inheriting */
635
- `,Kd=({renderTick:e})=>{const{samplesPerPixel:t,sampleRate:n,duration:r,timeScaleHeight:s}=p.useContext(Wr),a=Gd(),o=p.useMemo(()=>{const i=ah(r/1e3,t,n);if(a&&a.scaleMode==="beats"){const{bpm:g,timeSignature:y,ticksPerBar:b,ticksPerBeat:_}=a,w=new Map,x=[],S=r/1e3,k=Math.ceil(S*g*Nn/60),E=Rn(_,g,n)/t,M=Rn(b,g,n)/t,T=10,$=30;let A;if(E>=T)A=_;else if(M>=T)A=b;else{const R=Math.ceil(T/M);A=b*R}let I;if(E>=$)I=_;else if(M>=$)I=b;else{const R=Math.ceil($/M);I=b*R}for(let R=0;R<=k;R+=A){const D=Rn(R,g,n),O=sh(D,t);if(O>=i)break;const Z=R%b===0,G=R%I===0,Y=Z?s:Math.floor(G?s/2:s/5);if(w.set(O,Y),G){const te=oh(R,y),X=e?C.jsx(p.Fragment,{children:e(te,O)},`bb-${R}`):C.jsx("div",{style:{position:"absolute",left:`${O+4}px`,fontSize:"0.75rem",whiteSpace:"nowrap"},children:te},`bb-${R}`);x.push({pix:O,element:X})}}return{widthX:i,canvasInfo:w,timeMarkersWithPositions:x}}const l=ho(t),{marker:c,bigStep:u,smallStep:f}=l,m=new Map,d=[],h=n/t;let v=0;for(let g=0;g<i;g+=h*f/1e3){const y=Math.floor(g);if(v%c===0){const b=Zv(v),_=e?C.jsx(p.Fragment,{children:e(b,y)},`timestamp-${v}`):C.jsx(Hv,{$left:y,children:b},b);d.push({pix:y,element:_}),m.set(y,s)}else v%u===0?m.set(y,Math.floor(s/2)):v%f===0&&m.set(y,Math.floor(s/5));v+=f}return{widthX:i,canvasInfo:m,timeMarkersWithPositions:d}},[a,r,t,n,s,e]);return C.jsx(jv,{tickData:o})},Gv=F.div`
635
+ `,Kd=({renderTick:e})=>{const{samplesPerPixel:t,sampleRate:n,duration:r,timeScaleHeight:s}=m.useContext(Lr),a=Gd(),o=m.useMemo(()=>{const i=ah(r/1e3,t,n);if(a&&a.scaleMode==="beats"){const{bpm:g,timeSignature:y,ticksPerBar:b,ticksPerBeat:w}=a,_=new Map,x=[],S=r/1e3,k=Math.ceil(S*g*Vn/60),E=$n(w,g,n)/t,I=$n(b,g,n)/t,M=10,T=30;let A;if(E>=M)A=w;else if(I>=M)A=b;else{const R=Math.ceil(M/I);A=b*R}let $;if(E>=T)$=w;else if(I>=T)$=b;else{const R=Math.ceil(T/I);$=b*R}for(let R=0;R<=k;R+=A){const F=$n(R,g,n),O=sh(F,t);if(O>=i)break;const G=R%b===0,Q=R%$===0,ee=G?s:Math.floor(Q?s/2:s/5);if(_.set(O,ee),Q){const ue=oh(R,y),te=e?C.jsx(m.Fragment,{children:e(ue,O)},`bb-${R}`):C.jsx("div",{style:{position:"absolute",left:`${O+4}px`,fontSize:"0.75rem",whiteSpace:"nowrap"},children:ue},`bb-${R}`);x.push({pix:O,element:te})}}return{widthX:i,canvasInfo:_,timeMarkersWithPositions:x}}const l=co(t),{marker:c,bigStep:u,smallStep:f}=l,p=new Map,d=[],h=n/t;let v=0;for(let g=0;g<i;g+=h*f/1e3){const y=Math.floor(g);if(v%c===0){const b=Nv(v),w=e?C.jsx(m.Fragment,{children:e(b,y)},`timestamp-${v}`):C.jsx(jv,{$left:y,children:b},b);d.push({pix:y,element:w}),p.set(y,s)}else v%u===0?p.set(y,Math.floor(s/2)):v%f===0&&p.set(y,Math.floor(s/5));v+=f}return{widthX:i,canvasInfo:p,timeMarkersWithPositions:d}},[a,r,t,n,s,e]);return C.jsx(Vv,{tickData:o})},zv=P.div`
636
636
  display: inline-flex;
637
637
  align-items: center;
638
638
  gap: 0.5rem;
639
- `,Uv=[{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"}],Xv=({value:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.value)};return C.jsx(Gv,{className:r,children:C.jsx(Od,{className:"time-format",value:e,onChange:s,disabled:n,"aria-label":"Time format selection",children:Uv.map(a=>C.jsx("option",{value:a.value,children:a.label},a.value))})})},Yv=F.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?xi:0)}px`}}))`
639
+ `,Zv=[{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"}],Hv=({value:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.value)};return C.jsx(zv,{className:r,children:C.jsx(Od,{className:"time-format",value:e,onChange:s,disabled:n,"aria-label":"Time format selection",children:Zv.map(a=>C.jsx("option",{value:a.value,children:a.label},a.value))})})},Gv=P.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?bi:0)}px`}}))`
640
640
  position: relative;
641
641
  ${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
642
- `,Kv=F.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
642
+ `,Uv=P.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
643
643
  position: relative;
644
644
  background: ${e=>e.$backgroundColor||"transparent"};
645
645
  height: 100%;
646
- `,qd=({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}=Js();return C.jsx(Yv,{$numChannels:e,className:n,$waveHeight:u,$width:a,$hasClipHeaders:o,children:C.jsx(Kv,{$backgroundColor:r,$offset:s,onClick:i,"data-track-id":l,children:t})})},Kl=F.button.attrs({type:"button"})`
646
+ `,qd=({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}=Ys();return C.jsx(Gv,{$numChannels:e,className:n,$waveHeight:u,$width:a,$hasClipHeaders:o,children:C.jsx(Uv,{$backgroundColor:r,$offset:s,onClick:i,"data-track-id":l,children:t})})},Kl=P.button.attrs({type:"button"})`
647
647
  display: inline-block;
648
648
  font-family: ${e=>e.theme.fontFamily};
649
649
  font-weight: 500;
@@ -705,7 +705,7 @@
705
705
  box-shadow: 0 0 0 0.2rem ${e.theme.inputFocusBorder}33;
706
706
  }
707
707
  `}
708
- `,qv=F.div`
708
+ `,Xv=P.div`
709
709
  margin-bottom: 0.3rem;
710
710
 
711
711
  button:not(:first-child) {
@@ -717,7 +717,7 @@
717
717
  border-top-right-radius: 0;
718
718
  border-bottom-right-radius: 0;
719
719
  }
720
- `,Jv=F.button`
720
+ `,Yv=P.button`
721
721
  position: absolute;
722
722
  left: 0;
723
723
  top: 0;
@@ -739,7 +739,7 @@
739
739
  opacity: 1;
740
740
  color: #dc3545;
741
741
  }
742
- `,Qv=({onClick:e,title:t="Remove track"})=>C.jsx(Jv,{onClick:e,title:t,children:C.jsx(Tg,{size:12,weight:"bold"})}),e0=F.div`
742
+ `,Kv=({onClick:e,title:t="Remove track"})=>C.jsx(Yv,{onClick:e,title:t,children:C.jsx(Tg,{size:12,weight:"bold"})}),qv=P.div`
743
743
  background: transparent;
744
744
  width: 100%;
745
745
  height: 100%;
@@ -752,7 +752,7 @@
752
752
  text-align: center;
753
753
  border: 1px solid ${e=>e.theme.borderColor};
754
754
  border-radius: ${e=>e.theme.borderRadius};
755
- `,t0=F.header`
755
+ `,Jv=P.header`
756
756
  overflow: hidden;
757
757
  height: 26px;
758
758
  width: 100%;
@@ -763,7 +763,7 @@
763
763
  font-size: ${e=>e.theme.fontSizeSmall};
764
764
  color: ${e=>e.theme.textColor};
765
765
  background-color: transparent;
766
- `,n0=e=>C.jsx(Dd,{weight:"light",...e}),r0=e=>C.jsx(Rd,{weight:"light",...e}),s0=e=>C.jsx($d,{weight:"bold",...e}),ql=F(Ld)`
766
+ `,Qv=e=>C.jsx(Dd,{weight:"light",...e}),e0=e=>C.jsx(Rd,{weight:"light",...e}),t0=e=>C.jsx($d,{weight:"bold",...e}),ql=P(Ld)`
767
767
  width: 75%;
768
768
  height: 5px;
769
769
  background: ${e=>e.theme.sliderTrackColor};
@@ -812,7 +812,7 @@
812
812
  &:focus::-moz-range-thumb {
813
813
  border: 2px solid ${e=>e.theme.textColor};
814
814
  }
815
- `,Jl=F.label`
815
+ `,Jl=P.label`
816
816
  width: 100%;
817
817
  display: flex;
818
818
  justify-content: space-between;
@@ -820,10 +820,10 @@
820
820
  padding: 0 1rem;
821
821
  margin-bottom: 0.2rem;
822
822
  font-size: 14px;
823
- `,a0=F.div`
823
+ `,n0=P.div`
824
824
  position: relative;
825
825
  display: inline-block;
826
- `,o0=F.button`
826
+ `,r0=P.button`
827
827
  background: none;
828
828
  border: none;
829
829
  cursor: pointer;
@@ -837,7 +837,7 @@
837
837
  &:hover {
838
838
  opacity: 1;
839
839
  }
840
- `,bs=180,i0=F.div`
840
+ `,gs=180,s0=P.div`
841
841
  position: fixed;
842
842
  top: ${e=>e.$top}px;
843
843
  left: ${e=>e.$left}px;
@@ -847,14 +847,14 @@
847
847
  border: 1px solid rgba(128, 128, 128, 0.4);
848
848
  border-radius: 6px;
849
849
  padding: 0.5rem 0;
850
- min-width: ${bs}px;
850
+ min-width: ${gs}px;
851
851
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
852
- `,l0=F.hr`
852
+ `,a0=P.hr`
853
853
  border: none;
854
854
  border-top: 1px solid rgba(128, 128, 128, 0.3);
855
855
  margin: 0.35rem 0;
856
- `,c0=({items:e})=>{const[t,n]=p.useState(!1),r=p.useCallback(()=>n(!1),[]),s=typeof e=="function"?e(r):e,[a,o]=p.useState({top:0,left:0}),i=p.useRef(null),l=p.useRef(null),c=p.useCallback(()=>{if(!i.current)return;const u=i.current.getBoundingClientRect(),f=window.innerWidth,m=window.innerHeight,d=l.current?.offsetHeight??160;let h=u.right+4;h+bs>f&&(h=u.left-bs-4),h=Math.max(4,Math.min(h,f-bs-4));let v=u.top;v+d>m-4&&(v=Math.max(4,u.bottom-d)),o({top:v,left:h})},[]);return p.useEffect(()=>{if(!t)return;c();const u=requestAnimationFrame(()=>c()),f=()=>c(),m=()=>c();return window.addEventListener("scroll",f,!0),window.addEventListener("resize",m),()=>{cancelAnimationFrame(u),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",m)}},[t,c]),p.useEffect(()=>{if(!t)return;const u=m=>{const d=m.target;i.current&&!i.current.contains(d)&&l.current&&!l.current.contains(d)&&n(!1)},f=m=>{m.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[t]),C.jsxs(a0,{children:[C.jsx(o0,{ref:i,onClick:u=>{u.stopPropagation(),n(f=>!f)},onMouseDown:u=>u.stopPropagation(),title:"Track menu","aria-label":"Track menu",children:C.jsx(s0,{size:16})}),t&&typeof document<"u"&&yo.createPortal(C.jsx(i0,{ref:l,$top:a.top,$left:a.left,onMouseDown:u=>u.stopPropagation(),children:s.map((u,f)=>C.jsxs(p.Fragment,{children:[f>0&&C.jsx(l0,{}),u.content]},u.id))}),document.body)]})};function wn(e,t){this._waveformData=e,this._channelIndex=t}wn.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};wn.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};wn.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};wn.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};wn.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};wn.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 u0=127,d0=-128,f0=32767,h0=-32768;function p0(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function m0(e){for(var t=e.scale,n=e.amplitude_scale,r=e.split_channels,s=e.length,a=e.sample_rate,o=e.channels.map(function($){return new Float32Array($)}),i=r?o.length:1,l=24,c=p0(s,t),u=e.bits===8?1:2,f=l+c*2*u*i,m=new ArrayBuffer(f),d=new DataView(m),h=0,v=l,g=new Array(i),y=new Array(i),b=0;b<i;b++)g[b]=1/0,y[b]=-1/0;var _=e.bits===8?d0:h0,w=e.bits===8?u0:f0;d.setInt32(0,2,!0),d.setUint32(4,e.bits===8,!0),d.setInt32(8,a,!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<o.length;++k)S+=o[k][x];S=Math.floor(w*S*n/o.length),S<g[0]&&(g[0]=S,g[0]<_&&(g[0]=_)),S>y[0]&&(y[0]=S,y[0]>w&&(y[0]=w))}else for(var E=0;E<i;++E)S=Math.floor(w*o[E][x]*n),S<g[E]&&(g[E]=S,g[E]<_&&(g[E]=_)),S>y[E]&&(y[E]=S,y[E]>w&&(y[E]=w));if(++h===t){for(var M=0;M<i;M++)e.bits===8?(d.setInt8(v++,g[M]),d.setInt8(v++,y[M])):(d.setInt16(v,g[M],!0),d.setInt16(v+2,y[M],!0),v+=4),g[M]=1/0,y[M]=-1/0;h=0}}if(h>0)for(var T=0;T<i;T++)e.bits===8?(d.setInt8(v++,g[T]),d.setInt8(v++,y[T])):(d.setInt16(v,g[T],!0),d.setInt16(v+2,y[T],!0));return m}function Os(e){"@babel/helpers - typeof";return Os=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},Os(e)}function g0(e){return e&&Os(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function v0(e){var t=e&&Os(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 y0(e){var t=e.data,n=e.channels||1,r=24,s=e.bits===8?1:2,a=e.length*2*n;if(t.length!==a)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=r+t.length*s,i=new ArrayBuffer(o),l=new DataView(i);l.setInt32(0,2,!0),l.setUint32(4,e.bits===8,!0),l.setInt32(8,e.sample_rate,!0),l.setInt32(12,e.samples_per_pixel,!0),l.setInt32(16,e.length,!0),l.setInt32(20,n,!0);var 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 Sn(e){return e==null}function b0(e,t){var n=atob(e);return n}function w0(e,t,n){var r=b0(e),s=r.indexOf(`
857
- `,10)+1,a=r.substring(s)+"",o=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(o)}function _0(e,t,n){var r;return function(a){return r=r||w0(e),new Worker(r,a)}}var x0=_0("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function mt(e){if(g0(e)&&(e=y0(e)),v0(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 wn(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var Qn={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function C0(e){var t={scale:e.scale||Qn.scale,bits:e.bits||Qn.bits,amplitude_scale:e.amplitude_scale||Qn.amplitude_scale,split_channels:e.split_channels||Qn.split_channels,disable_worker:e.disable_worker||Qn.disable_worker};return t}function S0(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Jd(e,t,n){var r=S0(e);if(t.disable_worker){var s=m0({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 x0;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 k0(e,t,n,r){function s(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var a=e.decodeAudioData(t,function(o){Jd(o,n,r)},s);a&&a.catch(s)}mt.create=function(t){return new mt(t)};mt.createFromAudio=function(e,t){var n=C0(e);if(e.audio_context&&e.array_buffer)return k0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Jd(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Qs(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}Qs.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};Qs.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};Qs.prototype.getOutputData=function(){return this._output_data};mt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Sn(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Sn(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 Qs(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(y){return y._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]),f=new DataView(c),m=0;m<n;m++)f.setUint8(m,u.getUint8(m));f.setInt32(16,s,!0);for(var d=0,h=new Uint8Array(c,n),v=0;v<a.length;v++){var g=a[v];h.set(new Uint8Array(g,n),d),d+=g.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!Sn(t.startIndex)&&!Sn(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Sn(t.startTime)&&!Sn(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 f=this._at(n*this.channels*2+u);this.bits===8?c.setInt8(a+u,f):c.setInt16(a+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 ki(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 Qd(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 E0(e,t=0){const n=await ki(e);return Qd(n,t)}async function I0(e){const t=await ki(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function ef(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 M0(e,t,n=0,r,s){const a=ef(e,t,r,s);if(a===null){const m=e.bits;return{data:m===8?new Int8Array(0):new Int16Array(0),bits:m,length:0}}const o=a.channel(n),i=a.bits,l=o.min_array(),c=o.max_array(),u=l.length,f=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let m=0;m<u;m++)f[m*2]=l[m],f[m*2+1]=c[m];return{data:f,bits:i,length:u}}function Ql(e,t,n,r,s){const a=ef(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 f=a.channel(u),m=f.min_array(),d=f.max_array(),h=m.length,v=i===8?new Int8Array(h*2):new Int16Array(h*2);for(let g=0;g<h;g++)v[g*2]=m[g],v[g*2+1]=d[g];l.push(v)}if(n&&l.length>1){const u=1/l.length,f=l[0].length/2,m=i===8?new Int8Array(f*2):new Int16Array(f*2);for(let d=0;d<f;d++){let h=0,v=0;for(let g=0;g<l.length;g++)h+=u*l[g][d*2],v+=u*l[g][d*2+1];m[d*2]=h,m[d*2+1]=v}return{length:f,data:[m],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function tf(){const[e,t]=p.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Pn(s,e),parseTime:s=>Hd(s,e)}}function nf({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=p.useState(t),[s,a]=p.useState(!0),[o,i]=p.useState(!0),l=p.useRef(!0),c=p.useRef(!0),u=p.useRef(t),f=p.useCallback(()=>{e.current?.zoomIn()},[e]),m=p.useCallback(()=>{e.current?.zoomOut()},[e]),d=p.useCallback(h=>{h.samplesPerPixel!==u.current&&(u.current=h.samplesPerPixel,p.startTransition(()=>{r(h.samplesPerPixel)})),h.canZoomIn!==l.current&&(l.current=h.canZoomIn,a(h.canZoomIn)),h.canZoomOut!==c.current&&(c.current=h.canZoomOut,i(h.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:f,zoomOut:m,canZoomIn:s,canZoomOut:o,onEngineState:d}}function rf({engineRef:e,initialVolume:t=1}){const[n,r]=p.useState(t),s=p.useRef(t),a=p.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),o=p.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:a,masterVolumeRef:s,onEngineState:o}}function A0({engineRef:e}){const[t,n]=p.useState(0),[r,s]=p.useState(0),a=p.useRef(0),o=p.useRef(0),i=p.useCallback((c,u)=>{e.current?.setSelection(c,u)},[e]),l=p.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 T0({engineRef:e}){const[t,n]=p.useState(!1),[r,s]=p.useState(0),[a,o]=p.useState(0),i=p.useRef(!1),l=p.useRef(0),c=p.useRef(0),u=p.useCallback(h=>{e.current?.setLoopEnabled(h)},[e]),f=p.useCallback((h,v)=>{e.current?.setLoopRegion(h,v)},[e]),m=p.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),d=p.useCallback(h=>{h.isLoopEnabled!==i.current&&(i.current=h.isLoopEnabled,n(h.isLoopEnabled)),h.loopStart!==l.current&&(l.current=h.loopStart,s(h.loopStart)),h.loopEnd!==c.current&&(c.current=h.loopEnd,o(h.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:a,setLoopEnabled:u,setLoopRegion:f,clearLoopRegion:m,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:d}}function $0({engineRef:e}){const[t,n]=p.useState(null),r=p.useRef(null),s=p.useCallback(o=>{e.current?.selectTrack(o)},[e]),a=p.useCallback(o=>{o.selectedTrackId!==r.current&&(r.current=o.selectedTrackId,n(o.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:a,selectedTrackIdRef:r}}const R0=(e=256)=>{const t=p.useRef(null),n=p.useCallback((r,s,a)=>{const o=new L.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 as(e,t,n,r,s=48e3){const a=n??e.audioBuffer,o=a?.sampleRate??e.waveformData?.sample_rate??s,i=a?.duration??e.waveformData?.duration??(e.duration!=null?e.duration+(e.offset??0):void 0);if(i===void 0)return console.warn(`[waveform-playlist] Track ${t+1} ("${e.name??"unnamed"}"): Cannot create track — provide duration, audioBuffer, or waveformData with duration.`),null;const l=uc({audioBuffer:a,sampleRate:o,sourceDuration:i,startTime:e.startTime??0,duration:e.duration??i,offset:e.offset??0,name:e.name||`Track ${t+1}`,fadeIn:e.fadeIn,fadeOut:e.fadeOut,waveformData:e.waveformData});if(isNaN(l.startSample)||isNaN(l.durationSamples)||isNaN(l.offsetSamples))return console.error(`[waveform-playlist] Invalid clip values for track ${t+1} ("${e.name??"unnamed"}"): startSample=${l.startSample}, durationSamples=${l.durationSamples}, offsetSamples=${l.offsetSamples}`),null;const c={...dc({name:e.name||`Track ${t+1}`,clips:[l],muted:e.muted??!1,soloed:e.soloed??!1,volume:e.volume??1,pan:e.pan??0,color:e.color}),effects:e.effects,renderMode:e.renderMode,spectrogramConfig:e.spectrogramConfig,spectrogramColorMap:e.spectrogramColorMap},u=r.get(t);return u?(c.id=u.trackId,c.clips[0]={...c.clips[0],id:u.clipId}):r.set(t,{trackId:c.id,clipId:c.clips[0].id}),c}function D0(e,t={}){const{immediate:n=!1,progressive:r=!1}=t,s=n||r,[a,o]=p.useState(!0),[i,l]=p.useState(null),[c,u]=p.useState(0),f=e.length,[m,d]=p.useState(new Map),h=p.useRef(new Map),v=p.useRef(48e3),g=p.useMemo(()=>{if(!s)return null;const w=[];for(let x=0;x<e.length;x++){const S=as(e[x],x,m.get(x),h.current,v.current);S&&w.push(S)}return w},[s,e,m]),[y,b]=p.useState(g??[]),_=p.useRef(g);return g!==_.current&&(_.current=g,g&&b(g)),p.useEffect(()=>{if(e.length===0){b([]),o(!1),u(0);return}let w=!1;const x=new AbortController;return(async()=>{try{o(!0),l(null),u(0),s&&d(new Map);const k=cc.getContext().rawContext;v.current=k.sampleRate;const E=e.map(async(T,$)=>{if(T.audioBuffer){if(s&&!w){d(D=>{const O=new Map(D);return O.set($,T.audioBuffer),O}),u(D=>D+1);return}return as(T,$,T.audioBuffer,h.current,k.sampleRate)}if(!T.src&&T.waveformData){if(s&&!w){u(D=>D+1);return}return as(T,$,void 0,h.current,k.sampleRate)}if(!T.src)throw new Error(`Track ${$+1}: Must provide src, audioBuffer, or waveformData`);const A=await fetch(T.src,{signal:x.signal});if(!A.ok)throw new Error(`Failed to fetch ${T.src}: ${A.statusText}`);const I=await A.arrayBuffer(),R=await k.decodeAudioData(I);if(!R||!R.sampleRate||!R.duration)throw new Error(`Invalid audio buffer for ${T.src}`);if(s&&!w){d(D=>{const O=new Map(D);return O.set($,R),O}),u(D=>D+1);return}return as(T,$,R,h.current,k.sampleRate)}),M=await Promise.all(E);if(!w){if(!s){const T=M.filter($=>$!=null);b(T),u(T.length)}o(!1)}}catch(k){if(!w){const E=k instanceof Error?k.message:"Unknown error loading audio";l(E),o(!1),console.error(`[waveform-playlist] Error loading audio tracks: ${E}`)}}})(),()=>{w=!0,x.abort()}},[e,s]),{tracks:y,loading:a,error:i,loadedCount:c,totalCount:f}}function P0({originalClip:e,clip:t,pixelDelta:n,samplesPerPixel:r,sampleRate:s,boundary:a,sortedClips:o,sortedIndex:i}){const l=n*r,c=Math.floor(.1*s),u={...t,startSample:e.startSample,offsetSamples:e.offsetSamples,durationSamples:e.durationSamples},f=vc(u,Math.floor(l),a,o,i,c);return a==="left"?{startSample:e.startSample+f,durationSamples:e.durationSamples-f,offsetSamples:e.offsetSamples+f}:{startSample:e.startSample,durationSamples:e.durationSamples+f,offsetSamples:e.offsetSamples}}function sf({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:a,snapSamplePosition:o}){const i=p.useRef(o);i.current=o;const l=p.useRef(null),c=p.useRef(0),u=p.useCallback(d=>{const h=d.operation.source?.data;if(!h)return;if(!h.boundary){l.current=null;return}const g=e[h.trackIndex]?.clips[h.clipIndex];g&&(l.current={offsetSamples:g.offsetSamples,durationSamples:g.durationSamples,startSample:g.startSample},a.current=!0)},[e,a]),f=p.useCallback(d=>{const h=d.operation.source?.data;if(!h||!h.boundary||!l.current)return;const{boundary:v,trackIndex:g,clipIndex:y}=h,_=(d.to?.x??d.operation.position.current.x)-d.operation.position.initial.x,w=_*n,x=l.current,S=i.current;let k=w;const E=e.map((M,T)=>{if(T!==g)return M;const $=[...M.clips].sort((R,D)=>R.startSample-D.startSample),A=$.findIndex(R=>R===M.clips[y]),I=M.clips.map((R,D)=>{if(D!==y)return R;let O=P0({originalClip:x,clip:R,pixelDelta:_,samplesPerPixel:n,sampleRate:r,boundary:v,sortedClips:$,sortedIndex:A});if(S)if(v==="left"){const Z=S(O.startSample),G=Z-O.startSample;O={startSample:Z,durationSamples:O.durationSamples-G,offsetSamples:O.offsetSamples+G},k=Z-x.startSample}else{const Z=O.startSample+O.durationSamples,G=S(Z);O={...O,durationSamples:G-O.startSample},k=O.durationSamples-x.durationSamples}return{...R,startSample:O.startSample,durationSamples:O.durationSamples,offsetSamples:O.offsetSamples}});return{...M,clips:I}});c.current=k,t(E)},[e,t,n,r]),m=p.useCallback(d=>{if(d.canceled){if(l.current){const w=d.operation.source?.data;if(w){const{trackIndex:x,clipIndex:S}=w,k=l.current,E=e.map((M,T)=>{if(T!==x)return M;const $=M.clips.map((A,I)=>I!==S?A:{...A,offsetSamples:k.offsetSamples,durationSamples:k.durationSamples,startSample:k.startSample});return{...M,clips:$}});t(E)}}a.current=!1,l.current=null,c.current=0;return}const h=d.operation.source?.data;if(!h)return;const{trackIndex:v,clipId:g,boundary:y}=h,b=y?c.current:d.operation.transform.x*n,_=e[v]?.id;if(y){a.current=!1,_?s.current?s.current.trimClip(_,g,y,Math.floor(b)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${v} not found — trim not synced to adapter`),l.current=null,c.current=0;return}_?s.current?s.current.moveClip(_,g,Math.floor(b)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${v} not found — move not synced to adapter`)},[e,t,n,s,a]);return{onDragStart:u,onDragMove:f,onDragEnd:m}}const xa=.01;function af({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:a}){const o=p.useRef(null),i=p.useCallback(u=>{const f=u.operation.source?.data;if(!f||f.annotationIndex===void 0){o.current=null;return}const m=e[f.annotationIndex];m&&(o.current={start:m.start,end:m.end,annotationIndex:f.annotationIndex})},[e]),l=p.useCallback(u=>{if(!o.current)return;const f=u.operation.source?.data;if(!f)return;const{edge:m,annotationIndex:d}=f,h=o.current,y=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n/r,b=m==="start"?h.start+y:h.end+y,_=F0({annotationIndex:d,newTime:b,isDraggingStart:m==="start",annotations:e,duration:s,linkEndpoints:a});t(_)},[e,t,n,r,s,a]),c=p.useCallback(u=>{if(u.canceled&&o.current){const{annotationIndex:f,start:m,end:d}=o.current,h=e.map((v,g)=>g!==f?v:{...v,start:m,end:d});t(h)}o.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function F0({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)<xa?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)<xa){const f=u.start+c;o[e+1]={...u,start:Math.min(u.end-.1,f)};let m=e+1;for(;m<o.length-1;){const d=o[m],h=o[m+1];if(Math.abs(h.start-d.end)<xa){const v=d.end-r[m].end;o[m+1]={...h,start:Math.min(h.end-.1,h.start+v)},m++}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 f=e+1;for(;f<o.length-1;){const m=o[f],d=o[f+1];if(m.end>d.start)o[f+1]={...d,start:m.end},f++;else break}}}return o}function of(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return p.useMemo(()=>t?[oo.configure({activationConstraints(a){return a.pointerType==="touch"?[new Ot.Delay({value:n,tolerance:r})]:[new Ot.Distance({value:s})]}})]:[oo.configure({activationConstraints:[new Ot.Distance({value:s})]})],[t,n,r,s])}const lf=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=ot(),{selectedTrackId:a}=it(),o=p.useCallback((l,c,u)=>{const{samplesPerPixel:f}=e,m=t[l];if(!m)return!1;const d=m.clips[c];if(!d)return!1;const h=Math.round(u*n),v=yh(h,f),g=Math.floor(.1*n);if(!yc(d,v,g))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const y=r.current;return y?(y.splitClip(m.id,d.id,v),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:p.useCallback(()=>{if(!a)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const l=t.findIndex(f=>f.id===a);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 m=c.clips[f],d=m.startSample/n,h=(m.startSample+m.durationSamples)/n;if(u>d&&u<h)return o(l,f,u)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${c.name}"`),!1},[t,s,a,o,n]),splitClipAt:o}},Ls=e=>{const{shortcuts:t,enabled:n=!0}=e,r=p.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,f=i.metaKey===void 0||s.metaKey===i.metaKey,m=i.altKey===void 0||s.altKey===i.altKey;return l&&c&&u&&f&&m});o&&(o.preventDefault!==!1&&s.preventDefault(),o.action())},[t,n]);p.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},O0=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("+")},cf=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=ot(),{setCurrentTime:a,play:o,pause:i,stop:l}=Ie(),c=p.useCallback(()=>{s?i():o()},[s,o,i]),u=p.useCallback(()=>{l()},[l]),f=p.useCallback(()=>{a(0),s&&o(0)},[s,a,o]),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 Ls({shortcuts:d,enabled:t}),{rewindToStart:f,togglePlayPause:c,stopPlayback:u,shortcuts:d}},Ca=.01,os=.01;function uf({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:s,linkEndpoints:a,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:c,sampleRate:u,onPlay:f}){const m=p.useMemo(()=>t?e.findIndex(E=>E.id===t):-1,[e,t]),d=p.useCallback(E=>{if(!l?.current||!c||!u)return;const M=e.find(G=>G.id===E);if(!M)return;const T=l.current,$=T.clientWidth,A=M.start*u/c,I=M.end*u/c,R=(A+I)/2,D=T.scrollLeft,O=D,Z=D+$;if(A<O||I>Z){const G=Math.max(0,R-$/2);T.scrollTo({left:G,behavior:"smooth"})}},[e,l,c,u]);p.useEffect(()=>{t&&l?.current&&c&&u&&d(t)},[t,d,l,c,u]);const h=p.useCallback(E=>{if(m<0)return;const M=e[m],T=Math.max(0,Math.min(M.end-.1,M.start+E)),$=T-M.start,A=[...e];if(A[m]={...M,start:T},a&&m>0){const I=A[m-1];Math.abs(I.end-M.start)<Ca&&(A[m-1]={...I,end:Math.max(I.start+.1,I.end+$)})}else if(!a&&m>0){const I=A[m-1];T<I.end&&(A[m-1]={...I,end:T})}n(A)},[e,m,a,n]),v=p.useCallback(E=>{if(m<0)return;const M=e[m],T=Math.max(M.start+.1,Math.min(s,M.end+E)),$=T-M.end,A=[...e];if(A[m]={...M,end:T},a&&m<e.length-1){const I=A[m+1];if(Math.abs(I.start-M.end)<Ca){const R=Math.min(I.end-.1,I.start+$);A[m+1]={...I,start:R};let D=m+1;for(;D<A.length-1;){const O=A[D],Z=A[D+1];if(Math.abs(Z.start-e[D].end)<Ca){const G=O.end-e[D].end;A[D+1]={...Z,start:Math.min(Z.end-.1,Z.start+G)},D++}else break}}}else if(!a&&m<e.length-1){const I=A[m+1];if(T>I.start){A[m+1]={...I,start:T};let R=m+1;for(;R<A.length-1;){const D=A[R],O=A[R+1];if(D.end>O.start)A[R+1]={...O,start:D.end},R++;else break}}}n(A)},[e,m,s,a,n]),g=p.useCallback(()=>{!r||e.length===0||(m<=0?r(e[e.length-1].id):r(e[m-1].id))},[e,m,r]),y=p.useCallback(()=>{!r||e.length===0||(m<0||m>=e.length-1?r(e[0].id):r(e[m+1].id))},[e,m,r]),b=p.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),_=p.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),w=p.useCallback(()=>{r&&r(null)},[r]),x=p.useCallback(()=>{if(m<0||!f)return;const E=e[m],M=o?void 0:E.end-E.start;f(E.start,M)},[e,m,o,f]),S=p.useMemo(()=>[{key:"[",action:()=>h(-os),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>h(os),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-os),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(os),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:x,description:"Play selected annotation",preventDefault:!0}],[h,v,x]),k=p.useMemo(()=>[{key:"ArrowUp",action:g,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:g,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:y,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:y,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}],[g,y,b,_,w]);return Ls({shortcuts:S,enabled:i&&m>=0}),Ls({shortcuts:k,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:h,moveEndBoundary:v,selectPrevious:g,selectNext:y,selectFirst:b,selectLast:_,clearSelection:w,scrollToAnnotation:d,playActiveAnnotation:x}}const Nr=[{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}]}],Ei=e=>Nr.find(t=>t.id===e),L0=e=>Nr.filter(t=>t.category===e),B0=[{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 W0={reverb:L.Reverb,freeverb:L.Freeverb,jcReverb:L.JCReverb,feedbackDelay:L.FeedbackDelay,pingPongDelay:L.PingPongDelay,chorus:L.Chorus,phaser:L.Phaser,tremolo:L.Tremolo,vibrato:L.Vibrato,autoPanner:L.AutoPanner,autoFilter:L.AutoFilter,autoWah:L.AutoWah,eq3:L.EQ3,distortion:L.Distortion,bitCrusher:L.BitCrusher,chebyshev:L.Chebyshev,compressor:L.Compressor,limiter:L.Limiter,gate:L.Gate,stereoWidener:L.StereoWidener};let V0=0;const N0=()=>`effect_${Date.now()}_${++V0}`;function Ir(e,t){const n=W0[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=N0(),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 z0(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 j0(e=256){const[t,n]=p.useState([]),r=p.useRef(t);r.current=t;const s=p.useRef(new Map),a=p.useRef(null),o=p.useRef(null),i=p.useCallback(g=>{const y=o.current;if(!y)return;const{masterGainNode:b,destination:_,analyserNode:w}=y;try{b.disconnect()}catch(S){console.warn("[waveform-playlist] Error disconnecting master effects chain:",S)}const x=g.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=p.useCallback(g=>{const y=Ei(g);if(!y){console.error(`Unknown effect: ${g}`);return}const b={};y.parameters.forEach(x=>{b[x.name]=x.default});const _=Ir(y,b);s.current.set(_.instanceId,_);const w={instanceId:_.instanceId,effectId:y.id,definition:y,params:b,bypassed:!1};n(x=>[...x,w])},[]),c=p.useCallback(g=>{const y=s.current.get(g);y&&(y.dispose(),s.current.delete(g)),n(b=>b.filter(_=>_.instanceId!==g))},[]),u=p.useCallback((g,y,b)=>{const _=s.current.get(g);_&&_.setParameter(y,b),n(w=>w.map(x=>x.instanceId===g?{...x,params:{...x.params,[y]:b}}:x))},[]),f=p.useCallback(g=>{const y=r.current.find(w=>w.instanceId===g);if(!y)return;const b=!y.bypassed,_=s.current.get(g);if(_){const w=y.params.wet??1;_.setParameter("wet",b?0:w)}n(w=>w.map(x=>x.instanceId===g?{...x,bypassed:b}:x))},[]),m=p.useCallback((g,y)=>{n(b=>{const _=[...b],[w]=_.splice(g,1);return _.splice(y,0,w),_})},[]),d=p.useCallback(()=>{s.current.forEach(g=>g.dispose()),s.current.clear(),n([])},[]);p.useEffect(()=>{i(t)},[t,i]);const h=p.useCallback((g,y,b)=>{const _=new L.Analyser("fft",e);a.current=_,o.current={masterGainNode:g,destination:y,analyserNode:_};const x=r.current.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)g.connect(_),_.connect(y);else{let S=g;x.forEach(k=>{S.connect(k.effect),S=k.effect}),S.connect(_),_.connect(y)}return function(){_.dispose(),a.current=null,o.current=null}},[e]);p.useEffect(()=>{const g=s.current;return()=>{g.forEach(y=>y.dispose()),g.clear()}},[]);const v=p.useCallback(()=>{const g=t.filter(y=>!y.bypassed);if(g.length!==0)return(y,b,_)=>{const w=[];for(const x of g){const S=Ir(x.definition,x.params);w.push(S)}if(w.length===0)y.connect(b);else{let x=y;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:Nr,addEffect:l,removeEffect:c,updateParameter:u,toggleBypass:f,reorderEffects:m,clearAllEffects:d,masterEffects:h,createOfflineEffectsFunction:v,analyserRef:a}}function Z0(){const[e,t]=p.useState(new Map),n=p.useRef(new Map),r=p.useRef(new Map),s=p.useCallback((d,h)=>{const v=r.current.get(d);if(!v)return;const{graphEnd:g,masterGainNode:y}=v,b=n.current.get(d);try{g.disconnect()}catch(w){console.warn(`[waveform-playlist] Error disconnecting track "${d}" effect chain:`,w)}const _=h.map(w=>b?.get(w.instanceId)).filter(w=>w!==void 0);if(_.length===0)g.connect(y);else{let w=g;_.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(y)}},[]),a=p.useCallback((d,h)=>{const v=Ei(h);if(!v){console.error(`Unknown effect: ${h}`);return}const g={};v.parameters.forEach(_=>{g[_.name]=_.default});const y=Ir(v,g);n.current.has(d)||n.current.set(d,new Map),n.current.get(d).set(y.instanceId,y);const b={instanceId:y.instanceId,effectId:v.id,definition:v,params:g,bypassed:!1};t(_=>{const w=new Map(_),x=w.get(d)||[];return w.set(d,[...x,b]),w})},[]),o=p.useCallback((d,h)=>{const v=n.current.get(d),g=v?.get(h);g&&(g.dispose(),v?.delete(h)),t(y=>{const b=new Map(y),_=b.get(d)||[];return b.set(d,_.filter(w=>w.instanceId!==h)),b})},[]),i=p.useCallback((d,h,v,g)=>{const b=n.current.get(d)?.get(h);b&&b.setParameter(v,g),t(_=>{const w=new Map(_),x=w.get(d)||[];return w.set(d,x.map(S=>S.instanceId===h?{...S,params:{...S.params,[v]:g}}:S)),w})},[]),l=p.useCallback((d,h)=>{const g=(u.current.get(d)||[]).find(w=>w.instanceId===h);if(!g)return;const y=!g.bypassed,_=n.current.get(d)?.get(h);if(_){const w=g.params.wet??1;_.setParameter("wet",y?0:w)}t(w=>{const x=new Map(w),S=x.get(d)||[];return x.set(d,S.map(k=>k.instanceId===h?{...k,bypassed:y}:k)),x})},[]),c=p.useCallback(d=>{const h=n.current.get(d);h&&(h.forEach(v=>v.dispose()),h.clear()),t(v=>{const g=new Map(v);return g.set(d,[]),g})},[]),u=p.useRef(e);u.current=e;const f=p.useCallback(d=>(h,v,g)=>{r.current.set(d,{graphEnd:h,masterGainNode:v});const y=u.current.get(d)||[],b=n.current.get(d),_=y.map(w=>b?.get(w.instanceId)).filter(w=>w!==void 0);if(_.length===0)h.connect(v);else{let w=h;_.forEach(x=>{w.connect(x.effect),w=x.effect}),w.connect(v)}return function(){r.current.delete(d)}},[]);p.useEffect(()=>{e.forEach((d,h)=>{s(h,d)})},[e,s]),p.useEffect(()=>{const d=n.current;return()=>{d.forEach(h=>{h.forEach(v=>v.dispose()),h.clear()}),d.clear()}},[]);const m=p.useCallback(d=>{const v=(e.get(d)||[]).filter(g=>!g.bypassed);if(v.length!==0)return(g,y,b)=>{const _=[];for(const w of v){const x=Ir(w.definition,w.params);_.push(x)}if(_.length===0)g.connect(y);else{let w=g;_.forEach(x=>{w.connect(x.effect),w=x.effect}),w.connect(y)}return function(){_.forEach(x=>x.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:a,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:f,createOfflineTrackEffectsFunction:m,availableEffects:Nr}}function H0(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,f=u+c,m=new ArrayBuffer(f),d=new DataView(m);is(d,0,"RIFF"),d.setUint32(4,f-8,!0),is(d,8,"WAVE"),is(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),is(d,36,"data"),d.setUint32(40,c,!0);const h=[];for(let g=0;g<r;g++)h.push(e.getChannelData(g));let v=u;if(n===16)for(let g=0;g<a;g++)for(let y=0;y<r;y++){const b=h[y][g],_=Math.max(-1,Math.min(1,b)),w=_<0?_*32768:_*32767;d.setInt16(v,w,!0),v+=2}else for(let g=0;g<a;g++)for(let y=0;y<r;y++)d.setFloat32(v,h[y][g],!0),v+=4;return new Blob([m],{type:"audio/wav"})}function is(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function G0(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 df(){const[e,t]=p.useState(!1),[n,r]=p.useState(0),[s,a]=p.useState(null);return{exportWav:p.useCallback(async(i,l,c={})=>{const{filename:u="export",mode:f="master",trackIndex:m,autoDownload:d=!0,applyEffects:h=!0,effectsFunction:v,createOfflineTrackEffects:g,bitDepth:y=16,onProgress:b}=c;t(!0),r(0),a(null);try{if(i.length===0)throw new Error("No tracks to export");if(f==="individual"&&(m===void 0||m<0||m>=i.length))throw new Error("Invalid track index for individual export");const _=i[0].clips[0]?.sampleRate||44100;let w=0;for(const $ of i)for(const A of $.clips){const I=A.startSample+A.durationSamples;w=Math.max(w,I)}w+=Math.round(_*.1);const x=w/_,S=f==="individual"?[{track:i[m],state:l[m],index:m}]:i.map(($,A)=>({track:$,state:l[A],index:A})),k=l.some($=>$.soloed),E=!!g;let M;if((v||E)&&h)M=await U0(S,l,k,x,_,v,g,$=>{r($),b?.($)});else{const $=new OfflineAudioContext(2,w,_);let A=0;const I=S.reduce((R,{track:D})=>R+D.clips.length,0);for(const{track:R,state:D}of S)if(!(D.muted&&!D.soloed)&&!(k&&!D.soloed))for(const O of R.clips){await Y0($,O,D,_,h),A++;const Z=A/I*.5;r(Z),b?.(Z)}r(.5),b?.(.5),M=await $.startRendering()}r(.9),b?.(.9);const T=H0(M,{bitDepth:y});if(r(1),b?.(1),d){const $=f==="individual"?`${u}_${i[m].name}`:u;G0(T,`${$}.wav`)}return{audioBuffer:M,blob:T,duration:x}}catch(_){const w=_ instanceof Error?_.message:"Export failed";throw a(w),_}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function U0(e,t,n,r,s,a,o,i){const{Offline:l,Volume:c,Gain:u,Panner:f,Player:m,ToneAudioBuffer:d}=await import("tone");i(.1);let h;try{h=await l(async({transport:v,destination:g})=>{const y=new c(0);let b;a?b=a(y,g,!0):y.connect(g);for(const{track:_,state:w}of e){if(w.muted&&!w.soloed||n&&!w.soloed)continue;const x=new c(X0(w.volume)),S=new f(w.pan),k=new u(w.muted?0:1),E=o?.(_.id);E?E(k,y,!0):k.connect(y),S.connect(k),x.connect(S);for(const M of _.clips){const{audioBuffer:T,startSample:$,durationSamples:A,offsetSamples:I,gain:R,fadeIn:D,fadeOut:O}=M,Z=$/s,G=A/s,Y=I/s,te=new d(T),X=new m(te),K=new u(R);if(X.connect(K),K.connect(x),D){const le=Z,J=Z+D.duration,de=yr(K.gain);de&&(de.setValueAtTime(0,le),de.linearRampToValueAtTime(R,J))}if(O){const le=Z+G-O.duration,J=Z+G,de=yr(K.gain);de&&(de.setValueAtTime(R,le),de.linearRampToValueAtTime(0,J))}X.start(Z,Y,G)}}v.start(0)},r,2,s)}catch(v){throw v instanceof Error?v:new Error(`Tone.Offline rendering failed: ${String(v)}`)}return i(.9),h.get()}function X0(e){return 20*Math.log10(Math.max(e,1e-4))}async function Y0(e,t,n,r,s){const{audioBuffer:a,startSample:o,durationSamples:i,offsetSamples:l,gain:c,fadeIn:u,fadeOut:f}=t;if(!a){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const m=o/r,d=i/r,h=l/r,v=e.createBufferSource();v.buffer=a;const g=e.createGain(),y=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,v.connect(g),g.connect(b),b.connect(e.destination),s){if(u?g.gain.setValueAtTime(0,m):g.gain.setValueAtTime(y,m),u){const _=m,w=m+u.duration;ec(g.gain,_,w,0,y,u.type||"linear")}if(f){const _=m+d-f.duration,w=m+d;(!u||u.duration<d-f.duration)&&g.gain.setValueAtTime(y,_),ec(g.gain,_,w,y,0,f.type||"linear")}}else g.gain.setValueAtTime(y,m);v.start(m,h,d)}function ec(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=tc(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,o);break}case"sCurve":{const i=tc(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,o);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function tc(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 ff=()=>{const e=p.useRef(null),t=p.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=p.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return p.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},K0=`
856
+ `,o0=({items:e})=>{const[t,n]=m.useState(!1),r=m.useCallback(()=>n(!1),[]),s=typeof e=="function"?e(r):e,[a,o]=m.useState({top:0,left:0}),i=m.useRef(null),l=m.useRef(null),c=m.useCallback(()=>{if(!i.current)return;const u=i.current.getBoundingClientRect(),f=window.innerWidth,p=window.innerHeight,d=l.current?.offsetHeight??160;let h=u.right+4;h+gs>f&&(h=u.left-gs-4),h=Math.max(4,Math.min(h,f-gs-4));let v=u.top;v+d>p-4&&(v=Math.max(4,u.bottom-d)),o({top:v,left:h})},[]);return m.useEffect(()=>{if(!t)return;c();const u=requestAnimationFrame(()=>c()),f=()=>c(),p=()=>c();return window.addEventListener("scroll",f,!0),window.addEventListener("resize",p),()=>{cancelAnimationFrame(u),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",p)}},[t,c]),m.useEffect(()=>{if(!t)return;const u=p=>{const d=p.target;i.current&&!i.current.contains(d)&&l.current&&!l.current.contains(d)&&n(!1)},f=p=>{p.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[t]),C.jsxs(n0,{children:[C.jsx(r0,{ref:i,onClick:u=>{u.stopPropagation(),n(f=>!f)},onMouseDown:u=>u.stopPropagation(),title:"Track menu","aria-label":"Track menu",children:C.jsx(t0,{size:16})}),t&&typeof document<"u"&&mo.createPortal(C.jsx(s0,{ref:l,$top:a.top,$left:a.left,onMouseDown:u=>u.stopPropagation(),children:s.map((u,f)=>C.jsxs(m.Fragment,{children:[f>0&&C.jsx(a0,{}),u.content]},u.id))}),document.body)]})};function yn(e,t){this._waveformData=e,this._channelIndex=t}yn.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};yn.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};yn.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};yn.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};yn.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};yn.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 i0=127,l0=-128,c0=32767,u0=-32768;function d0(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function f0(e){for(var t=e.scale,n=e.amplitude_scale,r=e.split_channels,s=e.length,a=e.sample_rate,o=e.channels.map(function(T){return new Float32Array(T)}),i=r?o.length:1,l=24,c=d0(s,t),u=e.bits===8?1:2,f=l+c*2*u*i,p=new ArrayBuffer(f),d=new DataView(p),h=0,v=l,g=new Array(i),y=new Array(i),b=0;b<i;b++)g[b]=1/0,y[b]=-1/0;var w=e.bits===8?l0:u0,_=e.bits===8?i0:c0;d.setInt32(0,2,!0),d.setUint32(4,e.bits===8,!0),d.setInt32(8,a,!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<o.length;++k)S+=o[k][x];S=Math.floor(_*S*n/o.length),S<g[0]&&(g[0]=S,g[0]<w&&(g[0]=w)),S>y[0]&&(y[0]=S,y[0]>_&&(y[0]=_))}else for(var E=0;E<i;++E)S=Math.floor(_*o[E][x]*n),S<g[E]&&(g[E]=S,g[E]<w&&(g[E]=w)),S>y[E]&&(y[E]=S,y[E]>_&&(y[E]=_));if(++h===t){for(var I=0;I<i;I++)e.bits===8?(d.setInt8(v++,g[I]),d.setInt8(v++,y[I])):(d.setInt16(v,g[I],!0),d.setInt16(v+2,y[I],!0),v+=4),g[I]=1/0,y[I]=-1/0;h=0}}if(h>0)for(var M=0;M<i;M++)e.bits===8?(d.setInt8(v++,g[M]),d.setInt8(v++,y[M])):(d.setInt16(v,g[M],!0),d.setInt16(v+2,y[M],!0));return p}function Ds(e){"@babel/helpers - typeof";return Ds=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},Ds(e)}function h0(e){return e&&Ds(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function p0(e){var t=e&&Ds(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 m0(e){var t=e.data,n=e.channels||1,r=24,s=e.bits===8?1:2,a=e.length*2*n;if(t.length!==a)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=r+t.length*s,i=new ArrayBuffer(o),l=new DataView(i);l.setInt32(0,2,!0),l.setUint32(4,e.bits===8,!0),l.setInt32(8,e.sample_rate,!0),l.setInt32(12,e.samples_per_pixel,!0),l.setInt32(16,e.length,!0),l.setInt32(20,n,!0);var 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 Cn(e){return e==null}function g0(e,t){var n=atob(e);return n}function v0(e,t,n){var r=g0(e),s=r.indexOf(`
857
+ `,10)+1,a=r.substring(s)+"",o=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(o)}function y0(e,t,n){var r;return function(a){return r=r||v0(e),new Worker(r,a)}}var b0=y0("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function pt(e){if(h0(e)&&(e=m0(e)),p0(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 yn(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var qn={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function w0(e){var t={scale:e.scale||qn.scale,bits:e.bits||qn.bits,amplitude_scale:e.amplitude_scale||qn.amplitude_scale,split_channels:e.split_channels||qn.split_channels,disable_worker:e.disable_worker||qn.disable_worker};return t}function _0(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Jd(e,t,n){var r=_0(e);if(t.disable_worker){var s=f0({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 pt(s),e)}else{var a=new b0;a.onmessage=function(o){n(void 0,new pt(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 x0(e,t,n,r){function s(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var a=e.decodeAudioData(t,function(o){Jd(o,n,r)},s);a&&a.catch(s)}pt.create=function(t){return new pt(t)};pt.createFromAudio=function(e,t){var n=w0(e);if(e.audio_context&&e.array_buffer)return x0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Jd(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Ks(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 pt(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}Ks.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};Ks.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};Ks.prototype.getOutputData=function(){return this._output_data};pt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Cn(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Cn(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 Ks(t);!n.next(););return new pt(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 pt.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(y){return y._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]),f=new DataView(c),p=0;p<n;p++)f.setUint8(p,u.getUint8(p));f.setInt32(16,s,!0);for(var d=0,h=new Uint8Array(c,n),v=0;v<a.length;v++){var g=a[v];h.set(new Uint8Array(g,n),d),d+=g.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!Cn(t.startIndex)&&!Cn(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Cn(t.startTime)&&!Cn(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 f=this._at(n*this.channels*2+u);this.bits===8?c.setInt8(a+u,f):c.setInt16(a+u*2,f,!0)}return new pt(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 xi(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 pt.create(r)}else{const r=await t.json();return pt.create(r)}}function Qd(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 C0(e,t=0){const n=await xi(e);return Qd(n,t)}async function S0(e){const t=await xi(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function ef(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 k0(e,t,n=0,r,s){const a=ef(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,f=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let p=0;p<u;p++)f[p*2]=l[p],f[p*2+1]=c[p];return{data:f,bits:i,length:u}}function Ql(e,t,n,r,s){const a=ef(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 f=a.channel(u),p=f.min_array(),d=f.max_array(),h=p.length,v=i===8?new Int8Array(h*2):new Int16Array(h*2);for(let g=0;g<h;g++)v[g*2]=p[g],v[g*2+1]=d[g];l.push(v)}if(n&&l.length>1){const u=1/l.length,f=l[0].length/2,p=i===8?new Int8Array(f*2):new Int16Array(f*2);for(let d=0;d<f;d++){let h=0,v=0;for(let g=0;g<l.length;g++)h+=u*l[g][d*2],v+=u*l[g][d*2+1];p[d*2]=h,p[d*2+1]=v}return{length:f,data:[p],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function tf(){const[e,t]=m.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Dn(s,e),parseTime:s=>Hd(s,e)}}function nf({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=m.useState(t),[s,a]=m.useState(!0),[o,i]=m.useState(!0),l=m.useRef(!0),c=m.useRef(!0),u=m.useRef(t),f=m.useCallback(()=>{e.current?.zoomIn()},[e]),p=m.useCallback(()=>{e.current?.zoomOut()},[e]),d=m.useCallback(h=>{h.samplesPerPixel!==u.current&&(u.current=h.samplesPerPixel,m.startTransition(()=>{r(h.samplesPerPixel)})),h.canZoomIn!==l.current&&(l.current=h.canZoomIn,a(h.canZoomIn)),h.canZoomOut!==c.current&&(c.current=h.canZoomOut,i(h.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:f,zoomOut:p,canZoomIn:s,canZoomOut:o,onEngineState:d}}function rf({engineRef:e,initialVolume:t=1}){const[n,r]=m.useState(t),s=m.useRef(t),a=m.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),o=m.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:a,masterVolumeRef:s,onEngineState:o}}function E0({engineRef:e}){const[t,n]=m.useState(0),[r,s]=m.useState(0),a=m.useRef(0),o=m.useRef(0),i=m.useCallback((c,u)=>{e.current?.setSelection(c,u)},[e]),l=m.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 I0({engineRef:e}){const[t,n]=m.useState(!1),[r,s]=m.useState(0),[a,o]=m.useState(0),i=m.useRef(!1),l=m.useRef(0),c=m.useRef(0),u=m.useCallback(h=>{e.current?.setLoopEnabled(h)},[e]),f=m.useCallback((h,v)=>{e.current?.setLoopRegion(h,v)},[e]),p=m.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),d=m.useCallback(h=>{h.isLoopEnabled!==i.current&&(i.current=h.isLoopEnabled,n(h.isLoopEnabled)),h.loopStart!==l.current&&(l.current=h.loopStart,s(h.loopStart)),h.loopEnd!==c.current&&(c.current=h.loopEnd,o(h.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:a,setLoopEnabled:u,setLoopRegion:f,clearLoopRegion:p,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:d}}function M0({engineRef:e}){const[t,n]=m.useState(null),r=m.useRef(null),s=m.useCallback(o=>{e.current?.selectTrack(o)},[e]),a=m.useCallback(o=>{o.selectedTrackId!==r.current&&(r.current=o.selectedTrackId,n(o.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:a,selectedTrackIdRef:r}}const A0=(e=256)=>{const t=m.useRef(null),n=m.useCallback((r,s,a)=>{const o=new L.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 ns(e,t,n,r,s=48e3){const a=n??e.audioBuffer,o=a?.sampleRate??e.waveformData?.sample_rate??s,i=a?.duration??e.waveformData?.duration??(e.duration!=null?e.duration+(e.offset??0):void 0);if(i===void 0)return console.warn(`[waveform-playlist] Track ${t+1} ("${e.name??"unnamed"}"): Cannot create track — provide duration, audioBuffer, or waveformData with duration.`),null;const l=uc({audioBuffer:a,sampleRate:o,sourceDuration:i,startTime:e.startTime??0,duration:e.duration??i,offset:e.offset??0,name:e.name||`Track ${t+1}`,fadeIn:e.fadeIn,fadeOut:e.fadeOut,waveformData:e.waveformData});if(isNaN(l.startSample)||isNaN(l.durationSamples)||isNaN(l.offsetSamples))return console.error(`[waveform-playlist] Invalid clip values for track ${t+1} ("${e.name??"unnamed"}"): startSample=${l.startSample}, durationSamples=${l.durationSamples}, offsetSamples=${l.offsetSamples}`),null;const c={...dc({name:e.name||`Track ${t+1}`,clips:[l],muted:e.muted??!1,soloed:e.soloed??!1,volume:e.volume??1,pan:e.pan??0,color:e.color}),effects:e.effects,renderMode:e.renderMode,spectrogramConfig:e.spectrogramConfig,spectrogramColorMap:e.spectrogramColorMap},u=r.get(t);return u?(c.id=u.trackId,c.clips[0]={...c.clips[0],id:u.clipId}):r.set(t,{trackId:c.id,clipId:c.clips[0].id}),c}function T0(e,t={}){const{immediate:n=!1,progressive:r=!1}=t,s=n||r,[a,o]=m.useState(!0),[i,l]=m.useState(null),[c,u]=m.useState(0),f=e.length,[p,d]=m.useState(new Map),h=m.useRef(new Map),v=m.useRef(48e3),g=m.useMemo(()=>{if(!s)return null;const _=[];for(let x=0;x<e.length;x++){const S=ns(e[x],x,p.get(x),h.current,v.current);S&&_.push(S)}return _},[s,e,p]),[y,b]=m.useState(g??[]),w=m.useRef(g);return g!==w.current&&(w.current=g,g&&b(g)),m.useEffect(()=>{if(e.length===0){b([]),o(!1),u(0);return}let _=!1;const x=new AbortController;return(async()=>{try{o(!0),l(null),u(0),s&&d(new Map);const k=cc.getContext().rawContext;v.current=k.sampleRate;const E=e.map(async(M,T)=>{if(M.audioBuffer){if(s&&!_){d(F=>{const O=new Map(F);return O.set(T,M.audioBuffer),O}),u(F=>F+1);return}return ns(M,T,M.audioBuffer,h.current,k.sampleRate)}if(!M.src&&M.waveformData){if(s&&!_){u(F=>F+1);return}return ns(M,T,void 0,h.current,k.sampleRate)}if(!M.src)throw new Error(`Track ${T+1}: Must provide src, audioBuffer, or waveformData`);const A=await fetch(M.src,{signal:x.signal});if(!A.ok)throw new Error(`Failed to fetch ${M.src}: ${A.statusText}`);const $=await A.arrayBuffer(),R=await k.decodeAudioData($);if(!R||!R.sampleRate||!R.duration)throw new Error(`Invalid audio buffer for ${M.src}`);if(s&&!_){d(F=>{const O=new Map(F);return O.set(T,R),O}),u(F=>F+1);return}return ns(M,T,R,h.current,k.sampleRate)}),I=await Promise.all(E);if(!_){if(!s){const M=I.filter(T=>T!=null);b(M),u(M.length)}o(!1)}}catch(k){if(!_){const E=k instanceof Error?k.message:"Unknown error loading audio";l(E),o(!1),console.error(`[waveform-playlist] Error loading audio tracks: ${E}`)}}})(),()=>{_=!0,x.abort()}},[e,s]),{tracks:y,loading:a,error:i,loadedCount:c,totalCount:f}}function $0({originalClip:e,clip:t,pixelDelta:n,samplesPerPixel:r,sampleRate:s,boundary:a,sortedClips:o,sortedIndex:i}){const l=n*r,c=Math.floor(.1*s),u={...t,startSample:e.startSample,offsetSamples:e.offsetSamples,durationSamples:e.durationSamples},f=vc(u,Math.floor(l),a,o,i,c);return a==="left"?{startSample:e.startSample+f,durationSamples:e.durationSamples-f,offsetSamples:e.offsetSamples+f}:{startSample:e.startSample,durationSamples:e.durationSamples+f,offsetSamples:e.offsetSamples}}function sf({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:a,snapSamplePosition:o}){const i=m.useRef(o);i.current=o;const l=m.useRef(null),c=m.useRef(0),u=m.useCallback(d=>{const h=d.operation.source?.data;if(!h)return;if(!h.boundary){l.current=null;return}const g=e[h.trackIndex]?.clips[h.clipIndex];g&&(l.current={offsetSamples:g.offsetSamples,durationSamples:g.durationSamples,startSample:g.startSample},a.current=!0)},[e,a]),f=m.useCallback(d=>{const h=d.operation.source?.data;if(!h||!h.boundary||!l.current)return;const{boundary:v,trackIndex:g,clipIndex:y}=h,w=(d.to?.x??d.operation.position.current.x)-d.operation.position.initial.x,_=w*n,x=l.current,S=i.current;let k=_;const E=e.map((I,M)=>{if(M!==g)return I;const T=[...I.clips].sort((R,F)=>R.startSample-F.startSample),A=T.findIndex(R=>R===I.clips[y]),$=I.clips.map((R,F)=>{if(F!==y)return R;let O=$0({originalClip:x,clip:R,pixelDelta:w,samplesPerPixel:n,sampleRate:r,boundary:v,sortedClips:T,sortedIndex:A});if(S)if(v==="left"){const G=S(O.startSample),Q=G-O.startSample;O={startSample:G,durationSamples:O.durationSamples-Q,offsetSamples:O.offsetSamples+Q},k=G-x.startSample}else{const G=O.startSample+O.durationSamples,Q=S(G);O={...O,durationSamples:Q-O.startSample},k=O.durationSamples-x.durationSamples}return{...R,startSample:O.startSample,durationSamples:O.durationSamples,offsetSamples:O.offsetSamples}});return{...I,clips:$}});c.current=k,t(E)},[e,t,n,r]),p=m.useCallback(d=>{if(d.canceled){if(l.current){const _=d.operation.source?.data;if(_){const{trackIndex:x,clipIndex:S}=_,k=l.current,E=e.map((I,M)=>{if(M!==x)return I;const T=I.clips.map((A,$)=>$!==S?A:{...A,offsetSamples:k.offsetSamples,durationSamples:k.durationSamples,startSample:k.startSample});return{...I,clips:T}});t(E)}}a.current=!1,l.current=null,c.current=0;return}const h=d.operation.source?.data;if(!h)return;const{trackIndex:v,clipId:g,boundary:y}=h,b=y?c.current:d.operation.transform.x*n,w=e[v]?.id;if(y){a.current=!1,w?s.current?s.current.trimClip(w,g,y,Math.floor(b)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${v} not found — trim not synced to adapter`),l.current=null,c.current=0;return}w?s.current?s.current.moveClip(w,g,Math.floor(b)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${v} not found — move not synced to adapter`)},[e,t,n,s,a]);return{onDragStart:u,onDragMove:f,onDragEnd:p}}const ba=.01;function af({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:a}){const o=m.useRef(null),i=m.useCallback(u=>{const f=u.operation.source?.data;if(!f||f.annotationIndex===void 0){o.current=null;return}const p=e[f.annotationIndex];p&&(o.current={start:p.start,end:p.end,annotationIndex:f.annotationIndex})},[e]),l=m.useCallback(u=>{if(!o.current)return;const f=u.operation.source?.data;if(!f)return;const{edge:p,annotationIndex:d}=f,h=o.current,y=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n/r,b=p==="start"?h.start+y:h.end+y,w=R0({annotationIndex:d,newTime:b,isDraggingStart:p==="start",annotations:e,duration:s,linkEndpoints:a});t(w)},[e,t,n,r,s,a]),c=m.useCallback(u=>{if(u.canceled&&o.current){const{annotationIndex:f,start:p,end:d}=o.current,h=e.map((v,g)=>g!==f?v:{...v,start:p,end:d});t(h)}o.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function R0({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)<ba?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)<ba){const f=u.start+c;o[e+1]={...u,start:Math.min(u.end-.1,f)};let p=e+1;for(;p<o.length-1;){const d=o[p],h=o[p+1];if(Math.abs(h.start-d.end)<ba){const v=d.end-r[p].end;o[p+1]={...h,start:Math.min(h.end-.1,h.start+v)},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 f=e+1;for(;f<o.length-1;){const p=o[f],d=o[f+1];if(p.end>d.start)o[f+1]={...d,start:p.end},f++;else break}}}return o}function of(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return m.useMemo(()=>t?[ro.configure({activationConstraints(a){return a.pointerType==="touch"?[new Ft.Delay({value:n,tolerance:r})]:[new Ft.Distance({value:s})]}})]:[ro.configure({activationConstraints:[new Ft.Distance({value:s})]})],[t,n,r,s])}const lf=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=tt(),{selectedTrackId:a}=nt(),o=m.useCallback((l,c,u)=>{const{samplesPerPixel:f}=e,p=t[l];if(!p)return!1;const d=p.clips[c];if(!d)return!1;const h=Math.round(u*n),v=yh(h,f),g=Math.floor(.1*n);if(!yc(d,v,g))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const y=r.current;return y?(y.splitClip(p.id,d.id,v),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:m.useCallback(()=>{if(!a)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const l=t.findIndex(f=>f.id===a);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 p=c.clips[f],d=p.startSample/n,h=(p.startSample+p.durationSamples)/n;if(u>d&&u<h)return o(l,f,u)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${c.name}"`),!1},[t,s,a,o,n]),splitClipAt:o}},Ps=e=>{const{shortcuts:t,enabled:n=!0}=e,r=m.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,f=i.metaKey===void 0||s.metaKey===i.metaKey,p=i.altKey===void 0||s.altKey===i.altKey;return l&&c&&u&&f&&p});o&&(o.preventDefault!==!1&&s.preventDefault(),o.action())},[t,n]);m.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},D0=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("+")},cf=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=tt(),{setCurrentTime:a,play:o,pause:i,stop:l}=Se(),c=m.useCallback(()=>{s?i():o()},[s,o,i]),u=m.useCallback(()=>{l()},[l]),f=m.useCallback(()=>{a(0),s&&o(0)},[s,a,o]),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 Ps({shortcuts:d,enabled:t}),{rewindToStart:f,togglePlayPause:c,stopPlayback:u,shortcuts:d}},wa=.01,rs=.01;function uf({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:s,linkEndpoints:a,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:c,sampleRate:u,onPlay:f}){const p=m.useMemo(()=>t?e.findIndex(E=>E.id===t):-1,[e,t]),d=m.useCallback(E=>{if(!l?.current||!c||!u)return;const I=e.find(Q=>Q.id===E);if(!I)return;const M=l.current,T=M.clientWidth,A=I.start*u/c,$=I.end*u/c,R=(A+$)/2,F=M.scrollLeft,O=F,G=F+T;if(A<O||$>G){const Q=Math.max(0,R-T/2);M.scrollTo({left:Q,behavior:"smooth"})}},[e,l,c,u]);m.useEffect(()=>{t&&l?.current&&c&&u&&d(t)},[t,d,l,c,u]);const h=m.useCallback(E=>{if(p<0)return;const I=e[p],M=Math.max(0,Math.min(I.end-.1,I.start+E)),T=M-I.start,A=[...e];if(A[p]={...I,start:M},a&&p>0){const $=A[p-1];Math.abs($.end-I.start)<wa&&(A[p-1]={...$,end:Math.max($.start+.1,$.end+T)})}else if(!a&&p>0){const $=A[p-1];M<$.end&&(A[p-1]={...$,end:M})}n(A)},[e,p,a,n]),v=m.useCallback(E=>{if(p<0)return;const I=e[p],M=Math.max(I.start+.1,Math.min(s,I.end+E)),T=M-I.end,A=[...e];if(A[p]={...I,end:M},a&&p<e.length-1){const $=A[p+1];if(Math.abs($.start-I.end)<wa){const R=Math.min($.end-.1,$.start+T);A[p+1]={...$,start:R};let F=p+1;for(;F<A.length-1;){const O=A[F],G=A[F+1];if(Math.abs(G.start-e[F].end)<wa){const Q=O.end-e[F].end;A[F+1]={...G,start:Math.min(G.end-.1,G.start+Q)},F++}else break}}}else if(!a&&p<e.length-1){const $=A[p+1];if(M>$.start){A[p+1]={...$,start:M};let R=p+1;for(;R<A.length-1;){const F=A[R],O=A[R+1];if(F.end>O.start)A[R+1]={...O,start:F.end},R++;else break}}}n(A)},[e,p,s,a,n]),g=m.useCallback(()=>{!r||e.length===0||(p<=0?r(e[e.length-1].id):r(e[p-1].id))},[e,p,r]),y=m.useCallback(()=>{!r||e.length===0||(p<0||p>=e.length-1?r(e[0].id):r(e[p+1].id))},[e,p,r]),b=m.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),w=m.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),_=m.useCallback(()=>{r&&r(null)},[r]),x=m.useCallback(()=>{if(p<0||!f)return;const E=e[p],I=o?void 0:E.end-E.start;f(E.start,I)},[e,p,o,f]),S=m.useMemo(()=>[{key:"[",action:()=>h(-rs),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>h(rs),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-rs),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(rs),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:x,description:"Play selected annotation",preventDefault:!0}],[h,v,x]),k=m.useMemo(()=>[{key:"ArrowUp",action:g,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:g,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:y,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:y,description:"Select next annotation",preventDefault:!0},{key:"Home",action:b,description:"Select first annotation",preventDefault:!0},{key:"End",action:w,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:_,description:"Deselect annotation",preventDefault:!0}],[g,y,b,w,_]);return Ps({shortcuts:S,enabled:i&&p>=0}),Ps({shortcuts:k,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:h,moveEndBoundary:v,selectPrevious:g,selectNext:y,selectFirst:b,selectLast:w,clearSelection:_,scrollToAnnotation:d,playActiveAnnotation:x}}const Wr=[{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}]}],Ci=e=>Wr.find(t=>t.id===e),P0=e=>Wr.filter(t=>t.category===e),F0=[{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 O0={reverb:L.Reverb,freeverb:L.Freeverb,jcReverb:L.JCReverb,feedbackDelay:L.FeedbackDelay,pingPongDelay:L.PingPongDelay,chorus:L.Chorus,phaser:L.Phaser,tremolo:L.Tremolo,vibrato:L.Vibrato,autoPanner:L.AutoPanner,autoFilter:L.AutoFilter,autoWah:L.AutoWah,eq3:L.EQ3,distortion:L.Distortion,bitCrusher:L.BitCrusher,chebyshev:L.Chebyshev,compressor:L.Compressor,limiter:L.Limiter,gate:L.Gate,stereoWidener:L.StereoWidener};let L0=0;const B0=()=>`effect_${Date.now()}_${++L0}`;function kr(e,t){const n=O0[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=B0(),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 W0(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 V0(e=256){const[t,n]=m.useState([]),r=m.useRef(t);r.current=t;const s=m.useRef(new Map),a=m.useRef(null),o=m.useRef(null),i=m.useCallback(g=>{const y=o.current;if(!y)return;const{masterGainNode:b,destination:w,analyserNode:_}=y;try{b.disconnect()}catch(S){console.warn("[waveform-playlist] Error disconnecting master effects chain:",S)}const x=g.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)b.connect(_),_.connect(w);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(_),_.connect(w)}},[]),l=m.useCallback(g=>{const y=Ci(g);if(!y){console.error(`Unknown effect: ${g}`);return}const b={};y.parameters.forEach(x=>{b[x.name]=x.default});const w=kr(y,b);s.current.set(w.instanceId,w);const _={instanceId:w.instanceId,effectId:y.id,definition:y,params:b,bypassed:!1};n(x=>[...x,_])},[]),c=m.useCallback(g=>{const y=s.current.get(g);y&&(y.dispose(),s.current.delete(g)),n(b=>b.filter(w=>w.instanceId!==g))},[]),u=m.useCallback((g,y,b)=>{const w=s.current.get(g);w&&w.setParameter(y,b),n(_=>_.map(x=>x.instanceId===g?{...x,params:{...x.params,[y]:b}}:x))},[]),f=m.useCallback(g=>{const y=r.current.find(_=>_.instanceId===g);if(!y)return;const b=!y.bypassed,w=s.current.get(g);if(w){const _=y.params.wet??1;w.setParameter("wet",b?0:_)}n(_=>_.map(x=>x.instanceId===g?{...x,bypassed:b}:x))},[]),p=m.useCallback((g,y)=>{n(b=>{const w=[...b],[_]=w.splice(g,1);return w.splice(y,0,_),w})},[]),d=m.useCallback(()=>{s.current.forEach(g=>g.dispose()),s.current.clear(),n([])},[]);m.useEffect(()=>{i(t)},[t,i]);const h=m.useCallback((g,y,b)=>{const w=new L.Analyser("fft",e);a.current=w,o.current={masterGainNode:g,destination:y,analyserNode:w};const x=r.current.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)g.connect(w),w.connect(y);else{let S=g;x.forEach(k=>{S.connect(k.effect),S=k.effect}),S.connect(w),w.connect(y)}return function(){w.dispose(),a.current=null,o.current=null}},[e]);m.useEffect(()=>{const g=s.current;return()=>{g.forEach(y=>y.dispose()),g.clear()}},[]);const v=m.useCallback(()=>{const g=t.filter(y=>!y.bypassed);if(g.length!==0)return(y,b,w)=>{const _=[];for(const x of g){const S=kr(x.definition,x.params);_.push(S)}if(_.length===0)y.connect(b);else{let x=y;_.forEach(S=>{x.connect(S.effect),x=S.effect}),x.connect(b)}return function(){_.forEach(S=>S.dispose())}}},[t]);return{activeEffects:t,availableEffects:Wr,addEffect:l,removeEffect:c,updateParameter:u,toggleBypass:f,reorderEffects:p,clearAllEffects:d,masterEffects:h,createOfflineEffectsFunction:v,analyserRef:a}}function N0(){const[e,t]=m.useState(new Map),n=m.useRef(new Map),r=m.useRef(new Map),s=m.useCallback((d,h)=>{const v=r.current.get(d);if(!v)return;const{graphEnd:g,masterGainNode:y}=v,b=n.current.get(d);try{g.disconnect()}catch(_){console.warn(`[waveform-playlist] Error disconnecting track "${d}" effect chain:`,_)}const w=h.map(_=>b?.get(_.instanceId)).filter(_=>_!==void 0);if(w.length===0)g.connect(y);else{let _=g;w.forEach(x=>{try{x.disconnect()}catch(S){console.warn(`[waveform-playlist] Error disconnecting effect "${x.id}" on track "${d}":`,S)}_.connect(x.effect),_=x.effect}),_.connect(y)}},[]),a=m.useCallback((d,h)=>{const v=Ci(h);if(!v){console.error(`Unknown effect: ${h}`);return}const g={};v.parameters.forEach(w=>{g[w.name]=w.default});const y=kr(v,g);n.current.has(d)||n.current.set(d,new Map),n.current.get(d).set(y.instanceId,y);const b={instanceId:y.instanceId,effectId:v.id,definition:v,params:g,bypassed:!1};t(w=>{const _=new Map(w),x=_.get(d)||[];return _.set(d,[...x,b]),_})},[]),o=m.useCallback((d,h)=>{const v=n.current.get(d),g=v?.get(h);g&&(g.dispose(),v?.delete(h)),t(y=>{const b=new Map(y),w=b.get(d)||[];return b.set(d,w.filter(_=>_.instanceId!==h)),b})},[]),i=m.useCallback((d,h,v,g)=>{const b=n.current.get(d)?.get(h);b&&b.setParameter(v,g),t(w=>{const _=new Map(w),x=_.get(d)||[];return _.set(d,x.map(S=>S.instanceId===h?{...S,params:{...S.params,[v]:g}}:S)),_})},[]),l=m.useCallback((d,h)=>{const g=(u.current.get(d)||[]).find(_=>_.instanceId===h);if(!g)return;const y=!g.bypassed,w=n.current.get(d)?.get(h);if(w){const _=g.params.wet??1;w.setParameter("wet",y?0:_)}t(_=>{const x=new Map(_),S=x.get(d)||[];return x.set(d,S.map(k=>k.instanceId===h?{...k,bypassed:y}:k)),x})},[]),c=m.useCallback(d=>{const h=n.current.get(d);h&&(h.forEach(v=>v.dispose()),h.clear()),t(v=>{const g=new Map(v);return g.set(d,[]),g})},[]),u=m.useRef(e);u.current=e;const f=m.useCallback(d=>(h,v,g)=>{r.current.set(d,{graphEnd:h,masterGainNode:v});const y=u.current.get(d)||[],b=n.current.get(d),w=y.map(_=>b?.get(_.instanceId)).filter(_=>_!==void 0);if(w.length===0)h.connect(v);else{let _=h;w.forEach(x=>{_.connect(x.effect),_=x.effect}),_.connect(v)}return function(){r.current.delete(d)}},[]);m.useEffect(()=>{e.forEach((d,h)=>{s(h,d)})},[e,s]),m.useEffect(()=>{const d=n.current;return()=>{d.forEach(h=>{h.forEach(v=>v.dispose()),h.clear()}),d.clear()}},[]);const p=m.useCallback(d=>{const v=(e.get(d)||[]).filter(g=>!g.bypassed);if(v.length!==0)return(g,y,b)=>{const w=[];for(const _ of v){const x=kr(_.definition,_.params);w.push(x)}if(w.length===0)g.connect(y);else{let _=g;w.forEach(x=>{_.connect(x.effect),_=x.effect}),_.connect(y)}return function(){w.forEach(x=>x.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:a,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:f,createOfflineTrackEffectsFunction:p,availableEffects:Wr}}function j0(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,f=u+c,p=new ArrayBuffer(f),d=new DataView(p);ss(d,0,"RIFF"),d.setUint32(4,f-8,!0),ss(d,8,"WAVE"),ss(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),ss(d,36,"data"),d.setUint32(40,c,!0);const h=[];for(let g=0;g<r;g++)h.push(e.getChannelData(g));let v=u;if(n===16)for(let g=0;g<a;g++)for(let y=0;y<r;y++){const b=h[y][g],w=Math.max(-1,Math.min(1,b)),_=w<0?w*32768:w*32767;d.setInt16(v,_,!0),v+=2}else for(let g=0;g<a;g++)for(let y=0;y<r;y++)d.setFloat32(v,h[y][g],!0),v+=4;return new Blob([p],{type:"audio/wav"})}function ss(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function z0(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 df(){const[e,t]=m.useState(!1),[n,r]=m.useState(0),[s,a]=m.useState(null);return{exportWav:m.useCallback(async(i,l,c={})=>{const{filename:u="export",mode:f="master",trackIndex:p,autoDownload:d=!0,applyEffects:h=!0,effectsFunction:v,createOfflineTrackEffects:g,bitDepth:y=16,onProgress:b}=c;t(!0),r(0),a(null);try{if(i.length===0)throw new Error("No tracks to export");if(f==="individual"&&(p===void 0||p<0||p>=i.length))throw new Error("Invalid track index for individual export");const w=i[0].clips[0]?.sampleRate||44100;let _=0;for(const T of i)for(const A of T.clips){const $=A.startSample+A.durationSamples;_=Math.max(_,$)}_+=Math.round(w*.1);const x=_/w,S=f==="individual"?[{track:i[p],state:l[p],index:p}]:i.map((T,A)=>({track:T,state:l[A],index:A})),k=l.some(T=>T.soloed),E=!!g;let I;if((v||E)&&h)I=await Z0(S,l,k,x,w,v,g,T=>{r(T),b?.(T)});else{const T=new OfflineAudioContext(2,_,w);let A=0;const $=S.reduce((R,{track:F})=>R+F.clips.length,0);for(const{track:R,state:F}of S)if(!(F.muted&&!F.soloed)&&!(k&&!F.soloed))for(const O of R.clips){await G0(T,O,F,w,h),A++;const G=A/$*.5;r(G),b?.(G)}r(.5),b?.(.5),I=await T.startRendering()}r(.9),b?.(.9);const M=j0(I,{bitDepth:y});if(r(1),b?.(1),d){const T=f==="individual"?`${u}_${i[p].name}`:u;z0(M,`${T}.wav`)}return{audioBuffer:I,blob:M,duration:x}}catch(w){const _=w instanceof Error?w.message:"Export failed";throw a(_),w}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function Z0(e,t,n,r,s,a,o,i){const{Offline:l,Volume:c,Gain:u,Panner:f,Player:p,ToneAudioBuffer:d}=await import("tone");i(.1);let h;try{h=await l(async({transport:v,destination:g})=>{const y=new c(0);let b;a?b=a(y,g,!0):y.connect(g);for(const{track:w,state:_}of e){if(_.muted&&!_.soloed||n&&!_.soloed)continue;const x=new c(H0(_.volume)),S=new f(_.pan),k=new u(_.muted?0:1),E=o?.(w.id);E?E(k,y,!0):k.connect(y),S.connect(k),x.connect(S);for(const I of w.clips){const{audioBuffer:M,startSample:T,durationSamples:A,offsetSamples:$,gain:R,fadeIn:F,fadeOut:O}=I,G=T/s,Q=A/s,ee=$/s,ue=new d(M),te=new p(ue),oe=new u(R);if(te.connect(oe),oe.connect(x),F){const se=G,le=G+F.duration,ye=gr(oe.gain);ye&&(ye.setValueAtTime(0,se),ye.linearRampToValueAtTime(R,le))}if(O){const se=G+Q-O.duration,le=G+Q,ye=gr(oe.gain);ye&&(ye.setValueAtTime(R,se),ye.linearRampToValueAtTime(0,le))}te.start(G,ee,Q)}}v.start(0)},r,2,s)}catch(v){throw v instanceof Error?v:new Error(`Tone.Offline rendering failed: ${String(v)}`)}return i(.9),h.get()}function H0(e){return 20*Math.log10(Math.max(e,1e-4))}async function G0(e,t,n,r,s){const{audioBuffer:a,startSample:o,durationSamples:i,offsetSamples:l,gain:c,fadeIn:u,fadeOut:f}=t;if(!a){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const p=o/r,d=i/r,h=l/r,v=e.createBufferSource();v.buffer=a;const g=e.createGain(),y=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,v.connect(g),g.connect(b),b.connect(e.destination),s){if(u?g.gain.setValueAtTime(0,p):g.gain.setValueAtTime(y,p),u){const w=p,_=p+u.duration;ec(g.gain,w,_,0,y,u.type||"linear")}if(f){const w=p+d-f.duration,_=p+d;(!u||u.duration<d-f.duration)&&g.gain.setValueAtTime(y,w),ec(g.gain,w,_,y,0,f.type||"linear")}}else g.gain.setValueAtTime(y,p);v.start(p,h,d)}function ec(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=tc(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,o);break}case"sCurve":{const i=tc(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,o);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function tc(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 ff=()=>{const e=m.useRef(null),t=m.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=m.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return m.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},U0=`
858
858
  "use strict";
859
859
 
860
860
  var INT8_MAX = 127;
@@ -1001,13 +1001,13 @@ self.onmessage = function(e) {
1001
1001
  self.postMessage({ id: msg.id, error: err.message || String(err) });
1002
1002
  }
1003
1003
  };
1004
- `;let q0=0;function J0(){let e;try{const r=new Blob([K0],{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(++q0);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 Q0(e,t){const[n,r]=p.useState(()=>new Map),[s,a]=p.useState(!1),o=p.useRef(null),i=p.useRef(new WeakMap),l=p.useRef(new WeakMap),c=p.useRef(new WeakMap),u=p.useRef(0),f=p.useCallback(()=>(o.current||(o.current=J0()),o.current),[]);return p.useEffect(()=>{let m=!1;const d=i.current,h=l.current,v=c.current,g=[],y=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){g.push({clipId:w.id,waveformData:x});continue}if(h.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=y.get(w.audioBuffer);S?S.add(w.id):y.set(w.audioBuffer,new Set([w.id]))}if(g.length>0&&r(_=>{const w=new Map(_);for(const x of g)w.set(x.clipId,x.waveformData);return w}),y.size===0)return;u.current+=y.size,a(!0);const b=f();for(const[_,w]of y){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 M=v.get(_)??new Set;v.delete(_),h.delete(_),!m&&(r(T=>{const $=new Map(T);for(const A of M)$.set(A,E);return $}),u.current--,u.current<=0&&(u.current=0,a(!1)))}).catch(E=>{v.delete(_),h.delete(_),!m&&(console.warn("[waveform-playlist] Worker peak generation failed:",E),u.current--,u.current<=0&&(u.current=0,a(!1)))});h.set(_,k)}return()=>{m=!0,l.current=new WeakMap,c.current=new WeakMap,u.current=0,a(!1)}},[e,t,f]),p.useEffect(()=>()=>{o.current?.terminate(),o.current=null},[]),{cache:n,isGenerating:s}}function po(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 ey(e,t,n){const r=po(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 ty(){const[e,t]=p.useState([]),[n,r]=p.useState(0),[s,a]=p.useState([]),o=p.useRef(!1),i=p.useRef(new Set),l=p.useRef(new Map);p.useEffect(()=>{const f=l.current;return()=>{o.current=!0;for(const m of f.values())m.abort();f.clear()}},[]);const c=p.useCallback(f=>{if(f.length===0)return;const m=gh(),d=f.map(h=>({track:dc({name:`${po(h)} (loading...)`,clips:[]}),source:h}));t(h=>[...h,...d.map(v=>v.track)]),r(h=>h+f.length);for(const{track:h,source:v}of d){i.current.add(h.id);const g=new AbortController;l.current.set(h.id,g),(async()=>{try{const{audioBuffer:y,name:b}=await ey(v,m,g.signal),_=uc({audioBuffer:y,startTime:0,duration:y.duration,offset:0,name:b});!o.current&&i.current.has(h.id)&&t(w=>w.map(x=>x.id===h.id?{...x,name:b,clips:[_]}:x))}catch(y){if(y instanceof DOMException&&y.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",y),!o.current&&i.current.has(h.id)&&(t(b=>b.filter(_=>_.id!==h.id)),a(b=>[...b,{name:po(v),error:y instanceof Error?y:new Error(String(y))}]))}finally{l.current.delete(h.id),!o.current&&i.current.delete(h.id)&&r(y=>y-1)}})()}},[]),u=p.useCallback(f=>{t(d=>d.filter(h=>h.id!==f));const m=l.current.get(f);m&&(m.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 hf=p.createContext(null),pf=p.createContext(null),mf=p.createContext(null),gf=p.createContext(null),ny=({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:f,onAnnotationUpdate:m,onAnnotationsChange:d,barWidth:h=1,barGap:v=0,progressBarWidth:g,onTracksChange:y,soundFontCache:b,deferEngineRebuild:_=!1,children:w})=>{const x=g??h+v,S=p.useMemo(()=>a,[a?.join(",")]),k=p.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const V=c.annotations[0];if(typeof V.start!="number"||typeof V.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 V.start),[]}return c.annotations},[c?.annotations]),E=p.useRef(k);E.current=k;const[M,T]=p.useState(null),[$,A]=p.useState(!1),[I,R]=p.useState(0),[D,O]=p.useState(0),[Z,G]=p.useState([]),[Y,te]=p.useState([]),[X,K]=p.useState([]),[le,J]=p.useState(o),[de,ue]=p.useState(c?.isContinuousPlay??!1),[ne,z]=p.useState(c?.linkEndpoints??!1),[ae,ke]=p.useState(c?.editable??!1),[ce,xe]=p.useState(!1),B=p.useRef(null),_e=p.useRef(!1),re=p.useRef(!1);re.current=$;const Me=p.useRef(0),pe=p.useRef(0),Ae=p.useRef(e),He=p.useRef(b);He.current=b;const qe=p.useRef(X),Ve=p.useRef(0),Le=p.useRef(0),je=p.useRef(null),tt=p.useRef(null),Ct=p.useRef(!1),St=p.useRef(c?.isContinuousPlay??!1),j=p.useRef(null),ge=p.useRef(null),Ge=p.useRef(0),Ue=p.useRef(!1),oe=p.useRef(!1),ve=p.useRef(s),Xe=p.useRef(44100),{timeFormat:kt,setTimeFormat:N,formatTime:q}=tf(),U=nf({engineRef:B,initialSamplesPerPixel:s}),{samplesPerPixel:Q,onEngineState:Te}=U,De=rf({engineRef:B,initialVolume:1}),{masterVolume:ee,setMasterVolume:Ne,masterVolumeRef:Je,onEngineState:Ye}=De,{selectionStart:Et,selectionEnd:Dt,setSelection:en,selectionStartRef:Pt,selectionEndRef:zt,onEngineState:Yn}=A0({engineRef:B}),{isLoopEnabled:Zr,loopStart:Hr,loopEnd:$i,setLoopEnabled:Ri,setLoopRegion:Gr,clearLoopRegion:Di,isLoopEnabledRef:Pi,loopStartRef:Fi,loopEndRef:Oi,onEngineState:Li}=T0({engineRef:B}),{selectedTrackId:Bi,setSelectedTrackId:Wi,onEngineState:Vi,selectedTrackIdRef:Ni}=$0({engineRef:B}),{animationFrameRef:zi,startAnimationFrameLoop:sa,stopAnimationFrameLoop:Ur}=ff(),zf=p.useMemo(()=>Math.min(...S??[256,512,1024,2048,4096,8192]),[S]),{cache:ji}=Q0(e,zf),Zi=p.useCallback(V=>{St.current=V,ue(V)},[]),Ft=p.useCallback(V=>{j.current=V,T(V)},[]),Hi=p.useCallback(()=>{const V=Pt.current??0,H=zt.current??0;V!==H&&H>V&&Gr(V,H)},[Gr,Pt,zt]);p.useEffect(()=>{Ct.current=le},[le]),p.useEffect(()=>{qe.current=X},[X]),Ae.current=e;const aa=e===ge.current;Ue.current=aa||oe.current,p.useEffect(()=>{if(!tt.current||D===0)return;const V=tt.current,H=ve.current,me=Q;if(H===me)return;const W=V.clientWidth,$e=V.scrollLeft+W/2,Ee=Xe.current,ca=$e*H/Ee*Ee/me,qr=Math.max(0,ca-W/2);V.scrollLeft=qr,ve.current=me},[Q,D]);const Xr=p.useRef(null);p.useEffect(()=>{if(aa||oe.current){aa&&(ge.current=null);let W=0;e.forEach(Ce=>{Ce.clips.forEach($e=>{const Ee=($e.startSample+$e.durationSamples)/$e.sampleRate;W=Math.max(W,Ee)})}),O(W);return}if(_){let W=0;e.forEach(Ce=>{Ce.clips.forEach($e=>{const Ee=($e.startSample+$e.durationSamples)/$e.sampleRate;W=Math.max(W,Ee)})}),O(W);return}if(xe(!1),e.length===0){G([]),O(0),K([]),te([]),B.current&&(B.current.dispose(),B.current=null);return}const V=re.current,H=pe.current;return B.current&&V&&(B.current.stop(),Ur(),Xr.current={position:H}),(async()=>{try{const W=[];e.forEach(Re=>{Re.clips.length>0&&Re.clips[0].audioBuffer&&W.push(Re.clips[0].audioBuffer)});let Ce=0;e.forEach(Re=>{Re.clips.forEach(ht=>{const jt=ht.sampleRate,Yf=(ht.startSample+ht.durationSamples)/jt;Ce=Math.max(Ce,Yf)})}),G(W),O(Ce),K(Re=>Re.length===e.length?Re.map((ht,jt)=>({...ht,name:e[jt].name})):e.map(ht=>({name:ht.name,muted:ht.muted,soloed:ht.soloed,volume:ht.volume,pan:ht.pan}))),B.current&&B.current.dispose(),Ge.current=0,ge.current=null,_e.current=!1;const $e=vh({effects:u,soundFontCache:He.current}),Ee=new Sh({adapter:$e,samplesPerPixel:ve.current,zoomLevels:S});Ee.setSelection(Pt.current??0,zt.current??0),Ee.setLoopRegion(Fi.current??0,Oi.current??0),Pi.current&&Ee.setLoopEnabled(!0),Ee.setMasterVolume(Je.current??1),Ni.current&&Ee.selectTrack(Ni.current);const Kr=qe.current,ca=e.map((Re,ht)=>{const jt=Kr[ht];return{...Re,volume:jt?.volume??Re.volume,muted:jt?.muted??Re.muted,soloed:jt?.soloed??Re.soloed,pan:jt?.pan??Re.pan}});let qr=!0;Ee.on("statechange",Re=>{Yn(Re),Li(Re),Vi(Re),Te(Re),Ye(Re),!qr&&Re.tracksVersion!==Ge.current&&(Ge.current=Re.tracksVersion,ge.current=Re.tracks,y?y(Re.tracks):console.warn("[waveform-playlist] Engine tracks changed but onTracksChange prop is not set — UI will revert on next render. Pass onTracksChange to WaveformPlaylistProvider."))}),Ee.setTracks(ca),qr=!1,Ge.current=Ee.getState().tracksVersion,B.current=Ee,xe(!0);const Xf=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:Ce}});window.dispatchEvent(Xf),f?.()}catch(W){console.error("Error loading audio:",W)}})(),()=>{if(Ue.current){Ue.current=!1;return}Ur(),B.current&&B.current.dispose()}},[e,f,u,Ur,Yn,Li,Vi,Te,Ye,y,Je,Pt,zt,Fi,Oi,Pi,S,b,_]),p.useEffect(()=>{if(e.length===0)return;const V=e.map(H=>H.clips.map(W=>{let Ce;if(W.waveformData)try{Ce=Ql(W.waveformData,Q,n,W.offsetSamples,W.durationSamples)}catch($e){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",$e)}if(!Ce){const $e=ji.get(W.id);if($e)try{Ce=Ql($e,Q,n,W.offsetSamples,W.durationSamples)}catch(Ee){console.warn("[waveform-playlist] Failed to extract peaks from cache:",Ee)}}if(!Ce){!_&&!W.audioBuffer&&!W.waveformData&&!W.midiNotes&&console.warn(`[waveform-playlist] Clip "${W.id}" has no audio data or waveform data`);const $e=n?1:W.audioBuffer?.numberOfChannels??1,Ee=W.midiNotes?Math.ceil(W.durationSamples/Q):0;Ce={length:Ee,data:Array.from({length:$e},()=>new Int16Array(Ee*2)),bits:16}}return{clipId:W.id,trackName:H.name,peaks:Ce,startSample:W.startSample,durationSamples:W.durationSamples,fadeIn:W.fadeIn,fadeOut:W.fadeOut,midiNotes:W.midiNotes,sampleRate:W.sampleRate,offsetSamples:W.offsetSamples}}));te(V)},[e,Q,n,ji,_]);const Gi=p.useRef(!1),xn=p.useCallback(()=>{if(B.current)return B.current.getCurrentTime();Gi.current||(Gi.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const V=L.getContext().currentTime-(Ve.current??0);return(Le.current??0)+V},[]),tn=p.useCallback(()=>{const V=()=>{const H=xn();pe.current=H;const me=E.current;if(me.length>0){const W=me.find(Ce=>H>=Ce.start&&H<Ce.end);if(St.current)W&&W.id!==j.current?Ft(W.id):!W&&j.current!==null&&Ft(null);else if(j.current){const Ce=me.find($e=>$e.id===j.current);if(Ce&&H>=Ce.end){B.current&&B.current.stop(),A(!1),pe.current=Me.current,R(Me.current);return}}else W&&Ft(W.id)}if(Ct.current&&tt.current&&D>0){const W=tt.current,Ce=Xe.current,$e=H*Ce/ve.current,Ee=W.clientWidth,Kr=Math.max(0,$e-Ee/2);W.scrollLeft=Kr}if(je.current!==null&&H>=je.current){B.current&&B.current.stop(),A(!1),pe.current=je.current,R(je.current),je.current=null;return}if(H>=D){B.current&&B.current.stop(),A(!1),pe.current=Me.current,R(Me.current),Ft(null);return}sa(V)};sa(V)},[D,Ft,sa,xn]),ft=Ur;p.useEffect(()=>{(async()=>{if($&&zi.current&&B.current)if(de){const H=pe.current;B.current.stop(),ft();const W=L.getContext().currentTime;Ve.current=W,Le.current=H,B.current.play(H),tn()}else ft(),tn()})().catch(H=>{console.warn("[waveform-playlist] Failed to reschedule playback:",H),A(!1),ft()})},[de,$,tn,ft,zi]),p.useEffect(()=>{(async()=>{if(Xr.current&&B.current){const{position:H}=Xr.current;Xr.current=null;const W=L.getContext().currentTime;Ve.current=W,Le.current=H,_e.current||(await B.current.init(),_e.current=!0),B.current.play(H),A(!0),tn()}})().catch(H=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",H),A(!1),ft()})},[e,tn,ft]);const Yr=p.useCallback(async(V,H)=>{if(!B.current||D===0)return;const me=V??pe.current;Me.current=me,pe.current=me,B.current.stop(),B.current.seek(me),ft();const Ce=L.getContext().currentTime;Ve.current=Ce,Le.current=me,je.current=H!==void 0?me+H:null,_e.current||(await B.current.init(),_e.current=!0);const $e=H!==void 0?me+H:void 0;try{B.current.play(me,$e)}catch(Ee){console.warn("[waveform-playlist] Playback failed to start:",Ee),ft();return}A(!0),tn()},[D,tn,ft]),Ui=p.useCallback(()=>{if(!B.current)return;const V=xn();B.current.pause(),A(!1),ft(),pe.current=V,R(V)},[ft,xn]),Xi=p.useCallback(()=>{B.current&&(B.current.stop(),A(!1),ft(),pe.current=Me.current,R(Me.current),Ft(null))},[ft,Ft]),Yi=p.useCallback(V=>{const H=Math.max(0,Math.min(V,D));pe.current=H,R(H),$&&B.current&&Yr(H)},[D,$,Yr]),Ki=p.useCallback((V,H)=>{const me=Ae.current[V]?.id;if(!me)return;const W=[...X];W[V]={...W[V],muted:H},K(W),B.current&&B.current.setTrackMute(me,H)},[X]),qi=p.useCallback((V,H)=>{const me=Ae.current[V]?.id;if(!me)return;const W=[...X];W[V]={...W[V],soloed:H},K(W),B.current&&B.current.setTrackSolo(me,H)},[X]),Ji=p.useCallback((V,H)=>{const me=Ae.current[V]?.id;if(!me)return;const W=[...X];W[V]={...W[V],volume:H},K(W),B.current&&B.current.setTrackVolume(me,H)},[X]),Qi=p.useCallback((V,H)=>{const me=Ae.current[V]?.id;if(!me)return;const W=[...X];W[V]={...W[V],pan:H},K(W),B.current&&B.current.setTrackPan(me,H)},[X]),el=p.useCallback((V,H)=>{en(V,H),pe.current=V,R(V),$&&B.current&&(B.current.stop(),B.current.seek(V),B.current.play(V))},[$,en]),tl=p.useCallback(V=>{tt.current=V},[]),oa=p.useRef(d);oa.current=d;const nl=p.useCallback(V=>{const H=typeof V=="function"?V(E.current):V;if(!oa.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}oa.current(H)},[]),ia=Z[0]?.sampleRate||e[0]?.clips[0]?.sampleRate||44100;Xe.current=ia;const la=t?30:0,rl=e.length*r+la,jf=p.useMemo(()=>({isPlaying:$,currentTime:I,currentTimeRef:pe,playbackStartTimeRef:Ve,audioStartPositionRef:Le,getPlaybackTime:xn}),[$,I,pe,Ve,Le,xn]),Zf=p.useMemo(()=>({continuousPlay:de,linkEndpoints:ne,annotationsEditable:ae,isAutomaticScroll:le,isLoopEnabled:Zr,annotations:k,activeAnnotationId:M,selectionStart:Et,selectionEnd:Dt,selectedTrackId:Bi,loopStart:Hr,loopEnd:$i}),[de,ne,ae,le,Zr,k,M,Et,Dt,Bi,Hr,$i]),sl=p.useCallback(V=>{pe.current=V,R(V)},[pe]),al=p.useCallback(V=>{J(V)},[]),Hf=p.useMemo(()=>({play:Yr,pause:Ui,stop:Xi,seekTo:Yi,setCurrentTime:sl,setTrackMute:Ki,setTrackSolo:qi,setTrackVolume:Ji,setTrackPan:Qi,setSelection:el,setSelectedTrackId:Wi,setTimeFormat:N,formatTime:q,zoomIn:U.zoomIn,zoomOut:U.zoomOut,setMasterVolume:Ne,setAutomaticScroll:al,setScrollContainer:tl,scrollContainerRef:tt,setContinuousPlay:Zi,setLinkEndpoints:z,setAnnotationsEditable:ke,setAnnotations:nl,setActiveAnnotationId:Ft,setLoopEnabled:Ri,setLoopRegion:Gr,setLoopRegionFromSelection:Hi,clearLoopRegion:Di}),[Yr,Ui,Xi,Yi,sl,Ki,qi,Ji,Qi,el,Wi,N,q,U.zoomIn,U.zoomOut,Ne,al,tl,tt,Zi,z,ke,nl,Ft,Ri,Gr,Hi,Di]),Gf=p.useMemo(()=>({duration:D,audioBuffers:Z,peaksDataArray:Y,trackStates:X,tracks:e,sampleRate:ia,waveHeight:r,timeScaleHeight:la,minimumPlaylistHeight:rl,controls:l,playoutRef:B,samplesPerPixel:Q,timeFormat:kt,masterVolume:ee,canZoomIn:U.canZoomIn,canZoomOut:U.canZoomOut,barWidth:h,barGap:v,progressBarWidth:x,isReady:ce,mono:n,isDraggingRef:oe,onTracksChange:y}),[D,Z,Y,X,e,ia,r,la,rl,l,B,Q,kt,ee,U.canZoomIn,U.canZoomOut,h,v,x,ce,n,oe,y]),Uf={...Wd,...i};return C.jsx(F.ThemeProvider,{theme:Uf,children:C.jsx(hf.Provider,{value:jf,children:C.jsx(pf.Provider,{value:Zf,children:C.jsx(mf.Provider,{value:Hf,children:C.jsx(gf.Provider,{value:Gf,children:w})})})})})},ot=()=>{const e=p.useContext(hf);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},it=()=>{const e=p.useContext(pf);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},Ie=()=>{const e=p.useContext(mf);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},lt=()=>{const e=p.useContext(gf);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var ry=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}},sy=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 ry({...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 vf=p.createContext(null),yf=p.createContext(null),bf=p.createContext(null),wf=p.createContext(null),ay=({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:f,onAnnotationsChange:m,onReady:d,children:h})=>{const v=f??c+u,[g,y]=p.useState(!1),[b,_]=p.useState(0),[w,x]=p.useState(0),[S,k]=p.useState([]),[E,M]=p.useState(s),T=p.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const j=l.annotations[0];if(typeof j.start!="number"||typeof j.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 j.start),[]}return l.annotations},[l?.annotations]),$=p.useRef(T);$.current=T;const[A,I]=p.useState(null),[R,D]=p.useState(l?.isContinuousPlay??!1),[O]=p.useState(t),[Z,G]=p.useState(a),Y=p.useRef(null),te=p.useRef(0),X=p.useRef(R),K=p.useRef(null),le=p.useRef(null),J=p.useRef(a),de=p.useRef(t),{startAnimationFrameLoop:ue,stopAnimationFrameLoop:ne}=ff();p.useEffect(()=>{X.current=R},[R]),p.useEffect(()=>{J.current=Z},[Z]);const z=p.useCallback(j=>{K.current=j,I(j)},[]),ae=p.useCallback(j=>{X.current=j,D(j)},[]),ke=p.useCallback(j=>{le.current=j},[]),ce=e.waveformData.sample_rate;p.useEffect(()=>{const j=new sy({playbackRate:s});j.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const ge=j.getTrack(j.track?.id??"");return ge&&ge.setOnTimeUpdateCallback(Ge=>{te.current=Ge}),j.setOnPlaybackComplete(()=>{ne(),y(!1),z(null),te.current=0,_(0)}),Y.current=j,x(e.waveformData.duration),d?.(),()=>{ne(),j.dispose()}},[e.source,e.waveformData,e.name,s,d,ne,z]),p.useEffect(()=>{try{const j=M0(e.waveformData,O,0,0,Math.ceil(e.waveformData.duration*ce)),ge={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:j.length,data:[j.data],bits:j.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*ce)};k([[ge]])}catch(j){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",j)}},[e.waveformData,e.name,O,ce]);const xe=p.useCallback(()=>{const j=()=>{const ge=Y.current?.getCurrentTime()??0;te.current=ge;const Ge=$.current;if(Ge.length>0){const Ue=Ge.find(oe=>ge>=oe.start&&ge<oe.end);if(X.current)Ue&&Ue.id!==K.current?z(Ue.id):!Ue&&K.current!==null&&z(null);else if(K.current){const oe=Ge.find(ve=>ve.id===K.current);if(oe&&ge>=oe.end){Y.current?.stop(),y(!1);return}}else Ue&&z(Ue.id)}if(J.current&&le.current){const Ue=le.current,oe=ge*ce/de.current,ve=Ue.clientWidth,Xe=Math.max(0,oe-ve/2);Ue.scrollLeft=Xe}ue(j)};ue(j)},[z,ce,ue]),B=ne,_e=p.useCallback(j=>{if(!Y.current)return;const ge=j??te.current;Y.current.play(void 0,ge),y(!0),xe()},[xe]),re=p.useCallback(()=>{Y.current&&(Y.current.pause(),y(!1),B(),_(Y.current.getCurrentTime()))},[B]),Me=p.useCallback(()=>{Y.current&&(Y.current.stop(),y(!1),B(),te.current=0,_(0),z(null))},[B,z]),pe=p.useCallback(j=>{const ge=Math.max(0,Math.min(j,w));te.current=ge,_(ge),Y.current&&Y.current.seekTo(ge)},[w]),Ae=p.useCallback(j=>{const ge=Math.max(.5,Math.min(2,j));M(ge),Y.current&&Y.current.setPlaybackRate(ge)},[]),He=r?30:0,qe=p.useMemo(()=>({isPlaying:g,currentTime:b,currentTimeRef:te}),[g,b]),Ve=p.useMemo(()=>({continuousPlay:R,annotations:T,activeAnnotationId:A,playbackRate:E,isAutomaticScroll:Z}),[R,T,A,E,Z]),Le=p.useRef(m);Le.current=m;const je=p.useCallback(j=>{const ge=typeof j=="function"?j($.current):j;if(!Le.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}Le.current(ge)},[]),tt=p.useMemo(()=>({play:_e,pause:re,stop:Me,seekTo:pe,setPlaybackRate:Ae,setContinuousPlay:ae,setAnnotations:je,setActiveAnnotationId:z,setAutomaticScroll:j=>{G(j)},setScrollContainer:ke,scrollContainerRef:le}),[_e,re,Me,pe,Ae,ae,je,z,ke]),Ct=p.useMemo(()=>({duration:w,peaksDataArray:S,sampleRate:ce,waveHeight:n,timeScaleHeight:He,samplesPerPixel:O,playoutRef:Y,controls:i,barWidth:c,barGap:u,progressBarWidth:v}),[w,S,ce,n,He,O,i,c,u,v]),St={...Wd,...o};return C.jsx(F.ThemeProvider,{theme:St,children:C.jsx(vf.Provider,{value:qe,children:C.jsx(yf.Provider,{value:Ve,children:C.jsx(bf.Provider,{value:tt,children:C.jsx(wf.Provider,{value:Ct,children:h})})})})})},zr=()=>{const e=p.useContext(vf);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},ea=()=>{const e=p.useContext(yf);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},Ii=()=>{const e=p.useContext(bf);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},ta=()=>{const e=p.useContext(wf);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},oy=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=ot(),{selectionStart:r,selectionEnd:s,isLoopEnabled:a}=it(),{play:o}=Ie(),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(vt,{onClick:i,disabled:t,className:e,children:"Play"})},iy=({className:e})=>{const{isPlaying:t}=ot(),{pause:n}=Ie();return C.jsx(vt,{onClick:n,disabled:!t,className:e,children:"Pause"})},ly=({className:e})=>{const{isPlaying:t}=ot(),{stop:n}=Ie();return C.jsx(vt,{onClick:n,disabled:!t,className:e,children:"Stop"})},cy=({className:e})=>{const{isPlaying:t}=ot(),{play:n,setCurrentTime:r}=Ie(),s=()=>{r(0),t&&n(0)};return C.jsx(vt,{onClick:s,className:e,children:"Rewind"})},uy=({className:e})=>{const{isPlaying:t}=ot(),{play:n,setCurrentTime:r}=Ie(),{duration:s}=lt(),a=()=>{r(s),t&&n(s)};return C.jsx(vt,{onClick:a,className:e,children:"Fast Forward"})},dy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ot(),{play:s,setCurrentTime:a}=Ie(),o=()=>{const i=Math.max(0,(n.current??0)-e);a(i),r&&s(i)};return C.jsx(vt,{onClick:o,className:t,children:"Skip Backward"})},fy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ot(),{play:s,setCurrentTime:a}=Ie(),{duration:o}=lt(),i=()=>{const l=Math.min(o,(n.current??0)+e);a(l),r&&s(l)};return C.jsx(vt,{onClick:i,className:t,children:"Skip Forward"})},hy=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=it(),{setLoopEnabled:s,setLoopRegion:a}=Ie(),{duration:o}=lt(),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(vt,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},py=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=it(),{setLoopRegionFromSelection:a,clearLoopRegion:o}=Ie(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?o():a()};return C.jsx(vt,{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"})},my=({onClearAll:e,label:t="Clear All",className:n})=>{const{stop:r}=Ie(),s=p.useCallback(()=>{r(),e()},[r,e]);return C.jsx(vt,{onClick:s,className:n,title:"Remove all tracks",children:t})},gy=({className:e,disabled:t})=>{const{zoomIn:n}=Ie(),{canZoomIn:r}=lt();return C.jsx(vt,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},vy=({className:e,disabled:t})=>{const{zoomOut:n}=Ie(),{canZoomOut:r}=lt();return C.jsx(vt,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},yy=({className:e})=>{const{masterVolume:t}=lt(),{setMasterVolume:n}=Ie();return C.jsx(lv,{volume:t,onChange:n,className:e})},by=({className:e})=>{const{timeFormat:t}=lt(),{setTimeFormat:n}=Ie();return C.jsx(Xv,{value:t,onChange:n,className:e})},wy=F.span`
1004
+ `;let X0=0;function Y0(){let e;try{const r=new Blob([U0],{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=pt.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(++X0);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 K0(e,t){const[n,r]=m.useState(()=>new Map),[s,a]=m.useState(!1),o=m.useRef(null),i=m.useRef(new WeakMap),l=m.useRef(new WeakMap),c=m.useRef(new WeakMap),u=m.useRef(0),f=m.useCallback(()=>(o.current||(o.current=Y0()),o.current),[]);return m.useEffect(()=>{let p=!1;const d=i.current,h=l.current,v=c.current,g=[],y=new Map;for(const w of e)for(const _ of w.clips){if(!_.audioBuffer||_.waveformData)continue;const x=d.get(_.audioBuffer);if(x){g.push({clipId:_.id,waveformData:x});continue}if(h.get(_.audioBuffer)){const k=v.get(_.audioBuffer);k?k.add(_.id):v.set(_.audioBuffer,new Set([_.id]));continue}const S=y.get(_.audioBuffer);S?S.add(_.id):y.set(_.audioBuffer,new Set([_.id]))}if(g.length>0&&r(w=>{const _=new Map(w);for(const x of g)_.set(x.clipId,x.waveformData);return _}),y.size===0)return;u.current+=y.size,a(!0);const b=f();for(const[w,_]of y){v.set(w,new Set(_));const x=[];for(let E=0;E<w.numberOfChannels;E++)x.push(w.getChannelData(E).slice().buffer);const S=`buffer-${Math.random().toString(36).slice(2,11)}`,k=b.generate({id:S,channels:x,length:w.length,sampleRate:w.sampleRate,scale:t,bits:16,splitChannels:!0}).then(E=>{d.set(w,E);const I=v.get(w)??new Set;v.delete(w),h.delete(w),!p&&(r(M=>{const T=new Map(M);for(const A of I)T.set(A,E);return T}),u.current--,u.current<=0&&(u.current=0,a(!1)))}).catch(E=>{v.delete(w),h.delete(w),!p&&(console.warn("[waveform-playlist] Worker peak generation failed:",E),u.current--,u.current<=0&&(u.current=0,a(!1)))});h.set(w,k)}return()=>{p=!0,l.current=new WeakMap,c.current=new WeakMap,u.current=0,a(!1)}},[e,t,f]),m.useEffect(()=>()=>{o.current?.terminate(),o.current=null},[]),{cache:n,isGenerating:s}}function uo(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 q0(e,t,n){const r=uo(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 J0(){const[e,t]=m.useState([]),[n,r]=m.useState(0),[s,a]=m.useState([]),o=m.useRef(!1),i=m.useRef(new Set),l=m.useRef(new Map);m.useEffect(()=>{const f=l.current;return()=>{o.current=!0;for(const p of f.values())p.abort();f.clear()}},[]);const c=m.useCallback(f=>{if(f.length===0)return;const p=gh(),d=f.map(h=>({track:dc({name:`${uo(h)} (loading...)`,clips:[]}),source:h}));t(h=>[...h,...d.map(v=>v.track)]),r(h=>h+f.length);for(const{track:h,source:v}of d){i.current.add(h.id);const g=new AbortController;l.current.set(h.id,g),(async()=>{try{const{audioBuffer:y,name:b}=await q0(v,p,g.signal),w=uc({audioBuffer:y,startTime:0,duration:y.duration,offset:0,name:b});!o.current&&i.current.has(h.id)&&t(_=>_.map(x=>x.id===h.id?{...x,name:b,clips:[w]}:x))}catch(y){if(y instanceof DOMException&&y.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",y),!o.current&&i.current.has(h.id)&&(t(b=>b.filter(w=>w.id!==h.id)),a(b=>[...b,{name:uo(v),error:y instanceof Error?y:new Error(String(y))}]))}finally{l.current.delete(h.id),!o.current&&i.current.delete(h.id)&&r(y=>y-1)}})()}},[]),u=m.useCallback(f=>{t(d=>d.filter(h=>h.id!==f));const p=l.current.get(f);p&&(p.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 hf=m.createContext(null),pf=m.createContext(null),mf=m.createContext(null),gf=m.createContext(null),Q0=({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:f,onAnnotationUpdate:p,onAnnotationsChange:d,barWidth:h=1,barGap:v=0,progressBarWidth:g,onTracksChange:y,soundFontCache:b,deferEngineRebuild:w=!1,children:_})=>{const x=g??h+v,S=m.useMemo(()=>a,[a?.join(",")]),k=m.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const V=c.annotations[0];if(typeof V.start!="number"||typeof V.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 V.start),[]}return c.annotations},[c?.annotations]),E=m.useRef(k);E.current=k;const[I,M]=m.useState(null),[T,A]=m.useState(!1),[$,R]=m.useState(0),[F,O]=m.useState(0),[G,Q]=m.useState([]),[ee,ue]=m.useState([]),[te,oe]=m.useState([]),[se,le]=m.useState(o),[ye,de]=m.useState(c?.isContinuousPlay??!1),[ne,Z]=m.useState(c?.linkEndpoints??!1),[fe,Fe]=m.useState(c?.editable??!1),[ae,Te]=m.useState(!1),B=m.useRef(null),$e=m.useRef(!1),re=m.useRef(!1);re.current=T;const Ve=m.useRef(0),ve=m.useRef(0),Re=m.useRef(e),ct=m.useRef(b);ct.current=b;const xt=m.useRef(te),st=m.useRef(0),je=m.useRef(0),at=m.useRef(null),ut=m.useRef(null),Mt=m.useRef(!1),Ct=m.useRef(c?.isContinuousPlay??!1),j=m.useRef(null),pe=m.useRef(null),ze=m.useRef(0),Ze=m.useRef(!1),q=m.useRef(!1),me=m.useRef(s),He=m.useRef(44100),{timeFormat:St,setTimeFormat:N,formatTime:U}=tf(),H=nf({engineRef:B,initialSamplesPerPixel:s}),{samplesPerPixel:X,onEngineState:ke}=H,Me=rf({engineRef:B,initialVolume:1}),{masterVolume:Y,setMasterVolume:Be,masterVolumeRef:Xe,onEngineState:Ge}=Me,{selectionStart:kt,selectionEnd:Nt,setSelection:wn,selectionStartRef:Dt,selectionEndRef:jr,onEngineState:Mi}=E0({engineRef:B}),{isLoopEnabled:Ai,loopStart:Ti,loopEnd:$i,setLoopEnabled:Ri,setLoopRegion:zr,clearLoopRegion:Di,isLoopEnabledRef:Pi,loopStartRef:Fi,loopEndRef:Oi,onEngineState:Li}=I0({engineRef:B}),{selectedTrackId:Bi,setSelectedTrackId:Wi,onEngineState:Vi,selectedTrackIdRef:Ni}=M0({engineRef:B}),{animationFrameRef:ji,startAnimationFrameLoop:ta,stopAnimationFrameLoop:Zr}=ff(),jf=m.useMemo(()=>Math.min(...S??[256,512,1024,2048,4096,8192]),[S]),{cache:zi}=K0(e,jf),Zi=m.useCallback(V=>{Ct.current=V,de(V)},[]),Pt=m.useCallback(V=>{j.current=V,M(V)},[]),Hi=m.useCallback(()=>{const V=Dt.current??0,z=jr.current??0;V!==z&&z>V&&zr(V,z)},[zr,Dt,jr]);m.useEffect(()=>{Mt.current=se},[se]),m.useEffect(()=>{xt.current=te},[te]),Re.current=e;const na=e===pe.current;Ze.current=na||q.current,m.useEffect(()=>{if(!ut.current||F===0)return;const V=ut.current,z=me.current,he=X;if(z===he)return;const W=V.clientWidth,Ee=V.scrollLeft+W/2,Ce=He.current,oa=Ee*z/Ce*Ce/he,Xr=Math.max(0,oa-W/2);V.scrollLeft=Xr,me.current=he},[X,F]);const Hr=m.useRef(null);m.useEffect(()=>{if(na||q.current){na&&(pe.current=null);let W=0;e.forEach(_e=>{_e.clips.forEach(Ee=>{const Ce=(Ee.startSample+Ee.durationSamples)/Ee.sampleRate;W=Math.max(W,Ce)})}),O(W);return}if(w){let W=0;e.forEach(_e=>{_e.clips.forEach(Ee=>{const Ce=(Ee.startSample+Ee.durationSamples)/Ee.sampleRate;W=Math.max(W,Ce)})}),O(W);return}if(Te(!1),e.length===0){Q([]),O(0),oe([]),ue([]),B.current&&(B.current.dispose(),B.current=null);return}const V=re.current,z=ve.current;return B.current&&V&&(B.current.stop(),Zr(),Hr.current={position:z}),(async()=>{try{const W=[];e.forEach(Ie=>{Ie.clips.length>0&&Ie.clips[0].audioBuffer&&W.push(Ie.clips[0].audioBuffer)});let _e=0;e.forEach(Ie=>{Ie.clips.forEach(ft=>{const jt=ft.sampleRate,Yf=(ft.startSample+ft.durationSamples)/jt;_e=Math.max(_e,Yf)})}),Q(W),O(_e),oe(Ie=>Ie.length===e.length?Ie.map((ft,jt)=>({...ft,name:e[jt].name})):e.map(ft=>({name:ft.name,muted:ft.muted,soloed:ft.soloed,volume:ft.volume,pan:ft.pan}))),B.current&&B.current.dispose(),ze.current=0,pe.current=null,$e.current=!1;const Ee=vh({effects:u,soundFontCache:ct.current}),Ce=new Sh({adapter:Ee,samplesPerPixel:me.current,zoomLevels:S});Ce.setSelection(Dt.current??0,jr.current??0),Ce.setLoopRegion(Fi.current??0,Oi.current??0),Pi.current&&Ce.setLoopEnabled(!0),Ce.setMasterVolume(Xe.current??1),Ni.current&&Ce.selectTrack(Ni.current);const Ur=xt.current,oa=e.map((Ie,ft)=>{const jt=Ur[ft];return{...Ie,volume:jt?.volume??Ie.volume,muted:jt?.muted??Ie.muted,soloed:jt?.soloed??Ie.soloed,pan:jt?.pan??Ie.pan}});let Xr=!0;Ce.on("statechange",Ie=>{Mi(Ie),Li(Ie),Vi(Ie),ke(Ie),Ge(Ie),!Xr&&Ie.tracksVersion!==ze.current&&(ze.current=Ie.tracksVersion,pe.current=Ie.tracks,y?y(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."))}),Ce.setTracks(oa),Xr=!1,ze.current=Ce.getState().tracksVersion,B.current=Ce,Te(!0);const Xf=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:_e}});window.dispatchEvent(Xf),f?.()}catch(W){console.error("Error loading audio:",W)}})(),()=>{if(Ze.current){Ze.current=!1;return}Zr(),B.current&&B.current.dispose()}},[e,f,u,Zr,Mi,Li,Vi,ke,Ge,y,Xe,Dt,jr,Fi,Oi,Pi,S,b,w]),m.useEffect(()=>{if(e.length===0)return;const V=e.map(z=>z.clips.map(W=>{let _e;if(W.waveformData)try{_e=Ql(W.waveformData,X,n,W.offsetSamples,W.durationSamples)}catch(Ee){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",Ee)}if(!_e){const Ee=zi.get(W.id);if(Ee)try{_e=Ql(Ee,X,n,W.offsetSamples,W.durationSamples)}catch(Ce){console.warn("[waveform-playlist] Failed to extract peaks from cache:",Ce)}}if(!_e){!w&&!W.audioBuffer&&!W.waveformData&&!W.midiNotes&&console.warn(`[waveform-playlist] Clip "${W.id}" has no audio data or waveform data`);const Ee=n?1:W.audioBuffer?.numberOfChannels??1,Ce=W.midiNotes?Math.ceil(W.durationSamples/X):0;_e={length:Ce,data:Array.from({length:Ee},()=>new Int16Array(Ce*2)),bits:16}}return{clipId:W.id,trackName:z.name,peaks:_e,startSample:W.startSample,durationSamples:W.durationSamples,fadeIn:W.fadeIn,fadeOut:W.fadeOut,midiNotes:W.midiNotes,sampleRate:W.sampleRate,offsetSamples:W.offsetSamples}}));ue(V)},[e,X,n,zi,w]);const Gi=m.useRef(!1),_n=m.useCallback(()=>{if(B.current)return B.current.getCurrentTime();Gi.current||(Gi.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const V=L.getContext().currentTime-(st.current??0);return(je.current??0)+V},[]),Qt=m.useCallback(()=>{const V=()=>{const z=_n();ve.current=z;const he=E.current;if(he.length>0){const W=he.find(_e=>z>=_e.start&&z<_e.end);if(Ct.current)W&&W.id!==j.current?Pt(W.id):!W&&j.current!==null&&Pt(null);else if(j.current){const _e=he.find(Ee=>Ee.id===j.current);if(_e&&z>=_e.end){B.current&&B.current.stop(),A(!1),ve.current=Ve.current,R(Ve.current);return}}else W&&Pt(W.id)}if(Mt.current&&ut.current&&F>0){const W=ut.current,_e=He.current,Ee=z*_e/me.current,Ce=W.clientWidth,Ur=Math.max(0,Ee-Ce/2);W.scrollLeft=Ur}if(at.current!==null&&z>=at.current){B.current&&B.current.stop(),A(!1),ve.current=at.current,R(at.current),at.current=null;return}if(z>=F){B.current&&B.current.stop(),A(!1),ve.current=Ve.current,R(Ve.current),Pt(null);return}ta(V)};ta(V)},[F,Pt,ta,_n]),dt=Zr;m.useEffect(()=>{(async()=>{if(T&&ji.current&&B.current)if(ye){const z=ve.current;B.current.stop(),dt();const W=L.getContext().currentTime;st.current=W,je.current=z,B.current.play(z),Qt()}else dt(),Qt()})().catch(z=>{console.warn("[waveform-playlist] Failed to reschedule playback:",z),A(!1),dt()})},[ye,T,Qt,dt,ji]),m.useEffect(()=>{(async()=>{if(Hr.current&&B.current){const{position:z}=Hr.current;Hr.current=null;const W=L.getContext().currentTime;st.current=W,je.current=z,$e.current||(await B.current.init(),$e.current=!0),B.current.play(z),A(!0),Qt()}})().catch(z=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",z),A(!1),dt()})},[e,Qt,dt]);const Gr=m.useCallback(async(V,z)=>{if(!B.current||F===0)return;const he=V??ve.current;Ve.current=he,ve.current=he,B.current.stop(),B.current.seek(he),dt();const _e=L.getContext().currentTime;st.current=_e,je.current=he,at.current=z!==void 0?he+z:null,$e.current||(await B.current.init(),$e.current=!0);const Ee=z!==void 0?he+z:void 0;try{B.current.play(he,Ee)}catch(Ce){console.warn("[waveform-playlist] Playback failed to start:",Ce),dt();return}A(!0),Qt()},[F,Qt,dt]),Ui=m.useCallback(()=>{if(!B.current)return;const V=_n();B.current.pause(),A(!1),dt(),ve.current=V,R(V)},[dt,_n]),Xi=m.useCallback(()=>{B.current&&(B.current.stop(),A(!1),dt(),ve.current=Ve.current,R(Ve.current),Pt(null))},[dt,Pt]),Yi=m.useCallback(V=>{const z=Math.max(0,Math.min(V,F));ve.current=z,R(z),T&&B.current&&Gr(z)},[F,T,Gr]),Ki=m.useCallback((V,z)=>{const he=Re.current[V]?.id;if(!he)return;const W=[...te];W[V]={...W[V],muted:z},oe(W),B.current&&B.current.setTrackMute(he,z)},[te]),qi=m.useCallback((V,z)=>{const he=Re.current[V]?.id;if(!he)return;const W=[...te];W[V]={...W[V],soloed:z},oe(W),B.current&&B.current.setTrackSolo(he,z)},[te]),Ji=m.useCallback((V,z)=>{const he=Re.current[V]?.id;if(!he)return;const W=[...te];W[V]={...W[V],volume:z},oe(W),B.current&&B.current.setTrackVolume(he,z)},[te]),Qi=m.useCallback((V,z)=>{const he=Re.current[V]?.id;if(!he)return;const W=[...te];W[V]={...W[V],pan:z},oe(W),B.current&&B.current.setTrackPan(he,z)},[te]),el=m.useCallback((V,z)=>{wn(V,z),ve.current=V,R(V),T&&B.current&&(B.current.stop(),B.current.seek(V),B.current.play(V))},[T,wn]),tl=m.useCallback(V=>{ut.current=V},[]),ra=m.useRef(d);ra.current=d;const nl=m.useCallback(V=>{const z=typeof V=="function"?V(E.current):V;if(!ra.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}ra.current(z)},[]),sa=G[0]?.sampleRate||e[0]?.clips[0]?.sampleRate||44100;He.current=sa;const aa=t?30:0,rl=e.length*r+aa,zf=m.useMemo(()=>({isPlaying:T,currentTime:$,currentTimeRef:ve,playbackStartTimeRef:st,audioStartPositionRef:je,getPlaybackTime:_n}),[T,$,ve,st,je,_n]),Zf=m.useMemo(()=>({continuousPlay:ye,linkEndpoints:ne,annotationsEditable:fe,isAutomaticScroll:se,isLoopEnabled:Ai,annotations:k,activeAnnotationId:I,selectionStart:kt,selectionEnd:Nt,selectedTrackId:Bi,loopStart:Ti,loopEnd:$i}),[ye,ne,fe,se,Ai,k,I,kt,Nt,Bi,Ti,$i]),sl=m.useCallback(V=>{ve.current=V,R(V)},[ve]),al=m.useCallback(V=>{le(V)},[]),Hf=m.useMemo(()=>({play:Gr,pause:Ui,stop:Xi,seekTo:Yi,setCurrentTime:sl,setTrackMute:Ki,setTrackSolo:qi,setTrackVolume:Ji,setTrackPan:Qi,setSelection:el,setSelectedTrackId:Wi,setTimeFormat:N,formatTime:U,zoomIn:H.zoomIn,zoomOut:H.zoomOut,setMasterVolume:Be,setAutomaticScroll:al,setScrollContainer:tl,scrollContainerRef:ut,setContinuousPlay:Zi,setLinkEndpoints:Z,setAnnotationsEditable:Fe,setAnnotations:nl,setActiveAnnotationId:Pt,setLoopEnabled:Ri,setLoopRegion:zr,setLoopRegionFromSelection:Hi,clearLoopRegion:Di}),[Gr,Ui,Xi,Yi,sl,Ki,qi,Ji,Qi,el,Wi,N,U,H.zoomIn,H.zoomOut,Be,al,tl,ut,Zi,Z,Fe,nl,Pt,Ri,zr,Hi,Di]),Gf=m.useMemo(()=>({duration:F,audioBuffers:G,peaksDataArray:ee,trackStates:te,tracks:e,sampleRate:sa,waveHeight:r,timeScaleHeight:aa,minimumPlaylistHeight:rl,controls:l,playoutRef:B,samplesPerPixel:X,timeFormat:St,masterVolume:Y,canZoomIn:H.canZoomIn,canZoomOut:H.canZoomOut,barWidth:h,barGap:v,progressBarWidth:x,isReady:ae,mono:n,isDraggingRef:q,onTracksChange:y}),[F,G,ee,te,e,sa,r,aa,rl,l,B,X,St,Y,H.canZoomIn,H.canZoomOut,h,v,x,ae,n,q,y]),Uf={...Wd,...i};return C.jsx(P.ThemeProvider,{theme:Uf,children:C.jsx(hf.Provider,{value:zf,children:C.jsx(pf.Provider,{value:Zf,children:C.jsx(mf.Provider,{value:Hf,children:C.jsx(gf.Provider,{value:Gf,children:_})})})})})},tt=()=>{const e=m.useContext(hf);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},nt=()=>{const e=m.useContext(pf);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},Se=()=>{const e=m.useContext(mf);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},rt=()=>{const e=m.useContext(gf);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var ey=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}},ty=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 ey({...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 vf=m.createContext(null),yf=m.createContext(null),bf=m.createContext(null),wf=m.createContext(null),ny=({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:f,onAnnotationsChange:p,onReady:d,children:h})=>{const v=f??c+u,[g,y]=m.useState(!1),[b,w]=m.useState(0),[_,x]=m.useState(0),[S,k]=m.useState([]),[E,I]=m.useState(s),M=m.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const j=l.annotations[0];if(typeof j.start!="number"||typeof j.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 j.start),[]}return l.annotations},[l?.annotations]),T=m.useRef(M);T.current=M;const[A,$]=m.useState(null),[R,F]=m.useState(l?.isContinuousPlay??!1),[O]=m.useState(t),[G,Q]=m.useState(a),ee=m.useRef(null),ue=m.useRef(0),te=m.useRef(R),oe=m.useRef(null),se=m.useRef(null),le=m.useRef(a),ye=m.useRef(t),{startAnimationFrameLoop:de,stopAnimationFrameLoop:ne}=ff();m.useEffect(()=>{te.current=R},[R]),m.useEffect(()=>{le.current=G},[G]);const Z=m.useCallback(j=>{oe.current=j,$(j)},[]),fe=m.useCallback(j=>{te.current=j,F(j)},[]),Fe=m.useCallback(j=>{se.current=j},[]),ae=e.waveformData.sample_rate;m.useEffect(()=>{const j=new ty({playbackRate:s});j.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const pe=j.getTrack(j.track?.id??"");return pe&&pe.setOnTimeUpdateCallback(ze=>{ue.current=ze}),j.setOnPlaybackComplete(()=>{ne(),y(!1),Z(null),ue.current=0,w(0)}),ee.current=j,x(e.waveformData.duration),d?.(),()=>{ne(),j.dispose()}},[e.source,e.waveformData,e.name,s,d,ne,Z]),m.useEffect(()=>{try{const j=k0(e.waveformData,O,0,0,Math.ceil(e.waveformData.duration*ae)),pe={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:j.length,data:[j.data],bits:j.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*ae)};k([[pe]])}catch(j){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",j)}},[e.waveformData,e.name,O,ae]);const Te=m.useCallback(()=>{const j=()=>{const pe=ee.current?.getCurrentTime()??0;ue.current=pe;const ze=T.current;if(ze.length>0){const Ze=ze.find(q=>pe>=q.start&&pe<q.end);if(te.current)Ze&&Ze.id!==oe.current?Z(Ze.id):!Ze&&oe.current!==null&&Z(null);else if(oe.current){const q=ze.find(me=>me.id===oe.current);if(q&&pe>=q.end){ee.current?.stop(),y(!1);return}}else Ze&&Z(Ze.id)}if(le.current&&se.current){const Ze=se.current,q=pe*ae/ye.current,me=Ze.clientWidth,He=Math.max(0,q-me/2);Ze.scrollLeft=He}de(j)};de(j)},[Z,ae,de]),B=ne,$e=m.useCallback(j=>{if(!ee.current)return;const pe=j??ue.current;ee.current.play(void 0,pe),y(!0),Te()},[Te]),re=m.useCallback(()=>{ee.current&&(ee.current.pause(),y(!1),B(),w(ee.current.getCurrentTime()))},[B]),Ve=m.useCallback(()=>{ee.current&&(ee.current.stop(),y(!1),B(),ue.current=0,w(0),Z(null))},[B,Z]),ve=m.useCallback(j=>{const pe=Math.max(0,Math.min(j,_));ue.current=pe,w(pe),ee.current&&ee.current.seekTo(pe)},[_]),Re=m.useCallback(j=>{const pe=Math.max(.5,Math.min(2,j));I(pe),ee.current&&ee.current.setPlaybackRate(pe)},[]),ct=r?30:0,xt=m.useMemo(()=>({isPlaying:g,currentTime:b,currentTimeRef:ue}),[g,b]),st=m.useMemo(()=>({continuousPlay:R,annotations:M,activeAnnotationId:A,playbackRate:E,isAutomaticScroll:G}),[R,M,A,E,G]),je=m.useRef(p);je.current=p;const at=m.useCallback(j=>{const pe=typeof j=="function"?j(T.current):j;if(!je.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}je.current(pe)},[]),ut=m.useMemo(()=>({play:$e,pause:re,stop:Ve,seekTo:ve,setPlaybackRate:Re,setContinuousPlay:fe,setAnnotations:at,setActiveAnnotationId:Z,setAutomaticScroll:j=>{Q(j)},setScrollContainer:Fe,scrollContainerRef:se}),[$e,re,Ve,ve,Re,fe,at,Z,Fe]),Mt=m.useMemo(()=>({duration:_,peaksDataArray:S,sampleRate:ae,waveHeight:n,timeScaleHeight:ct,samplesPerPixel:O,playoutRef:ee,controls:i,barWidth:c,barGap:u,progressBarWidth:v}),[_,S,ae,n,ct,O,i,c,u,v]),Ct={...Wd,...o};return C.jsx(P.ThemeProvider,{theme:Ct,children:C.jsx(vf.Provider,{value:xt,children:C.jsx(yf.Provider,{value:st,children:C.jsx(bf.Provider,{value:ut,children:C.jsx(wf.Provider,{value:Mt,children:h})})})})})},Vr=()=>{const e=m.useContext(vf);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},qs=()=>{const e=m.useContext(yf);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},Si=()=>{const e=m.useContext(bf);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},Js=()=>{const e=m.useContext(wf);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},ry=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=tt(),{selectionStart:r,selectionEnd:s,isLoopEnabled:a}=nt(),{play:o}=Se(),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(gt,{onClick:i,disabled:t,className:e,children:"Play"})},sy=({className:e})=>{const{isPlaying:t}=tt(),{pause:n}=Se();return C.jsx(gt,{onClick:n,disabled:!t,className:e,children:"Pause"})},ay=({className:e})=>{const{isPlaying:t}=tt(),{stop:n}=Se();return C.jsx(gt,{onClick:n,disabled:!t,className:e,children:"Stop"})},oy=({className:e})=>{const{isPlaying:t}=tt(),{play:n,setCurrentTime:r}=Se(),s=()=>{r(0),t&&n(0)};return C.jsx(gt,{onClick:s,className:e,children:"Rewind"})},iy=({className:e})=>{const{isPlaying:t}=tt(),{play:n,setCurrentTime:r}=Se(),{duration:s}=rt(),a=()=>{r(s),t&&n(s)};return C.jsx(gt,{onClick:a,className:e,children:"Fast Forward"})},ly=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=tt(),{play:s,setCurrentTime:a}=Se(),o=()=>{const i=Math.max(0,(n.current??0)-e);a(i),r&&s(i)};return C.jsx(gt,{onClick:o,className:t,children:"Skip Backward"})},cy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=tt(),{play:s,setCurrentTime:a}=Se(),{duration:o}=rt(),i=()=>{const l=Math.min(o,(n.current??0)+e);a(l),r&&s(l)};return C.jsx(gt,{onClick:i,className:t,children:"Skip Forward"})},uy=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=nt(),{setLoopEnabled:s,setLoopRegion:a}=Se(),{duration:o}=rt(),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(gt,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},dy=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=nt(),{setLoopRegionFromSelection:a,clearLoopRegion:o}=Se(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?o():a()};return C.jsx(gt,{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"})},fy=({onClearAll:e,label:t="Clear All",className:n})=>{const{stop:r}=Se(),s=m.useCallback(()=>{r(),e()},[r,e]);return C.jsx(gt,{onClick:s,className:n,title:"Remove all tracks",children:t})},hy=({className:e,disabled:t})=>{const{zoomIn:n}=Se(),{canZoomIn:r}=rt();return C.jsx(gt,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},py=({className:e,disabled:t})=>{const{zoomOut:n}=Se(),{canZoomOut:r}=rt();return C.jsx(gt,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},my=({className:e})=>{const{masterVolume:t}=rt(),{setMasterVolume:n}=Se();return C.jsx(lv,{volume:t,onChange:n,className:e})},gy=({className:e})=>{const{timeFormat:t}=rt(),{setTimeFormat:n}=Se();return C.jsx(Hv,{value:t,onChange:n,className:e})},vy=P.span`
1005
1005
  font-family: 'Courier New', Monaco, monospace;
1006
1006
  font-size: 1rem;
1007
1007
  font-weight: 600;
1008
1008
  color: ${e=>e.theme?.textColor||"#333"};
1009
1009
  user-select: none;
1010
- `,_y=({className:e})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=ot(),{timeFormat:o}=lt();return p.useEffect(()=>{const i=()=>{if(t.current){const l=r?a():s.current??0;t.current.textContent=Pn(l,o)}r&&(n.current=requestAnimationFrame(i))};return r?n.current=requestAnimationFrame(i):i(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,o,s,a]),p.useEffect(()=>{!r&&t.current&&(t.current.textContent=Pn(s.current??0,o))}),C.jsx(wy,{ref:t,className:e,"aria-label":"Audio position",children:Pn(s.current??0,o)})},xy=({className:e})=>{const{selectionStart:t,selectionEnd:n}=it(),{setSelection:r}=Ie();return C.jsx(kv,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},Cy=({className:e})=>{const{isAutomaticScroll:t}=it(),{setAutomaticScroll:n}=Ie();return C.jsx(Og,{checked:t,onChange:n,className:e})},na=p.createContext(null),Sy=na.Provider;function _n(){const e=p.useContext(na);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 ky=({className:e})=>{const{ContinuousPlayCheckbox:t}=_n(),{continuousPlay:n}=it(),{setContinuousPlay:r}=Ie();return C.jsx(t,{checked:n,onChange:r,className:e})},Ey=({className:e})=>{const{LinkEndpointsCheckbox:t}=_n(),{linkEndpoints:n}=it(),{setLinkEndpoints:r}=Ie();return C.jsx(t,{checked:n,onChange:r,className:e})},Iy=({className:e})=>{const{EditableCheckbox:t}=_n(),{annotationsEditable:n}=it(),{setAnnotationsEditable:r}=Ie();return C.jsx(t,{checked:n,onChange:r,className:e})},My=({filename:e,className:t})=>{const{DownloadAnnotationsButton:n}=_n(),{annotations:r}=it();return C.jsx(n,{annotations:r,filename:e,className:t})},Ay=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:r,bitDepth:s=16,applyEffects:a=!0,effectsFunction:o,createOfflineTrackEffects:i,className:l,onExportComplete:c,onExportError:u})=>{const{tracks:f,trackStates:m}=lt(),{exportWav:d,isExporting:h,progress:v}=df(),g=async()=>{try{const b=await d(f,m,{filename:t,mode:n,trackIndex:r,bitDepth:s,applyEffects:a,effectsFunction:o,createOfflineTrackEffects:i,autoDownload:!0});c?.(b.blob)}catch(b){u?.(b instanceof Error?b:new Error("Export failed"))}},y=h?`Exporting ${Math.round(v*100)}%`:e;return C.jsx(vt,{onClick:g,disabled:h||f.length===0,className:l,children:y})},_f=p.createContext(!1),Ty=_f.Provider;function xf(){return p.useContext(_f)}const $y=F.div.attrs(e=>({style:{width:`${e.$width}px`,background:e.$color}}))`
1010
+ `,yy=({className:e})=>{const t=m.useRef(null),n=m.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=tt(),{timeFormat:o}=rt();return m.useEffect(()=>{const i=()=>{if(t.current){const l=r?a():s.current??0;t.current.textContent=Dn(l,o)}r&&(n.current=requestAnimationFrame(i))};return r?n.current=requestAnimationFrame(i):i(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,o,s,a]),m.useEffect(()=>{!r&&t.current&&(t.current.textContent=Dn(s.current??0,o))}),C.jsx(vy,{ref:t,className:e,"aria-label":"Audio position",children:Dn(s.current??0,o)})},by=({className:e})=>{const{selectionStart:t,selectionEnd:n}=nt(),{setSelection:r}=Se();return C.jsx(kv,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},wy=({className:e})=>{const{isAutomaticScroll:t}=nt(),{setAutomaticScroll:n}=Se();return C.jsx(Og,{checked:t,onChange:n,className:e})},Qs=m.createContext(null),_y=Qs.Provider;function bn(){const e=m.useContext(Qs);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 xy=({className:e})=>{const{ContinuousPlayCheckbox:t}=bn(),{continuousPlay:n}=nt(),{setContinuousPlay:r}=Se();return C.jsx(t,{checked:n,onChange:r,className:e})},Cy=({className:e})=>{const{LinkEndpointsCheckbox:t}=bn(),{linkEndpoints:n}=nt(),{setLinkEndpoints:r}=Se();return C.jsx(t,{checked:n,onChange:r,className:e})},Sy=({className:e})=>{const{EditableCheckbox:t}=bn(),{annotationsEditable:n}=nt(),{setAnnotationsEditable:r}=Se();return C.jsx(t,{checked:n,onChange:r,className:e})},ky=({filename:e,className:t})=>{const{DownloadAnnotationsButton:n}=bn(),{annotations:r}=nt();return C.jsx(n,{annotations:r,filename:e,className:t})},Ey=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:r,bitDepth:s=16,applyEffects:a=!0,effectsFunction:o,createOfflineTrackEffects:i,className:l,onExportComplete:c,onExportError:u})=>{const{tracks:f,trackStates:p}=rt(),{exportWav:d,isExporting:h,progress:v}=df(),g=async()=>{try{const b=await d(f,p,{filename:t,mode:n,trackIndex:r,bitDepth:s,applyEffects:a,effectsFunction:o,createOfflineTrackEffects:i,autoDownload:!0});c?.(b.blob)}catch(b){u?.(b instanceof Error?b:new Error("Export failed"))}},y=h?`Exporting ${Math.round(v*100)}%`:e;return C.jsx(gt,{onClick:g,disabled:h||f.length===0,className:l,children:y})},_f=m.createContext(!1),Iy=_f.Provider;function xf(){return m.useContext(_f)}const My=P.div.attrs(e=>({style:{width:`${e.$width}px`,background:e.$color}}))`
1011
1011
  position: absolute;
1012
1012
  top: 0;
1013
1013
  left: 0;
@@ -1015,16 +1015,16 @@ self.onmessage = function(e) {
1015
1015
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
1016
1016
  pointer-events: none;
1017
1017
  will-change: transform;
1018
- `,Ry=({color:e="#ff0000"})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=ot(),{samplesPerPixel:o,sampleRate:i,progressBarWidth:l}=lt();return p.useEffect(()=>{const c=()=>{if(t.current){const f=(r?a():s.current??0)*i/o;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,o,s,a]),p.useEffect(()=>{if(!r&&t.current){const u=(s.current??0)*i/o;t.current.style.transform=`translate3d(${u}px, 0, 0)`}}),C.jsx($y,{ref:t,$color:e,$width:l,"data-playhead":!0})},Dy=F.div`
1018
+ `,Ay=({color:e="#ff0000"})=>{const t=m.useRef(null),n=m.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=tt(),{samplesPerPixel:o,sampleRate:i,progressBarWidth:l}=rt();return m.useEffect(()=>{const c=()=>{if(t.current){const f=(r?a():s.current??0)*i/o;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,o,s,a]),m.useEffect(()=>{if(!r&&t.current){const u=(s.current??0)*i/o;t.current.style.transform=`translate3d(${u}px, 0, 0)`}}),C.jsx(My,{ref:t,$color:e,$width:l,"data-playhead":!0})},Ty=P.div`
1019
1019
  position: relative;
1020
- `,Sa=F.div.attrs(e=>({style:{top:`${e.$top}px`,width:`${e.$width}px`,height:`${e.$height}px`,background:e.$color}}))`
1020
+ `,_a=P.div.attrs(e=>({style:{top:`${e.$top}px`,width:`${e.$width}px`,height:`${e.$height}px`,background:e.$color}}))`
1021
1021
  position: absolute;
1022
1022
  left: 0;
1023
1023
  z-index: 0;
1024
1024
  /* Force GPU compositing layer to prevent gradient flickering during scroll */
1025
1025
  transform: translateZ(0);
1026
1026
  backface-visibility: hidden;
1027
- `,Py=F.div.attrs(e=>({style:{top:`${e.$top}px`,height:`${e.$height}px`,width:`${e.$width}px`,background:e.$color,transform:"scaleX(0)"}}))`
1027
+ `,$y=P.div.attrs(e=>({style:{top:`${e.$top}px`,height:`${e.$height}px`,width:`${e.$width}px`,background:e.$color,transform:"scaleX(0)"}}))`
1028
1028
  position: absolute;
1029
1029
  left: 0;
1030
1030
  pointer-events: none;
@@ -1032,16 +1032,16 @@ self.onmessage = function(e) {
1032
1032
  transform-origin: left;
1033
1033
  /* scaleX changes are composite-only (GPU) — no layout reflow per frame */
1034
1034
  will-change: transform;
1035
- `,Fy=F.div`
1035
+ `,Ry=P.div`
1036
1036
  position: relative;
1037
1037
  z-index: 2;
1038
- `,nc=({clipStartSample:e,clipDurationSamples:t,midiNotes:n,clipSampleRate:r,clipOffsetSeconds:s,...a})=>{const o=p.useRef(null),i=p.useRef(null),l=Vr(),{waveHeight:c}=Js(),{isPlaying:u,currentTimeRef:f,getPlaybackTime:m}=ot(),{samplesPerPixel:d,sampleRate:h}=lt(),v=l?.waveProgressColor||"rgba(0, 0, 0, 0.1)",g=hc(e,t,d);p.useEffect(()=>{const $=()=>{if(o.current){const I=(u?m():f.current??0)*h,R=e+t;let D=0;I<=e?D=0:I>=R?D=1:D=(I-e)/t,o.current.style.transform=`scaleX(${D})`}u&&(i.current=requestAnimationFrame($))};return u?i.current=requestAnimationFrame($):$(),()=>{i.current&&(cancelAnimationFrame(i.current),i.current=null)}},[u,h,e,t,g,f,m]),p.useEffect(()=>{if(!u&&o.current){const A=(f.current??0)*h,I=e+t;let R=0;A<=e?R=0:A>=I?R=1:R=(A-e)/t,o.current.style.transform=`scaleX(${R})`}});const y=l?.waveformDrawMode||"inverted";let b;y==="inverted"?b=a.isSelected&&l?l.selectedWaveFillColor:l?.waveFillColor||"white":b=a.isSelected&&l?l.selectedWaveOutlineColor:l?.waveOutlineColor||"grey";const _=a.renderMode==="spectrogram"||a.renderMode==="both",w=a.renderMode==="piano-roll",x=a.renderMode==="both",S=_?"#000":w?l?.pianoRollBackgroundColor||"#1a1a2e":qt(b),k=Math.floor(c/2),E=c,M=a.index*c,T=qt(b);return C.jsxs(Dy,{children:[x?C.jsxs(C.Fragment,{children:[C.jsx(Sa,{$color:"#000",$height:k,$top:M,$width:a.length}),C.jsx(Sa,{$color:T,$height:k,$top:M+k,$width:a.length})]}):C.jsx(Sa,{$color:S,$height:E,$top:M,$width:a.length}),!w&&C.jsx(Py,{ref:o,$color:v,$height:E,$top:M,$width:g}),C.jsx(Fy,{children:C.jsx(Yd,{...a,transparentBackground:!0,midiNotes:n,sampleRate:r,clipOffsetSeconds:s})})]})},Mi=p.createContext(null),Oy=Mi.Provider;function Ly(){const e=p.useContext(Mi);if(!e)throw new Error("useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>.");return e}const By=60,Wy=F.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
1038
+ `,nc=({clipStartSample:e,clipDurationSamples:t,midiNotes:n,clipSampleRate:r,clipOffsetSeconds:s,...a})=>{const o=m.useRef(null),i=m.useRef(null),l=Br(),{waveHeight:c}=Ys(),{isPlaying:u,currentTimeRef:f,getPlaybackTime:p}=tt(),{samplesPerPixel:d,sampleRate:h}=rt(),v=l?.waveProgressColor||"rgba(0, 0, 0, 0.1)",g=hc(e,t,d);m.useEffect(()=>{const T=()=>{if(o.current){const $=(u?p():f.current??0)*h,R=e+t;let F=0;$<=e?F=0:$>=R?F=1:F=($-e)/t,o.current.style.transform=`scaleX(${F})`}u&&(i.current=requestAnimationFrame(T))};return u?i.current=requestAnimationFrame(T):T(),()=>{i.current&&(cancelAnimationFrame(i.current),i.current=null)}},[u,h,e,t,g,f,p]),m.useEffect(()=>{if(!u&&o.current){const A=(f.current??0)*h,$=e+t;let R=0;A<=e?R=0:A>=$?R=1:R=(A-e)/t,o.current.style.transform=`scaleX(${R})`}});const y=l?.waveformDrawMode||"inverted";let b;y==="inverted"?b=a.isSelected&&l?l.selectedWaveFillColor:l?.waveFillColor||"white":b=a.isSelected&&l?l.selectedWaveOutlineColor:l?.waveOutlineColor||"grey";const w=a.renderMode==="spectrogram"||a.renderMode==="both",_=a.renderMode==="piano-roll",x=a.renderMode==="both",S=w?"#000":_?l?.pianoRollBackgroundColor||"#1a1a2e":Kt(b),k=Math.floor(c/2),E=c,I=a.index*c,M=Kt(b);return C.jsxs(Ty,{children:[x?C.jsxs(C.Fragment,{children:[C.jsx(_a,{$color:"#000",$height:k,$top:I,$width:a.length}),C.jsx(_a,{$color:M,$height:k,$top:I+k,$width:a.length})]}):C.jsx(_a,{$color:S,$height:E,$top:I,$width:a.length}),!_&&C.jsx($y,{ref:o,$color:v,$height:E,$top:I,$width:g}),C.jsx(Ry,{children:C.jsx(Yd,{...a,transparentBackground:!0,midiNotes:n,sampleRate:r,clipOffsetSeconds:s})})]})},ki=m.createContext(null),Dy=ki.Provider;function Py(){const e=m.useContext(ki);if(!e)throw new Error("useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>.");return e}const Fy=60,Oy=P.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
1039
1039
  overflow: hidden;
1040
1040
  pointer-events: auto;
1041
1041
  background: ${e=>e.theme.surfaceColor};
1042
1042
  transition: background 0.15s ease-in-out;
1043
1043
  ${e=>e.$isSelected&&`background: ${e.theme.selectedTrackControlsBackground};`}
1044
- `,Vy=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:a,playbackStartTimeRef:o,audioStartPositionRef:i,getPlaybackTime:l}=ot();return e({position:(a.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:a,playbackStartTimeRef:o,audioStartPositionRef:i,samplesPerPixel:n,sampleRate:r,controlsOffset:0,getAudioContextTime:()=>L.getContext().currentTime,getPlaybackTime:l})};function ka(e,t,n,r){const s=e.length>0?Math.max(1,...e.map(o=>o.peaks.data.length)):1,a=t?.isRecording&&t.trackId===n?r?1:t.peaks.length:0;return Math.max(s,a)}const Cf=({renderTrackControls:e,renderTick:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:s,className:a,showClipHeaders:o=!1,interactiveClips:i=!1,showFades:l=!1,touchOptimized:c=!1,onRemoveTrack:u,recordingState:f})=>{const m=Vr(),{isPlaying:d}=ot(),{selectionStart:h,selectionEnd:v,annotations:g,activeAnnotationId:y,annotationsEditable:b,linkEndpoints:_,continuousPlay:w,selectedTrackId:x,loopStart:S,loopEnd:k,isLoopEnabled:E}=it(),M=p.useContext(na),{setAnnotations:T,setActiveAnnotationId:$,setTrackMute:A,setTrackSolo:I,setTrackVolume:R,setTrackPan:D,setSelection:O,play:Z,setScrollContainer:G,setSelectedTrackId:Y,setCurrentTime:te,setLoopRegion:X}=Ie(),{peaksDataArray:K,trackStates:le,tracks:J,duration:de,samplesPerPixel:ue,sampleRate:ne,waveHeight:z,timeScaleHeight:ae,controls:ke,barWidth:ce,barGap:xe,isReady:B,mono:_e}=lt(),re=p.useContext(Mi),Me=p.useMemo(()=>{if(!re)return new Map;const N=new Map;return J.forEach(q=>{if((re.trackSpectrogramOverrides.get(q.id)?.renderMode??q.renderMode??"waveform")==="waveform")return;const Q=re.trackSpectrogramOverrides.get(q.id),Te=Q?.colorMap??q.spectrogramColorMap??re.spectrogramColorMap??"viridis",De=Q?.config??q.spectrogramConfig??re.spectrogramConfig;N.set(q.id,{colorLUT:re.getColorMap(Te),frequencyScaleFn:re.getFrequencyScale(De?.frequencyScale??"mel"),config:De})}),N},[J,re]),pe=p.useMemo(()=>{if(re?.spectrogramWorkerApi)return{registerCanvas:re.spectrogramWorkerApi.registerCanvas.bind(re.spectrogramWorkerApi),unregisterCanvas:re.spectrogramWorkerApi.unregisterCanvas.bind(re.spectrogramWorkerApi)}},[re?.spectrogramWorkerApi]),[Ae,He]=p.useState(null),[qe,Ve]=p.useState(!1),Le=p.useRef(0),je=p.useRef(null),tt=p.useCallback(N=>{je.current=N,G(N)},[G]),Ct=J.reduce((N,q)=>q.clips.reduce((U,Q)=>{const Te=(Q.startSample+Q.durationSamples)/Q.sampleRate;return Math.max(U,Te)},N),0);let St=Ct>0?Ct:de>0?de:By;if(f?.isRecording){const q=(f.startSample+f.durationSamples)/ne;St=Math.max(St,q+10)}const j=Math.floor(St*ne/ue),ge=async N=>{$(N.id);const q=w?void 0:N.end-N.start;try{await Z(N.start,q)}catch(U){console.error("waveform-playlist: Failed to start playback for annotation",N.id,U)}},Ge=p.useCallback(N=>{if(N>=0&&N<J.length){const q=J[N];Y(q.id)}},[J,Y]),Ue=N=>{const q=N.currentTarget.getBoundingClientRect(),Q=(N.clientX-q.left)*ue/ne,De=N.clientY-q.top;let ee=0,Ne=-1;for(let Je=0;Je<K.length;Je++){const Ye=K[Je],Et=ka(Ye,f,J[Je]?.id,_e),Pt=((re?.trackSpectrogramOverrides.get(J[Je]?.id)?.renderMode??J[Je]?.renderMode??"waveform")==="both"?Et*2:Et)*z+(o?22:0);if(De>=ee&&De<ee+Pt){Ne=Je;break}ee+=Pt}Ne!==-1&&Ge(Ne),Le.current=Q,Ve(!0),te(Q),O(Q,Q)},oe=N=>{if(!qe||d)return;const q=N.currentTarget.getBoundingClientRect(),Q=(N.clientX-q.left)*ue/ne,Te=Math.min(h,Q),De=Math.max(h,Q);O(Te,De)},ve=N=>{if(!qe)return;if(Ve(!1),d){const ee=Math.max(0,Le.current);te(ee),O(ee,ee),Z(ee);return}const q=N.currentTarget.getBoundingClientRect(),Q=(N.clientX-q.left)*ue/ne,Te=Math.min(h,Q),De=Math.max(h,Q);Math.abs(De-Te)<.1?te(Te):O(Te,De)};if(J.some(N=>N.clips.length>0)&&K.length===0)return C.jsx("div",{className:a,children:"Loading waveform..."});const kt=ke.show?K.map((N,q)=>{const U=J[q];if(!U)return null;const Q=le[q]||{name:`Track ${q+1}`,muted:!1,soloed:!1,volume:1,pan:0},Te=U.clips.some(Ye=>Ye.midiNotes&&Ye.midiNotes.length>0),De=re?.trackSpectrogramOverrides.get(U.id)?.renderMode??U.renderMode??(Te?"piano-roll":"waveform"),ee=ka(N,f,U.id,_e),Ne=z*ee+(o?xi:0),Je=e?e(q):C.jsxs(e0,{onClick:()=>Ge(q),children:[C.jsxs(t0,{style:{justifyContent:"center",position:"relative"},children:[u&&C.jsx(Qv,{onClick:Ye=>{Ye.stopPropagation(),u(q)}}),C.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:Q.name||`Track ${q+1}`}),re?.renderMenuItems&&C.jsx("span",{style:{position:"absolute",right:0,top:0},children:C.jsx(c0,{items:Ye=>re.renderMenuItems({renderMode:De,onRenderModeChange:Et=>re.setTrackRenderMode(U.id,Et),onOpenSettings:()=>He(U.id),onClose:Ye})})})]}),C.jsxs(qv,{children:[C.jsx(Kl,{$variant:Q.muted?"danger":"outline",onClick:()=>A(q,!Q.muted),children:"Mute"}),C.jsx(Kl,{$variant:Q.soloed?"info":"outline",onClick:()=>I(q,!Q.soloed),children:"Solo"})]}),C.jsxs(Jl,{children:[C.jsx(n0,{}),C.jsx(ql,{min:"0",max:"1",step:"0.01",value:Q.volume,onChange:Ye=>R(q,parseFloat(Ye.target.value))}),C.jsx(r0,{})]}),C.jsxs(Jl,{children:[C.jsx("span",{children:"L"}),C.jsx(ql,{min:"-1",max:"1",step:"0.01",value:Q.pan,onChange:Ye=>D(q,parseFloat(Ye.target.value))}),C.jsx("span",{children:"R"})]})]});return C.jsx(Wy,{$height:Ne,$isSelected:U.id===x,children:Je},U.id)}):void 0;return C.jsxs(Xd,{children:[C.jsx(Wr.Provider,{value:{samplesPerPixel:ue,sampleRate:ne,zoomLevels:[ue],waveHeight:z,timeScaleHeight:ae,duration:St*1e3,controls:ke,barWidth:ce,barGap:xe},children:C.jsx(Ci,{theme:m,backgroundColor:m.playlistBackgroundColor||qt(m.waveOutlineColor),timescaleBackgroundColor:m.timescaleBackgroundColor,timescaleWidth:j,tracksWidth:j,controlsWidth:ke.show?ke.width:0,onTracksMouseDown:Ue,onTracksMouseMove:oe,onTracksMouseUp:ve,scrollContainerRef:tt,isSelecting:qe,"data-playlist-state":B?"ready":"loading",trackControlsSlots:kt,timescaleGapHeight:ae>0?ae+1:0,timescale:ae>0?C.jsxs(C.Fragment,{children:[C.jsx(Kd,{renderTick:t}),E&&C.jsx(Sv,{startPosition:Math.min(S,k)*ne/ue,endPosition:Math.max(S,k)*ne/ue,markerColor:m.loopMarkerColor,regionColor:m.loopRegionColor,minPosition:0,maxPosition:j,onLoopRegionChange:(N,q)=>{const U=N*ue/ne,Q=q*ue/ne;X(U,Q)}})]}):void 0,children:C.jsxs(C.Fragment,{children:[K.map((N,q)=>{const U=J[q];if(!U)return null;const Q=U.clips.some(ee=>ee.midiNotes&&ee.midiNotes.length>0),Te=re?.trackSpectrogramOverrides.get(U.id)?.renderMode??U.renderMode??(Q?"piano-roll":"waveform"),De=ka(N,f,U.id,_e);return C.jsxs(qd,{numChannels:De,backgroundColor:Te==="piano-roll"?m.pianoRollBackgroundColor||"#1a1a2e":qt(m.waveOutlineColor),offset:0,width:j,hasClipHeaders:o,trackId:U.id,isSelected:U.id===x,children:[Te!=="waveform"&&(()=>{const ee=Me.get(U.id),Ne=ee?.config;return!Ne?.labels||!ee?null:C.jsx(Wv,{waveHeight:z,numChannels:De,frequencyScaleFn:ee.frequencyScaleFn,minFrequency:Ne.minFrequency??0,maxFrequency:Ne.maxFrequency??ne/2,labelsColor:Ne.labelsColor,labelsBackground:Ne.labelsBackground,renderMode:Te,hasClipHeaders:o})})(),N.map((ee,Ne)=>{const Je=ee.peaks,Ye=Je.length;return C.jsx(fo,{clipId:ee.clipId,trackIndex:q,clipIndex:Ne,trackName:ee.trackName,startSample:ee.startSample,durationSamples:ee.durationSamples,samplesPerPixel:ue,showHeader:o,disableHeaderDrag:!i,isSelected:U.id===x,trackId:U.id,fadeIn:ee.fadeIn,fadeOut:ee.fadeOut,sampleRate:ne,showFades:l,touchOptimized:c,onMouseDown:Et=>{Et.target.closest('[role="button"][aria-roledescription="draggable"]')||Ge(q)},children:Je.data.map((Et,Dt)=>{const en=re?.spectrogramDataMap.get(ee.clipId),Pt=en?.[Dt]??en?.[0],zt=Me.get(U.id),Yn=zt?.config;return C.jsx(nc,{index:Dt,data:Et,bits:Je.bits,length:Ye,isSelected:U.id===x,clipStartSample:ee.startSample,clipDurationSamples:ee.durationSamples,renderMode:ee.midiNotes?"piano-roll":Te,midiNotes:ee.midiNotes,clipSampleRate:ee.sampleRate,clipOffsetSeconds:ee.offsetSamples!=null?ee.offsetSamples/(ee.sampleRate||ne):0,spectrogramData:Pt,samplesPerPixel:ue,spectrogramColorLUT:zt?.colorLUT,spectrogramFrequencyScaleFn:zt?.frequencyScaleFn,spectrogramMinFrequency:Yn?.minFrequency,spectrogramMaxFrequency:Yn?.maxFrequency,spectrogramWorkerApi:pe,spectrogramClipId:ee.clipId,spectrogramOnCanvasesReady:re?(Zr,Hr)=>{re.registerSpectrogramCanvases(ee.clipId,Dt,Zr,Hr)}:void 0},`${ee.clipId}-${Dt}`)})},ee.clipId)}),f?.isRecording&&f.trackId===U.id&&f.peaks[0]?.length>0&&C.jsx(fo,{clipId:"recording-preview",trackIndex:q,clipIndex:N.length,trackName:"Recording...",startSample:f.startSample,durationSamples:f.durationSamples,samplesPerPixel:ue,showHeader:o,disableHeaderDrag:!0,isSelected:U.id===x,trackId:U.id,children:(_e?f.peaks.slice(0,1):f.peaks).map((ee,Ne)=>C.jsx(nc,{index:Ne,data:ee,bits:f.bits,length:Math.floor(ee.length/2),isSelected:U.id===x,clipStartSample:f.startSample,clipDurationSamples:f.durationSamples},`${U.id}-recording-${Ne}`))},`${U.id}-recording`)]},U.id)}),g.length>0&&M&&C.jsx(M.AnnotationBoxesWrapper,{height:30,width:j,children:g.map((N,q)=>{const U=N.start*ne/ue,Q=N.end*ne/ue,Te=s?s(N,q):N.id;return C.jsx(M.AnnotationBox,{annotationId:N.id,annotationIndex:q,startPosition:U,endPosition:Q,label:Te,color:"#ff9800",isActive:N.id===y,onClick:()=>ge(N),editable:b},N.id)})}),h!==v&&C.jsx(Zd,{startPosition:Math.min(h,v)*ne/ue,endPosition:Math.max(h,v)*ne/ue,color:m.selectionColor}),(d||h===v)&&(n?C.jsx(Vy,{renderPlayhead:n,color:m.playheadColor,samplesPerPixel:ue,sampleRate:ne}):C.jsx(Ry,{color:m.playheadColor}))]})})}),re?.SettingsModal&&typeof document<"u"&&yo.createPortal(C.jsx(re.SettingsModal,{open:Ae!==null,onClose:()=>He(null),config:Ae!==null?re.trackSpectrogramOverrides.get(Ae)?.config??J.find(N=>N.id===Ae)?.spectrogramConfig??re.spectrogramConfig??{}:{},colorMap:Ae!==null?re.trackSpectrogramOverrides.get(Ae)?.colorMap??J.find(N=>N.id===Ae)?.spectrogramColorMap??re.spectrogramColorMap??"viridis":"viridis",onApply:(N,q)=>{Ae!==null&&re.setTrackSpectrogramConfig(Ae,N,q)}}),document.body)]})},Sf=({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:f}=it(),m=_n(),{setAnnotations:d}=Ie(),h=s??{linkEndpoints:u,continuousPlay:f},v=p.useCallback(y=>{d(y),n?.(y)},[d,n]),{AnnotationText:g}=m;return C.jsx(g,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:a,scrollActiveContainer:o,editable:c,controls:c?r:void 0,annotationListConfig:h,height:e,onAnnotationUpdate:v,renderAnnotationItem:t})},Ny=({renderTrackControls:e,renderTick:t,renderTimestamp:n,renderPlayhead:r,annotationControls:s,annotationListConfig:a,annotationTextHeight:o,renderAnnotationItem:i,getAnnotationBoxLabel:l,scrollActivePosition:c="center",scrollActiveContainer:u="nearest",className:f,showClipHeaders:m=!1,interactiveClips:d=!1,showFades:h=!1,touchOptimized:v=!1,onRemoveTrack:g,recordingState:y})=>{const{annotations:b}=it(),_=xf(),w=d||_;return C.jsxs(C.Fragment,{children:[C.jsx(Cf,{renderTrackControls:e,renderTick:t??(n?(x,S)=>n(parseFloat(x)||0,S):void 0),renderPlayhead:r,annotationControls:s,getAnnotationBoxLabel:l,className:f,showClipHeaders:m,interactiveClips:w,showFades:h,touchOptimized:v,onRemoveTrack:g,recordingState:y}),b.length>0&&C.jsx(Sf,{height:o,renderAnnotationItem:i,controls:s,annotationListConfig:a,scrollActivePosition:c,scrollActiveContainer:u})]})};var zy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kf=zy?p.useLayoutEffect:p.useEffect;function kn(e){const t=p.useRef(e);return kf(()=>{t.current=e},[e]),t}function Ea(e,t,n=p.useEffect,r=Object.is){const s=p.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}var rc=Object.getOwnPropertySymbols,jy=Object.prototype.hasOwnProperty,Zy=Object.prototype.propertyIsEnumerable,Hy=(e,t)=>{var n={};for(var r in e)jy.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&rc)for(var r of rc(e))t.indexOf(r)<0&&Zy.call(e,r)&&(n[r]=e[r]);return n},Gy=new hi,Uy=p.createContext(Gy),Xy=p.memo(p.forwardRef(({children:e},t)=>{const[n,r]=p.useState(0),s=p.useRef(null),a=p.useRef(null),o=p.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})),p.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return kf(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),p.useImperativeHandle(t,()=>o),null})),Ia=[void 0,br];function Ef(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:a,onDragMove:o,onDragOver:i,onDragEnd:l}=t,c=Hy(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=p.useRef(null),{plugins:f,modifiers:m,sensors:d}=c,h=Lt(f,Dn.plugins),v=Lt(d,Dn.sensors),g=Lt(m,Dn.modifiers),y=kn(s),b=kn(a),_=kn(i),w=kn(o),x=kn(l),S=kn(r),k=Yy(()=>{var E;return(E=c.manager)!=null?E:new hi(c)});return p.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:E,trackRendering:M}=u.current,{monitor:T}=k;k.renderer=E;const $=[T.addEventListener("beforedragstart",A=>{const I=y.current;I&&M(()=>I(A,k))}),T.addEventListener("dragstart",A=>{var I;return(I=b.current)==null?void 0:I.call(b,A,k)}),T.addEventListener("dragover",A=>{const I=_.current;I&&M(()=>I(A,k))}),T.addEventListener("dragmove",A=>{const I=w.current;I&&M(()=>I(A,k))}),T.addEventListener("dragend",A=>{const I=x.current;I&&M(()=>I(A,k))}),T.addEventListener("collision",A=>{var I;return(I=S.current)==null?void 0:I.call(S,A,k)})];return()=>$.forEach(A=>A())},[k]),Ea(h,()=>k&&(k.plugins=h),...Ia),Ea(v,()=>k&&(k.sensors=v),...Ia),Ea(g,()=>k&&(k.modifiers=g),...Ia),C.jsxs(Uy.Provider,{value:k,children:[C.jsx(Xy,{ref:u,children:n}),n]})}function Yy(e){const t=p.useRef(null);return t.current||(t.current=e()),p.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var Ky=Object.create,If=Object.defineProperty,qy=Object.getOwnPropertyDescriptor,Mf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ra=e=>{throw TypeError(e)},Jy=(e,t,n)=>t in e?If(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qy=e=>{var t;return[,,,Ky((t=e?.[Mf("metadata")])!=null?t:null)]},Af=["class","method","getter","setter","accessor","field","value","get","set"],Tf=e=>e!==void 0&&typeof e!="function"?ra("Function expected"):e,eb=(e,t,n,r,s)=>({kind:Af[e],name:t,metadata:r,addInitializer:a=>n._?ra("Already initialized"):s.push(Tf(a||null))}),tb=(e,t)=>Jy(t,Mf("metadata"),e[3]),nb=(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},$f=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=Af[u+5],v=e[d]||(e[d]=[]),g=(s=s.prototype,qy(s,n)),y=r.length-1;y>=0;y--)l=eb(u,n,i={},e[3],v),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(g[h],l),i._=1,Tf(o)&&(g[h]=o);return g&&If(s,n,g),s},Rf=(e,t,n)=>t.has(e)||ra("Cannot "+n),rb=(e,t,n)=>(Rf(e,t,"read from private field"),t.get(e)),sb=(e,t,n)=>t.has(e)?ra("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ab=(e,t,n,r)=>(Rf(e,t,"write to private field"),t.set(e,n),n),er=class mo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new mo(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 mo(t,n)}},Df,Pf,go,ws,jr,Ai=class extends(go=Jt,Pf=[Pe],Df=[Pe],go){constructor(e){const t=er.from(e);super(t,(n,r)=>er.equals(n,r)),nb(jr,5,this),sb(this,ws,0),this.velocity={x:0,y:0}}get delta(){return er.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=er.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),a=s-rb(this,ws),o=i=>Math.round(i/a*100);Kt(()=>{ab(this,ws,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(er.from(e)),this.velocity={x:0,y:0}}};jr=Qy(go);ws=new WeakMap;$f(jr,2,"delta",Pf,Ai);$f(jr,2,"direction",Df,Ai);tb(jr,Ai);var Ff=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ff||{});Object.values(Ff);var ob=Object.defineProperty,ib=Object.defineProperties,lb=Object.getOwnPropertyDescriptors,sc=Object.getOwnPropertySymbols,cb=Object.prototype.hasOwnProperty,ub=Object.prototype.propertyIsEnumerable,ac=(e,t,n)=>t in e?ob(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Of=(e,t)=>{for(var n in t||(t={}))cb.call(t,n)&&ac(e,n,t[n]);if(sc)for(var n of sc(t))ub.call(t,n)&&ac(e,n,t[n]);return e},Lf=(e,t)=>ib(e,lb(t)),vo=class extends On{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return Lf(Of({},t),{[n]:r})}};vo.configure=gn(vo);var Bf=vo;Bf.configure({axis:"x",value:0});var Wf=Bf.configure({axis:"y",value:0}),oc=class extends On{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 Lf(Of({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/a)*a})}};oc.configure=gn(oc);const Ti=e=>{let t=!1;const n=e.map(r=>r===no?(t=!0,no.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},db=F.div`
1044
+ `,Ly=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:a,playbackStartTimeRef:o,audioStartPositionRef:i,getPlaybackTime:l}=tt();return e({position:(a.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:a,playbackStartTimeRef:o,audioStartPositionRef:i,samplesPerPixel:n,sampleRate:r,controlsOffset:0,getAudioContextTime:()=>L.getContext().currentTime,getPlaybackTime:l})};function xa(e,t,n,r){const s=e.length>0?Math.max(1,...e.map(o=>o.peaks.data.length)):1,a=t?.isRecording&&t.trackId===n?r?1:t.peaks.length:0;return Math.max(s,a)}const Cf=({renderTrackControls:e,renderTick:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:s,className:a,showClipHeaders:o=!1,interactiveClips:i=!1,showFades:l=!1,touchOptimized:c=!1,onRemoveTrack:u,recordingState:f})=>{const p=Br(),{isPlaying:d}=tt(),{selectionStart:h,selectionEnd:v,annotations:g,activeAnnotationId:y,annotationsEditable:b,linkEndpoints:w,continuousPlay:_,selectedTrackId:x,loopStart:S,loopEnd:k,isLoopEnabled:E}=nt(),I=m.useContext(Qs),{setAnnotations:M,setActiveAnnotationId:T,setTrackMute:A,setTrackSolo:$,setTrackVolume:R,setTrackPan:F,setSelection:O,play:G,setScrollContainer:Q,setSelectedTrackId:ee,setCurrentTime:ue,setLoopRegion:te}=Se(),{peaksDataArray:oe,trackStates:se,tracks:le,duration:ye,samplesPerPixel:de,sampleRate:ne,waveHeight:Z,timeScaleHeight:fe,controls:Fe,barWidth:ae,barGap:Te,isReady:B,mono:$e}=rt(),re=m.useContext(ki),Ve=m.useMemo(()=>{if(!re)return new Map;const N=new Map;return le.forEach(U=>{if((re.trackSpectrogramOverrides.get(U.id)?.renderMode??U.renderMode??"waveform")==="waveform")return;const X=re.trackSpectrogramOverrides.get(U.id),ke=X?.colorMap??U.spectrogramColorMap??re.spectrogramColorMap??"viridis",Me=X?.config??U.spectrogramConfig??re.spectrogramConfig;N.set(U.id,{colorLUT:re.getColorMap(ke),frequencyScaleFn:re.getFrequencyScale(Me?.frequencyScale??"mel"),config:Me})}),N},[le,re]),ve=m.useMemo(()=>{if(re?.spectrogramWorkerApi)return{registerCanvas:re.spectrogramWorkerApi.registerCanvas.bind(re.spectrogramWorkerApi),unregisterCanvas:re.spectrogramWorkerApi.unregisterCanvas.bind(re.spectrogramWorkerApi)}},[re?.spectrogramWorkerApi]),[Re,ct]=m.useState(null),[xt,st]=m.useState(!1),je=m.useRef(0),at=m.useRef(null),ut=m.useCallback(N=>{at.current=N,Q(N)},[Q]),Mt=le.reduce((N,U)=>U.clips.reduce((H,X)=>{const ke=(X.startSample+X.durationSamples)/X.sampleRate;return Math.max(H,ke)},N),0);let Ct=Mt>0?Mt:ye>0?ye:Fy;if(f?.isRecording){const U=(f.startSample+f.durationSamples)/ne;Ct=Math.max(Ct,U+10)}const j=Math.floor(Ct*ne/de),pe=async N=>{T(N.id);const U=_?void 0:N.end-N.start;try{await G(N.start,U)}catch(H){console.error("waveform-playlist: Failed to start playback for annotation",N.id,H)}},ze=m.useCallback(N=>{if(N>=0&&N<le.length){const U=le[N];ee(U.id)}},[le,ee]),Ze=N=>{const U=N.currentTarget.getBoundingClientRect(),X=(N.clientX-U.left)*de/ne,Me=N.clientY-U.top;let Y=0,Be=-1;for(let Xe=0;Xe<oe.length;Xe++){const Ge=oe[Xe],kt=xa(Ge,f,le[Xe]?.id,$e),Dt=((re?.trackSpectrogramOverrides.get(le[Xe]?.id)?.renderMode??le[Xe]?.renderMode??"waveform")==="both"?kt*2:kt)*Z+(o?22:0);if(Me>=Y&&Me<Y+Dt){Be=Xe;break}Y+=Dt}Be!==-1&&ze(Be),je.current=X,st(!0),ue(X),O(X,X)},q=N=>{if(!xt||d)return;const U=N.currentTarget.getBoundingClientRect(),X=(N.clientX-U.left)*de/ne,ke=Math.min(h,X),Me=Math.max(h,X);O(ke,Me)},me=N=>{if(!xt)return;if(st(!1),d){const Y=Math.max(0,je.current);ue(Y),O(Y,Y),G(Y);return}const U=N.currentTarget.getBoundingClientRect(),X=(N.clientX-U.left)*de/ne,ke=Math.min(h,X),Me=Math.max(h,X);Math.abs(Me-ke)<.1?ue(ke):O(ke,Me)};if(le.some(N=>N.clips.length>0)&&oe.length===0)return C.jsx("div",{className:a,children:"Loading waveform..."});const St=Fe.show?oe.map((N,U)=>{const H=le[U];if(!H)return null;const X=se[U]||{name:`Track ${U+1}`,muted:!1,soloed:!1,volume:1,pan:0},ke=H.clips.some(Ge=>Ge.midiNotes&&Ge.midiNotes.length>0),Me=re?.trackSpectrogramOverrides.get(H.id)?.renderMode??H.renderMode??(ke?"piano-roll":"waveform"),Y=xa(N,f,H.id,$e),Be=Z*Y+(o?bi:0),Xe=e?e(U):C.jsxs(qv,{onClick:()=>ze(U),children:[C.jsxs(Jv,{style:{justifyContent:"center",position:"relative"},children:[u&&C.jsx(Kv,{onClick:Ge=>{Ge.stopPropagation(),u(U)}}),C.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:X.name||`Track ${U+1}`}),re?.renderMenuItems&&C.jsx("span",{style:{position:"absolute",right:0,top:0},children:C.jsx(o0,{items:Ge=>re.renderMenuItems({renderMode:Me,onRenderModeChange:kt=>re.setTrackRenderMode(H.id,kt),onOpenSettings:()=>ct(H.id),onClose:Ge})})})]}),C.jsxs(Xv,{children:[C.jsx(Kl,{$variant:X.muted?"danger":"outline",onClick:()=>A(U,!X.muted),children:"Mute"}),C.jsx(Kl,{$variant:X.soloed?"info":"outline",onClick:()=>$(U,!X.soloed),children:"Solo"})]}),C.jsxs(Jl,{children:[C.jsx(Qv,{}),C.jsx(ql,{min:"0",max:"1",step:"0.01",value:X.volume,onChange:Ge=>R(U,parseFloat(Ge.target.value))}),C.jsx(e0,{})]}),C.jsxs(Jl,{children:[C.jsx("span",{children:"L"}),C.jsx(ql,{min:"-1",max:"1",step:"0.01",value:X.pan,onChange:Ge=>F(U,parseFloat(Ge.target.value))}),C.jsx("span",{children:"R"})]})]});return C.jsx(Oy,{$height:Be,$isSelected:H.id===x,children:Xe},H.id)}):void 0;return C.jsxs(Xd,{children:[C.jsx(Lr.Provider,{value:{samplesPerPixel:de,sampleRate:ne,zoomLevels:[de],waveHeight:Z,timeScaleHeight:fe,duration:Ct*1e3,controls:Fe,barWidth:ae,barGap:Te},children:C.jsx(wi,{theme:p,backgroundColor:p.playlistBackgroundColor||Kt(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,timescaleWidth:j,tracksWidth:j,controlsWidth:Fe.show?Fe.width:0,onTracksMouseDown:Ze,onTracksMouseMove:q,onTracksMouseUp:me,scrollContainerRef:ut,isSelecting:xt,"data-playlist-state":B?"ready":"loading",trackControlsSlots:St,timescaleGapHeight:fe>0?fe+1:0,timescale:fe>0?C.jsxs(C.Fragment,{children:[C.jsx(Kd,{renderTick:t}),E&&C.jsx(Sv,{startPosition:Math.min(S,k)*ne/de,endPosition:Math.max(S,k)*ne/de,markerColor:p.loopMarkerColor,regionColor:p.loopRegionColor,minPosition:0,maxPosition:j,onLoopRegionChange:(N,U)=>{const H=N*de/ne,X=U*de/ne;te(H,X)}})]}):void 0,children:C.jsxs(C.Fragment,{children:[oe.map((N,U)=>{const H=le[U];if(!H)return null;const X=H.clips.some(Y=>Y.midiNotes&&Y.midiNotes.length>0),ke=re?.trackSpectrogramOverrides.get(H.id)?.renderMode??H.renderMode??(X?"piano-roll":"waveform"),Me=xa(N,f,H.id,$e);return C.jsxs(qd,{numChannels:Me,backgroundColor:ke==="piano-roll"?p.pianoRollBackgroundColor||"#1a1a2e":Kt(p.waveOutlineColor),offset:0,width:j,hasClipHeaders:o,trackId:H.id,isSelected:H.id===x,children:[ke!=="waveform"&&(()=>{const Y=Ve.get(H.id),Be=Y?.config;return!Be?.labels||!Y?null:C.jsx(Ov,{waveHeight:Z,numChannels:Me,frequencyScaleFn:Y.frequencyScaleFn,minFrequency:Be.minFrequency??0,maxFrequency:Be.maxFrequency??ne/2,labelsColor:Be.labelsColor,labelsBackground:Be.labelsBackground,renderMode:ke,hasClipHeaders:o})})(),N.map((Y,Be)=>{const Xe=Y.peaks,Ge=Xe.length;return C.jsx(lo,{clipId:Y.clipId,trackIndex:U,clipIndex:Be,trackName:Y.trackName,startSample:Y.startSample,durationSamples:Y.durationSamples,samplesPerPixel:de,showHeader:o,disableHeaderDrag:!i,isSelected:H.id===x,trackId:H.id,fadeIn:Y.fadeIn,fadeOut:Y.fadeOut,sampleRate:ne,showFades:l,touchOptimized:c,onMouseDown:kt=>{kt.target.closest('[role="button"][aria-roledescription="draggable"]')||ze(U)},children:Xe.data.map((kt,Nt)=>C.jsx(nc,{index:Nt,data:kt,bits:Xe.bits,length:Ge,isSelected:H.id===x,clipStartSample:Y.startSample,clipDurationSamples:Y.durationSamples,renderMode:Y.midiNotes?"piano-roll":ke,midiNotes:Y.midiNotes,clipSampleRate:Y.sampleRate,clipOffsetSeconds:Y.offsetSamples!=null?Y.offsetSamples/(Y.sampleRate||ne):0,samplesPerPixel:de,spectrogramWorkerApi:ve,spectrogramClipId:Y.clipId,spectrogramOnCanvasesReady:re?(wn,Dt)=>{re.registerSpectrogramCanvases(Y.clipId,Nt,wn,Dt)}:void 0},`${Y.clipId}-${Nt}`))},Y.clipId)}),f?.isRecording&&f.trackId===H.id&&f.peaks[0]?.length>0&&C.jsx(lo,{clipId:"recording-preview",trackIndex:U,clipIndex:N.length,trackName:"Recording...",startSample:f.startSample,durationSamples:f.durationSamples,samplesPerPixel:de,showHeader:o,disableHeaderDrag:!0,isSelected:H.id===x,trackId:H.id,children:($e?f.peaks.slice(0,1):f.peaks).map((Y,Be)=>C.jsx(nc,{index:Be,data:Y,bits:f.bits,length:Math.floor(Y.length/2),isSelected:H.id===x,clipStartSample:f.startSample,clipDurationSamples:f.durationSamples},`${H.id}-recording-${Be}`))},`${H.id}-recording`)]},H.id)}),g.length>0&&I&&C.jsx(I.AnnotationBoxesWrapper,{height:30,width:j,children:g.map((N,U)=>{const H=N.start*ne/de,X=N.end*ne/de,ke=s?s(N,U):N.id;return C.jsx(I.AnnotationBox,{annotationId:N.id,annotationIndex:U,startPosition:H,endPosition:X,label:ke,color:"#ff9800",isActive:N.id===y,onClick:()=>pe(N),editable:b},N.id)})}),h!==v&&C.jsx(Zd,{startPosition:Math.min(h,v)*ne/de,endPosition:Math.max(h,v)*ne/de,color:p.selectionColor}),(d||h===v)&&(n?C.jsx(Ly,{renderPlayhead:n,color:p.playheadColor,samplesPerPixel:de,sampleRate:ne}):C.jsx(Ay,{color:p.playheadColor}))]})})}),re?.SettingsModal&&typeof document<"u"&&mo.createPortal(C.jsx(re.SettingsModal,{open:Re!==null,onClose:()=>ct(null),config:Re!==null?re.trackSpectrogramOverrides.get(Re)?.config??le.find(N=>N.id===Re)?.spectrogramConfig??re.spectrogramConfig??{}:{},colorMap:Re!==null?re.trackSpectrogramOverrides.get(Re)?.colorMap??le.find(N=>N.id===Re)?.spectrogramColorMap??re.spectrogramColorMap??"viridis":"viridis",onApply:(N,U)=>{Re!==null&&re.setTrackSpectrogramConfig(Re,N,U)}}),document.body)]})},Sf=({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:f}=nt(),p=bn(),{setAnnotations:d}=Se(),h=s??{linkEndpoints:u,continuousPlay:f},v=m.useCallback(y=>{d(y),n?.(y)},[d,n]),{AnnotationText:g}=p;return C.jsx(g,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:a,scrollActiveContainer:o,editable:c,controls:c?r:void 0,annotationListConfig:h,height:e,onAnnotationUpdate:v,renderAnnotationItem:t})},By=({renderTrackControls:e,renderTick:t,renderTimestamp:n,renderPlayhead:r,annotationControls:s,annotationListConfig:a,annotationTextHeight:o,renderAnnotationItem:i,getAnnotationBoxLabel:l,scrollActivePosition:c="center",scrollActiveContainer:u="nearest",className:f,showClipHeaders:p=!1,interactiveClips:d=!1,showFades:h=!1,touchOptimized:v=!1,onRemoveTrack:g,recordingState:y})=>{const{annotations:b}=nt(),w=xf(),_=d||w;return C.jsxs(C.Fragment,{children:[C.jsx(Cf,{renderTrackControls:e,renderTick:t??(n?(x,S)=>n(parseFloat(x)||0,S):void 0),renderPlayhead:r,annotationControls:s,getAnnotationBoxLabel:l,className:f,showClipHeaders:p,interactiveClips:_,showFades:h,touchOptimized:v,onRemoveTrack:g,recordingState:y}),b.length>0&&C.jsx(Sf,{height:o,renderAnnotationItem:i,controls:s,annotationListConfig:a,scrollActivePosition:c,scrollActiveContainer:u})]})};var Wy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kf=Wy?m.useLayoutEffect:m.useEffect;function Sn(e){const t=m.useRef(e);return kf(()=>{t.current=e},[e]),t}function Ca(e,t,n=m.useEffect,r=Object.is){const s=m.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}var rc=Object.getOwnPropertySymbols,Vy=Object.prototype.hasOwnProperty,Ny=Object.prototype.propertyIsEnumerable,jy=(e,t)=>{var n={};for(var r in e)Vy.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&rc)for(var r of rc(e))t.indexOf(r)<0&&Ny.call(e,r)&&(n[r]=e[r]);return n},zy=new ui,Zy=m.createContext(zy),Hy=m.memo(m.forwardRef(({children:e},t)=>{const[n,r]=m.useState(0),s=m.useRef(null),a=m.useRef(null),o=m.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})),m.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return kf(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),m.useImperativeHandle(t,()=>o),null})),Sa=[void 0,vr];function Ef(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:a,onDragMove:o,onDragOver:i,onDragEnd:l}=t,c=jy(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=m.useRef(null),{plugins:f,modifiers:p,sensors:d}=c,h=Ot(f,Rn.plugins),v=Ot(d,Rn.sensors),g=Ot(p,Rn.modifiers),y=Sn(s),b=Sn(a),w=Sn(i),_=Sn(o),x=Sn(l),S=Sn(r),k=Gy(()=>{var E;return(E=c.manager)!=null?E:new ui(c)});return m.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:E,trackRendering:I}=u.current,{monitor:M}=k;k.renderer=E;const T=[M.addEventListener("beforedragstart",A=>{const $=y.current;$&&I(()=>$(A,k))}),M.addEventListener("dragstart",A=>{var $;return($=b.current)==null?void 0:$.call(b,A,k)}),M.addEventListener("dragover",A=>{const $=w.current;$&&I(()=>$(A,k))}),M.addEventListener("dragmove",A=>{const $=_.current;$&&I(()=>$(A,k))}),M.addEventListener("dragend",A=>{const $=x.current;$&&I(()=>$(A,k))}),M.addEventListener("collision",A=>{var $;return($=S.current)==null?void 0:$.call(S,A,k)})];return()=>T.forEach(A=>A())},[k]),Ca(h,()=>k&&(k.plugins=h),...Sa),Ca(v,()=>k&&(k.sensors=v),...Sa),Ca(g,()=>k&&(k.modifiers=g),...Sa),C.jsxs(Zy.Provider,{value:k,children:[C.jsx(Hy,{ref:u,children:n}),n]})}function Gy(e){const t=m.useRef(null);return t.current||(t.current=e()),m.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var Uy=Object.create,If=Object.defineProperty,Xy=Object.getOwnPropertyDescriptor,Mf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ea=e=>{throw TypeError(e)},Yy=(e,t,n)=>t in e?If(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ky=e=>{var t;return[,,,Uy((t=e?.[Mf("metadata")])!=null?t:null)]},Af=["class","method","getter","setter","accessor","field","value","get","set"],Tf=e=>e!==void 0&&typeof e!="function"?ea("Function expected"):e,qy=(e,t,n,r,s)=>({kind:Af[e],name:t,metadata:r,addInitializer:a=>n._?ea("Already initialized"):s.push(Tf(a||null))}),Jy=(e,t)=>Yy(t,Mf("metadata"),e[3]),Qy=(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},$f=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,p=!1,d=2,h=Af[u+5],v=e[d]||(e[d]=[]),g=(s=s.prototype,Xy(s,n)),y=r.length-1;y>=0;y--)l=qy(u,n,i={},e[3],v),l.static=f,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(g[h],l),i._=1,Tf(o)&&(g[h]=o);return g&&If(s,n,g),s},Rf=(e,t,n)=>t.has(e)||ea("Cannot "+n),eb=(e,t,n)=>(Rf(e,t,"read from private field"),t.get(e)),tb=(e,t,n)=>t.has(e)?ea("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),nb=(e,t,n,r)=>(Rf(e,t,"write to private field"),t.set(e,n),n),Jn=class fo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new fo(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 fo(t,n)}},Df,Pf,ho,vs,Nr,Ei=class extends(ho=qt,Pf=[Ae],Df=[Ae],ho){constructor(e){const t=Jn.from(e);super(t,(n,r)=>Jn.equals(n,r)),Qy(Nr,5,this),tb(this,vs,0),this.velocity={x:0,y:0}}get delta(){return Jn.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=Jn.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),a=s-eb(this,vs),o=i=>Math.round(i/a*100);Yt(()=>{nb(this,vs,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Jn.from(e)),this.velocity={x:0,y:0}}};Nr=Ky(ho);vs=new WeakMap;$f(Nr,2,"delta",Pf,Ei);$f(Nr,2,"direction",Df,Ei);Jy(Nr,Ei);var Ff=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ff||{});Object.values(Ff);var rb=Object.defineProperty,sb=Object.defineProperties,ab=Object.getOwnPropertyDescriptors,sc=Object.getOwnPropertySymbols,ob=Object.prototype.hasOwnProperty,ib=Object.prototype.propertyIsEnumerable,ac=(e,t,n)=>t in e?rb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Of=(e,t)=>{for(var n in t||(t={}))ob.call(t,n)&&ac(e,n,t[n]);if(sc)for(var n of sc(t))ib.call(t,n)&&ac(e,n,t[n]);return e},Lf=(e,t)=>sb(e,ab(t)),po=class extends Fn{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return Lf(Of({},t),{[n]:r})}};po.configure=pn(po);var Bf=po;Bf.configure({axis:"x",value:0});var Wf=Bf.configure({axis:"y",value:0}),oc=class extends Fn{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 Lf(Of({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/a)*a})}};oc.configure=pn(oc);const Ii=e=>{let t=!1;const n=e.map(r=>r===Qa?(t=!0,Qa.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},lb=P.div`
1045
1045
  position: absolute;
1046
1046
  top: 0;
1047
1047
  left: 0;
@@ -1051,9 +1051,9 @@ self.onmessage = function(e) {
1051
1051
  z-index: 100;
1052
1052
  pointer-events: none;
1053
1053
  will-change: transform;
1054
- `,fb=({color:e="#ff0000"})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s}=zr(),{samplesPerPixel:a,sampleRate:o,progressBarWidth:i}=ta();return p.useEffect(()=>{const l=()=>{if(t.current){const u=(s.current??0)*o/a;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,o,a,s]),p.useEffect(()=>{if(!r&&t.current){const c=(s.current??0)*o/a;t.current.style.transform=`translate3d(${c}px, 0, 0)`}}),C.jsx(db,{ref:t,$color:e,$width:i,"data-playhead":!0})},hb=F.div`
1054
+ `,cb=({color:e="#ff0000"})=>{const t=m.useRef(null),n=m.useRef(null),{isPlaying:r,currentTimeRef:s}=Vr(),{samplesPerPixel:a,sampleRate:o,progressBarWidth:i}=Js();return m.useEffect(()=>{const l=()=>{if(t.current){const u=(s.current??0)*o/a;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,o,a,s]),m.useEffect(()=>{if(!r&&t.current){const c=(s.current??0)*o/a;t.current.style.transform=`translate3d(${c}px, 0, 0)`}}),C.jsx(lb,{ref:t,$color:e,$width:i,"data-playhead":!0})},ub=P.div`
1055
1055
  position: relative;
1056
- `,pb=F.div`
1056
+ `,db=P.div`
1057
1057
  position: absolute;
1058
1058
  top: ${e=>e.$top}px;
1059
1059
  left: 0;
@@ -1063,7 +1063,7 @@ self.onmessage = function(e) {
1063
1063
  z-index: 0;
1064
1064
  transform: translateZ(0);
1065
1065
  backface-visibility: hidden;
1066
- `,mb=F.div`
1066
+ `,fb=P.div`
1067
1067
  position: absolute;
1068
1068
  top: ${e=>e.$top}px;
1069
1069
  left: 0;
@@ -1072,8 +1072,8 @@ self.onmessage = function(e) {
1072
1072
  pointer-events: none;
1073
1073
  z-index: 1;
1074
1074
  will-change: width;
1075
- `,gb=F.div`
1075
+ `,hb=P.div`
1076
1076
  position: relative;
1077
1077
  z-index: 2;
1078
- `,vb=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=p.useRef(null),s=p.useRef(null),a=Vr(),{waveHeight:o}=Js(),{isPlaying:i,currentTimeRef:l}=zr(),{samplesPerPixel:c,sampleRate:u}=ta(),f=a?.waveProgressColor||"rgba(0, 0, 0, 0.1)";p.useEffect(()=>{const v=()=>{if(r.current){const y=(l.current??0)*u,b=e+t;let _=0;if(y<=e)_=0;else if(y>=b)_=n.length;else{const w=y-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]),p.useEffect(()=>{if(!i&&r.current){const g=(l.current??0)*u,y=e+t;let b=0;if(g<=e)b=0;else if(g>=y)b=n.length;else{const _=g-e;b=Math.floor(_/c)}r.current.style.width=`${b}px`}});const m=a?.waveformDrawMode||"inverted";let d;m==="inverted"?d=a?.selectedWaveFillColor||a?.waveFillColor||"white":d=a?.selectedWaveOutlineColor||a?.waveOutlineColor||"grey";const h=qt(d);return C.jsxs(hb,{children:[C.jsx(pb,{$color:h,$height:o,$top:n.index*o,$width:n.length}),C.jsx(mb,{ref:r,$color:f,$height:o,$top:n.index*o}),C.jsx(gb,{children:C.jsx(Yd,{...n,isSelected:!0,transparentBackground:!0})})]})},ic={current:0},yb=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:a}=zr();return e({position:(a.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:a,playbackStartTimeRef:ic,audioStartPositionRef:ic,samplesPerPixel:n,sampleRate:r,controlsOffset:0})},Vf=({getAnnotationBoxLabel:e,editable:t=!1,linkEndpoints:n=!1,onAnnotationUpdate:r,renderPlayhead:s,className:a})=>{const o=Vr(),{isPlaying:i}=zr(),{annotations:l,activeAnnotationId:c}=ea(),u=p.useContext(na),{play:f,seekTo:m,setActiveAnnotationId:d,setAnnotations:h,setScrollContainer:v}=Ii(),{duration:g,peaksDataArray:y,sampleRate:b,waveHeight:_,timeScaleHeight:w,samplesPerPixel:x,controls:S,playoutRef:k,barWidth:E,barGap:M}=ta(),[T,$]=p.useState(0),[A,I]=p.useState(0),[R,D]=p.useState(!1),O=p.useRef(null),Z=p.useCallback(z=>{O.current=z,v(z)},[v]),G=Math.floor(g*b/x),Y=p.useCallback(async z=>{d(z.id);try{await f(z.start)}catch(ae){console.error("waveform-playlist: Failed to start playback for annotation",z.id,ae)}},[d,f]),te=p.useCallback(z=>{h(z),r?.(z)},[h,r]),{onDragStart:X,onDragMove:K,onDragEnd:le}=af({annotations:l,onAnnotationsChange:te,samplesPerPixel:x,sampleRate:b,duration:g,linkEndpoints:n}),J=p.useRef(0),de=p.useCallback(z=>{const ae=z.currentTarget.getBoundingClientRect(),ce=(z.clientX-ae.left)*x/b;J.current=ce,D(!0),$(ce),I(ce)},[x,b]),ue=p.useCallback(z=>{if(!R)return;const ae=z.currentTarget.getBoundingClientRect(),ce=(z.clientX-ae.left)*x/b;I(ce)},[R,x,b]),ne=p.useCallback(z=>{if(!R)return;if(D(!1),i&&k.current){const _e=Math.max(0,J.current);m(_e),$(_e),I(_e),k.current.stop(),f(_e);return}const ae=z.currentTarget.getBoundingClientRect(),ce=(z.clientX-ae.left)*x/b,xe=Math.min(T,ce),B=Math.max(T,ce);Math.abs(B-xe)<.1?(m(xe),$(xe),I(xe)):($(xe),I(B))},[R,T,x,b,m,i,k,f]);return y.length===0?C.jsx("div",{className:a,children:"Loading waveform..."}):C.jsx(Xd,{children:C.jsx(Wr.Provider,{value:{samplesPerPixel:x,sampleRate:b,zoomLevels:[x],waveHeight:_,timeScaleHeight:w,duration:g*1e3,controls:S,barWidth:E,barGap:M},children:C.jsx(Ci,{theme:o,backgroundColor:qt(o.waveOutlineColor),timescaleBackgroundColor:o.timescaleBackgroundColor,timescaleWidth:G,tracksWidth:G,controlsWidth:S.show?S.width:0,onTracksMouseDown:de,onTracksMouseMove:ue,onTracksMouseUp:ne,scrollContainerRef:Z,isSelecting:R,timescale:w>0?C.jsx(Kd,{}):void 0,children:C.jsxs(C.Fragment,{children:[y.map((z,ae)=>{const ke=z.length>0?Math.max(...z.map(ce=>ce.peaks.data.length)):1;return C.jsx(qd,{numChannels:ke,backgroundColor:qt(o.waveOutlineColor),offset:0,width:G,hasClipHeaders:!1,trackId:`media-element-track-${ae}`,isSelected:!0,children:z.map((ce,xe)=>{const B=ce.peaks,_e=B.length;return C.jsx(fo,{clipId:ce.clipId,trackIndex:ae,clipIndex:xe,trackName:ce.trackName,startSample:ce.startSample,durationSamples:ce.durationSamples,samplesPerPixel:x,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${ae}`,children:B.data.map((re,Me)=>C.jsx(vb,{index:Me,data:re,bits:B.bits,length:_e,clipStartSample:ce.startSample,clipDurationSamples:ce.durationSamples},`${ae}-${xe}-${Me}`))},`${ae}-${xe}`)})},ae)}),l.length>0&&u&&C.jsx(Ef,{onDragStart:X,onDragMove:K,onDragEnd:le,modifiers:t?[Wf]:[],plugins:Ti,children:C.jsx(u.AnnotationBoxesWrapper,{height:30,width:G,children:l.map((z,ae)=>{const ke=z.start*b/x,ce=z.end*b/x,xe=e?e(z,ae):z.id;return C.jsx(u.AnnotationBox,{annotationId:z.id,annotationIndex:ae,startPosition:ke,endPosition:ce,label:xe,color:"#ff9800",isActive:z.id===c,onClick:()=>Y(z),editable:t},z.id)})})}),T!==A&&C.jsx(Zd,{startPosition:Math.min(T,A)*b/x,endPosition:Math.max(T,A)*b/x,color:o.selectionColor}),s?C.jsx(yb,{renderPlayhead:s,color:o.playheadColor,samplesPerPixel:x,sampleRate:b}):C.jsx(fb,{color:o.playheadColor})]})})})})},Nf=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,editable:r=!1,controls:s,annotationListConfig:a,scrollActivePosition:o="center",scrollActiveContainer:i="nearest"})=>{const{annotations:l,activeAnnotationId:c,continuousPlay:u}=ea(),f=_n(),{setAnnotations:m}=Ii(),d=a??{linkEndpoints:!1,continuousPlay:u},h=p.useCallback(g=>{m(g),n?.(g)},[m,n]),{AnnotationText:v}=f;return C.jsx(v,{annotations:l,activeAnnotationId:c??void 0,shouldScrollToActive:!0,scrollActivePosition:o,scrollActiveContainer:i,editable:r,controls:r?s:void 0,annotationListConfig:d,height:e,onAnnotationUpdate:h,renderAnnotationItem:t})},bb=({annotationTextHeight:e,getAnnotationBoxLabel:t,renderAnnotationItem:n,editable:r=!1,linkEndpoints:s=!1,onAnnotationUpdate:a,scrollActivePosition:o="center",scrollActiveContainer:i="nearest",renderPlayhead:l,className:c})=>{const{annotations:u}=ea();return C.jsxs(C.Fragment,{children:[C.jsx(Vf,{getAnnotationBoxLabel:t,editable:r,linkEndpoints:s,onAnnotationUpdate:a,renderPlayhead:l,className:c}),u.length>0&&C.jsx(Nf,{height:e,renderAnnotationItem:n,onAnnotationUpdate:a,editable:r,annotationListConfig:{linkEndpoints:s,continuousPlay:!1},scrollActivePosition:o,scrollActiveContainer:i})]})},wb=({playback:e=!1,clipSplitting:t=!1,annotations:n=!1,additionalShortcuts:r=[]})=>{const{tracks:s,samplesPerPixel:a,sampleRate:o,playoutRef:i,duration:l}=lt(),{annotations:c,linkEndpoints:u,activeAnnotationId:f,continuousPlay:m}=it(),{setAnnotations:d,setActiveAnnotationId:h,scrollContainerRef:v,play:g}=Ie(),{splitClipAtPlayhead:y}=lf({tracks:s,sampleRate:o,samplesPerPixel:a,engineRef:i}),b=[];return t&&b.push({key:"s",action:y,description:"Split clip at playhead",preventDefault:!0}),r.length>0&&b.push(...r),cf({enabled:e||b.length>0,...e?{additionalShortcuts:b}:{shortcuts:b}}),uf({annotations:c,activeAnnotationId:f,onAnnotationsChange:d,onActiveAnnotationChange:h,duration:l,linkEndpoints:u,continuousPlay:m,scrollContainerRef:v,samplesPerPixel:a,sampleRate:o,onPlay:g,enabled:n&&c.length>0}),null},Ws=class Ws extends On{apply(t){const{transform:n,source:r}=t;if(!r?.data||!this.options)return n;const{boundary:s,trackIndex:a,clipIndex:o}=r.data;if(s)return{x:0,y:0};const{tracks:i,samplesPerPixel:l}=this.options,c=i[a];if(!c)return n;const u=c.clips[o];if(!u)return n;const f=n.x*l,m=[...c.clips].sort((v,g)=>v.startSample-g.startSample),d=m.findIndex(v=>v.id===u.id);return{x:gc(u,f,m,d)/l,y:0}}};Ws.configure=gn(Ws);let Bs=Ws;const Vs=class Vs extends On{apply(t){const{transform:n,source:r}=t;if(!this.options||!r?.data)return n;const{boundary:s,startSample:a}=r.data;if(s)return n;const{samplesPerPixel:o}=this.options;if(this.options.mode==="timescale"){const{gridSamples:g}=this.options;if(a!==void 0){const _=a+n.x*o;return{x:(Math.round(_/g)*g-a)/o,y:0}}const y=n.x*o;return{x:Math.round(y/g)*g/o,y:0}}const{snapTo:i,bpm:l,timeSignature:c,sampleRate:u}=this.options;if(i==="off")return n;const f=i==="bar"?bo(c):Ns(c);if(a!==void 0){const g=a+n.x*o,y=Aa(g,l,u),b=Ta(y,f);return{x:(Rn(b,l,u)-a)/o,y:0}}const m=n.x*o,d=Aa(m,l,u),h=Ta(d,f);return{x:Rn(h,l,u)/o,y:0}}};Vs.configure=gn(Vs);let Mr=Vs;const _b=()=>{},xb=({snap:e=!1,touchOptimized:t=!1,children:n})=>{const{tracks:r,samplesPerPixel:s,sampleRate:a,playoutRef:o,isDraggingRef:i,onTracksChange:l}=lt(),{setSelectedTrackId:c}=Ie(),u=Gd(),f=e&&u!=null&&u.scaleMode==="beats"&&u.snapTo!=="off",m=e&&!f;p.useEffect(()=>{l==null&&console.warn("[waveform-playlist] ClipInteractionProvider: onTracksChange is not set on WaveformPlaylistProvider. Drag and trim edits will not be persisted.")},[l]);const d=p.useMemo(()=>{if(f&&u){const{bpm:w,timeSignature:x,snapTo:S}=u,k=S==="bar"?bo(x):Ns(x);return E=>{const M=Aa(E,w,a),T=Ta(M,k);return Rn(T,w,a)}}if(m){const w=Math.round(ho(s).smallStep/1e3*a);return x=>Math.round(x/w)*w}},[f,m,u,a,s]),h=of({touchOptimized:t}),{onDragStart:v,onDragMove:g,onDragEnd:y}=sf({tracks:r,onTracksChange:l??_b,samplesPerPixel:s,sampleRate:a,engineRef:o,isDraggingRef:i,snapSamplePosition:d}),b=p.useCallback(w=>{const x=w.operation?.source?.data?.trackIndex;x!==void 0&&r[x]&&c(r[x].id),v(w)},[v,r,c]),_=p.useMemo(()=>{const w=[Wf];return f&&u?w.push(Mr.configure({mode:"beats",snapTo:u.snapTo,bpm:u.bpm,timeSignature:u.timeSignature,samplesPerPixel:s,sampleRate:a})):m&&w.push(Mr.configure({mode:"timescale",gridSamples:Math.round(ho(s).smallStep/1e3*a),samplesPerPixel:s})),w.push(Bs.configure({tracks:r,samplesPerPixel:s})),w},[f,m,u,r,s,a]);return C.jsx(Ty,{value:!0,children:C.jsx(Ef,{sensors:h,onDragStart:b,onDragMove:g,onDragEnd:y,modifiers:_,plugins:Ti,children:n})})};exports.Tone=cc;exports.AnnotationIntegrationProvider=Sy;exports.AudioPosition=_y;exports.AutomaticScrollCheckbox=Cy;exports.ClearAllButton=my;exports.ClipCollisionModifier=Bs;exports.ClipInteractionProvider=xb;exports.ContinuousPlayCheckbox=ky;exports.DownloadAnnotationsButton=My;exports.EditableCheckbox=Iy;exports.ExportWavButton=Ay;exports.FastForwardButton=uy;exports.KeyboardShortcuts=wb;exports.LinkEndpointsCheckbox=Ey;exports.LoopButton=hy;exports.MasterVolumeControl=yy;exports.MediaElementAnnotationList=Nf;exports.MediaElementPlaylist=Vf;exports.MediaElementPlaylistProvider=ay;exports.MediaElementWaveform=bb;exports.PauseButton=iy;exports.PlayButton=oy;exports.PlaylistAnnotationList=Sf;exports.PlaylistVisualization=Cf;exports.RewindButton=cy;exports.SelectionTimeInputs=xy;exports.SetLoopRegionButton=py;exports.SkipBackwardButton=dy;exports.SkipForwardButton=fy;exports.SnapToGridModifier=Mr;exports.SpectrogramIntegrationProvider=Oy;exports.StopButton=ly;exports.TimeFormatSelect=by;exports.Waveform=Ny;exports.WaveformPlaylistProvider=ny;exports.ZoomInButton=gy;exports.ZoomOutButton=vy;exports.createEffectChain=z0;exports.createEffectInstance=Ir;exports.effectCategories=B0;exports.effectDefinitions=Nr;exports.getEffectDefinition=Ei;exports.getEffectsByCategory=L0;exports.getShortcutLabel=O0;exports.getWaveformDataMetadata=I0;exports.loadPeaksFromWaveformData=E0;exports.loadWaveformData=ki;exports.noDropAnimationPlugins=Ti;exports.useAnnotationDragHandlers=af;exports.useAnnotationIntegration=_n;exports.useAnnotationKeyboardControls=uf;exports.useAudioTracks=D0;exports.useClipDragHandlers=sf;exports.useClipInteractionEnabled=xf;exports.useClipSplitting=lf;exports.useDragSensors=of;exports.useDynamicEffects=j0;exports.useDynamicTracks=ty;exports.useExportWav=df;exports.useKeyboardShortcuts=Ls;exports.useMasterAnalyser=R0;exports.useMasterVolume=rf;exports.useMediaElementAnimation=zr;exports.useMediaElementControls=Ii;exports.useMediaElementData=ta;exports.useMediaElementState=ea;exports.usePlaybackAnimation=ot;exports.usePlaybackShortcuts=cf;exports.usePlaylistControls=Ie;exports.usePlaylistData=lt;exports.usePlaylistState=it;exports.useSpectrogramIntegration=Ly;exports.useTimeFormat=tf;exports.useTrackDynamicEffects=Z0;exports.useZoomControls=nf;exports.waveformDataToPeaks=Qd;
1078
+ `,pb=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=m.useRef(null),s=m.useRef(null),a=Br(),{waveHeight:o}=Ys(),{isPlaying:i,currentTimeRef:l}=Vr(),{samplesPerPixel:c,sampleRate:u}=Js(),f=a?.waveProgressColor||"rgba(0, 0, 0, 0.1)";m.useEffect(()=>{const v=()=>{if(r.current){const y=(l.current??0)*u,b=e+t;let w=0;if(y<=e)w=0;else if(y>=b)w=n.length;else{const _=y-e;w=Math.floor(_/c)}r.current.style.width=`${w}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]),m.useEffect(()=>{if(!i&&r.current){const g=(l.current??0)*u,y=e+t;let b=0;if(g<=e)b=0;else if(g>=y)b=n.length;else{const w=g-e;b=Math.floor(w/c)}r.current.style.width=`${b}px`}});const p=a?.waveformDrawMode||"inverted";let d;p==="inverted"?d=a?.selectedWaveFillColor||a?.waveFillColor||"white":d=a?.selectedWaveOutlineColor||a?.waveOutlineColor||"grey";const h=Kt(d);return C.jsxs(ub,{children:[C.jsx(db,{$color:h,$height:o,$top:n.index*o,$width:n.length}),C.jsx(fb,{ref:r,$color:f,$height:o,$top:n.index*o}),C.jsx(hb,{children:C.jsx(Yd,{...n,isSelected:!0,transparentBackground:!0})})]})},ic={current:0},mb=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:a}=Vr();return e({position:(a.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:a,playbackStartTimeRef:ic,audioStartPositionRef:ic,samplesPerPixel:n,sampleRate:r,controlsOffset:0})},Vf=({getAnnotationBoxLabel:e,editable:t=!1,linkEndpoints:n=!1,onAnnotationUpdate:r,renderPlayhead:s,className:a})=>{const o=Br(),{isPlaying:i}=Vr(),{annotations:l,activeAnnotationId:c}=qs(),u=m.useContext(Qs),{play:f,seekTo:p,setActiveAnnotationId:d,setAnnotations:h,setScrollContainer:v}=Si(),{duration:g,peaksDataArray:y,sampleRate:b,waveHeight:w,timeScaleHeight:_,samplesPerPixel:x,controls:S,playoutRef:k,barWidth:E,barGap:I}=Js(),[M,T]=m.useState(0),[A,$]=m.useState(0),[R,F]=m.useState(!1),O=m.useRef(null),G=m.useCallback(Z=>{O.current=Z,v(Z)},[v]),Q=Math.floor(g*b/x),ee=m.useCallback(async Z=>{d(Z.id);try{await f(Z.start)}catch(fe){console.error("waveform-playlist: Failed to start playback for annotation",Z.id,fe)}},[d,f]),ue=m.useCallback(Z=>{h(Z),r?.(Z)},[h,r]),{onDragStart:te,onDragMove:oe,onDragEnd:se}=af({annotations:l,onAnnotationsChange:ue,samplesPerPixel:x,sampleRate:b,duration:g,linkEndpoints:n}),le=m.useRef(0),ye=m.useCallback(Z=>{const fe=Z.currentTarget.getBoundingClientRect(),ae=(Z.clientX-fe.left)*x/b;le.current=ae,F(!0),T(ae),$(ae)},[x,b]),de=m.useCallback(Z=>{if(!R)return;const fe=Z.currentTarget.getBoundingClientRect(),ae=(Z.clientX-fe.left)*x/b;$(ae)},[R,x,b]),ne=m.useCallback(Z=>{if(!R)return;if(F(!1),i&&k.current){const $e=Math.max(0,le.current);p($e),T($e),$($e),k.current.stop(),f($e);return}const fe=Z.currentTarget.getBoundingClientRect(),ae=(Z.clientX-fe.left)*x/b,Te=Math.min(M,ae),B=Math.max(M,ae);Math.abs(B-Te)<.1?(p(Te),T(Te),$(Te)):(T(Te),$(B))},[R,M,x,b,p,i,k,f]);return y.length===0?C.jsx("div",{className:a,children:"Loading waveform..."}):C.jsx(Xd,{children:C.jsx(Lr.Provider,{value:{samplesPerPixel:x,sampleRate:b,zoomLevels:[x],waveHeight:w,timeScaleHeight:_,duration:g*1e3,controls:S,barWidth:E,barGap:I},children:C.jsx(wi,{theme:o,backgroundColor:Kt(o.waveOutlineColor),timescaleBackgroundColor:o.timescaleBackgroundColor,timescaleWidth:Q,tracksWidth:Q,controlsWidth:S.show?S.width:0,onTracksMouseDown:ye,onTracksMouseMove:de,onTracksMouseUp:ne,scrollContainerRef:G,isSelecting:R,timescale:_>0?C.jsx(Kd,{}):void 0,children:C.jsxs(C.Fragment,{children:[y.map((Z,fe)=>{const Fe=Z.length>0?Math.max(...Z.map(ae=>ae.peaks.data.length)):1;return C.jsx(qd,{numChannels:Fe,backgroundColor:Kt(o.waveOutlineColor),offset:0,width:Q,hasClipHeaders:!1,trackId:`media-element-track-${fe}`,isSelected:!0,children:Z.map((ae,Te)=>{const B=ae.peaks,$e=B.length;return C.jsx(lo,{clipId:ae.clipId,trackIndex:fe,clipIndex:Te,trackName:ae.trackName,startSample:ae.startSample,durationSamples:ae.durationSamples,samplesPerPixel:x,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${fe}`,children:B.data.map((re,Ve)=>C.jsx(pb,{index:Ve,data:re,bits:B.bits,length:$e,clipStartSample:ae.startSample,clipDurationSamples:ae.durationSamples},`${fe}-${Te}-${Ve}`))},`${fe}-${Te}`)})},fe)}),l.length>0&&u&&C.jsx(Ef,{onDragStart:te,onDragMove:oe,onDragEnd:se,modifiers:t?[Wf]:[],plugins:Ii,children:C.jsx(u.AnnotationBoxesWrapper,{height:30,width:Q,children:l.map((Z,fe)=>{const Fe=Z.start*b/x,ae=Z.end*b/x,Te=e?e(Z,fe):Z.id;return C.jsx(u.AnnotationBox,{annotationId:Z.id,annotationIndex:fe,startPosition:Fe,endPosition:ae,label:Te,color:"#ff9800",isActive:Z.id===c,onClick:()=>ee(Z),editable:t},Z.id)})})}),M!==A&&C.jsx(Zd,{startPosition:Math.min(M,A)*b/x,endPosition:Math.max(M,A)*b/x,color:o.selectionColor}),s?C.jsx(mb,{renderPlayhead:s,color:o.playheadColor,samplesPerPixel:x,sampleRate:b}):C.jsx(cb,{color:o.playheadColor})]})})})})},Nf=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,editable:r=!1,controls:s,annotationListConfig:a,scrollActivePosition:o="center",scrollActiveContainer:i="nearest"})=>{const{annotations:l,activeAnnotationId:c,continuousPlay:u}=qs(),f=bn(),{setAnnotations:p}=Si(),d=a??{linkEndpoints:!1,continuousPlay:u},h=m.useCallback(g=>{p(g),n?.(g)},[p,n]),{AnnotationText:v}=f;return C.jsx(v,{annotations:l,activeAnnotationId:c??void 0,shouldScrollToActive:!0,scrollActivePosition:o,scrollActiveContainer:i,editable:r,controls:r?s:void 0,annotationListConfig:d,height:e,onAnnotationUpdate:h,renderAnnotationItem:t})},gb=({annotationTextHeight:e,getAnnotationBoxLabel:t,renderAnnotationItem:n,editable:r=!1,linkEndpoints:s=!1,onAnnotationUpdate:a,scrollActivePosition:o="center",scrollActiveContainer:i="nearest",renderPlayhead:l,className:c})=>{const{annotations:u}=qs();return C.jsxs(C.Fragment,{children:[C.jsx(Vf,{getAnnotationBoxLabel:t,editable:r,linkEndpoints:s,onAnnotationUpdate:a,renderPlayhead:l,className:c}),u.length>0&&C.jsx(Nf,{height:e,renderAnnotationItem:n,onAnnotationUpdate:a,editable:r,annotationListConfig:{linkEndpoints:s,continuousPlay:!1},scrollActivePosition:o,scrollActiveContainer:i})]})},vb=({playback:e=!1,clipSplitting:t=!1,annotations:n=!1,additionalShortcuts:r=[]})=>{const{tracks:s,samplesPerPixel:a,sampleRate:o,playoutRef:i,duration:l}=rt(),{annotations:c,linkEndpoints:u,activeAnnotationId:f,continuousPlay:p}=nt(),{setAnnotations:d,setActiveAnnotationId:h,scrollContainerRef:v,play:g}=Se(),{splitClipAtPlayhead:y}=lf({tracks:s,sampleRate:o,samplesPerPixel:a,engineRef:i}),b=[];return t&&b.push({key:"s",action:y,description:"Split clip at playhead",preventDefault:!0}),r.length>0&&b.push(...r),cf({enabled:e||b.length>0,...e?{additionalShortcuts:b}:{shortcuts:b}}),uf({annotations:c,activeAnnotationId:f,onAnnotationsChange:d,onActiveAnnotationChange:h,duration:l,linkEndpoints:u,continuousPlay:p,scrollContainerRef:v,samplesPerPixel:a,sampleRate:o,onPlay:g,enabled:n&&c.length>0}),null},Os=class Os extends Fn{apply(t){const{transform:n,source:r}=t;if(!r?.data||!this.options)return n;const{boundary:s,trackIndex:a,clipIndex:o}=r.data;if(s)return{x:0,y:0};const{tracks:i,samplesPerPixel:l}=this.options,c=i[a];if(!c)return n;const u=c.clips[o];if(!u)return n;const f=n.x*l,p=[...c.clips].sort((v,g)=>v.startSample-g.startSample),d=p.findIndex(v=>v.id===u.id);return{x:gc(u,f,p,d)/l,y:0}}};Os.configure=pn(Os);let Fs=Os;const Ls=class Ls extends Fn{apply(t){const{transform:n,source:r}=t;if(!this.options||!r?.data)return n;const{boundary:s,startSample:a}=r.data;if(s)return n;const{samplesPerPixel:o}=this.options;if(this.options.mode==="timescale"){const{gridSamples:g}=this.options;if(a!==void 0){const w=a+n.x*o;return{x:(Math.round(w/g)*g-a)/o,y:0}}const y=n.x*o;return{x:Math.round(y/g)*g/o,y:0}}const{snapTo:i,bpm:l,timeSignature:c,sampleRate:u}=this.options;if(i==="off")return n;const f=i==="bar"?go(c):Bs(c);if(a!==void 0){const g=a+n.x*o,y=Ea(g,l,u),b=Ia(y,f);return{x:($n(b,l,u)-a)/o,y:0}}const p=n.x*o,d=Ea(p,l,u),h=Ia(d,f);return{x:$n(h,l,u)/o,y:0}}};Ls.configure=pn(Ls);let Er=Ls;const yb=()=>{},bb=({snap:e=!1,touchOptimized:t=!1,children:n})=>{const{tracks:r,samplesPerPixel:s,sampleRate:a,playoutRef:o,isDraggingRef:i,onTracksChange:l}=rt(),{setSelectedTrackId:c}=Se(),u=Gd(),f=e&&u!=null&&u.scaleMode==="beats"&&u.snapTo!=="off",p=e&&!f;m.useEffect(()=>{l==null&&console.warn("[waveform-playlist] ClipInteractionProvider: onTracksChange is not set on WaveformPlaylistProvider. Drag and trim edits will not be persisted.")},[l]);const d=m.useMemo(()=>{if(f&&u){const{bpm:_,timeSignature:x,snapTo:S}=u,k=S==="bar"?go(x):Bs(x);return E=>{const I=Ea(E,_,a),M=Ia(I,k);return $n(M,_,a)}}if(p){const _=Math.round(co(s).smallStep/1e3*a);return x=>Math.round(x/_)*_}},[f,p,u,a,s]),h=of({touchOptimized:t}),{onDragStart:v,onDragMove:g,onDragEnd:y}=sf({tracks:r,onTracksChange:l??yb,samplesPerPixel:s,sampleRate:a,engineRef:o,isDraggingRef:i,snapSamplePosition:d}),b=m.useCallback(_=>{const x=_.operation?.source?.data?.trackIndex;x!==void 0&&r[x]&&c(r[x].id),v(_)},[v,r,c]),w=m.useMemo(()=>{const _=[Wf];return f&&u?_.push(Er.configure({mode:"beats",snapTo:u.snapTo,bpm:u.bpm,timeSignature:u.timeSignature,samplesPerPixel:s,sampleRate:a})):p&&_.push(Er.configure({mode:"timescale",gridSamples:Math.round(co(s).smallStep/1e3*a),samplesPerPixel:s})),_.push(Fs.configure({tracks:r,samplesPerPixel:s})),_},[f,p,u,r,s,a]);return C.jsx(Iy,{value:!0,children:C.jsx(Ef,{sensors:h,onDragStart:b,onDragMove:g,onDragEnd:y,modifiers:w,plugins:Ii,children:n})})};exports.Tone=cc;exports.AnnotationIntegrationProvider=_y;exports.AudioPosition=yy;exports.AutomaticScrollCheckbox=wy;exports.ClearAllButton=fy;exports.ClipCollisionModifier=Fs;exports.ClipInteractionProvider=bb;exports.ContinuousPlayCheckbox=xy;exports.DownloadAnnotationsButton=ky;exports.EditableCheckbox=Sy;exports.ExportWavButton=Ey;exports.FastForwardButton=iy;exports.KeyboardShortcuts=vb;exports.LinkEndpointsCheckbox=Cy;exports.LoopButton=uy;exports.MasterVolumeControl=my;exports.MediaElementAnnotationList=Nf;exports.MediaElementPlaylist=Vf;exports.MediaElementPlaylistProvider=ny;exports.MediaElementWaveform=gb;exports.PauseButton=sy;exports.PlayButton=ry;exports.PlaylistAnnotationList=Sf;exports.PlaylistVisualization=Cf;exports.RewindButton=oy;exports.SelectionTimeInputs=by;exports.SetLoopRegionButton=dy;exports.SkipBackwardButton=ly;exports.SkipForwardButton=cy;exports.SnapToGridModifier=Er;exports.SpectrogramIntegrationProvider=Dy;exports.StopButton=ay;exports.TimeFormatSelect=gy;exports.Waveform=By;exports.WaveformPlaylistProvider=Q0;exports.ZoomInButton=hy;exports.ZoomOutButton=py;exports.createEffectChain=W0;exports.createEffectInstance=kr;exports.effectCategories=F0;exports.effectDefinitions=Wr;exports.getEffectDefinition=Ci;exports.getEffectsByCategory=P0;exports.getShortcutLabel=D0;exports.getWaveformDataMetadata=S0;exports.loadPeaksFromWaveformData=C0;exports.loadWaveformData=xi;exports.noDropAnimationPlugins=Ii;exports.useAnnotationDragHandlers=af;exports.useAnnotationIntegration=bn;exports.useAnnotationKeyboardControls=uf;exports.useAudioTracks=T0;exports.useClipDragHandlers=sf;exports.useClipInteractionEnabled=xf;exports.useClipSplitting=lf;exports.useDragSensors=of;exports.useDynamicEffects=V0;exports.useDynamicTracks=J0;exports.useExportWav=df;exports.useKeyboardShortcuts=Ps;exports.useMasterAnalyser=A0;exports.useMasterVolume=rf;exports.useMediaElementAnimation=Vr;exports.useMediaElementControls=Si;exports.useMediaElementData=Js;exports.useMediaElementState=qs;exports.usePlaybackAnimation=tt;exports.usePlaybackShortcuts=cf;exports.usePlaylistControls=Se;exports.usePlaylistData=rt;exports.usePlaylistState=nt;exports.useSpectrogramIntegration=Py;exports.useTimeFormat=tf;exports.useTrackDynamicEffects=N0;exports.useZoomControls=nf;exports.waveformDataToPeaks=Qd;
1079
1079
  //# sourceMappingURL=index.js.map