@waveform-playlist/browser 9.5.2 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +76 -0
- package/dist/index.js +158 -107
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5217 -4669
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -9
package/dist/index.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
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(`
|
|
1
|
+
"use strict";var uh=Object.create;var Cl=Object.defineProperty;var dh=Object.getOwnPropertyDescriptor;var fh=Object.getOwnPropertyNames;var hh=Object.getPrototypeOf,ph=Object.prototype.hasOwnProperty;var mh=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fh(t))!ph.call(e,s)&&s!==n&&Cl(e,s,{get:()=>t[s],enumerable:!(r=dh(t,s))||r.enumerable});return e};var gh=(e,t,n)=>(n=e!=null?uh(hh(e)):{},mh(t||!e||!e.__esModule?Cl(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("tone"),x=require("react/jsx-runtime"),m=require("react"),D=require("styled-components"),Eo=require("react-dom");var On=typeof document<"u"?document.currentScript:null;function xc(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 Sc=xc(W),F=xc(m);var Be=1e3;function Oa(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 g=e.durationSamples??h;return{id:Ac(),audioBuffer:t,startSample:n,durationSamples:g,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 kc(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 g=e.duration??h;return Oa({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(g*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 Ic(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:Ac(),name:t,clips:n,muted:r,soloed:s,volume:a,pan:o,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}}function Ac(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function _l(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function vh(e,t){return Math.floor(e/t)}function yh(e,t,n){return Math.ceil(e*n/t)}var Hn=192;function Ys(e,t=Hn){const[,n]=e;return t*(4/n)}function Mo(e,t=Hn){const[n]=e;return n*Ys(e,t)}function Bn(e,t,n,r=Hn){return Math.round(e*60*n/(t*r))}function Ba(e,t,n,r=Hn){return Math.round(e*r*t/(60*n))}function Wa(e,t){return Math.round(e/t)*t}function bh(e,t,n=Hn){const r=Mo(t,n),s=Ys(t,n),a=Math.floor(e/r)+1,o=Math.floor(e%r/s)+1;return o===1?`${a}`:`${a}.${o}`}var Ss=-100;function wh(e,t=Ss){return Number.isNaN(e)?(console.warn("[waveform-playlist] dBToNormalized received NaN"),0):t>=0?(console.warn("[waveform-playlist] dBToNormalized floor must be negative, got:",t),0):!isFinite(e)||e<=t?0:(e-t)/-t}function xl(e,t=Ss){return isFinite(e)?t>=0?(console.warn("[waveform-playlist] normalizedToDb floor must be negative, got:",t),Ss):Math.max(0,e)*-t+t:t}function Sl(e,t=Ss){if(e<=0)return 0;const n=20*Math.log10(e);return wh(n,t)}function ts(e){return e.startSample/e.sampleRate}function kl(e){return(e.startSample+e.durationSamples)/e.sampleRate}function Il(e){return e.offsetSamples/e.sampleRate}function Al(e){return e.durationSamples/e.sampleRate}function Ec(e,t,n){return Math.floor((e+t)/n)-Math.floor(e/n)}function El(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 Ch(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 _h(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 xh(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 ks(e,t,n){switch(e){case"linear":return El(t,n);case"exponential":return Ch(t,n);case"sCurve":return _h(t,n);case"logarithmic":return xh(t,n);default:return El(t,n)}}function Va(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=ks(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 La(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=ks(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 ga={exports:{}},Ml;function Sh(){return Ml||(Ml=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(g){return typeof g}:function(g){return g&&typeof Symbol=="function"&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g})(h)}function c(h,g){for(var y=0;y<g.length;y++){var v=g[y];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(h,v.key,v)}}function u(h){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(g){return g.__proto__||Object.getPrototypeOf(g)})(h)}function f(h,g){return(f=Object.setPrototypeOf||function(y,v){return y.__proto__=v,y})(h,g)}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 g(b){var w,C,_,S,k,I;return(function(E,A){if(!(E instanceof A))throw new TypeError("Cannot call a class as a function")})(this,g),C=this,w=!(_=u(g).call(this,b.id,b.length,b.buffer,b.subChunks))||l(_)!=="object"&&typeof _!="function"?p(C):_,S=p(p(w)),I=void 0,(k="subChunks")in S?Object.defineProperty(S,k,{value:I,enumerable:!0,configurable:!0,writable:!0}):S[k]=I,w.subChunks=b.subChunks.map((function(E){return new g(E)})),w}var y,v;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)})(g,h),y=g,(v=[{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,C){if(C.id==="ifil"||C.id==="iver"){if(C.length!==o.SF_VERSION_LENGTH)throw new a.ParseError("Invalid size for the '".concat(C.id,"' sub-chunk"));w[C.id]="".concat(C.getInt16(),".").concat(C.getInt16(2))}else w[C.id]=C.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(y.prototype,v),g})(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 g=h.getInt16();return o.GeneratorType[g]?d==="pgen"&&l.includes(g)||d==="igen"&&c.includes(g)?null:u.includes(g)?{id:g,range:{lo:h.getByte(),hi:h.getByte()}}:{id:g,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(g){return{generatorIndex:g.getInt16(),modulatorIndex:g.getInt16()}}))},c=function(d,h,g,y,v,b){for(var w=[],C=0;C<d.length;C++){for(var _=d[C],S=d[C+1],k=_.bagIndex,I=S?S.bagIndex:h.length,E=[],A=void 0,R=k;R<I;R++){var T=u(R,h,g),M=f(R,h,y),$=M[i.GeneratorType.KeyRange]&&M[i.GeneratorType.KeyRange].range,O=M[b];if(O){var P=v[O.value];P&&E.push({keyRange:$,modulators:T,generators:M,reference:P})}else R-k==0&&(A={keyRange:$,modulators:T,generators:M})}w.push({header:_,globalZone:A,zones:E})}return w},u=function(d,h,g){var y=h[d],v=h[d+1],b=y.modulatorIndex,w=v?v.modulatorIndex:h.length;return p(b,w,g)},f=function(d,h,g){var y=h[d],v=h[d+1],b=y.generatorIndex,w=v?v.generatorIndex:h.length;return p(b,w,g)},p=function(d,h,g){for(var y={},v=d;v<h;v++){var b=g[v];b&&(y[b.id]=b)}return y}},"./src/constants.ts":function(n,r,s){s.r(r),s.d(r,"SF_VERSION_LENGTH",(function(){return 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(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g})(d):h}function i(d){var h=typeof Map=="function"?new Map:void 0;return(i=function(g){if(g===null||(y=g,Function.toString.call(y).indexOf("[native code]")===-1))return g;var y;if(typeof g!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(g))return h.get(g);h.set(g,v)}function v(){return c(g,arguments,f(this).constructor)}return v.prototype=Object.create(g.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),u(v,g)})(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,g){return(c=l()?Reflect.construct:function(y,v,b){var w=[null];w.push.apply(w,v);var C=new(Function.bind.apply(y,w));return b&&u(C,b.prototype),C}).apply(null,arguments)}function u(d,h){return(u=Object.setPrototypeOf||function(g,y){return g.__proto__=y,g})(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(g,y,v){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(g).concat(y&&v?", expected ".concat(y,", received ").concat(v):"")))}return(function(g,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function");g.prototype=Object.create(y&&y.prototype,{constructor:{value:g,writable:!0,configurable:!0}}),y&&u(g,y)})(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 g=p(d,8);if(g!=="sfbk")throw new a.ParseError("Invalid signature","sfbk",g);var y=d.subarray(8),v=f(y.subarray(4));return new i.RIFFChunk(h,y.length,y,v)},c=function(d,h){var g=p(d,h),y=u(d,h+4),v=[];return g!=="RIFF"&&g!=="LIST"||(v=f(d.subarray(h+12))),new i.RIFFChunk(g,y,d.subarray(h+8),v)},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=[],g=0;g<=d.length-8;){var y=c(d,g);h.push(y),g=(g+=8+y.length)%2?g+1:g}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,g,y){(function(v,b){if(!(v 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=g,this.subChunks=y}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,g=new a.ChunkIterator(this,h);return g.iterate(d),g.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(g){for(var y=1;y<arguments.length;y++){var v=arguments[y]!=null?arguments[y]:{},b=Object.keys(v);typeof Object.getOwnPropertySymbols=="function"&&(b=b.concat(Object.getOwnPropertySymbols(v).filter((function(w){return Object.getOwnPropertyDescriptor(v,w).enumerable})))),b.forEach((function(w){d(g,w,v[w])}))}return g}function f(g,y){for(var v=0;v<y.length;v++){var b=y[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}function p(g,y,v){return y&&f(g.prototype,y),v&&f(g,v),g}function d(g,y,v){return y in g?Object.defineProperty(g,y,{value:v,enumerable:!0,configurable:!0,writable:!0}):g[y]=v,g}var h=(function(){function g(y){if((function(b,w){if(!(b instanceof w))throw new TypeError("Cannot call a class as a function")})(this,g),d(this,"chunk",void 0),d(this,"metaData",void 0),d(this,"sampleData",void 0),d(this,"samples",void 0),d(this,"presetData",void 0),d(this,"instruments",void 0),d(this,"presets",void 0),d(this,"banks",void 0),!(y instanceof o.SF2Chunk)){var v=Object(i.parseBuffer)(y);y=new o.SF2Chunk(v)}if(y.subChunks.length!==3)throw new i.ParseError("Invalid sfbk structure","3 chunks","".concat(y.subChunks.length," chunks"));this.chunk=y,this.metaData=y.subChunks[0].getMetaData(),this.sampleData=y.subChunks[1].getSampleData(),this.presetData=y.subChunks[2].getPresetData(),this.samples=this.getSamples(),this.instruments=this.getInstruments(),this.presets=this.getPresets(),this.banks=this.getBanks()}return p(g,null,[{key:"from",value:function(y){return new g(y)}}]),p(g,[{key:"getKeyData",value:function(y){var v=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(C,_,S){var k=v.banks[_];if(k){var I=k.presets[S];if(I){var E=I.zones.filter((function(q){return v.isKeyInRange(q,C)}));if(E.length>0){var A=!0,R=!1,T=void 0;try{for(var M,$=E[Symbol.iterator]();!(A=(M=$.next()).done);A=!0){var O=M.value,P=O.instrument,V=P.zones.filter((function(q){return v.isKeyInRange(q,C)}));if(V.length>0){var X=!0,ge=!1,re=void 0;try{for(var se,Ie=V[Symbol.iterator]();!(X=(se=Ie.next()).done);X=!0){var j=se.value,_e=j.sample,te=u({},O.generators,j.generators),mt=u({},O.modulators,j.modulators);return{keyNumber:C,preset:I,instrument:P,sample:_e,generators:te,modulators:mt}}}catch(q){ge=!0,re=q}finally{try{X||Ie.return==null||Ie.return()}finally{if(ge)throw re}}}}}catch(q){R=!0,T=q}finally{try{A||$.return==null||$.return()}finally{if(R)throw T}}}}}return null}))(y,b,w)}},{key:"isKeyInRange",value:function(y,v){return y.keyRange===void 0||y.keyRange.lo<=v&&y.keyRange.hi>=v}},{key:"getBanks",value:function(){return this.presets.reduce((function(y,v){var b=v.header.bank;return y[b]||(y[b]={presets:[]}),y[b].presets[v.header.preset]=v,y}),[])}},{key:"getPresets",value:function(){var y=this.presetData,v=y.presetHeaders,b=y.presetZones,w=y.presetGenerators,C=y.presetModulators;return Object(l.getItemsInZone)(v,b,C,w,this.instruments,a.GeneratorType.Instrument).filter((function(_){return _.header.name!=="EOP"})).map((function(_){return{header:_.header,globalZone:_.globalZone,zones:_.zones.map((function(S){return{keyRange:S.keyRange,generators:S.generators,modulators:S.modulators,instrument:S.reference}}))}}))}},{key:"getInstruments",value:function(){var y=this.presetData,v=y.instrumentHeaders,b=y.instrumentZones,w=y.instrumentModulators,C=y.instrumentGenerators;return Object(l.getItemsInZone)(v,b,w,C,this.samples,a.GeneratorType.SampleId).filter((function(_){return _.header.name!=="EOI"})).map((function(_){return{header:_.header,globalZone:_.globalZone,zones:_.zones.map((function(S){return{keyRange:S.keyRange,generators:S.generators,modulators:S.modulators,sample:S.reference}}))}}))}},{key:"getSamples",value:function(){var y=this;return this.presetData.sampleHeaders.filter((function(v){return v.name!=="EOS"})).map((function(v){if(v.name!=="EOS"&&v.sampleRate<=0)throw new Error("Illegal sample rate of ".concat(v.sampleRate," hz in sample '").concat(v.name,"'"));return v.originalPitch>=128&&v.originalPitch<=254&&(v.originalPitch=60),v.startLoop-=v.start,v.endLoop-=v.start,{header:v,data:new Int16Array(new Uint8Array(y.sampleData.subarray(2*v.start,2*v.end)).buffer)}}))}}]),g})()},"./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(y){s.d(r,y,(function(){return a[y]}))})(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(v){s.d(r,v,(function(){return l[v]}))})(o);var c=s("./src/types/key.ts");for(var o in c)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(v){s.d(r,v,(function(){return c[v]}))})(o);var u=s("./src/types/metaData.ts");for(var o in u)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(v){s.d(r,v,(function(){return u[v]}))})(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(v){s.d(r,v,(function(){return p[v]}))})(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(v){s.d(r,v,(function(){return d[v]}))})(o);var h=s("./src/types/sample.ts");s.d(r,"SampleType",(function(){return h.SampleType}));var g=s("./src/types/zone.ts");for(var o in g)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS","SampleType"].indexOf(o)<0&&(function(v){s.d(r,v,(function(){return g[v]}))})(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}}}})}))})(ga)),ga.exports}Sh();var Tl=!1;function _r(e){const t=e._param;return!t&&!Tl&&(Tl=!0,console.warn("[waveform-playlist] Unable to access Tone.js internal _param. This likely means the Tone.js version is incompatible. Mute scheduling may not work correctly.")),t}var kh=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new W.Volume(this.gainToDb(e.track.gain)),this.panNode=new W.Panner({pan:e.track.stereoPan,channelCount:2}),this.muteGain=new W.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||W.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=W.getTransport(),s=W.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=W.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)Va(a,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,c=o/i,u=r.gain*c;Va(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;La(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);La(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;_r(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=W.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 Ih(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 Ah=class{constructor(e){this.track=e.track,this.volumeNode=new W.Volume(this.gainToDb(e.track.gain)),this.panNode=new W.Panner(e.track.stereoPan),this.muteGain=new W.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain),this.synth=new W.PolySynth(W.Synth,e.synthOptions),this.synth.connect(this.volumeNode),this.kickSynth=new W.PolySynth(W.MembraneSynth,{voice:W.MembraneSynth,options:{pitchDecay:.05,octaves:6,envelope:{attack:.001,decay:.4,sustain:0,release:.1}}}),this.snareSynth=new W.NoiseSynth({noise:{type:"white"},envelope:{attack:.001,decay:.15,sustain:0,release:.05}}),this.cymbalSynth=new W.PolySynth(W.MetalSynth,{voice:W.MetalSynth,options:{envelope:{attack:.001,decay:.3,release:.1},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5}}),this.tomSynth=new W.PolySynth(W.MembraneSynth,{voice:W.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||W.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 W.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(Ih(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=W.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;_r(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 Na{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 W.Volume(this.gainToDb(t.track.gain)),this.panNode=new W.Panner(t.track.stereoPan),this.muteGain=new W.Gain(t.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const n=t.destination||W.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 W.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){Na._missingSampleWarned||(console.warn(`[waveform-playlist] SoundFont sample not found for MIDI note ${t} (bank ${o}, preset ${i}). Subsequent missing samples will be silent.`),Na._missingSampleWarned=!0);return}const c=W.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:g,holdVolEnv:y,decayVolEnv:v,sustainVolEnv:b,releaseVolEnv:w}=l,C=d*b;h.gain.setValueAtTime(0,r),h.gain.linearRampToValueAtTime(d,r+g),y>.001&&h.gain.setValueAtTime(d,r+g+y);const _=r+g+y;h.gain.linearRampToValueAtTime(C,_+v),h.gain.setValueAtTime(C,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;_r(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 Eh=Mc,Mh=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 W.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,W.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{W.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await W.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new kh(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 Ah(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 Eh(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??W.now(),s=W.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=W.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=W.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=W.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=W.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 W.getTransport().seconds}seekTo(e){W.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 W.getContext()}get sampleRate(){return W.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},ns=null;function Is(){return ns||(ns=new W.Context,W.setContext(ns)),ns}function Th(){return Is().rawContext}function Rh(e){let t=null,n=!1,r=0,s=!1,a=0,o=0,i=!1;function l(u,f){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(ts)),g=Math.max(...p.map(kl)),y={id:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:g},v=p.map(b=>({buffer:b.audioBuffer,startTime:ts(b)-h,duration:Al(b),offset:Il(b),fadeIn:b.fadeIn,fadeOut:b.fadeOut,gain:b.gain}));u.addTrack({clips:v,track:y,effects:f.effects})}if(d.length>0){const h=Math.min(...d.map(ts)),g=Math.max(...d.map(kl)),v={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:g},b=d.map(w=>({notes:w.midiNotes,startTime:ts(w)-h,duration:Al(w),offset:Il(w)}));if(e?.soundFontCache?.isLoaded){const w=d[0],_=w.midiChannel===9,S=w.midiProgram??0;u.addSoundFontTrack({clips:b,track:v,soundFontCache:e.soundFontCache,programNumber:S,isPercussion:_,effects:f.effects})}else e?.soundFontCache&&console.warn(`[waveform-playlist] SoundFont not loaded for track "${f.name}" — falling back to PolySynth.`),u.addMidiTrack({clips:b,track:v,effects:f.effects})}}function c(u){if(t){try{t.dispose()}catch(p){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",p)}t=null}r++;const f=r;t=new Mh({effects:e?.effects}),i&&t.init().catch(p=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",p),i=!1});for(const p of u)l(t,p);t.applyInitialSoloState(),t.setLoop(s,a,o),t.setOnPlaybackComplete(()=>{f===r&&(n=!1)})}return{async init(){t&&(await t.init(),i=!0)},setTracks(u){c(u)},addTrack(u){if(!t)throw new Error("[waveform-playlist] adapter.addTrack() called but no playout exists. Call setTracks() first to initialize the playout.");l(t,u),t.applyInitialSoloState()},play(u,f){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 p=f!==void 0?f-u:void 0;t.play(W.now(),u,p),n=!0},pause(){t?.pause(),n=!1},stop(){t?.stop(),n=!1},seek(u){t?.seekTo(u)},getCurrentTime(){return t?.getCurrentTime()??0},isPlaying(){return n},setMasterVolume(u){t?.setMasterGain(u)},setTrackVolume(u,f){t?.getTrack(u)?.setVolume(f)},setTrackMute(u,f){t?.setMute(u,f)},setTrackSolo(u,f){t?.setSolo(u,f)},setTrackPan(u,f){t?.getTrack(u)?.setPan(f)},setLoop(u,f,p){s=u,a=f,o=p,t?.setLoop(u,f,p)},dispose(){try{t?.dispose()}catch(u){console.warn("[waveform-playlist] Error disposing playout:",u)}t=null,n=!1}}}function Tc(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 Rc(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 $h(e,t){return Math.floor(e/t)*t}function Dh(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=Oa({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=Oa({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 $c(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 va(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 Ph(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 Rl(e,t){return Math.max(0,Math.min(e,t))}var Fh=44100,Oh=1024,Bh=[256,512,1024,2048,4096,8192],$l=.1,Wh=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??Fh,this._zoomLevels=[...e.zoomLevels??Bh],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??Oh,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:va(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?.addTrack?this._adapter.addTrack(e):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=_l(r.clips),i=o.findIndex(c=>c.id===t),l=Tc(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($l*this._sampleRate);if(!$c(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}=Dh(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=_l(s.clips),l=i.findIndex(f=>f.id===t),c=Math.floor($l*this._sampleRate),u=Rc(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=va(this._tracks);this._currentTime=Rl(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=va(this._tracks);this._currentTime=Rl(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=Ph(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)}},Vh=Symbol.for("preact-signals");function Us(){if(Qt>1)Qt--;else{for(var e,t=!1;gr!==void 0;){var n=gr;for(gr=void 0,Za++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Pc(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(Za=0,Qt--,t)throw e}}function qt(e){if(Qt>0)return e();Qt++;try{return e()}finally{Us()}}var ve=void 0;function Ce(e){var t=ve;ve=void 0;try{return e()}finally{ve=t}}var gr=void 0,Qt=0,Za=0,As=0;function Dc(e){if(ve!==void 0){var t=e.n;if(t===void 0||t.t!==ve)return t={i:0,S:e,p:ve.s,n:void 0,t:ve,e:void 0,x:void 0,r:t},ve.s!==void 0&&(ve.s.n=t),ve.s=t,e.n=t,32&ve.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=ve.s,t.n=void 0,ve.s.n=t,ve.s=t),t}}function st(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}st.prototype.brand=Vh;st.prototype.h=function(){return!0};st.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:Ce(function(){var r;(r=t.W)==null||r.call(t)}))};st.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&Ce(function(){var s;(s=t.Z)==null||s.call(t)}))}};st.prototype.subscribe=function(e){var t=this;return At(function(){var n=t.value,r=ve;ve=void 0;try{e(n)}finally{ve=r}},{name:"sub"})};st.prototype.valueOf=function(){return this.value};st.prototype.toString=function(){return this.value+""};st.prototype.toJSON=function(){return this.value};st.prototype.peek=function(){var e=ve;ve=void 0;try{return this.value}finally{ve=e}};Object.defineProperty(st.prototype,"value",{get:function(){var e=Dc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Za>100)throw new Error("Cycle detected");this.v=e,this.i++,As++,Qt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Us()}}}});function Dr(e,t){return new st(e,t)}function Pc(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 Fc(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 Oc(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 vn(e,t){st.call(this,void 0),this.x=e,this.s=void 0,this.g=As-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}vn.prototype=new st;vn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===As))return!0;if(this.g=As,this.f|=1,this.i>0&&!Pc(this))return this.f&=-2,!0;var e=ve;try{Fc(this),ve=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 ve=e,Oc(this),this.f&=-2,!0};vn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}st.prototype.S.call(this,e)};vn.prototype.U=function(e){if(this.t!==void 0&&(st.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};vn.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(vn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Dc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Dl(e,t){return new vn(e,t)}function Bc(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Qt++;var n=ve;ve=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,To(e),r}finally{ve=n,Us()}}}function To(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Bc(e)}function Lh(e){if(ve!==this)throw new Error("Out-of-order effect");Oc(this),ve=e,this.f&=-2,8&this.f&&To(this),Us()}function Xn(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}Xn.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()}};Xn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Bc(this),Fc(this),Qt++;var e=ve;return ve=this,Lh.bind(this,e)};Xn.prototype.N=function(){2&this.f||(this.f|=2,this.o=gr,gr=this)};Xn.prototype.d=function(){this.f|=8,1&this.f||To(this)};Xn.prototype.dispose=function(){this.d()};function At(e,t){var n=new Xn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Nh=Object.create,Ro=Object.defineProperty,Zh=Object.defineProperties,Gh=Object.getOwnPropertyDescriptor,zh=Object.getOwnPropertyDescriptors,Pl=Object.getOwnPropertySymbols,jh=Object.prototype.hasOwnProperty,Hh=Object.prototype.propertyIsEnumerable,Xh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Yn=e=>{throw TypeError(e)},Ga=(e,t,n)=>t in e?Ro(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yh=(e,t)=>{for(var n in t||(t={}))jh.call(t,n)&&Ga(e,n,t[n]);if(Pl)for(var n of Pl(t))Hh.call(t,n)&&Ga(e,n,t[n]);return e},Uh=(e,t)=>Zh(e,zh(t)),Fl=(e,t)=>Ro(e,"name",{value:t,configurable:!0}),Kh=e=>{var t;return[,,,Nh((t=void 0)!=null?t:null)]},Wc=["class","method","getter","setter","accessor","field","value","get","set"],ar=e=>e!==void 0&&typeof e!="function"?Yn("Function expected"):e,Qh=(e,t,n,r,s)=>({kind:Wc[e],name:t,metadata:r,addInitializer:a=>n._?Yn("Already initialized"):s.push(ar(a||null))}),Vc=(e,t)=>Ga(t,Xh("metadata"),e[3]),an=(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},Un=(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,g=Wc[f+5],y=f>3&&(e[h-1]=[]),v=e[h]||(e[h]=[]),b=f&&(!d&&!p&&(s=s.prototype),f<5&&(f>3||!d)&&Gh(f<4?s:{get[n](){return hn(this,a)},set[n](C){return Yt(this,a,C)}},n));f?d&&f<4&&Fl(a,(f>2?"set ":f>1?"get ":"")+n):Fl(s,n);for(var w=r.length-1;w>=0;w--)c=Qh(f,n,l={},e[3],v),f&&(c.static=p,c.private=d,u=c.access={has:d?C=>qh(s,C):C=>n in C},f^3&&(u.get=d?C=>(f^1?hn:Jh)(C,s,f^4?a:b.get):C=>C[n]),f>2&&(u.set=d?(C,_)=>Yt(C,s,_,f^4?a:b.set):(C,_)=>C[n]=_)),i=(0,r[w])(f?f<4?d?a:b[g]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?ar(i)&&(f>4?y.unshift(i):f?d?a=i:b[g]=i:s=i):typeof i!="object"||i===null?Yn("Object expected"):(ar(o=i.get)&&(b.get=o),ar(o=i.set)&&(b.set=o),ar(o=i.init)&&y.unshift(o));return f||Vc(e,s),b&&Ro(s,n,b),d?f^4?a:b:s},$o=(e,t,n)=>t.has(e)||Yn("Cannot "+n),qh=(e,t)=>Object(t)!==t?Yn('Cannot use the "in" operator on this value'):e.has(t),hn=(e,t,n)=>($o(e,t,"read from private field"),n?n.call(e):t.get(e)),rs=(e,t,n)=>t.has(e)?Yn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Yt=(e,t,n,r)=>($o(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Jh=(e,t,n)=>($o(e,t,"access private method"),n);function Es(e,t){if(t){let n;return Dl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return Dl(e)}function xr(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)=>!xr(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=>!xr(e[a],t[a]))}return!1}function pe({get:e},t){return{init(n){return Dr(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Re(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Es(e.bind(this)),n.set(this,r)),r.value}}function ya(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,Uh(Yh({},s),{enumerable:e}))})}}function Pr(...e){const t=e.map(n=>At(n));return()=>t.forEach(n=>n())}var Lc,Nc,Zc,Gc,zc,jc,tt,Do,ba,za,ja,Qe,Po,wa,Hc,Ha,Fo,Ca,Xa,Ya;jc=[pe],zc=[pe],Gc=[pe],Zc=[ya()],Nc=[ya()],Lc=[ya()];var en=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,an(tt,5,this),rs(this,Qe),rs(this,Do,an(tt,8,this)),an(tt,11,this),rs(this,Po,an(tt,12,this)),an(tt,15,this),rs(this,Fo,an(tt,16,this)),an(tt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return hn(this,Qe,Xa)}get initial(){return hn(this,Qe,za)}get previous(){return hn(this,Qe,Hc)}set current(e){const t=Ce(()=>hn(this,Qe,Xa));e&&t&&this.equals(t,e)||qt(()=>{hn(this,Qe,za)||Yt(this,Qe,e,ja),Yt(this,Qe,t,Ha),Yt(this,Qe,e,Ya)})}reset(e=this.defaultValue){qt(()=>{Yt(this,Qe,void 0,Ha),Yt(this,Qe,e,ja),Yt(this,Qe,e,Ya)})}};tt=Kh();Do=new WeakMap;Qe=new WeakSet;Po=new WeakMap;Fo=new WeakMap;ba=Un(tt,20,"#initial",jc,Qe,Do),za=ba.get,ja=ba.set;wa=Un(tt,20,"#previous",zc,Qe,Po),Hc=wa.get,Ha=wa.set;Ca=Un(tt,20,"#current",Gc,Qe,Fo),Xa=Ca.get,Ya=Ca.set;Un(tt,2,"current",Zc,en);Un(tt,2,"initial",Nc,en);Un(tt,2,"previous",Lc,en);Vc(tt,en);function _a(e){return Ce(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var ep=Object.create,Xc=Object.defineProperty,tp=Object.getOwnPropertyDescriptor,Ol=Object.getOwnPropertySymbols,np=Object.prototype.hasOwnProperty,rp=Object.prototype.propertyIsEnumerable,Yc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ks=e=>{throw TypeError(e)},Bl=Math.pow,Ua=(e,t,n)=>t in e?Xc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sp=(e,t)=>{for(var n in t||(t={}))np.call(t,n)&&Ua(e,n,t[n]);if(Ol)for(var n of Ol(t))rp.call(t,n)&&Ua(e,n,t[n]);return e},ap=e=>{var t;return[,,,ep((t=e?.[Yc("metadata")])!=null?t:null)]},Uc=["class","method","getter","setter","accessor","field","value","get","set"],Kc=e=>e!==void 0&&typeof e!="function"?Ks("Function expected"):e,op=(e,t,n,r,s)=>({kind:Uc[e],name:t,metadata:r,addInitializer:a=>n._?Ks("Already initialized"):s.push(Kc(a||null))}),ip=(e,t)=>Ua(t,Yc("metadata"),e[3]),lp=(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},Qc=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,p=!1,d=2,h=Uc[u+5],g=e[d]||(e[d]=[]),y=(s=s.prototype,tp(s,n)),v=r.length-1;v>=0;v--)l=op(u,n,i={},e[3],g),l.static=f,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[v])(y[h],l),i._=1,Kc(o)&&(y[h]=o);return y&&Xc(s,n,y),s},qc=(e,t,n)=>t.has(e)||Ks("Cannot "+n),cp=(e,t,n)=>(qc(e,t,"read from private field"),t.get(e)),up=(e,t,n)=>t.has(e)?Ks("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),dp=(e,t,n,r)=>(qc(e,t,"write to private field"),t.set(e,n),n),Pt=class Ka{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ka(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 Ka(t,n)}},Fr=class ln{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 ln(s+t,r+n,a,o);return l.scale=sp({},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 Pt((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof ln))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 ln?fp(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 ln(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 Pt.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return ln.from(t).intersectionRatio(ln.from(n))}};function fp(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 Jc,eu,Qa,ds,Or,Qs=class extends(Qa=en,eu=[Re],Jc=[Re],Qa){constructor(t){const n=Pt.from(t);super(n,(r,s)=>Pt.equals(r,s)),lp(Or,5,this),up(this,ds,0),this.velocity={x:0,y:0}}get delta(){return Pt.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Pt.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-cp(this,ds),i=l=>Math.round(l/o*100);qt(()=>{dp(this,ds,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Pt.from(t)),this.velocity={x:0,y:0}}};Or=ap(Qa);ds=new WeakMap;Qc(Or,2,"delta",eu,Qs);Qc(Or,2,"direction",Jc,Qs);ip(Or,Qs);function qa({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(Bl(r,2)+Bl(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 tu=(e=>(e.Horizontal="x",e.Vertical="y",e))(tu||{}),nu=Object.values(tu),hp=Object.create,Oo=Object.defineProperty,pp=Object.defineProperties,mp=Object.getOwnPropertyDescriptor,gp=Object.getOwnPropertyDescriptors,Ms=Object.getOwnPropertySymbols,ru=Object.prototype.hasOwnProperty,su=Object.prototype.propertyIsEnumerable,au=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Kn=e=>{throw TypeError(e)},Ja=(e,t,n)=>t in e?Oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ou=(e,t)=>{for(var n in t||(t={}))ru.call(t,n)&&Ja(e,n,t[n]);if(Ms)for(var n of Ms(t))su.call(t,n)&&Ja(e,n,t[n]);return e},iu=(e,t)=>pp(e,gp(t)),Wl=(e,t)=>Oo(e,"name",{value:t,configurable:!0}),lu=(e,t)=>{var n={};for(var r in e)ru.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ms)for(var r of Ms(e))t.indexOf(r)<0&&su.call(e,r)&&(n[r]=e[r]);return n},Qn=e=>{var t;return[,,,hp((t=e?.[au("metadata")])!=null?t:null)]},cu=["class","method","getter","setter","accessor","field","value","get","set"],or=e=>e!==void 0&&typeof e!="function"?Kn("Function expected"):e,vp=(e,t,n,r,s)=>({kind:cu[e],name:t,metadata:r,addInitializer:a=>n._?Kn("Already initialized"):s.push(or(a||null))}),yn=(e,t)=>Ja(t,au("metadata"),e[3]),ee=(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},de=(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,g=cu[f+5],y=f>3&&(e[h-1]=[]),v=e[h]||(e[h]=[]),b=f&&(!d&&!p&&(s=s.prototype),f<5&&(f>3||!d)&&mp(f<4?s:{get[n](){return Ne(this,a)},set[n](C){return St(this,a,C)}},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=vp(f,n,l={},e[3],v),f&&(c.static=p,c.private=d,u=c.access={has:d?C=>yp(s,C):C=>n in C},f^3&&(u.get=d?C=>(f^1?Ne:bp)(C,s,f^4?a:b.get):C=>C[n]),f>2&&(u.set=d?(C,_)=>St(C,s,_,f^4?a:b.set):(C,_)=>C[n]=_)),i=(0,r[w])(f?f<4?d?a:b[g]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?or(i)&&(f>4?y.unshift(i):f?d?a=i:b[g]=i:s=i):typeof i!="object"||i===null?Kn("Object expected"):(or(o=i.get)&&(b.get=o),or(o=i.set)&&(b.set=o),or(o=i.init)&&y.unshift(o));return f||yn(e,s),b&&Oo(s,n,b),d?f^4?a:b:s},Bo=(e,t,n)=>t.has(e)||Kn("Cannot "+n),yp=(e,t)=>Object(t)!==t?Kn('Cannot use the "in" operator on this value'):e.has(t),Ne=(e,t,n)=>(Bo(e,t,"read from private field"),n?n.call(e):t.get(e)),we=(e,t,n)=>t.has(e)?Kn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),St=(e,t,n,r)=>(Bo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),bp=(e,t,n)=>(Bo(e,t,"access private method"),n);function uu(e,t){return{plugin:e,options:t}}function bn(e){return t=>uu(e,t)}function Wo(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var du,Sr,Vo,fs;du=[pe];var pt=class{constructor(e,t){this.manager=e,this.options=t,we(this,Vo,ee(Sr,8,this,!1)),ee(Sr,11,this),we(this,fs,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return Ce(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=At(e.bind(this));return Ne(this,fs).add(t),t}destroy(){Ne(this,fs).forEach(e=>e())}static configure(e){return uu(this,e)}};Sr=Qn(null);Vo=new WeakMap;fs=new WeakMap;de(Sr,4,"disabled",du,pt,Vo);yn(Sr,pt);var Br=class extends pt{},hs,xa=class{constructor(e){this.manager=e,this.instances=new Map,we(this,hs,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(Wo).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,hs))if(!n.includes(r)){if(r.prototype instanceof Br)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);St(this,hs,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()}};hs=new WeakMap;function wp(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var ss=[],Tn,Rn,Cp=class extends pt{constructor(e){super(e),we(this,Tn),we(this,Rn),this.computeCollisions=this.computeCollisions.bind(this),St(this,Rn,Dr(ss)),this.destroy=Pr(()=>{const t=this.computeCollisions(),n=Ce(()=>this.manager.dragOperation.position.current);if(t!==ss){const r=Ne(this,Tn);if(St(this,Tn,n),r&&n.x==r.x&&n.y==r.y)return}else St(this,Tn,void 0);Ne(this,Rn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){Ce(()=>{e?Ne(this,Rn).value=this.computeCollisions():St(this,Tn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:a,status:o}=r;if(!o.initialized||!a)return ss;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=Ce(()=>u({droppable:c,dragOperation:r}));f&&(c.collisionPriority!=null&&(f.priority=c.collisionPriority),i.push(f))}return l.length===0?ss:(i.sort(wp),i)}get collisions(){return Ne(this,Rn).value}};Tn=new WeakMap;Rn=new WeakMap;var _p=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)}},xp=class extends _p{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ps(e,t=!0){let n=!1;return iu(ou({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Sp=class extends Br{constructor(e){super(e);const t=(r,s)=>r.map(({id:a})=>a).join("")===s.map(({id:a})=>a).join("");let n=[];this.destroy=Pr(()=>{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=ps({collisions:a});if(s.dispatch("collision",o),o.defaultPrevented||t(a,n))return;n=a;const[i]=a;Ce(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},Lo=(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))(Lo||{}),No=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(No||{}),fu,hu,pu,mu,gu,vu,yu,It,Zo;yu=[pe],vu=[Re],gu=[Re],mu=[Re],pu=[Re],hu=[Re],fu=[Re];var Zt=class{constructor(){ee(It,5,this),we(this,Zo,ee(It,8,this,"idle")),ee(It,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}};It=Qn(null);Zo=new WeakMap;de(It,4,"value",yu,Zt,Zo);de(It,2,"current",vu,Zt);de(It,2,"idle",gu,Zt);de(It,2,"initializing",mu,Zt);de(It,2,"initialized",pu,Zt);de(It,2,"dragging",hu,Zt);de(It,2,"dropped",fu,Zt);yn(It,Zt);var kp=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 Ce(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=ps({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return Ce(()=>{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;qt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(a)});const o=ps({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 Ce(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:a}=r;if(!s.dragging||!a||a.signal.aborted)return;const o=ps({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 Ce(()=>{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=Ce(()=>{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=At(()=>{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()})}},bu,wu,Cu,_u,ht,Go,zo,jo,Ho;_u=[pe],Cu=[pe],wu=[pe],bu=[pe];var tn=class{constructor(e,t){we(this,Go,ee(ht,8,this)),ee(ht,11,this),we(this,zo,ee(ht,12,this)),ee(ht,15,this),we(this,jo,ee(ht,16,this)),ee(ht,19,this),we(this,Ho,ee(ht,20,this)),ee(ht,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)}};ht=Qn(null);Go=new WeakMap;zo=new WeakMap;jo=new WeakMap;Ho=new WeakMap;de(ht,4,"manager",_u,tn,Go);de(ht,4,"id",Cu,tn,zo);de(ht,4,"data",wu,tn,jo);de(ht,4,"disabled",bu,tn,Ho);yn(ht,tn);var Vl=class{constructor(){this.map=Dr(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=Pr(...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}},xu,Su,ku,Iu,Au,Eu,eo,nt,Xo,Yo,Uo,Ft=class extends(eo=tn,Eu=[pe],Au=[pe],Iu=[pe],ku=[Re],Su=[Re],xu=[Re],eo){constructor(t,n){var r=t,{modifiers:s,type:a,sensors:o}=r,i=lu(r,["modifiers","type","sensors"]);super(i,n),ee(nt,5,this),we(this,Xo,ee(nt,8,this)),ee(nt,11,this),we(this,Yo,ee(nt,12,this)),ee(nt,15,this),we(this,Uo,ee(nt,16,this,this.isDragSource?"dragging":"idle")),ee(nt,19,this),this.type=a,this.sensors=o,this.modifiers=s,this.alignment=i.alignment}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};nt=Qn(eo);Xo=new WeakMap;Yo=new WeakMap;Uo=new WeakMap;de(nt,4,"type",Eu,Ft,Xo);de(nt,4,"modifiers",Au,Ft,Yo);de(nt,4,"status",Iu,Ft,Uo);de(nt,2,"isDropping",ku,Ft);de(nt,2,"isDragging",Su,Ft);de(nt,2,"isDragSource",xu,Ft);yn(nt,Ft);var Mu,Tu,Ru,$u,Du,Pu,to,We,Ko,Qo,qo,Jo,ei,Ot=class extends(to=tn,Pu=[pe],Du=[pe],$u=[pe],Ru=[pe],Tu=[pe],Mu=[Re],to){constructor(t,n){var r=t,{accept:s,collisionDetector:a,collisionPriority:o,type:i}=r,l=lu(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),ee(We,5,this),we(this,Ko,ee(We,8,this)),ee(We,11,this),we(this,Qo,ee(We,12,this)),ee(We,15,this),we(this,qo,ee(We,16,this)),ee(We,19,this),we(this,Jo,ee(We,20,this)),ee(We,23,this),we(this,ei,ee(We,24,this)),ee(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=Qn(to);Ko=new WeakMap;Qo=new WeakMap;qo=new WeakMap;Jo=new WeakMap;ei=new WeakMap;de(We,4,"accept",Pu,Ot,Ko);de(We,4,"type",Du,Ot,Qo);de(We,4,"collisionDetector",$u,Ot,qo);de(We,4,"collisionPriority",Ru,Ot,Jo);de(We,4,"shape",Tu,Ot,ei);de(We,2,"isDropTarget",Mu,Ot);yn(We,Ot);var Ln=class extends pt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Ip=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)}},ms,Fu=class{constructor(e){this.options=e,we(this,ms)}set controller(e){St(this,ms,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ne(this,ms))==null||t.activate(e)}};ms=new WeakMap;var Nn=class extends pt{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Ap=class{constructor(e){this.draggables=new Vl,this.droppables=new Vl,this.plugins=new xa(e),this.sensors=new xa(e),this.modifiers=new xa(e)}register(e,t){if(e instanceof Ft)return this.draggables.register(e.id,e);if(e instanceof Ot)return this.droppables.register(e.id,e);if(e.prototype instanceof Nn)return this.modifiers.register(e,t);if(e.prototype instanceof Ln)return this.sensors.register(e,t);if(e.prototype instanceof pt)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof tn)return e instanceof Ft?this.draggables.unregister(e.id,e):e instanceof Ot?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Nn)return this.modifiers.unregister(e);if(e.prototype instanceof Ln)return this.sensors.unregister(e);if(e.prototype instanceof pt)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()}},Ou,Bu,Wu,Vu,Lu,Nu,Zu,Gu,zu,ir,gs,$n,De,ti,ni,ri,si,ai,lr;zu=[Re],Gu=[pe],Zu=[pe],Nu=[pe],Lu=[pe],Vu=[pe],Wu=[Re],Bu=[Re],Ou=[Re];var $t=class{constructor(e){ee(De,5,this),we(this,ir),we(this,gs),we(this,$n,new en(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Zt,we(this,ti,ee(De,8,this,!1)),ee(De,11,this),we(this,ni,ee(De,12,this,null)),ee(De,15,this),we(this,ri,ee(De,16,this,null)),ee(De,19,this),we(this,si,ee(De,20,this,null)),ee(De,23,this),we(this,ai,ee(De,24,this,[])),ee(De,27,this),this.position=new Qs({x:0,y:0}),we(this,lr,{x:0,y:0}),St(this,ir,e)}get shape(){const{current:e,initial:t,previous:n}=Ne(this,$n);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ne(this,$n).current=e:Ne(this,$n).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ne(this,ir).registry.draggables.get(t);return n&&St(this,gs,n),(e=n??Ne(this,gs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ne(this,ir).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(iu(ou({},this.snapshot()),{transform:n}));return St(this,lr,n),n}snapshot(){return Ce(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ne(this,lr),shape:this.shape?_a(this.shape):null,position:_a(this.position),status:_a(this.status),canceled:this.canceled}))}reset(){qt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ne(this,$n).reset(),this.position.reset({x:0,y:0}),St(this,lr,{x:0,y:0}),this.modifiers=[]})}};De=Qn(null);ir=new WeakMap;gs=new WeakMap;$n=new WeakMap;ti=new WeakMap;ni=new WeakMap;ri=new WeakMap;si=new WeakMap;ai=new WeakMap;lr=new WeakMap;de(De,2,"shape",zu,$t);de(De,4,"canceled",Gu,$t,ti);de(De,4,"activatorEvent",Zu,$t,ni);de(De,4,"sourceIdentifier",Nu,$t,ri);de(De,4,"targetIdentifier",Lu,$t,si);de(De,4,"modifiers",Vu,$t,ai);de(De,2,"source",Wu,$t);de(De,2,"target",Bu,$t);de(De,2,"transform",Ou,$t);yn(De,$t);var Ep={get rendering(){return Promise.resolve()}};function Vt(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=Vt(r.plugins,[]),a=Vt(r.sensors,[]),o=Vt(r.modifiers,[]),i=(n=r.renderer)!=null?n:Ep,l=new xp(this),c=new Ap(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new kp(this),this.dragOperation=new $t(this),this.collisionObserver=new Cp(this),this.plugins=[Sp,...s],this.modifiers=o,this.sensors=a;const{destroy:u}=this,f=Pr(()=>{var p,d,h;const g=Ce(()=>this.dragOperation.modifiers),y=this.modifiers;for(const v of g)y.includes(v)||v.destroy();this.dragOperation.modifiers=(h=(d=(p=this.dragOperation.source)==null?void 0:p.modifiers)==null?void 0:d.map(v=>{const{plugin:b,options:w}=Wo(v);return new b(this,w)}))!=null?h:y});this.destroy=()=>{f(),u()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},ju=e=>{throw TypeError(e)},oi=(e,t,n)=>t.has(e)||ju("Cannot "+n),ne=(e,t,n)=>(oi(e,t,"read from private field"),t.get(e)),ft=(e,t,n)=>t.has(e)?ju("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),bt=(e,t,n,r)=>(oi(e,t,"write to private field"),t.set(e,n),n),Hu=(e,t,n)=>(oi(e,t,"access private method"),n);function qs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Tp(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=(qs(s)?s.getKeyframes():[]).filter(t);if(o.length>0)return[o[o.length-1],r]}return null}function Js(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 ii(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Wr(e){return"nodeType"in e}function Et(e){var t,n,r;return e?ii(e)?e:Wr(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 li(e){const{Document:t}=Et(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function pn(e){return!e||ii(e)?!1:e instanceof Et(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Xu(e){return e instanceof Et(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function wn(e){return e?ii(e)?e.document:Wr(e)?li(e)?e:pn(e)||Xu(e)?e.ownerDocument:document:document:document}function Rp(e){var t,n,r,s;const{documentElement:a}=wn(e),o=Et(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 $p(e,t){if(Dp(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function Dp(e){return e.tagName==="DETAILS"}function Ts(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(!$p(f)){const w=f.getBoundingClientRect(),C=n*(w.bottom-w.top),_=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-C),right:Math.min(l.right,w.right+_),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,g=(o=p?.width)!=null?o:u.innerWidth,y=(i=p?.height)!=null?i:u.innerHeight,v=n*y,b=n*g;return l={top:Math.max(l.top,d-v),right:Math.min(l.right,h+g+b),bottom:Math.min(l.bottom,d+y+v),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 Zn(e){return{x:e.clientX,y:e.clientY}}var Yu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function no(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(...no(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(...no(s.document,t))}}catch{}return n}function ci(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Uu(){var e,t;const n=ci()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function ui(e){return!e||!Wr(e)?!1:e instanceof Et(e).ShadowRoot}function Rs(e){if(e&&Wr(e)){let t=e.getRootNode();if(ui(t))return t;if(t instanceof Document)return t}return wn(e)}function Ku(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Pp(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(Ll(a)&&Ll(i)&&(a.type!=="file"&&(a.value=i.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),Nl(a)&&Nl(i)&&i.width>0&&i.height>0){const l=a.getContext("2d");l?.drawImage(i,0,0)}}),n}function Ll(e){return"value"in e}function Nl(e){return e.tagName==="CANVAS"}function Qu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Fp(r)){const{contentDocument:s}=r;if(s){const{left:a,top:o}=r.getBoundingClientRect();return Qu(s,{x:t-a,y:n-o})}}return r}function Fp(e){return e?.tagName==="IFRAME"}var Zl=new WeakMap;function Op(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 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
|
-
:is(:root,:host) [${
|
|
8
|
+
`)}var qu=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 Gn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Bp(e){const t=new Set;let n=Gn(e);for(;n;)t.add(n),n=Gn(n);return t}function Wp(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Ju(e,t){const n=()=>performance.now();let r,s;return function(...a){const o=this;s?(r?.(),r=Wp(()=>{e.apply(o,a),s=n()},t-(n()-s))):(e.apply(o,a),s=n())}}function Vp(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 Lp(e,t=e.getBoundingClientRect()){const{width:n,height:r}=Ts(e,t);return n>0&&r>0}var Np=Yu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},vs,Zp=class extends Np{constructor(e){super(t=>{if(!ne(this,vs)){bt(this,vs,!0);return}e(t,this)}),ft(this,vs,!1)}};vs=new WeakMap;var Gl=Array.from({length:100},(e,t)=>t/100),ed=75,cn,$s,Ht,un,cr,ze,vr,ur,Ds,td,nd,rd=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ft(this,Ds),this.disconnect=()=>{var a,o,i;bt(this,vr,!0),(a=ne(this,Ht))==null||a.disconnect(),(o=ne(this,un))==null||o.disconnect(),ne(this,cr).disconnect(),(i=ne(this,ze))==null||i.remove()},ft(this,cn,!0),ft(this,$s),ft(this,Ht),ft(this,un),ft(this,cr),ft(this,ze),ft(this,vr,!1),ft(this,ur,Ju(()=>{var a,o,i;const{element:l}=this;if((a=ne(this,un))==null||a.disconnect(),ne(this,vr)||!ne(this,cn)||!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=Ts(l,p),{top:h,left:g,bottom:y,right:v}=d,b=-Math.floor(h),w=-Math.floor(g),C=-Math.floor(f-v),_=-Math.floor(u-y),S=`${b}px ${C}px ${_}px ${w}px`;this.boundingClientRect=p,bt(this,un,new IntersectionObserver(k=>{const[I]=k,{intersectionRect:E}=I;(I.intersectionRatio!==1?I.intersectionRatio:Fr.intersectionRatio(E,Ts(l)))!==1&&ne(this,ur).call(this)},{threshold:Gl,rootMargin:S,root:c})),ne(this,un).observe(l),Hu(this,Ds,td).call(this)},ed)),this.boundingClientRect=e.getBoundingClientRect(),bt(this,cn,Lp(e,this.boundingClientRect));let r=!0;this.callback=a=>{r&&(r=!1,n.skipInitial)||t(a)};const s=e.ownerDocument;n?.debug&&(bt(this,ze,document.createElement("div")),ne(this,ze).style.background="rgba(0,0,0,0.15)",ne(this,ze).style.position="fixed",ne(this,ze).style.pointerEvents="none",s.body.appendChild(ne(this,ze))),bt(this,cr,new IntersectionObserver(a=>{var o,i;const l=a[a.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:f,height:p}=c,d=ne(this,cn);bt(this,cn,u),!(!f&&!p)&&(d&&!u?((o=ne(this,un))==null||o.disconnect(),this.callback(null),(i=ne(this,Ht))==null||i.disconnect(),bt(this,Ht,void 0),ne(this,ze)&&(ne(this,ze).style.visibility="hidden")):ne(this,ur).call(this),u&&!ne(this,Ht)&&(bt(this,Ht,new Zp(ne(this,ur))),ne(this,Ht).observe(e)))},{threshold:Gl,root:s})),ne(this,cn)&&!n.skipInitial&&this.callback(this.boundingClientRect),ne(this,cr).observe(e)}};cn=new WeakMap;$s=new WeakMap;Ht=new WeakMap;un=new WeakMap;cr=new WeakMap;ze=new WeakMap;vr=new WeakMap;ur=new WeakMap;Ds=new WeakSet;td=function(){ne(this,vr)||(Hu(this,Ds,nd).call(this),!Vp(this.boundingClientRect,ne(this,$s))&&(this.callback(this.boundingClientRect),bt(this,$s,this.boundingClientRect)))};nd=function(){if(ne(this,ze)){const{top:e,left:t,width:n,height:r}=Ts(this.element);ne(this,ze).style.overflow="hidden",ne(this,ze).style.visibility="visible",ne(this,ze).style.top=`${Math.floor(e)}px`,ne(this,ze).style.left=`${Math.floor(t)}px`,ne(this,ze).style.width=`${Math.floor(n)}px`,ne(this,ze).style.height=`${Math.floor(r)}px`}};var as=new WeakMap,os=new WeakMap;function Gp(e,t){let n=as.get(e);return n||(n={disconnect:new rd(e,s=>{const a=as.get(e);a&&a.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),as.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(as.delete(e),n.disconnect())}}function zp(e,t){const n=new Set;for(const r of e){const s=Gp(r,t);n.add(s)}return()=>n.forEach(r=>r())}function jp(e,t){var n;const r=e.ownerDocument;if(!os.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}),os.set(r,{disconnect:()=>o.abort(),listeners:i})}const{listeners:s,disconnect:a}=(n=os.get(r))!=null?n:{};return!s||!a?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(a(),os.delete(r))})}var dr,fr,ys,ro,Hp=class{constructor(e,t,n){this.callback=t,ft(this,dr),ft(this,fr,!1),ft(this,ys),ft(this,ro,Ju(o=>{if(!ne(this,fr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const i of ne(this,ys))if(o.target.contains(i)){this.callback(ne(this,dr).boundingClientRect);break}}},ed));const r=Bp(e),s=zp(r,t),a=jp(e,ne(this,ro));bt(this,ys,r),bt(this,dr,new rd(e,t,n)),this.disconnect=()=>{ne(this,fr)||(bt(this,fr,!0),s(),a(),ne(this,dr).disconnect())}}};dr=new WeakMap;fr=new WeakMap;ys=new WeakMap;ro=new WeakMap;function so(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function kr(e){try{so(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function zl(e){return!Yu||!e?!1:e===wn(e).scrollingElement}function sd(e){var t,n;const r=Et(e),s=zl(e)?Rp(e):Js(e),a=r.visualViewport,o=zl(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 Xp(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:a,position:o}=sd(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 di=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))}},Ps=new di(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Yp=new di(e=>setTimeout(e,50)),Fs=new Map,Up=Fs.clear.bind(Fs);function Gt(e,t=!1){if(!t)return jl(e);let n=Fs.get(e);return n||(n=jl(e),Fs.set(e,n),Yp.schedule(Up),n)}function jl(e){return Et(e).getComputedStyle(e)}function Kp(e,t=Gt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Qp(e,t=Gt(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 qp={excludeElement:!0,escapeShadowDOM:!0};function ao(e,t=qp){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,a=new Set;function o(i){if(n!=null&&a.size>=n||!i)return a;if(li(i)&&i.scrollingElement!=null&&!a.has(i.scrollingElement))return a.add(i.scrollingElement),a;if(s&&ui(i))return o(i.host);if(!pn(i))return Xu(i)?o(i.parentElement):a;if(a.has(i))return a;const l=Gt(i,!0);if(r&&i===e||Qp(i,l)&&a.add(i),Kp(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&a.add(c),a}return o(i.parentNode)}return e?o(e):a}function Jp(e){const[t]=ao(e,{limit:1});return t??null}function zn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Gn(e);for(;r;){if(r===t)return n;const s=Js(r),{x:a,y:o}=em(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=Gn(r)}return n}function em(e,t=Js(e)){const n=Math.round(t.width),r=Math.round(t.height);if(pn(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=Gt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function tm(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 fi(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 hi(e){var t,n,r,s,a,o,i,l,c;const{scale:u,transform:f,translate:p}=e,d=tm(u),h=fi(p),g=nm(f);if(!g&&!d&&!h)return null;const y={x:(t=d?.x)!=null?t:1,y:(n=d?.y)!=null?n:1},v={x:(r=h?.x)!=null?r:0,y:(s=h?.y)!=null?s:0},b={x:(a=g?.x)!=null?a:0,y:(o=g?.y)!=null?o:0,scaleX:(i=g?.scaleX)!=null?i:1,scaleY:(l=g?.scaleY)!=null?l:1};return{x:v.x+b.x,y:v.y+b.y,z:(c=h?.z)!=null?c:0,scaleX:y.x*b.scaleX,scaleY:y.y*b.scaleY}}function nm(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 kt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(kt||{}),rm={x:.2,y:.2},sm={x:10,y:10};function am(e,t,n,r=25,s=rm,a=sm){const{x:o,y:i}=t,{rect:l,isTop:c,isBottom:u,isLeft:f,isRight:p}=sd(e),d=zn(e),h=Gt(e,!0),g=hi(h),y=g!==null?g?.scaleX<0:!1,v=g!==null?g?.scaleY<0:!1,b=new Fr(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},C={x:0,y:0},_={height:b.height*s.y,width:b.width*s.x};return(!c||v&&!u)&&i<=b.top+_.height&&n?.y!==1&&o>=b.left-a.x&&o<=b.right+a.x?(w.y=v?1:-1,C.y=r*Math.abs((b.top+_.height-i)/_.height)):(!u||v&&!c)&&i>=b.bottom-_.height&&n?.y!==-1&&o>=b.left-a.x&&o<=b.right+a.x&&(w.y=v?-1:1,C.y=r*Math.abs((b.bottom-_.height-i)/_.height)),(!p||y&&!f)&&o>=b.right-_.width&&n?.x!==-1&&i>=b.top-a.y&&i<=b.bottom+a.y?(w.x=y?-1:1,C.x=r*Math.abs((b.right-_.width-o)/_.width)):(!f||y&&!p)&&o<=b.left+_.width&&n?.x!==1&&i>=b.top-a.y&&i<=b.bottom+a.y&&(w.x=y?1:-1,C.x=r*Math.abs((b.left+_.width-o)/_.width)),{direction:w,speed:C}}function om(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function im(e,t=!1){if(om(e)){e.scrollIntoViewIfNeeded(t);return}if(!pn(e))return e.scrollIntoView();var n=Jp(e);if(!pn(n))return;const r=Gt(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 lm(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 cm(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 um({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var dm=new di(e=>setTimeout(e,0)),yr=new Map,fm=yr.clear.bind(yr);function hm(e){const t=e.ownerDocument;let n=yr.get(t);if(n)return n;n=t.getAnimations(),yr.set(t,n),dm.schedule(fm);const r=n.filter(s=>qs(s.effect)&&s.effect.target===e);return yr.set(e,r),n}function pm(e,t){const n=hm(e).filter(r=>{var s,a;if(qs(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 Fr{constructor(e,t={}){var n,r,s,a;const{frameTransform:o=zn(e),ignoreTransforms:i,getBoundingClientRect:l=Js}=t,c=pm(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||ci())&&_.contains(e)}),u=l(e);let{top:f,left:p,width:d,height:h}=u,g;const y=Gt(e),v=hi(y),b={x:(n=v?.scaleX)!=null?n:1,y:(r=v?.scaleY)!=null?r:1},w=mm(e,y);c?.(),v&&(g=cm(u,v,y.transformOrigin),(i||w)&&(f=g.top,p=g.left,d=g.width,h=g.height));const C={width:(s=g?.width)!=null?s:d,height:(a=g?.height)!=null?a:h};if(w&&!i&&g){const _=lm(g,w,y.transformOrigin);f=_.top,p=_.left,d=_.width,h=_.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=C.width,this.intrinsicHeight=C.height}};function mm(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=qs(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=hi({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 br(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 gm=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(br(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(br(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(br(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function mn(e){return e?e instanceof Et(e).Element||Wr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function pi(e){if(!e)return!1;const{KeyboardEvent:t}=Et(e.target);return e instanceof t}function vm(e){if(!e)return!1;const{PointerEvent:t}=Et(e.target);return e instanceof t}function ym(e){if(!mn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||bm(e)}function bm(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Sa={};function oo(e){const t=Sa[e]==null?0:Sa[e]+1;return Sa[e]=t,`${e}-${t}`}var wm=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=Pt.distance(t.shape.center,n);return{id:r,value:1/s,type:No.PointerIntersection,priority:Lo.High}}return null},Cm=({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=Pt.distance(t.shape.center,s.current),i=r/(n.current.area+t.shape.area-r)/a;return{id:t.id,value:i,type:No.ShapeIntersection,priority:Lo.Normal}}return null},_m=e=>{var t;return(t=wm(e))!=null?t:Cm(e)},xm=Object.create,mi=Object.defineProperty,Sm=Object.defineProperties,km=Object.getOwnPropertyDescriptor,Im=Object.getOwnPropertyDescriptors,Os=Object.getOwnPropertySymbols,ad=Object.prototype.hasOwnProperty,od=Object.prototype.propertyIsEnumerable,id=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),qn=e=>{throw TypeError(e)},io=(e,t,n)=>t in e?mi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ir=(e,t)=>{for(var n in t||(t={}))ad.call(t,n)&&io(e,n,t[n]);if(Os)for(var n of Os(t))od.call(t,n)&&io(e,n,t[n]);return e},gi=(e,t)=>Sm(e,Im(t)),Hl=(e,t)=>mi(e,"name",{value:t,configurable:!0}),ld=(e,t)=>{var n={};for(var r in e)ad.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Os)for(var r of Os(e))t.indexOf(r)<0&&od.call(e,r)&&(n[r]=e[r]);return n},Jn=e=>{var t;return[,,,xm((t=e?.[id("metadata")])!=null?t:null)]},cd=["class","method","getter","setter","accessor","field","value","get","set"],hr=e=>e!==void 0&&typeof e!="function"?qn("Function expected"):e,Am=(e,t,n,r,s)=>({kind:cd[e],name:t,metadata:r,addInitializer:a=>n._?qn("Already initialized"):s.push(hr(a||null))}),Cn=(e,t)=>io(t,id("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},Ct=(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,g=cd[f+5],y=f>3&&(e[h-1]=[]),v=e[h]||(e[h]=[]),b=f&&(!d&&!p&&(s=s.prototype),f<5&&(f>3||!d)&&km(f<4?s:{get[n](){return Se(this,a)},set[n](C){return rt(this,a,C)}},n));f?d&&f<4&&Hl(a,(f>2?"set ":f>1?"get ":"")+n):Hl(s,n);for(var w=r.length-1;w>=0;w--)c=Am(f,n,l={},e[3],v),f&&(c.static=p,c.private=d,u=c.access={has:d?C=>Em(s,C):C=>n in C},f^3&&(u.get=d?C=>(f^1?Se:gn)(C,s,f^4?a:b.get):C=>C[n]),f>2&&(u.set=d?(C,_)=>rt(C,s,_,f^4?a:b.set):(C,_)=>C[n]=_)),i=(0,r[w])(f?f<4?d?a:b[g]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?hr(i)&&(f>4?y.unshift(i):f?d?a=i:b[g]=i:s=i):typeof i!="object"||i===null?qn("Object expected"):(hr(o=i.get)&&(b.get=o),hr(o=i.set)&&(b.set=o),hr(o=i.init)&&y.unshift(o));return f||Cn(e,s),b&&mi(s,n,b),d?f^4?a:b:s},vi=(e,t,n)=>t.has(e)||qn("Cannot "+n),Em=(e,t)=>Object(t)!==t?qn('Cannot use the "in" operator on this value'):e.has(t),Se=(e,t,n)=>(vi(e,t,"read from private field"),n?n.call(e):t.get(e)),Pe=(e,t,n)=>t.has(e)?qn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rt=(e,t,n,r)=>(vi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),gn=(e,t,n)=>(vi(e,t,"access private method"),n),Xl={role:"button",roleDescription:"draggable"},Mm="dnd-kit-description",Tm="dnd-kit-announcement",Rm={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."},$m={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 Dm(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Pm(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function Fm(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 Om=["dragover","dragmove"],Bm=class extends pt{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Mm,announcement:s=Tm}={},announcements:a=$m,screenReaderInstructions:o=Rm,debounce:i=500}=t??{},l=n?`${r}-${n}`:oo(r),c=n?`${s}-${n}`:oo(s);let u,f,p,d;const h=(_=d)=>{!p||!_||p?.nodeValue!==_&&(p.nodeValue=_)},g=()=>Ps.schedule(h),y=Wm(g,i),v=Object.entries(a).map(([_,S])=>this.manager.monitor.addEventListener(_,(k,I)=>{const E=p;if(!E)return;const A=S?.(k,I);A&&E.nodeValue!==A&&(d=A,Om.includes(_)?y():(g(),y.cancel()))})),b=()=>{let _=[];u?.isConnected||(u=Pm(l,o.draggable),_.push(u)),f?.isConnected||(f=Fm(c),p=document.createTextNode(""),f.appendChild(p),_.push(f)),_.length>0&&document.body.append(..._)},w=new Set;function C(){for(const _ of w)_()}this.registerEffect(()=>{var _;w.clear();for(const S of this.manager.registry.draggables.value){const k=(_=S.handle)!=null?_:S.element;if(k){(!u||!f)&&w.add(b),(!Dm(k)||ci())&&!k.hasAttribute("tabindex")&&w.add(()=>k.setAttribute("tabindex","0")),!k.hasAttribute("role")&&k.tagName.toLowerCase()!=="button"&&w.add(()=>k.setAttribute("role",Xl.role)),k.hasAttribute("aria-roledescription")||w.add(()=>k.setAttribute("aria-roledescription",Xl.roleDescription)),k.hasAttribute("aria-describedby")||w.add(()=>k.setAttribute("aria-describedby",l));for(const E of["aria-pressed","aria-grabbed"]){const A=String(S.isDragging);k.getAttribute(E)!==A&&w.add(()=>k.setAttribute(E,A))}const I=String(S.disabled);k.getAttribute("aria-disabled")!==I&&w.add(()=>k.setAttribute("aria-disabled",I))}}w.size>0&&Ps.schedule(C)}),this.destroy=()=>{super.destroy(),u?.remove(),f?.remove(),v.forEach(_=>_())}}};function Wm(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Vm=class extends pt{constructor(e,t){super(e,t),this.manager=e;const n=Es(()=>{var r;return wn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=At(()=>{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()}})}},Bs=new Map,ud,dd,fd,hd,lo,wr,Nt,yi,jn,pd,md,gd,vd,_n=class extends(lo=Br,hd=[pe],fd=[Re],dd=[Re],ud=[Re],lo){constructor(e){super(e),Oe(Nt,5,this),Pe(this,jn),Pe(this,wr,new Set),Pe(this,yi,Oe(Nt,8,this,new Set)),Oe(Nt,11,this),this.registerEffect(gn(this,jn,pd))}register(e){return Se(this,wr).add(e),()=>{Se(this,wr).delete(e)}}addRoot(e){return Ce(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{Ce(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return Rs((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return Rs((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}};Nt=Jn(lo);wr=new WeakMap;yi=new WeakMap;jn=new WeakSet;pd=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Se(this,wr))t.push(gn(this,jn,md).call(this,n,r));return()=>{for(const n of t)n()}};md=function(e,t){let n=Bs.get(e);n||(n=new Map,Bs.set(e,n));let r=n.get(t);if(!r){const a=li(e)?gn(this,jn,gd).call(this,e,n,t):gn(this,jn,vd).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())}};gd=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&&Bs.delete(e)}}};vd=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(ui(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&&Bs.delete(e)}}};Ct(Nt,4,"additionalRoots",hd,_n,yi);Ct(Nt,2,"sourceRoot",fd,_n);Ct(Nt,2,"targetRoot",dd,_n);Ct(Nt,2,"roots",ud,_n);Cn(Nt,_n);var Vr="data-dnd-",co=`${Vr}dropping`,qe="--dnd-",Dt=`${Vr}dragging`,Ws=`${Vr}placeholder`,Lm=[Dt,Ws,"popover","aria-pressed","aria-grabbing"],Nm=["view-transition-name"],Zm=`
|
|
9
|
+
:is(:root,:host) [${Dt}] {
|
|
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(${
|
|
16
|
-
left: var(${
|
|
15
|
+
top: var(${qe}top, 0px) !important;
|
|
16
|
+
left: var(${qe}left, 0px) !important;
|
|
17
17
|
right: unset !important;
|
|
18
18
|
bottom: unset !important;
|
|
19
|
-
width: var(${
|
|
20
|
-
max-width: var(${
|
|
21
|
-
height: var(${
|
|
22
|
-
max-height: var(${
|
|
23
|
-
transition: var(${
|
|
19
|
+
width: var(${qe}width, auto);
|
|
20
|
+
max-width: var(${qe}width, auto);
|
|
21
|
+
height: var(${qe}height, auto);
|
|
22
|
+
max-height: var(${qe}height, auto);
|
|
23
|
+
transition: var(${qe}transition) !important;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
:is(:root,:host) [${
|
|
26
|
+
:is(:root,:host) [${Ws}] {
|
|
27
27
|
transition: none;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
:is(:root,:host) [${
|
|
30
|
+
:is(:root,:host) [${Ws}='hidden'] {
|
|
31
31
|
visibility: hidden;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
[${
|
|
34
|
+
[${Dt}] * {
|
|
35
35
|
pointer-events: none !important;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
[${
|
|
39
|
-
translate: var(${
|
|
38
|
+
[${Dt}]:not([${co}]) {
|
|
39
|
+
translate: var(${qe}translate) !important;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
[${
|
|
43
|
-
scale: var(${
|
|
44
|
-
transform-origin: var(${
|
|
42
|
+
[${Dt}][style*='${qe}scale'] {
|
|
43
|
+
scale: var(${qe}scale) !important;
|
|
44
|
+
transform-origin: var(${qe}transform-origin) !important;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
@layer dnd-kit {
|
|
48
|
-
:where([${
|
|
48
|
+
:where([${Dt}][popover]) {
|
|
49
49
|
overflow: visible;
|
|
50
50
|
background: unset;
|
|
51
51
|
border: unset;
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
[${
|
|
62
|
+
[${Dt}]::backdrop, [${Vr}overlay]:not([${Dt}]) {
|
|
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=`${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`
|
|
66
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Gm(e,t="hidden"){return Ce(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=zm(n,r.registry.droppables),a=[],o=Pp(n),{remove:i}=o;return jm(s,o,a),Hm(o,t),o.remove=()=>{a.forEach(l=>l()),i.call(o)},o})}function zm(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Vr}${oo("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function jm(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),Zl.set(i,o),n.push(()=>{Zl.delete(i),r.proxy=void 0})}}function Hm(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Ws,t)}function yd(e,t){return e===t?!0:Gn(e)===Gn(t)}function Yl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&mn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>kr(t))}function uo(e){return e.tagName==="TR"}function Xm(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-")||Lm.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(br(e)&&br(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(Nm.includes(u)||u.startsWith(qe))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 Ym(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),kr(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),kr(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Um(e){return new ResizeObserver(()=>{var t,n;const r=new Lt(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},a=(e.width-r.width)*s.x+e.delta.x,o=(e.height-r.height)*s.y+e.delta.y,i=Uu();if(e.styles.set({width:r.width-e.widthOffset,height:r.height-e.heightOffset,top:e.top+o+i.y,left:e.left+a+i.x},qe),(n=e.getElementMutationObserver())==null||n.takeRecords(),uo(e.element)&&uo(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 Km=250,Qm="ease";function qm(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=Km,easing:i=Qm}=a??{};kr(e.feedbackElement);const[,l]=(t=Tp(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:yd(e.feedbackElement,c)?null:void 0},f=new Lt(e.feedbackElement,u),p=(r=fi(Gt(e.feedbackElement).translate))!=null?r:e.translate,d=new Lt(c,u),h=Fr.delta(f,d,e.alignment),g={x:p.x-h.x,y:p.y-h.y},y=Math.round(f.intrinsicHeight)!==Math.round(d.intrinsicHeight)?{minHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`],maxHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`]}:{},v=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},qe),e.feedbackElement.setAttribute(co,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),um({element:e.feedbackElement,keyframes:gi(Ir(Ir({},y),v),{translate:[`${p.x}px ${p.y}px 0`,`${g.x}px ${g.y}px 0`]}),options:{duration:Ku(Et(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(co),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var bd,fo,Ar,bi,bs,wd,Cd,Er=class extends(fo=pt,bd=[pe],fo){constructor(t,n){super(t,n),Pe(this,bs),Pe(this,bi,Oe(Ar,8,this)),Oe(Ar,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(_n),s=r?.register(Zm);if(s){const a=this.destroy.bind(this);this.destroy=()=>{s(),a()}}this.registerEffect(gn(this,bs,wd).bind(this,r)),this.registerEffect(gn(this,bs,Cd))}};Ar=Jn(fo);bi=new WeakMap;bs=new WeakSet;wd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Rs(t);if(n)return e.addRoot(n)};Cd=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=zn(d),g=zn(u),y=!yd(u,d),v=new Lt(u,{frameTransform:y?g:null,ignoreTransforms:!y}),b={x:g.scaleX/h.scaleX,y:g.scaleY/h.scaleY};let{width:w,height:C,top:_,left:S}=v;y&&(w=w/b.x,C=C/b.y);const k=new gm(d),{transition:I,translate:E,boxSizing:A,paddingBlockStart:R,paddingBlockEnd:T,paddingInlineStart:M,paddingInlineEnd:$,borderInlineStartWidth:O,borderInlineEndWidth:P,borderBlockStartWidth:V,borderBlockEndWidth:X}=Gt(u),ge=f==="clone",re=A==="content-box",se=re?parseInt(M)+parseInt($)+parseInt(O)+parseInt(P):0,Ie=re?parseInt(R)+parseInt(T)+parseInt(V)+parseInt(X):0,j=f!=="move"&&!this.overlay?Gm(l,ge?"clone":"hidden"):null,_e=Ce(()=>pi(s.dragOperation.activatorEvent));if(E!=="none"){const J=fi(E);J&&!p.translate&&(p.translate=J)}if(!p.transformOrigin){const J=Ce(()=>i.current);p.transformOrigin={x:(J.x-S*h.scaleX-h.x)/(w*h.scaleX),y:(J.y-_*h.scaleY-h.y)/(C*h.scaleY)}}const{transformOrigin:te}=p,mt=_*h.scaleY+h.y,q=S*h.scaleX+h.x;if(!p.coordinates&&(p.coordinates={x:q,y:mt},b.x!==1||b.y!==1)){const{scaleX:J,scaleY:ce}=g,{x:Fe,y:et}=te;p.coordinates.x+=(w*J-w)*Fe,p.coordinates.y+=(C*ce-C)*et}p.dimensions||(p.dimensions={width:w,height:C}),p.frameTransform||(p.frameTransform=h);const me={x:p.coordinates.x-q,y:p.coordinates.y-mt},Me={width:(p.dimensions.width*p.frameTransform.scaleX-w*h.scaleX)*te.x,height:(p.dimensions.height*p.frameTransform.scaleY-C*h.scaleY)*te.y},je={x:me.x/h.scaleX+Me.width,y:me.y/h.scaleY+Me.height},K={left:S+je.x,top:_+je.y};d.setAttribute(Dt,"true");const le=Ce(()=>o.transform),Ze=(t=p.translate)!=null?t:{x:0,y:0},fe=le.x*h.scaleX+Ze.x,B=le.y*h.scaleY+Ze.y,Y=Uu();k.set({width:w-se,height:C-Ie,top:K.top+Y.y,left:K.left+Y.x,translate:`${fe}px ${B}px 0`,transition:I?`${I}, translate 0ms linear`:"",scale:y?`${b.x} ${b.y}`:"","transform-origin":`${te.x*100}% ${te.y*100}%`},qe),j&&(u.insertAdjacentElement("afterend",j),a?.rootElement&&(typeof a.rootElement=="function"?a.rootElement(l):a.rootElement).appendChild(u)),so(d)&&(d.hasAttribute("popover")||d.setAttribute("popover","manual"),kr(d),d.addEventListener("beforetoggle",Yl));let Te,Ve,ae;const lt=Um({placeholder:j,element:u,feedbackElement:d,frameTransform:h,transformOrigin:te,width:w,height:C,top:_,left:S,widthOffset:se,heightOffset:Ie,delta:je,styles:k,dragOperation:o,getElementMutationObserver:()=>Te,getSavedCellWidths:()=>ae,setSavedCellWidths:J=>{ae=J}}),Mt=new Lt(d);Ce(()=>o.shape=Mt);const xt=Et(d),He=J=>{this.manager.actions.stop({event:J})},ct=Ku(xt);_e&&xt.addEventListener("resize",He),Ce(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),j&&(lt.observe(j),Te=Xm(u,j,ge),Ve=Ym(u,j,d));const gt=(n=s.dragOperation.source)==null?void 0:n.id,ut=()=>{var J;if(!_e||gt==null)return;const ce=s.registry.draggables.get(gt),Fe=(J=ce?.handle)!=null?J:ce?.element;pn(Fe)&&Fe.focus()},Je=()=>{var J;if(Te?.disconnect(),Ve?.disconnect(),lt.disconnect(),xt.removeEventListener("resize",He),so(d)&&(d.removeEventListener("beforetoggle",Yl),d.removeAttribute("popover")),d.removeAttribute(Dt),k.reset(),ae&&uo(u)){const Fe=Array.from(u.cells);for(const[et,vt]of Fe.entries())vt.style.width=(J=ae[et])!=null?J:""}l.status="idle";const ce=r.current.translate!=null;j&&(ce||j.parentElement!==d.parentElement)&&d.isConnected&&j.replaceWith(d),j?.remove()},H=a?.dropAnimation,he=this,Xe=Pr(()=>{var J;const{transform:ce,status:Fe}=o;if(!(!ce.x&&!ce.y&&!r.current.translate)&&Fe.dragging){const et=(J=p.translate)!=null?J:{x:0,y:0},vt={x:ce.x/h.scaleX+et.x,y:ce.y/h.scaleY+et.y},Z=r.current.translate,z=Ce(()=>o.modifiers),U=Ce(()=>{var ie;return(ie=o.shape)==null?void 0:ie.current}),oe=_e&&!ct?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(k.set({transition:`${I}, translate ${oe}`,translate:`${vt.x}px ${vt.y}px 0`},qe),Te?.takeRecords(),U&&U!==Mt&&Z&&!z.length){const ie=Pt.delta(vt,Z);o.shape=Fr.from(U.boundingRectangle).translate(ie.x*h.scaleX,ie.y*h.scaleY)}else o.shape=new Lt(d);r.current.translate=vt}},function(){if(o.status.dropped){this.dispose(),l.status="dropping";const J=he.dropAnimation!==void 0?he.dropAnimation:H;let ce=r.current.translate;const Fe=ce!=null;if(!ce&&u!==d&&(ce={x:0,y:0}),!ce||J===null){Je();return}s.renderer.rendering.then(()=>{qm({element:u,feedbackElement:d,placeholder:j,translate:ce,moved:Fe,transition:I,alignment:l.alignment,styles:k,animation:J??void 0,getElementMutationObserver:()=>Te,cleanup:Je,restoreFocus:ut})})}});return()=>{Je(),Xe()}};Ct(Ar,4,"overlay",bd,Er,bi);Cn(Ar,Er);Er.configure=bn(Er);var ho=Er,er=!0,Jm=!1,_d,xd,Sd,kd,Ut,wi,Ci;kd=(Sd=[pe],kt.Forward),xd=(_d=[pe],kt.Reverse);var Mr=class{constructor(){Pe(this,wi,Oe(Ut,8,this,er)),Oe(Ut,11,this),Pe(this,Ci,Oe(Ut,12,this,er)),Oe(Ut,15,this)}isLocked(e){return e===kt.Idle?!1:e==null?this[kt.Forward]===er&&this[kt.Reverse]===er:this[e]===er}unlock(e){e!==kt.Idle&&(this[e]=Jm)}};Ut=Jn(null);wi=new WeakMap;Ci=new WeakMap;Ct(Ut,4,kd,Sd,Mr,wi);Ct(Ut,4,xd,_d,Mr,Ci);Cn(Ut,Mr);var eg=[kt.Forward,kt.Reverse],Ul=class{constructor(){this.x=new Mr,this.y=new Mr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},tg=class extends pt{constructor(e){super(e);const t=Dr(new Ul);let n=null;this.signal=t,At(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Ul;return}const{delta:s}=e.dragOperation.position;if(n){const a={x:Kl(s.x,n.x),y:Kl(s.y,n.y)},o=t.peek();qt(()=>{for(const i of nu)for(const l of eg)a[i]===l&&o[i].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function Kl(e,t){return Math.sign(e-t)}var Id,po,Tr,_i,Xt,mo,ea=class extends(po=Br,Id=[pe],po){constructor(e){super(e),Pe(this,_i,Oe(Tr,8,this,!1)),Oe(Tr,11,this),Pe(this,Xt),Pe(this,mo,()=>{if(!Se(this,Xt))return;const{element:a,by:o}=Se(this,Xt);o.y&&(a.scrollTop+=o.y),o.x&&(a.scrollLeft+=o.x)}),this.scroll=a=>{var o;if(this.disabled)return!1;const i=this.getScrollableElements();if(!i)return rt(this,Xt,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:u}=a??{},f=u?{x:Ql(u.x),y:Ql(u.y)}:void 0,p=f?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const d of i){const h=Xp(d,u);if(h.x||h.y){const{speed:g,direction:y}=am(d,c,f);if(p)for(const v of nu)p[v].isLocked(y[v])&&(g[v]=0,y[v]=0);if(y.x||y.y){const{x:v,y:b}=u??y,w=v*g.x,C=b*g.y;if(w||C){const _=(o=Se(this,Xt))==null?void 0:o.by;if(this.autoScrolling&&_&&(_.x&&!w||_.y&&!C))continue;return rt(this,Xt,{element:d,by:{x:w,y:C}}),Ps.schedule(Se(this,mo)),!0}}}}}return rt(this,Xt,void 0),!1};let t=null,n=null;const r=Es(()=>{const{position:a,source:o}=e.dragOperation;if(!a)return null;const i=Qu(Rs(o?.element),a.current);return i&&(t=i),i??t}),s=Es(()=>{const a=r.value,{documentElement:o}=wn(a);if(!a||a===o){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=ao(l,{excludeElement:!1});return n=c,c}}if(a){const i=ao(a,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},xr);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new tg(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!pi(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Tr=Jn(po);_i=new WeakMap;Xt=new WeakMap;mo=new WeakMap;Ct(Tr,4,"autoScrolling",Id,ea,_i);Cn(Tr,ea);function Ql(e){return e>0?kt.Forward:e<0?kt.Reverse:kt.Idle}var ng=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))}},rg=new ng(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),sg=10,Ad=class extends pt{constructor(e,t){super(e);const n=e.registry.plugins.get(ea);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=At(()=>{if(this.disabled)return;const{position:r,status:s}=e.dragOperation;if(s.dragging)if(n.scroll()){n.autoScrolling=!0;const o=setInterval(()=>rg.schedule(n.scroll),sg);return()=>{clearInterval(o)}}else n.autoScrolling=!1})}},ql={capture:!0,passive:!0},pr,ag=class extends Br{constructor(e){super(e),Pe(this,pr),this.handleScroll=()=>{Se(this,pr)==null&&rt(this,pr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),rt(this,pr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=At(()=>{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,ql),()=>{o.removeEventListener("scroll",this.handleScroll,ql)}}})}};pr=new WeakMap;var og=class extends pt{constructor(e,t){super(e,t),this.manager=e,this.destroy=At(()=>{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),ka(),document.addEventListener("selectionchange",ka,{capture:!0}),()=>{document.removeEventListener("selectionchange",ka,{capture:!0}),a.remove()}}})}};function ka(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var mr=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),Dn,Vs=class extends Ln{constructor(t,n){super(t),this.manager=t,this.options=n,Pe(this,Dn,[]),this.listeners=new qu,this.handleSourceKeyDown=(r,s,a)=>{if(this.disabled||r.defaultPrevented||!mn(r.target)||s.disabled)return;const{keyboardCodes:o=mr.keyboardCodes,preventActivation:i=mr.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 At(()=>{var s;const a=(s=t.handle)!=null?s:t.element,o=i=>{pi(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(),im(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=wn(s),l=[this.listeners.bind(i,[{type:"keydown",listener:c=>this.handleKeyDown(c,n,r),options:{capture:!0}}])];Se(this,Dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=mr.keyboardCodes}=r??{};if(An(t,[...s.end,...s.cancel])){t.preventDefault();const a=An(t,s.cancel);this.handleEnd(t,a);return}An(t,s.up)?this.handleMove("up",t):An(t,s.down)&&this.handleMove("down",t),An(t,s.left)?this.handleMove("left",t):An(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:mr.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(Ad);t?.disabled===!1&&(t.disable(),Se(this,Dn).push(()=>{t.enable()}))}cleanup(){Se(this,Dn).forEach(t=>t()),rt(this,Dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};Dn=new WeakMap;Vs.configure=bn(Vs);Vs.defaults=mr;var ig=Vs;function An(e,t){return t.includes(e.code)}var dn,lg=class extends Fu{constructor(){super(...arguments),Pe(this,dn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,dn,Zn(e));break;case"pointermove":if(!Se(this,dn))return;const{x:t,y:n}=Zn(e),r={x:t-Se(this,dn).x,y:n-Se(this,dn).y},{tolerance:s}=this.options;if(s&&qa(r,s)){this.abort();return}qa(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){rt(this,dn,void 0)}};dn=new WeakMap;var Pn,fn,cg=class extends Fu{constructor(){super(...arguments),Pe(this,Pn),Pe(this,fn)}onEvent(e){switch(e.type){case"pointerdown":rt(this,fn,Zn(e)),rt(this,Pn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Se(this,fn))return;const{x:t,y:n}=Zn(e),r={x:t-Se(this,fn).x,y:n-Se(this,fn).y};qa(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Se(this,Pn)&&(clearTimeout(Se(this,Pn)),rt(this,fn,void 0),rt(this,Pn,void 0))}};Pn=new WeakMap;fn=new WeakMap;var Wt=class{};Wt.Delay=cg;Wt.Distance=lg;var go=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&mn(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Wt.Delay({value:250,tolerance:5})]:ym(s)&&!e.defaultPrevented?[new Wt.Delay({value:200,tolerance:0})]:[new Wt.Delay({value:200,tolerance:10}),new Wt.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;return r===t.element||r===t.handle||!mn(r)||(n=t.handle)!=null&&n.contains(r)?!1:Op(r)}}),Fn,Ls=class extends Ln{constructor(t,n){super(t),this.manager=t,this.options=n,Pe(this,Fn,new Set),this.listeners=new qu,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=go.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return At(()=>{var s;const a=new AbortController,{signal:o}=a,i=c=>{vm(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&&(fg(c.ownerDocument.defaultView),c.addEventListener("pointerdown",i,{signal:o}));return()=>a.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!mn(t.target)||n.disabled||ug(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=go.preventActivation}=r??{};if(s?.(t,n))return;const{target:a}=t,o=pn(a)&&a.draggable&&a.getAttribute("draggable")==="true",i=zn(n.element),{x:l,y:c}=Zn(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 Ip(u,g=>this.handleStart(n,g));f.signal.onabort=()=>this.handleCancel(t),f.onEvent(t),this.controller=f;const p=no(),d=this.listeners.bind(p,[{type:"pointermove",listener:g=>this.handlePointerMove(g,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:is,options:{capture:!0}}]),h=()=>{d(),this.initialCoordinates=void 0};Se(this,Fn).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=Zn(t),o=zn(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,Ps.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:s}=this;if(!s||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:s,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const i=wn(n.target).body;i.setPointerCapture(n.pointerId);const l=mn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:is,options:{passive:!1}},{type:"click",listener:is},{type:"contextmenu",listener:is},{type:"keydown",listener:this.handleKeyDown}]);Se(this,Fn).add(c)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){this.latest={event:void 0,coordinates:void 0},Se(this,Fn).forEach(t=>t()),Se(this,Fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};Fn=new WeakMap;Ls.configure=bn(Ls);Ls.defaults=go;var vo=Ls;function ug(e){return"sensor"in e}function is(e){e.preventDefault()}function dg(){}var Jl=new WeakSet;function fg(e){!e||Jl.has(e)||(e.addEventListener("touchmove",dg,{capture:!1,passive:!1}),Jl.add(e))}var Wn={modifiers:[],plugins:[Bm,Ad,Vm,ho,og],sensors:[vo,ig]},xi=class extends Mp{constructor(e={}){const t=Vt(e.plugins,Wn.plugins),n=Vt(e.sensors,Wn.sensors),r=Vt(e.modifiers,Wn.modifiers);super(gi(Ir({},e),{plugins:[ag,ea,_n,...t],sensors:n,modifiers:r}))}},Ed,Md,Td,yo,Rt,Si,ki,Ii,Lr=class extends(yo=Ft,Td=[pe],Md=[pe],Ed=[pe],yo){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:a,feedback:o="default"}=n,i=ld(n,["element","effects","handle","feedback"]);super(Ir({effects:()=>[...s(),()=>{var l,c;const{manager:u}=this;if(!u)return;const p=((c=(l=this.sensors)==null?void 0:l.map(Wo))!=null?c:[...u.sensors]).map(d=>{const h=d instanceof Ln?d:u.registry.register(d.plugin),g=d instanceof Ln?void 0:d.options;return h.bind(this,g)});return function(){p.forEach(h=>h())}}]},i),t),Pe(this,Si,Oe(Rt,8,this)),Oe(Rt,11,this),Pe(this,ki,Oe(Rt,12,this)),Oe(Rt,15,this),Pe(this,Ii,Oe(Rt,16,this)),Oe(Rt,19,this),this.element=r,this.handle=a,this.feedback=o}};Rt=Jn(yo);Si=new WeakMap;ki=new WeakMap;Ii=new WeakMap;Ct(Rt,4,"handle",Td,Lr,Si);Ct(Rt,4,"element",Md,Lr,ki);Ct(Rt,4,"feedback",Ed,Lr,Ii);Cn(Rt,Lr);var Rd,$d,bo,Kt,Ai,Ia,Dd,Pd,Cr,Ei,Fd=class extends(bo=Ot,$d=[pe],Rd=[pe],bo){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,a=ld(n,["element","effects"]);const{collisionDetector:o=_m}=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=Ce(()=>this.shape);return p&&d?.equals(p)?d:(this.shape=p,p)},l=Dr(!1);super(gi(Ir({},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 Hp(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,Cr),Pe(this,Ai,Oe(Kt,8,this)),Oe(Kt,11,this),Pe(this,Ei,Oe(Kt,12,this)),Oe(Kt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){rt(this,Cr,e,Pd)}get element(){var e;return(e=this.proxy)!=null?e:Se(this,Cr,Dd)}};Kt=Jn(bo);Ai=new WeakMap;Cr=new WeakSet;Ei=new WeakMap;Ia=Ct(Kt,20,"#element",$d,Cr,Ai),Dd=Ia.get,Pd=Ia.set;Ct(Kt,4,"proxy",Rd,Fd,Ei);Cn(Kt,Fd);function hg(e){return e!=null&&typeof e=="object"&&"current"in e}function Ns(e){var t;if(e!=null)return hg(e)?(t=e.current)!=null?t:void 0:e}var pg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ta=pg?m.useLayoutEffect:m.useEffect;function mg(){const e=m.useState(0)[1];return m.useCallback(()=>{e(t=>t+1)},[e])}function gg(e,t){const n=m.useRef(new Map),r=mg();return ta(()=>{if(!e){n.current.clear();return}return At(()=>{var s;let a=!1,o=!1;for(const i of n.current){const[l]=i,c=Ce(()=>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?Eo.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 on(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 ec(e,t){const n=m.useRef(Ns(e));ta(()=>{const r=Ns(e);r!==n.current&&(n.current=r,t(r))})}var vg=Object.defineProperty,yg=Object.defineProperties,bg=Object.getOwnPropertyDescriptors,tc=Object.getOwnPropertySymbols,wg=Object.prototype.hasOwnProperty,Cg=Object.prototype.propertyIsEnumerable,nc=(e,t,n)=>t in e?vg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_g=(e,t)=>{for(var n in t||(t={}))wg.call(t,n)&&nc(e,n,t[n]);if(tc)for(var n of tc(t))Cg.call(t,n)&&nc(e,n,t[n]);return e},xg=(e,t)=>yg(e,bg(t)),Sg=new xi,kg=m.createContext(Sg);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 ta(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),m.useImperativeHandle(t,()=>o),null}));function Ig(){return m.useContext(kg)}function Ag(e){var t;const n=(t=Ig())!=null?t:void 0,[r]=m.useState(()=>e(n));return r.manager!==n&&(r.manager=n),ta(r.register,[n,r]),r}function Aa(e){const{disabled:t,data:n,element:r,handle:s,id:a,modifiers:o,sensors:i}=e,l=Ag(u=>new Lr(xg(_g({},e),{register:!1,handle:Ns(s),element:Ns(r)}),u)),c=gg(l,Eg);return on(a,()=>l.id=a),ec(s,u=>l.handle=u),ec(r,u=>l.element=u),on(n,()=>n&&(l.data=n)),on(t,()=>l.disabled=t===!0),on(i,()=>l.sensors=i),on(o,()=>l.modifiers=o,void 0,xr),on(e.feedback,()=>{var u;return l.feedback=(u=e.feedback)!=null?u:"default"}),on(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 Eg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var Mg=Object.create,Od=Object.defineProperty,Tg=Object.getOwnPropertyDescriptor,Bd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),na=e=>{throw TypeError(e)},Rg=(e,t,n)=>t in e?Od(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$g=e=>{var t;return[,,,Mg((t=e?.[Bd("metadata")])!=null?t:null)]},Wd=["class","method","getter","setter","accessor","field","value","get","set"],Vd=e=>e!==void 0&&typeof e!="function"?na("Function expected"):e,Dg=(e,t,n,r,s)=>({kind:Wd[e],name:t,metadata:r,addInitializer:a=>n._?na("Already initialized"):s.push(Vd(a||null))}),Pg=(e,t)=>Rg(t,Bd("metadata"),e[3]),Fg=(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},Ld=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,p=!1,d=2,h=Wd[u+5],g=e[d]||(e[d]=[]),y=(s=s.prototype,Tg(s,n)),v=r.length-1;v>=0;v--)l=Dg(u,n,i={},e[3],g),l.static=f,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[v])(y[h],l),i._=1,Vd(o)&&(y[h]=o);return y&&Od(s,n,y),s},Nd=(e,t,n)=>t.has(e)||na("Cannot "+n),Og=(e,t,n)=>(Nd(e,t,"read from private field"),t.get(e)),Bg=(e,t,n)=>t.has(e)?na("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Wg=(e,t,n,r)=>(Nd(e,t,"write to private field"),t.set(e,n),n),tr=class wo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new wo(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 wo(t,n)}},Zd,Gd,Co,ws,Nr,Mi=class extends(Co=en,Gd=[Re],Zd=[Re],Co){constructor(t){const n=tr.from(t);super(n,(r,s)=>tr.equals(r,s)),Fg(Nr,5,this),Bg(this,ws,0),this.velocity={x:0,y:0}}get delta(){return tr.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=tr.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-Og(this,ws),i=l=>Math.round(l/o*100);qt(()=>{Wg(this,ws,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(tr.from(t)),this.velocity={x:0,y:0}}};Nr=$g(Co);ws=new WeakMap;Ld(Nr,2,"delta",Gd,Mi);Ld(Nr,2,"direction",Zd,Mi);Pg(Nr,Mi);var zd=(e=>(e.Horizontal="x",e.Vertical="y",e))(zd||{});Object.values(zd);const Vg=new Map([["bold",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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"}),F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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"}))]]),Lg=new Map([["bold",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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"}))]]),Ng=new Map([["bold",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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"}))]]),Zg=new Map([["bold",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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"}),F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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",F.createElement(F.Fragment,null,F.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"}))]]),Gg=m.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Zr=F.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}=F.useContext(Gg);return F.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&&F.createElement("title",null,n),i,l.get(a??p))});Zr.displayName="IconBase";const jd=F.forwardRef((e,t)=>F.createElement(Zr,{ref:t,...e,weights:Vg}));jd.displayName="DotsThreeIcon";const Hd=F.forwardRef((e,t)=>F.createElement(Zr,{ref:t,...e,weights:Lg}));Hd.displayName="SpeakerHighIcon";const Xd=F.forwardRef((e,t)=>F.createElement(Zr,{ref:t,...e,weights:Ng}));Xd.displayName="SpeakerLowIcon";const Yd=F.forwardRef((e,t)=>F.createElement(Zr,{ref:t,...e,weights:Zg}));Yd.displayName="XIcon";const zg=Yd;D.span`
|
|
67
67
|
font-family: 'Courier New', Monaco, monospace;
|
|
68
68
|
font-size: 1rem;
|
|
69
69
|
font-weight: 600;
|
|
70
70
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
71
71
|
user-select: none;
|
|
72
|
-
`;var
|
|
72
|
+
`;var Ti=D.button`
|
|
73
73
|
display: inline-flex;
|
|
74
74
|
align-items: center;
|
|
75
75
|
justify-content: center;
|
|
@@ -100,37 +100,37 @@
|
|
|
100
100
|
opacity: 0.6;
|
|
101
101
|
cursor: not-allowed;
|
|
102
102
|
}
|
|
103
|
-
`;
|
|
103
|
+
`;D(Ti)`
|
|
104
104
|
padding: 0.25rem 0.5rem;
|
|
105
105
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
106
|
-
`;
|
|
106
|
+
`;D(Ti)`
|
|
107
107
|
padding: 0.5rem;
|
|
108
108
|
min-width: 2.25rem;
|
|
109
109
|
min-height: 2.25rem;
|
|
110
|
-
`;
|
|
110
|
+
`;D(Ti)`
|
|
111
111
|
padding: 0.25rem;
|
|
112
112
|
min-width: 1.75rem;
|
|
113
113
|
min-height: 1.75rem;
|
|
114
114
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
115
|
-
`;var
|
|
115
|
+
`;var jg=D.div`
|
|
116
116
|
display: inline-flex;
|
|
117
117
|
align-items: center;
|
|
118
118
|
gap: 0.5rem;
|
|
119
|
-
`,
|
|
119
|
+
`,Hg=D.input`
|
|
120
120
|
cursor: pointer;
|
|
121
121
|
accent-color: ${e=>e.theme.inputFocusBorder};
|
|
122
122
|
|
|
123
123
|
&:disabled {
|
|
124
124
|
cursor: not-allowed;
|
|
125
125
|
}
|
|
126
|
-
`,
|
|
126
|
+
`,Xg=D.label`
|
|
127
127
|
margin: 0;
|
|
128
128
|
cursor: pointer;
|
|
129
129
|
user-select: none;
|
|
130
130
|
font-family: ${e=>e.theme.fontFamily};
|
|
131
131
|
font-size: ${e=>e.theme.fontSize};
|
|
132
132
|
color: ${e=>e.theme.textColor};
|
|
133
|
-
`,
|
|
133
|
+
`,_t=D.button`
|
|
134
134
|
padding: 0.5rem 1rem;
|
|
135
135
|
background: ${e=>e.theme.buttonBackground||"#007bff"};
|
|
136
136
|
color: ${e=>e.theme.buttonText||"white"};
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
cursor: not-allowed;
|
|
157
157
|
opacity: 0.6;
|
|
158
158
|
}
|
|
159
|
-
`,
|
|
159
|
+
`,Ud=D.input`
|
|
160
160
|
padding: 0.5rem 0.75rem;
|
|
161
161
|
font-family: ${e=>e.theme.fontFamily};
|
|
162
162
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -182,17 +182,17 @@
|
|
|
182
182
|
opacity: 0.6;
|
|
183
183
|
cursor: not-allowed;
|
|
184
184
|
}
|
|
185
|
-
`;
|
|
185
|
+
`;D(Ud)`
|
|
186
186
|
padding: 0.25rem 0.5rem;
|
|
187
187
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
188
|
-
`;var
|
|
188
|
+
`;var Yg=D.label`
|
|
189
189
|
font-family: ${e=>e.theme.fontFamily};
|
|
190
190
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
191
191
|
font-weight: 500;
|
|
192
192
|
color: ${e=>e.theme.textColorMuted};
|
|
193
193
|
margin-bottom: 0.25rem;
|
|
194
194
|
display: block;
|
|
195
|
-
`;
|
|
195
|
+
`;D.label`
|
|
196
196
|
font-family: ${e=>e.theme.fontFamily};
|
|
197
197
|
font-size: ${e=>e.theme.fontSize};
|
|
198
198
|
color: ${e=>e.theme.textColor};
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
align-items: center;
|
|
201
201
|
gap: 0.5rem;
|
|
202
202
|
cursor: pointer;
|
|
203
|
-
`;var
|
|
203
|
+
`;var Ug=D.span`
|
|
204
204
|
position: absolute;
|
|
205
205
|
width: 1px;
|
|
206
206
|
height: 1px;
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
clip: rect(0, 0, 0, 0);
|
|
211
211
|
white-space: nowrap;
|
|
212
212
|
border: 0;
|
|
213
|
-
`,
|
|
213
|
+
`,Kd=D.select`
|
|
214
214
|
padding: 0.5rem 2rem 0.5rem 0.75rem;
|
|
215
215
|
font-family: ${e=>e.theme.fontFamily};
|
|
216
216
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -243,10 +243,10 @@
|
|
|
243
243
|
color: ${e=>e.theme.inputText};
|
|
244
244
|
background-color: ${e=>e.theme.inputBackground};
|
|
245
245
|
}
|
|
246
|
-
`;
|
|
246
|
+
`;D(Kd)`
|
|
247
247
|
padding: 0.25rem 1.75rem 0.25rem 0.5rem;
|
|
248
248
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
249
|
-
`;var
|
|
249
|
+
`;var Qd=D.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
|
-
`,
|
|
329
|
+
`,Kg=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.checked)};return x.jsxs(jg,{className:r,children:[x.jsx(Hg,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:s,disabled:n}),x.jsx(Xg,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function qd(e){return typeof e=="object"&&e!==null&&"type"in e}function Jt(e){if(!qd(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 Jd={waveformDrawMode:"inverted",waveOutlineColor:"#ffffff",waveFillColor:"#1a7f8e",waveProgressColor:"rgba(0, 0, 0, 0.10)",selectedWaveOutlineColor:"#ffffff",selectedWaveFillColor:"#00b4d8",selectedTrackControlsBackground:"#d9e9ff",selectedTrackBackground:"#e8f0fe",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"},Qg=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)}},ef=m.createContext(null),qg=()=>()=>{},Jg=({containerRef:e,children:t})=>{const n=m.useRef(null);n.current===null&&(n.current=new Qg(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]),x.jsx(ef.Provider,{value:r,children:t})};function ev(e){const t=m.useContext(ef);return m.useSyncExternalStore(t?t.subscribe:qg,()=>e(t?t.getSnapshot():null),()=>e(null))}function ra(e,t,n=0){const r=ev(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 tf=m.createContext(0),tv=({originX:e,children:t})=>x.jsx(tf.Provider,{value:e,children:t}),Ri=()=>m.useContext(tf);function sa(){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 nv(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 rv(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 sv(e,t,n){return Math.floor((e-t+n)/n)*n}function av(e,t,n,r){if(!qd(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 ov=D.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
|
-
`,
|
|
335
|
+
`,iv=D.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
|
-
`,
|
|
341
|
+
`,rc=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:g}=sa(),y=Ri(),v=ra(r,Be,y);m.useLayoutEffect(()=>{const _=u+f;for(const[S,k]of g.current.entries()){const I=S*Be,E=k.getContext("2d"),A=Math.floor(i/2);if(E){E.resetTransform(),E.clearRect(0,0,k.width,k.height),E.imageSmoothingEnabled=!1,E.scale(o,o);const R=k.width/o;let T;d==="normal"?T=c:T=l,E.fillStyle=av(E,T,R,i);const M=I,$=I+R,O=sv(M,u,_);for(let P=Math.max(0,O);P<$;P+=_){const V=P-M;if(V+u<=0)continue;const X=Math.min(P+_,r),ge=nv(t,n,P,X);if(ge){const re=rv(V,u,A,ge.min,ge.max,d);for(const se of re)E.fillRect(se.x,se.y,se.width,se.height)}}}}},[g,t,n,i,l,c,o,r,u,f,d,v,s]);const b=v.map(_=>{const S=_*Be,k=Math.min(r-S,Be);return x.jsx(ov,{$cssWidth:k,$left:S,width:k*o,height:i*o,$waveHeight:i,"data-index":_,ref:h},`${r}-${_}`)}),C=p?"transparent":Jt(c);return x.jsx(iv,{$index:s,$cssWidth:r,className:a,$waveHeight:i,$waveFillColor:C,children:b})},lv={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:x.jsx("div",{style:lv,children:"Waveform playlist encountered an error. Check console for details."}):this.props.children}});var $i=22,nf=D.div`
|
|
342
342
|
position: relative;
|
|
343
|
-
height: ${
|
|
343
|
+
height: ${$i}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
|
-
`,
|
|
365
|
+
`,rf=D.span`
|
|
366
366
|
font-size: 11px;
|
|
367
367
|
font-weight: 600;
|
|
368
368
|
font-family: ${e=>e.theme.clipHeaderFontFamily};
|
|
@@ -370,12 +370,12 @@
|
|
|
370
370
|
white-space: nowrap;
|
|
371
371
|
overflow: hidden;
|
|
372
372
|
text-overflow: ellipsis;
|
|
373
|
-
`,
|
|
373
|
+
`,cv=({trackName:e,isSelected:t=!1})=>x.jsx(nf,{$interactive:!1,$isSelected:t,children:x.jsx(rf,{title:e,children:e})}),uv=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:s=!1,disableDrag:a=!1,dragHandleProps:o})=>{if(a||!o)return x.jsx(cv,{trackName:r,isSelected:s});const{handleRef:i}=o;return x.jsx(nf,{ref:i,"data-clip-id":e,$interactive:!0,$isSelected:s,children:x.jsx(rf,{title:r,children:r})})},dv=8,fv=24,hv=D.div`
|
|
374
374
|
position: absolute;
|
|
375
375
|
${e=>e.$edge==="left"?"left: 0;":"right: 0;"}
|
|
376
376
|
top: 0;
|
|
377
377
|
bottom: 0;
|
|
378
|
-
width: ${e=>e.$touchOptimized?
|
|
378
|
+
width: ${e=>e.$touchOptimized?fv:dv}px;
|
|
379
379
|
cursor: col-resize;
|
|
380
380
|
user-select: none;
|
|
381
381
|
z-index: 105; /* Above waveform, below header */
|
|
@@ -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
|
-
`,
|
|
401
|
+
`,sc=({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 x.jsx(hv,{ref:l,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:c,$isHovered:o,$touchOptimized:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1)})},pv=D.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
|
-
`,
|
|
407
|
+
`,mv=D.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
|
|
413
|
+
`;function gv(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 Zs=({left:e,width:t,type:n,curveType:r="logarithmic",color:s})=>{const a=D.useTheme();if(t<1)return null;const o=s||a?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return x.jsx(pv,{$left:e,$width:t,$type:n,children:x.jsx(mv,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:x.jsx("path",{d:gv(t,100,r),fill:o})})})},vv=D.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
|
-
`,
|
|
422
|
+
`,yv=D.div`
|
|
423
423
|
flex: 1;
|
|
424
424
|
position: relative;
|
|
425
425
|
overflow: ${e=>e.$isOverlay?"visible":"hidden"};
|
|
426
|
-
`,
|
|
426
|
+
`,_o=({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:g,fadeOut:y,sampleRate:v=44100,showFades:b=!1,touchOptimized:w=!1})=>{const C=Math.floor(o/l),_=Ec(o,i,l),S=c&&!u&&!f,k=`clip-${r}-${s}`,{ref:I,handleRef:E,isDragSource:A}=Aa({id:k,data:{clipId:n,trackIndex:r,clipIndex:s,startSample:o,durationSamples:i},disabled:!S}),R=`clip-boundary-left-${r}-${s}`,{ref:T,isDragSource:M}=Aa({id:R,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"left",startSample:o,durationSamples:i},disabled:!S,feedback:"none"}),$=`clip-boundary-right-${r}-${s}`,{ref:O,isDragSource:P}=Aa({id:$,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"right",startSample:o,durationSamples:i},disabled:!S,feedback:"none"}),V=A?{zIndex:100}:void 0;return x.jsxs(vv,{ref:I,style:V,className:t,$left:C,$width:_,$isOverlay:f,"data-clip-container":"true","data-track-id":h,onMouseDown:d,tabIndex:-1,children:[c&&x.jsx(uv,{clipId:n,trackIndex:r,clipIndex:s,trackName:a,isSelected:p,disableDrag:u,dragHandleProps:S?{handleRef:E}:void 0}),x.jsx(tv,{originX:C,children:x.jsxs(yv,{$isOverlay:f,children:[e,b&&g&&g.duration>0&&x.jsx(Zs,{left:0,width:Math.floor(g.duration*v/l),type:"fadeIn",curveType:g.type}),b&&y&&y.duration>0&&x.jsx(Zs,{left:_-Math.floor(y.duration*v/l),width:Math.floor(y.duration*v/l),type:"fadeOut",curveType:y.type})]})}),c&&!u&&!f&&x.jsxs(x.Fragment,{children:[x.jsx(sc,{clipId:n,trackIndex:r,clipIndex:s,edge:"left",touchOptimized:w,dragHandleProps:{ref:T,isDragging:M}}),x.jsx(sc,{clipId:n,trackIndex:r,clipIndex:s,edge:"right",touchOptimized:w,dragHandleProps:{ref:O,isDragging:P}})]})]})},bv=D.div`
|
|
427
427
|
display: inline-flex;
|
|
428
428
|
align-items: center;
|
|
429
429
|
gap: 0.5rem;
|
|
430
|
-
`,
|
|
430
|
+
`,wv=D(Yg)`
|
|
431
431
|
margin: 0;
|
|
432
432
|
white-space: nowrap;
|
|
433
|
-
`,
|
|
433
|
+
`,Cv=D(Qd)`
|
|
434
434
|
width: 120px;
|
|
435
|
-
`,
|
|
435
|
+
`,_v=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(parseFloat(a.target.value)/100)};return x.jsxs(bv,{className:r,children:[x.jsx(wv,{htmlFor:"master-gain",children:"Master Volume"}),x.jsx(Cv,{min:"0",max:"100",value:e*100,onChange:s,disabled:n,id:"master-gain"})]})},xv=D.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
|
-
`,
|
|
440
|
+
`,Sv=D.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
|
-
`,
|
|
445
|
+
`,kv=({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}=sa(),g=Ri(),y=ra(n,Be,g),{minMidi:v,maxMidi:b}=m.useMemo(()=>{if(t.length===0)return{minMidi:0,maxMidi:127};let S=127,k=0;for(const I of t)I.midi<S&&(S=I.midi),I.midi>k&&(k=I.midi);return{minMidi:Math.max(0,S-1),maxMidi:Math.min(127,k+1)}},[t]),w=u?c:l;m.useLayoutEffect(()=>{const S=b-v+1,k=Math.max(2,r/S),I=o/a;for(const[E,A]of h.current.entries()){const R=E*Be,T=A.width/s,M=A.getContext("2d");if(!M)continue;M.resetTransform(),M.clearRect(0,0,A.width,A.height),M.imageSmoothingEnabled=!1,M.scale(s,s);const $=R*a/o,O=(R+T)*a/o;for(const P of t){const V=P.time-i;if(V+P.duration<=$||V>=O)continue;const ge=V*I-R,re=Math.max(2,P.duration*I),se=(b-P.midi)/S*r,Ie=.3+P.velocity*.7;M.fillStyle=w,M.globalAlpha=Ie;const j=1;M.beginPath(),M.roundRect(ge,se,re,k,j),M.fill()}M.globalAlpha=1}},[h,t,r,s,a,o,i,w,v,b,n,y,e]);const C=y.map(S=>{const k=S*Be,I=Math.min(n-k,Be);return x.jsx(xv,{$cssWidth:I,$left:k,width:I*s,height:r*s,$waveHeight:r,"data-index":S,ref:d},`${n}-${S}`)}),_=f?"transparent":p;return x.jsx(Sv,{$index:e,$cssWidth:n,$waveHeight:r,$backgroundColor:_,children:C})};D.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
|
-
`;
|
|
455
|
+
`;D.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
|
-
`;
|
|
463
|
+
`;D.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
|
-
`;
|
|
472
|
+
`;D.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
|
|
479
|
+
`;var Iv=D.div`
|
|
480
480
|
display: flex;
|
|
481
481
|
overflow-y: hidden;
|
|
482
482
|
position: relative;
|
|
483
|
-
`,
|
|
483
|
+
`,Av=D.div.attrs(e=>({style:{width:`${e.$width}px`}}))`
|
|
484
484
|
flex-shrink: 0;
|
|
485
485
|
overflow: hidden;
|
|
486
|
-
`,
|
|
486
|
+
`,Ev=D.div.attrs(e=>({style:{height:`${e.$height}px`}}))``,Mv=D.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
|
-
`,
|
|
492
|
+
`,Tv=D.div.attrs(e=>({style:e.$width!==void 0?{width:`${e.$width}px`}:{}}))`
|
|
493
493
|
position: relative;
|
|
494
494
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
495
|
-
`,
|
|
495
|
+
`,Rv=D.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
|
-
|
|
500
|
+
`,$v=D.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
|
-
`,
|
|
504
|
+
`,Dv=D.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
|
-
`,
|
|
513
|
+
`,Di=({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:g=0})=>{const y=m.useRef(null),v=m.useCallback(w=>{y.current=w,f?.(w)},[f]),b=o!==void 0&&o>0;return x.jsxs(Iv,{"data-playlist-state":d,children:[b&&x.jsxs(Av,{$width:o,children:[g>0&&x.jsx(Ev,{$height:g}),h]}),x.jsx(Mv,{"data-scroll-container":"true",ref:v,children:x.jsx(Jg,{containerRef:y,children:x.jsxs(Tv,{$backgroundColor:t,$width:a,children:[r&&x.jsx(Rv,{$width:s,$backgroundColor:n,children:r}),x.jsxs($v,{$width:a,$backgroundColor:t,children:[e,(i||l)&&x.jsx(Dv,{$isSelecting:p,onClick:i,onMouseDown:l,onMouseMove:c,onMouseUp:u})]})]})})})]})};D.withTheme(Di);var Pv=D.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
|
-
`,
|
|
521
|
+
`,sf=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:x.jsx(Pv,{$left:e,$width:r,$color:n,"data-selection":!0})};D.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
|
-
`;
|
|
528
|
+
`;D.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
|
|
548
|
+
`;var ac=D.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
|
-
`,
|
|
585
|
+
`,Fv=D.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
|
-
`,
|
|
596
|
+
`,Ov=({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),g=m.useCallback((v,b)=>{v.preventDefault(),v.stopPropagation(),u(b),f.current=v.clientX,p.current=b==="start"?e:t;const w=_=>{const S=_.clientX-f.current,k=p.current+S;if(b==="start"){const I=Math.max(i,Math.min(t-10,k));s?.(I)}else{const I=Math.max(e+10,Math.min(l,k));a?.(I)}},C=()=>{u(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",C)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",C)},[e,t,i,l,s,a]),y=m.useCallback(v=>{v.preventDefault(),v.stopPropagation(),u("region"),f.current=v.clientX,p.current=e,d.current=t;const b=t-e,w=_=>{const S=_.clientX-f.current;let k=p.current+S,I=d.current+S;k<i&&(k=i,I=i+b),I>l&&(I=l,k=l-b),o?.(k,I)},C=()=>{u(null),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",C)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",C)},[e,t,i,l,o]);return h<=0?null:x.jsxs(x.Fragment,{children:[x.jsx(Fv,{$left:e,$width:h,$color:r,$isDragging:c==="region",onMouseDown:y,"data-loop-region-timescale":!0}),x.jsx(ac,{$left:e,$color:n,$isStart:!0,$isDragging:c==="start",onMouseDown:v=>g(v,"start"),"data-loop-marker-handle":"start"}),x.jsx(ac,{$left:t,$color:n,$isStart:!1,$isDragging:c==="end",onMouseDown:v=>g(v,"end"),"data-loop-marker-handle":"end"})]})},Bv=D.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
|
-
`,
|
|
604
|
+
`,Wv=({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 g=p.clientX-h.left,y=Math.max(a,Math.min(o,g));l.current=y,s?.(y,y);const v=w=>{const C=w.clientX-h.left,_=Math.max(a,Math.min(o,C)),S=Math.min(l.current,_),k=Math.max(l.current,_);s?.(S,k)},b=()=>{i(!1),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",v),document.addEventListener("mouseup",b)},[a,o,s]);return x.jsx(Bv,{ref:c,onMouseDown:f,"data-timescale-loop-creator":!0,children:u&&x.jsx(Ov,{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 nr(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 Vn(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return nr(e,0);case"hh:mm:ss.u":return nr(e,1);case"hh:mm:ss.uu":return nr(e,2);case"hh:mm:ss.uuu":return nr(e,3);default:return nr(e,3)}}function af(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 oc=({id:e,label:t,value:n,format:r,className:s,onChange:a,readOnly:o=!1})=>{const[i,l]=m.useState("");m.useEffect(()=>{const p=Vn(n,r);l(p)},[n,r,e]);const c=p=>{const d=p.target.value;l(d)},u=()=>{if(a){const p=af(i,r);a(p)}l(Vn(n,r))},f=p=>{p.key==="Enter"&&p.currentTarget.blur()};return x.jsxs(x.Fragment,{children:[x.jsx(Ug,{as:"label",htmlFor:e,children:t}),x.jsx(Ud,{type:"text",className:s,id:e,value:i,onChange:c,onBlur:u,onKeyDown:f,readOnly:o})]})},Vv=({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 x.jsxs("div",{className:r,children:[x.jsx(oc,{id:"audio_start",label:"Start of audio selection",value:e,format:s,className:"audio-start form-control mr-sm-2",onChange:o}),x.jsx(oc,{id:"audio_end",label:"End of audio selection",value:t,format:s,className:"audio-end form-control mr-sm-2",onChange:i})]})},Lv=m.createContext(null);function of(){return m.useContext(Lv)}function Cs(){return window.devicePixelRatio}var lf=m.createContext(Cs()),cf=({children:e})=>{const[t,n]=m.useState(Cs());return matchMedia(`(resolution: ${Cs()}dppx)`).addEventListener("change",()=>{n(Cs())},{once:!0}),x.jsx(lf.Provider,{value:Math.ceil(t),children:e})},Pi=()=>m.useContext(lf),Gr=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}),aa=()=>m.useContext(Gr),zr=()=>m.useContext(D.ThemeContext);m.createContext(x.jsx(m.Fragment,{}));var Nv=0,Zv=!1,Gv=0,zv=0,jv={progress:Nv,isPlaying:Zv,selectionStart:Gv,selectionEnd:zv};m.createContext(jv);m.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var Hv=D.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
|
-
`,
|
|
609
|
+
`,Xv=D.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
|
-
`,
|
|
614
|
+
`,ic=({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}=sa(),p=m.useRef([]),d=m.useRef(new WeakSet),h=m.useRef(o),g=m.useRef(l),y=Ri(),v=ra(n,Be,y);m.useEffect(()=>{h.current=o},[o]),m.useEffect(()=>{g.current=l},[l]),m.useEffect(()=>{const w=h.current;if(!w||!i)return;const C=p.current.length,_=[];for(const I of p.current){const E=I.match(/chunk(\d+)$/);if(!E){_.push(I);continue}const A=parseInt(E[1],10),R=f.current.get(A);if(R&&R.isConnected)_.push(I);else try{w.unregisterCanvas(I)}catch(T){console.warn(`[spectrogram] unregisterCanvas failed for ${I}:`,T)}}p.current=_;const S=[];for(const[I,E]of f.current.entries()){if(d.current.has(E))continue;const A=`${i}-ch${c}-chunk${I}`;let R;try{R=E.transferControlToOffscreen()}catch(T){console.warn(`[spectrogram] transferControlToOffscreen failed for ${A}:`,T);continue}d.current.add(E);try{w.registerCanvas(A,R),S.push(A)}catch(T){console.warn(`[spectrogram] registerCanvas failed for ${A}:`,T);continue}}if(S.length>0&&(p.current=[...p.current,...S]),S.length>0||_.length<C){const I=p.current,E=I.map(A=>{const R=A.match(/chunk(\d+)$/);if(!R)return console.warn(`[spectrogram] Unexpected canvas ID format: ${A}`),Be;const T=parseInt(R[1],10);return Math.min(n-T*Be,Be)});g.current?.(I,E)}},[f,i,c,n,v]),m.useEffect(()=>()=>{const w=h.current;if(w){for(const C of p.current)try{w.unregisterCanvas(C)}catch(_){console.warn(`[spectrogram] unregisterCanvas failed for ${C}:`,_)}p.current=[]}},[]);const b=v.map(w=>{const C=w*Be,_=Math.min(n-C,Be);return x.jsx(Xv,{$cssWidth:_,$left:C,width:_*s,height:r*s,$waveHeight:r,"data-index":w,ref:u},`${n}-${w}`)});return x.jsx(Hv,{$index:e,$cssWidth:n,$waveHeight:r,children:b})},uf=({isSelected:e,transparentBackground:t,renderMode:n="waveform",samplesPerPixel:r,spectrogramWorkerApi:s,spectrogramClipId:a,spectrogramOnCanvasesReady:o,midiNotes:i,sampleRate:l,clipOffsetSeconds:c,...u})=>{const f=zr(),{waveHeight:p,barWidth:d,barGap:h,samplesPerPixel:g,sampleRate:y}=aa(),v=Pi(),b=r??g,w=e&&f?f.selectedWaveOutlineColor:f?.waveOutlineColor,C=e&&f?f.selectedWaveFillColor:f?.waveFillColor,_=f?.waveformDrawMode||"inverted",S=s&&a;if(n==="spectrogram"&&S)return x.jsx(ic,{index:u.index,length:u.length,waveHeight:p,devicePixelRatio:v,samplesPerPixel:b,workerApi:s,clipId:a,onCanvasesReady:o});if(n==="both"&&S){const k=Math.floor(p/2);return x.jsxs(x.Fragment,{children:[x.jsx(ic,{index:u.index*2,channelIndex:u.index,length:u.length,waveHeight:k,devicePixelRatio:v,samplesPerPixel:b,workerApi:s,clipId:a,onCanvasesReady:o}),x.jsx("div",{style:{position:"absolute",top:(u.index*2+1)*k,width:u.length,height:k},children:x.jsx(rc,{...u,index:0,waveOutlineColor:w,waveFillColor:C,waveHeight:k,devicePixelRatio:v,barWidth:d,barGap:h,transparentBackground:t,drawMode:_})})]})}return n==="piano-roll"?x.jsx(kv,{index:u.index,midiNotes:i??[],length:u.length,waveHeight:p,devicePixelRatio:v,samplesPerPixel:b,sampleRate:l??y,clipOffsetSeconds:c??0,noteColor:f?.pianoRollNoteColor,selectedNoteColor:f?.pianoRollSelectedNoteColor,isSelected:e,transparentBackground:t,backgroundColor:f?.pianoRollBackgroundColor}):x.jsx(rc,{...u,waveOutlineColor:w,waveFillColor:C,waveHeight:p,devicePixelRatio:v,barWidth:d,barGap:h,transparentBackground:t,drawMode:_})},lc=72,Yv=D.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
|
|
622
|
+
`;function Uv(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 Kv=({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=Pi(),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 g=h.getContext("2d");if(!g)return;g.resetTransform(),g.clearRect(0,0,h.width,h.height),g.scale(u,u);const y=Uv(r,s,f);for(let v=0;v<t;v++){const b=v*e+d;g.font="11px monospace",g.textBaseline="middle";for(const w of y){const C=n(w,r,s);if(C<0||C>1)continue;const _=b+f*(1-C),S=w>=1e3?`${(w/1e3).toFixed(1)}k`:`${w} Hz`,k=g.measureText(S),I=3;g.fillStyle=o,g.fillRect(0,_-7,k.width+I*2,14),g.fillStyle=a,g.fillText(S,I,_)}}},[e,t,n,r,s,a,o,u,f,d]),x.jsx(Yv,{$height:p+d,children:x.jsx("canvas",{ref:c,width:lc*u,height:(p+d)*u,style:{width:lc,height:p+d,pointerEvents:"none"}})})},Qv=D.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
|
-
`,
|
|
627
|
+
`,qv=D.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
|
-
`,
|
|
630
|
+
`,Jv=e=>{const{theme:{timeColor:t},tickData:n}=e,{canvasRef:r,canvasMapRef:s}=sa(),{timeScaleHeight:a}=m.useContext(Gr),o=Pi(),{widthX:i,canvasInfo:l,timeMarkersWithPositions:c}=n,u=ra(i,Be),f=u.map(g=>{const y=g*Be,v=Math.min(i-y,Be);return x.jsx(qv,{$cssWidth:v,$left:y,$timeScaleHeight:a,width:v*o,height:a*o,"data-index":g,ref:r},`timescale-${g}`)}),p=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:g})=>g>=p&&g<d).map(({element:g})=>g):c.map(({element:g})=>g);return m.useLayoutEffect(()=>{for(const[g,y]of s.current.entries()){const v=y.getContext("2d");if(!v)continue;const b=g*Be,w=y.width/o;v.resetTransform(),v.clearRect(0,0,y.width,y.height),v.imageSmoothingEnabled=!1,v.fillStyle=t,v.scale(o,o);for(const[C,_]of l.entries()){if(C<b||C>=b+w)continue;const S=C-b,k=a-_;v.fillRect(S,k,1,_)}}},[s,o,t,a,l,u]),x.jsxs(Qv,{$cssWidth:i,$timeScaleHeight:a,children:[h,f]})},e0=D.withTheme(Jv),cc=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 xo(e){const t=cc.keys();let n;for(const r of t)if(e<r){n=cc.get(r);break}return n===void 0&&(n={marker:3e4,bigStep:1e4,smallStep:5e3}),n}function t0(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var n0=D.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
|
-
`,
|
|
635
|
+
`,df=({renderTick:e})=>{const{samplesPerPixel:t,sampleRate:n,duration:r,timeScaleHeight:s}=m.useContext(Gr),a=of(),o=m.useMemo(()=>{const i=yh(r/1e3,t,n);if(a&&a.scaleMode==="beats"){const{bpm:y,timeSignature:v,ticksPerBar:b,ticksPerBeat:w}=a,C=new Map,_=[],S=r/1e3,k=Math.ceil(S*y*Hn/60),I=Bn(w,y,n)/t,E=Bn(b,y,n)/t,A=10,R=30;let T;if(I>=A)T=w;else if(E>=A)T=b;else{const $=Math.ceil(A/E);T=b*$}let M;if(I>=R)M=w;else if(E>=R)M=b;else{const $=Math.ceil(R/E);M=b*$}for(let $=0;$<=k;$+=T){const O=Bn($,y,n),P=vh(O,t);if(P>=i)break;const V=$%b===0,X=$%M===0,ge=V?s:Math.floor(X?s/2:s/5);if(C.set(P,ge),X){const re=bh($,v),se=e?x.jsx(m.Fragment,{children:e(re,P)},`bb-${$}`):x.jsx("div",{style:{position:"absolute",left:`${P+4}px`,fontSize:"0.75rem",whiteSpace:"nowrap"},children:re},`bb-${$}`);_.push({pix:P,element:se})}}return{widthX:i,canvasInfo:C,timeMarkersWithPositions:_}}const l=xo(t),{marker:c,bigStep:u,smallStep:f}=l,p=new Map,d=[],h=n/t;let g=0;for(let y=0;y<i;y+=h*f/1e3){const v=Math.floor(y);if(g%c===0){const b=t0(g),w=e?x.jsx(m.Fragment,{children:e(b,v)},`timestamp-${g}`):x.jsx(n0,{$left:v,children:b},b);d.push({pix:v,element:w}),p.set(v,s)}else g%u===0?p.set(v,Math.floor(s/2)):g%f===0&&p.set(v,Math.floor(s/5));g+=f}return{widthX:i,canvasInfo:p,timeMarkersWithPositions:d}},[a,r,t,n,s,e]);return x.jsx(e0,{tickData:o})},r0=D.div`
|
|
636
636
|
display: inline-flex;
|
|
637
637
|
align-items: center;
|
|
638
638
|
gap: 0.5rem;
|
|
639
|
-
`,
|
|
639
|
+
`,s0=[{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"}],a0=({value:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.value)};return x.jsx(r0,{className:r,children:x.jsx(Kd,{className:"time-format",value:e,onChange:s,disabled:n,"aria-label":"Time format selection",children:s0.map(a=>x.jsx("option",{value:a.value,children:a.label},a.value))})})},o0=D.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?$i:0)}px`}}))`
|
|
640
640
|
position: relative;
|
|
641
641
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
642
|
-
`,
|
|
642
|
+
`,i0=D.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
|
|
643
643
|
position: relative;
|
|
644
|
-
background: ${e=>e.$backgroundColor||"transparent"};
|
|
644
|
+
background: ${e=>e.$isSelected?e.theme.selectedTrackBackground||e.$backgroundColor||"transparent":e.$backgroundColor||"transparent"};
|
|
645
645
|
height: 100%;
|
|
646
|
-
`,
|
|
646
|
+
`,ff=({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}=aa();return x.jsx(o0,{$numChannels:e,className:n,$waveHeight:u,$width:a,$hasClipHeaders:o,children:x.jsx(i0,{$backgroundColor:r,$offset:s,$isSelected:c,onClick:i,"data-track-id":l,children:t})})},uc=D.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
|
-
`,
|
|
708
|
+
`,l0=D.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
|
-
`,
|
|
720
|
+
`,c0=D.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
|
-
`,
|
|
742
|
+
`,u0=({onClick:e,title:t="Remove track"})=>x.jsx(c0,{onClick:e,title:t,children:x.jsx(zg,{size:12,weight:"bold"})}),d0=D.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
|
-
`,
|
|
755
|
+
`,f0=D.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
|
-
`,
|
|
766
|
+
`,h0=e=>x.jsx(Xd,{weight:"light",...e}),p0=e=>x.jsx(Hd,{weight:"light",...e}),m0=e=>x.jsx(jd,{weight:"bold",...e}),dc=D(Qd)`
|
|
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
|
-
`,
|
|
815
|
+
`,fc=D.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
|
-
`,
|
|
823
|
+
`,g0=D.div`
|
|
824
824
|
position: relative;
|
|
825
825
|
display: inline-block;
|
|
826
|
-
`,
|
|
826
|
+
`,v0=D.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
|
-
`,
|
|
840
|
+
`,_s=180,y0=D.div`
|
|
841
841
|
position: fixed;
|
|
842
842
|
top: ${e=>e.$top}px;
|
|
843
843
|
left: ${e=>e.$left}px;
|
|
@@ -847,14 +847,65 @@
|
|
|
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: ${
|
|
850
|
+
min-width: ${_s}px;
|
|
851
851
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
852
|
-
`,
|
|
852
|
+
`,b0=D.hr`
|
|
853
853
|
border: none;
|
|
854
854
|
border-top: 1px solid rgba(128, 128, 128, 0.3);
|
|
855
855
|
margin: 0.35rem 0;
|
|
856
|
-
`,
|
|
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}};function D0(e,t,n){if(!n||e.repeat)return;const r=e.target;if(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)return;const s=t.find(a=>{const o=e.key.toLowerCase()===a.key.toLowerCase()||e.key===a.key,i=a.ctrlKey===void 0||e.ctrlKey===a.ctrlKey,l=a.shiftKey===void 0||e.shiftKey===a.shiftKey,c=a.metaKey===void 0||e.metaKey===a.metaKey,u=a.altKey===void 0||e.altKey===a.altKey;return o&&i&&l&&c&&u});s&&(s.preventDefault!==!1&&e.preventDefault(),s.action())}const Ps=e=>{const{shortcuts:t,enabled:n=!0}=e,r=m.useCallback(s=>D0(s,t,n),[t,n]);m.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},P0=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),F0=e=>Wr.filter(t=>t.category===e),O0=[{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 L0={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 B0=0;const W0=()=>`effect_${Date.now()}_${++B0}`;function kr(e,t){const n=L0[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=W0(),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 V0(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 N0(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 j0(){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 z0(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 H0(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 U0(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=z0(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 H0(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(G0(_.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 G0(e){return 20*Math.log10(Math.max(e,1e-4))}async function U0(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}},X0=`
|
|
856
|
+
`,w0=({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+_s>f&&(h=u.left-_s-4),h=Math.max(4,Math.min(h,f-_s-4));let g=u.top;g+d>p-4&&(g=Math.max(4,u.bottom-d)),o({top:g,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]),x.jsxs(g0,{children:[x.jsx(v0,{ref:i,onClick:u=>{u.stopPropagation(),n(f=>!f)},onMouseDown:u=>u.stopPropagation(),title:"Track menu","aria-label":"Track menu",children:x.jsx(m0,{size:16})}),t&&typeof document<"u"&&Eo.createPortal(x.jsx(y0,{ref:l,$top:a.top,$left:a.left,onMouseDown:u=>u.stopPropagation(),children:s.map((u,f)=>x.jsxs(m.Fragment,{children:[f>0&&x.jsx(b0,{}),u.content]},u.id))}),document.body)]})},C0=[{dB:2,color:"#ff0000"},{dB:-1,color:"#e74c3c"},{dB:-3,color:"#e67e22"},{dB:-6,color:"#f1c40f"},{dB:-12,color:"#2ecc71"},{dB:-20,color:"#27ae60"},{dB:-30,color:"#5dade2"},{dB:-50,color:"#85c1e9"}],_0=.15,hf="rgba(128, 128, 128, 0.2)",hc="#ffffff";function x0(e){return e===1?["M"]:e===2?["L","R"]:Array.from({length:e},(t,n)=>String(n+1))}function S0(e,t){if(t.length===0)return hf;for(const n of t)if(e>=n.dB)return n.color;return t[t.length-1].color}function k0(e,t){const n=Math.max(2,e),[r,s]=t,a=(s-r)/(n-1);return Array.from({length:n},(o,i)=>s-i*a)}function I0(e){return Math.round(e).toString()}var Ea=D.div`
|
|
857
|
+
display: inline-flex;
|
|
858
|
+
flex-direction: ${e=>e.$orientation==="horizontal"?"column":"row"};
|
|
859
|
+
gap: 4px;
|
|
860
|
+
font-family: 'Courier New', monospace;
|
|
861
|
+
`,A0=D.div`
|
|
862
|
+
display: flex;
|
|
863
|
+
flex-direction: ${e=>e.$orientation==="horizontal"?"row":"column"};
|
|
864
|
+
align-items: center;
|
|
865
|
+
gap: 4px;
|
|
866
|
+
`,E0=D.div`
|
|
867
|
+
display: flex;
|
|
868
|
+
flex-direction: ${e=>e.$orientation==="horizontal"?"row":"column"};
|
|
869
|
+
`,M0=D.div.attrs(e=>({style:{width:`${e.$width}px`,height:`${e.$height}px`,...e.$orientation==="horizontal"?{marginRight:`${e.$gap}px`}:{marginBottom:`${e.$gap}px`},backgroundColor:e.$isPeak?hc:e.$active||e.$coloredInactive?e.$color:hf,opacity:e.$isPeak||e.$active?1:e.$coloredInactive?_0:1,boxShadow:e.$active||e.$isPeak?`0 0 4px ${e.$isPeak?hc:e.$color}40`:"none"}}))`
|
|
870
|
+
border-radius: 1px;
|
|
871
|
+
`,T0="#888",Ma=D.div`
|
|
872
|
+
color: ${e=>e.$labelColor};
|
|
873
|
+
font-size: 10px;
|
|
874
|
+
text-align: center;
|
|
875
|
+
user-select: none;
|
|
876
|
+
`,R0=D.div`
|
|
877
|
+
display: flex;
|
|
878
|
+
flex-direction: column;
|
|
879
|
+
position: relative;
|
|
880
|
+
min-width: 28px;
|
|
881
|
+
`,$0=D.div.attrs(e=>({style:{top:`${e.$top}px`,color:e.$labelColor}}))`
|
|
882
|
+
position: absolute;
|
|
883
|
+
left: 50%;
|
|
884
|
+
font-size: 9px;
|
|
885
|
+
font-family: 'Courier New', monospace;
|
|
886
|
+
white-space: nowrap;
|
|
887
|
+
transform: translate(-50%, -50%);
|
|
888
|
+
user-select: none;
|
|
889
|
+
`,D0=D.div`
|
|
890
|
+
display: flex;
|
|
891
|
+
flex-direction: row;
|
|
892
|
+
align-items: center;
|
|
893
|
+
gap: 4px;
|
|
894
|
+
`,P0=D.div`
|
|
895
|
+
display: flex;
|
|
896
|
+
flex-direction: row;
|
|
897
|
+
position: relative;
|
|
898
|
+
min-height: 16px;
|
|
899
|
+
`,F0=D.div.attrs(e=>({style:{left:`${e.$left}px`,color:e.$labelColor}}))`
|
|
900
|
+
position: absolute;
|
|
901
|
+
top: 50%;
|
|
902
|
+
font-size: 9px;
|
|
903
|
+
font-family: 'Courier New', monospace;
|
|
904
|
+
white-space: nowrap;
|
|
905
|
+
transform: translate(-50%, -50%);
|
|
906
|
+
user-select: none;
|
|
907
|
+
`,O0=({levels:e,peakLevels:t,channelLabels:n,orientation:r="vertical",segmentCount:s=24,dBRange:a=[-50,5],showScale:o=!0,colorStops:i=C0,segmentWidth:l=20,segmentHeight:c=8,segmentGap:u=2,coloredInactive:f=!1,labelColor:p,className:d})=>{const h=n??x0(e.length),g=p??T0,y=e.length;process.env.NODE_ENV!=="production"&&t!=null&&t.length!==y&&console.warn(`[waveform-playlist] SegmentedVUMeter: peakLevels length (${t.length}) does not match levels length (${y})`);const v=y>=2,b=c+u,[w,C]=a,_=m.useMemo(()=>k0(s,[w,C]),[s,w,C]),S=m.useMemo(()=>{const A=s*b-u,R=w,T=C;let M;r==="horizontal"?M=35:M=Math.max(14,b*2);const $=Math.max(2,Math.floor(A/M)),O=[];for(let P=0;P<$;P++){const V=P/($-1),X=V*A,ge=r==="horizontal"?R+V*(T-R):T-V*(T-R);O.push({position:X,label:I0(ge)})}return O},[r,s,b,u,w,C]),k=m.useMemo(()=>r==="horizontal"?[..._].reverse():_,[_,r]),I=A=>{const R=e[A],T=xl(R),M=t!=null?xl(t[A]):null;let $=-1;if(M!=null){let O=1/0;for(let P=0;P<k.length;P++){const V=Math.abs(k[P]-M);V<O&&(O=V,$=P)}}return x.jsxs(A0,{$orientation:r,"data-channel":!0,children:[r==="horizontal"&&x.jsx(Ma,{$labelColor:g,children:h[A]}),x.jsx(E0,{$orientation:r,children:k.map((O,P)=>{const V=T>=O,X=P===$,ge=S0(O,i);return x.jsx(M0,{$width:r==="horizontal"?c:l,$height:r==="horizontal"?l:c,$gap:u,$active:V,$color:ge,$isPeak:X,$orientation:r,$coloredInactive:f,"data-segment":!0,...X?{"data-peak":!0}:{}},P)})}),r==="vertical"&&x.jsx(Ma,{$labelColor:g,children:h[A]})]},A)},E=()=>{if(r==="horizontal"){const R=s*b-u;return x.jsxs(D0,{children:[x.jsx(Ma,{$labelColor:g,style:{visibility:"hidden"},children:"L"}),x.jsx(P0,{style:{width:`${R}px`},children:S.map(({position:T,label:M},$)=>x.jsx(F0,{$left:T,$labelColor:g,children:M},$))})]})}const A=s*b-u;return x.jsx(R0,{style:{height:`${A}px`},children:S.map(({position:R,label:T},M)=>x.jsx($0,{$top:R,$labelColor:g,children:T},M))})};if(v){if(r==="horizontal")return x.jsxs(Ea,{className:d,$orientation:r,"data-meter-orientation":r,children:[Array.from({length:y},(M,$)=>I($)),o&&E()]});const A=Math.ceil(y/2),R=Array.from({length:A},(M,$)=>$),T=Array.from({length:y-A},(M,$)=>A+$);return x.jsxs(Ea,{className:d,$orientation:r,"data-meter-orientation":r,children:[R.map(I),o&&E(),T.map(I)]})}return x.jsxs(Ea,{className:d,$orientation:r,"data-meter-orientation":r,children:[I(0),o&&E()]})};m.memo(O0);function xn(e,t){this._waveformData=e,this._channelIndex=t}xn.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};xn.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};xn.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};xn.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};xn.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};xn.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 B0=127,W0=-128,V0=32767,L0=-32768;function N0(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function Z0(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(R){return new Float32Array(R)}),i=r?o.length:1,l=24,c=N0(s,t),u=e.bits===8?1:2,f=l+c*2*u*i,p=new ArrayBuffer(f),d=new DataView(p),h=0,g=l,y=new Array(i),v=new Array(i),b=0;b<i;b++)y[b]=1/0,v[b]=-1/0;var w=e.bits===8?W0:L0,C=e.bits===8?B0:V0;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 _=0;_<s;_++){var S=0;if(i===1){for(var k=0;k<o.length;++k)S+=o[k][_];S=Math.floor(C*S*n/o.length),S<y[0]&&(y[0]=S,y[0]<w&&(y[0]=w)),S>v[0]&&(v[0]=S,v[0]>C&&(v[0]=C))}else for(var I=0;I<i;++I)S=Math.floor(C*o[I][_]*n),S<y[I]&&(y[I]=S,y[I]<w&&(y[I]=w)),S>v[I]&&(v[I]=S,v[I]>C&&(v[I]=C));if(++h===t){for(var E=0;E<i;E++)e.bits===8?(d.setInt8(g++,y[E]),d.setInt8(g++,v[E])):(d.setInt16(g,y[E],!0),d.setInt16(g+2,v[E],!0),g+=4),y[E]=1/0,v[E]=-1/0;h=0}}if(h>0)for(var A=0;A<i;A++)e.bits===8?(d.setInt8(g++,y[A]),d.setInt8(g++,v[A])):(d.setInt16(g,y[A],!0),d.setInt16(g+2,v[A],!0));return p}function Gs(e){"@babel/helpers - typeof";return Gs=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},Gs(e)}function G0(e){return e&&Gs(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function z0(e){var t=e&&Gs(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 j0(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 En(e){return e==null}function H0(e,t){var n=atob(e);return n}function X0(e,t,n){var r=H0(e),s=r.indexOf(`
|
|
908
|
+
`,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||X0(e),new Worker(r,a)}}var U0=Y0("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function wt(e){if(G0(e)&&(e=j0(e)),z0(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 xn(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var rr={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function K0(e){var t={scale:e.scale||rr.scale,bits:e.bits||rr.bits,amplitude_scale:e.amplitude_scale||rr.amplitude_scale,split_channels:e.split_channels||rr.split_channels,disable_worker:e.disable_worker||rr.disable_worker};return t}function Q0(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function pf(e,t,n){var r=Q0(e);if(t.disable_worker){var s=Z0({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 wt(s),e)}else{var a=new U0;a.onmessage=function(o){n(void 0,new wt(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 q0(e,t,n,r){function s(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var a=e.decodeAudioData(t,function(o){pf(o,n,r)},s);a&&a.catch(s)}wt.create=function(t){return new wt(t)};wt.createFromAudio=function(e,t){var n=K0(e);if(e.audio_context&&e.array_buffer)return q0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return pf(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function oa(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 wt(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}oa.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};oa.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};oa.prototype.getOutputData=function(){return this._output_data};wt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!En(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!En(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 oa(t);!n.next(););return new wt(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 wt.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(v){return v._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),g=0;g<a.length;g++){var y=a[g];h.set(new Uint8Array(y,n),d),d+=y.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!En(t.startIndex)&&!En(t.endIndex)?(n=t.startIndex,r=t.endIndex):!En(t.startTime)&&!En(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 wt(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 Fi(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 wt.create(r)}else{const r=await t.json();return wt.create(r)}}function mf(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 J0(e,t=0){const n=await Fi(e);return mf(n,t)}async function ey(e){const t=await Fi(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function gf(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 ty(e,t,n=0,r,s){const a=gf(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 pc(e,t,n,r,s){const a=gf(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,g=i===8?new Int8Array(h*2):new Int16Array(h*2);for(let y=0;y<h;y++)g[y*2]=p[y],g[y*2+1]=d[y];l.push(g)}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,g=0;for(let y=0;y<l.length;y++)h+=u*l[y][d*2],g+=u*l[y][d*2+1];p[d*2]=h,p[d*2+1]=g}return{length:f,data:[p],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function vf(){const[e,t]=m.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Vn(s,e),parseTime:s=>af(s,e)}}function yf({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 bf({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 ny({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 ry({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,g)=>{e.current?.setLoopRegion(h,g)},[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 sy({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 ay=(e=256)=>{const t=m.useRef(null),n=m.useCallback((r,s,a)=>{const o=new W.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 ls(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=kc({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={...Ic({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 oy(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),g=m.useRef(48e3),y=m.useMemo(()=>{if(!s)return null;const C=[];for(let _=0;_<e.length;_++){const S=ls(e[_],_,p.get(_),h.current,g.current);S&&C.push(S)}return C},[s,e,p]),[v,b]=m.useState(y??[]),w=m.useRef(y);return y!==w.current&&(w.current=y,y&&b(y)),m.useEffect(()=>{if(e.length===0){b([]),o(!1),u(0);return}let C=!1;const _=new AbortController;return(async()=>{try{o(!0),l(null),u(0),s&&d(new Map);const k=Sc.getContext().rawContext;g.current=k.sampleRate;const I=e.map(async(A,R)=>{if(A.audioBuffer){if(s&&!C){d(O=>{const P=new Map(O);return P.set(R,A.audioBuffer),P}),u(O=>O+1);return}return ls(A,R,A.audioBuffer,h.current,k.sampleRate)}if(!A.src&&A.waveformData){if(s&&!C){u(O=>O+1);return}return ls(A,R,void 0,h.current,k.sampleRate)}if(!A.src)throw new Error(`Track ${R+1}: Must provide src, audioBuffer, or waveformData`);const T=await fetch(A.src,{signal:_.signal});if(!T.ok)throw new Error(`Failed to fetch ${A.src}: ${T.statusText}`);const M=await T.arrayBuffer(),$=await k.decodeAudioData(M);if(!$||!$.sampleRate||!$.duration)throw new Error(`Invalid audio buffer for ${A.src}`);if(s&&!C){d(O=>{const P=new Map(O);return P.set(R,$),P}),u(O=>O+1);return}return ls(A,R,$,h.current,k.sampleRate)}),E=await Promise.all(I);if(!C){if(!s){const A=E.filter(R=>R!=null);b(A),u(A.length)}o(!1)}}catch(k){if(!C){const I=k instanceof Error?k.message:"Unknown error loading audio";l(I),o(!1),console.error(`[waveform-playlist] Error loading audio tracks: ${I}`)}}})(),()=>{C=!0,_.abort()}},[e,s]),{tracks:v,loading:a,error:i,loadedCount:c,totalCount:f}}function iy({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=Rc(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 wf({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 y=e[h.trackIndex]?.clips[h.clipIndex];y&&(l.current={offsetSamples:y.offsetSamples,durationSamples:y.durationSamples,startSample:y.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:g,trackIndex:y,clipIndex:v}=h,w=(d.to?.x??d.operation.position.current.x)-d.operation.position.initial.x,C=w*n,_=l.current,S=i.current;let k=C;const I=e.map((E,A)=>{if(A!==y)return E;const R=[...E.clips].sort(($,O)=>$.startSample-O.startSample),T=R.findIndex($=>$===E.clips[v]),M=E.clips.map(($,O)=>{if(O!==v)return $;let P=iy({originalClip:_,clip:$,pixelDelta:w,samplesPerPixel:n,sampleRate:r,boundary:g,sortedClips:R,sortedIndex:T});if(S)if(g==="left"){const V=S(P.startSample),X=V-P.startSample;P={startSample:V,durationSamples:P.durationSamples-X,offsetSamples:P.offsetSamples+X},k=V-_.startSample}else{const V=P.startSample+P.durationSamples,X=S(V);P={...P,durationSamples:X-P.startSample},k=P.durationSamples-_.durationSamples}return{...$,startSample:P.startSample,durationSamples:P.durationSamples,offsetSamples:P.offsetSamples}});return{...E,clips:M}});c.current=k,t(I)},[e,t,n,r]),p=m.useCallback(d=>{if(d.canceled){if(l.current){const C=d.operation.source?.data;if(C){const{trackIndex:_,clipIndex:S}=C,k=l.current,I=e.map((E,A)=>{if(A!==_)return E;const R=E.clips.map((T,M)=>M!==S?T:{...T,offsetSamples:k.offsetSamples,durationSamples:k.durationSamples,startSample:k.startSample});return{...E,clips:R}});t(I)}}a.current=!1,l.current=null,c.current=0;return}const h=d.operation.source?.data;if(!h)return;const{trackIndex:g,clipId:y,boundary:v}=h,b=v?c.current:d.operation.transform.x*n,w=e[g]?.id;if(v){a.current=!1,w?s.current?s.current.trimClip(w,y,v,Math.floor(b)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${g} not found — trim not synced to adapter`),l.current=null,c.current=0;return}w?s.current?s.current.moveClip(w,y,Math.floor(b)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${g} not found — move not synced to adapter`)},[e,t,n,s,a]);return{onDragStart:u,onDragMove:f,onDragEnd:p}}const Ta=.01;function Cf({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,v=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n/r,b=p==="start"?h.start+v:h.end+v,w=ly({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((g,y)=>y!==f?g:{...g,start:p,end:d});t(h)}o.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function ly({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)<Ta?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)<Ta){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)<Ta){const g=d.end-r[p].end;o[p+1]={...h,start:Math.min(h.end-.1,h.start+g)},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 _f(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return m.useMemo(()=>t?[vo.configure({activationConstraints(a){return a.pointerType==="touch"?[new Wt.Delay({value:n,tolerance:r})]:[new Wt.Distance({value:s})]}})]:[vo.configure({activationConstraints:[new Wt.Distance({value:s})]})],[t,n,r,s])}const xf=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=at(),{selectedTrackId:a}=ot(),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),g=$h(h,f),y=Math.floor(.1*n);if(!$c(d,g,y))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const v=r.current;return v?(v.splitClip(p.id,d.id,g),!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}};function cy(e,t,n){if(!n||e.repeat)return;const r=e.target;if(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)return;const s=t.find(a=>{const o=e.key.toLowerCase()===a.key.toLowerCase()||e.key===a.key,i=a.ctrlKey===void 0||e.ctrlKey===a.ctrlKey,l=a.shiftKey===void 0||e.shiftKey===a.shiftKey,c=a.metaKey===void 0||e.metaKey===a.metaKey,u=a.altKey===void 0||e.altKey===a.altKey;return o&&i&&l&&c&&u});s&&(s.preventDefault!==!1&&e.preventDefault(),s.action())}const zs=e=>{const{shortcuts:t,enabled:n=!0}=e,r=m.useCallback(s=>cy(s,t,n),[t,n]);m.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},uy=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("+")},Sf=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=at(),{setCurrentTime:a,play:o,pause:i,stop:l}=ke(),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 zs({shortcuts:d,enabled:t}),{rewindToStart:f,togglePlayPause:c,stopPlayback:u,shortcuts:d}},Ra=.01,cs=.01;function kf({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(I=>I.id===t):-1,[e,t]),d=m.useCallback(I=>{if(!l?.current||!c||!u)return;const E=e.find(X=>X.id===I);if(!E)return;const A=l.current,R=A.clientWidth,T=E.start*u/c,M=E.end*u/c,$=(T+M)/2,O=A.scrollLeft,P=O,V=O+R;if(T<P||M>V){const X=Math.max(0,$-R/2);A.scrollTo({left:X,behavior:"smooth"})}},[e,l,c,u]);m.useEffect(()=>{t&&l?.current&&c&&u&&d(t)},[t,d,l,c,u]);const h=m.useCallback(I=>{if(p<0)return;const E=e[p],A=Math.max(0,Math.min(E.end-.1,E.start+I)),R=A-E.start,T=[...e];if(T[p]={...E,start:A},a&&p>0){const M=T[p-1];Math.abs(M.end-E.start)<Ra&&(T[p-1]={...M,end:Math.max(M.start+.1,M.end+R)})}else if(!a&&p>0){const M=T[p-1];A<M.end&&(T[p-1]={...M,end:A})}n(T)},[e,p,a,n]),g=m.useCallback(I=>{if(p<0)return;const E=e[p],A=Math.max(E.start+.1,Math.min(s,E.end+I)),R=A-E.end,T=[...e];if(T[p]={...E,end:A},a&&p<e.length-1){const M=T[p+1];if(Math.abs(M.start-E.end)<Ra){const $=Math.min(M.end-.1,M.start+R);T[p+1]={...M,start:$};let O=p+1;for(;O<T.length-1;){const P=T[O],V=T[O+1];if(Math.abs(V.start-e[O].end)<Ra){const X=P.end-e[O].end;T[O+1]={...V,start:Math.min(V.end-.1,V.start+X)},O++}else break}}}else if(!a&&p<e.length-1){const M=T[p+1];if(A>M.start){T[p+1]={...M,start:A};let $=p+1;for(;$<T.length-1;){const O=T[$],P=T[$+1];if(O.end>P.start)T[$+1]={...P,start:O.end},$++;else break}}}n(T)},[e,p,s,a,n]),y=m.useCallback(()=>{!r||e.length===0||(p<=0?r(e[e.length-1].id):r(e[p-1].id))},[e,p,r]),v=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]),C=m.useCallback(()=>{r&&r(null)},[r]),_=m.useCallback(()=>{if(p<0||!f)return;const I=e[p],E=o?void 0:I.end-I.start;f(I.start,E)},[e,p,o,f]),S=m.useMemo(()=>[{key:"[",action:()=>h(-cs),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>h(cs),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>g(-cs),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>g(cs),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:_,description:"Play selected annotation",preventDefault:!0}],[h,g,_]),k=m.useMemo(()=>[{key:"ArrowUp",action:y,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:y,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:v,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:v,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:C,description:"Deselect annotation",preventDefault:!0}],[y,v,b,w,C]);return zs({shortcuts:S,enabled:i&&p>=0}),zs({shortcuts:k,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:h,moveEndBoundary:g,selectPrevious:y,selectNext:v,selectFirst:b,selectLast:w,clearSelection:C,scrollToAnnotation:d,playActiveAnnotation:_}}const jr=[{id:"reverb",name:"Reverb",category:"reverb",description:"Simple convolution reverb with adjustable decay time",parameters:[{name:"decay",label:"Decay",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"s"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"freeverb",name:"Freeverb",category:"reverb",description:"Classic Schroeder/Moorer reverb with room size and dampening",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.7},{name:"dampening",label:"Dampening",type:"number",min:0,max:1e4,step:100,default:3e3,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"jcReverb",name:"JC Reverb",category:"reverb",description:"Attempt at Roland JC-120 chorus reverb emulation",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"feedbackDelay",name:"Feedback Delay",category:"delay",description:"Delay line with feedback for echo effects",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"pingPongDelay",name:"Ping Pong Delay",category:"delay",description:"Stereo delay bouncing between left and right channels",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"chorus",name:"Chorus",category:"modulation",description:"Creates thickness by layering detuned copies of the signal",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"Hz"},{name:"delayTime",label:"Delay",type:"number",min:0,max:20,step:.5,default:3.5,unit:"ms"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.7},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"phaser",name:"Phaser",category:"modulation",description:"Classic phaser effect using allpass filters",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:.5,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:6,step:1,default:3},{name:"baseFrequency",label:"Base Freq",type:"number",min:100,max:2e3,step:10,default:350,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"tremolo",name:"Tremolo",category:"modulation",description:"Rhythmic volume modulation",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:4,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"vibrato",name:"Vibrato",category:"modulation",description:"Pitch modulation effect",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:5,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoPanner",name:"Auto Panner",category:"modulation",description:"Automatic left-right panning",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoFilter",name:"Auto Filter",category:"filter",description:"Automated filter sweep with LFO",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:2e3,step:10,default:200,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:.5,max:8,step:.5,default:2.6},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoWah",name:"Auto Wah",category:"filter",description:"Envelope follower filter effect",parameters:[{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:500,step:10,default:100,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:8,step:1,default:6},{name:"sensitivity",label:"Sensitivity",type:"number",min:-40,max:0,step:1,default:0,unit:"dB"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"eq3",name:"3-Band EQ",category:"filter",description:"Three band equalizer with low, mid, and high controls",parameters:[{name:"low",label:"Low",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"mid",label:"Mid",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"high",label:"High",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"lowFrequency",label:"Low Freq",type:"number",min:20,max:500,step:10,default:400,unit:"Hz"},{name:"highFrequency",label:"High Freq",type:"number",min:1e3,max:1e4,step:100,default:2500,unit:"Hz"}]},{id:"distortion",name:"Distortion",category:"distortion",description:"Wave shaping distortion effect",parameters:[{name:"distortion",label:"Drive",type:"number",min:0,max:1,step:.01,default:.4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"bitCrusher",name:"Bit Crusher",category:"distortion",description:"Reduces bit depth for lo-fi digital texture",parameters:[{name:"bits",label:"Bits",type:"number",min:1,max:16,step:1,default:4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"chebyshev",name:"Chebyshev",category:"distortion",description:"Waveshaping distortion using Chebyshev polynomials",parameters:[{name:"order",label:"Order",type:"number",min:1,max:100,step:1,default:50},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"compressor",name:"Compressor",category:"dynamics",description:"Dynamic range compressor",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-60,max:0,step:1,default:-24,unit:"dB"},{name:"ratio",label:"Ratio",type:"number",min:1,max:20,step:.5,default:4},{name:"attack",label:"Attack",type:"number",min:0,max:1,step:.001,default:.003,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"knee",label:"Knee",type:"number",min:0,max:40,step:1,default:30,unit:"dB"}]},{id:"limiter",name:"Limiter",category:"dynamics",description:"Hard limiter to prevent clipping",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-12,max:0,step:.5,default:-6,unit:"dB"}]},{id:"gate",name:"Gate",category:"dynamics",description:"Noise gate to silence signal below threshold",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-100,max:0,step:1,default:-40,unit:"dB"},{name:"attack",label:"Attack",type:"number",min:0,max:.3,step:.001,default:.001,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:.5,step:.01,default:.1,unit:"s"}]},{id:"stereoWidener",name:"Stereo Widener",category:"spatial",description:"Expands or narrows the stereo image",parameters:[{name:"width",label:"Width",type:"number",min:0,max:1,step:.01,default:.5}]}],Oi=e=>jr.find(t=>t.id===e),dy=e=>jr.filter(t=>t.category===e),fy=[{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 hy={reverb:W.Reverb,freeverb:W.Freeverb,jcReverb:W.JCReverb,feedbackDelay:W.FeedbackDelay,pingPongDelay:W.PingPongDelay,chorus:W.Chorus,phaser:W.Phaser,tremolo:W.Tremolo,vibrato:W.Vibrato,autoPanner:W.AutoPanner,autoFilter:W.AutoFilter,autoWah:W.AutoWah,eq3:W.EQ3,distortion:W.Distortion,bitCrusher:W.BitCrusher,chebyshev:W.Chebyshev,compressor:W.Compressor,limiter:W.Limiter,gate:W.Gate,stereoWidener:W.StereoWidener};let py=0;const my=()=>`effect_${Date.now()}_${++py}`;function Rr(e,t){const n=hy[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=my(),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 gy(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 vy(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(y=>{const v=o.current;if(!v)return;const{masterGainNode:b,destination:w,analyserNode:C}=v;try{b.disconnect()}catch(S){console.warn("[waveform-playlist] Error disconnecting master effects chain:",S)}const _=y.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(_.length===0)b.connect(C),C.connect(w);else{let S=b;_.forEach(k=>{try{k.disconnect()}catch(I){console.warn(`[waveform-playlist] Error disconnecting effect "${k.id}":`,I)}S.connect(k.effect),S=k.effect}),S.connect(C),C.connect(w)}},[]),l=m.useCallback(y=>{const v=Oi(y);if(!v){console.error(`Unknown effect: ${y}`);return}const b={};v.parameters.forEach(_=>{b[_.name]=_.default});const w=Rr(v,b);s.current.set(w.instanceId,w);const C={instanceId:w.instanceId,effectId:v.id,definition:v,params:b,bypassed:!1};n(_=>[..._,C])},[]),c=m.useCallback(y=>{const v=s.current.get(y);v&&(v.dispose(),s.current.delete(y)),n(b=>b.filter(w=>w.instanceId!==y))},[]),u=m.useCallback((y,v,b)=>{const w=s.current.get(y);w&&w.setParameter(v,b),n(C=>C.map(_=>_.instanceId===y?{..._,params:{..._.params,[v]:b}}:_))},[]),f=m.useCallback(y=>{const v=r.current.find(C=>C.instanceId===y);if(!v)return;const b=!v.bypassed,w=s.current.get(y);if(w){const C=v.params.wet??1;w.setParameter("wet",b?0:C)}n(C=>C.map(_=>_.instanceId===y?{..._,bypassed:b}:_))},[]),p=m.useCallback((y,v)=>{n(b=>{const w=[...b],[C]=w.splice(y,1);return w.splice(v,0,C),w})},[]),d=m.useCallback(()=>{s.current.forEach(y=>y.dispose()),s.current.clear(),n([])},[]);m.useEffect(()=>{i(t)},[t,i]);const h=m.useCallback((y,v,b)=>{const w=new W.Analyser("fft",e);a.current=w,o.current={masterGainNode:y,destination:v,analyserNode:w};const _=r.current.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(_.length===0)y.connect(w),w.connect(v);else{let S=y;_.forEach(k=>{S.connect(k.effect),S=k.effect}),S.connect(w),w.connect(v)}return function(){w.dispose(),a.current=null,o.current=null}},[e]);m.useEffect(()=>{const y=s.current;return()=>{y.forEach(v=>v.dispose()),y.clear()}},[]);const g=m.useCallback(()=>{const y=t.filter(v=>!v.bypassed);if(y.length!==0)return(v,b,w)=>{const C=[];for(const _ of y){const S=Rr(_.definition,_.params);C.push(S)}if(C.length===0)v.connect(b);else{let _=v;C.forEach(S=>{_.connect(S.effect),_=S.effect}),_.connect(b)}return function(){C.forEach(S=>S.dispose())}}},[t]);return{activeEffects:t,availableEffects:jr,addEffect:l,removeEffect:c,updateParameter:u,toggleBypass:f,reorderEffects:p,clearAllEffects:d,masterEffects:h,createOfflineEffectsFunction:g,analyserRef:a}}function yy(){const[e,t]=m.useState(new Map),n=m.useRef(new Map),r=m.useRef(new Map),s=m.useCallback((d,h)=>{const g=r.current.get(d);if(!g)return;const{graphEnd:y,masterGainNode:v}=g,b=n.current.get(d);try{y.disconnect()}catch(C){console.warn(`[waveform-playlist] Error disconnecting track "${d}" effect chain:`,C)}const w=h.map(C=>b?.get(C.instanceId)).filter(C=>C!==void 0);if(w.length===0)y.connect(v);else{let C=y;w.forEach(_=>{try{_.disconnect()}catch(S){console.warn(`[waveform-playlist] Error disconnecting effect "${_.id}" on track "${d}":`,S)}C.connect(_.effect),C=_.effect}),C.connect(v)}},[]),a=m.useCallback((d,h)=>{const g=Oi(h);if(!g){console.error(`Unknown effect: ${h}`);return}const y={};g.parameters.forEach(w=>{y[w.name]=w.default});const v=Rr(g,y);n.current.has(d)||n.current.set(d,new Map),n.current.get(d).set(v.instanceId,v);const b={instanceId:v.instanceId,effectId:g.id,definition:g,params:y,bypassed:!1};t(w=>{const C=new Map(w),_=C.get(d)||[];return C.set(d,[..._,b]),C})},[]),o=m.useCallback((d,h)=>{const g=n.current.get(d),y=g?.get(h);y&&(y.dispose(),g?.delete(h)),t(v=>{const b=new Map(v),w=b.get(d)||[];return b.set(d,w.filter(C=>C.instanceId!==h)),b})},[]),i=m.useCallback((d,h,g,y)=>{const b=n.current.get(d)?.get(h);b&&b.setParameter(g,y),t(w=>{const C=new Map(w),_=C.get(d)||[];return C.set(d,_.map(S=>S.instanceId===h?{...S,params:{...S.params,[g]:y}}:S)),C})},[]),l=m.useCallback((d,h)=>{const y=(u.current.get(d)||[]).find(C=>C.instanceId===h);if(!y)return;const v=!y.bypassed,w=n.current.get(d)?.get(h);if(w){const C=y.params.wet??1;w.setParameter("wet",v?0:C)}t(C=>{const _=new Map(C),S=_.get(d)||[];return _.set(d,S.map(k=>k.instanceId===h?{...k,bypassed:v}:k)),_})},[]),c=m.useCallback(d=>{const h=n.current.get(d);h&&(h.forEach(g=>g.dispose()),h.clear()),t(g=>{const y=new Map(g);return y.set(d,[]),y})},[]),u=m.useRef(e);u.current=e;const f=m.useCallback(d=>(h,g,y)=>{r.current.set(d,{graphEnd:h,masterGainNode:g});const v=u.current.get(d)||[],b=n.current.get(d),w=v.map(C=>b?.get(C.instanceId)).filter(C=>C!==void 0);if(w.length===0)h.connect(g);else{let C=h;w.forEach(_=>{C.connect(_.effect),C=_.effect}),C.connect(g)}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(g=>g.dispose()),h.clear()}),d.clear()}},[]);const p=m.useCallback(d=>{const g=(e.get(d)||[]).filter(y=>!y.bypassed);if(g.length!==0)return(y,v,b)=>{const w=[];for(const C of g){const _=Rr(C.definition,C.params);w.push(_)}if(w.length===0)y.connect(v);else{let C=y;w.forEach(_=>{C.connect(_.effect),C=_.effect}),C.connect(v)}return function(){w.forEach(_=>_.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:a,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:f,createOfflineTrackEffectsFunction:p,availableEffects:jr}}function by(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);us(d,0,"RIFF"),d.setUint32(4,f-8,!0),us(d,8,"WAVE"),us(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),us(d,36,"data"),d.setUint32(40,c,!0);const h=[];for(let y=0;y<r;y++)h.push(e.getChannelData(y));let g=u;if(n===16)for(let y=0;y<a;y++)for(let v=0;v<r;v++){const b=h[v][y],w=Math.max(-1,Math.min(1,b)),C=w<0?w*32768:w*32767;d.setInt16(g,C,!0),g+=2}else for(let y=0;y<a;y++)for(let v=0;v<r;v++)d.setFloat32(g,h[v][y],!0),g+=4;return new Blob([p],{type:"audio/wav"})}function us(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function wy(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 If(){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:g,createOfflineTrackEffects:y,bitDepth:v=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 C=0;for(const R of i)for(const T of R.clips){const M=T.startSample+T.durationSamples;C=Math.max(C,M)}C+=Math.round(w*.1);const _=C/w,S=f==="individual"?[{track:i[p],state:l[p],index:p}]:i.map((R,T)=>({track:R,state:l[T],index:T})),k=l.some(R=>R.soloed),I=!!y;let E;if((g||I)&&h)E=await Cy(S,l,k,_,w,g,y,R=>{r(R),b?.(R)});else{const R=new OfflineAudioContext(2,C,w);let T=0;const M=S.reduce(($,{track:O})=>$+O.clips.length,0);for(const{track:$,state:O}of S)if(!(O.muted&&!O.soloed)&&!(k&&!O.soloed))for(const P of $.clips){await xy(R,P,O,w,h),T++;const V=T/M*.5;r(V),b?.(V)}r(.5),b?.(.5),E=await R.startRendering()}r(.9),b?.(.9);const A=by(E,{bitDepth:v});if(r(1),b?.(1),d){const R=f==="individual"?`${u}_${i[p].name}`:u;wy(A,`${R}.wav`)}return{audioBuffer:E,blob:A,duration:_}}catch(w){const C=w instanceof Error?w.message:"Export failed";throw a(C),w}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function Cy(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:g,destination:y})=>{const v=new c(0);let b;a?b=a(v,y,!0):v.connect(y);for(const{track:w,state:C}of e){if(C.muted&&!C.soloed||n&&!C.soloed)continue;const _=new c(_y(C.volume)),S=new f(C.pan),k=new u(C.muted?0:1),I=o?.(w.id);I?I(k,v,!0):k.connect(v),S.connect(k),_.connect(S);for(const E of w.clips){const{audioBuffer:A,startSample:R,durationSamples:T,offsetSamples:M,gain:$,fadeIn:O,fadeOut:P}=E,V=R/s,X=T/s,ge=M/s,re=new d(A),se=new p(re),Ie=new u($);if(se.connect(Ie),Ie.connect(_),O){const j=V,_e=V+O.duration,te=_r(Ie.gain);te&&(te.setValueAtTime(0,j),te.linearRampToValueAtTime($,_e))}if(P){const j=V+X-P.duration,_e=V+X,te=_r(Ie.gain);te&&(te.setValueAtTime($,j),te.linearRampToValueAtTime(0,_e))}se.start(V,ge,X)}}g.start(0)},r,2,s)}catch(g){throw g instanceof Error?g:new Error(`Tone.Offline rendering failed: ${String(g)}`)}return i(.9),h.get()}function _y(e){return 20*Math.log10(Math.max(e,1e-4))}async function xy(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,g=e.createBufferSource();g.buffer=a;const y=e.createGain(),v=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,g.connect(y),y.connect(b),b.connect(e.destination),s){if(u?y.gain.setValueAtTime(0,p):y.gain.setValueAtTime(v,p),u){const w=p,C=p+u.duration;mc(y.gain,w,C,0,v,u.type||"linear")}if(f){const w=p+d-f.duration,C=p+d;(!u||u.duration<d-f.duration)&&y.gain.setValueAtTime(v,w),mc(y.gain,w,C,v,0,f.type||"linear")}}else y.gain.setValueAtTime(v,p);g.start(p,h,d)}function mc(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=gc(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,o);break}case"sCurve":{const i=gc(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,o);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function gc(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 Af=()=>{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}},Sy=`
|
|
858
909
|
"use strict";
|
|
859
910
|
|
|
860
911
|
var INT8_MAX = 127;
|
|
@@ -1001,13 +1052,13 @@ self.onmessage = function(e) {
|
|
|
1001
1052
|
self.postMessage({ id: msg.id, error: err.message || String(err) });
|
|
1002
1053
|
}
|
|
1003
1054
|
};
|
|
1004
|
-
`;let Y0=0;function K0(){let e;try{const r=new Blob([X0],{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(++Y0);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]=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=K0()),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 J0(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 Q0(){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 J0(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),ey=({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}=q0(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 ty=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}},ny=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 ty({...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),ry=({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 ny({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},sy=({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"})},ay=({className:e})=>{const{isPlaying:t}=tt(),{pause:n}=Se();return C.jsx(gt,{onClick:n,disabled:!t,className:e,children:"Pause"})},oy=({className:e})=>{const{isPlaying:t}=tt(),{stop:n}=Se();return C.jsx(gt,{onClick:n,disabled:!t,className:e,children:"Stop"})},iy=({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"})},ly=({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"})},cy=({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"})},uy=({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"})},dy=({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"})},fy=({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"})},hy=({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})},py=({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"})},my=({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"})},gy=({className:e})=>{const{masterVolume:t}=rt(),{setMasterVolume:n}=Se();return C.jsx(lv,{volume:t,onChange:n,className:e})},vy=({className:e})=>{const{timeFormat:t}=rt(),{setTimeFormat:n}=Se();return C.jsx(Hv,{value:t,onChange:n,className:e})},yy=P.span`
|
|
1055
|
+
`;let ky=0;function Iy(){let e;try{const r=new Blob([Sy],{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=wt.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(++ky);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 Ay(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=Iy()),o.current),[]);return m.useEffect(()=>{let p=!1;const d=i.current,h=l.current,g=c.current,y=[],v=new Map;for(const w of e)for(const C of w.clips){if(!C.audioBuffer||C.waveformData)continue;const _=d.get(C.audioBuffer);if(_){y.push({clipId:C.id,waveformData:_});continue}if(h.get(C.audioBuffer)){const k=g.get(C.audioBuffer);k?k.add(C.id):g.set(C.audioBuffer,new Set([C.id]));continue}const S=v.get(C.audioBuffer);S?S.add(C.id):v.set(C.audioBuffer,new Set([C.id]))}if(y.length>0&&r(w=>{const C=new Map(w);for(const _ of y)C.set(_.clipId,_.waveformData);return C}),v.size===0)return;u.current+=v.size,a(!0);const b=f();for(const[w,C]of v){g.set(w,new Set(C));const _=[];for(let I=0;I<w.numberOfChannels;I++)_.push(w.getChannelData(I).slice().buffer);const S=`buffer-${Math.random().toString(36).slice(2,11)}`,k=b.generate({id:S,channels:_,length:w.length,sampleRate:w.sampleRate,scale:t,bits:16,splitChannels:!0}).then(I=>{d.set(w,I);const E=g.get(w)??new Set;g.delete(w),h.delete(w),!p&&(r(A=>{const R=new Map(A);for(const T of E)R.set(T,I);return R}),u.current--,u.current<=0&&(u.current=0,a(!1)))}).catch(I=>{g.delete(w),h.delete(w),!p&&(console.warn("[waveform-playlist] Worker peak generation failed:",I),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 So(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=So(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 My(){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=Th(),d=f.map(h=>({track:Ic({name:`${So(h)} (loading...)`,clips:[]}),source:h}));t(h=>[...h,...d.map(g=>g.track)]),r(h=>h+f.length);for(const{track:h,source:g}of d){i.current.add(h.id);const y=new AbortController;l.current.set(h.id,y),(async()=>{try{const{audioBuffer:v,name:b}=await Ey(g,p,y.signal),w=kc({audioBuffer:v,startTime:0,duration:v.duration,offset:0,name:b});!o.current&&i.current.has(h.id)&&t(C=>C.map(_=>_.id===h.id?{..._,name:b,clips:[w]}:_))}catch(v){if(v instanceof DOMException&&v.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",v),!o.current&&i.current.has(h.id)&&(t(b=>b.filter(w=>w.id!==h.id)),a(b=>[...b,{name:So(g),error:v instanceof Error?v:new Error(String(v))}]))}finally{l.current.delete(h.id),!o.current&&i.current.delete(h.id)&&r(v=>v-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}}var Ty=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvbWV0ZXItcHJvY2Vzc29yLndvcmtsZXQudHMKdmFyIE1ldGVyUHJvY2Vzc29yID0gY2xhc3MgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIGNvbnN0cnVjdG9yKG9wdGlvbnMpIHsKICAgIHN1cGVyKCk7CiAgICBjb25zdCB7IG51bWJlck9mQ2hhbm5lbHMsIHVwZGF0ZVJhdGUgfSA9IG9wdGlvbnMucHJvY2Vzc29yT3B0aW9uczsKICAgIHRoaXMubnVtYmVyT2ZDaGFubmVscyA9IG51bWJlck9mQ2hhbm5lbHM7CiAgICB0aGlzLmJsb2Nrc1BlclVwZGF0ZSA9IE1hdGgubWF4KDEsIE1hdGguZmxvb3Ioc2FtcGxlUmF0ZSAvICgxMjggKiB1cGRhdGVSYXRlKSkpOwogICAgdGhpcy5ibG9ja3NQcm9jZXNzZWQgPSAwOwogICAgdGhpcy5tYXhQZWFrID0gbmV3IEFycmF5KG51bWJlck9mQ2hhbm5lbHMpLmZpbGwoMCk7CiAgICB0aGlzLnN1bVNxdWFyZXMgPSBuZXcgQXJyYXkobnVtYmVyT2ZDaGFubmVscykuZmlsbCgwKTsKICAgIHRoaXMuc2FtcGxlQ291bnQgPSBuZXcgQXJyYXkobnVtYmVyT2ZDaGFubmVscykuZmlsbCgwKTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIF9wYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBpZiAoIWlucHV0IHx8IGlucHV0Lmxlbmd0aCA9PT0gMCkgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGZvciAobGV0IGNoID0gMDsgY2ggPCBvdXRwdXQubGVuZ3RoOyBjaCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoXTsKICAgICAgY29uc3Qgb3V0cHV0Q2hhbm5lbCA9IG91dHB1dFtjaF07CiAgICAgIGlmIChpbnB1dENoYW5uZWwgJiYgb3V0cHV0Q2hhbm5lbCkgewogICAgICAgIG91dHB1dENoYW5uZWwuc2V0KGlucHV0Q2hhbm5lbCk7CiAgICAgIH0KICAgIH0KICAgIGZvciAobGV0IGNoID0gMDsgY2ggPCB0aGlzLm51bWJlck9mQ2hhbm5lbHM7IGNoKyspIHsKICAgICAgY29uc3QgaW5wdXRDaGFubmVsID0gaW5wdXRbY2hdOwogICAgICBpZiAoIWlucHV0Q2hhbm5lbCkgY29udGludWU7CiAgICAgIGxldCBwZWFrID0gdGhpcy5tYXhQZWFrW2NoXTsKICAgICAgbGV0IHN1bSA9IHRoaXMuc3VtU3F1YXJlc1tjaF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaW5wdXRDaGFubmVsLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgY29uc3Qgc2FtcGxlID0gaW5wdXRDaGFubmVsW2ldOwogICAgICAgIGNvbnN0IGFicyA9IE1hdGguYWJzKHNhbXBsZSk7CiAgICAgICAgaWYgKGFicyA+IHBlYWspIHBlYWsgPSBhYnM7CiAgICAgICAgc3VtICs9IHNhbXBsZSAqIHNhbXBsZTsKICAgICAgfQogICAgICB0aGlzLm1heFBlYWtbY2hdID0gcGVhazsKICAgICAgdGhpcy5zdW1TcXVhcmVzW2NoXSA9IHN1bTsKICAgICAgdGhpcy5zYW1wbGVDb3VudFtjaF0gKz0gaW5wdXRDaGFubmVsLmxlbmd0aDsKICAgIH0KICAgIHRoaXMuYmxvY2tzUHJvY2Vzc2VkKys7CiAgICBpZiAodGhpcy5ibG9ja3NQcm9jZXNzZWQgPj0gdGhpcy5ibG9ja3NQZXJVcGRhdGUpIHsKICAgICAgY29uc3QgcGVhayA9IFtdOwogICAgICBjb25zdCBybXMgPSBbXTsKICAgICAgZm9yIChsZXQgY2ggPSAwOyBjaCA8IHRoaXMubnVtYmVyT2ZDaGFubmVsczsgY2grKykgewogICAgICAgIHBlYWsucHVzaCh0aGlzLm1heFBlYWtbY2hdKTsKICAgICAgICBjb25zdCBjb3VudCA9IHRoaXMuc2FtcGxlQ291bnRbY2hdOwogICAgICAgIHJtcy5wdXNoKGNvdW50ID4gMCA/IE1hdGguc3FydCh0aGlzLnN1bVNxdWFyZXNbY2hdIC8gY291bnQpIDogMCk7CiAgICAgIH0KICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsgcGVhaywgcm1zIH0pOwogICAgICB0aGlzLm1heFBlYWsuZmlsbCgwKTsKICAgICAgdGhpcy5zdW1TcXVhcmVzLmZpbGwoMCk7CiAgICAgIHRoaXMuc2FtcGxlQ291bnQuZmlsbCgwKTsKICAgICAgdGhpcy5ibG9ja3NQcm9jZXNzZWQgPSAwOwogICAgfQogICAgcmV0dXJuIHRydWU7CiAgfQp9OwpyZWdpc3RlclByb2Nlc3NvcigibWV0ZXItcHJvY2Vzc29yIiwgTWV0ZXJQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1tZXRlci1wcm9jZXNzb3Iud29ya2xldC5qcy5tYXA=",typeof document>"u"?require("url").pathToFileURL(__filename).href:On&&On.tagName.toUpperCase()==="SCRIPT"&&On.src||new URL("index.js",document.baseURI).href).href;new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIF9vdXRwdXRzLCBfcGFyYW1ldGVycykgewogICAgaWYgKCF0aGlzLmlzUmVjb3JkaW5nKSB7CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgY29uc3QgaW5wdXQgPSBpbnB1dHNbMF07CiAgICBpZiAoIWlucHV0IHx8IGlucHV0Lmxlbmd0aCA9PT0gMCkgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGZyYW1lQ291bnQgPSBpbnB1dFswXS5sZW5ndGg7CiAgICBpZiAodGhpcy5idWZmZXJTaXplIDw9IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBsZXQgb2Zmc2V0ID0gMDsKICAgIHdoaWxlIChvZmZzZXQgPCBmcmFtZUNvdW50KSB7CiAgICAgIGNvbnN0IHJlbWFpbmluZyA9IHRoaXMuYnVmZmVyU2l6ZSAtIHRoaXMuc2FtcGxlc0NvbGxlY3RlZDsKICAgICAgY29uc3QgdG9Db3B5ID0gTWF0aC5taW4ocmVtYWluaW5nLCBmcmFtZUNvdW50IC0gb2Zmc2V0KTsKICAgICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgICAgY29uc3QgaW5wdXRDaGFubmVsID0gaW5wdXRbY2hhbm5lbF07CiAgICAgICAgY29uc3QgYnVmZmVyID0gdGhpcy5idWZmZXJzW2NoYW5uZWxdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdG9Db3B5OyBpKyspIHsKICAgICAgICAgIGJ1ZmZlclt0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKyBpXSA9IGlucHV0Q2hhbm5lbFtvZmZzZXQgKyBpXTsKICAgICAgICB9CiAgICAgIH0KICAgICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkICs9IHRvQ29weTsKICAgICAgb2Zmc2V0ICs9IHRvQ29weTsKICAgICAgaWYgKHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA+PSB0aGlzLmJ1ZmZlclNpemUpIHsKICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3QgY2hhbm5lbHMgPSBbXTsKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdGhpcy5jaGFubmVsQ291bnQ7IGkrKykgewogICAgICBjaGFubmVscy5wdXNoKHRoaXMuYnVmZmVyc1tpXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpKTsKICAgIH0KICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgIGNoYW5uZWxzLAogICAgICBzYW1wbGVSYXRlLAogICAgICBjaGFubmVsQ291bnQ6IHRoaXMuY2hhbm5lbENvdW50CiAgICB9KTsKICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgfQp9OwpyZWdpc3RlclByb2Nlc3NvcigicmVjb3JkaW5nLXByb2Nlc3NvciIsIFJlY29yZGluZ1Byb2Nlc3Nvcik7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXJlY29yZGluZy1wcm9jZXNzb3Iud29ya2xldC5qcy5tYXA=",typeof document>"u"?require("url").pathToFileURL(__filename).href:On&&On.tagName.toUpperCase()==="SCRIPT"&&On.src||new URL("index.js",document.baseURI).href).href;const Ry=.98;function $y(e={}){const{channelCount:t=2,updateRate:n=60,isPlaying:r=!1}=e,[s,a]=m.useState(()=>new Array(t).fill(0)),[o,i]=m.useState(()=>new Array(t).fill(0)),[l,c]=m.useState(()=>new Array(t).fill(0)),u=m.useRef(null),f=m.useRef(new Array(t).fill(0)),[p,d]=m.useState(null),h=m.useCallback(()=>i(new Array(t).fill(0)),[t]);return m.useEffect(()=>{if(!r){const g=new Array(t).fill(0);f.current=new Array(t).fill(0),a(g),c(g),i(g)}},[r,t]),m.useEffect(()=>{let g=!0;return(async()=>{const v=Is();if(await v.rawContext.audioWorklet.addModule(Ty),!g)return;const w=v.createAudioWorkletNode("meter-processor",{channelCount:t,channelCountMode:"explicit",processorOptions:{numberOfChannels:t,updateRate:n}});u.current=w,w.onprocessorerror=_=>{console.warn("[waveform-playlist] Output meter worklet processor error:",String(_))},v.destination.chain(w),f.current=new Array(t).fill(0),w.port.onmessage=_=>{if(!g)return;const{peak:S,rms:k}=_.data,I=f.current,E=[],A=[];for(let R=0;R<S.length;R++)I[R]=Math.max(S[R],(I[R]??0)*Ry),E.push(Sl(I[R])),A.push(Sl(k[R]));a(E),c(A),i(R=>E.map((T,M)=>Math.max(R[M]??0,T)))}})().catch(v=>{console.warn("[waveform-playlist] Failed to set up output meter:",String(v)),g&&d(v instanceof Error?v:new Error(String(v)))}),()=>{if(g=!1,u.current){try{Is().destination.chain()}catch(v){console.warn("[waveform-playlist] Failed to restore destination chain:",String(v))}try{u.current.disconnect(),u.current.port.close()}catch(v){console.warn("[waveform-playlist] Output meter disconnect during cleanup:",String(v))}u.current=null}}},[t,n]),{levels:s,peakLevels:o,rmsLevels:l,resetPeak:h,error:p}}const Ef=m.createContext(null),Mf=m.createContext(null),Tf=m.createContext(null),Rf=m.createContext(null),Dy=({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:g=0,progressBarWidth:y,onTracksChange:v,soundFontCache:b,deferEngineRebuild:w=!1,indefinitePlayback:C=!1,children:_})=>{const S=y??h+g,k=m.useRef(C);k.current=C;const I=m.useMemo(()=>a,[a?.join(",")]),E=m.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const N=c.annotations[0];if(typeof N.start!="number"||typeof N.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof N.start),[]}return c.annotations},[c?.annotations]),A=m.useRef(E);A.current=E;const[R,T]=m.useState(null),[M,$]=m.useState(!1),[O,P]=m.useState(0),[V,X]=m.useState(0),[ge,re]=m.useState([]),[se,Ie]=m.useState([]),[j,_e]=m.useState([]),[te,mt]=m.useState(o),[q,me]=m.useState(c?.isContinuousPlay??!1),[Me,je]=m.useState(c?.linkEndpoints??!1),[K,le]=m.useState(c?.editable??!1),[Ze,fe]=m.useState(!1),B=m.useRef(null),Y=m.useRef(!1),Te=m.useRef(!1);Te.current=M;const Ve=m.useRef(0),ae=m.useRef(0),lt=m.useRef(e),Mt=m.useRef(b);Mt.current=b;const xt=m.useRef(j),He=m.useRef(0),ct=m.useRef(0),gt=m.useRef(null),ut=m.useRef(null),Je=m.useRef(!1),H=m.useRef(c?.isContinuousPlay??!1),he=m.useRef(null),Xe=m.useRef(null),J=m.useRef(0),ce=m.useRef(!1),Fe=m.useRef(!1),et=m.useRef([]),vt=m.useRef(s),Z=m.useRef(44100),{timeFormat:z,setTimeFormat:U,formatTime:oe}=vf(),ie=yf({engineRef:B,initialSamplesPerPixel:s}),{samplesPerPixel:Ae,onEngineState:Q}=ie,Le=bf({engineRef:B,initialVolume:1}),{masterVolume:Ye,setMasterVolume:Ge,masterVolumeRef:Tt,onEngineState:zt}=Le,{selectionStart:kn,selectionEnd:nn,setSelection:Ni,selectionStartRef:Yr,selectionEndRef:Ur,onEngineState:Zi}=ny({engineRef:B}),{isLoopEnabled:Gi,loopStart:zi,loopEnd:ji,setLoopEnabled:Hi,setLoopRegion:Kr,clearLoopRegion:Xi,isLoopEnabledRef:Yi,loopStartRef:Ui,loopEndRef:Ki,onEngineState:Qi}=ry({engineRef:B}),{selectedTrackId:qi,setSelectedTrackId:Ji,onEngineState:el,selectedTrackIdRef:tl}=sy({engineRef:B}),{animationFrameRef:nl,startAnimationFrameLoop:da,stopAnimationFrameLoop:Qr}=Af(),rh=m.useMemo(()=>Math.min(...I??[256,512,1024,2048,4096,8192]),[I]),{cache:rl}=Ay(e,rh),sl=m.useCallback(N=>{H.current=N,me(N)},[]),Bt=m.useCallback(N=>{he.current=N,T(N)},[]),al=m.useCallback(()=>{const N=Yr.current??0,G=Ur.current??0;N!==G&&G>N&&Kr(N,G)},[Kr,Yr,Ur]);m.useEffect(()=>{Je.current=te},[te]),m.useEffect(()=>{xt.current=j},[j]),lt.current=e;const fa=e===Xe.current,qr=et.current,ol=B.current!==null&&qr.length>0&&e.length>qr.length&&qr.every(N=>e.find(ue=>ue.id===N.id)===N);ce.current=fa||Fe.current||ol,m.useEffect(()=>{if(!ut.current||V===0)return;const N=ut.current,G=vt.current,ue=Ae;if(G===ue)return;const L=N.clientWidth,xe=N.scrollLeft+L/2,be=Z.current,$e=xe*G/be*be/ue,Ue=Math.max(0,$e-L/2);N.scrollLeft=Ue,vt.current=ue},[Ae,V]);const Jr=m.useRef(null);m.useEffect(()=>{if(fa||Fe.current){fa&&(Xe.current=null);let L=0;e.forEach(ye=>{ye.clips.forEach(xe=>{const be=(xe.startSample+xe.durationSamples)/xe.sampleRate;L=Math.max(L,be)})}),X(L),et.current=e;return}if(ol&&B.current)try{const L=new Set(qr.map($e=>$e.id)),ye=e.filter($e=>!L.has($e.id)),xe=xt.current;for(const $e of ye){const Ue=e.indexOf($e),dt=xe[Ue],Ee={...$e,volume:dt?.volume??$e.volume,muted:dt?.muted??$e.muted,soloed:dt?.soloed??$e.soloed,pan:dt?.pan??$e.pan};B.current.addTrack(Ee)}let be=0;e.forEach($e=>{$e.clips.forEach(Ue=>{const dt=(Ue.startSample+Ue.durationSamples)/Ue.sampleRate;be=Math.max(be,dt)})}),X(be),_e($e=>{if($e.length===e.length)return $e;const Ue=[...$e];for(const dt of ye)Ue.push({name:dt.name,muted:dt.muted,soloed:dt.soloed,volume:dt.volume,pan:dt.pan});return Ue});const sn=[];e.forEach($e=>{$e.clips.forEach(Ue=>{Ue.audioBuffer&&sn.push(Ue.audioBuffer)})}),re(sn),et.current=e;return}catch(L){console.warn("[waveform-playlist] Incremental add failed, falling through to full rebuild:",String(L))}if(w){let L=0;e.forEach(ye=>{ye.clips.forEach(xe=>{const be=(xe.startSample+xe.durationSamples)/xe.sampleRate;L=Math.max(L,be)})}),X(L);return}if(fe(!1),e.length===0){re([]),X(0),_e([]),Ie([]),B.current&&(B.current.dispose(),B.current=null),et.current=e;return}const N=Te.current,G=ae.current;return B.current&&N&&(B.current.stop(),Qr(),Jr.current={position:G}),(async()=>{try{const L=[];e.forEach(Ee=>{Ee.clips.forEach(Ke=>{Ke.audioBuffer&&L.push(Ke.audioBuffer)})});let ye=0;e.forEach(Ee=>{Ee.clips.forEach(Ke=>{const jt=Ke.sampleRate,ch=(Ke.startSample+Ke.durationSamples)/jt;ye=Math.max(ye,ch)})}),re(L),X(ye),_e(Ee=>Ee.length===e.length?Ee.map((Ke,jt)=>({...Ke,name:e[jt].name})):e.map(Ke=>({name:Ke.name,muted:Ke.muted,soloed:Ke.soloed,volume:Ke.volume,pan:Ke.pan}))),B.current&&B.current.dispose(),J.current=0,Xe.current=null,Y.current=!1;const xe=Rh({effects:u,soundFontCache:Mt.current}),be=new Wh({adapter:xe,samplesPerPixel:vt.current,zoomLevels:I});be.setSelection(Yr.current??0,Ur.current??0),be.setLoopRegion(Ui.current??0,Ki.current??0),Yi.current&&be.setLoopEnabled(!0),be.setMasterVolume(Tt.current??1),tl.current&&be.selectTrack(tl.current);const sn=xt.current,$e=e.map((Ee,Ke)=>{const jt=sn[Ke];return{...Ee,volume:jt?.volume??Ee.volume,muted:jt?.muted??Ee.muted,soloed:jt?.soloed??Ee.soloed,pan:jt?.pan??Ee.pan}});let Ue=!0;be.on("statechange",Ee=>{Zi(Ee),Qi(Ee),el(Ee),Q(Ee),zt(Ee),!Ue&&Ee.tracksVersion!==J.current&&(J.current=Ee.tracksVersion,Xe.current=Ee.tracks,v?v(Ee.tracks):console.warn("[waveform-playlist] Engine tracks changed but onTracksChange prop is not set — UI will revert on next render. Pass onTracksChange to WaveformPlaylistProvider."))}),be.setTracks($e),Ue=!1,J.current=be.getState().tracksVersion,B.current=be,fe(!0);const dt=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:ye}});window.dispatchEvent(dt),et.current=e,f?.()}catch(L){console.warn("[waveform-playlist] Error loading audio:",String(L))}})(),()=>{if(ce.current){ce.current=!1;return}Qr(),B.current&&B.current.dispose()}},[e,f,u,Qr,Zi,Qi,el,Q,zt,v,Tt,Yr,Ur,Ui,Ki,Yi,I,b,w]),m.useEffect(()=>{if(e.length===0)return;const N=e.map(G=>G.clips.map(L=>{let ye;if(L.waveformData)try{ye=pc(L.waveformData,Ae,n,L.offsetSamples,L.durationSamples)}catch(xe){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",xe)}if(!ye){const xe=rl.get(L.id);if(xe)try{ye=pc(xe,Ae,n,L.offsetSamples,L.durationSamples)}catch(be){console.warn("[waveform-playlist] Failed to extract peaks from cache:",be)}}if(!ye){!w&&!L.audioBuffer&&!L.waveformData&&!L.midiNotes&&console.warn(`[waveform-playlist] Clip "${L.id}" has no audio data or waveform data`);const xe=n?1:L.audioBuffer?.numberOfChannels??1,be=L.midiNotes?Math.ceil(L.durationSamples/Ae):0;ye={length:be,data:Array.from({length:xe},()=>new Int16Array(be*2)),bits:16}}return{clipId:L.id,trackName:G.name,peaks:ye,startSample:L.startSample,durationSamples:L.durationSamples,fadeIn:L.fadeIn,fadeOut:L.fadeOut,midiNotes:L.midiNotes,sampleRate:L.sampleRate,offsetSamples:L.offsetSamples}}));Ie(N)},[e,Ae,n,rl,w]);const il=m.useRef(!1),In=m.useCallback(()=>{if(B.current)return B.current.getCurrentTime();il.current||(il.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const N=W.getContext().currentTime-(He.current??0);return(ct.current??0)+N},[]),rn=m.useCallback(()=>{const N=()=>{const G=In();ae.current=G;const ue=A.current;if(ue.length>0){const L=ue.find(ye=>G>=ye.start&&G<ye.end);if(H.current)L&&L.id!==he.current?Bt(L.id):!L&&he.current!==null&&Bt(null);else if(he.current){const ye=ue.find(xe=>xe.id===he.current);if(ye&&G>=ye.end){B.current&&B.current.stop(),$(!1),ae.current=Ve.current,P(Ve.current);return}}else L&&Bt(L.id)}if(Je.current&&ut.current&&V>0){const L=ut.current,ye=Z.current,xe=G*ye/vt.current,be=L.clientWidth,sn=Math.max(0,xe-be/2);L.scrollLeft=sn}if(gt.current!==null&&G>=gt.current){B.current&&B.current.stop(),$(!1),ae.current=gt.current,P(gt.current),gt.current=null;return}if(G>=V&&!k.current){B.current&&B.current.stop(),$(!1),ae.current=Ve.current,P(Ve.current),Bt(null);return}da(N)};da(N)},[V,Bt,da,In]),yt=Qr;m.useEffect(()=>{(async()=>{if(M&&nl.current&&B.current)if(q){const G=ae.current;B.current.stop(),yt();const L=W.getContext().currentTime;He.current=L,ct.current=G,B.current.play(G),rn()}else yt(),rn()})().catch(G=>{console.warn("[waveform-playlist] Failed to reschedule playback:",G),$(!1),yt()})},[q,M,rn,yt,nl]),m.useEffect(()=>{(async()=>{if(Jr.current&&B.current){const{position:G}=Jr.current;Jr.current=null;const L=W.getContext().currentTime;He.current=L,ct.current=G,Y.current||(await B.current.init(),Y.current=!0),B.current.play(G),$(!0),rn()}})().catch(G=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",G),$(!1),yt()})},[e,rn,yt]);const es=m.useCallback(async(N,G)=>{if(!B.current||V===0)return;const ue=N??ae.current;Ve.current=ue,ae.current=ue,B.current.stop(),B.current.seek(ue),yt();const ye=W.getContext().currentTime;He.current=ye,ct.current=ue,gt.current=G!==void 0?ue+G:null,Y.current||(await B.current.init(),Y.current=!0);const xe=G!==void 0?ue+G:void 0;try{B.current.play(ue,xe)}catch(be){console.warn("[waveform-playlist] Playback failed to start:",be),yt();return}$(!0),rn()},[V,rn,yt]),ll=m.useCallback(()=>{if(!B.current)return;const N=In();B.current.pause(),$(!1),yt(),ae.current=N,P(N)},[yt,In]),cl=m.useCallback(()=>{B.current&&(B.current.stop(),$(!1),yt(),ae.current=Ve.current,P(Ve.current),Bt(null))},[yt,Bt]),ul=m.useCallback(N=>{const G=Math.max(0,Math.min(N,V));ae.current=G,P(G),M&&B.current&&es(G)},[V,M,es]),dl=m.useCallback((N,G)=>{const ue=lt.current[N]?.id;if(!ue)return;const L=[...j];L[N]={...L[N],muted:G},_e(L),B.current&&B.current.setTrackMute(ue,G)},[j]),fl=m.useCallback((N,G)=>{const ue=lt.current[N]?.id;if(!ue)return;const L=[...j];L[N]={...L[N],soloed:G},_e(L),B.current&&B.current.setTrackSolo(ue,G)},[j]),hl=m.useCallback((N,G)=>{const ue=lt.current[N]?.id;if(!ue)return;const L=[...j];L[N]={...L[N],volume:G},_e(L),B.current&&B.current.setTrackVolume(ue,G)},[j]),pl=m.useCallback((N,G)=>{const ue=lt.current[N]?.id;if(!ue)return;const L=[...j];L[N]={...L[N],pan:G},_e(L),B.current&&B.current.setTrackPan(ue,G)},[j]),ml=m.useCallback((N,G)=>{Ni(N,G),ae.current=N,P(N),M&&B.current&&(B.current.stop(),B.current.seek(N),B.current.play(N))},[M,Ni]),gl=m.useCallback(N=>{ut.current=N},[]),ha=m.useRef(d);ha.current=d;const vl=m.useCallback(N=>{const G=typeof N=="function"?N(A.current):N;if(!ha.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}ha.current(G)},[]),pa=ge[0]?.sampleRate||e[0]?.clips[0]?.sampleRate||44100;Z.current=pa;const ma=t?30:0,yl=e.length*r+ma,sh=m.useMemo(()=>({isPlaying:M,currentTime:O,currentTimeRef:ae,playbackStartTimeRef:He,audioStartPositionRef:ct,getPlaybackTime:In}),[M,O,ae,He,ct,In]),ah=m.useMemo(()=>({continuousPlay:q,linkEndpoints:Me,annotationsEditable:K,isAutomaticScroll:te,isLoopEnabled:Gi,annotations:E,activeAnnotationId:R,selectionStart:kn,selectionEnd:nn,selectedTrackId:qi,loopStart:zi,loopEnd:ji,indefinitePlayback:C}),[q,Me,K,te,Gi,E,R,kn,nn,qi,zi,ji,C]),bl=m.useCallback(N=>{ae.current=N,P(N)},[ae]),wl=m.useCallback(N=>{mt(N)},[]),oh=m.useMemo(()=>({play:es,pause:ll,stop:cl,seekTo:ul,setCurrentTime:bl,setTrackMute:dl,setTrackSolo:fl,setTrackVolume:hl,setTrackPan:pl,setSelection:ml,setSelectedTrackId:Ji,setTimeFormat:U,formatTime:oe,zoomIn:ie.zoomIn,zoomOut:ie.zoomOut,setMasterVolume:Ge,setAutomaticScroll:wl,setScrollContainer:gl,scrollContainerRef:ut,setContinuousPlay:sl,setLinkEndpoints:je,setAnnotationsEditable:le,setAnnotations:vl,setActiveAnnotationId:Bt,setLoopEnabled:Hi,setLoopRegion:Kr,setLoopRegionFromSelection:al,clearLoopRegion:Xi}),[es,ll,cl,ul,bl,dl,fl,hl,pl,ml,Ji,U,oe,ie.zoomIn,ie.zoomOut,Ge,wl,gl,ut,sl,je,le,vl,Bt,Hi,Kr,al,Xi]),ih=m.useMemo(()=>({duration:V,audioBuffers:ge,peaksDataArray:se,trackStates:j,tracks:e,sampleRate:pa,waveHeight:r,timeScaleHeight:ma,minimumPlaylistHeight:yl,controls:l,playoutRef:B,samplesPerPixel:Ae,timeFormat:z,masterVolume:Ye,canZoomIn:ie.canZoomIn,canZoomOut:ie.canZoomOut,barWidth:h,barGap:g,progressBarWidth:S,isReady:Ze,mono:n,isDraggingRef:Fe,onTracksChange:v}),[V,ge,se,j,e,pa,r,ma,yl,l,B,Ae,z,Ye,ie.canZoomIn,ie.canZoomOut,h,g,S,Ze,n,Fe,v]),lh={...Jd,...i};return x.jsx(D.ThemeProvider,{theme:lh,children:x.jsx(Ef.Provider,{value:sh,children:x.jsx(Mf.Provider,{value:ah,children:x.jsx(Tf.Provider,{value:oh,children:x.jsx(Rf.Provider,{value:ih,children:_})})})})})},at=()=>{const e=m.useContext(Ef);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},ot=()=>{const e=m.useContext(Mf);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},ke=()=>{const e=m.useContext(Tf);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},it=()=>{const e=m.useContext(Rf);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var Py=class{constructor(e){this._playbackRate=1,this._audioContext=null,this._sourceNode=null,this._fadeGain=null,this._volumeGain=null,this.handleEnded=()=>{this._cancelFades(),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,this._volume=e.volume??1,this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut,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.playbackRate=this._playbackRate;const t=this.audioElement;if("preservesPitch"in this.audioElement?t.preservesPitch=!0:"mozPreservesPitch"in this.audioElement?t.mozPreservesPitch=!0:"webkitPreservesPitch"in this.audioElement&&(t.webkitPreservesPitch=!0),e.audioContext){this._audioContext=e.audioContext;try{this._sourceNode=e.audioContext.createMediaElementSource(this.audioElement)}catch(n){throw new Error("[waveform-playlist] MediaElementTrack: createMediaElementSource() failed. This can happen if the audio element is already connected to another AudioContext. Each audio element can only have one MediaElementSourceNode. Original error: "+String(n))}this._fadeGain=e.audioContext.createGain(),this._volumeGain=e.audioContext.createGain(),this._volumeGain.gain.value=this._volume,this._sourceNode.connect(this._fadeGain),this._fadeGain.connect(this._volumeGain),this._volumeGain.connect(e.audioContext.destination),this.audioElement.volume=1}else this.audioElement.volume=this._volume;this.audioElement.addEventListener("ended",this.handleEnded),this.audioElement.addEventListener("timeupdate",this.handleTimeUpdate)}_scheduleFades(e){if(!this._fadeGain||!this._audioContext)return;const t=this._fadeGain.gain,n=this._audioContext.currentTime,r=this.duration;if(t.cancelScheduledValues(0),t.setValueAtTime(1,n),this._fadeIn&&this._fadeIn.duration>0){const s=this._fadeIn.duration;if(e<s){const a=s-e,o=this._fadeIn.type??"linear";if(e===0)Va(t,n,a,o,0,1);else{const i=ks(o,1e3,!0),l=Math.round(e/this._fadeIn.duration*(i.length-1)),c=i.slice(l);t.setValueAtTime(c[0],n),t.setValueCurveAtTime(c,n,a)}}}if(this._fadeOut&&this._fadeOut.duration>0){const s=r-this._fadeOut.duration;if(e<r&&s<r)if(e>s){const a=e-s,o=this._fadeOut.type??"linear",i=ks(o,1e3,!1),l=Math.round(a/this._fadeOut.duration*(i.length-1)),c=i.slice(l),u=this._fadeOut.duration-a;t.setValueAtTime(c[0],n),t.setValueCurveAtTime(c,n,u)}else{const a=s-e;La(t,n+a,this._fadeOut.duration,this._fadeOut.type??"linear",1,0)}}}_cancelFades(){this._fadeGain&&(this._fadeGain.gain.cancelScheduledValues(0),this._fadeGain.gain.value=1)}play(e=0){const t=()=>{this._scheduleFades(e),this.audioElement.currentTime=e,this.audioElement.play().catch(n=>{console.warn("[waveform-playlist] MediaElementTrack: play() failed: "+String(n))})};this._audioContext&&this._audioContext.state==="suspended"?this._audioContext.resume().then(t).catch(n=>{console.warn("[waveform-playlist] MediaElementTrack: AudioContext.resume() failed: "+String(n))}):t()}pause(){this._cancelFades(),this.audioElement.pause()}stop(){this._cancelFades(),this.audioElement.pause(),this.audioElement.currentTime=0}seekTo(e){this.audioElement.currentTime=Math.max(0,Math.min(e,this.duration))}setVolume(e){this._volume=Math.max(0,Math.min(1,e)),this._volumeGain?this._volumeGain.gain.value=this._volume:this.audioElement.volume=this._volume}setPlaybackRate(e){const t=Math.max(.5,Math.min(2,e));this._playbackRate=t,this.audioElement.playbackRate=t}setMuted(e){this.audioElement.muted=e}setFadeIn(e){this._fadeIn=e}setFadeOut(e){this._fadeOut=e}setOnStopCallback(e){this.onStopCallback=e}setOnTimeUpdateCallback(e){this.onTimeUpdateCallback=e}connectOutput(e){if(!this._volumeGain){console.warn("[waveform-playlist] MediaElementTrack: connectOutput() requires audioContext. Pass audioContext in constructor options.");return}try{this._volumeGain.disconnect()}catch(t){console.warn("[waveform-playlist] MediaElementTrack: disconnect before connectOutput failed: "+String(t))}this._volumeGain.connect(e)}disconnectOutput(){if(!(!this._volumeGain||!this._audioContext)){try{this._volumeGain.disconnect()}catch(e){console.warn("[waveform-playlist] MediaElementTrack: disconnect before disconnectOutput failed: "+String(e))}this._volumeGain.connect(this._audioContext.destination)}}dispose(){if(this.audioElement.removeEventListener("ended",this.handleEnded),this.audioElement.removeEventListener("timeupdate",this.handleTimeUpdate),this._cancelFades(),this.audioElement.pause(),this._sourceNode)try{this._sourceNode.disconnect()}catch(e){console.warn("[waveform-playlist] MediaElementTrack: sourceNode disconnect failed: "+String(e))}if(this._fadeGain)try{this._fadeGain.disconnect()}catch(e){console.warn("[waveform-playlist] MediaElementTrack: fadeGain disconnect failed: "+String(e))}if(this._volumeGain)try{this._volumeGain.disconnect()}catch(e){console.warn("[waveform-playlist] MediaElementTrack: volumeGain disconnect failed: "+String(e))}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._volume}get playbackRate(){return this._playbackRate}get muted(){return this.audioElement.muted}get element(){return this.audioElement}get outputNode(){return this._volumeGain}},Fy=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 Py({...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}get outputNode(){return this.track?.outputNode??null}};const $f=m.createContext(null),Df=m.createContext(null),Pf=m.createContext(null),Ff=m.createContext(null),Oy=({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,audioContext:p,onAnnotationsChange:d,onReady:h,children:g})=>{const y=f??c+u,[v,b]=m.useState(!1),[w,C]=m.useState(0),[_,S]=m.useState(0),[k,I]=m.useState([]),[E,A]=m.useState(s),R=m.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const H=l.annotations[0];if(typeof H.start!="number"||typeof H.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 H.start),[]}return l.annotations},[l?.annotations]),T=m.useRef(R);T.current=R;const[M,$]=m.useState(null),[O,P]=m.useState(l?.isContinuousPlay??!1),[V]=m.useState(t),[X,ge]=m.useState(a),re=m.useRef(null),se=m.useRef(0),Ie=m.useRef(O),j=m.useRef(null),_e=m.useRef(null),te=m.useRef(a),mt=m.useRef(t),{startAnimationFrameLoop:q,stopAnimationFrameLoop:me}=Af();m.useEffect(()=>{Ie.current=O},[O]),m.useEffect(()=>{te.current=X},[X]);const Me=m.useCallback(H=>{j.current=H,$(H)},[]),je=m.useCallback(H=>{Ie.current=H,P(H)},[]),K=m.useCallback(H=>{_e.current=H},[]),le=e.waveformData.sample_rate;m.useEffect(()=>{const H=new Fy({playbackRate:s});H.addTrack({source:e.source,peaks:e.waveformData,name:e.name,audioContext:p,fadeIn:e.fadeIn,fadeOut:e.fadeOut});const he=H.getTrack(H.track?.id??"");return he&&he.setOnTimeUpdateCallback(Xe=>{se.current=Xe}),H.setOnPlaybackComplete(()=>{me(),b(!1),Me(null),se.current=0,C(0)}),re.current=H,S(e.waveformData.duration),h?.(),()=>{me(),H.dispose()}},[e.source,e.waveformData,e.name,e.fadeIn,e.fadeOut,p,s,h,me,Me]),m.useEffect(()=>{try{const H=ty(e.waveformData,V,0,0,Math.ceil(e.waveformData.duration*le)),he={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:H.length,data:[H.data],bits:H.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*le)};I([[he]])}catch(H){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",H)}},[e.waveformData,e.name,V,le]);const Ze=m.useCallback(()=>{const H=()=>{const he=re.current?.getCurrentTime()??0;se.current=he;const Xe=T.current;if(Xe.length>0){const J=Xe.find(ce=>he>=ce.start&&he<ce.end);if(Ie.current)J&&J.id!==j.current?Me(J.id):!J&&j.current!==null&&Me(null);else if(j.current){const ce=Xe.find(Fe=>Fe.id===j.current);if(ce&&he>=ce.end){re.current?.stop(),b(!1);return}}else J&&Me(J.id)}if(te.current&&_e.current){const J=_e.current,ce=he*le/mt.current,Fe=J.clientWidth,et=Math.max(0,ce-Fe/2);J.scrollLeft=et}q(H)};q(H)},[Me,le,q]),fe=me,B=m.useCallback(H=>{if(!re.current)return;const he=H??se.current;re.current.play(void 0,he),b(!0),Ze()},[Ze]),Y=m.useCallback(()=>{re.current&&(re.current.pause(),b(!1),fe(),C(re.current.getCurrentTime()))},[fe]),Te=m.useCallback(()=>{re.current&&(re.current.stop(),b(!1),fe(),se.current=0,C(0),Me(null))},[fe,Me]),Ve=m.useCallback(H=>{const he=Math.max(0,Math.min(H,_));se.current=he,C(he),re.current&&re.current.seekTo(he)},[_]),ae=m.useCallback(H=>{const he=Math.max(.5,Math.min(2,H));A(he),re.current&&re.current.setPlaybackRate(he)},[]),lt=r?30:0,Mt=m.useMemo(()=>({isPlaying:v,currentTime:w,currentTimeRef:se}),[v,w]),xt=m.useMemo(()=>({continuousPlay:O,annotations:R,activeAnnotationId:M,playbackRate:E,isAutomaticScroll:X}),[O,R,M,E,X]),He=m.useRef(d);He.current=d;const ct=m.useCallback(H=>{const he=typeof H=="function"?H(T.current):H;if(!He.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}He.current(he)},[]),gt=m.useMemo(()=>({play:B,pause:Y,stop:Te,seekTo:Ve,setPlaybackRate:ae,setContinuousPlay:je,setAnnotations:ct,setActiveAnnotationId:Me,setAutomaticScroll:H=>{ge(H)},setScrollContainer:K,scrollContainerRef:_e}),[B,Y,Te,Ve,ae,je,ct,Me,K]),ut=m.useMemo(()=>({duration:_,peaksDataArray:k,sampleRate:le,waveHeight:n,timeScaleHeight:lt,samplesPerPixel:V,playoutRef:re,controls:i,barWidth:c,barGap:u,progressBarWidth:y,fadeIn:e.fadeIn,fadeOut:e.fadeOut}),[_,k,le,n,lt,V,i,c,u,y,e.fadeIn,e.fadeOut]),Je={...Jd,...o};return x.jsx(D.ThemeProvider,{theme:Je,children:x.jsx($f.Provider,{value:Mt,children:x.jsx(Df.Provider,{value:xt,children:x.jsx(Pf.Provider,{value:gt,children:x.jsx(Ff.Provider,{value:ut,children:g})})})})})},Hr=()=>{const e=m.useContext($f);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},ia=()=>{const e=m.useContext(Df);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},Bi=()=>{const e=m.useContext(Pf);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},la=()=>{const e=m.useContext(Ff);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},By=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=at(),{selectionStart:r,selectionEnd:s,isLoopEnabled:a}=ot(),{play:o}=ke(),i=async()=>{if(r!==s&&s>r&&!a){const c=s-r;await o(r,c)}else await o(n.current??0)};return x.jsx(_t,{onClick:i,disabled:t,className:e,children:"Play"})},Wy=({className:e})=>{const{isPlaying:t}=at(),{pause:n}=ke();return x.jsx(_t,{onClick:n,disabled:!t,className:e,children:"Pause"})},Vy=({className:e})=>{const{isPlaying:t}=at(),{stop:n}=ke();return x.jsx(_t,{onClick:n,disabled:!t,className:e,children:"Stop"})},Ly=({className:e})=>{const{isPlaying:t}=at(),{play:n,setCurrentTime:r}=ke(),s=()=>{r(0),t&&n(0)};return x.jsx(_t,{onClick:s,className:e,children:"Rewind"})},Ny=({className:e})=>{const{isPlaying:t}=at(),{play:n,setCurrentTime:r}=ke(),{duration:s}=it(),a=()=>{r(s),t&&n(s)};return x.jsx(_t,{onClick:a,className:e,children:"Fast Forward"})},Zy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=at(),{play:s,setCurrentTime:a}=ke(),o=()=>{const i=Math.max(0,(n.current??0)-e);a(i),r&&s(i)};return x.jsx(_t,{onClick:o,className:t,children:"Skip Backward"})},Gy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=at(),{play:s,setCurrentTime:a}=ke(),{duration:o}=it(),i=()=>{const l=Math.min(o,(n.current??0)+e);a(l),r&&s(l)};return x.jsx(_t,{onClick:i,className:t,children:"Skip Forward"})},zy=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=ot(),{setLoopEnabled:s,setLoopRegion:a}=ke(),{duration:o}=it(),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 x.jsx(_t,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},jy=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=ot(),{setLoopRegionFromSelection:a,clearLoopRegion:o}=ke(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?o():a()};return x.jsx(_t,{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"})},Hy=({onClearAll:e,label:t="Clear All",className:n})=>{const{stop:r}=ke(),s=m.useCallback(()=>{r(),e()},[r,e]);return x.jsx(_t,{onClick:s,className:n,title:"Remove all tracks",children:t})},Xy=({className:e,disabled:t})=>{const{zoomIn:n}=ke(),{canZoomIn:r}=it();return x.jsx(_t,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},Yy=({className:e,disabled:t})=>{const{zoomOut:n}=ke(),{canZoomOut:r}=it();return x.jsx(_t,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},Uy=({className:e})=>{const{masterVolume:t}=it(),{setMasterVolume:n}=ke();return x.jsx(_v,{volume:t,onChange:n,className:e})},Ky=({className:e})=>{const{timeFormat:t}=it(),{setTimeFormat:n}=ke();return x.jsx(a0,{value:t,onChange:n,className:e})},Qy=D.span`
|
|
1005
1056
|
font-family: 'Courier New', Monaco, monospace;
|
|
1006
1057
|
font-size: 1rem;
|
|
1007
1058
|
font-weight: 600;
|
|
1008
1059
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
1009
1060
|
user-select: none;
|
|
1010
|
-
`,
|
|
1061
|
+
`,qy=({className:e})=>{const t=m.useRef(null),n=m.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=at(),{timeFormat:o}=it();return m.useEffect(()=>{const i=()=>{if(t.current){const l=r?a():s.current??0;t.current.textContent=Vn(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=Vn(s.current??0,o))}),x.jsx(Qy,{ref:t,className:e,"aria-label":"Audio position",children:Vn(s.current??0,o)})},Jy=({className:e})=>{const{selectionStart:t,selectionEnd:n}=ot(),{setSelection:r}=ke();return x.jsx(Vv,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},eb=({className:e})=>{const{isAutomaticScroll:t}=ot(),{setAutomaticScroll:n}=ke();return x.jsx(Kg,{checked:t,onChange:n,className:e})},ca=m.createContext(null),tb=ca.Provider;function Sn(){const e=m.useContext(ca);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 nb=({className:e})=>{const{ContinuousPlayCheckbox:t}=Sn(),{continuousPlay:n}=ot(),{setContinuousPlay:r}=ke();return x.jsx(t,{checked:n,onChange:r,className:e})},rb=({className:e})=>{const{LinkEndpointsCheckbox:t}=Sn(),{linkEndpoints:n}=ot(),{setLinkEndpoints:r}=ke();return x.jsx(t,{checked:n,onChange:r,className:e})},sb=({className:e})=>{const{EditableCheckbox:t}=Sn(),{annotationsEditable:n}=ot(),{setAnnotationsEditable:r}=ke();return x.jsx(t,{checked:n,onChange:r,className:e})},ab=({filename:e,className:t})=>{const{DownloadAnnotationsButton:n}=Sn(),{annotations:r}=ot();return x.jsx(n,{annotations:r,filename:e,className:t})},ob=({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}=it(),{exportWav:d,isExporting:h,progress:g}=If(),y=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"))}},v=h?`Exporting ${Math.round(g*100)}%`:e;return x.jsx(_t,{onClick:y,disabled:h||f.length===0,className:l,children:v})},Of=m.createContext(!1),ib=Of.Provider;function Bf(){return m.useContext(Of)}const lb=D.div.attrs(e=>({style:{width:`${e.$width}px`,background:e.$color}}))`
|
|
1011
1062
|
position: absolute;
|
|
1012
1063
|
top: 0;
|
|
1013
1064
|
left: 0;
|
|
@@ -1015,16 +1066,16 @@ self.onmessage = function(e) {
|
|
|
1015
1066
|
z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
|
|
1016
1067
|
pointer-events: none;
|
|
1017
1068
|
will-change: transform;
|
|
1018
|
-
`,
|
|
1069
|
+
`,cb=({color:e="#ff0000"})=>{const t=m.useRef(null),n=m.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=at(),{samplesPerPixel:o,sampleRate:i,progressBarWidth:l}=it();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)`}}),x.jsx(lb,{ref:t,$color:e,$width:l,"data-playhead":!0})},ub=D.div`
|
|
1019
1070
|
position: relative;
|
|
1020
|
-
|
|
1071
|
+
`,$a=D.div.attrs(e=>({style:{top:`${e.$top}px`,width:`${e.$width}px`,height:`${e.$height}px`,background:e.$color}}))`
|
|
1021
1072
|
position: absolute;
|
|
1022
1073
|
left: 0;
|
|
1023
1074
|
z-index: 0;
|
|
1024
1075
|
/* Force GPU compositing layer to prevent gradient flickering during scroll */
|
|
1025
1076
|
transform: translateZ(0);
|
|
1026
1077
|
backface-visibility: hidden;
|
|
1027
|
-
`,
|
|
1078
|
+
`,db=D.div.attrs(e=>({style:{top:`${e.$top}px`,height:`${e.$height}px`,width:`${e.$width}px`,background:e.$color,transform:"scaleX(0)"}}))`
|
|
1028
1079
|
position: absolute;
|
|
1029
1080
|
left: 0;
|
|
1030
1081
|
pointer-events: none;
|
|
@@ -1032,16 +1083,16 @@ self.onmessage = function(e) {
|
|
|
1032
1083
|
transform-origin: left;
|
|
1033
1084
|
/* scaleX changes are composite-only (GPU) — no layout reflow per frame */
|
|
1034
1085
|
will-change: transform;
|
|
1035
|
-
`,
|
|
1086
|
+
`,fb=D.div`
|
|
1036
1087
|
position: relative;
|
|
1037
1088
|
z-index: 2;
|
|
1038
|
-
`,
|
|
1089
|
+
`,vc=({clipStartSample:e,clipDurationSamples:t,midiNotes:n,clipSampleRate:r,clipOffsetSeconds:s,...a})=>{const o=m.useRef(null),i=m.useRef(null),l=zr(),{waveHeight:c}=aa(),{isPlaying:u,currentTimeRef:f,getPlaybackTime:p}=at(),{samplesPerPixel:d,sampleRate:h}=it(),g=l?.waveProgressColor||"rgba(0, 0, 0, 0.1)",y=Ec(e,t,d);m.useEffect(()=>{const R=()=>{if(o.current){const M=(u?p():f.current??0)*h,$=e+t;let O=0;M<=e?O=0:M>=$?O=1:O=(M-e)/t,o.current.style.transform=`scaleX(${O})`}u&&(i.current=requestAnimationFrame(R))};return u?i.current=requestAnimationFrame(R):R(),()=>{i.current&&(cancelAnimationFrame(i.current),i.current=null)}},[u,h,e,t,y,f,p]),m.useEffect(()=>{if(!u&&o.current){const T=(f.current??0)*h,M=e+t;let $=0;T<=e?$=0:T>=M?$=1:$=(T-e)/t,o.current.style.transform=`scaleX(${$})`}});const v=l?.waveformDrawMode||"inverted";let b;v==="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",C=a.renderMode==="piano-roll",_=a.renderMode==="both",S=w?"#000":C?l?.pianoRollBackgroundColor||"#1a1a2e":Jt(b),k=Math.floor(c/2),I=c,E=a.index*c,A=Jt(b);return x.jsxs(ub,{children:[_?x.jsxs(x.Fragment,{children:[x.jsx($a,{$color:"#000",$height:k,$top:E,$width:a.length}),x.jsx($a,{$color:A,$height:k,$top:E+k,$width:a.length})]}):x.jsx($a,{$color:S,$height:I,$top:E,$width:a.length}),!C&&x.jsx(db,{ref:o,$color:g,$height:I,$top:E,$width:y}),x.jsx(fb,{children:x.jsx(uf,{...a,transparentBackground:!0,midiNotes:n,sampleRate:r,clipOffsetSeconds:s})})]})},Wi=m.createContext(null),hb=Wi.Provider;function pb(){const e=m.useContext(Wi);if(!e)throw new Error("useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>.");return e}const mb=60,gb=D.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
|
|
1039
1090
|
overflow: hidden;
|
|
1040
1091
|
pointer-events: auto;
|
|
1041
1092
|
background: ${e=>e.theme.surfaceColor};
|
|
1042
1093
|
transition: background 0.15s ease-in-out;
|
|
1043
1094
|
${e=>e.$isSelected&&`background: ${e.theme.selectedTrackControlsBackground};`}
|
|
1044
|
-
`,By=({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:Oy;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(Ly,{$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(By,{renderPlayhead:n,color:p.playheadColor,samplesPerPixel:de,sampleRate:ne}):C.jsx(Ty,{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})},Wy=({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 Vy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kf=Vy?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,Ny=Object.prototype.hasOwnProperty,jy=Object.prototype.propertyIsEnumerable,zy=(e,t)=>{var n={};for(var r in e)Ny.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&&jy.call(e,r)&&(n[r]=e[r]);return n},Zy=new ui,Hy=m.createContext(Zy),Gy=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=zy(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=Uy(()=>{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(Hy.Provider,{value:k,children:[C.jsx(Gy,{ref:u,children:n}),n]})}function Uy(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 Xy=Object.create,If=Object.defineProperty,Yy=Object.getOwnPropertyDescriptor,Mf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ea=e=>{throw TypeError(e)},Ky=(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[,,,Xy((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,Jy=(e,t,n,r,s)=>({kind:Af[e],name:t,metadata:r,addInitializer:a=>n._?ea("Already initialized"):s.push(Tf(a||null))}),Qy=(e,t)=>Ky(t,Mf("metadata"),e[3]),eb=(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,Yy(s,n)),y=r.length-1;y>=0;y--)l=Jy(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),tb=(e,t,n)=>(Rf(e,t,"read from private field"),t.get(e)),nb=(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),rb=(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)),eb(Nr,5,this),nb(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-tb(this,vs),o=i=>Math.round(i/a*100);Yt(()=>{rb(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=qy(ho);vs=new WeakMap;$f(Nr,2,"delta",Pf,Ei);$f(Nr,2,"direction",Df,Ei);Qy(Nr,Ei);var Ff=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ff||{});Object.values(Ff);var sb=Object.defineProperty,ab=Object.defineProperties,ob=Object.getOwnPropertyDescriptors,sc=Object.getOwnPropertySymbols,ib=Object.prototype.hasOwnProperty,lb=Object.prototype.propertyIsEnumerable,ac=(e,t,n)=>t in e?sb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Of=(e,t)=>{for(var n in t||(t={}))ib.call(t,n)&&ac(e,n,t[n]);if(sc)for(var n of sc(t))lb.call(t,n)&&ac(e,n,t[n]);return e},Lf=(e,t)=>ab(e,ob(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},cb=P.div`
|
|
1095
|
+
`,vb=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:a,playbackStartTimeRef:o,audioStartPositionRef:i,getPlaybackTime:l}=at();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:()=>Is().rawContext.currentTime,getPlaybackTime:l})};function Da(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 Wf=({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=zr(),{isPlaying:d}=at(),{selectionStart:h,selectionEnd:g,annotations:y,activeAnnotationId:v,annotationsEditable:b,linkEndpoints:w,continuousPlay:C,selectedTrackId:_,loopStart:S,loopEnd:k,isLoopEnabled:I,indefinitePlayback:E}=ot(),A=m.useContext(ca),{setAnnotations:R,setActiveAnnotationId:T,setTrackMute:M,setTrackSolo:$,setTrackVolume:O,setTrackPan:P,setSelection:V,play:X,setScrollContainer:ge,setSelectedTrackId:re,setCurrentTime:se,setLoopRegion:Ie}=ke(),{peaksDataArray:j,trackStates:_e,tracks:te,duration:mt,samplesPerPixel:q,sampleRate:me,waveHeight:Me,timeScaleHeight:je,controls:K,barWidth:le,barGap:Ze,isReady:fe,mono:B}=it(),Y=m.useContext(Wi),Te=m.useMemo(()=>{if(!Y)return new Map;const Z=new Map;return te.forEach(z=>{if((Y.trackSpectrogramOverrides.get(z.id)?.renderMode??z.renderMode??"waveform")==="waveform")return;const oe=Y.trackSpectrogramOverrides.get(z.id),ie=oe?.colorMap??z.spectrogramColorMap??Y.spectrogramColorMap??"viridis",Ae=oe?.config??z.spectrogramConfig??Y.spectrogramConfig;Z.set(z.id,{colorLUT:Y.getColorMap(ie),frequencyScaleFn:Y.getFrequencyScale(Ae?.frequencyScale??"mel"),config:Ae})}),Z},[te,Y]),Ve=m.useMemo(()=>{if(Y?.spectrogramWorkerApi)return{registerCanvas:Y.spectrogramWorkerApi.registerCanvas.bind(Y.spectrogramWorkerApi),unregisterCanvas:Y.spectrogramWorkerApi.unregisterCanvas.bind(Y.spectrogramWorkerApi)}},[Y?.spectrogramWorkerApi]),[ae,lt]=m.useState(null),[Mt,xt]=m.useState(!1),He=m.useRef(0),ct=m.useRef(null),gt=m.useCallback(Z=>{ct.current=Z,ge(Z)},[ge]),ut=te.reduce((Z,z)=>z.clips.reduce((U,oe)=>{const ie=(oe.startSample+oe.durationSamples)/oe.sampleRate;return Math.max(U,ie)},Z),0);let Je=ut>0?ut:mt>0?mt:mb;if(E){const z=(ct.current?.clientWidth??0)*q/me;Je=Math.max(Je,z)}if(f?.isRecording){const z=(f.startSample+f.durationSamples)/me;Je=Math.max(Je,z+10)}const H=Math.floor(Je*me/q),he=async Z=>{T(Z.id);const z=C?void 0:Z.end-Z.start;try{await X(Z.start,z)}catch(U){console.error("waveform-playlist: Failed to start playback for annotation",Z.id,U)}},Xe=m.useCallback(Z=>{if(Z>=0&&Z<te.length){const z=te[Z];re(z.id)}},[te,re]),J=Z=>{const z=Z.currentTarget.getBoundingClientRect(),oe=(Z.clientX-z.left)*q/me,Ae=Z.clientY-z.top;let Q=0,Le=-1;for(let Ye=0;Ye<j.length;Ye++){const Ge=j[Ye],Tt=Da(Ge,f,te[Ye]?.id,B),nn=((Y?.trackSpectrogramOverrides.get(te[Ye]?.id)?.renderMode??te[Ye]?.renderMode??"waveform")==="both"?Tt*2:Tt)*Me+(o?22:0);if(Ae>=Q&&Ae<Q+nn){Le=Ye;break}Q+=nn}Le!==-1&&Xe(Le),He.current=oe,xt(!0),se(oe),V(oe,oe)},ce=Z=>{if(!Mt||d)return;const z=Z.currentTarget.getBoundingClientRect(),oe=(Z.clientX-z.left)*q/me,ie=Math.min(h,oe),Ae=Math.max(h,oe);V(ie,Ae)},Fe=Z=>{if(!Mt)return;if(xt(!1),d){const Q=Math.max(0,He.current);se(Q),V(Q,Q),X(Q);return}const z=Z.currentTarget.getBoundingClientRect(),oe=(Z.clientX-z.left)*q/me,ie=Math.min(h,oe),Ae=Math.max(h,oe);Math.abs(Ae-ie)<.1?se(ie):V(ie,Ae)};if(te.some(Z=>Z.clips.length>0)&&j.length===0)return x.jsx("div",{className:a,children:"Loading waveform..."});const vt=K.show?j.map((Z,z)=>{const U=te[z];if(!U)return null;const oe=_e[z]||{name:`Track ${z+1}`,muted:!1,soloed:!1,volume:1,pan:0},ie=U.clips.some(Ge=>Ge.midiNotes&&Ge.midiNotes.length>0),Ae=Y?.trackSpectrogramOverrides.get(U.id)?.renderMode??U.renderMode??(ie?"piano-roll":"waveform"),Q=Da(Z,f,U.id,B),Le=Me*Q+(o?$i:0),Ye=e?e(z):x.jsxs(d0,{onClick:()=>Xe(z),children:[x.jsxs(f0,{style:{justifyContent:"center",position:"relative"},children:[u&&x.jsx(u0,{onClick:Ge=>{Ge.stopPropagation(),u(z)}}),x.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:oe.name||`Track ${z+1}`}),Y?.renderMenuItems&&x.jsx("span",{style:{position:"absolute",right:0,top:0},children:x.jsx(w0,{items:Ge=>Y.renderMenuItems({renderMode:Ae,onRenderModeChange:Tt=>Y.setTrackRenderMode(U.id,Tt),onOpenSettings:()=>lt(U.id),onClose:Ge})})})]}),x.jsxs(l0,{children:[x.jsx(uc,{$variant:oe.muted?"danger":"outline",onClick:()=>M(z,!oe.muted),children:"Mute"}),x.jsx(uc,{$variant:oe.soloed?"info":"outline",onClick:()=>$(z,!oe.soloed),children:"Solo"})]}),x.jsxs(fc,{children:[x.jsx(h0,{}),x.jsx(dc,{min:"0",max:"1",step:"0.01",value:oe.volume,onChange:Ge=>O(z,parseFloat(Ge.target.value))}),x.jsx(p0,{})]}),x.jsxs(fc,{children:[x.jsx("span",{children:"L"}),x.jsx(dc,{min:"-1",max:"1",step:"0.01",value:oe.pan,onChange:Ge=>P(z,parseFloat(Ge.target.value))}),x.jsx("span",{children:"R"})]})]});return x.jsx(gb,{$height:Le,$isSelected:U.id===_,children:Ye},U.id)}):void 0;return x.jsxs(cf,{children:[x.jsx(Gr.Provider,{value:{samplesPerPixel:q,sampleRate:me,zoomLevels:[q],waveHeight:Me,timeScaleHeight:je,duration:Je*1e3,controls:K,barWidth:le,barGap:Ze},children:x.jsx(Di,{theme:p,backgroundColor:p.playlistBackgroundColor||Jt(p.waveOutlineColor),timescaleBackgroundColor:p.timescaleBackgroundColor,timescaleWidth:H,tracksWidth:H,controlsWidth:K.show?K.width:0,onTracksMouseDown:J,onTracksMouseMove:ce,onTracksMouseUp:Fe,scrollContainerRef:gt,isSelecting:Mt,"data-playlist-state":fe?"ready":"loading",trackControlsSlots:vt,timescaleGapHeight:je>0?je+1:0,timescale:je>0?x.jsxs(x.Fragment,{children:[x.jsx(df,{renderTick:t}),I&&x.jsx(Wv,{startPosition:Math.min(S,k)*me/q,endPosition:Math.max(S,k)*me/q,markerColor:p.loopMarkerColor,regionColor:p.loopRegionColor,minPosition:0,maxPosition:H,onLoopRegionChange:(Z,z)=>{const U=Z*q/me,oe=z*q/me;Ie(U,oe)}})]}):void 0,children:x.jsxs(x.Fragment,{children:[j.map((Z,z)=>{const U=te[z];if(!U)return null;const oe=U.clips.some(Q=>Q.midiNotes&&Q.midiNotes.length>0),ie=Y?.trackSpectrogramOverrides.get(U.id)?.renderMode??U.renderMode??(oe?"piano-roll":"waveform"),Ae=Da(Z,f,U.id,B);return x.jsxs(ff,{numChannels:Ae,backgroundColor:ie==="piano-roll"?p.pianoRollBackgroundColor||"#1a1a2e":Jt(p.waveOutlineColor),offset:0,width:H,hasClipHeaders:o,trackId:U.id,isSelected:U.id===_,children:[ie!=="waveform"&&(()=>{const Q=Te.get(U.id),Le=Q?.config;return!Le?.labels||!Q?null:x.jsx(Kv,{waveHeight:Me,numChannels:Ae,frequencyScaleFn:Q.frequencyScaleFn,minFrequency:Le.minFrequency??0,maxFrequency:Le.maxFrequency??me/2,labelsColor:Le.labelsColor,labelsBackground:Le.labelsBackground,renderMode:ie,hasClipHeaders:o})})(),Z.map((Q,Le)=>{const Ye=Q.peaks,Ge=Ye.length;return x.jsx(_o,{clipId:Q.clipId,trackIndex:z,clipIndex:Le,trackName:Q.trackName,startSample:Q.startSample,durationSamples:Q.durationSamples,samplesPerPixel:q,showHeader:o,disableHeaderDrag:!i,isSelected:U.id===_,trackId:U.id,fadeIn:Q.fadeIn,fadeOut:Q.fadeOut,sampleRate:me,showFades:l,touchOptimized:c,onMouseDown:Tt=>{Tt.target.closest('[role="button"][aria-roledescription="draggable"]')||Xe(z)},children:Ye.data.map((Tt,zt)=>x.jsx(vc,{index:zt,data:Tt,bits:Ye.bits,length:Ge,isSelected:U.id===_,clipStartSample:Q.startSample,clipDurationSamples:Q.durationSamples,renderMode:Q.midiNotes?"piano-roll":ie,midiNotes:Q.midiNotes,clipSampleRate:Q.sampleRate,clipOffsetSeconds:Q.offsetSamples!=null?Q.offsetSamples/(Q.sampleRate||me):0,samplesPerPixel:q,spectrogramWorkerApi:Ve,spectrogramClipId:Q.clipId,spectrogramOnCanvasesReady:Y?(kn,nn)=>{Y.registerSpectrogramCanvases(Q.clipId,zt,kn,nn)}:void 0},`${Q.clipId}-${zt}`))},Q.clipId)}),f?.isRecording&&f.trackId===U.id&&f.peaks[0]?.length>0&&x.jsx(_o,{clipId:"recording-preview",trackIndex:z,clipIndex:Z.length,trackName:"Recording...",startSample:f.startSample,durationSamples:f.durationSamples,samplesPerPixel:q,showHeader:o,disableHeaderDrag:!0,isSelected:U.id===_,trackId:U.id,children:(B?f.peaks.slice(0,1):f.peaks).map((Q,Le)=>x.jsx(vc,{index:Le,data:Q,bits:f.bits,length:Math.floor(Q.length/2),isSelected:U.id===_,clipStartSample:f.startSample,clipDurationSamples:f.durationSamples},`${U.id}-recording-${Le}`))},`${U.id}-recording`)]},U.id)}),y.length>0&&A&&x.jsx(A.AnnotationBoxesWrapper,{height:30,width:H,children:y.map((Z,z)=>{const U=Z.start*me/q,oe=Z.end*me/q,ie=s?s(Z,z):Z.id;return x.jsx(A.AnnotationBox,{annotationId:Z.id,annotationIndex:z,startPosition:U,endPosition:oe,label:ie,color:"#ff9800",isActive:Z.id===v,onClick:()=>he(Z),editable:b},Z.id)})}),h!==g&&x.jsx(sf,{startPosition:Math.min(h,g)*me/q,endPosition:Math.max(h,g)*me/q,color:p.selectionColor}),(d||h===g)&&(n?x.jsx(vb,{renderPlayhead:n,color:p.playheadColor,samplesPerPixel:q,sampleRate:me}):x.jsx(cb,{color:p.playheadColor}))]})})}),Y?.SettingsModal&&typeof document<"u"&&Eo.createPortal(x.jsx(Y.SettingsModal,{open:ae!==null,onClose:()=>lt(null),config:ae!==null?Y.trackSpectrogramOverrides.get(ae)?.config??te.find(Z=>Z.id===ae)?.spectrogramConfig??Y.spectrogramConfig??{}:{},colorMap:ae!==null?Y.trackSpectrogramOverrides.get(ae)?.colorMap??te.find(Z=>Z.id===ae)?.spectrogramColorMap??Y.spectrogramColorMap??"viridis":"viridis",onApply:(Z,z)=>{ae!==null&&Y.setTrackSpectrogramConfig(ae,Z,z)}}),document.body)]})},Vf=({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}=ot(),p=Sn(),{setAnnotations:d}=ke(),h=s??{linkEndpoints:u,continuousPlay:f},g=m.useCallback(v=>{d(v),n?.(v)},[d,n]),{AnnotationText:y}=p;return x.jsx(y,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:a,scrollActiveContainer:o,editable:c,controls:c?r:void 0,annotationListConfig:h,height:e,onAnnotationUpdate:g,renderAnnotationItem:t})},yb=({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:g=!1,onRemoveTrack:y,recordingState:v})=>{const{annotations:b}=ot(),w=Bf(),C=d||w;return x.jsxs(x.Fragment,{children:[x.jsx(Wf,{renderTrackControls:e,renderTick:t??(n?(_,S)=>n(parseFloat(_)||0,S):void 0),renderPlayhead:r,annotationControls:s,getAnnotationBoxLabel:l,className:f,showClipHeaders:p,interactiveClips:C,showFades:h,touchOptimized:g,onRemoveTrack:y,recordingState:v}),b.length>0&&x.jsx(Vf,{height:o,renderAnnotationItem:i,controls:s,annotationListConfig:a,scrollActivePosition:c,scrollActiveContainer:u})]})};var bb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Lf=bb?m.useLayoutEffect:m.useEffect;function Mn(e){const t=m.useRef(e);return Lf(()=>{t.current=e},[e]),t}function Pa(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 yc=Object.getOwnPropertySymbols,wb=Object.prototype.hasOwnProperty,Cb=Object.prototype.propertyIsEnumerable,_b=(e,t)=>{var n={};for(var r in e)wb.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&yc)for(var r of yc(e))t.indexOf(r)<0&&Cb.call(e,r)&&(n[r]=e[r]);return n},xb=new xi,Sb=m.createContext(xb),kb=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 Lf(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),m.useImperativeHandle(t,()=>o),null})),Fa=[void 0,xr];function Nf(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:a,onDragMove:o,onDragOver:i,onDragEnd:l}=t,c=_b(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=m.useRef(null),{plugins:f,modifiers:p,sensors:d}=c,h=Vt(f,Wn.plugins),g=Vt(d,Wn.sensors),y=Vt(p,Wn.modifiers),v=Mn(s),b=Mn(a),w=Mn(i),C=Mn(o),_=Mn(l),S=Mn(r),k=Ib(()=>{var I;return(I=c.manager)!=null?I:new xi(c)});return m.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:I,trackRendering:E}=u.current,{monitor:A}=k;k.renderer=I;const R=[A.addEventListener("beforedragstart",T=>{const M=v.current;M&&E(()=>M(T,k))}),A.addEventListener("dragstart",T=>{var M;return(M=b.current)==null?void 0:M.call(b,T,k)}),A.addEventListener("dragover",T=>{const M=w.current;M&&E(()=>M(T,k))}),A.addEventListener("dragmove",T=>{const M=C.current;M&&E(()=>M(T,k))}),A.addEventListener("dragend",T=>{const M=_.current;M&&E(()=>M(T,k))}),A.addEventListener("collision",T=>{var M;return(M=S.current)==null?void 0:M.call(S,T,k)})];return()=>R.forEach(T=>T())},[k]),Pa(h,()=>k&&(k.plugins=h),...Fa),Pa(g,()=>k&&(k.sensors=g),...Fa),Pa(y,()=>k&&(k.modifiers=y),...Fa),x.jsxs(Sb.Provider,{value:k,children:[x.jsx(kb,{ref:u,children:n}),n]})}function Ib(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 Ab=Object.create,Zf=Object.defineProperty,Eb=Object.getOwnPropertyDescriptor,Gf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ua=e=>{throw TypeError(e)},Mb=(e,t,n)=>t in e?Zf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tb=e=>{var t;return[,,,Ab((t=e?.[Gf("metadata")])!=null?t:null)]},zf=["class","method","getter","setter","accessor","field","value","get","set"],jf=e=>e!==void 0&&typeof e!="function"?ua("Function expected"):e,Rb=(e,t,n,r,s)=>({kind:zf[e],name:t,metadata:r,addInitializer:a=>n._?ua("Already initialized"):s.push(jf(a||null))}),$b=(e,t)=>Mb(t,Gf("metadata"),e[3]),Db=(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},Hf=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,p=!1,d=2,h=zf[u+5],g=e[d]||(e[d]=[]),y=(s=s.prototype,Eb(s,n)),v=r.length-1;v>=0;v--)l=Rb(u,n,i={},e[3],g),l.static=f,l.private=p,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[v])(y[h],l),i._=1,jf(o)&&(y[h]=o);return y&&Zf(s,n,y),s},Xf=(e,t,n)=>t.has(e)||ua("Cannot "+n),Pb=(e,t,n)=>(Xf(e,t,"read from private field"),t.get(e)),Fb=(e,t,n)=>t.has(e)?ua("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ob=(e,t,n,r)=>(Xf(e,t,"write to private field"),t.set(e,n),n),sr=class ko{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ko(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 ko(t,n)}},Yf,Uf,Io,xs,Xr,Vi=class extends(Io=en,Uf=[Re],Yf=[Re],Io){constructor(e){const t=sr.from(e);super(t,(n,r)=>sr.equals(n,r)),Db(Xr,5,this),Fb(this,xs,0),this.velocity={x:0,y:0}}get delta(){return sr.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=sr.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),a=s-Pb(this,xs),o=i=>Math.round(i/a*100);qt(()=>{Ob(this,xs,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(sr.from(e)),this.velocity={x:0,y:0}}};Xr=Tb(Io);xs=new WeakMap;Hf(Xr,2,"delta",Uf,Vi);Hf(Xr,2,"direction",Yf,Vi);$b(Xr,Vi);var Kf=(e=>(e.Horizontal="x",e.Vertical="y",e))(Kf||{});Object.values(Kf);var Bb=Object.defineProperty,Wb=Object.defineProperties,Vb=Object.getOwnPropertyDescriptors,bc=Object.getOwnPropertySymbols,Lb=Object.prototype.hasOwnProperty,Nb=Object.prototype.propertyIsEnumerable,wc=(e,t,n)=>t in e?Bb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qf=(e,t)=>{for(var n in t||(t={}))Lb.call(t,n)&&wc(e,n,t[n]);if(bc)for(var n of bc(t))Nb.call(t,n)&&wc(e,n,t[n]);return e},qf=(e,t)=>Wb(e,Vb(t)),Ao=class extends Nn{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return qf(Qf({},t),{[n]:r})}};Ao.configure=bn(Ao);var Jf=Ao;Jf.configure({axis:"x",value:0});var eh=Jf.configure({axis:"y",value:0}),Cc=class extends Nn{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 qf(Qf({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/a)*a})}};Cc.configure=bn(Cc);const Li=e=>{let t=!1;const n=e.map(r=>r===ho?(t=!0,ho.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},Zb=D.div`
|
|
1045
1096
|
position: absolute;
|
|
1046
1097
|
top: 0;
|
|
1047
1098
|
left: 0;
|
|
@@ -1051,9 +1102,9 @@ self.onmessage = function(e) {
|
|
|
1051
1102
|
z-index: 100;
|
|
1052
1103
|
pointer-events: none;
|
|
1053
1104
|
will-change: transform;
|
|
1054
|
-
`,
|
|
1105
|
+
`,Gb=({color:e="#ff0000"})=>{const t=m.useRef(null),n=m.useRef(null),{isPlaying:r,currentTimeRef:s}=Hr(),{samplesPerPixel:a,sampleRate:o,progressBarWidth:i}=la();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)`}}),x.jsx(Zb,{ref:t,$color:e,$width:i,"data-playhead":!0})},zb=D.div`
|
|
1055
1106
|
position: relative;
|
|
1056
|
-
`,
|
|
1107
|
+
`,jb=D.div`
|
|
1057
1108
|
position: absolute;
|
|
1058
1109
|
top: ${e=>e.$top}px;
|
|
1059
1110
|
left: 0;
|
|
@@ -1063,7 +1114,7 @@ self.onmessage = function(e) {
|
|
|
1063
1114
|
z-index: 0;
|
|
1064
1115
|
transform: translateZ(0);
|
|
1065
1116
|
backface-visibility: hidden;
|
|
1066
|
-
`,
|
|
1117
|
+
`,Hb=D.div`
|
|
1067
1118
|
position: absolute;
|
|
1068
1119
|
top: ${e=>e.$top}px;
|
|
1069
1120
|
left: 0;
|
|
@@ -1072,8 +1123,8 @@ self.onmessage = function(e) {
|
|
|
1072
1123
|
pointer-events: none;
|
|
1073
1124
|
z-index: 1;
|
|
1074
1125
|
will-change: width;
|
|
1075
|
-
`,
|
|
1126
|
+
`,Xb=D.div`
|
|
1076
1127
|
position: relative;
|
|
1077
1128
|
z-index: 2;
|
|
1078
|
-
`,mb=({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(db,{children:[C.jsx(fb,{$color:h,$height:o,$top:n.index*o,$width:n.length}),C.jsx(hb,{ref:r,$color:f,$height:o,$top:n.index*o}),C.jsx(pb,{children:C.jsx(Yd,{...n,isSelected:!0,transparentBackground:!0})})]})},ic={current:0},gb=({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(mb,{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(gb,{renderPlayhead:s,color:o.playheadColor,samplesPerPixel:x,sampleRate:b}):C.jsx(ub,{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})},vb=({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})]})},yb=({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 bb=()=>{},wb=({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??bb,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(My,{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=xy;exports.AudioPosition=by;exports.AutomaticScrollCheckbox=_y;exports.ClearAllButton=hy;exports.ClipCollisionModifier=Fs;exports.ClipInteractionProvider=wb;exports.ContinuousPlayCheckbox=Cy;exports.DownloadAnnotationsButton=Ey;exports.EditableCheckbox=ky;exports.ExportWavButton=Iy;exports.FastForwardButton=ly;exports.KeyboardShortcuts=yb;exports.LinkEndpointsCheckbox=Sy;exports.LoopButton=dy;exports.MasterVolumeControl=gy;exports.MediaElementAnnotationList=Nf;exports.MediaElementPlaylist=Vf;exports.MediaElementPlaylistProvider=ry;exports.MediaElementWaveform=vb;exports.PauseButton=ay;exports.PlayButton=sy;exports.PlaylistAnnotationList=Sf;exports.PlaylistVisualization=Cf;exports.RewindButton=iy;exports.SelectionTimeInputs=wy;exports.SetLoopRegionButton=fy;exports.SkipBackwardButton=cy;exports.SkipForwardButton=uy;exports.SnapToGridModifier=Er;exports.SpectrogramIntegrationProvider=Py;exports.StopButton=oy;exports.TimeFormatSelect=vy;exports.Waveform=Wy;exports.WaveformPlaylistProvider=ey;exports.ZoomInButton=py;exports.ZoomOutButton=my;exports.createEffectChain=V0;exports.createEffectInstance=kr;exports.effectCategories=O0;exports.effectDefinitions=Wr;exports.getEffectDefinition=Ci;exports.getEffectsByCategory=F0;exports.getShortcutLabel=P0;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=N0;exports.useDynamicTracks=Q0;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=Fy;exports.useTimeFormat=tf;exports.useTrackDynamicEffects=j0;exports.useZoomControls=nf;exports.waveformDataToPeaks=Qd;
|
|
1129
|
+
`,Yb=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=m.useRef(null),s=m.useRef(null),a=zr(),{waveHeight:o}=aa(),{isPlaying:i,currentTimeRef:l}=Hr(),{samplesPerPixel:c,sampleRate:u}=la(),f=a?.waveProgressColor||"rgba(0, 0, 0, 0.1)";m.useEffect(()=>{const g=()=>{if(r.current){const v=(l.current??0)*u,b=e+t;let w=0;if(v<=e)w=0;else if(v>=b)w=n.length;else{const C=v-e;w=Math.floor(C/c)}r.current.style.width=`${w}px`}i&&(s.current=requestAnimationFrame(g))};return i?s.current=requestAnimationFrame(g):g(),()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i,u,c,e,t,n.length,l]),m.useEffect(()=>{if(!i&&r.current){const y=(l.current??0)*u,v=e+t;let b=0;if(y<=e)b=0;else if(y>=v)b=n.length;else{const w=y-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=Jt(d);return x.jsxs(zb,{children:[x.jsx(jb,{$color:h,$height:o,$top:n.index*o,$width:n.length}),x.jsx(Hb,{ref:r,$color:f,$height:o,$top:n.index*o}),x.jsx(Xb,{children:x.jsx(uf,{...n,isSelected:!0,transparentBackground:!0})})]})},_c={current:0},Ub=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:a}=Hr();return e({position:(a.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:a,playbackStartTimeRef:_c,audioStartPositionRef:_c,samplesPerPixel:n,sampleRate:r,controlsOffset:0})},th=({getAnnotationBoxLabel:e,editable:t=!1,linkEndpoints:n=!1,onAnnotationUpdate:r,renderPlayhead:s,showFades:a=!1,className:o})=>{const i=zr(),{isPlaying:l}=Hr(),{annotations:c,activeAnnotationId:u}=ia(),f=m.useContext(ca),{play:p,seekTo:d,setActiveAnnotationId:h,setAnnotations:g,setScrollContainer:y}=Bi(),{duration:v,peaksDataArray:b,sampleRate:w,waveHeight:C,timeScaleHeight:_,samplesPerPixel:S,controls:k,playoutRef:I,barWidth:E,barGap:A,fadeIn:R,fadeOut:T}=la(),[M,$]=m.useState(0),[O,P]=m.useState(0),[V,X]=m.useState(!1),ge=m.useRef(null),re=m.useCallback(K=>{ge.current=K,y(K)},[y]),se=Math.floor(v*w/S),Ie=m.useCallback(async K=>{h(K.id);try{await p(K.start)}catch(le){console.error("waveform-playlist: Failed to start playback for annotation",K.id,le)}},[h,p]),j=m.useCallback(K=>{g(K),r?.(K)},[g,r]),{onDragStart:_e,onDragMove:te,onDragEnd:mt}=Cf({annotations:c,onAnnotationsChange:j,samplesPerPixel:S,sampleRate:w,duration:v,linkEndpoints:n}),q=m.useRef(0),me=m.useCallback(K=>{const le=K.currentTarget.getBoundingClientRect(),fe=(K.clientX-le.left)*S/w;q.current=fe,X(!0),$(fe),P(fe)},[S,w]),Me=m.useCallback(K=>{if(!V)return;const le=K.currentTarget.getBoundingClientRect(),fe=(K.clientX-le.left)*S/w;P(fe)},[V,S,w]),je=m.useCallback(K=>{if(!V)return;if(X(!1),l&&I.current){const Te=Math.max(0,q.current);d(Te),$(Te),P(Te),I.current.stop(),p(Te);return}const le=K.currentTarget.getBoundingClientRect(),fe=(K.clientX-le.left)*S/w,B=Math.min(M,fe),Y=Math.max(M,fe);Math.abs(Y-B)<.1?(d(B),$(B),P(B)):($(B),P(Y))},[V,M,S,w,d,l,I,p]);return b.length===0?x.jsx("div",{className:o,children:"Loading waveform..."}):x.jsx(cf,{children:x.jsx(Gr.Provider,{value:{samplesPerPixel:S,sampleRate:w,zoomLevels:[S],waveHeight:C,timeScaleHeight:_,duration:v*1e3,controls:k,barWidth:E,barGap:A},children:x.jsx(Di,{theme:i,backgroundColor:Jt(i.waveOutlineColor),timescaleBackgroundColor:i.timescaleBackgroundColor,timescaleWidth:se,tracksWidth:se,controlsWidth:k.show?k.width:0,onTracksMouseDown:me,onTracksMouseMove:Me,onTracksMouseUp:je,scrollContainerRef:re,isSelecting:V,timescale:_>0?x.jsx(df,{}):void 0,children:x.jsxs(x.Fragment,{children:[b.map((K,le)=>{const Ze=K.length>0?Math.max(...K.map(fe=>fe.peaks.data.length)):1;return x.jsx(ff,{numChannels:Ze,backgroundColor:Jt(i.waveOutlineColor),offset:0,width:se,hasClipHeaders:!1,trackId:`media-element-track-${le}`,isSelected:!0,children:K.map((fe,B)=>{const Y=fe.peaks,Te=Y.length;return x.jsxs(_o,{clipId:fe.clipId,trackIndex:le,clipIndex:B,trackName:fe.trackName,startSample:fe.startSample,durationSamples:fe.durationSamples,samplesPerPixel:S,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${le}`,children:[Y.data.map((Ve,ae)=>x.jsx(Yb,{index:ae,data:Ve,bits:Y.bits,length:Te,clipStartSample:fe.startSample,clipDurationSamples:fe.durationSamples},`${le}-${B}-${ae}`)),a&&R&&R.duration>0&&x.jsx(Zs,{left:0,width:Math.floor(R.duration*w/S),type:"fadeIn",curveType:R.type}),a&&T&&T.duration>0&&x.jsx(Zs,{left:Te-Math.floor(T.duration*w/S),width:Math.floor(T.duration*w/S),type:"fadeOut",curveType:T.type})]},`${le}-${B}`)})},le)}),c.length>0&&f&&x.jsx(Nf,{onDragStart:_e,onDragMove:te,onDragEnd:mt,modifiers:t?[eh]:[],plugins:Li,children:x.jsx(f.AnnotationBoxesWrapper,{height:30,width:se,children:c.map((K,le)=>{const Ze=K.start*w/S,fe=K.end*w/S,B=e?e(K,le):K.id;return x.jsx(f.AnnotationBox,{annotationId:K.id,annotationIndex:le,startPosition:Ze,endPosition:fe,label:B,color:"#ff9800",isActive:K.id===u,onClick:()=>Ie(K),editable:t},K.id)})})}),M!==O&&x.jsx(sf,{startPosition:Math.min(M,O)*w/S,endPosition:Math.max(M,O)*w/S,color:i.selectionColor}),s?x.jsx(Ub,{renderPlayhead:s,color:i.playheadColor,samplesPerPixel:S,sampleRate:w}):x.jsx(Gb,{color:i.playheadColor})]})})})})},nh=({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}=ia(),f=Sn(),{setAnnotations:p}=Bi(),d=a??{linkEndpoints:!1,continuousPlay:u},h=m.useCallback(y=>{p(y),n?.(y)},[p,n]),{AnnotationText:g}=f;return x.jsx(g,{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})},Kb=({annotationTextHeight:e,getAnnotationBoxLabel:t,renderAnnotationItem:n,editable:r=!1,linkEndpoints:s=!1,onAnnotationUpdate:a,scrollActivePosition:o="center",scrollActiveContainer:i="nearest",renderPlayhead:l,showFades:c=!1,className:u})=>{const{annotations:f}=ia();return x.jsxs(x.Fragment,{children:[x.jsx(th,{getAnnotationBoxLabel:t,editable:r,linkEndpoints:s,onAnnotationUpdate:a,renderPlayhead:l,showFades:c,className:u}),f.length>0&&x.jsx(nh,{height:e,renderAnnotationItem:n,onAnnotationUpdate:a,editable:r,annotationListConfig:{linkEndpoints:s,continuousPlay:!1},scrollActivePosition:o,scrollActiveContainer:i})]})},Qb=({playback:e=!1,clipSplitting:t=!1,annotations:n=!1,additionalShortcuts:r=[]})=>{const{tracks:s,samplesPerPixel:a,sampleRate:o,playoutRef:i,duration:l}=it(),{annotations:c,linkEndpoints:u,activeAnnotationId:f,continuousPlay:p}=ot(),{setAnnotations:d,setActiveAnnotationId:h,scrollContainerRef:g,play:y}=ke(),{splitClipAtPlayhead:v}=xf({tracks:s,sampleRate:o,samplesPerPixel:a,engineRef:i}),b=[];return t&&b.push({key:"s",action:v,description:"Split clip at playhead",preventDefault:!0}),r.length>0&&b.push(...r),Sf({enabled:e||b.length>0,...e?{additionalShortcuts:b}:{shortcuts:b}}),kf({annotations:c,activeAnnotationId:f,onAnnotationsChange:d,onActiveAnnotationChange:h,duration:l,linkEndpoints:u,continuousPlay:p,scrollContainerRef:g,samplesPerPixel:a,sampleRate:o,onPlay:y,enabled:n&&c.length>0}),null},Hs=class Hs extends Nn{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((g,y)=>g.startSample-y.startSample),d=p.findIndex(g=>g.id===u.id);return{x:Tc(u,f,p,d)/l,y:0}}};Hs.configure=bn(Hs);let js=Hs;const Xs=class Xs extends Nn{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:y}=this.options;if(a!==void 0){const w=a+n.x*o;return{x:(Math.round(w/y)*y-a)/o,y:0}}const v=n.x*o;return{x:Math.round(v/y)*y/o,y:0}}const{snapTo:i,bpm:l,timeSignature:c,sampleRate:u}=this.options;if(i==="off")return n;const f=i==="bar"?Mo(c):Ys(c);if(a!==void 0){const y=a+n.x*o,v=Ba(y,l,u),b=Wa(v,f);return{x:(Bn(b,l,u)-a)/o,y:0}}const p=n.x*o,d=Ba(p,l,u),h=Wa(d,f);return{x:Bn(h,l,u)/o,y:0}}};Xs.configure=bn(Xs);let $r=Xs;const qb=()=>{},Jb=({snap:e=!1,touchOptimized:t=!1,children:n})=>{const{tracks:r,samplesPerPixel:s,sampleRate:a,playoutRef:o,isDraggingRef:i,onTracksChange:l}=it(),{setSelectedTrackId:c}=ke(),u=of(),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:C,timeSignature:_,snapTo:S}=u,k=S==="bar"?Mo(_):Ys(_);return I=>{const E=Ba(I,C,a),A=Wa(E,k);return Bn(A,C,a)}}if(p){const C=Math.round(xo(s).smallStep/1e3*a);return _=>Math.round(_/C)*C}},[f,p,u,a,s]),h=_f({touchOptimized:t}),{onDragStart:g,onDragMove:y,onDragEnd:v}=wf({tracks:r,onTracksChange:l??qb,samplesPerPixel:s,sampleRate:a,engineRef:o,isDraggingRef:i,snapSamplePosition:d}),b=m.useCallback(C=>{const _=C.operation?.source?.data?.trackIndex;_!==void 0&&r[_]&&c(r[_].id),g(C)},[g,r,c]),w=m.useMemo(()=>{const C=[eh];return f&&u?C.push($r.configure({mode:"beats",snapTo:u.snapTo,bpm:u.bpm,timeSignature:u.timeSignature,samplesPerPixel:s,sampleRate:a})):p&&C.push($r.configure({mode:"timescale",gridSamples:Math.round(xo(s).smallStep/1e3*a),samplesPerPixel:s})),C.push(js.configure({tracks:r,samplesPerPixel:s})),C},[f,p,u,r,s,a]);return x.jsx(ib,{value:!0,children:x.jsx(Nf,{sensors:h,onDragStart:b,onDragMove:y,onDragEnd:v,modifiers:w,plugins:Li,children:n})})};exports.Tone=Sc;exports.AnnotationIntegrationProvider=tb;exports.AudioPosition=qy;exports.AutomaticScrollCheckbox=eb;exports.ClearAllButton=Hy;exports.ClipCollisionModifier=js;exports.ClipInteractionProvider=Jb;exports.ContinuousPlayCheckbox=nb;exports.DownloadAnnotationsButton=ab;exports.EditableCheckbox=sb;exports.ExportWavButton=ob;exports.FastForwardButton=Ny;exports.KeyboardShortcuts=Qb;exports.LinkEndpointsCheckbox=rb;exports.LoopButton=zy;exports.MasterVolumeControl=Uy;exports.MediaElementAnnotationList=nh;exports.MediaElementPlaylist=th;exports.MediaElementPlaylistProvider=Oy;exports.MediaElementWaveform=Kb;exports.PauseButton=Wy;exports.PlayButton=By;exports.PlaylistAnnotationList=Vf;exports.PlaylistVisualization=Wf;exports.RewindButton=Ly;exports.SelectionTimeInputs=Jy;exports.SetLoopRegionButton=jy;exports.SkipBackwardButton=Zy;exports.SkipForwardButton=Gy;exports.SnapToGridModifier=$r;exports.SpectrogramIntegrationProvider=hb;exports.StopButton=Vy;exports.TimeFormatSelect=Ky;exports.Waveform=yb;exports.WaveformPlaylistProvider=Dy;exports.ZoomInButton=Xy;exports.ZoomOutButton=Yy;exports.createEffectChain=gy;exports.createEffectInstance=Rr;exports.effectCategories=fy;exports.effectDefinitions=jr;exports.getEffectDefinition=Oi;exports.getEffectsByCategory=dy;exports.getShortcutLabel=uy;exports.getWaveformDataMetadata=ey;exports.loadPeaksFromWaveformData=J0;exports.loadWaveformData=Fi;exports.noDropAnimationPlugins=Li;exports.useAnnotationDragHandlers=Cf;exports.useAnnotationIntegration=Sn;exports.useAnnotationKeyboardControls=kf;exports.useAudioTracks=oy;exports.useClipDragHandlers=wf;exports.useClipInteractionEnabled=Bf;exports.useClipSplitting=xf;exports.useDragSensors=_f;exports.useDynamicEffects=vy;exports.useDynamicTracks=My;exports.useExportWav=If;exports.useKeyboardShortcuts=zs;exports.useMasterAnalyser=ay;exports.useMasterVolume=bf;exports.useMediaElementAnimation=Hr;exports.useMediaElementControls=Bi;exports.useMediaElementData=la;exports.useMediaElementState=ia;exports.useOutputMeter=$y;exports.usePlaybackAnimation=at;exports.usePlaybackShortcuts=Sf;exports.usePlaylistControls=ke;exports.usePlaylistData=it;exports.usePlaylistState=ot;exports.useSpectrogramIntegration=pb;exports.useTimeFormat=vf;exports.useTrackDynamicEffects=yy;exports.useZoomControls=yf;exports.waveformDataToPeaks=mf;
|
|
1079
1130
|
//# sourceMappingURL=index.js.map
|