@waveform-playlist/browser 9.4.1 → 9.5.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 +4 -2
- package/dist/index.js +92 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3502 -3463
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
"use strict";var Yf=Object.create;var al=Object.defineProperty;var Kf=Object.getOwnPropertyDescriptor;var qf=Object.getOwnPropertyNames;var Jf=Object.getPrototypeOf,Qf=Object.prototype.hasOwnProperty;var eh=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of qf(t))!Qf.call(e,s)&&s!==n&&al(e,s,{get:()=>t[s],enumerable:!(r=Kf(t,s))||r.enumerable});return e};var th=(e,t,n)=>(n=e!=null?Yf(Jf(e)):{},eh(t||!e||!e.__esModule?al(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("tone"),C=require("react/jsx-runtime"),p=require("react"),F=require("styled-components"),go=require("react-dom");function ic(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 lc=ic(L),D=ic(p);var ca={exports:{}},ol;function nh(){return ol||(ol=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 v=0;v<g.length;v++){var y=g[v];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(g){return g.__proto__||Object.getPrototypeOf(g)})(h)}function f(h,g){return(f=Object.setPrototypeOf||function(v,y){return v.__proto__=y,v})(h,g)}function m(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}var d=(function(h){function g(b){var w,_,x,S,k,E;return(function(I,T){if(!(I instanceof T))throw new TypeError("Cannot call a class as a function")})(this,g),_=this,w=!(x=u(g).call(this,b.id,b.length,b.buffer,b.subChunks))||l(x)!=="object"&&typeof x!="function"?m(_):x,S=m(m(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 g(I)})),w}var v,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)})(g,h),v=g,(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(v.prototype,y),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(m,d){if(m.id!==d)throw new a.ParseError("Unexpected chunk ID","'".concat(d,"'"),"'".concat(m.id,"'"));if(m.length%i.SF_GENERATOR_SIZE)throw new a.ParseError("Invalid size for the '".concat(d,"' sub-chunk"));return m.iterate((function(h){var 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,v,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=[],T=void 0,R=k;R<E;R++){var A=u(R,h,g),M=f(R,h,v),$=M[i.GeneratorType.KeyRange]&&M[i.GeneratorType.KeyRange].range,P=M[b];if(P){var O=y[P.value];O&&I.push({keyRange:$,modulators:A,generators:M,reference:O})}else R-k==0&&(T={keyRange:$,modulators:A,generators:M})}w.push({header:x,globalZone:T,zones:I})}return w},u=function(d,h,g){var v=h[d],y=h[d+1],b=v.modulatorIndex,w=y?y.modulatorIndex:h.length;return m(b,w,g)},f=function(d,h,g){var v=h[d],y=h[d+1],b=v.generatorIndex,w=y?y.generatorIndex:h.length;return m(b,w,g)},m=function(d,h,g){for(var v={},y=d;y<h;y++){var b=g[y];b&&(v[b.id]=b)}return v}},"./src/constants.ts":function(n,r,s){s.r(r),s.d(r,"SF_VERSION_LENGTH",(function(){return a})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return o})),s.d(r,"SF_BAG_SIZE",(function(){return i})),s.d(r,"SF_MODULATOR_SIZE",(function(){return l})),s.d(r,"SF_GENERATOR_SIZE",(function(){return c})),s.d(r,"SF_INSTRUMENT_HEADER_SIZE",(function(){return u})),s.d(r,"SF_SAMPLE_HEADER_SIZE",(function(){return f})),s.d(r,"DEFAULT_SAMPLE_RATE",(function(){return m}));var a=4,o=38,i=4,l=10,c=4,u=22,f=46,m=22050},"./src/index.ts":function(n,r,s){s.r(r);var a=s("./src/types/index.ts");for(var o in a)["default"].indexOf(o)<0&&(function(u){s.d(r,u,(function(){return a[u]}))})(o);var i=s("./src/chunk.ts");s.d(r,"SF2Chunk",(function(){return i.SF2Chunk}));var l=s("./src/constants.ts");s.d(r,"SF_VERSION_LENGTH",(function(){return l.SF_VERSION_LENGTH})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return l.SF_PRESET_HEADER_SIZE})),s.d(r,"SF_BAG_SIZE",(function(){return l.SF_BAG_SIZE})),s.d(r,"SF_MODULATOR_SIZE",(function(){return l.SF_MODULATOR_SIZE})),s.d(r,"SF_GENERATOR_SIZE",(function(){return l.SF_GENERATOR_SIZE})),s.d(r,"SF_INSTRUMENT_HEADER_SIZE",(function(){return l.SF_INSTRUMENT_HEADER_SIZE})),s.d(r,"SF_SAMPLE_HEADER_SIZE",(function(){return l.SF_SAMPLE_HEADER_SIZE})),s.d(r,"DEFAULT_SAMPLE_RATE",(function(){return l.DEFAULT_SAMPLE_RATE}));var c=s("./src/soundFont2.ts");s.d(r,"SoundFont2",(function(){return c.SoundFont2}))},"./src/riff/chunkIterator.ts":function(n,r,s){s.r(r),s.d(r,"ChunkIterator",(function(){return c}));var a=s("./src/utils/index.ts");function o(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function i(u,f){for(var m=0;m<f.length;m++){var d=f[m];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,m){return f in u?Object.defineProperty(u,f,{value:m,enumerable:!0,configurable:!0,writable:!0}):u[f]=m,u}var c=(function(){function u(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;o(this,u),l(this,"target",[]),l(this,"chunk",void 0),l(this,"position",0),this.chunk=d,this.position=h}var f,m;return f=u,(m=[{key:"iterate",value:function(d){for(;this.position<this.chunk.length;){var h=d(this);h&&this.target.push(h)}}},{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,h=Object(a.getStringFromBuffer)(this.getBuffer(this.position,d));return this.position+=d,h}},{key:"getInt16",value:function(){return this.chunk.buffer[this.position++]|this.chunk.buffer[this.position++]<<8}},{key:"getInt16BE",value:function(){return this.getInt16()<<16>>16}},{key:"getUInt32",value:function(){return(this.chunk.buffer[this.position++]|this.chunk.buffer[this.position++]<<8|this.chunk.buffer[this.position++]<<16|this.chunk.buffer[this.position++]<<24)>>>0}},{key:"getByte",value:function(){return this.chunk.buffer[this.position++]}},{key:"getChar",value:function(){return this.chunk.buffer[this.position++]<<24>>24}},{key:"skip",value:function(d){this.position+=d}},{key:"getBuffer",value:function(d,h){return this.chunk.buffer.subarray(d,d+h)}},{key:"currentPosition",get:function(){return this.position}}])&&i(f.prototype,m),u})()},"./src/riff/index.ts":function(n,r,s){s.r(r);var a=s("./src/riff/chunkIterator.ts");s.d(r,"ChunkIterator",(function(){return a.ChunkIterator}));var o=s("./src/riff/parseError.ts");s.d(r,"ParseError",(function(){return o.ParseError}));var i=s("./src/riff/parser.ts");s.d(r,"parseBuffer",(function(){return i.parseBuffer})),s.d(r,"getChunk",(function(){return i.getChunk})),s.d(r,"getChunkLength",(function(){return i.getChunkLength})),s.d(r,"getSubChunks",(function(){return i.getSubChunks})),s.d(r,"getChunkId",(function(){return i.getChunkId}));var l=s("./src/riff/riffChunk.ts");s.d(r,"RIFFChunk",(function(){return l.RIFFChunk}))},"./src/riff/parseError.ts":function(n,r,s){function a(d){return(a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h})(d)}function o(d,h){return!h||a(h)!=="object"&&typeof h!="function"?(function(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||(v=g,Function.toString.call(v).indexOf("[native code]")===-1))return g;var v;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,y)}function y(){return c(g,arguments,f(this).constructor)}return y.prototype=Object.create(g.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),u(y,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(v,y,b){var w=[null];w.push.apply(w,y);var _=new(Function.bind.apply(v,w));return b&&u(_,b.prototype),_}).apply(null,arguments)}function u(d,h){return(u=Object.setPrototypeOf||function(g,v){return g.__proto__=v,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 m}));var m=(function(d){function h(g,v,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(g).concat(v&&y?", expected ".concat(v,", received ").concat(y):"")))}return(function(g,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function");g.prototype=Object.create(v&&v.prototype,{constructor:{value:g,writable:!0,configurable:!0}}),v&&u(g,v)})(h,d),h})(i(Error))},"./src/riff/parser.ts":function(n,r,s){s.r(r),s.d(r,"parseBuffer",(function(){return l})),s.d(r,"getChunk",(function(){return c})),s.d(r,"getChunkLength",(function(){return u})),s.d(r,"getSubChunks",(function(){return f})),s.d(r,"getChunkId",(function(){return m}));var a=s("./src/riff/parseError.ts"),o=s("./src/utils/buffer.ts"),i=s("./src/riff/riffChunk.ts"),l=function(d){var h=m(d);if(h!=="RIFF")throw new a.ParseError("Invalid file format","RIFF",h);var g=m(d,8);if(g!=="sfbk")throw new a.ParseError("Invalid signature","sfbk",g);var v=d.subarray(8),y=f(v.subarray(4));return new i.RIFFChunk(h,v.length,v,y)},c=function(d,h){var g=m(d,h),v=u(d,h+4),y=[];return g!=="RIFF"&&g!=="LIST"||(y=f(d.subarray(h+12))),new i.RIFFChunk(g,v,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=[],g=0;g<=d.length-8;){var v=c(d,g);h.push(v),g=(g+=8+v.length)%2?g+1:g}return h},m=function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return Object(o.getStringFromBuffer)(d.subarray(h,h+4))}},"./src/riff/riffChunk.ts":function(n,r,s){s.r(r),s.d(r,"RIFFChunk",(function(){return c}));var a=s("./src/riff/chunkIterator.ts"),o=s("./src/utils/index.ts");function i(u,f){for(var m=0;m<f.length;m++){var d=f[m];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,m){return f in u?Object.defineProperty(u,f,{value:m,enumerable:!0,configurable:!0,writable:!0}):u[f]=m,u}var c=(function(){function u(d,h,g,v){(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=g,this.subChunks=v}var f,m;return f=u,(m=[{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,h=arguments.length>1?arguments[1]:void 0;return Object(o.getStringFromBuffer)(this.getBuffer(d,h||this.length-d))}},{key:"getInt16",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d++]|this.buffer[d]<<8}},{key:"getUInt32",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return(this.buffer[d++]|this.buffer[d++]<<8|this.buffer[d++]<<16|this.buffer[d]<<24)>>>0}},{key:"getByte",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d]}},{key:"getChar",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d]<<24>>24}},{key:"iterator",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new a.ChunkIterator(this,d)}},{key:"iterate",value:function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,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,m),u})()},"./src/soundFont2.ts":function(n,r,s){s.r(r),s.d(r,"SoundFont2",(function(){return h}));var a=s("./src/types/index.ts"),o=s("./src/chunk.ts"),i=s("./src/riff/index.ts"),l=s("./src/chunks/index.ts"),c=s("./src/utils/index.ts");function u(g){for(var v=1;v<arguments.length;v++){var y=arguments[v]!=null?arguments[v]:{},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(g,w,y[w])}))}return g}function f(g,v){for(var y=0;y<v.length;y++){var b=v[y];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(g,b.key,b)}}function m(g,v,y){return v&&f(g.prototype,v),y&&f(g,y),g}function d(g,v,y){return v in g?Object.defineProperty(g,v,{value:y,enumerable:!0,configurable:!0,writable:!0}):g[v]=y,g}var h=(function(){function g(v){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),!(v instanceof o.SF2Chunk)){var y=Object(i.parseBuffer)(v);v=new o.SF2Chunk(y)}if(v.subChunks.length!==3)throw new i.ParseError("Invalid sfbk structure","3 chunks","".concat(v.subChunks.length," chunks"));this.chunk=v,this.metaData=v.subChunks[0].getMetaData(),this.sampleData=v.subChunks[1].getSampleData(),this.presetData=v.subChunks[2].getPresetData(),this.samples=this.getSamples(),this.instruments=this.getInstruments(),this.presets=this.getPresets(),this.banks=this.getBanks()}return m(g,null,[{key:"from",value:function(v){return new g(v)}}]),m(g,[{key:"getKeyData",value:function(v){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 T=!0,R=!1,A=void 0;try{for(var M,$=I[Symbol.iterator]();!(T=(M=$.next()).done);T=!0){var P=M.value,O=P.instrument,Z=O.zones.filter((function(ne){return y.isKeyInRange(ne,_)}));if(Z.length>0){var G=!0,Y=!1,ee=void 0;try{for(var X,K=Z[Symbol.iterator]();!(G=(X=K.next()).done);G=!0){var le=X.value,te=le.sample,fe=u({},P.generators,le.generators),de=u({},P.modulators,le.modulators);return{keyNumber:_,preset:E,instrument:O,sample:te,generators:fe,modulators:de}}}catch(ne){Y=!0,ee=ne}finally{try{G||K.return==null||K.return()}finally{if(Y)throw ee}}}}}catch(ne){R=!0,A=ne}finally{try{T||$.return==null||$.return()}finally{if(R)throw A}}}}}return null}))(v,b,w)}},{key:"isKeyInRange",value:function(v,y){return v.keyRange===void 0||v.keyRange.lo<=y&&v.keyRange.hi>=y}},{key:"getBanks",value:function(){return this.presets.reduce((function(v,y){var b=y.header.bank;return v[b]||(v[b]={presets:[]}),v[b].presets[y.header.preset]=y,v}),[])}},{key:"getPresets",value:function(){var v=this.presetData,y=v.presetHeaders,b=v.presetZones,w=v.presetGenerators,_=v.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 v=this.presetData,y=v.instrumentHeaders,b=v.instrumentZones,w=v.instrumentModulators,_=v.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 v=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(v.sampleData.subarray(2*y.start,2*y.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(v){s.d(r,v,(function(){return a[v]}))})(o);var i=s("./src/types/generator.ts");s.d(r,"GeneratorType",(function(){return i.GeneratorType})),s.d(r,"DEFAULT_GENERATOR_VALUES",(function(){return i.DEFAULT_GENERATOR_VALUES}));var l=s("./src/types/instrument.ts");for(var o in l)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return l[y]}))})(o);var c=s("./src/types/key.ts");for(var o in c)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return c[y]}))})(o);var u=s("./src/types/metaData.ts");for(var o in u)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return u[y]}))})(o);var f=s("./src/types/modulator.ts");s.d(r,"ControllerType",(function(){return f.ControllerType})),s.d(r,"ControllerPolarity",(function(){return f.ControllerPolarity})),s.d(r,"ControllerDirection",(function(){return f.ControllerDirection})),s.d(r,"ControllerPalette",(function(){return f.ControllerPalette})),s.d(r,"Controller",(function(){return f.Controller})),s.d(r,"TransformType",(function(){return f.TransformType})),s.d(r,"DEFAULT_INSTRUMENT_MODULATORS",(function(){return f.DEFAULT_INSTRUMENT_MODULATORS}));var m=s("./src/types/preset.ts");for(var o in m)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return m[y]}))})(o);var d=s("./src/types/presetData.ts");for(var o in d)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return d[y]}))})(o);var h=s("./src/types/sample.ts");s.d(r,"SampleType",(function(){return h.SampleType}));var 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(y){s.d(r,y,(function(){return g[y]}))})(o)},"./src/types/instrument.ts":function(n,r){},"./src/types/key.ts":function(n,r){},"./src/types/metaData.ts":function(n,r){},"./src/types/modulator.ts":function(n,r,s){s.r(r),s.d(r,"ControllerType",(function(){return a})),s.d(r,"ControllerPolarity",(function(){return o})),s.d(r,"ControllerDirection",(function(){return i})),s.d(r,"ControllerPalette",(function(){return l})),s.d(r,"Controller",(function(){return c})),s.d(r,"TransformType",(function(){return u})),s.d(r,"DEFAULT_INSTRUMENT_MODULATORS",(function(){return m}));var a,o,i,l,c,u,f=s("./src/types/generator.ts");(function(d){d[d.Linear=0]="Linear",d[d.Concave=1]="Concave",d[d.Convex=2]="Convex",d[d.Switch=3]="Switch"})(a||(a={})),(function(d){d[d.Unipolar=0]="Unipolar",d[d.Bipolar=1]="Bipolar"})(o||(o={})),(function(d){d[d.Increasing=0]="Increasing",d[d.Decreasing=1]="Decreasing"})(i||(i={})),(function(d){d[d.GeneralController=0]="GeneralController",d[d.MidiController=1]="MidiController"})(l||(l={})),(function(d){d[d.NoController=0]="NoController",d[d.NoteOnVelocity=2]="NoteOnVelocity",d[d.NoteOnKeyNumber=3]="NoteOnKeyNumber",d[d.PolyPressure=10]="PolyPressure",d[d.ChannelPressure=13]="ChannelPressure",d[d.PitchWheel=14]="PitchWheel",d[d.PitchWheelSensitivity=16]="PitchWheelSensitivity",d[d.Link=127]="Link"})(c||(c={})),(function(d){d[d.Linear=0]="Linear",d[d.Absolute=2]="Absolute"})(u||(u={}));var m=[{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialFilterFc,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:-2400,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.ChannelPressure},value:50,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:1},value:50,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:7},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:l.MidiController,index:10},value:1e3,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:11},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ReverbEffectsSend,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:91},value:200,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ChorusEffectsSend,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:93},value:200,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.CoarseTune,source:{type:a.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheel},value:12700,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheelSensitivity},transform:u.Linear}]},"./src/types/preset.ts":function(n,r){},"./src/types/presetData.ts":function(n,r){},"./src/types/sample.ts":function(n,r,s){var a;s.r(r),s.d(r,"SampleType",(function(){return a})),(function(o){o[o.EOS=0]="EOS",o[o.Mono=1]="Mono",o[o.Right=2]="Right",o[o.Left=4]="Left",o[o.Linked=8]="Linked",o[o.RomMono=32769]="RomMono",o[o.RomRight=32770]="RomRight",o[o.RomLeft=32772]="RomLeft",o[o.RomLinked=32776]="RomLinked"})(a||(a={}))},"./src/types/zone.ts":function(n,r){},"./src/utils/buffer.ts":function(n,r,s){s.r(r),s.d(r,"getStringFromBuffer",(function(){return a}));var a=function(o){var i=new TextDecoder("utf8").decode(o),l=i.indexOf("\0");return(l===-1?i:i.slice(0,l)).trim()}},"./src/utils/index.ts":function(n,r,s){s.r(r);var a=s("./src/utils/buffer.ts");s.d(r,"getStringFromBuffer",(function(){return a.getStringFromBuffer}));var o=s("./src/utils/memoize.ts");s.d(r,"memoize",(function(){return o.memoize}))},"./src/utils/memoize.ts":function(n,r,s){s.r(r),s.d(r,"memoize",(function(){return a}));var a=function(o){var i={};return function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var f=JSON.stringify(c);if(f in i)return i[f];var m=o.apply(void 0,c);return i[f]=m,m}}}})}))})(ca)),ca.exports}nh();var Pe=1e3;function Ea(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate,h=t?.length??e.sourceDurationSamples??(c&&d?Math.ceil(c.duration*d):void 0);if(d===void 0)throw new Error("createClip: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");if(h===void 0)throw new Error("createClip: sourceDurationSamples is required when audioBuffer is not provided (can use waveformData.duration)");t&&c&&t.sampleRate!==c.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${c.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const g=e.durationSamples??h;return{id:dc(),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:m}}function cc(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate;if(d===void 0)throw new Error("createClipFromSeconds: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");const h=t?.duration??e.sourceDuration??c?.duration;if(h===void 0)throw new Error("createClipFromSeconds: sourceDuration is required when audioBuffer is not provided (can use waveformData.duration)");t&&c&&t.sampleRate!==c.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${c.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const g=e.duration??h;return Ea({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:m})}function uc(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:dc(),name:t,clips:n,muted:r,soloed:s,volume:a,pan:o,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}}function dc(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function il(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function rh(e,t){return Math.floor(e/t)}function sh(e,t,n){return Math.ceil(e*n/t)}var Nn=192;function Vs(e,t=Nn){const[,n]=e;return t*(4/n)}function vo(e,t=Nn){const[n]=e;return n*Vs(e,t)}function Rn(e,t,n,r=Nn){return Math.round(e*60*n/(t*r))}function Ia(e,t,n,r=Nn){return Math.round(e*r*t/(60*n))}function Ma(e,t){return Math.round(e/t)*t}function ah(e,t,n=Nn){const r=vo(t,n),s=Vs(t,n),a=Math.floor(e/r)+1,o=Math.floor(e%r/s)+1;return o===1?`${a}`:`${a}.${o}`}function qr(e){return e.startSample/e.sampleRate}function ll(e){return(e.startSample+e.durationSamples)/e.sampleRate}function cl(e){return e.offsetSamples/e.sampleRate}function ul(e){return e.durationSamples/e.sampleRate}function fc(e,t,n){return Math.floor((e+t)/n)-Math.floor(e/n)}var dl=!1;function vr(e){const t=e._param;return!t&&!dl&&(dl=!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 fl(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 oh(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 ih(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 lh(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 hc(e,t,n){switch(e){case"linear":return fl(t,n);case"exponential":return oh(t,n);case"sCurve":return ih(t,n);case"logarithmic":return lh(t,n);default:return fl(t,n)}}function hl(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=hc(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 pl(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=hc(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 ch=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)hl(a,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,c=o/i,u=r.gain*c;hl(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;pl(a,c,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const c=-l,u=r.fadeOut.duration-c,f=c/r.fadeOut.duration,m=r.gain*(1-f);pl(a,t,u,r.fadeOut.type||"linear",m,0)}}}prepareFades(e,t){this.scheduledClips.forEach(n=>{const r=this.track.startTime+n.clipInfo.startTime,s=r+n.clipInfo.duration;if(!(t>=s))if(t>=r){const a=t-r+n.clipInfo.offset;this.scheduleFades(n,e,a)}else{const a=r-t;this.scheduleFades(n,e+a,n.clipInfo.offset)}})}cancelFades(){this.scheduledClips.forEach(({fadeGainNode:e,clipInfo:t})=>{const n=e.gain;n.cancelScheduledValues(0),n.setValueAtTime(t.gain,0)})}gainToDb(e){return 20*Math.log10(e)}setVolume(e){this.track.gain=e,this.volumeNode.volume.value=this.gainToDb(e)}setPan(e){this.track.stereoPan=e,this.panNode.pan.value=e}setMute(e){this.track.muted=e;const t=e?0:1;vr(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 uh(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 dh=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(uh(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;vr(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}},pc=class Aa{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){Aa._missingSampleWarned||(console.warn(`[waveform-playlist] SoundFont sample not found for MIDI note ${t} (bank ${o}, preset ${i}). Subsequent missing samples will be silent.`),Aa._missingSampleWarned=!0);return}const c=L.getContext().rawContext,u=c.createBufferSource();u.buffer=l.buffer,u.playbackRate.value=l.playbackRate,(l.loopMode===1||l.loopMode===3)&&(u.loop=!0,u.loopStart=l.loopStart,u.loopEnd=l.loopEnd);const f=l.buffer.duration/l.playbackRate,m=l.loopMode===0?Math.max(n,f):n,d=s*s,h=c.createGain(),{attackVolEnv:g,holdVolEnv:v,decayVolEnv:y,sustainVolEnv:b,releaseVolEnv:w}=l,_=d*b;h.gain.setValueAtTime(0,r),h.gain.linearRampToValueAtTime(d,r+g),v>.001&&h.gain.setValueAtTime(d,r+g+v);const x=r+g+v;h.gain.linearRampToValueAtTime(_,x+y),h.gain.setValueAtTime(_,r+m),h.gain.linearRampToValueAtTime(0,r+m+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+m+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;vr(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}};pc._missingSampleWarned=!1;var fh=pc,hh=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 ch(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 dh(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 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}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}},Jr=null;function ph(){return Jr||(Jr=new L.Context,L.setContext(Jr)),Jr}function mh(){return ph().rawContext}function gh(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 hh({effects:e?.effects}),i&&t.init().catch(f=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",f),i=!1});for(const f of c){const m=f.clips.filter(h=>h.audioBuffer&&!h.midiNotes),d=f.clips.filter(h=>h.midiNotes&&h.midiNotes.length>0);if(m.length>0){const h=Math.min(...m.map(qr)),g=Math.max(...m.map(ll)),v={id:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:g},y=m.map(b=>({buffer:b.audioBuffer,startTime:qr(b)-h,duration:ul(b),offset:cl(b),fadeIn:b.fadeIn,fadeOut:b.fadeOut,gain:b.gain}));t.addTrack({clips:y,track:v,effects:f.effects})}if(d.length>0){const h=Math.min(...d.map(qr)),g=Math.max(...d.map(ll)),y={id:m.length>0?`${f.id}:midi`:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:g},b=d.map(w=>({notes:w.midiNotes,startTime:qr(w)-h,duration:ul(w),offset:cl(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 mc(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 gc(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 vh(e,t){return Math.floor(e/t)*t}function yh(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=Ea({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=Ea({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 vc(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 ua(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 bh(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 ml(e,t){return Math.max(0,Math.min(e,t))}var wh=44100,_h=1024,xh=[256,512,1024,2048,4096,8192],gl=.1,Ch=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??wh,this._zoomLevels=[...e.zoomLevels??xh],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??_h,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:ua(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=il(r.clips),i=o.findIndex(c=>c.id===t),l=mc(a,n,o,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=c.clips.map((f,m)=>m===s?{...f,startSample:Math.floor(f.startSample+l)}:f);return{...c,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}splitClip(e,t,n){const r=this._tracks.find(c=>c.id===e);if(!r){console.warn(`[waveform-playlist/engine] splitClip: track "${e}" not found`);return}const s=r.clips.findIndex(c=>c.id===t);if(s===-1){console.warn(`[waveform-playlist/engine] splitClip: clip "${t}" not found in track "${e}"`);return}const a=r.clips[s],o=Math.floor(gl*this._sampleRate);if(!vc(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}=yh(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=il(s.clips),l=i.findIndex(f=>f.id===t),c=Math.floor(gl*this._sampleRate),u=gc(o,r,n,i,l,c);u!==0&&(this._tracks=this._tracks.map(f=>{if(f.id!==e)return f;const m=f.clips.map((d,h)=>h!==a?d:n==="left"?{...d,startSample:d.startSample+u,offsetSamples:d.offsetSamples+u,durationSamples:d.durationSamples-u}:{...d,durationSamples:d.durationSamples+u});return{...f,clips:m}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}async init(){this._adapter&&await this._adapter.init()}play(e,t){const n=this._currentTime,r=this._playStartPosition;if(e!==void 0){const s=ua(this._tracks);this._currentTime=ml(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=ua(this._tracks);this._currentTime=ml(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=bh(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)}},Sh=Symbol.for("preact-signals");function Ns(){if(Ut>1)Ut--;else{for(var e,t=!1;dr!==void 0;){var n=dr;for(dr=void 0,Ta++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&bc(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(Ta=0,Ut--,t)throw e}}function Xt(e){if(Ut>0)return e();Ut++;try{return e()}finally{Ns()}}var ye=void 0;function _e(e){var t=ye;ye=void 0;try{return e()}finally{ye=t}}var dr=void 0,Ut=0,Ta=0,ws=0;function yc(e){if(ye!==void 0){var t=e.n;if(t===void 0||t.t!==ye)return t={i:0,S:e,p:ye.s,n:void 0,t:ye,e:void 0,x:void 0,r:t},ye.s!==void 0&&(ye.s.n=t),ye.s=t,e.n=t,32&ye.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ye.s,t.n=void 0,ye.s.n=t,ye.s=t),t}}function at(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}at.prototype.brand=Sh;at.prototype.h=function(){return!0};at.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:_e(function(){var r;(r=t.W)==null||r.call(t)}))};at.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&_e(function(){var s;(s=t.Z)==null||s.call(t)}))}};at.prototype.subscribe=function(e){var t=this;return Ct(function(){var n=t.value,r=ye;ye=void 0;try{e(n)}finally{ye=r}},{name:"sub"})};at.prototype.valueOf=function(){return this.value};at.prototype.toString=function(){return this.value+""};at.prototype.toJSON=function(){return this.value};at.prototype.peek=function(){var e=ye;ye=void 0;try{return this.value}finally{ye=e}};Object.defineProperty(at.prototype,"value",{get:function(){var e=yc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ta>100)throw new Error("Cycle detected");this.v=e,this.i++,ws++,Ut++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Ns()}}}});function Mr(e,t){return new at(e,t)}function bc(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 wc(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 _c(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function pn(e,t){at.call(this,void 0),this.x=e,this.s=void 0,this.g=ws-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}pn.prototype=new at;pn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ws))return!0;if(this.g=ws,this.f|=1,this.i>0&&!bc(this))return this.f&=-2,!0;var e=ye;try{wc(this),ye=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ye=e,_c(this),this.f&=-2,!0};pn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}at.prototype.S.call(this,e)};pn.prototype.U=function(e){if(this.t!==void 0&&(at.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};pn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(pn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=yc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function vl(e,t){return new pn(e,t)}function xc(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Ut++;var n=ye;ye=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,yo(e),r}finally{ye=n,Ns()}}}function yo(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,xc(e)}function kh(e){if(ye!==this)throw new Error("Out-of-order effect");_c(this),ye=e,this.f&=-2,8&this.f&&yo(this),Ns()}function zn(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}zn.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};zn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,xc(this),wc(this),Ut++;var e=ye;return ye=this,kh.bind(this,e)};zn.prototype.N=function(){2&this.f||(this.f|=2,this.o=dr,dr=this)};zn.prototype.d=function(){this.f|=8,1&this.f||yo(this)};zn.prototype.dispose=function(){this.d()};function Ct(e,t){var n=new zn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Eh=Object.create,bo=Object.defineProperty,Ih=Object.defineProperties,Mh=Object.getOwnPropertyDescriptor,Ah=Object.getOwnPropertyDescriptors,yl=Object.getOwnPropertySymbols,Th=Object.prototype.hasOwnProperty,$h=Object.prototype.propertyIsEnumerable,Rh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),jn=e=>{throw TypeError(e)},$a=(e,t,n)=>t in e?bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Dh=(e,t)=>{for(var n in t||(t={}))Th.call(t,n)&&$a(e,n,t[n]);if(yl)for(var n of yl(t))$h.call(t,n)&&$a(e,n,t[n]);return e},Ph=(e,t)=>Ih(e,Ah(t)),bl=(e,t)=>bo(e,"name",{value:t,configurable:!0}),Fh=e=>{var t;return[,,,Eh((t=void 0)!=null?t:null)]},Cc=["class","method","getter","setter","accessor","field","value","get","set"],er=e=>e!==void 0&&typeof e!="function"?jn("Function expected"):e,Oh=(e,t,n,r,s)=>({kind:Cc[e],name:t,metadata:r,addInitializer:a=>n._?jn("Already initialized"):s.push(er(a||null))}),Sc=(e,t)=>$a(t,Rh("metadata"),e[3]),nn=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},Zn=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,g=Cc[f+5],v=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&Mh(f<4?s:{get[n](){return un(this,a)},set[n](_){return Zt(this,a,_)}},n));f?d&&f<4&&bl(a,(f>2?"set ":f>1?"get ":"")+n):bl(s,n);for(var w=r.length-1;w>=0;w--)c=Oh(f,n,l={},e[3],y),f&&(c.static=m,c.private=d,u=c.access={has:d?_=>Lh(s,_):_=>n in _},f^3&&(u.get=d?_=>(f^1?un:Bh)(_,s,f^4?a:b.get):_=>_[n]),f>2&&(u.set=d?(_,x)=>Zt(_,s,x,f^4?a:b.set):(_,x)=>_[n]=x)),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?er(i)&&(f>4?v.unshift(i):f?d?a=i:b[g]=i:s=i):typeof i!="object"||i===null?jn("Object expected"):(er(o=i.get)&&(b.get=o),er(o=i.set)&&(b.set=o),er(o=i.init)&&v.unshift(o));return f||Sc(e,s),b&&bo(s,n,b),d?f^4?a:b:s},wo=(e,t,n)=>t.has(e)||jn("Cannot "+n),Lh=(e,t)=>Object(t)!==t?jn('Cannot use the "in" operator on this value'):e.has(t),un=(e,t,n)=>(wo(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),Zt=(e,t,n,r)=>(wo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Bh=(e,t,n)=>(wo(e,t,"access private method"),n);function _s(e,t){if(t){let n;return vl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return vl(e)}function yr(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)=>!yr(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=>!yr(e[a],t[a]))}return!1}function ge({get:e},t){return{init(n){return Mr(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function $e(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=_s(e.bind(this)),n.set(this,r)),r.value}}function da(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,Ph(Dh({},s),{enumerable:e}))})}}function Ar(...e){const t=e.map(n=>Ct(n));return()=>t.forEach(n=>n())}var kc,Ec,Ic,Mc,Ac,Tc,nt,_o,fa,Ra,Da,Ke,xo,ha,$c,Pa,Co,pa,Fa,Oa;Tc=[ge],Ac=[ge],Mc=[ge],Ic=[da()],Ec=[da()],kc=[da()];var Kt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,nn(nt,5,this),Qr(this,Ke),Qr(this,_o,nn(nt,8,this)),nn(nt,11,this),Qr(this,xo,nn(nt,12,this)),nn(nt,15,this),Qr(this,Co,nn(nt,16,this)),nn(nt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return un(this,Ke,Fa)}get initial(){return un(this,Ke,Ra)}get previous(){return un(this,Ke,$c)}set current(e){const t=_e(()=>un(this,Ke,Fa));e&&t&&this.equals(t,e)||Xt(()=>{un(this,Ke,Ra)||Zt(this,Ke,e,Da),Zt(this,Ke,t,Pa),Zt(this,Ke,e,Oa)})}reset(e=this.defaultValue){Xt(()=>{Zt(this,Ke,void 0,Pa),Zt(this,Ke,e,Da),Zt(this,Ke,e,Oa)})}};nt=Fh();_o=new WeakMap;Ke=new WeakSet;xo=new WeakMap;Co=new WeakMap;fa=Zn(nt,20,"#initial",Tc,Ke,_o),Ra=fa.get,Da=fa.set;ha=Zn(nt,20,"#previous",Ac,Ke,xo),$c=ha.get,Pa=ha.set;pa=Zn(nt,20,"#current",Mc,Ke,Co),Fa=pa.get,Oa=pa.set;Zn(nt,2,"current",Ic,Kt);Zn(nt,2,"initial",Ec,Kt);Zn(nt,2,"previous",kc,Kt);Sc(nt,Kt);function ma(e){return _e(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Wh=Object.create,Rc=Object.defineProperty,Vh=Object.getOwnPropertyDescriptor,wl=Object.getOwnPropertySymbols,Nh=Object.prototype.hasOwnProperty,zh=Object.prototype.propertyIsEnumerable,Dc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),zs=e=>{throw TypeError(e)},_l=Math.pow,La=(e,t,n)=>t in e?Rc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jh=(e,t)=>{for(var n in t||(t={}))Nh.call(t,n)&&La(e,n,t[n]);if(wl)for(var n of wl(t))zh.call(t,n)&&La(e,n,t[n]);return e},Zh=e=>{var t;return[,,,Wh((t=e?.[Dc("metadata")])!=null?t:null)]},Pc=["class","method","getter","setter","accessor","field","value","get","set"],Fc=e=>e!==void 0&&typeof e!="function"?zs("Function expected"):e,Hh=(e,t,n,r,s)=>({kind:Pc[e],name:t,metadata:r,addInitializer:a=>n._?zs("Already initialized"):s.push(Fc(a||null))}),Gh=(e,t)=>La(t,Dc("metadata"),e[3]),Uh=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},Oc=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=Pc[u+5],g=e[d]||(e[d]=[]),v=(s=s.prototype,Vh(s,n)),y=r.length-1;y>=0;y--)l=Hh(u,n,i={},e[3],g),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(v[h],l),i._=1,Fc(o)&&(v[h]=o);return v&&Rc(s,n,v),s},Lc=(e,t,n)=>t.has(e)||zs("Cannot "+n),Xh=(e,t,n)=>(Lc(e,t,"read from private field"),t.get(e)),Yh=(e,t,n)=>t.has(e)?zs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Kh=(e,t,n,r)=>(Lc(e,t,"write to private field"),t.set(e,n),n),Tt=class Ba{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ba(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 Ba(t,n)}},Tr=class sn{constructor(t,n,r,s){this.left=t,this.top=n,this.width=r,this.height=s,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:s,width:a,height:o,scale:i}=this,l=new sn(s+t,r+n,a,o);return l.scale=jh({},i),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:a,bottom:o}=this;return{width:t,height:n,left:r,top:s,right:a,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new Tt((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof sn))return!1;const{left:n,top:r,width:s,height:a}=this;return n===t.left&&r===t.top&&s===t.width&&a===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:a}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=a}intersectionArea(t){return t instanceof sn?qh(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:s}){return new sn(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(a,o)=>{const i=r[o],l=o==="x"?a.left:a.top,c=o==="x"?a.width:a.height;return i=="start"?l:i=="end"?l+c:l+c/2};return Tt.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return sn.from(t).intersectionRatio(sn.from(n))}};function qh(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 Bc,Wc,Wa,is,$r,js=class extends(Wa=Kt,Wc=[$e],Bc=[$e],Wa){constructor(t){const n=Tt.from(t);super(n,(r,s)=>Tt.equals(r,s)),Uh($r,5,this),Yh(this,is,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-Xh(this,is),i=l=>Math.round(l/o*100);Xt(()=>{Kh(this,is,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}}};$r=Zh(Wa);is=new WeakMap;Oc($r,2,"delta",Wc,js);Oc($r,2,"direction",Bc,js);Gh($r,js);function Va({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(_l(r,2)+_l(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 Vc=(e=>(e.Horizontal="x",e.Vertical="y",e))(Vc||{}),Nc=Object.values(Vc),Jh=Object.create,So=Object.defineProperty,Qh=Object.defineProperties,ep=Object.getOwnPropertyDescriptor,tp=Object.getOwnPropertyDescriptors,xs=Object.getOwnPropertySymbols,zc=Object.prototype.hasOwnProperty,jc=Object.prototype.propertyIsEnumerable,Zc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Hn=e=>{throw TypeError(e)},Na=(e,t,n)=>t in e?So(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hc=(e,t)=>{for(var n in t||(t={}))zc.call(t,n)&&Na(e,n,t[n]);if(xs)for(var n of xs(t))jc.call(t,n)&&Na(e,n,t[n]);return e},Gc=(e,t)=>Qh(e,tp(t)),xl=(e,t)=>So(e,"name",{value:t,configurable:!0}),Uc=(e,t)=>{var n={};for(var r in e)zc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&xs)for(var r of xs(e))t.indexOf(r)<0&&jc.call(e,r)&&(n[r]=e[r]);return n},Gn=e=>{var t;return[,,,Jh((t=e?.[Zc("metadata")])!=null?t:null)]},Xc=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?Hn("Function expected"):e,np=(e,t,n,r,s)=>({kind:Xc[e],name:t,metadata:r,addInitializer:a=>n._?Hn("Already initialized"):s.push(tr(a||null))}),mn=(e,t)=>Na(t,Zc("metadata"),e[3]),se=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},he=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,g=Xc[f+5],v=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&ep(f<4?s:{get[n](){return Ze(this,a)},set[n](_){return wt(this,a,_)}},n));f?d&&f<4&&xl(a,(f>2?"set ":f>1?"get ":"")+n):xl(s,n);for(var w=r.length-1;w>=0;w--)c=np(f,n,l={},e[3],y),f&&(c.static=m,c.private=d,u=c.access={has:d?_=>rp(s,_):_=>n in _},f^3&&(u.get=d?_=>(f^1?Ze:sp)(_,s,f^4?a:b.get):_=>_[n]),f>2&&(u.set=d?(_,x)=>wt(_,s,x,f^4?a:b.set):(_,x)=>_[n]=x)),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?tr(i)&&(f>4?v.unshift(i):f?d?a=i:b[g]=i:s=i):typeof i!="object"||i===null?Hn("Object expected"):(tr(o=i.get)&&(b.get=o),tr(o=i.set)&&(b.set=o),tr(o=i.init)&&v.unshift(o));return f||mn(e,s),b&&So(s,n,b),d?f^4?a:b:s},ko=(e,t,n)=>t.has(e)||Hn("Cannot "+n),rp=(e,t)=>Object(t)!==t?Hn('Cannot use the "in" operator on this value'):e.has(t),Ze=(e,t,n)=>(ko(e,t,"read from private field"),n?n.call(e):t.get(e)),we=(e,t,n)=>t.has(e)?Hn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),wt=(e,t,n,r)=>(ko(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),sp=(e,t,n)=>(ko(e,t,"access private method"),n);function Yc(e,t){return{plugin:e,options:t}}function gn(e){return t=>Yc(e,t)}function Eo(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Kc,br,Io,ls;Kc=[ge];var dt=class{constructor(e,t){this.manager=e,this.options=t,we(this,Io,se(br,8,this,!1)),se(br,11,this),we(this,ls,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return _e(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=Ct(e.bind(this));return Ze(this,ls).add(t),t}destroy(){Ze(this,ls).forEach(e=>e())}static configure(e){return Yc(this,e)}};br=Gn(null);Io=new WeakMap;ls=new WeakMap;he(br,4,"disabled",Kc,dt,Io);mn(br,dt);var Rr=class extends dt{},cs,ga=class{constructor(e){this.manager=e,this.instances=new Map,we(this,cs,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(Eo).reduceRight((r,s)=>r.some(({plugin:a})=>a===s.plugin)?r:[s,...r],[]),n=t.map(({plugin:r})=>r);for(const r of Ze(this,cs))if(!n.includes(r)){if(r.prototype instanceof Rr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);wt(this,cs,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()}};cs=new WeakMap;function ap(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var es=[],En,In,op=class extends dt{constructor(e){super(e),we(this,En),we(this,In),this.computeCollisions=this.computeCollisions.bind(this),wt(this,In,Mr(es)),this.destroy=Ar(()=>{const t=this.computeCollisions(),n=_e(()=>this.manager.dragOperation.position.current);if(t!==es){const r=Ze(this,En);if(wt(this,En,n),r&&n.x==r.x&&n.y==r.y)return}else wt(this,En,void 0);Ze(this,In).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){_e(()=>{e?Ze(this,In).value=this.computeCollisions():wt(this,En,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:a,status:o}=r;if(!o.initialized||!a)return es;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=_e(()=>u({droppable:c,dragOperation:r}));f&&(c.collisionPriority!=null&&(f.priority=c.collisionPriority),i.push(f))}return l.length===0?es:(i.sort(ap),i)}get collisions(){return Ze(this,In).value}};En=new WeakMap;In=new WeakMap;var ip=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)}},lp=class extends ip{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function us(e,t=!0){let n=!1;return Gc(Hc({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var cp=class extends Rr{constructor(e){super(e);const t=(r,s)=>r.map(({id:a})=>a).join("")===s.map(({id:a})=>a).join("");let n=[];this.destroy=Ar(()=>{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=us({collisions:a});if(s.dispatch("collision",o),o.defaultPrevented||t(a,n))return;n=a;const[i]=a;_e(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},Mo=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(Mo||{}),Ao=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Ao||{}),qc,Jc,Qc,eu,tu,nu,ru,xt,To;ru=[ge],nu=[$e],tu=[$e],eu=[$e],Qc=[$e],Jc=[$e],qc=[$e];var Wt=class{constructor(){se(xt,5,this),we(this,To,se(xt,8,this,"idle")),se(xt,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};xt=Gn(null);To=new WeakMap;he(xt,4,"value",ru,Wt,To);he(xt,2,"current",nu,Wt);he(xt,2,"idle",tu,Wt);he(xt,2,"initializing",eu,Wt);he(xt,2,"initialized",Qc,Wt);he(xt,2,"dragging",Jc,Wt);he(xt,2,"dropped",qc,Wt);mn(xt,Wt);var up=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return _e(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=us({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return _e(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const r=new AbortController,{event:s,coordinates:a}=e;Xt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(a)});const o=us({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:i}=t;i.current==="initializing"&&(t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1}))}),r)})}move(e){return _e(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:a}=r;if(!s.dragging||!a||a.signal.aborted)return;const o=us({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var i,l,c,u,f;if(o.defaultPrevented)return;const m=(f=e.to)!=null?f:{x:r.position.current.x+((l=(i=e.by)==null?void 0:i.x)!=null?l:0),y:r.position.current.y+((u=(c=e.by)==null?void 0:c.y)!=null?u:0)};r.position.current=m})})}stop(e={}){return _e(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let a;const o=()=>{const l={resume:()=>{},abort:()=>{}};return a=new Promise((c,u)=>{l.resume=c,l.abort=u}),l};s.abort();const i=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=_e(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),c=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:u}=r,f=Ct(()=>{u?.status==="idle"&&(f(),c())})}else this.manager.renderer.rendering.then(c)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),a?a.then(i).catch(()=>r.reset()):i()})}},su,au,ou,iu,ut,$o,Ro,Do,Po;iu=[ge],ou=[ge],au=[ge],su=[ge];var qt=class{constructor(e,t){we(this,$o,se(ut,8,this)),se(ut,11,this),we(this,Ro,se(ut,12,this)),se(ut,15,this),we(this,Do,se(ut,16,this)),se(ut,19,this),we(this,Po,se(ut,20,this)),se(ut,23,this);const{effects:n,id:r,data:s={},disabled:a=!1,register:o=!0}=e;let i=r;this.manager=t,this.id=r,this.data=s,this.disabled=a,this.effects=()=>{var l;return[()=>{const{id:c,manager:u}=this;if(c!==i)return u?.registry.register(this),()=>u?.registry.unregister(this)},...(l=n?.())!=null?l:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),t&&o&&queueMicrotask(this.register)}register(){var e;return(e=this.manager)==null?void 0:e.registry.register(this)}unregister(){var e;(e=this.manager)==null||e.registry.unregister(this)}destroy(){var e;(e=this.manager)==null||e.registry.unregister(this)}};ut=Gn(null);$o=new WeakMap;Ro=new WeakMap;Do=new WeakMap;Po=new WeakMap;he(ut,4,"manager",iu,qt,$o);he(ut,4,"id",ou,qt,Ro);he(ut,4,"data",au,qt,Do);he(ut,4,"disabled",su,qt,Po);mn(ut,qt);var Cl=class{constructor(){this.map=Mr(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,t);if(r===t)return s;if(r){const i=this.cleanupFunctions.get(r);i?.(),this.cleanupFunctions.delete(r)}const a=new Map(n);a.set(e,t),this.map.value=a;const o=Ar(...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}},lu,cu,uu,du,fu,hu,za,rt,Fo,Oo,Lo,$t=class extends(za=qt,hu=[ge],fu=[ge],du=[ge],uu=[$e],cu=[$e],lu=[$e],za){constructor(t,n){var r=t,{modifiers:s,type:a,sensors:o}=r,i=Uc(r,["modifiers","type","sensors"]);super(i,n),se(rt,5,this),we(this,Fo,se(rt,8,this)),se(rt,11,this),we(this,Oo,se(rt,12,this)),se(rt,15,this),we(this,Lo,se(rt,16,this,this.isDragSource?"dragging":"idle")),se(rt,19,this),this.type=a,this.sensors=o,this.modifiers=s,this.alignment=i.alignment}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};rt=Gn(za);Fo=new WeakMap;Oo=new WeakMap;Lo=new WeakMap;he(rt,4,"type",hu,$t,Fo);he(rt,4,"modifiers",fu,$t,Oo);he(rt,4,"status",du,$t,Lo);he(rt,2,"isDropping",uu,$t);he(rt,2,"isDragging",cu,$t);he(rt,2,"isDragSource",lu,$t);mn(rt,$t);var pu,mu,gu,vu,yu,bu,ja,Ve,Bo,Wo,Vo,No,zo,Rt=class extends(ja=qt,bu=[ge],yu=[ge],vu=[ge],gu=[ge],mu=[ge],pu=[$e],ja){constructor(t,n){var r=t,{accept:s,collisionDetector:a,collisionPriority:o,type:i}=r,l=Uc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),se(Ve,5,this),we(this,Bo,se(Ve,8,this)),se(Ve,11,this),we(this,Wo,se(Ve,12,this)),se(Ve,15,this),we(this,Vo,se(Ve,16,this)),se(Ve,19,this),we(this,No,se(Ve,20,this)),se(Ve,23,this),we(this,zo,se(Ve,24,this)),se(Ve,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}};Ve=Gn(ja);Bo=new WeakMap;Wo=new WeakMap;Vo=new WeakMap;No=new WeakMap;zo=new WeakMap;he(Ve,4,"accept",bu,Rt,Bo);he(Ve,4,"type",yu,Rt,Wo);he(Ve,4,"collisionDetector",vu,Rt,Vo);he(Ve,4,"collisionPriority",gu,Rt,No);he(Ve,4,"shape",mu,Rt,zo);he(Ve,2,"isDropTarget",pu,Rt);mn(Ve,Rt);var Fn=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},dp=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)}},ds,wu=class{constructor(e){this.options=e,we(this,ds)}set controller(e){wt(this,ds,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ze(this,ds))==null||t.activate(e)}};ds=new WeakMap;var On=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},fp=class{constructor(e){this.draggables=new Cl,this.droppables=new Cl,this.plugins=new ga(e),this.sensors=new ga(e),this.modifiers=new ga(e)}register(e,t){if(e instanceof $t)return this.draggables.register(e.id,e);if(e instanceof Rt)return this.droppables.register(e.id,e);if(e.prototype instanceof On)return this.modifiers.register(e,t);if(e.prototype instanceof Fn)return this.sensors.register(e,t);if(e.prototype instanceof dt)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof qt)return e instanceof $t?this.draggables.unregister(e.id,e):e instanceof Rt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof On)return this.modifiers.unregister(e);if(e.prototype instanceof Fn)return this.sensors.unregister(e);if(e.prototype instanceof dt)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},_u,xu,Cu,Su,ku,Eu,Iu,Mu,Au,nr,fs,Mn,Re,jo,Zo,Ho,Go,Uo,rr;Au=[$e],Mu=[ge],Iu=[ge],Eu=[ge],ku=[ge],Su=[ge],Cu=[$e],xu=[$e],_u=[$e];var It=class{constructor(e){se(Re,5,this),we(this,nr),we(this,fs),we(this,Mn,new Kt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Wt,we(this,jo,se(Re,8,this,!1)),se(Re,11,this),we(this,Zo,se(Re,12,this,null)),se(Re,15,this),we(this,Ho,se(Re,16,this,null)),se(Re,19,this),we(this,Go,se(Re,20,this,null)),se(Re,23,this),we(this,Uo,se(Re,24,this,[])),se(Re,27,this),this.position=new js({x:0,y:0}),we(this,rr,{x:0,y:0}),wt(this,nr,e)}get shape(){const{current:e,initial:t,previous:n}=Ze(this,Mn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ze(this,Mn).current=e:Ze(this,Mn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ze(this,nr).registry.draggables.get(t);return n&&wt(this,fs,n),(e=n??Ze(this,fs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ze(this,nr).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(Gc(Hc({},this.snapshot()),{transform:n}));return wt(this,rr,n),n}snapshot(){return _e(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ze(this,rr),shape:this.shape?ma(this.shape):null,position:ma(this.position),status:ma(this.status),canceled:this.canceled}))}reset(){Xt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ze(this,Mn).reset(),this.position.reset({x:0,y:0}),wt(this,rr,{x:0,y:0}),this.modifiers=[]})}};Re=Gn(null);nr=new WeakMap;fs=new WeakMap;Mn=new WeakMap;jo=new WeakMap;Zo=new WeakMap;Ho=new WeakMap;Go=new WeakMap;Uo=new WeakMap;rr=new WeakMap;he(Re,2,"shape",Au,It);he(Re,4,"canceled",Mu,It,jo);he(Re,4,"activatorEvent",Iu,It,Zo);he(Re,4,"sourceIdentifier",Eu,It,Ho);he(Re,4,"targetIdentifier",ku,It,Go);he(Re,4,"modifiers",Su,It,Uo);he(Re,2,"source",Cu,It);he(Re,2,"target",xu,It);he(Re,2,"transform",_u,It);mn(Re,It);var hp={get rendering(){return Promise.resolve()}};function Ot(e,t){return typeof e=="function"?e(t):e??t}var pp=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(m=>m.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=Ot(r.plugins,[]),a=Ot(r.sensors,[]),o=Ot(r.modifiers,[]),i=(n=r.renderer)!=null?n:hp,l=new lp(this),c=new fp(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new up(this),this.dragOperation=new It(this),this.collisionObserver=new op(this),this.plugins=[cp,...s],this.modifiers=o,this.sensors=a;const{destroy:u}=this,f=Ar(()=>{var m,d,h;const g=_e(()=>this.dragOperation.modifiers),v=this.modifiers;for(const y of g)v.includes(y)||y.destroy();this.dragOperation.modifiers=(h=(d=(m=this.dragOperation.source)==null?void 0:m.modifiers)==null?void 0:d.map(y=>{const{plugin:b,options:w}=Eo(y);return new b(this,w)}))!=null?h:v});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}},Tu=e=>{throw TypeError(e)},Xo=(e,t,n)=>t.has(e)||Tu("Cannot "+n),ie=(e,t,n)=>(Xo(e,t,"read from private field"),t.get(e)),ct=(e,t,n)=>t.has(e)?Tu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),mt=(e,t,n,r)=>(Xo(e,t,"write to private field"),t.set(e,n),n),$u=(e,t,n)=>(Xo(e,t,"access private method"),n);function Zs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function mp(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=(Zs(s)?s.getKeyframes():[]).filter(t);if(o.length>0)return[o[o.length-1],r]}return null}function Hs(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 Yo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Dr(e){return"nodeType"in e}function St(e){var t,n,r;return e?Yo(e)?e:Dr(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 Ko(e){const{Document:t}=St(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function dn(e){return!e||Yo(e)?!1:e instanceof St(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Ru(e){return e instanceof St(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function vn(e){return e?Yo(e)?e.document:Dr(e)?Ko(e)?e:dn(e)||Ru(e)?e.ownerDocument:document:document:document}function gp(e){var t,n,r,s;const{documentElement:a}=vn(e),o=St(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 vp(e,t){if(yp(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function yp(e){return e.tagName==="DETAILS"}function Cs(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(!vp(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 m=u.visualViewport,d=(s=m?.offsetTop)!=null?s:0,h=(a=m?.offsetLeft)!=null?a:0,g=(o=m?.width)!=null?o:u.innerWidth,v=(i=m?.height)!=null?i:u.innerHeight,y=n*v,b=n*g;return l={top:Math.max(l.top,d-y),right:Math.min(l.right,h+g+b),bottom:Math.min(l.bottom,d+v+y),left:Math.max(l.left,h-b),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function Ln(e){return{x:e.clientX,y:e.clientY}}var Du=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 qo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Pu(){var e,t;const n=qo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Jo(e){return!e||!Dr(e)?!1:e instanceof St(e).ShadowRoot}function Ss(e){if(e&&Dr(e)){let t=e.getRootNode();if(Jo(t))return t;if(t instanceof Document)return t}return vn(e)}function Fu(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function bp(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((a,o)=>{const i=r[o];if(Sl(a)&&Sl(i)&&(a.type!=="file"&&(a.value=i.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),kl(a)&&kl(i)&&i.width>0&&i.height>0){const l=a.getContext("2d");l?.drawImage(i,0,0)}}),n}function Sl(e){return"value"in e}function kl(e){return e.tagName==="CANVAS"}function Ou(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(wp(r)){const{contentDocument:s}=r;if(s){const{left:a,top:o}=r.getBoundingClientRect();return Ou(s,{x:t-a,y:n-o})}}return r}function wp(e){return e?.tagName==="IFRAME"}var El=new WeakMap;function _p(e){return!!e.closest(`
|
|
1
|
+
"use strict";var Kf=Object.create;var ol=Object.defineProperty;var qf=Object.getOwnPropertyDescriptor;var Jf=Object.getOwnPropertyNames;var Qf=Object.getPrototypeOf,eh=Object.prototype.hasOwnProperty;var th=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Jf(t))!eh.call(e,s)&&s!==n&&ol(e,s,{get:()=>t[s],enumerable:!(r=qf(t,s))||r.enumerable});return e};var nh=(e,t,n)=>(n=e!=null?Kf(Qf(e)):{},th(t||!e||!e.__esModule?ol(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("tone"),C=require("react/jsx-runtime"),p=require("react"),F=require("styled-components"),yo=require("react-dom");function lc(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const cc=lc(L),P=lc(p);var ua={exports:{}},il;function rh(){return il||(il=1,(function(e,t){(function(n,r){e.exports=r()})(window,(function(){return(function(n){var r={};function s(a){if(r[a])return r[a].exports;var o=r[a]={i:a,l:!1,exports:{}};return n[a].call(o.exports,o,o.exports,s),o.l=!0,o.exports}return s.m=n,s.c=r,s.d=function(a,o,i){s.o(a,o)||Object.defineProperty(a,o,{enumerable:!0,get:i})},s.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},s.t=function(a,o){if(1&o&&(a=s(a)),8&o||4&o&&typeof a=="object"&&a&&a.__esModule)return a;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:a}),2&o&&typeof a!="string")for(var l in a)s.d(i,l,(function(c){return a[c]}).bind(null,l));return i},s.n=function(a){var o=a&&a.__esModule?function(){return a.default}:function(){return a};return s.d(o,"a",o),o},s.o=function(a,o){return Object.prototype.hasOwnProperty.call(a,o)},s.p="",s(s.s="./src/index.ts")})({"./src/chunk.ts":function(n,r,s){s.r(r),s.d(r,"SF2Chunk",(function(){return d}));var a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=s("./src/chunks/index.ts");function l(h){return(l=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(v){return typeof v}:function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v})(h)}function c(h,v){for(var g=0;g<v.length;g++){var y=v[g];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(h,y.key,y)}}function u(h){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)})(h)}function f(h,v){return(f=Object.setPrototypeOf||function(g,y){return g.__proto__=y,g})(h,v)}function m(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}var d=(function(h){function v(b){var _,w,x,S,k,E;return(function(M,T){if(!(M instanceof T))throw new TypeError("Cannot call a class as a function")})(this,v),w=this,_=!(x=u(v).call(this,b.id,b.length,b.buffer,b.subChunks))||l(x)!=="object"&&typeof x!="function"?m(w):x,S=m(m(_)),E=void 0,(k="subChunks")in S?Object.defineProperty(S,k,{value:E,enumerable:!0,configurable:!0,writable:!0}):S[k]=E,_.subChunks=b.subChunks.map((function(M){return new v(M)})),_}var g,y;return(function(b,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(_&&_.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),_&&f(b,_)})(v,h),g=v,(y=[{key:"getMetaData",value:function(){if(this.id!=="LIST")throw new a.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks.reduce((function(_,w){if(w.id==="ifil"||w.id==="iver"){if(w.length!==o.SF_VERSION_LENGTH)throw new a.ParseError("Invalid size for the '".concat(w.id,"' sub-chunk"));_[w.id]="".concat(w.getInt16(),".").concat(w.getInt16(2))}else _[w.id]=w.getString();return _}),{});if(!b.ifil)throw new a.ParseError("Missing required 'ifil' sub-chunk");if(!b.INAM)throw new a.ParseError("Missing required 'INAM' sub-chunk");return{version:b.ifil,soundEngine:b.isng||"EMU8000",name:b.INAM,rom:b.irom,romVersion:b.iver,creationDate:b.ICRD,author:b.IENG,product:b.IPRD,copyright:b.ICOP,comments:b.ICMT,createdBy:b.ISFT}}},{key:"getSampleData",value:function(){if(this.id!=="LIST")throw new a.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));var b=this.subChunks[0];if(b.id!=="smpl")throw new a.ParseError("Invalid chunk signature","'smpl'","'".concat(b.id,"'"));return b.buffer}},{key:"getPresetData",value:function(){if(this.id!=="LIST")throw new a.ParseError("Unexpected chunk ID","'LIST'","'".concat(this.id,"'"));return{presetHeaders:Object(i.getPresetHeaders)(this.subChunks[0]),presetZones:Object(i.getZones)(this.subChunks[1],"pbag"),presetModulators:Object(i.getModulators)(this.subChunks[2],"pmod"),presetGenerators:Object(i.getGenerators)(this.subChunks[3],"pgen"),instrumentHeaders:Object(i.getInstrumentHeaders)(this.subChunks[4]),instrumentZones:Object(i.getZones)(this.subChunks[5],"ibag"),instrumentModulators:Object(i.getModulators)(this.subChunks[6],"imod"),instrumentGenerators:Object(i.getGenerators)(this.subChunks[7],"igen"),sampleHeaders:Object(i.getSampleHeaders)(this.subChunks[8])}}}])&&c(g.prototype,y),v})(a.RIFFChunk)},"./src/chunks/generators.ts":function(n,r,s){s.r(r),s.d(r,"getGenerators",(function(){return f}));var a=s("./src/riff/index.ts"),o=s("./src/types/index.ts"),i=s("./src/constants.ts"),l=[o.GeneratorType.StartAddrsOffset,o.GeneratorType.EndAddrsOffset,o.GeneratorType.StartLoopAddrsOffset,o.GeneratorType.EndLoopAddrsOffset,o.GeneratorType.StartAddrsCoarseOffset,o.GeneratorType.EndAddrsCoarseOffset,o.GeneratorType.StartLoopAddrsCoarseOffset,o.GeneratorType.KeyNum,o.GeneratorType.Velocity,o.GeneratorType.EndLoopAddrsCoarseOffset,o.GeneratorType.SampleModes,o.GeneratorType.ExclusiveClass,o.GeneratorType.OverridingRootKey],c=[o.GeneratorType.Unused1,o.GeneratorType.Unused2,o.GeneratorType.Unused3,o.GeneratorType.Unused4,o.GeneratorType.Reserved1,o.GeneratorType.Reserved2,o.GeneratorType.Reserved3],u=[o.GeneratorType.KeyRange,o.GeneratorType.VelRange],f=function(m,d){if(m.id!==d)throw new a.ParseError("Unexpected chunk ID","'".concat(d,"'"),"'".concat(m.id,"'"));if(m.length%i.SF_GENERATOR_SIZE)throw new a.ParseError("Invalid size for the '".concat(d,"' sub-chunk"));return m.iterate((function(h){var v=h.getInt16();return o.GeneratorType[v]?d==="pgen"&&l.includes(v)||d==="igen"&&c.includes(v)?null:u.includes(v)?{id:v,range:{lo:h.getByte(),hi:h.getByte()}}:{id:v,value:h.getInt16BE()}:null}))}},"./src/chunks/index.ts":function(n,r,s){s.r(r);var a=s("./src/chunks/instruments/index.ts");s.d(r,"getInstrumentHeaders",(function(){return a.getInstrumentHeaders}));var o=s("./src/chunks/presets/index.ts");s.d(r,"getPresetHeaders",(function(){return o.getPresetHeaders}));var i=s("./src/chunks/samples/index.ts");s.d(r,"getSampleHeaders",(function(){return i.getSampleHeaders}));var l=s("./src/chunks/generators.ts");s.d(r,"getGenerators",(function(){return l.getGenerators}));var c=s("./src/chunks/modulators.ts");s.d(r,"getModulators",(function(){return c.getModulators}));var u=s("./src/chunks/zones.ts");s.d(r,"getZones",(function(){return u.getZones})),s.d(r,"getItemsInZone",(function(){return u.getItemsInZone}))},"./src/chunks/instruments/headers.ts":function(n,r,s){s.r(r),s.d(r,"getInstrumentHeaders",(function(){return i}));var a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="inst")throw new a.ParseError("Unexpected chunk ID","'inst'","'".concat(l.id,"'"));if(l.length%o.SF_INSTRUMENT_HEADER_SIZE)throw new a.ParseError("Invalid size for the 'inst' sub-chunk");return l.iterate((function(c){return{name:c.getString(),bagIndex:c.getInt16()}}))}},"./src/chunks/instruments/index.ts":function(n,r,s){s.r(r);var a=s("./src/chunks/instruments/headers.ts");s.d(r,"getInstrumentHeaders",(function(){return a.getInstrumentHeaders}))},"./src/chunks/modulators.ts":function(n,r,s){s.r(r),s.d(r,"getModulators",(function(){return l}));var a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(c){return{type:c>>10&63,polarity:c>>9&1,direction:c>>8&1,palette:c>>7&1,index:127&c}},l=function(c,u){if(c.id!==u)throw new a.ParseError("Unexpected chunk ID","'".concat(u,"'"),"'".concat(c.id,"'"));if(c.length%o.SF_MODULATOR_SIZE)throw new a.ParseError("Invalid size for the '".concat(u,"' sub-chunk"));return c.iterate((function(f){return{source:i(f.getInt16BE()),id:f.getInt16BE(),value:f.getInt16BE(),valueSource:i(f.getInt16BE()),transform:f.getInt16BE()}}))}},"./src/chunks/presets/headers.ts":function(n,r,s){s.r(r),s.d(r,"getPresetHeaders",(function(){return i}));var a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="phdr")throw new a.ParseError("Invalid chunk ID","'phdr'","'".concat(l.id,"'"));if(l.length%o.SF_PRESET_HEADER_SIZE)throw new a.ParseError("Invalid size for the 'phdr' sub-chunk");return l.iterate((function(c){return{name:c.getString(),preset:c.getInt16(),bank:c.getInt16(),bagIndex:c.getInt16(),library:c.getUInt32(),genre:c.getUInt32(),morphology:c.getUInt32()}}))}},"./src/chunks/presets/index.ts":function(n,r,s){s.r(r);var a=s("./src/chunks/presets/headers.ts");s.d(r,"getPresetHeaders",(function(){return a.getPresetHeaders}))},"./src/chunks/samples/headers.ts":function(n,r,s){s.r(r),s.d(r,"getSampleHeaders",(function(){return i}));var a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=function(l){if(l.id!=="shdr")throw new a.ParseError("Unexpected chunk ID","'shdr'","'".concat(l.id,"'"));if(l.length%o.SF_SAMPLE_HEADER_SIZE)throw new a.ParseError("Invalid size for the 'shdr' sub-chunk");return l.iterate((function(c){return{name:c.getString(),start:c.getUInt32(),end:c.getUInt32(),startLoop:c.getUInt32(),endLoop:c.getUInt32(),sampleRate:c.getUInt32(),originalPitch:c.getByte(),pitchCorrection:c.getChar(),link:c.getInt16(),type:c.getInt16()}}))}},"./src/chunks/samples/index.ts":function(n,r,s){s.r(r);var a=s("./src/chunks/samples/headers.ts");s.d(r,"getSampleHeaders",(function(){return a.getSampleHeaders}))},"./src/chunks/zones.ts":function(n,r,s){s.r(r),s.d(r,"getZones",(function(){return l})),s.d(r,"getItemsInZone",(function(){return c}));var a=s("./src/riff/index.ts"),o=s("./src/constants.ts"),i=s("./src/types/index.ts"),l=function(d,h){if(d.id!==h)throw new a.ParseError("Unexpected chunk ID","'".concat(h,"'"),"'".concat(d.id,"'"));if(d.length%o.SF_BAG_SIZE)throw new a.ParseError("Invalid size for the '".concat(h,"' sub-chunk"));return d.iterate((function(v){return{generatorIndex:v.getInt16(),modulatorIndex:v.getInt16()}}))},c=function(d,h,v,g,y,b){for(var _=[],w=0;w<d.length;w++){for(var x=d[w],S=d[w+1],k=x.bagIndex,E=S?S.bagIndex:h.length,M=[],T=void 0,$=k;$<E;$++){var A=u($,h,v),I=f($,h,g),R=I[i.GeneratorType.KeyRange]&&I[i.GeneratorType.KeyRange].range,D=I[b];if(D){var O=y[D.value];O&&M.push({keyRange:R,modulators:A,generators:I,reference:O})}else $-k==0&&(T={keyRange:R,modulators:A,generators:I})}_.push({header:x,globalZone:T,zones:M})}return _},u=function(d,h,v){var g=h[d],y=h[d+1],b=g.modulatorIndex,_=y?y.modulatorIndex:h.length;return m(b,_,v)},f=function(d,h,v){var g=h[d],y=h[d+1],b=g.generatorIndex,_=y?y.generatorIndex:h.length;return m(b,_,v)},m=function(d,h,v){for(var g={},y=d;y<h;y++){var b=v[y];b&&(g[b.id]=b)}return g}},"./src/constants.ts":function(n,r,s){s.r(r),s.d(r,"SF_VERSION_LENGTH",(function(){return a})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return o})),s.d(r,"SF_BAG_SIZE",(function(){return i})),s.d(r,"SF_MODULATOR_SIZE",(function(){return l})),s.d(r,"SF_GENERATOR_SIZE",(function(){return c})),s.d(r,"SF_INSTRUMENT_HEADER_SIZE",(function(){return u})),s.d(r,"SF_SAMPLE_HEADER_SIZE",(function(){return f})),s.d(r,"DEFAULT_SAMPLE_RATE",(function(){return m}));var a=4,o=38,i=4,l=10,c=4,u=22,f=46,m=22050},"./src/index.ts":function(n,r,s){s.r(r);var a=s("./src/types/index.ts");for(var o in a)["default"].indexOf(o)<0&&(function(u){s.d(r,u,(function(){return a[u]}))})(o);var i=s("./src/chunk.ts");s.d(r,"SF2Chunk",(function(){return i.SF2Chunk}));var l=s("./src/constants.ts");s.d(r,"SF_VERSION_LENGTH",(function(){return l.SF_VERSION_LENGTH})),s.d(r,"SF_PRESET_HEADER_SIZE",(function(){return l.SF_PRESET_HEADER_SIZE})),s.d(r,"SF_BAG_SIZE",(function(){return l.SF_BAG_SIZE})),s.d(r,"SF_MODULATOR_SIZE",(function(){return l.SF_MODULATOR_SIZE})),s.d(r,"SF_GENERATOR_SIZE",(function(){return l.SF_GENERATOR_SIZE})),s.d(r,"SF_INSTRUMENT_HEADER_SIZE",(function(){return l.SF_INSTRUMENT_HEADER_SIZE})),s.d(r,"SF_SAMPLE_HEADER_SIZE",(function(){return l.SF_SAMPLE_HEADER_SIZE})),s.d(r,"DEFAULT_SAMPLE_RATE",(function(){return l.DEFAULT_SAMPLE_RATE}));var c=s("./src/soundFont2.ts");s.d(r,"SoundFont2",(function(){return c.SoundFont2}))},"./src/riff/chunkIterator.ts":function(n,r,s){s.r(r),s.d(r,"ChunkIterator",(function(){return c}));var a=s("./src/utils/index.ts");function o(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function i(u,f){for(var m=0;m<f.length;m++){var d=f[m];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,m){return f in u?Object.defineProperty(u,f,{value:m,enumerable:!0,configurable:!0,writable:!0}):u[f]=m,u}var c=(function(){function u(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;o(this,u),l(this,"target",[]),l(this,"chunk",void 0),l(this,"position",0),this.chunk=d,this.position=h}var f,m;return f=u,(m=[{key:"iterate",value:function(d){for(;this.position<this.chunk.length;){var h=d(this);h&&this.target.push(h)}}},{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,h=Object(a.getStringFromBuffer)(this.getBuffer(this.position,d));return this.position+=d,h}},{key:"getInt16",value:function(){return this.chunk.buffer[this.position++]|this.chunk.buffer[this.position++]<<8}},{key:"getInt16BE",value:function(){return this.getInt16()<<16>>16}},{key:"getUInt32",value:function(){return(this.chunk.buffer[this.position++]|this.chunk.buffer[this.position++]<<8|this.chunk.buffer[this.position++]<<16|this.chunk.buffer[this.position++]<<24)>>>0}},{key:"getByte",value:function(){return this.chunk.buffer[this.position++]}},{key:"getChar",value:function(){return this.chunk.buffer[this.position++]<<24>>24}},{key:"skip",value:function(d){this.position+=d}},{key:"getBuffer",value:function(d,h){return this.chunk.buffer.subarray(d,d+h)}},{key:"currentPosition",get:function(){return this.position}}])&&i(f.prototype,m),u})()},"./src/riff/index.ts":function(n,r,s){s.r(r);var a=s("./src/riff/chunkIterator.ts");s.d(r,"ChunkIterator",(function(){return a.ChunkIterator}));var o=s("./src/riff/parseError.ts");s.d(r,"ParseError",(function(){return o.ParseError}));var i=s("./src/riff/parser.ts");s.d(r,"parseBuffer",(function(){return i.parseBuffer})),s.d(r,"getChunk",(function(){return i.getChunk})),s.d(r,"getChunkLength",(function(){return i.getChunkLength})),s.d(r,"getSubChunks",(function(){return i.getSubChunks})),s.d(r,"getChunkId",(function(){return i.getChunkId}));var l=s("./src/riff/riffChunk.ts");s.d(r,"RIFFChunk",(function(){return l.RIFFChunk}))},"./src/riff/parseError.ts":function(n,r,s){function a(d){return(a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h})(d)}function o(d,h){return!h||a(h)!=="object"&&typeof h!="function"?(function(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v})(d):h}function i(d){var h=typeof Map=="function"?new Map:void 0;return(i=function(v){if(v===null||(g=v,Function.toString.call(g).indexOf("[native code]")===-1))return v;var g;if(typeof v!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(v))return h.get(v);h.set(v,y)}function y(){return c(v,arguments,f(this).constructor)}return y.prototype=Object.create(v.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),u(y,v)})(d)}function l(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch{return!1}}function c(d,h,v){return(c=l()?Reflect.construct:function(g,y,b){var _=[null];_.push.apply(_,y);var w=new(Function.bind.apply(g,_));return b&&u(w,b.prototype),w}).apply(null,arguments)}function u(d,h){return(u=Object.setPrototypeOf||function(v,g){return v.__proto__=g,v})(d,h)}function f(d){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(h){return h.__proto__||Object.getPrototypeOf(h)})(d)}s.r(r),s.d(r,"ParseError",(function(){return m}));var m=(function(d){function h(v,g,y){return(function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,h),o(this,f(h).call(this,"".concat(v).concat(g&&y?", expected ".concat(g,", received ").concat(y):"")))}return(function(v,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(g&&g.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),g&&u(v,g)})(h,d),h})(i(Error))},"./src/riff/parser.ts":function(n,r,s){s.r(r),s.d(r,"parseBuffer",(function(){return l})),s.d(r,"getChunk",(function(){return c})),s.d(r,"getChunkLength",(function(){return u})),s.d(r,"getSubChunks",(function(){return f})),s.d(r,"getChunkId",(function(){return m}));var a=s("./src/riff/parseError.ts"),o=s("./src/utils/buffer.ts"),i=s("./src/riff/riffChunk.ts"),l=function(d){var h=m(d);if(h!=="RIFF")throw new a.ParseError("Invalid file format","RIFF",h);var v=m(d,8);if(v!=="sfbk")throw new a.ParseError("Invalid signature","sfbk",v);var g=d.subarray(8),y=f(g.subarray(4));return new i.RIFFChunk(h,g.length,g,y)},c=function(d,h){var v=m(d,h),g=u(d,h+4),y=[];return v!=="RIFF"&&v!=="LIST"||(y=f(d.subarray(h+12))),new i.RIFFChunk(v,g,d.subarray(h+8),y)},u=function(d,h){return((d=d.subarray(h,h+4))[0]|d[1]<<8|d[2]<<16|d[3]<<24)>>>0},f=function(d){for(var h=[],v=0;v<=d.length-8;){var g=c(d,v);h.push(g),v=(v+=8+g.length)%2?v+1:v}return h},m=function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return Object(o.getStringFromBuffer)(d.subarray(h,h+4))}},"./src/riff/riffChunk.ts":function(n,r,s){s.r(r),s.d(r,"RIFFChunk",(function(){return c}));var a=s("./src/riff/chunkIterator.ts"),o=s("./src/utils/index.ts");function i(u,f){for(var m=0;m<f.length;m++){var d=f[m];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(u,d.key,d)}}function l(u,f,m){return f in u?Object.defineProperty(u,f,{value:m,enumerable:!0,configurable:!0,writable:!0}):u[f]=m,u}var c=(function(){function u(d,h,v,g){(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,u),l(this,"id",void 0),l(this,"length",void 0),l(this,"buffer",void 0),l(this,"subChunks",void 0),this.id=d,this.length=h,this.buffer=v,this.subChunks=g}var f,m;return f=u,(m=[{key:"getString",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,h=arguments.length>1?arguments[1]:void 0;return Object(o.getStringFromBuffer)(this.getBuffer(d,h||this.length-d))}},{key:"getInt16",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d++]|this.buffer[d]<<8}},{key:"getUInt32",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return(this.buffer[d++]|this.buffer[d++]<<8|this.buffer[d++]<<16|this.buffer[d]<<24)>>>0}},{key:"getByte",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d]}},{key:"getChar",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.buffer[d]<<24>>24}},{key:"iterator",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new a.ChunkIterator(this,d)}},{key:"iterate",value:function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,v=new a.ChunkIterator(this,h);return v.iterate(d),v.target}},{key:"getBuffer",value:function(d,h){return this.buffer.subarray(d,d+h)}}])&&i(f.prototype,m),u})()},"./src/soundFont2.ts":function(n,r,s){s.r(r),s.d(r,"SoundFont2",(function(){return h}));var a=s("./src/types/index.ts"),o=s("./src/chunk.ts"),i=s("./src/riff/index.ts"),l=s("./src/chunks/index.ts"),c=s("./src/utils/index.ts");function u(v){for(var g=1;g<arguments.length;g++){var y=arguments[g]!=null?arguments[g]:{},b=Object.keys(y);typeof Object.getOwnPropertySymbols=="function"&&(b=b.concat(Object.getOwnPropertySymbols(y).filter((function(_){return Object.getOwnPropertyDescriptor(y,_).enumerable})))),b.forEach((function(_){d(v,_,y[_])}))}return v}function f(v,g){for(var y=0;y<g.length;y++){var b=g[y];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(v,b.key,b)}}function m(v,g,y){return g&&f(v.prototype,g),y&&f(v,y),v}function d(v,g,y){return g in v?Object.defineProperty(v,g,{value:y,enumerable:!0,configurable:!0,writable:!0}):v[g]=y,v}var h=(function(){function v(g){if((function(b,_){if(!(b instanceof _))throw new TypeError("Cannot call a class as a function")})(this,v),d(this,"chunk",void 0),d(this,"metaData",void 0),d(this,"sampleData",void 0),d(this,"samples",void 0),d(this,"presetData",void 0),d(this,"instruments",void 0),d(this,"presets",void 0),d(this,"banks",void 0),!(g instanceof o.SF2Chunk)){var y=Object(i.parseBuffer)(g);g=new o.SF2Chunk(y)}if(g.subChunks.length!==3)throw new i.ParseError("Invalid sfbk structure","3 chunks","".concat(g.subChunks.length," chunks"));this.chunk=g,this.metaData=g.subChunks[0].getMetaData(),this.sampleData=g.subChunks[1].getSampleData(),this.presetData=g.subChunks[2].getPresetData(),this.samples=this.getSamples(),this.instruments=this.getInstruments(),this.presets=this.getPresets(),this.banks=this.getBanks()}return m(v,null,[{key:"from",value:function(g){return new v(g)}}]),m(v,[{key:"getKeyData",value:function(g){var y=this,b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,_=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return Object(c.memoize)((function(w,x,S){var k=y.banks[x];if(k){var E=k.presets[S];if(E){var M=E.zones.filter((function(ne){return y.isKeyInRange(ne,w)}));if(M.length>0){var T=!0,$=!1,A=void 0;try{for(var I,R=M[Symbol.iterator]();!(T=(I=R.next()).done);T=!0){var D=I.value,O=D.instrument,Z=O.zones.filter((function(ne){return y.isKeyInRange(ne,w)}));if(Z.length>0){var G=!0,Y=!1,te=void 0;try{for(var X,K=Z[Symbol.iterator]();!(G=(X=K.next()).done);G=!0){var le=X.value,J=le.sample,de=u({},D.generators,le.generators),ue=u({},D.modulators,le.modulators);return{keyNumber:w,preset:E,instrument:O,sample:J,generators:de,modulators:ue}}}catch(ne){Y=!0,te=ne}finally{try{G||K.return==null||K.return()}finally{if(Y)throw te}}}}}catch(ne){$=!0,A=ne}finally{try{T||R.return==null||R.return()}finally{if($)throw A}}}}}return null}))(g,b,_)}},{key:"isKeyInRange",value:function(g,y){return g.keyRange===void 0||g.keyRange.lo<=y&&g.keyRange.hi>=y}},{key:"getBanks",value:function(){return this.presets.reduce((function(g,y){var b=y.header.bank;return g[b]||(g[b]={presets:[]}),g[b].presets[y.header.preset]=y,g}),[])}},{key:"getPresets",value:function(){var g=this.presetData,y=g.presetHeaders,b=g.presetZones,_=g.presetGenerators,w=g.presetModulators;return Object(l.getItemsInZone)(y,b,w,_,this.instruments,a.GeneratorType.Instrument).filter((function(x){return x.header.name!=="EOP"})).map((function(x){return{header:x.header,globalZone:x.globalZone,zones:x.zones.map((function(S){return{keyRange:S.keyRange,generators:S.generators,modulators:S.modulators,instrument:S.reference}}))}}))}},{key:"getInstruments",value:function(){var g=this.presetData,y=g.instrumentHeaders,b=g.instrumentZones,_=g.instrumentModulators,w=g.instrumentGenerators;return Object(l.getItemsInZone)(y,b,_,w,this.samples,a.GeneratorType.SampleId).filter((function(x){return x.header.name!=="EOI"})).map((function(x){return{header:x.header,globalZone:x.globalZone,zones:x.zones.map((function(S){return{keyRange:S.keyRange,generators:S.generators,modulators:S.modulators,sample:S.reference}}))}}))}},{key:"getSamples",value:function(){var g=this;return this.presetData.sampleHeaders.filter((function(y){return y.name!=="EOS"})).map((function(y){if(y.name!=="EOS"&&y.sampleRate<=0)throw new Error("Illegal sample rate of ".concat(y.sampleRate," hz in sample '").concat(y.name,"'"));return y.originalPitch>=128&&y.originalPitch<=254&&(y.originalPitch=60),y.startLoop-=y.start,y.endLoop-=y.start,{header:y,data:new Int16Array(new Uint8Array(g.sampleData.subarray(2*y.start,2*y.end)).buffer)}}))}}]),v})()},"./src/types/bank.ts":function(n,r){},"./src/types/generator.ts":function(n,r,s){var a,o;function i(c,u,f){return u in c?Object.defineProperty(c,u,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[u]=f,c}s.r(r),s.d(r,"GeneratorType",(function(){return o})),s.d(r,"DEFAULT_GENERATOR_VALUES",(function(){return l})),(function(c){c[c.StartAddrsOffset=0]="StartAddrsOffset",c[c.EndAddrsOffset=1]="EndAddrsOffset",c[c.StartLoopAddrsOffset=2]="StartLoopAddrsOffset",c[c.EndLoopAddrsOffset=3]="EndLoopAddrsOffset",c[c.StartAddrsCoarseOffset=4]="StartAddrsCoarseOffset",c[c.ModLFOToPitch=5]="ModLFOToPitch",c[c.VibLFOToPitch=6]="VibLFOToPitch",c[c.ModEnvToPitch=7]="ModEnvToPitch",c[c.InitialFilterFc=8]="InitialFilterFc",c[c.InitialFilterQ=9]="InitialFilterQ",c[c.ModLFOToFilterFc=10]="ModLFOToFilterFc",c[c.ModEnvToFilterFc=11]="ModEnvToFilterFc",c[c.EndAddrsCoarseOffset=12]="EndAddrsCoarseOffset",c[c.ModLFOToVolume=13]="ModLFOToVolume",c[c.Unused1=14]="Unused1",c[c.ChorusEffectsSend=15]="ChorusEffectsSend",c[c.ReverbEffectsSend=16]="ReverbEffectsSend",c[c.Pan=17]="Pan",c[c.Unused2=18]="Unused2",c[c.Unused3=19]="Unused3",c[c.Unused4=20]="Unused4",c[c.DelayModLFO=21]="DelayModLFO",c[c.FreqModLFO=22]="FreqModLFO",c[c.DelayVibLFO=23]="DelayVibLFO",c[c.FreqVibLFO=24]="FreqVibLFO",c[c.DelayModEnv=25]="DelayModEnv",c[c.AttackModEnv=26]="AttackModEnv",c[c.HoldModEnv=27]="HoldModEnv",c[c.DecayModEnv=28]="DecayModEnv",c[c.SustainModEnv=29]="SustainModEnv",c[c.ReleaseModEnv=30]="ReleaseModEnv",c[c.KeyNumToModEnvHold=31]="KeyNumToModEnvHold",c[c.KeyNumToModEnvDecay=32]="KeyNumToModEnvDecay",c[c.DelayVolEnv=33]="DelayVolEnv",c[c.AttackVolEnv=34]="AttackVolEnv",c[c.HoldVolEnv=35]="HoldVolEnv",c[c.DecayVolEnv=36]="DecayVolEnv",c[c.SustainVolEnv=37]="SustainVolEnv",c[c.ReleaseVolEnv=38]="ReleaseVolEnv",c[c.KeyNumToVolEnvHold=39]="KeyNumToVolEnvHold",c[c.KeyNumToVolEnvDecay=40]="KeyNumToVolEnvDecay",c[c.Instrument=41]="Instrument",c[c.Reserved1=42]="Reserved1",c[c.KeyRange=43]="KeyRange",c[c.VelRange=44]="VelRange",c[c.StartLoopAddrsCoarseOffset=45]="StartLoopAddrsCoarseOffset",c[c.KeyNum=46]="KeyNum",c[c.Velocity=47]="Velocity",c[c.InitialAttenuation=48]="InitialAttenuation",c[c.Reserved2=49]="Reserved2",c[c.EndLoopAddrsCoarseOffset=50]="EndLoopAddrsCoarseOffset",c[c.CoarseTune=51]="CoarseTune",c[c.FineTune=52]="FineTune",c[c.SampleId=53]="SampleId",c[c.SampleModes=54]="SampleModes",c[c.Reserved3=55]="Reserved3",c[c.ScaleTuning=56]="ScaleTuning",c[c.ExclusiveClass=57]="ExclusiveClass",c[c.OverridingRootKey=58]="OverridingRootKey",c[c.Unused5=59]="Unused5",c[c.EndOper=60]="EndOper"})(o||(o={}));var l=(i(a={},o.StartAddrsOffset,0),i(a,o.EndAddrsOffset,0),i(a,o.StartLoopAddrsOffset,0),i(a,o.EndLoopAddrsOffset,0),i(a,o.StartAddrsCoarseOffset,0),i(a,o.ModLFOToPitch,0),i(a,o.VibLFOToPitch,0),i(a,o.ModEnvToPitch,0),i(a,o.InitialFilterFc,13500),i(a,o.InitialFilterQ,0),i(a,o.ModLFOToFilterFc,0),i(a,o.ModEnvToFilterFc,0),i(a,o.EndAddrsCoarseOffset,0),i(a,o.ModLFOToVolume,0),i(a,o.ChorusEffectsSend,0),i(a,o.ReverbEffectsSend,0),i(a,o.Pan,0),i(a,o.DelayModLFO,-12e3),i(a,o.FreqModLFO,0),i(a,o.DelayVibLFO,-12e3),i(a,o.FreqVibLFO,0),i(a,o.DelayModEnv,-12e3),i(a,o.AttackModEnv,-12e3),i(a,o.HoldModEnv,-12e3),i(a,o.DecayModEnv,-12e3),i(a,o.SustainModEnv,0),i(a,o.ReleaseModEnv,-12e3),i(a,o.KeyNumToModEnvHold,0),i(a,o.KeyNumToModEnvDecay,0),i(a,o.DelayVolEnv,-12e3),i(a,o.AttackVolEnv,-12e3),i(a,o.HoldVolEnv,-12e3),i(a,o.DecayVolEnv,-12e3),i(a,o.SustainVolEnv,0),i(a,o.ReleaseVolEnv,-12e3),i(a,o.KeyNumToVolEnvHold,0),i(a,o.KeyNumToVolEnvDecay,0),i(a,o.StartLoopAddrsCoarseOffset,0),i(a,o.KeyNum,-1),i(a,o.Velocity,-1),i(a,o.InitialAttenuation,0),i(a,o.EndLoopAddrsCoarseOffset,0),i(a,o.CoarseTune,0),i(a,o.FineTune,0),i(a,o.SampleModes,0),i(a,o.ScaleTuning,100),i(a,o.ExclusiveClass,0),i(a,o.OverridingRootKey,-1),a)},"./src/types/index.ts":function(n,r,s){s.r(r);var a=s("./src/types/bank.ts");for(var o in a)["default"].indexOf(o)<0&&(function(g){s.d(r,g,(function(){return a[g]}))})(o);var i=s("./src/types/generator.ts");s.d(r,"GeneratorType",(function(){return i.GeneratorType})),s.d(r,"DEFAULT_GENERATOR_VALUES",(function(){return i.DEFAULT_GENERATOR_VALUES}));var l=s("./src/types/instrument.ts");for(var o in l)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return l[y]}))})(o);var c=s("./src/types/key.ts");for(var o in c)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return c[y]}))})(o);var u=s("./src/types/metaData.ts");for(var o in u)["default","GeneratorType","DEFAULT_GENERATOR_VALUES"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return u[y]}))})(o);var f=s("./src/types/modulator.ts");s.d(r,"ControllerType",(function(){return f.ControllerType})),s.d(r,"ControllerPolarity",(function(){return f.ControllerPolarity})),s.d(r,"ControllerDirection",(function(){return f.ControllerDirection})),s.d(r,"ControllerPalette",(function(){return f.ControllerPalette})),s.d(r,"Controller",(function(){return f.Controller})),s.d(r,"TransformType",(function(){return f.TransformType})),s.d(r,"DEFAULT_INSTRUMENT_MODULATORS",(function(){return f.DEFAULT_INSTRUMENT_MODULATORS}));var m=s("./src/types/preset.ts");for(var o in m)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return m[y]}))})(o);var d=s("./src/types/presetData.ts");for(var o in d)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return d[y]}))})(o);var h=s("./src/types/sample.ts");s.d(r,"SampleType",(function(){return h.SampleType}));var v=s("./src/types/zone.ts");for(var o in v)["default","GeneratorType","DEFAULT_GENERATOR_VALUES","ControllerType","ControllerPolarity","ControllerDirection","ControllerPalette","Controller","TransformType","DEFAULT_INSTRUMENT_MODULATORS","SampleType"].indexOf(o)<0&&(function(y){s.d(r,y,(function(){return v[y]}))})(o)},"./src/types/instrument.ts":function(n,r){},"./src/types/key.ts":function(n,r){},"./src/types/metaData.ts":function(n,r){},"./src/types/modulator.ts":function(n,r,s){s.r(r),s.d(r,"ControllerType",(function(){return a})),s.d(r,"ControllerPolarity",(function(){return o})),s.d(r,"ControllerDirection",(function(){return i})),s.d(r,"ControllerPalette",(function(){return l})),s.d(r,"Controller",(function(){return c})),s.d(r,"TransformType",(function(){return u})),s.d(r,"DEFAULT_INSTRUMENT_MODULATORS",(function(){return m}));var a,o,i,l,c,u,f=s("./src/types/generator.ts");(function(d){d[d.Linear=0]="Linear",d[d.Concave=1]="Concave",d[d.Convex=2]="Convex",d[d.Switch=3]="Switch"})(a||(a={})),(function(d){d[d.Unipolar=0]="Unipolar",d[d.Bipolar=1]="Bipolar"})(o||(o={})),(function(d){d[d.Increasing=0]="Increasing",d[d.Decreasing=1]="Decreasing"})(i||(i={})),(function(d){d[d.GeneralController=0]="GeneralController",d[d.MidiController=1]="MidiController"})(l||(l={})),(function(d){d[d.NoController=0]="NoController",d[d.NoteOnVelocity=2]="NoteOnVelocity",d[d.NoteOnKeyNumber=3]="NoteOnKeyNumber",d[d.PolyPressure=10]="PolyPressure",d[d.ChannelPressure=13]="ChannelPressure",d[d.PitchWheel=14]="PitchWheel",d[d.PitchWheelSensitivity=16]="PitchWheelSensitivity",d[d.Link=127]="Link"})(c||(c={})),(function(d){d[d.Linear=0]="Linear",d[d.Absolute=2]="Absolute"})(u||(u={}));var m=[{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialFilterFc,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Decreasing,palette:l.GeneralController,index:c.NoteOnVelocity},value:-2400,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.ChannelPressure},value:50,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.VibLFOToPitch,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:1},value:50,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:7},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:l.MidiController,index:10},value:1e3,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.InitialAttenuation,source:{type:a.Concave,polarity:o.Unipolar,direction:i.Decreasing,palette:l.MidiController,index:11},value:960,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ReverbEffectsSend,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:91},value:200,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.ChorusEffectsSend,source:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.MidiController,index:93},value:200,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.NoController},transform:u.Linear},{id:f.GeneratorType.CoarseTune,source:{type:a.Linear,polarity:o.Bipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheel},value:12700,valueSource:{type:a.Linear,polarity:o.Unipolar,direction:i.Increasing,palette:l.GeneralController,index:c.PitchWheelSensitivity},transform:u.Linear}]},"./src/types/preset.ts":function(n,r){},"./src/types/presetData.ts":function(n,r){},"./src/types/sample.ts":function(n,r,s){var a;s.r(r),s.d(r,"SampleType",(function(){return a})),(function(o){o[o.EOS=0]="EOS",o[o.Mono=1]="Mono",o[o.Right=2]="Right",o[o.Left=4]="Left",o[o.Linked=8]="Linked",o[o.RomMono=32769]="RomMono",o[o.RomRight=32770]="RomRight",o[o.RomLeft=32772]="RomLeft",o[o.RomLinked=32776]="RomLinked"})(a||(a={}))},"./src/types/zone.ts":function(n,r){},"./src/utils/buffer.ts":function(n,r,s){s.r(r),s.d(r,"getStringFromBuffer",(function(){return a}));var a=function(o){var i=new TextDecoder("utf8").decode(o),l=i.indexOf("\0");return(l===-1?i:i.slice(0,l)).trim()}},"./src/utils/index.ts":function(n,r,s){s.r(r);var a=s("./src/utils/buffer.ts");s.d(r,"getStringFromBuffer",(function(){return a.getStringFromBuffer}));var o=s("./src/utils/memoize.ts");s.d(r,"memoize",(function(){return o.memoize}))},"./src/utils/memoize.ts":function(n,r,s){s.r(r),s.d(r,"memoize",(function(){return a}));var a=function(o){var i={};return function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var f=JSON.stringify(c);if(f in i)return i[f];var m=o.apply(void 0,c);return i[f]=m,m}}}})}))})(ua)),ua.exports}rh();var Be=1e3;function Ma(e){const{audioBuffer:t,startSample:n,offsetSamples:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate,h=t?.length??e.sourceDurationSamples??(c&&d?Math.ceil(c.duration*d):void 0);if(d===void 0)throw new Error("createClip: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");if(h===void 0)throw new Error("createClip: sourceDurationSamples is required when audioBuffer is not provided (can use waveformData.duration)");t&&c&&t.sampleRate!==c.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${c.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const v=e.durationSamples??h;return{id:fc(),audioBuffer:t,startSample:n,durationSamples:v,offsetSamples:r,sampleRate:d,sourceDurationSamples:h,gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m}}function uc(e){const{audioBuffer:t,startTime:n,offset:r=0,gain:s=1,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m}=e,d=t?.sampleRate??e.sampleRate??c?.sample_rate;if(d===void 0)throw new Error("createClipFromSeconds: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)");const h=t?.duration??e.sourceDuration??c?.duration;if(h===void 0)throw new Error("createClipFromSeconds: sourceDuration is required when audioBuffer is not provided (can use waveformData.duration)");t&&c&&t.sampleRate!==c.sample_rate&&console.warn(`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${c.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`);const v=e.duration??h;return Ma({audioBuffer:t,startSample:Math.round(n*d),durationSamples:Math.round(v*d),offsetSamples:Math.round(r*d),sampleRate:d,sourceDurationSamples:Math.ceil(h*d),gain:s,name:a,color:o,fadeIn:i,fadeOut:l,waveformData:c,midiNotes:u,midiChannel:f,midiProgram:m})}function dc(e){const{name:t,clips:n=[],muted:r=!1,soloed:s=!1,volume:a=1,pan:o=0,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}=e;return{id:fc(),name:t,clips:n,muted:r,soloed:s,volume:a,pan:o,color:i,height:l,spectrogramConfig:c,spectrogramColorMap:u}}function fc(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function ll(e){return[...e].sort((t,n)=>t.startSample-n.startSample)}function sh(e,t){return Math.floor(e/t)}function ah(e,t,n){return Math.ceil(e*n/t)}var Nn=192;function Ns(e,t=Nn){const[,n]=e;return t*(4/n)}function bo(e,t=Nn){const[n]=e;return n*Ns(e,t)}function Rn(e,t,n,r=Nn){return Math.round(e*60*n/(t*r))}function Aa(e,t,n,r=Nn){return Math.round(e*r*t/(60*n))}function Ta(e,t){return Math.round(e/t)*t}function oh(e,t,n=Nn){const r=bo(t,n),s=Ns(t,n),a=Math.floor(e/r)+1,o=Math.floor(e%r/s)+1;return o===1?`${a}`:`${a}.${o}`}function Jr(e){return e.startSample/e.sampleRate}function cl(e){return(e.startSample+e.durationSamples)/e.sampleRate}function ul(e){return e.offsetSamples/e.sampleRate}function dl(e){return e.durationSamples/e.sampleRate}function hc(e,t,n){return Math.floor((e+t)/n)-Math.floor(e/n)}var fl=!1;function yr(e){const t=e._param;return!t&&!fl&&(fl=!0,console.warn("[waveform-playlist] Unable to access Tone.js internal _param. This likely means the Tone.js version is incompatible. Mute scheduling may not work correctly.")),t}function hl(e,t){const n=new Float32Array(e),r=e-1;for(let s=0;s<e;s++){const a=s/r;n[s]=t?a:1-a}return n}function ih(e,t){const n=new Float32Array(e),r=e-1;for(let s=0;s<e;s++){const a=s/r,o=t?s:e-1-s;n[o]=Math.exp(2*a-1)/Math.E}return n}function lh(e,t){const n=new Float32Array(e),r=t?Math.PI/2:-Math.PI/2;for(let s=0;s<e;s++)n[s]=Math.sin(Math.PI*s/e-r)/2+.5;return n}function ch(e,t,n=10){const r=new Float32Array(e);for(let s=0;s<e;s++){const a=t?s:e-1-s,o=s/e;r[a]=Math.log(1+n*o)/Math.log(1+n)}return r}function pc(e,t,n){switch(e){case"linear":return hl(t,n);case"exponential":return ih(t,n);case"sCurve":return lh(t,n);case"logarithmic":return ch(t,n);default:return hl(t,n)}}function pl(e,t,n,r="linear",s=0,a=1){if(!(n<=0))if(r==="linear")e.setValueAtTime(s,t),e.linearRampToValueAtTime(a,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(s,.001),t),e.exponentialRampToValueAtTime(Math.max(a,.001),t+n);else{const o=pc(r,1e4,!0),i=new Float32Array(o.length),l=a-s;for(let c=0;c<o.length;c++)i[c]=s+o[c]*l;e.setValueCurveAtTime(i,t,n)}}function ml(e,t,n,r="linear",s=1,a=0){if(!(n<=0))if(r==="linear")e.setValueAtTime(s,t),e.linearRampToValueAtTime(a,t+n);else if(r==="exponential")e.setValueAtTime(Math.max(s,.001),t),e.exponentialRampToValueAtTime(Math.max(a,.001),t+n);else{const o=pc(r,1e4,!1),i=new Float32Array(o.length),l=s-a;for(let c=0;c<o.length;c++)i[c]=a+o[c]*l;e.setValueCurveAtTime(i,t,n)}}var uh=class{constructor(e){this.activeSources=new Set,this._scheduleGuardOffset=0,this.track=e.track,this.volumeNode=new L.Volume(this.gainToDb(e.track.gain)),this.panNode=new L.Panner(e.track.stereoPan),this.muteGain=new L.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const t=e.destination||L.getDestination();if(e.effects){const o=e.effects(this.muteGain,t,!1);o&&(this.effectsCleanup=o)}else this.muteGain.connect(t);const n=e.clips||(e.buffer?[{buffer:e.buffer,startTime:0,duration:e.buffer.duration,offset:0,fadeIn:e.track.fadeIn,fadeOut:e.track.fadeOut,gain:1}]:[]),r=L.getTransport(),s=L.getContext().rawContext,a=this.volumeNode.input.input;this.scheduledClips=n.map(o=>{const i=s.createGain();i.gain.value=o.gain,i.connect(a);const l=this.track.startTime+o.startTime,c=r.schedule(u=>{l<this._scheduleGuardOffset||this.startClipSource(o,i,u)},l);return{clipInfo:o,fadeGainNode:i,scheduleId:c}})}startClipSource(e,t,n,r,s){const o=L.getContext().rawContext.createBufferSource();o.buffer=e.buffer,o.connect(t);const i=r??e.offset,l=s??e.duration;try{o.start(n,i,l)}catch(c){console.warn(`[waveform-playlist] Failed to start source on track "${this.id}" (time=${n}, offset=${i}, duration=${l}):`,c),o.disconnect();return}this.activeSources.add(o),o.onended=()=>{this.activeSources.delete(o)}}setScheduleGuardOffset(e){this._scheduleGuardOffset=e}startMidClipSources(e,t){for(const{clipInfo:n,fadeGainNode:r}of this.scheduledClips){const s=this.track.startTime+n.startTime,a=s+n.duration;if(s<e&&a>e){const o=e-s,i=n.offset+o,l=n.duration-o;this.startClipSource(n,r,t,i,l)}}}stopAllSources(){this.activeSources.forEach(e=>{try{e.stop()}catch(t){console.warn(`[waveform-playlist] Error stopping source on track "${this.id}":`,t)}}),this.activeSources.clear()}scheduleFades(e,t,n=0){const{clipInfo:r,fadeGainNode:s}=e,a=s.gain;a.cancelScheduledValues(0);const o=n-r.offset;if(r.fadeIn&&o<r.fadeIn.duration){const i=r.fadeIn.duration;if(o<=0)pl(a,t,i,r.fadeIn.type||"linear",0,r.gain);else{const l=i-o,c=o/i,u=r.gain*c;pl(a,t,l,r.fadeIn.type||"linear",u,r.gain)}}else a.setValueAtTime(r.gain,t);if(r.fadeOut){const l=r.duration-r.fadeOut.duration-o;if(l>0){const c=t+l;ml(a,c,r.fadeOut.duration,r.fadeOut.type||"linear",r.gain,0)}else if(l>-r.fadeOut.duration){const c=-l,u=r.fadeOut.duration-c,f=c/r.fadeOut.duration,m=r.gain*(1-f);ml(a,t,u,r.fadeOut.type||"linear",m,0)}}}prepareFades(e,t){this.scheduledClips.forEach(n=>{const r=this.track.startTime+n.clipInfo.startTime,s=r+n.clipInfo.duration;if(!(t>=s))if(t>=r){const a=t-r+n.clipInfo.offset;this.scheduleFades(n,e,a)}else{const a=r-t;this.scheduleFades(n,e+a,n.clipInfo.offset)}})}cancelFades(){this.scheduledClips.forEach(({fadeGainNode:e,clipInfo:t})=>{const n=e.gain;n.cancelScheduledValues(0),n.setValueAtTime(t.gain,0)})}gainToDb(e){return 20*Math.log10(e)}setVolume(e){this.track.gain=e,this.volumeNode.volume.value=this.gainToDb(e)}setPan(e){this.track.stereoPan=e,this.panNode.pan.value=e}setMute(e){this.track.muted=e;const t=e?0:1;yr(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){const e=L.getTransport();if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach((t,n)=>{try{e.clear(t.scheduleId)}catch(r){console.warn(`[waveform-playlist] Error clearing schedule ${n} on track "${this.id}":`,r)}try{t.fadeGainNode.disconnect()}catch(r){console.warn(`[waveform-playlist] Error disconnecting fadeGain ${n} on track "${this.id}":`,r)}});try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const e=this.scheduledClips[this.scheduledClips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get buffer(){return this.scheduledClips[0]?.clipInfo.buffer}get muted(){return this.track.muted}get startTime(){return this.track.startTime}};function dh(e){return e===35||e===36?"kick":e>=37&&e<=40?"snare":e===41||e===43||e===45||e===47||e===48||e===50?"tom":"cymbal"}var fh=class{constructor(e){this.track=e.track,this.volumeNode=new L.Volume(this.gainToDb(e.track.gain)),this.panNode=new L.Panner(e.track.stereoPan),this.muteGain=new L.Gain(e.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain),this.synth=new L.PolySynth(L.Synth,e.synthOptions),this.synth.connect(this.volumeNode),this.kickSynth=new L.PolySynth(L.MembraneSynth,{voice:L.MembraneSynth,options:{pitchDecay:.05,octaves:6,envelope:{attack:.001,decay:.4,sustain:0,release:.1}}}),this.snareSynth=new L.NoiseSynth({noise:{type:"white"},envelope:{attack:.001,decay:.15,sustain:0,release:.05}}),this.cymbalSynth=new L.PolySynth(L.MetalSynth,{voice:L.MetalSynth,options:{envelope:{attack:.001,decay:.3,release:.1},harmonicity:5.1,modulationIndex:32,resonance:4e3,octaves:1.5}}),this.tomSynth=new L.PolySynth(L.MembraneSynth,{voice:L.MembraneSynth,options:{pitchDecay:.08,octaves:4,envelope:{attack:.001,decay:.3,sustain:0,release:.1}}}),this.kickSynth.connect(this.volumeNode),this.snareSynth.connect(this.volumeNode),this.cymbalSynth.connect(this.volumeNode),this.tomSynth.connect(this.volumeNode);const t=e.destination||L.getDestination();if(e.effects){const n=e.effects(this.muteGain,t,!1);n&&(this.effectsCleanup=n)}else this.muteGain.connect(t);this.scheduledClips=e.clips.map(n=>{const r=n.notes.filter(i=>{const l=i.time+i.duration;return i.time<n.offset+n.duration&&l>n.offset}),s=this.track.startTime+n.startTime,a=r.map(i=>{const l=i.time-n.offset,c=Math.max(0,l),u=Math.min(i.duration-Math.max(0,n.offset-i.time),n.duration-c);return{time:s+c,note:i.name,midi:i.midi,duration:Math.max(0,u),velocity:i.velocity,channel:i.channel}}),o=new L.Part((i,l)=>{l.duration>0&&this.triggerNote(l.midi,l.note,l.duration,i,l.velocity,l.channel)},a);return o.start(0),{clipInfo:n,part:o}})}triggerNote(e,t,n,r,s,a){if(a===9)switch(dh(e)){case"kick":this.kickSynth.triggerAttackRelease("C1",n,r,s);break;case"snare":try{this.snareSynth.triggerAttackRelease(n,r,s)}catch(i){console.warn("[waveform-playlist] Snare overlap — previous hit still decaying, skipped:",i)}break;case"tom":{const i={41:"G1",43:"A1",45:"C2",47:"D2",48:"E2",50:"G2"};this.tomSynth.triggerAttackRelease(i[e]||"C2",n,r,s);break}case"cymbal":this.cymbalSynth.triggerAttackRelease("C4",n,r,s);break}else this.synth.triggerAttackRelease(t,n,r,s)}gainToDb(e){return 20*Math.log10(e)}setScheduleGuardOffset(e){}startMidClipSources(e,t){for(const{clipInfo:n}of this.scheduledClips){const r=this.track.startTime+n.startTime,s=r+n.duration;if(r<e&&s>e)for(const a of n.notes){const o=a.time-n.offset,i=r+Math.max(0,o),l=i+a.duration;if(i<e&&l>e){const c=l-e;try{this.triggerNote(a.midi,a.name,c,t,a.velocity,a.channel)}catch(u){console.warn(`[waveform-playlist] Failed to start mid-clip MIDI note "${a.name}" on track "${this.id}":`,u)}}}}}stopAllSources(){const e=L.getContext().rawContext.currentTime;try{this.synth.releaseAll(e),this.kickSynth.releaseAll(e),this.cymbalSynth.releaseAll(e),this.tomSynth.releaseAll(e)}catch(t){console.warn(`[waveform-playlist] Error releasing synth on track "${this.id}":`,t)}}prepareFades(e,t){}cancelFades(){}setVolume(e){this.track.gain=e,this.volumeNode.volume.value=this.gainToDb(e)}setPan(e){this.track.stereoPan=e,this.panNode.pan.value=e}setMute(e){this.track.muted=e;const t=e?0:1;yr(this.muteGain.gain)?.setValueAtTime(t,0),this.muteGain.gain.value=t}setSolo(e){this.track.soloed=e}dispose(){if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during MIDI track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach(({part:t},n)=>{try{t.dispose()}catch(r){console.warn(`[waveform-playlist] Error disposing Part ${n} on MIDI track "${this.id}":`,r)}});const e=[this.synth,this.kickSynth,this.snareSynth,this.cymbalSynth,this.tomSynth];for(const t of e)try{t?.dispose()}catch(n){console.warn(`[waveform-playlist] Error disposing synth on MIDI track "${this.id}":`,n)}try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on MIDI track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on MIDI track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on MIDI track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const e=this.scheduledClips[this.scheduledClips.length-1];return e.clipInfo.startTime+e.clipInfo.duration}get muted(){return this.track.muted}get startTime(){return this.track.startTime}},mc=class $a{constructor(t){this.activeSources=new Set,this.track=t.track,this.soundFontCache=t.soundFontCache,this.programNumber=t.programNumber??0,this.bankNumber=t.isPercussion?128:0,this.volumeNode=new L.Volume(this.gainToDb(t.track.gain)),this.panNode=new L.Panner(t.track.stereoPan),this.muteGain=new L.Gain(t.track.muted?0:1),this.volumeNode.chain(this.panNode,this.muteGain);const n=t.destination||L.getDestination();if(t.effects){const r=t.effects(this.muteGain,n,!1);r&&(this.effectsCleanup=r)}else this.muteGain.connect(n);this.scheduledClips=t.clips.map(r=>{const s=r.notes.filter(l=>{const c=l.time+l.duration;return l.time<r.offset+r.duration&&c>r.offset}),a=this.track.startTime+r.startTime,o=s.map(l=>{const c=l.time-r.offset,u=Math.max(0,c),f=Math.min(l.duration-Math.max(0,r.offset-l.time),r.duration-u);return{time:a+u,note:l.name,midi:l.midi,duration:Math.max(0,f),velocity:l.velocity,channel:l.channel}}),i=new L.Part((l,c)=>{c.duration>0&&this.triggerNote(c.midi,c.duration,l,c.velocity,c.channel)},o);return i.start(0),{clipInfo:r,part:i}})}triggerNote(t,n,r,s,a){const o=a===9?128:this.bankNumber,i=a===9?0:this.programNumber,l=this.soundFontCache.getAudioBuffer(t,o,i);if(!l){$a._missingSampleWarned||(console.warn(`[waveform-playlist] SoundFont sample not found for MIDI note ${t} (bank ${o}, preset ${i}). Subsequent missing samples will be silent.`),$a._missingSampleWarned=!0);return}const c=L.getContext().rawContext,u=c.createBufferSource();u.buffer=l.buffer,u.playbackRate.value=l.playbackRate,(l.loopMode===1||l.loopMode===3)&&(u.loop=!0,u.loopStart=l.loopStart,u.loopEnd=l.loopEnd);const f=l.buffer.duration/l.playbackRate,m=l.loopMode===0?Math.max(n,f):n,d=s*s,h=c.createGain(),{attackVolEnv:v,holdVolEnv:g,decayVolEnv:y,sustainVolEnv:b,releaseVolEnv:_}=l,w=d*b;h.gain.setValueAtTime(0,r),h.gain.linearRampToValueAtTime(d,r+v),g>.001&&h.gain.setValueAtTime(d,r+v+g);const x=r+v+g;h.gain.linearRampToValueAtTime(w,x+y),h.gain.setValueAtTime(w,r+m),h.gain.linearRampToValueAtTime(0,r+m+_),u.connect(h),h.connect(this.volumeNode.input.input),this.activeSources.add(u),u.onended=()=>{this.activeSources.delete(u);try{h.disconnect()}catch(S){console.warn("[waveform-playlist] GainNode already disconnected:",S)}},u.start(r),u.stop(r+m+_)}gainToDb(t){return 20*Math.log10(t)}setScheduleGuardOffset(t){}startMidClipSources(t,n){for(const{clipInfo:r}of this.scheduledClips){const s=this.track.startTime+r.startTime,a=s+r.duration;if(s<t&&a>t)for(const o of r.notes){const i=o.time-r.offset,l=s+Math.max(0,i),c=l+o.duration;if(l<t&&c>t){const u=c-t;try{this.triggerNote(o.midi,u,n,o.velocity,o.channel)}catch(f){console.warn(`[waveform-playlist] Failed to start mid-clip SoundFont note on track "${this.id}":`,f)}}}}}stopAllSources(){for(const t of this.activeSources)try{t.stop()}catch(n){console.warn("[waveform-playlist] Error stopping AudioBufferSourceNode:",n)}this.activeSources.clear()}prepareFades(t,n){}cancelFades(){}setVolume(t){this.track.gain=t,this.volumeNode.volume.value=this.gainToDb(t)}setPan(t){this.track.stereoPan=t,this.panNode.pan.value=t}setMute(t){this.track.muted=t;const n=t?0:1;yr(this.muteGain.gain)?.setValueAtTime(n,0),this.muteGain.gain.value=n}setSolo(t){this.track.soloed=t}dispose(){if(this.effectsCleanup)try{this.effectsCleanup()}catch(t){console.warn(`[waveform-playlist] Error during SoundFont track "${this.id}" effects cleanup:`,t)}this.stopAllSources(),this.scheduledClips.forEach(({part:t},n)=>{try{t.dispose()}catch(r){console.warn(`[waveform-playlist] Error disposing Part ${n} on SoundFont track "${this.id}":`,r)}});try{this.volumeNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing volumeNode on SoundFont track "${this.id}":`,t)}try{this.panNode.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing panNode on SoundFont track "${this.id}":`,t)}try{this.muteGain.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing muteGain on SoundFont track "${this.id}":`,t)}}get id(){return this.track.id}get duration(){if(this.scheduledClips.length===0)return 0;const t=this.scheduledClips[this.scheduledClips.length-1];return t.clipInfo.startTime+t.clipInfo.duration}get muted(){return this.track.muted}get startTime(){return this.track.startTime}};mc._missingSampleWarned=!1;var hh=mc,ph=class{constructor(e={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this._completionEventId=null,this._loopHandler=null,this._loopEnabled=!1,this._loopStart=0,this._loopEnd=0,this.masterVolume=new L.Volume(this.gainToDb(e.masterGain??1)),e.effects){const t=e.effects(this.masterVolume,L.getDestination(),!1);t&&(this.effectsCleanup=t)}else this.masterVolume.toDestination();e.tracks&&e.tracks.forEach(t=>{this.tracks.set(t.id,t),this.manualMuteState.set(t.id,t.muted)})}gainToDb(e){return 20*Math.log10(e)}clearCompletionEvent(){if(this._completionEventId!==null){try{L.getTransport().clear(this._completionEventId)}catch(e){console.warn("[waveform-playlist] Error clearing Transport completion event:",e)}this._completionEventId=null}}async init(){this.isInitialized||(await L.start(),this.isInitialized=!0)}addTrack(e){const t={...e,destination:this.masterVolume},n=new uh(t);return this.tracks.set(n.id,n),this.manualMuteState.set(n.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(n.id),n}addMidiTrack(e){const t={...e,destination:this.masterVolume},n=new fh(t);return this.tracks.set(n.id,n),this.manualMuteState.set(n.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(n.id),n}addSoundFontTrack(e){const t={...e,destination:this.masterVolume},n=new hh(t);return this.tracks.set(n.id,n),this.manualMuteState.set(n.id,e.track.muted??!1),e.track.soloed&&this.soloedTracks.add(n.id),n}applyInitialSoloState(){this.updateSoloMuting()}removeTrack(e){const t=this.tracks.get(e);t&&(t.dispose(),this.tracks.delete(e),this.manualMuteState.delete(e),this.soloedTracks.delete(e))}getTrack(e){return this.tracks.get(e)}play(e,t,n){if(!this.isInitialized)throw new Error("[waveform-playlist] TonePlayout not initialized. Call init() first.");const r=e??L.now(),s=L.getTransport();this.clearCompletionEvent();const a=t??0;this.tracks.forEach(o=>{o.cancelFades(),o.prepareFades(r,a)}),n!==void 0&&(this._completionEventId=s.scheduleOnce(()=>{this._completionEventId=null;try{this.onPlaybackCompleteCallback?.()}catch(o){console.warn("[waveform-playlist] Error in playback completion callback:",o)}},a+n));try{s.state!=="stopped"&&s.stop(),this.tracks.forEach(o=>o.stopAllSources()),s.loopStart=this._loopStart,s.loopEnd=this._loopEnd,s.loop=this._loopEnabled,this.tracks.forEach(o=>o.setScheduleGuardOffset(a)),t!==void 0?s.start(r,t):s.start(r),s._clock._lastUpdate=r,this.tracks.forEach(o=>{o.startMidClipSources(a,r)})}catch(o){throw this.clearCompletionEvent(),this.tracks.forEach(i=>i.cancelFades()),console.warn("[waveform-playlist] Transport.start() failed. Audio playback could not begin.",o),o}}pause(){const e=L.getTransport();try{e.pause()}catch(t){console.warn("[waveform-playlist] Transport.pause() failed:",t)}this.tracks.forEach(t=>t.stopAllSources()),this.tracks.forEach(t=>t.cancelFades()),this.clearCompletionEvent()}stop(){const e=L.getTransport();try{e.stop()}catch(t){console.warn("[waveform-playlist] Transport.stop() failed:",t)}if(this._loopHandler){try{e.off("loop",this._loopHandler)}catch(t){console.warn("[waveform-playlist] Error removing loop handler:",t)}this._loopHandler=null}this.tracks.forEach(t=>{try{t.stopAllSources()}catch(n){console.warn(`[waveform-playlist] Error stopping sources for track "${t.id}":`,n)}}),this.tracks.forEach(t=>{try{t.cancelFades()}catch(n){console.warn(`[waveform-playlist] Error canceling fades for track "${t.id}":`,n)}}),this.clearCompletionEvent()}setMasterGain(e){this.masterVolume.volume.value=this.gainToDb(e)}setSolo(e,t){const n=this.tracks.get(e);n&&(n.setSolo(t),t?this.soloedTracks.add(e):this.soloedTracks.delete(e),this.updateSoloMuting())}updateSoloMuting(){const e=this.soloedTracks.size>0;this.tracks.forEach((t,n)=>{if(e)if(!this.soloedTracks.has(n))t.setMute(!0);else{const r=this.manualMuteState.get(n)??!1;t.setMute(r)}else{const r=this.manualMuteState.get(n)??!1;t.setMute(r)}})}setMute(e,t){const n=this.tracks.get(e);n&&(this.manualMuteState.set(e,t),n.setMute(t))}setLoop(e,t,n){this._loopEnabled=e,this._loopStart=t,this._loopEnd=n;const r=L.getTransport();try{r.loopStart=t,r.loopEnd=n,r.loop=e}catch(s){console.warn("[waveform-playlist] Error configuring Transport loop:",s);return}e&&!this._loopHandler?(this._loopHandler=()=>{const s=L.now();this.tracks.forEach(a=>{try{a.stopAllSources(),a.cancelFades(),a.setScheduleGuardOffset(this._loopStart),a.startMidClipSources(this._loopStart,s),a.prepareFades(s,this._loopStart)}catch(o){console.warn(`[waveform-playlist] Error re-scheduling track "${a.id}" on loop:`,o)}})},r.on("loop",this._loopHandler)):!e&&this._loopHandler&&(r.off("loop",this._loopHandler),this._loopHandler=null)}getCurrentTime(){return L.getTransport().seconds}seekTo(e){L.getTransport().seconds=e}dispose(){try{this.stop()}catch(e){console.warn("[waveform-playlist] Error stopping Transport during dispose:",e)}if(this.tracks.forEach(e=>{try{e.dispose()}catch(t){console.warn(`[waveform-playlist] Error disposing track "${e.id}":`,t)}}),this.tracks.clear(),this.effectsCleanup)try{this.effectsCleanup()}catch(e){console.warn("[waveform-playlist] Error during master effects cleanup:",e)}try{this.masterVolume.dispose()}catch(e){console.warn("[waveform-playlist] Error disposing master volume:",e)}}get context(){return L.getContext()}get sampleRate(){return L.getContext().sampleRate}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}},Qr=null;function mh(){return Qr||(Qr=new L.Context,L.setContext(Qr)),Qr}function gh(){return mh().rawContext}function vh(e){let t=null,n=!1,r=0,s=!1,a=0,o=0,i=!1;function l(c){if(t){try{t.dispose()}catch(f){console.warn("[waveform-playlist] Error disposing previous playout during rebuild:",f)}t=null}r++;const u=r;t=new ph({effects:e?.effects}),i&&t.init().catch(f=>{console.warn("[waveform-playlist] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",f),i=!1});for(const f of c){const m=f.clips.filter(h=>h.audioBuffer&&!h.midiNotes),d=f.clips.filter(h=>h.midiNotes&&h.midiNotes.length>0);if(m.length>0){const h=Math.min(...m.map(Jr)),v=Math.max(...m.map(cl)),g={id:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:v},y=m.map(b=>({buffer:b.audioBuffer,startTime:Jr(b)-h,duration:dl(b),offset:ul(b),fadeIn:b.fadeIn,fadeOut:b.fadeOut,gain:b.gain}));t.addTrack({clips:y,track:g,effects:f.effects})}if(d.length>0){const h=Math.min(...d.map(Jr)),v=Math.max(...d.map(cl)),y={id:m.length>0?`${f.id}:midi`:f.id,name:f.name,gain:f.volume,muted:f.muted,soloed:f.soloed,stereoPan:f.pan,startTime:h,endTime:v},b=d.map(_=>({notes:_.midiNotes,startTime:Jr(_)-h,duration:dl(_),offset:ul(_)}));if(e?.soundFontCache?.isLoaded){const _=d[0],x=_.midiChannel===9,S=_.midiProgram??0;t.addSoundFontTrack({clips:b,track:y,soundFontCache:e.soundFontCache,programNumber:S,isPercussion:x,effects:f.effects})}else e?.soundFontCache&&console.warn(`[waveform-playlist] SoundFont not loaded for track "${f.name}" — falling back to PolySynth.`),t.addMidiTrack({clips:b,track:y,effects:f.effects})}}t.applyInitialSoloState(),t.setLoop(s,a,o),t.setOnPlaybackComplete(()=>{u===r&&(n=!1)})}return{async init(){t&&(await t.init(),i=!0)},setTracks(c){l(c)},play(c,u){if(!t){console.warn("[waveform-playlist] adapter.play() called but no playout is available. Tracks may not have been set, or the adapter was disposed.");return}const f=u!==void 0?u-c:void 0;t.play(L.now(),c,f),n=!0},pause(){t?.pause(),n=!1},stop(){t?.stop(),n=!1},seek(c){t?.seekTo(c)},getCurrentTime(){return t?.getCurrentTime()??0},isPlaying(){return n},setMasterVolume(c){t?.setMasterGain(c)},setTrackVolume(c,u){t?.getTrack(c)?.setVolume(u)},setTrackMute(c,u){t?.setMute(c,u)},setTrackSolo(c,u){t?.setSolo(c,u)},setTrackPan(c,u){t?.getTrack(c)?.setPan(u)},setLoop(c,u,f){s=c,a=u,o=f,t?.setLoop(c,u,f)},dispose(){try{t?.dispose()}catch(c){console.warn("[waveform-playlist] Error disposing playout:",c)}t=null,n=!1}}}function gc(e,t,n,r){let s=t;const a=-e.startSample;if(s=Math.max(s,a),r>0){const o=n[r-1],l=o.startSample+o.durationSamples-e.startSample;s=Math.max(s,l)}if(r<n.length-1){const i=n[r+1].startSample-(e.startSample+e.durationSamples);s=Math.min(s,i)}return s}function vc(e,t,n,r,s,a){let o=t;if(n==="left"){if(o=Math.max(o,-e.startSample),o=Math.max(o,-e.offsetSamples),s>0){const i=r[s-1],l=i.startSample+i.durationSamples;o=Math.max(o,l-e.startSample)}o=Math.min(o,e.durationSamples-a)}else if(o=Math.max(o,a-e.durationSamples),o=Math.min(o,e.sourceDurationSamples-e.offsetSamples-e.durationSamples),s<r.length-1){const i=r[s+1];o=Math.min(o,i.startSample-e.startSample-e.durationSamples)}return o}function yh(e,t){return Math.floor(e/t)*t}function bh(e,t){const n=t-e.startSample,r=e.durationSamples-n,s=e.name?`${e.name} (1)`:void 0,a=e.name?`${e.name} (2)`:void 0,o=Ma({startSample:e.startSample,durationSamples:n,offsetSamples:e.offsetSamples,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:s,color:e.color,fadeIn:e.fadeIn,audioBuffer:e.audioBuffer,waveformData:e.waveformData}),i=Ma({startSample:t,durationSamples:r,offsetSamples:e.offsetSamples+n,sampleRate:e.sampleRate,sourceDurationSamples:e.sourceDurationSamples,gain:e.gain,name:a,color:e.color,fadeOut:e.fadeOut,audioBuffer:e.audioBuffer,waveformData:e.waveformData});return{left:o,right:i}}function yc(e,t,n){const r=e.startSample+e.durationSamples;if(t<=e.startSample||t>=r)return!1;const s=t-e.startSample,a=r-t;return s>=n&&a>=n}function da(e){let t=0;for(const n of e)for(const r of n.clips){const a=(r.startSample+r.durationSamples)/r.sampleRate;t=Math.max(t,a)}return t}function wh(e,t){if(t.length===0)return 0;let n=0,r=Math.abs(t[0]-e);for(let s=1;s<t.length;s++){const a=Math.abs(t[s]-e);a<r&&(r=a,n=s)}return n}function gl(e,t){return Math.max(0,Math.min(e,t))}var _h=44100,xh=1024,Ch=[256,512,1024,2048,4096,8192],vl=.1,Sh=class{constructor(e={}){if(this._tracks=[],this._currentTime=0,this._playStartPosition=0,this._isPlaying=!1,this._selectedTrackId=null,this._selectionStart=0,this._selectionEnd=0,this._masterVolume=1,this._loopStart=0,this._loopEnd=0,this._isLoopEnabled=!1,this._tracksVersion=0,this._animFrameId=null,this._disposed=!1,this._listeners=new Map,this._sampleRate=e.sampleRate??_h,this._zoomLevels=[...e.zoomLevels??Ch],this._adapter=e.adapter??null,this._zoomLevels.length===0)throw new Error("PlaylistEngine: zoomLevels must not be empty");const t=e.samplesPerPixel??xh,n=this._zoomLevels.indexOf(t);if(n===-1)throw new Error(`PlaylistEngine: samplesPerPixel ${t} is not in zoomLevels [${this._zoomLevels.join(", ")}]. Either pass a samplesPerPixel value that exists in zoomLevels, or include ${t} in your zoomLevels array.`);this._zoomIndex=n}getState(){return{tracks:this._tracks.map(e=>({...e,clips:[...e.clips]})),tracksVersion:this._tracksVersion,duration:da(this._tracks),currentTime:this._currentTime,isPlaying:this._isPlaying,samplesPerPixel:this._zoomLevels[this._zoomIndex],sampleRate:this._sampleRate,selectedTrackId:this._selectedTrackId,zoomIndex:this._zoomIndex,canZoomIn:this._zoomIndex>0,canZoomOut:this._zoomIndex<this._zoomLevels.length-1,selectionStart:this._selectionStart,selectionEnd:this._selectionEnd,masterVolume:this._masterVolume,loopStart:this._loopStart,loopEnd:this._loopEnd,isLoopEnabled:this._isLoopEnabled}}setTracks(e){this._tracks=[...e],this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}addTrack(e){this._tracks=[...this._tracks,e],this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}removeTrack(e){this._tracks.some(t=>t.id===e)&&(this._tracks=this._tracks.filter(t=>t.id!==e),this._tracksVersion++,this._selectedTrackId===e&&(this._selectedTrackId=null),this._adapter?.setTracks(this._tracks),this._emitStateChange())}selectTrack(e){e!==this._selectedTrackId&&(this._selectedTrackId=e,this._emitStateChange())}moveClip(e,t,n){const r=this._tracks.find(c=>c.id===e);if(!r){console.warn(`[waveform-playlist/engine] moveClip: track "${e}" not found`);return}const s=r.clips.findIndex(c=>c.id===t);if(s===-1){console.warn(`[waveform-playlist/engine] moveClip: clip "${t}" not found in track "${e}"`);return}const a=r.clips[s],o=ll(r.clips),i=o.findIndex(c=>c.id===t),l=gc(a,n,o,i);l!==0&&(this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=c.clips.map((f,m)=>m===s?{...f,startSample:Math.floor(f.startSample+l)}:f);return{...c,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}splitClip(e,t,n){const r=this._tracks.find(c=>c.id===e);if(!r){console.warn(`[waveform-playlist/engine] splitClip: track "${e}" not found`);return}const s=r.clips.findIndex(c=>c.id===t);if(s===-1){console.warn(`[waveform-playlist/engine] splitClip: clip "${t}" not found in track "${e}"`);return}const a=r.clips[s],o=Math.floor(vl*this._sampleRate);if(!yc(a,n,o)){console.warn(`[waveform-playlist/engine] splitClip: cannot split clip "${t}" at sample ${n} (clip range: ${a.startSample}–${a.startSample+a.durationSamples}, minDuration: ${o})`);return}const{left:i,right:l}=bh(a,n);this._tracks=this._tracks.map(c=>{if(c.id!==e)return c;const u=[...c.clips];return u.splice(s,1,i,l),{...c,clips:u}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange()}trimClip(e,t,n,r){const s=this._tracks.find(f=>f.id===e);if(!s){console.warn(`[waveform-playlist/engine] trimClip: track "${e}" not found`);return}const a=s.clips.findIndex(f=>f.id===t);if(a===-1){console.warn(`[waveform-playlist/engine] trimClip: clip "${t}" not found in track "${e}"`);return}const o=s.clips[a],i=ll(s.clips),l=i.findIndex(f=>f.id===t),c=Math.floor(vl*this._sampleRate),u=vc(o,r,n,i,l,c);u!==0&&(this._tracks=this._tracks.map(f=>{if(f.id!==e)return f;const m=f.clips.map((d,h)=>h!==a?d:n==="left"?{...d,startSample:d.startSample+u,offsetSamples:d.offsetSamples+u,durationSamples:d.durationSamples-u}:{...d,durationSamples:d.durationSamples+u});return{...f,clips:m}}),this._tracksVersion++,this._adapter?.setTracks(this._tracks),this._emitStateChange())}async init(){this._adapter&&await this._adapter.init()}play(e,t){const n=this._currentTime,r=this._playStartPosition;if(e!==void 0){const s=da(this._tracks);this._currentTime=gl(e,s)}if(this._playStartPosition=this._currentTime,this._adapter){if(t!==void 0)this._adapter.setLoop(!1,this._loopStart,this._loopEnd);else if(this._isLoopEnabled){const s=this._currentTime<this._loopEnd;this._adapter.setLoop(s,this._loopStart,this._loopEnd)}try{this._adapter.play(this._currentTime,t)}catch(s){throw this._currentTime=n,this._playStartPosition=r,s}}this._isPlaying=!0,this._startTimeUpdateLoop(),this._emit("play"),this._emitStateChange()}pause(){this._isPlaying=!1,this._stopTimeUpdateLoop(),this._adapter?.pause(),this._adapter&&(this._currentTime=this._adapter.getCurrentTime()),this._emit("pause"),this._emitStateChange()}stop(){this._isPlaying=!1,this._currentTime=this._playStartPosition,this._stopTimeUpdateLoop(),this._adapter?.setLoop(!1,this._loopStart,this._loopEnd),this._adapter?.stop(),this._emit("stop"),this._emitStateChange()}seek(e){const t=da(this._tracks);this._currentTime=gl(e,t),this._adapter?.seek(this._currentTime),this._emitStateChange()}setMasterVolume(e){e!==this._masterVolume&&(this._masterVolume=e,this._adapter?.setMasterVolume(e),this._emitStateChange())}getCurrentTime(){return this._isPlaying&&this._adapter?this._adapter.getCurrentTime():this._currentTime}setSelection(e,t){const n=Math.min(e,t),r=Math.max(e,t);n===this._selectionStart&&r===this._selectionEnd||(this._selectionStart=n,this._selectionEnd=r,this._emitStateChange())}setLoopRegion(e,t){const n=Math.min(e,t),r=Math.max(e,t);n===this._loopStart&&r===this._loopEnd||(this._loopStart=n,this._loopEnd=r,this._adapter?.setLoop(this._isLoopEnabled&&this._isBeforeLoopEnd(),this._loopStart,this._loopEnd),this._emitStateChange())}setLoopEnabled(e){e!==this._isLoopEnabled&&(this._isLoopEnabled=e,this._adapter?.setLoop(e&&this._isBeforeLoopEnd(),this._loopStart,this._loopEnd),this._emitStateChange())}setTrackVolume(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.volume=t),this._adapter?.setTrackVolume(e,t)}setTrackMute(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.muted=t),this._adapter?.setTrackMute(e,t)}setTrackSolo(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.soloed=t),this._adapter?.setTrackSolo(e,t)}setTrackPan(e,t){const n=this._tracks.find(r=>r.id===e);n&&(n.pan=t),this._adapter?.setTrackPan(e,t)}zoomIn(){this._zoomIndex>0&&(this._zoomIndex--,this._emitStateChange())}zoomOut(){this._zoomIndex<this._zoomLevels.length-1&&(this._zoomIndex++,this._emitStateChange())}setZoomLevel(e){const t=wh(e,this._zoomLevels);t!==this._zoomIndex&&(this._zoomIndex=t,this._emitStateChange())}on(e,t){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(t)}off(e,t){this._listeners.get(e)?.delete(t)}dispose(){if(!this._disposed){this._disposed=!0,this._stopTimeUpdateLoop();try{this._adapter?.dispose()}catch(e){console.warn("[waveform-playlist/engine] Error disposing adapter:",e)}this._listeners.clear()}}_emit(e,...t){const n=this._listeners.get(e);if(n)for(const r of n)try{r(...t)}catch(s){console.warn("[waveform-playlist/engine] Error in event listener:",s)}}_isBeforeLoopEnd(){return this._isPlaying?(this._adapter?.getCurrentTime()??this._currentTime)<this._loopEnd:!0}_emitStateChange(){this._emit("statechange",this.getState())}_startTimeUpdateLoop(){if(typeof requestAnimationFrame>"u")return;this._stopTimeUpdateLoop();const e=()=>{this._disposed||!this._isPlaying||(this._adapter&&(this._currentTime=this._adapter.getCurrentTime(),this._emit("timeupdate",this._currentTime)),this._animFrameId=requestAnimationFrame(e))};this._animFrameId=requestAnimationFrame(e)}_stopTimeUpdateLoop(){this._animFrameId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this._animFrameId),this._animFrameId=null)}},kh=Symbol.for("preact-signals");function zs(){if(Yt>1)Yt--;else{for(var e,t=!1;fr!==void 0;){var n=fr;for(fr=void 0,Ra++;n!==void 0;){var r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&wc(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(Ra=0,Yt--,t)throw e}}function Kt(e){if(Yt>0)return e();Yt++;try{return e()}finally{zs()}}var ye=void 0;function we(e){var t=ye;ye=void 0;try{return e()}finally{ye=t}}var fr=void 0,Yt=0,Ra=0,_s=0;function bc(e){if(ye!==void 0){var t=e.n;if(t===void 0||t.t!==ye)return t={i:0,S:e,p:ye.s,n:void 0,t:ye,e:void 0,x:void 0,r:t},ye.s!==void 0&&(ye.s.n=t),ye.s=t,e.n=t,32&ye.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ye.s,t.n=void 0,ye.s.n=t,ye.s=t),t}}function at(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}at.prototype.brand=kh;at.prototype.h=function(){return!0};at.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:we(function(){var r;(r=t.W)==null||r.call(t)}))};at.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&we(function(){var s;(s=t.Z)==null||s.call(t)}))}};at.prototype.subscribe=function(e){var t=this;return _t(function(){var n=t.value,r=ye;ye=void 0;try{e(n)}finally{ye=r}},{name:"sub"})};at.prototype.valueOf=function(){return this.value};at.prototype.toString=function(){return this.value+""};at.prototype.toJSON=function(){return this.value};at.prototype.peek=function(){var e=ye;ye=void 0;try{return this.value}finally{ye=e}};Object.defineProperty(at.prototype,"value",{get:function(){var e=bc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ra>100)throw new Error("Cycle detected");this.v=e,this.i++,_s++,Yt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{zs()}}}});function Ar(e,t){return new at(e,t)}function wc(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function _c(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function xc(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function pn(e,t){at.call(this,void 0),this.x=e,this.s=void 0,this.g=_s-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}pn.prototype=new at;pn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===_s))return!0;if(this.g=_s,this.f|=1,this.i>0&&!wc(this))return this.f&=-2,!0;var e=ye;try{_c(this),ye=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ye=e,xc(this),this.f&=-2,!0};pn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}at.prototype.S.call(this,e)};pn.prototype.U=function(e){if(this.t!==void 0&&(at.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};pn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(pn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=bc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function yl(e,t){return new pn(e,t)}function Cc(e){var t=e.u;if(e.u=void 0,typeof t=="function"){Yt++;var n=ye;ye=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,wo(e),r}finally{ye=n,zs()}}}function wo(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Cc(e)}function Eh(e){if(ye!==this)throw new Error("Out-of-order effect");xc(this),ye=e,this.f&=-2,8&this.f&&wo(this),zs()}function zn(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t?.name}zn.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};zn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Cc(this),_c(this),Yt++;var e=ye;return ye=this,Eh.bind(this,e)};zn.prototype.N=function(){2&this.f||(this.f|=2,this.o=fr,fr=this)};zn.prototype.d=function(){this.f|=8,1&this.f||wo(this)};zn.prototype.dispose=function(){this.d()};function _t(e,t){var n=new zn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Ih=Object.create,_o=Object.defineProperty,Mh=Object.defineProperties,Ah=Object.getOwnPropertyDescriptor,Th=Object.getOwnPropertyDescriptors,bl=Object.getOwnPropertySymbols,$h=Object.prototype.hasOwnProperty,Rh=Object.prototype.propertyIsEnumerable,Dh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),jn=e=>{throw TypeError(e)},Da=(e,t,n)=>t in e?_o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ph=(e,t)=>{for(var n in t||(t={}))$h.call(t,n)&&Da(e,n,t[n]);if(bl)for(var n of bl(t))Rh.call(t,n)&&Da(e,n,t[n]);return e},Fh=(e,t)=>Mh(e,Th(t)),wl=(e,t)=>_o(e,"name",{value:t,configurable:!0}),Oh=e=>{var t;return[,,,Ih((t=void 0)!=null?t:null)]},Sc=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?jn("Function expected"):e,Lh=(e,t,n,r,s)=>({kind:Sc[e],name:t,metadata:r,addInitializer:a=>n._?jn("Already initialized"):s.push(tr(a||null))}),kc=(e,t)=>Da(t,Dh("metadata"),e[3]),nn=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},Zn=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,v=Sc[f+5],g=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&Ah(f<4?s:{get[n](){return un(this,a)},set[n](w){return Gt(this,a,w)}},n));f?d&&f<4&&wl(a,(f>2?"set ":f>1?"get ":"")+n):wl(s,n);for(var _=r.length-1;_>=0;_--)c=Lh(f,n,l={},e[3],y),f&&(c.static=m,c.private=d,u=c.access={has:d?w=>Bh(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?un:Wh)(w,s,f^4?a:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>Gt(w,s,x,f^4?a:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?tr(i)&&(f>4?g.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?jn("Object expected"):(tr(o=i.get)&&(b.get=o),tr(o=i.set)&&(b.set=o),tr(o=i.init)&&g.unshift(o));return f||kc(e,s),b&&_o(s,n,b),d?f^4?a:b:s},xo=(e,t,n)=>t.has(e)||jn("Cannot "+n),Bh=(e,t)=>Object(t)!==t?jn('Cannot use the "in" operator on this value'):e.has(t),un=(e,t,n)=>(xo(e,t,"read from private field"),n?n.call(e):t.get(e)),es=(e,t,n)=>t.has(e)?jn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Gt=(e,t,n,r)=>(xo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Wh=(e,t,n)=>(xo(e,t,"access private method"),n);function xs(e,t){if(t){let n;return yl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return yl(e)}function br(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((r,s)=>!br(r,t[s]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(a=>!br(e[a],t[a]))}return!1}function he({get:e},t){return{init(n){return Ar(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Pe(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=xs(e.bind(this)),n.set(this,r)),r.value}}function fa(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),s=Object.getOwnPropertyDescriptor(r,n.name);s&&Object.defineProperty(r,n.name,Fh(Ph({},s),{enumerable:e}))})}}function Tr(...e){const t=e.map(n=>_t(n));return()=>t.forEach(n=>n())}var Ec,Ic,Mc,Ac,Tc,$c,nt,Co,ha,Pa,Fa,Qe,So,pa,Rc,Oa,ko,ma,La,Ba;$c=[he],Tc=[he],Ac=[he],Mc=[fa()],Ic=[fa()],Ec=[fa()];var Jt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,nn(nt,5,this),es(this,Qe),es(this,Co,nn(nt,8,this)),nn(nt,11,this),es(this,So,nn(nt,12,this)),nn(nt,15,this),es(this,ko,nn(nt,16,this)),nn(nt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return un(this,Qe,La)}get initial(){return un(this,Qe,Pa)}get previous(){return un(this,Qe,Rc)}set current(e){const t=we(()=>un(this,Qe,La));e&&t&&this.equals(t,e)||Kt(()=>{un(this,Qe,Pa)||Gt(this,Qe,e,Fa),Gt(this,Qe,t,Oa),Gt(this,Qe,e,Ba)})}reset(e=this.defaultValue){Kt(()=>{Gt(this,Qe,void 0,Oa),Gt(this,Qe,e,Fa),Gt(this,Qe,e,Ba)})}};nt=Oh();Co=new WeakMap;Qe=new WeakSet;So=new WeakMap;ko=new WeakMap;ha=Zn(nt,20,"#initial",$c,Qe,Co),Pa=ha.get,Fa=ha.set;pa=Zn(nt,20,"#previous",Tc,Qe,So),Rc=pa.get,Oa=pa.set;ma=Zn(nt,20,"#current",Ac,Qe,ko),La=ma.get,Ba=ma.set;Zn(nt,2,"current",Mc,Jt);Zn(nt,2,"initial",Ic,Jt);Zn(nt,2,"previous",Ec,Jt);kc(nt,Jt);function ga(e){return we(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Vh=Object.create,Dc=Object.defineProperty,Nh=Object.getOwnPropertyDescriptor,_l=Object.getOwnPropertySymbols,zh=Object.prototype.hasOwnProperty,jh=Object.prototype.propertyIsEnumerable,Pc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),js=e=>{throw TypeError(e)},xl=Math.pow,Wa=(e,t,n)=>t in e?Dc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zh=(e,t)=>{for(var n in t||(t={}))zh.call(t,n)&&Wa(e,n,t[n]);if(_l)for(var n of _l(t))jh.call(t,n)&&Wa(e,n,t[n]);return e},Hh=e=>{var t;return[,,,Vh((t=e?.[Pc("metadata")])!=null?t:null)]},Fc=["class","method","getter","setter","accessor","field","value","get","set"],Oc=e=>e!==void 0&&typeof e!="function"?js("Function expected"):e,Gh=(e,t,n,r,s)=>({kind:Fc[e],name:t,metadata:r,addInitializer:a=>n._?js("Already initialized"):s.push(Oc(a||null))}),Uh=(e,t)=>Wa(t,Pc("metadata"),e[3]),Xh=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},Lc=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=Fc[u+5],v=e[d]||(e[d]=[]),g=(s=s.prototype,Nh(s,n)),y=r.length-1;y>=0;y--)l=Gh(u,n,i={},e[3],v),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(g[h],l),i._=1,Oc(o)&&(g[h]=o);return g&&Dc(s,n,g),s},Bc=(e,t,n)=>t.has(e)||js("Cannot "+n),Yh=(e,t,n)=>(Bc(e,t,"read from private field"),t.get(e)),Kh=(e,t,n)=>t.has(e)?js("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qh=(e,t,n,r)=>(Bc(e,t,"write to private field"),t.set(e,n),n),Tt=class Va{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Va(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Va(t,n)}},$r=class sn{constructor(t,n,r,s){this.left=t,this.top=n,this.width=r,this.height=s,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:s,width:a,height:o,scale:i}=this,l=new sn(s+t,r+n,a,o);return l.scale=Zh({},i),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:a,bottom:o}=this;return{width:t,height:n,left:r,top:s,right:a,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new Tt((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof sn))return!1;const{left:n,top:r,width:s,height:a}=this;return n===t.left&&r===t.top&&s===t.width&&a===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:a}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=a}intersectionArea(t){return t instanceof sn?Jh(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:s}){return new sn(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(a,o)=>{const i=r[o],l=o==="x"?a.left:a.top,c=o==="x"?a.width:a.height;return i=="start"?l:i=="end"?l+c:l+c/2};return Tt.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return sn.from(t).intersectionRatio(sn.from(n))}};function Jh(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=s-r,i=a-n;return r<s&&n<a?o*i:0}var Wc,Vc,Na,ls,Rr,Zs=class extends(Na=Jt,Vc=[Pe],Wc=[Pe],Na){constructor(t){const n=Tt.from(t);super(n,(r,s)=>Tt.equals(r,s)),Xh(Rr,5,this),Kh(this,ls,0),this.velocity={x:0,y:0}}get delta(){return Tt.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Tt.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-Yh(this,ls),i=l=>Math.round(l/o*100);Kt(()=>{qh(this,ls,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Tt.from(t)),this.velocity={x:0,y:0}}};Rr=Hh(Na);ls=new WeakMap;Lc(Rr,2,"delta",Vc,Zs);Lc(Rr,2,"direction",Wc,Zs);Uh(Rr,Zs);function za({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(xl(r,2)+xl(s,2))>n:"x"in n&&"y"in n?r>n.x&&s>n.y:"x"in n?r>n.x:"y"in n?s>n.y:!1}var Nc=(e=>(e.Horizontal="x",e.Vertical="y",e))(Nc||{}),zc=Object.values(Nc),Qh=Object.create,Eo=Object.defineProperty,ep=Object.defineProperties,tp=Object.getOwnPropertyDescriptor,np=Object.getOwnPropertyDescriptors,Cs=Object.getOwnPropertySymbols,jc=Object.prototype.hasOwnProperty,Zc=Object.prototype.propertyIsEnumerable,Hc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Hn=e=>{throw TypeError(e)},ja=(e,t,n)=>t in e?Eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gc=(e,t)=>{for(var n in t||(t={}))jc.call(t,n)&&ja(e,n,t[n]);if(Cs)for(var n of Cs(t))Zc.call(t,n)&&ja(e,n,t[n]);return e},Uc=(e,t)=>ep(e,np(t)),Cl=(e,t)=>Eo(e,"name",{value:t,configurable:!0}),Xc=(e,t)=>{var n={};for(var r in e)jc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Cs)for(var r of Cs(e))t.indexOf(r)<0&&Zc.call(e,r)&&(n[r]=e[r]);return n},Gn=e=>{var t;return[,,,Qh((t=e?.[Hc("metadata")])!=null?t:null)]},Yc=["class","method","getter","setter","accessor","field","value","get","set"],nr=e=>e!==void 0&&typeof e!="function"?Hn("Function expected"):e,rp=(e,t,n,r,s)=>({kind:Yc[e],name:t,metadata:r,addInitializer:a=>n._?Hn("Already initialized"):s.push(nr(a||null))}),mn=(e,t)=>ja(t,Hc("metadata"),e[3]),se=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},fe=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,v=Yc[f+5],g=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&tp(f<4?s:{get[n](){return Ze(this,a)},set[n](w){return yt(this,a,w)}},n));f?d&&f<4&&Cl(a,(f>2?"set ":f>1?"get ":"")+n):Cl(s,n);for(var _=r.length-1;_>=0;_--)c=rp(f,n,l={},e[3],y),f&&(c.static=m,c.private=d,u=c.access={has:d?w=>sp(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?Ze:ap)(w,s,f^4?a:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>yt(w,s,x,f^4?a:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?nr(i)&&(f>4?g.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?Hn("Object expected"):(nr(o=i.get)&&(b.get=o),nr(o=i.set)&&(b.set=o),nr(o=i.init)&&g.unshift(o));return f||mn(e,s),b&&Eo(s,n,b),d?f^4?a:b:s},Io=(e,t,n)=>t.has(e)||Hn("Cannot "+n),sp=(e,t)=>Object(t)!==t?Hn('Cannot use the "in" operator on this value'):e.has(t),Ze=(e,t,n)=>(Io(e,t,"read from private field"),n?n.call(e):t.get(e)),be=(e,t,n)=>t.has(e)?Hn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),yt=(e,t,n,r)=>(Io(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ap=(e,t,n)=>(Io(e,t,"access private method"),n);function Kc(e,t){return{plugin:e,options:t}}function gn(e){return t=>Kc(e,t)}function Mo(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var qc,wr,Ao,cs;qc=[he];var dt=class{constructor(e,t){this.manager=e,this.options=t,be(this,Ao,se(wr,8,this,!1)),se(wr,11,this),be(this,cs,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return we(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=_t(e.bind(this));return Ze(this,cs).add(t),t}destroy(){Ze(this,cs).forEach(e=>e())}static configure(e){return Kc(this,e)}};wr=Gn(null);Ao=new WeakMap;cs=new WeakMap;fe(wr,4,"disabled",qc,dt,Ao);mn(wr,dt);var Dr=class extends dt{},us,va=class{constructor(e){this.manager=e,this.instances=new Map,be(this,us,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(Mo).reduceRight((r,s)=>r.some(({plugin:a})=>a===s.plugin)?r:[s,...r],[]),n=t.map(({plugin:r})=>r);for(const r of Ze(this,us))if(!n.includes(r)){if(r.prototype instanceof Dr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);yt(this,us,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};us=new WeakMap;function op(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var ts=[],En,In,ip=class extends dt{constructor(e){super(e),be(this,En),be(this,In),this.computeCollisions=this.computeCollisions.bind(this),yt(this,In,Ar(ts)),this.destroy=Tr(()=>{const t=this.computeCollisions(),n=we(()=>this.manager.dragOperation.position.current);if(t!==ts){const r=Ze(this,En);if(yt(this,En,n),r&&n.x==r.x&&n.y==r.y)return}else yt(this,En,void 0);Ze(this,In).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){we(()=>{e?Ze(this,In).value=this.computeCollisions():yt(this,En,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:a,status:o}=r;if(!o.initialized||!a)return ts;const i=[],l=[];for(const c of e??n.droppables){if(c.disabled||s&&!c.accepts(s))continue;const u=t??c.collisionDetector;if(!u)continue;l.push(c),c.shape;const f=we(()=>u({droppable:c,dragOperation:r}));f&&(c.collisionPriority!=null&&(f.priority=c.collisionPriority),i.push(f))}return l.length===0?ts:(i.sort(op),i)}get collisions(){return Ze(this,In).value}};En=new WeakMap;In=new WeakMap;var lp=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const s of r)s(...t)}},cp=class extends lp{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ds(e,t=!0){let n=!1;return Uc(Gc({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var up=class extends Dr{constructor(e){super(e);const t=(r,s)=>r.map(({id:a})=>a).join("")===s.map(({id:a})=>a).join("");let n=[];this.destroy=Tr(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:a}=r;if(r.isDisabled())return;const o=ds({collisions:a});if(s.dispatch("collision",o),o.defaultPrevented||t(a,n))return;n=a;const[i]=a;we(()=>{var l;i?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(i?.id).then(()=>{r.enable()}))})})}},To=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(To||{}),$o=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))($o||{}),Jc,Qc,eu,tu,nu,ru,su,wt,Ro;su=[he],ru=[Pe],nu=[Pe],tu=[Pe],eu=[Pe],Qc=[Pe],Jc=[Pe];var Vt=class{constructor(){se(wt,5,this),be(this,Ro,se(wt,8,this,"idle")),se(wt,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};wt=Gn(null);Ro=new WeakMap;fe(wt,4,"value",su,Vt,Ro);fe(wt,2,"current",ru,Vt);fe(wt,2,"idle",nu,Vt);fe(wt,2,"initializing",tu,Vt);fe(wt,2,"initialized",eu,Vt);fe(wt,2,"dragging",Qc,Vt);fe(wt,2,"dropped",Jc,Vt);mn(wt,Vt);var dp=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return we(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=ds({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return we(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const r=new AbortController,{event:s,coordinates:a}=e;Kt(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(a)});const o=ds({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:i}=t;i.current==="initializing"&&(t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1}))}),r)})}move(e){return we(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:a}=r;if(!s.dragging||!a||a.signal.aborted)return;const o=ds({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var i,l,c,u,f;if(o.defaultPrevented)return;const m=(f=e.to)!=null?f:{x:r.position.current.x+((l=(i=e.by)==null?void 0:i.x)!=null?l:0),y:r.position.current.y+((u=(c=e.by)==null?void 0:c.y)!=null?u:0)};r.position.current=m})})}stop(e={}){return we(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let a;const o=()=>{const l={resume:()=>{},abort:()=>{}};return a=new Promise((c,u)=>{l.resume=c,l.abort=u}),l};s.abort();const i=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=we(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),c=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:u}=r,f=_t(()=>{u?.status==="idle"&&(f(),c())})}else this.manager.renderer.rendering.then(c)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),a?a.then(i).catch(()=>r.reset()):i()})}},au,ou,iu,lu,ut,Do,Po,Fo,Oo;lu=[he],iu=[he],ou=[he],au=[he];var Qt=class{constructor(e,t){be(this,Do,se(ut,8,this)),se(ut,11,this),be(this,Po,se(ut,12,this)),se(ut,15,this),be(this,Fo,se(ut,16,this)),se(ut,19,this),be(this,Oo,se(ut,20,this)),se(ut,23,this);const{effects:n,id:r,data:s={},disabled:a=!1,register:o=!0}=e;let i=r;this.manager=t,this.id=r,this.data=s,this.disabled=a,this.effects=()=>{var l;return[()=>{const{id:c,manager:u}=this;if(c!==i)return u?.registry.register(this),()=>u?.registry.unregister(this)},...(l=n?.())!=null?l:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),t&&o&&queueMicrotask(this.register)}register(){var e;return(e=this.manager)==null?void 0:e.registry.register(this)}unregister(){var e;(e=this.manager)==null||e.registry.unregister(this)}destroy(){var e;(e=this.manager)==null||e.registry.unregister(this)}};ut=Gn(null);Do=new WeakMap;Po=new WeakMap;Fo=new WeakMap;Oo=new WeakMap;fe(ut,4,"manager",lu,Qt,Do);fe(ut,4,"id",iu,Qt,Po);fe(ut,4,"data",ou,Qt,Fo);fe(ut,4,"disabled",au,Qt,Oo);mn(ut,Qt);var Sl=class{constructor(){this.map=Ar(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,t);if(r===t)return s;if(r){const i=this.cleanupFunctions.get(r);i?.(),this.cleanupFunctions.delete(r)}const a=new Map(n);a.set(e,t),this.map.value=a;const o=Tr(...t.effects());return this.cleanupFunctions.set(t,o),s},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const s=new Map(n);s.delete(e),this.map.value=s}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},cu,uu,du,fu,hu,pu,Za,rt,Lo,Bo,Wo,$t=class extends(Za=Qt,pu=[he],hu=[he],fu=[he],du=[Pe],uu=[Pe],cu=[Pe],Za){constructor(t,n){var r=t,{modifiers:s,type:a,sensors:o}=r,i=Xc(r,["modifiers","type","sensors"]);super(i,n),se(rt,5,this),be(this,Lo,se(rt,8,this)),se(rt,11,this),be(this,Bo,se(rt,12,this)),se(rt,15,this),be(this,Wo,se(rt,16,this,this.isDragSource?"dragging":"idle")),se(rt,19,this),this.type=a,this.sensors=o,this.modifiers=s,this.alignment=i.alignment}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};rt=Gn(Za);Lo=new WeakMap;Bo=new WeakMap;Wo=new WeakMap;fe(rt,4,"type",pu,$t,Lo);fe(rt,4,"modifiers",hu,$t,Bo);fe(rt,4,"status",fu,$t,Wo);fe(rt,2,"isDropping",du,$t);fe(rt,2,"isDragging",uu,$t);fe(rt,2,"isDragSource",cu,$t);mn(rt,$t);var mu,gu,vu,yu,bu,wu,Ha,ze,Vo,No,zo,jo,Zo,Rt=class extends(Ha=Qt,wu=[he],bu=[he],yu=[he],vu=[he],gu=[he],mu=[Pe],Ha){constructor(t,n){var r=t,{accept:s,collisionDetector:a,collisionPriority:o,type:i}=r,l=Xc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),se(ze,5,this),be(this,Vo,se(ze,8,this)),se(ze,11,this),be(this,No,se(ze,12,this)),se(ze,15,this),be(this,zo,se(ze,16,this)),se(ze,19,this),be(this,jo,se(ze,20,this)),se(ze,23,this),be(this,Zo,se(ze,24,this)),se(ze,27,this),this.accept=s,this.collisionDetector=a,this.collisionPriority=o,this.type=i}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};ze=Gn(Ha);Vo=new WeakMap;No=new WeakMap;zo=new WeakMap;jo=new WeakMap;Zo=new WeakMap;fe(ze,4,"accept",wu,Rt,Vo);fe(ze,4,"type",bu,Rt,No);fe(ze,4,"collisionDetector",yu,Rt,zo);fe(ze,4,"collisionPriority",vu,Rt,jo);fe(ze,4,"shape",gu,Rt,Zo);fe(ze,2,"isDropTarget",mu,Rt);mn(ze,Rt);var Fn=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},fp=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},fs,_u=class{constructor(e){this.options=e,be(this,fs)}set controller(e){yt(this,fs,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ze(this,fs))==null||t.activate(e)}};fs=new WeakMap;var On=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},hp=class{constructor(e){this.draggables=new Sl,this.droppables=new Sl,this.plugins=new va(e),this.sensors=new va(e),this.modifiers=new va(e)}register(e,t){if(e instanceof $t)return this.draggables.register(e.id,e);if(e instanceof Rt)return this.droppables.register(e.id,e);if(e.prototype instanceof On)return this.modifiers.register(e,t);if(e.prototype instanceof Fn)return this.sensors.register(e,t);if(e.prototype instanceof dt)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Qt)return e instanceof $t?this.draggables.unregister(e.id,e):e instanceof Rt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof On)return this.modifiers.unregister(e);if(e.prototype instanceof Fn)return this.sensors.unregister(e);if(e.prototype instanceof dt)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},xu,Cu,Su,ku,Eu,Iu,Mu,Au,Tu,rr,hs,Mn,Fe,Ho,Go,Uo,Xo,Yo,sr;Tu=[Pe],Au=[he],Mu=[he],Iu=[he],Eu=[he],ku=[he],Su=[Pe],Cu=[Pe],xu=[Pe];var Mt=class{constructor(e){se(Fe,5,this),be(this,rr),be(this,hs),be(this,Mn,new Jt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Vt,be(this,Ho,se(Fe,8,this,!1)),se(Fe,11,this),be(this,Go,se(Fe,12,this,null)),se(Fe,15,this),be(this,Uo,se(Fe,16,this,null)),se(Fe,19,this),be(this,Xo,se(Fe,20,this,null)),se(Fe,23,this),be(this,Yo,se(Fe,24,this,[])),se(Fe,27,this),this.position=new Zs({x:0,y:0}),be(this,sr,{x:0,y:0}),yt(this,rr,e)}get shape(){const{current:e,initial:t,previous:n}=Ze(this,Mn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ze(this,Mn).current=e:Ze(this,Mn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ze(this,rr).registry.draggables.get(t);return n&&yt(this,hs,n),(e=n??Ze(this,hs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ze(this,rr).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(Uc(Gc({},this.snapshot()),{transform:n}));return yt(this,sr,n),n}snapshot(){return we(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ze(this,sr),shape:this.shape?ga(this.shape):null,position:ga(this.position),status:ga(this.status),canceled:this.canceled}))}reset(){Kt(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ze(this,Mn).reset(),this.position.reset({x:0,y:0}),yt(this,sr,{x:0,y:0}),this.modifiers=[]})}};Fe=Gn(null);rr=new WeakMap;hs=new WeakMap;Mn=new WeakMap;Ho=new WeakMap;Go=new WeakMap;Uo=new WeakMap;Xo=new WeakMap;Yo=new WeakMap;sr=new WeakMap;fe(Fe,2,"shape",Tu,Mt);fe(Fe,4,"canceled",Au,Mt,Ho);fe(Fe,4,"activatorEvent",Mu,Mt,Go);fe(Fe,4,"sourceIdentifier",Iu,Mt,Uo);fe(Fe,4,"targetIdentifier",Eu,Mt,Xo);fe(Fe,4,"modifiers",ku,Mt,Yo);fe(Fe,2,"source",Su,Mt);fe(Fe,2,"target",Cu,Mt);fe(Fe,2,"transform",xu,Mt);mn(Fe,Mt);var pp={get rendering(){return Promise.resolve()}};function Lt(e,t){return typeof e=="function"?e(t):e??t}var mp=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(m=>m.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=Lt(r.plugins,[]),a=Lt(r.sensors,[]),o=Lt(r.modifiers,[]),i=(n=r.renderer)!=null?n:pp,l=new cp(this),c=new hp(this);this.registry=c,this.monitor=l,this.renderer=i,this.actions=new dp(this),this.dragOperation=new Mt(this),this.collisionObserver=new ip(this),this.plugins=[up,...s],this.modifiers=o,this.sensors=a;const{destroy:u}=this,f=Tr(()=>{var m,d,h;const v=we(()=>this.dragOperation.modifiers),g=this.modifiers;for(const y of v)g.includes(y)||y.destroy();this.dragOperation.modifiers=(h=(d=(m=this.dragOperation.source)==null?void 0:m.modifiers)==null?void 0:d.map(y=>{const{plugin:b,options:_}=Mo(y);return new b(this,_)}))!=null?h:g});this.destroy=()=>{f(),u()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},$u=e=>{throw TypeError(e)},Ko=(e,t,n)=>t.has(e)||$u("Cannot "+n),ie=(e,t,n)=>(Ko(e,t,"read from private field"),t.get(e)),ct=(e,t,n)=>t.has(e)?$u("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),pt=(e,t,n,r)=>(Ko(e,t,"write to private field"),t.set(e,n),n),Ru=(e,t,n)=>(Ko(e,t,"access private method"),n);function Hs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function gp(e,t){const n=e.getAnimations();if(n.length>0)for(const r of n){if(r.playState!=="running")continue;const{effect:s}=r,o=(Hs(s)?s.getKeyframes():[]).filter(t);if(o.length>0)return[o[o.length-1],r]}return null}function Gs(e){const{width:t,height:n,top:r,left:s,bottom:a,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:a,right:o}}function qo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Pr(e){return"nodeType"in e}function xt(e){var t,n,r;return e?qo(e)?e:Pr(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function Jo(e){const{Document:t}=xt(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function dn(e){return!e||qo(e)?!1:e instanceof xt(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Du(e){return e instanceof xt(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function vn(e){return e?qo(e)?e.document:Pr(e)?Jo(e)?e:dn(e)||Du(e)?e.ownerDocument:document:document:document}function vp(e){var t,n,r,s;const{documentElement:a}=vn(e),o=xt(e).visualViewport,i=(t=o?.width)!=null?t:a.clientWidth,l=(n=o?.height)!=null?n:a.clientHeight,c=(r=o?.offsetTop)!=null?r:0,u=(s=o?.offsetLeft)!=null?s:0;return{top:c,left:u,right:u+i,bottom:c+l,width:i,height:l}}function yp(e,t){if(bp(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function bp(e){return e.tagName==="DETAILS"}function Ss(e,t=e.getBoundingClientRect(),n=0){var r,s,a,o,i;let l=t;const{ownerDocument:c}=e,u=(r=c.defaultView)!=null?r:window;let f=e.parentElement;for(;f&&f!==c.documentElement;){if(!yp(f)){const _=f.getBoundingClientRect(),w=n*(_.bottom-_.top),x=n*(_.right-_.left),S=n*(_.bottom-_.top),k=n*(_.right-_.left);l={top:Math.max(l.top,_.top-w),right:Math.min(l.right,_.right+x),bottom:Math.min(l.bottom,_.bottom+S),left:Math.max(l.left,_.left-k),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}f=f.parentElement}const m=u.visualViewport,d=(s=m?.offsetTop)!=null?s:0,h=(a=m?.offsetLeft)!=null?a:0,v=(o=m?.width)!=null?o:u.innerWidth,g=(i=m?.height)!=null?i:u.innerHeight,y=n*g,b=n*v;return l={top:Math.max(l.top,d-y),right:Math.min(l.right,h+v+b),bottom:Math.min(l.bottom,d+g+y),left:Math.max(l.left,h-b),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function Ln(e){return{x:e.clientX,y:e.clientY}}var Pu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ga(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const s=r.contentDocument;s&&!t.has(s)&&n.push(...Ga(s,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const s=r.parent;s&&s.document&&s.document!==e&&n.push(...Ga(s.document,t))}}catch{}return n}function Qo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Fu(){var e,t;const n=Qo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function ei(e){return!e||!Pr(e)?!1:e instanceof xt(e).ShadowRoot}function ks(e){if(e&&Pr(e)){let t=e.getRootNode();if(ei(t))return t;if(t instanceof Document)return t}return vn(e)}function Ou(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function wp(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((a,o)=>{const i=r[o];if(kl(a)&&kl(i)&&(a.type!=="file"&&(a.value=i.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),El(a)&&El(i)&&i.width>0&&i.height>0){const l=a.getContext("2d");l?.drawImage(i,0,0)}}),n}function kl(e){return"value"in e}function El(e){return e.tagName==="CANVAS"}function Lu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(_p(r)){const{contentDocument:s}=r;if(s){const{left:a,top:o}=r.getBoundingClientRect();return Lu(s,{x:t-a,y:n-o})}}return r}function _p(e){return e?.tagName==="IFRAME"}var Il=new WeakMap;function xp(e){return!!e.closest(`
|
|
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 Lu=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:s}]=e;t.removeEventListener(n,r,s)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],s=[];for(const a of n)for(const o of r){const{type:i,listener:l,options:c}=o,u=[a,o];a.addEventListener(i,l,c),this.entries.add(u),s.push(u)}return function(){for(const[o,{type:i,listener:l,options:c}]of s)o.removeEventListener(i,l,c)}}};function Bn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function xp(e){const t=new Set;let n=Bn(e);for(;n;)t.add(n),n=Bn(n);return t}function Cp(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Bu(e,t){const n=()=>performance.now();let r,s;return function(...a){const o=this;s?(r?.(),r=Cp(()=>{e.apply(o,a),s=n()},t-(n()-s))):(e.apply(o,a),s=n())}}function Sp(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 kp(e,t=e.getBoundingClientRect()){const{width:n,height:r}=Cs(e,t);return n>0&&r>0}var Ep=Du?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},hs,Ip=class extends Ep{constructor(e){super(t=>{if(!ie(this,hs)){mt(this,hs,!0);return}e(t,this)}),ct(this,hs,!1)}};hs=new WeakMap;var Il=Array.from({length:100},(e,t)=>t/100),Wu=75,an,ks,zt,on,sr,Ue,fr,ar,Es,Vu,Nu,zu=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ct(this,Es),this.disconnect=()=>{var a,o,i;mt(this,fr,!0),(a=ie(this,zt))==null||a.disconnect(),(o=ie(this,on))==null||o.disconnect(),ie(this,sr).disconnect(),(i=ie(this,Ue))==null||i.remove()},ct(this,an,!0),ct(this,ks),ct(this,zt),ct(this,on),ct(this,sr),ct(this,Ue),ct(this,fr,!1),ct(this,ar,Bu(()=>{var a,o,i;const{element:l}=this;if((a=ie(this,on))==null||a.disconnect(),ie(this,fr)||!ie(this,an)||!l.isConnected)return;const c=(o=l.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:f}=(i=c.defaultView)!=null?i:window,m=l.getBoundingClientRect(),d=Cs(l,m),{top:h,left:g,bottom:v,right:y}=d,b=-Math.floor(h),w=-Math.floor(g),_=-Math.floor(f-y),x=-Math.floor(u-v),S=`${b}px ${_}px ${x}px ${w}px`;this.boundingClientRect=m,mt(this,on,new IntersectionObserver(k=>{const[E]=k,{intersectionRect:I}=E;(E.intersectionRatio!==1?E.intersectionRatio:Tr.intersectionRatio(I,Cs(l)))!==1&&ie(this,ar).call(this)},{threshold:Il,rootMargin:S,root:c})),ie(this,on).observe(l),$u(this,Es,Vu).call(this)},Wu)),this.boundingClientRect=e.getBoundingClientRect(),mt(this,an,kp(e,this.boundingClientRect));let r=!0;this.callback=a=>{r&&(r=!1,n.skipInitial)||t(a)};const s=e.ownerDocument;n?.debug&&(mt(this,Ue,document.createElement("div")),ie(this,Ue).style.background="rgba(0,0,0,0.15)",ie(this,Ue).style.position="fixed",ie(this,Ue).style.pointerEvents="none",s.body.appendChild(ie(this,Ue))),mt(this,sr,new IntersectionObserver(a=>{var o,i;const l=a[a.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:f,height:m}=c,d=ie(this,an);mt(this,an,u),!(!f&&!m)&&(d&&!u?((o=ie(this,on))==null||o.disconnect(),this.callback(null),(i=ie(this,zt))==null||i.disconnect(),mt(this,zt,void 0),ie(this,Ue)&&(ie(this,Ue).style.visibility="hidden")):ie(this,ar).call(this),u&&!ie(this,zt)&&(mt(this,zt,new Ip(ie(this,ar))),ie(this,zt).observe(e)))},{threshold:Il,root:s})),ie(this,an)&&!n.skipInitial&&this.callback(this.boundingClientRect),ie(this,sr).observe(e)}};an=new WeakMap;ks=new WeakMap;zt=new WeakMap;on=new WeakMap;sr=new WeakMap;Ue=new WeakMap;fr=new WeakMap;ar=new WeakMap;Es=new WeakSet;Vu=function(){ie(this,fr)||($u(this,Es,Nu).call(this),!Sp(this.boundingClientRect,ie(this,ks))&&(this.callback(this.boundingClientRect),mt(this,ks,this.boundingClientRect)))};Nu=function(){if(ie(this,Ue)){const{top:e,left:t,width:n,height:r}=Cs(this.element);ie(this,Ue).style.overflow="hidden",ie(this,Ue).style.visibility="visible",ie(this,Ue).style.top=`${Math.floor(e)}px`,ie(this,Ue).style.left=`${Math.floor(t)}px`,ie(this,Ue).style.width=`${Math.floor(n)}px`,ie(this,Ue).style.height=`${Math.floor(r)}px`}};var ts=new WeakMap,ns=new WeakMap;function Mp(e,t){let n=ts.get(e);return n||(n={disconnect:new zu(e,s=>{const a=ts.get(e);a&&a.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),ts.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(ts.delete(e),n.disconnect())}}function Ap(e,t){const n=new Set;for(const r of e){const s=Mp(r,t);n.add(s)}return()=>n.forEach(r=>r())}function Tp(e,t){var n;const r=e.ownerDocument;if(!ns.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}),ns.set(r,{disconnect:()=>o.abort(),listeners:i})}const{listeners:s,disconnect:a}=(n=ns.get(r))!=null?n:{};return!s||!a?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(a(),ns.delete(r))})}var or,ir,ps,Ha,$p=class{constructor(e,t,n){this.callback=t,ct(this,or),ct(this,ir,!1),ct(this,ps),ct(this,Ha,Bu(o=>{if(!ie(this,ir)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const i of ie(this,ps))if(o.target.contains(i)){this.callback(ie(this,or).boundingClientRect);break}}},Wu));const r=xp(e),s=Ap(r,t),a=Tp(e,ie(this,Ha));mt(this,ps,r),mt(this,or,new zu(e,t,n)),this.disconnect=()=>{ie(this,ir)||(mt(this,ir,!0),s(),a(),ie(this,or).disconnect())}}};or=new WeakMap;ir=new WeakMap;ps=new WeakMap;Ha=new WeakMap;function Ga(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function wr(e){try{Ga(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function Ml(e){return!Du||!e?!1:e===vn(e).scrollingElement}function ju(e){var t,n;const r=St(e),s=Ml(e)?gp(e):Hs(e),a=r.visualViewport,o=Ml(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 Rp(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:a,position:o}=ju(e),{x:i,y:l}=t??{x:0,y:0},c=!n&&o.current.y+l>0,u=!r&&o.current.y+l<o.max.y,f=!s&&o.current.x+i>0,m=!a&&o.current.x+i<o.max.x;return{top:c,bottom:u,left:f,right:m,x:f||m,y:c||u}}var Qo=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))}},Is=new Qo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Dp=new Qo(e=>setTimeout(e,50)),Ms=new Map,Pp=Ms.clear.bind(Ms);function Vt(e,t=!1){if(!t)return Al(e);let n=Ms.get(e);return n||(n=Al(e),Ms.set(e,n),Dp.schedule(Pp),n)}function Al(e){return St(e).getComputedStyle(e)}function Fp(e,t=Vt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Op(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 Lp={excludeElement:!0,escapeShadowDOM:!0};function Ua(e,t=Lp){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,a=new Set;function o(i){if(n!=null&&a.size>=n||!i)return a;if(Ko(i)&&i.scrollingElement!=null&&!a.has(i.scrollingElement))return a.add(i.scrollingElement),a;if(s&&Jo(i))return o(i.host);if(!dn(i))return Ru(i)?o(i.parentElement):a;if(a.has(i))return a;const l=Vt(i,!0);if(r&&i===e||Op(i,l)&&a.add(i),Fp(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&a.add(c),a}return o(i.parentNode)}return e?o(e):a}function Bp(e){const[t]=Ua(e,{limit:1});return t??null}function Wn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Bn(e);for(;r;){if(r===t)return n;const s=Hs(r),{x:a,y:o}=Wp(r,s);n.x=n.x+s.left,n.y=n.y+s.top,n.scaleX=n.scaleX*a,n.scaleY=n.scaleY*o,r=Bn(r)}return n}function Wp(e,t=Hs(e)){const n=Math.round(t.width),r=Math.round(t.height);if(dn(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=Vt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function Vp(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 ei(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 ti(e){var t,n,r,s,a,o,i,l,c;const{scale:u,transform:f,translate:m}=e,d=Vp(u),h=ei(m),g=Np(f);if(!g&&!d&&!h)return null;const v={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=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:y.x+b.x,y:y.y+b.y,z:(c=h?.z)!=null?c:0,scaleX:v.x*b.scaleX,scaleY:v.y*b.scaleY}}function Np(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var _t=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(_t||{}),zp={x:.2,y:.2},jp={x:10,y:10};function Zp(e,t,n,r=25,s=zp,a=jp){const{x:o,y:i}=t,{rect:l,isTop:c,isBottom:u,isLeft:f,isRight:m}=ju(e),d=Wn(e),h=Vt(e,!0),g=ti(h),v=g!==null?g?.scaleX<0:!1,y=g!==null?g?.scaleY<0:!1,b=new Tr(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)),(!m||v&&!f)&&o>=b.right-x.width&&n?.x!==-1&&i>=b.top-a.y&&i<=b.bottom+a.y?(w.x=v?-1:1,_.x=r*Math.abs((b.right-x.width-o)/x.width)):(!f||v&&!m)&&o<=b.left+x.width&&n?.x!==1&&i>=b.top-a.y&&i<=b.bottom+a.y&&(w.x=v?1:-1,_.x=r*Math.abs((b.left+x.width-o)/x.width)),{direction:w,speed:_}}function Hp(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function Gp(e,t=!1){if(Hp(e)){e.scrollIntoViewIfNeeded(t);return}if(!dn(e))return e.scrollIntoView();var n=Bp(e);if(!dn(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 Up(e,t,n){const{scaleX:r,scaleY:s,x:a,y:o}=t,i=e.left+a+(1-r)*parseFloat(n),l=e.top+o+(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width*r:e.width,u=s?e.height*s:e.height;return{width:c,height:u,top:l,right:i+c,bottom:l+u,left:i}}function 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({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var Kp=new Qo(e=>setTimeout(e,0)),hr=new Map,qp=hr.clear.bind(hr);function Jp(e){const t=e.ownerDocument;let n=hr.get(t);if(n)return n;n=t.getAnimations(),hr.set(t,n),Kp.schedule(qp);const r=n.filter(s=>Zs(s.effect)&&s.effect.target===e);return hr.set(e,r),n}function Qp(e,t){const n=Jp(e).filter(r=>{var s,a;if(Zs(r.effect)){const{target:o}=r.effect;if((a=o&&((s=t.isValidTarget)==null?void 0:s.call(t,o)))!=null?a:!0)return r.effect.getKeyframes().some(l=>{for(const c of t.properties)if(l[c])return!0})}}).map(r=>{const{effect:s,currentTime:a}=r,o=s?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof a=="number"&&a<o)return r.currentTime=o,()=>{r.currentTime=a}});if(n.length>0)return()=>n.forEach(r=>r?.())}var Lt=class extends Tr{constructor(e,t={}){var n,r,s,a;const{frameTransform:o=Wn(e),ignoreTransforms:i,getBoundingClientRect:l=Hs}=t,c=Qp(e,{properties:["transform","translate","scale","width","height"],isValidTarget:x=>(x!==e||qo())&&x.contains(e)}),u=l(e);let{top:f,left:m,width:d,height:h}=u,g;const v=Vt(e),y=ti(v),b={x:(n=y?.scaleX)!=null?n:1,y:(r=y?.scaleY)!=null?r:1},w=em(e,v);c?.(),y&&(g=Xp(u,y,v.transformOrigin),(i||w)&&(f=g.top,m=g.left,d=g.width,h=g.height));const _={width:(s=g?.width)!=null?s:d,height:(a=g?.height)!=null?a:h};if(w&&!i&&g){const x=Up(g,w,v.transformOrigin);f=x.top,m=x.left,d=x.width,h=x.height,b.x=w.scaleX,b.y=w.scaleY}o&&(i||(m*=o.scaleX,d*=o.scaleX,f*=o.scaleY,h*=o.scaleY),m+=o.x,f+=o.y),super(m,f,d,h),this.scale=b,this.intrinsicWidth=_.width,this.intrinsicHeight=_.height}};function em(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=Zs(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=ti({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 pr(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 tm=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(pr(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(pr(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(pr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function fn(e){return e?e instanceof St(e).Element||Dr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function ni(e){if(!e)return!1;const{KeyboardEvent:t}=St(e.target);return e instanceof t}function nm(e){if(!e)return!1;const{PointerEvent:t}=St(e.target);return e instanceof t}function rm(e){if(!fn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||sm(e)}function sm(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var va={};function Xa(e){const t=va[e]==null?0:va[e]+1;return va[e]=t,`${e}-${t}`}var am=({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:Ao.PointerIntersection,priority:Mo.High}}return null},om=({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:Ao.ShapeIntersection,priority:Mo.Normal}}return null},im=e=>{var t;return(t=am(e))!=null?t:om(e)},lm=Object.create,ri=Object.defineProperty,cm=Object.defineProperties,um=Object.getOwnPropertyDescriptor,dm=Object.getOwnPropertyDescriptors,As=Object.getOwnPropertySymbols,Zu=Object.prototype.hasOwnProperty,Hu=Object.prototype.propertyIsEnumerable,Gu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Un=e=>{throw TypeError(e)},Ya=(e,t,n)=>t in e?ri(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_r=(e,t)=>{for(var n in t||(t={}))Zu.call(t,n)&&Ya(e,n,t[n]);if(As)for(var n of As(t))Hu.call(t,n)&&Ya(e,n,t[n]);return e},si=(e,t)=>cm(e,dm(t)),Tl=(e,t)=>ri(e,"name",{value:t,configurable:!0}),Uu=(e,t)=>{var n={};for(var r in e)Zu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&As)for(var r of As(e))t.indexOf(r)<0&&Hu.call(e,r)&&(n[r]=e[r]);return n},Xn=e=>{var t;return[,,,lm((t=e?.[Gu("metadata")])!=null?t:null)]},Xu=["class","method","getter","setter","accessor","field","value","get","set"],lr=e=>e!==void 0&&typeof e!="function"?Un("Function expected"):e,fm=(e,t,n,r,s)=>({kind:Xu[e],name:t,metadata:r,addInitializer:a=>n._?Un("Already initialized"):s.push(lr(a||null))}),yn=(e,t)=>Ya(t,Gu("metadata"),e[3]),Fe=(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},vt=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,g=Xu[f+5],v=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&um(f<4?s:{get[n](){return Se(this,a)},set[n](_){return st(this,a,_)}},n));f?d&&f<4&&Tl(a,(f>2?"set ":f>1?"get ":"")+n):Tl(s,n);for(var w=r.length-1;w>=0;w--)c=fm(f,n,l={},e[3],y),f&&(c.static=m,c.private=d,u=c.access={has:d?_=>hm(s,_):_=>n in _},f^3&&(u.get=d?_=>(f^1?Se:hn)(_,s,f^4?a:b.get):_=>_[n]),f>2&&(u.set=d?(_,x)=>st(_,s,x,f^4?a:b.set):(_,x)=>_[n]=x)),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?lr(i)&&(f>4?v.unshift(i):f?d?a=i:b[g]=i:s=i):typeof i!="object"||i===null?Un("Object expected"):(lr(o=i.get)&&(b.get=o),lr(o=i.set)&&(b.set=o),lr(o=i.init)&&v.unshift(o));return f||yn(e,s),b&&ri(s,n,b),d?f^4?a:b:s},ai=(e,t,n)=>t.has(e)||Un("Cannot "+n),hm=(e,t)=>Object(t)!==t?Un('Cannot use the "in" operator on this value'):e.has(t),Se=(e,t,n)=>(ai(e,t,"read from private field"),n?n.call(e):t.get(e)),De=(e,t,n)=>t.has(e)?Un("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(ai(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),hn=(e,t,n)=>(ai(e,t,"access private method"),n),$l={role:"button",roleDescription:"draggable"},pm="dnd-kit-description",mm="dnd-kit-announcement",gm={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."},vm={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 ym(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function bm(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function wm(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 _m=["dragover","dragmove"],xm=class extends dt{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=pm,announcement:s=mm}={},announcements:a=vm,screenReaderInstructions:o=gm,debounce:i=500}=t??{},l=n?`${r}-${n}`:Xa(r),c=n?`${s}-${n}`:Xa(s);let u,f,m,d;const h=(x=d)=>{!m||!x||m?.nodeValue!==x&&(m.nodeValue=x)},g=()=>Is.schedule(h),v=Cm(g,i),y=Object.entries(a).map(([x,S])=>this.manager.monitor.addEventListener(x,(k,E)=>{const I=m;if(!I)return;const T=S?.(k,E);T&&I.nodeValue!==T&&(d=T,_m.includes(x)?v():(g(),v.cancel()))})),b=()=>{let x=[];u?.isConnected||(u=bm(l,o.draggable),x.push(u)),f?.isConnected||(f=wm(c),m=document.createTextNode(""),f.appendChild(m),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),(!ym(k)||qo())&&!k.hasAttribute("tabindex")&&w.add(()=>k.setAttribute("tabindex","0")),!k.hasAttribute("role")&&k.tagName.toLowerCase()!=="button"&&w.add(()=>k.setAttribute("role",$l.role)),k.hasAttribute("aria-roledescription")||w.add(()=>k.setAttribute("aria-roledescription",$l.roleDescription)),k.hasAttribute("aria-describedby")||w.add(()=>k.setAttribute("aria-describedby",l));for(const I of["aria-pressed","aria-grabbed"]){const T=String(S.isDragging);k.getAttribute(I)!==T&&w.add(()=>k.setAttribute(I,T))}const E=String(S.disabled);k.getAttribute("aria-disabled")!==E&&w.add(()=>k.setAttribute("aria-disabled",E))}}w.size>0&&Is.schedule(_)}),this.destroy=()=>{super.destroy(),u?.remove(),f?.remove(),y.forEach(x=>x())}}};function Cm(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Sm=class extends dt{constructor(e,t){super(e,t),this.manager=e;const n=_s(()=>{var r;return vn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=Ct(()=>{var r;const{dragOperation:s}=this.manager,{cursor:a="grabbing",nonce:o}=(r=this.options)!=null?r:{};if(s.status.initialized){const i=n.value,l=i.createElement("style");return o&&l.setAttribute("nonce",o),l.textContent=`* { cursor: ${a} !important; }`,i.head.appendChild(l),()=>l.remove()}})}},Ts=new Map,Yu,Ku,qu,Ju,Ka,mr,Bt,oi,Vn,Qu,ed,td,nd,bn=class extends(Ka=Rr,Ju=[ge],qu=[$e],Ku=[$e],Yu=[$e],Ka){constructor(e){super(e),Fe(Bt,5,this),De(this,Vn),De(this,mr,new Set),De(this,oi,Fe(Bt,8,this,new Set)),Fe(Bt,11,this),this.registerEffect(hn(this,Vn,Qu))}register(e){return Se(this,mr).add(e),()=>{Se(this,mr).delete(e)}}addRoot(e){return _e(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{_e(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return Ss((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return Ss((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=Xn(Ka);mr=new WeakMap;oi=new WeakMap;Vn=new WeakSet;Qu=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Se(this,mr))t.push(hn(this,Vn,ed).call(this,n,r));return()=>{for(const n of t)n()}};ed=function(e,t){let n=Ts.get(e);n||(n=new Map,Ts.set(e,n));let r=n.get(t);if(!r){const a=Ko(e)?hn(this,Vn,td).call(this,e,n,t):hn(this,Vn,nd).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())}};td=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&&Ts.delete(e)}}};nd=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(Jo(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&&Ts.delete(e)}}};vt(Bt,4,"additionalRoots",Ju,bn,oi);vt(Bt,2,"sourceRoot",qu,bn);vt(Bt,2,"targetRoot",Ku,bn);vt(Bt,2,"roots",Yu,bn);yn(Bt,bn);var Pr="data-dnd-",qa=`${Pr}dropping`,qe="--dnd-",At=`${Pr}dragging`,$s=`${Pr}placeholder`,km=[At,$s,"popover","aria-pressed","aria-grabbing"],Em=["view-transition-name"],Im=`
|
|
8
|
+
`)}var Bu=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:s}]=e;t.removeEventListener(n,r,s)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],s=[];for(const a of n)for(const o of r){const{type:i,listener:l,options:c}=o,u=[a,o];a.addEventListener(i,l,c),this.entries.add(u),s.push(u)}return function(){for(const[o,{type:i,listener:l,options:c}]of s)o.removeEventListener(i,l,c)}}};function Bn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Cp(e){const t=new Set;let n=Bn(e);for(;n;)t.add(n),n=Bn(n);return t}function Sp(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Wu(e,t){const n=()=>performance.now();let r,s;return function(...a){const o=this;s?(r?.(),r=Sp(()=>{e.apply(o,a),s=n()},t-(n()-s))):(e.apply(o,a),s=n())}}function kp(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function Ep(e,t=e.getBoundingClientRect()){const{width:n,height:r}=Ss(e,t);return n>0&&r>0}var Ip=Pu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ps,Mp=class extends Ip{constructor(e){super(t=>{if(!ie(this,ps)){pt(this,ps,!0);return}e(t,this)}),ct(this,ps,!1)}};ps=new WeakMap;var Ml=Array.from({length:100},(e,t)=>t/100),Vu=75,an,Es,Zt,on,ar,Ke,hr,or,Is,Nu,zu,ju=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,ct(this,Is),this.disconnect=()=>{var a,o,i;pt(this,hr,!0),(a=ie(this,Zt))==null||a.disconnect(),(o=ie(this,on))==null||o.disconnect(),ie(this,ar).disconnect(),(i=ie(this,Ke))==null||i.remove()},ct(this,an,!0),ct(this,Es),ct(this,Zt),ct(this,on),ct(this,ar),ct(this,Ke),ct(this,hr,!1),ct(this,or,Wu(()=>{var a,o,i;const{element:l}=this;if((a=ie(this,on))==null||a.disconnect(),ie(this,hr)||!ie(this,an)||!l.isConnected)return;const c=(o=l.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:f}=(i=c.defaultView)!=null?i:window,m=l.getBoundingClientRect(),d=Ss(l,m),{top:h,left:v,bottom:g,right:y}=d,b=-Math.floor(h),_=-Math.floor(v),w=-Math.floor(f-y),x=-Math.floor(u-g),S=`${b}px ${w}px ${x}px ${_}px`;this.boundingClientRect=m,pt(this,on,new IntersectionObserver(k=>{const[E]=k,{intersectionRect:M}=E;(E.intersectionRatio!==1?E.intersectionRatio:$r.intersectionRatio(M,Ss(l)))!==1&&ie(this,or).call(this)},{threshold:Ml,rootMargin:S,root:c})),ie(this,on).observe(l),Ru(this,Is,Nu).call(this)},Vu)),this.boundingClientRect=e.getBoundingClientRect(),pt(this,an,Ep(e,this.boundingClientRect));let r=!0;this.callback=a=>{r&&(r=!1,n.skipInitial)||t(a)};const s=e.ownerDocument;n?.debug&&(pt(this,Ke,document.createElement("div")),ie(this,Ke).style.background="rgba(0,0,0,0.15)",ie(this,Ke).style.position="fixed",ie(this,Ke).style.pointerEvents="none",s.body.appendChild(ie(this,Ke))),pt(this,ar,new IntersectionObserver(a=>{var o,i;const l=a[a.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:f,height:m}=c,d=ie(this,an);pt(this,an,u),!(!f&&!m)&&(d&&!u?((o=ie(this,on))==null||o.disconnect(),this.callback(null),(i=ie(this,Zt))==null||i.disconnect(),pt(this,Zt,void 0),ie(this,Ke)&&(ie(this,Ke).style.visibility="hidden")):ie(this,or).call(this),u&&!ie(this,Zt)&&(pt(this,Zt,new Mp(ie(this,or))),ie(this,Zt).observe(e)))},{threshold:Ml,root:s})),ie(this,an)&&!n.skipInitial&&this.callback(this.boundingClientRect),ie(this,ar).observe(e)}};an=new WeakMap;Es=new WeakMap;Zt=new WeakMap;on=new WeakMap;ar=new WeakMap;Ke=new WeakMap;hr=new WeakMap;or=new WeakMap;Is=new WeakSet;Nu=function(){ie(this,hr)||(Ru(this,Is,zu).call(this),!kp(this.boundingClientRect,ie(this,Es))&&(this.callback(this.boundingClientRect),pt(this,Es,this.boundingClientRect)))};zu=function(){if(ie(this,Ke)){const{top:e,left:t,width:n,height:r}=Ss(this.element);ie(this,Ke).style.overflow="hidden",ie(this,Ke).style.visibility="visible",ie(this,Ke).style.top=`${Math.floor(e)}px`,ie(this,Ke).style.left=`${Math.floor(t)}px`,ie(this,Ke).style.width=`${Math.floor(n)}px`,ie(this,Ke).style.height=`${Math.floor(r)}px`}};var ns=new WeakMap,rs=new WeakMap;function Ap(e,t){let n=ns.get(e);return n||(n={disconnect:new ju(e,s=>{const a=ns.get(e);a&&a.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),ns.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(ns.delete(e),n.disconnect())}}function Tp(e,t){const n=new Set;for(const r of e){const s=Ap(r,t);n.add(s)}return()=>n.forEach(r=>r())}function $p(e,t){var n;const r=e.ownerDocument;if(!rs.has(r)){const o=new AbortController,i=new Set;document.addEventListener("scroll",l=>i.forEach(c=>c(l)),{capture:!0,passive:!0,signal:o.signal}),rs.set(r,{disconnect:()=>o.abort(),listeners:i})}const{listeners:s,disconnect:a}=(n=rs.get(r))!=null?n:{};return!s||!a?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(a(),rs.delete(r))})}var ir,lr,ms,Ua,Rp=class{constructor(e,t,n){this.callback=t,ct(this,ir),ct(this,lr,!1),ct(this,ms),ct(this,Ua,Wu(o=>{if(!ie(this,lr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const i of ie(this,ms))if(o.target.contains(i)){this.callback(ie(this,ir).boundingClientRect);break}}},Vu));const r=Cp(e),s=Tp(r,t),a=$p(e,ie(this,Ua));pt(this,ms,r),pt(this,ir,new ju(e,t,n)),this.disconnect=()=>{ie(this,lr)||(pt(this,lr,!0),s(),a(),ie(this,ir).disconnect())}}};ir=new WeakMap;lr=new WeakMap;ms=new WeakMap;Ua=new WeakMap;function Xa(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function _r(e){try{Xa(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function Al(e){return!Pu||!e?!1:e===vn(e).scrollingElement}function Zu(e){var t,n;const r=xt(e),s=Al(e)?vp(e):Gs(e),a=r.visualViewport,o=Al(e)?{height:(t=a?.height)!=null?t:r.innerHeight,width:(n=a?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},i={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},l=i.current.y<=0,c=i.current.x<=0,u=i.current.y>=i.max.y,f=i.current.x>=i.max.x;return{rect:s,position:i,isTop:l,isLeft:c,isBottom:u,isRight:f}}function Dp(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:a,position:o}=Zu(e),{x:i,y:l}=t??{x:0,y:0},c=!n&&o.current.y+l>0,u=!r&&o.current.y+l<o.max.y,f=!s&&o.current.x+i>0,m=!a&&o.current.x+i<o.max.x;return{top:c,bottom:u,left:f,right:m,x:f||m,y:c||u}}var ti=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const s of n)s();for(const s of r)s()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},Ms=new ti(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Pp=new ti(e=>setTimeout(e,50)),As=new Map,Fp=As.clear.bind(As);function Nt(e,t=!1){if(!t)return Tl(e);let n=As.get(e);return n||(n=Tl(e),As.set(e,n),Pp.schedule(Fp),n)}function Tl(e){return xt(e).getComputedStyle(e)}function Op(e,t=Nt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Lp(e,t=Nt(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const a=t[s];return typeof a=="string"?n.test(a):!1})}var Bp={excludeElement:!0,escapeShadowDOM:!0};function Ya(e,t=Bp){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,a=new Set;function o(i){if(n!=null&&a.size>=n||!i)return a;if(Jo(i)&&i.scrollingElement!=null&&!a.has(i.scrollingElement))return a.add(i.scrollingElement),a;if(s&&ei(i))return o(i.host);if(!dn(i))return Du(i)?o(i.parentElement):a;if(a.has(i))return a;const l=Nt(i,!0);if(r&&i===e||Lp(i,l)&&a.add(i),Op(i,l)){const{scrollingElement:c}=i.ownerDocument;return c&&a.add(c),a}return o(i.parentNode)}return e?o(e):a}function Wp(e){const[t]=Ya(e,{limit:1});return t??null}function Wn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Bn(e);for(;r;){if(r===t)return n;const s=Gs(r),{x:a,y:o}=Vp(r,s);n.x=n.x+s.left,n.y=n.y+s.top,n.scaleX=n.scaleX*a,n.scaleY=n.scaleY*o,r=Bn(r)}return n}function Vp(e,t=Gs(e)){const n=Math.round(t.width),r=Math.round(t.height);if(dn(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=Nt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function Np(e){if(e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function ni(e){if(e==="none")return null;const[t,n,r="0"]=e.split(" "),s={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(s.x)&&isNaN(s.y)?null:{x:isNaN(s.x)?0:s.x,y:isNaN(s.y)?0:s.y,z:isNaN(s.z)?0:s.z}}function ri(e){var t,n,r,s,a,o,i,l,c;const{scale:u,transform:f,translate:m}=e,d=Np(u),h=ni(m),v=zp(f);if(!v&&!d&&!h)return null;const g={x:(t=d?.x)!=null?t:1,y:(n=d?.y)!=null?n:1},y={x:(r=h?.x)!=null?r:0,y:(s=h?.y)!=null?s:0},b={x:(a=v?.x)!=null?a:0,y:(o=v?.y)!=null?o:0,scaleX:(i=v?.scaleX)!=null?i:1,scaleY:(l=v?.scaleY)!=null?l:1};return{x:y.x+b.x,y:y.y+b.y,z:(c=h?.z)!=null?c:0,scaleX:g.x*b.scaleX,scaleY:g.y*b.scaleY}}function zp(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var bt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(bt||{}),jp={x:.2,y:.2},Zp={x:10,y:10};function Hp(e,t,n,r=25,s=jp,a=Zp){const{x:o,y:i}=t,{rect:l,isTop:c,isBottom:u,isLeft:f,isRight:m}=Zu(e),d=Wn(e),h=Nt(e,!0),v=ri(h),g=v!==null?v?.scaleX<0:!1,y=v!==null?v?.scaleY<0:!1,b=new $r(l.left*d.scaleX+d.x,l.top*d.scaleY+d.y,l.width*d.scaleX,l.height*d.scaleY),_={x:0,y:0},w={x:0,y:0},x={height:b.height*s.y,width:b.width*s.x};return(!c||y&&!u)&&i<=b.top+x.height&&n?.y!==1&&o>=b.left-a.x&&o<=b.right+a.x?(_.y=y?1:-1,w.y=r*Math.abs((b.top+x.height-i)/x.height)):(!u||y&&!c)&&i>=b.bottom-x.height&&n?.y!==-1&&o>=b.left-a.x&&o<=b.right+a.x&&(_.y=y?-1:1,w.y=r*Math.abs((b.bottom-x.height-i)/x.height)),(!m||g&&!f)&&o>=b.right-x.width&&n?.x!==-1&&i>=b.top-a.y&&i<=b.bottom+a.y?(_.x=g?-1:1,w.x=r*Math.abs((b.right-x.width-o)/x.width)):(!f||g&&!m)&&o<=b.left+x.width&&n?.x!==1&&i>=b.top-a.y&&i<=b.bottom+a.y&&(_.x=g?1:-1,w.x=r*Math.abs((b.left+x.width-o)/x.width)),{direction:_,speed:w}}function Gp(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function Up(e,t=!1){if(Gp(e)){e.scrollIntoViewIfNeeded(t);return}if(!dn(e))return e.scrollIntoView();var n=Wp(e);if(!dn(n))return;const r=Nt(n,!0),s=parseInt(r.getPropertyValue("border-top-width")),a=parseInt(r.getPropertyValue("border-left-width")),o=e.offsetTop-n.offsetTop<n.scrollTop,i=e.offsetTop-n.offsetTop+e.clientHeight-s>n.scrollTop+n.clientHeight,l=e.offsetLeft-n.offsetLeft<n.scrollLeft,c=e.offsetLeft-n.offsetLeft+e.clientWidth-a>n.scrollLeft+n.clientWidth,u=o&&!i;(o||i)&&t&&(n.scrollTop=e.offsetTop-n.offsetTop-n.clientHeight/2-s+e.clientHeight/2),(l||c)&&t&&(n.scrollLeft=e.offsetLeft-n.offsetLeft-n.clientWidth/2-a+e.clientWidth/2),(o||i||l||c)&&!t&&e.scrollIntoView(u)}function Xp(e,t,n){const{scaleX:r,scaleY:s,x:a,y:o}=t,i=e.left+a+(1-r)*parseFloat(n),l=e.top+o+(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width*r:e.width,u=s?e.height*s:e.height;return{width:c,height:u,top:l,right:i+c,bottom:l+u,left:i}}function Yp(e,t,n){const{scaleX:r,scaleY:s,x:a,y:o}=t,i=e.left-a-(1-r)*parseFloat(n),l=e.top-o-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width/r:e.width,u=s?e.height/s:e.height;return{width:c,height:u,top:l,right:i+c,bottom:l+u,left:i}}function Kp({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}var qp=new ti(e=>setTimeout(e,0)),pr=new Map,Jp=pr.clear.bind(pr);function Qp(e){const t=e.ownerDocument;let n=pr.get(t);if(n)return n;n=t.getAnimations(),pr.set(t,n),qp.schedule(Jp);const r=n.filter(s=>Hs(s.effect)&&s.effect.target===e);return pr.set(e,r),n}function em(e,t){const n=Qp(e).filter(r=>{var s,a;if(Hs(r.effect)){const{target:o}=r.effect;if((a=o&&((s=t.isValidTarget)==null?void 0:s.call(t,o)))!=null?a:!0)return r.effect.getKeyframes().some(l=>{for(const c of t.properties)if(l[c])return!0})}}).map(r=>{const{effect:s,currentTime:a}=r,o=s?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof a=="number"&&a<o)return r.currentTime=o,()=>{r.currentTime=a}});if(n.length>0)return()=>n.forEach(r=>r?.())}var Bt=class extends $r{constructor(e,t={}){var n,r,s,a;const{frameTransform:o=Wn(e),ignoreTransforms:i,getBoundingClientRect:l=Gs}=t,c=em(e,{properties:["transform","translate","scale","width","height"],isValidTarget:x=>(x!==e||Qo())&&x.contains(e)}),u=l(e);let{top:f,left:m,width:d,height:h}=u,v;const g=Nt(e),y=ri(g),b={x:(n=y?.scaleX)!=null?n:1,y:(r=y?.scaleY)!=null?r:1},_=tm(e,g);c?.(),y&&(v=Yp(u,y,g.transformOrigin),(i||_)&&(f=v.top,m=v.left,d=v.width,h=v.height));const w={width:(s=v?.width)!=null?s:d,height:(a=v?.height)!=null?a:h};if(_&&!i&&v){const x=Xp(v,_,g.transformOrigin);f=x.top,m=x.left,d=x.width,h=x.height,b.x=_.scaleX,b.y=_.scaleY}o&&(i||(m*=o.scaleX,d*=o.scaleX,f*=o.scaleY,h*=o.scaleY),m+=o.x,f+=o.y),super(m,f,d,h),this.scale=b,this.intrinsicWidth=w.width,this.intrinsicHeight=w.height}};function tm(e,t){var n;const r=e.getAnimations();let s=null;if(!r.length)return null;for(const a of r){if(a.playState!=="running")continue;const o=Hs(a.effect)?a.effect.getKeyframes():[],i=o[o.length-1];if(!i)continue;const{transform:l,translate:c,scale:u}=i;if(l||c||u){const f=ri({transform:typeof l=="string"&&l?l:t.transform,translate:typeof c=="string"&&c?c:t.translate,scale:typeof u=="string"&&u?u:t.scale});f&&(s=s?{x:s.x+f.x,y:s.y+f.y,z:(n=s.z)!=null?n:f.z,scaleX:s.scaleX*f.scaleX,scaleY:s.scaleY*f.scaleY}:f)}}return s}function mr(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var nm=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(mr(n))for(const[r,s]of Object.entries(e)){const a=`${t}${r}`;this.initial.has(a)||this.initial.set(a,n.style.getPropertyValue(a)),n.style.setProperty(a,typeof s=="string"?s:`${s}px`)}}remove(e,t=""){const{element:n}=this;if(mr(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(mr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function fn(e){return e?e instanceof xt(e).Element||Pr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function si(e){if(!e)return!1;const{KeyboardEvent:t}=xt(e.target);return e instanceof t}function rm(e){if(!e)return!1;const{PointerEvent:t}=xt(e.target);return e instanceof t}function sm(e){if(!fn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||am(e)}function am(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var ya={};function Ka(e){const t=ya[e]==null?0:ya[e]+1;return ya[e]=t,`${e}-${t}`}var om=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=Tt.distance(t.shape.center,n);return{id:r,value:1/s,type:$o.PointerIntersection,priority:To.High}}return null},im=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:s}=e,a=Tt.distance(t.shape.center,s.current),i=r/(n.current.area+t.shape.area-r)/a;return{id:t.id,value:i,type:$o.ShapeIntersection,priority:To.Normal}}return null},lm=e=>{var t;return(t=om(e))!=null?t:im(e)},cm=Object.create,ai=Object.defineProperty,um=Object.defineProperties,dm=Object.getOwnPropertyDescriptor,fm=Object.getOwnPropertyDescriptors,Ts=Object.getOwnPropertySymbols,Hu=Object.prototype.hasOwnProperty,Gu=Object.prototype.propertyIsEnumerable,Uu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Un=e=>{throw TypeError(e)},qa=(e,t,n)=>t in e?ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xr=(e,t)=>{for(var n in t||(t={}))Hu.call(t,n)&&qa(e,n,t[n]);if(Ts)for(var n of Ts(t))Gu.call(t,n)&&qa(e,n,t[n]);return e},oi=(e,t)=>um(e,fm(t)),$l=(e,t)=>ai(e,"name",{value:t,configurable:!0}),Xu=(e,t)=>{var n={};for(var r in e)Hu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ts)for(var r of Ts(e))t.indexOf(r)<0&&Gu.call(e,r)&&(n[r]=e[r]);return n},Xn=e=>{var t;return[,,,cm((t=e?.[Uu("metadata")])!=null?t:null)]},Yu=["class","method","getter","setter","accessor","field","value","get","set"],cr=e=>e!==void 0&&typeof e!="function"?Un("Function expected"):e,hm=(e,t,n,r,s)=>({kind:Yu[e],name:t,metadata:r,addInitializer:a=>n._?Un("Already initialized"):s.push(cr(a||null))}),yn=(e,t)=>qa(t,Uu("metadata"),e[3]),We=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)t&1?a[s].call(n):r=a[s].call(n,r);return r},gt=(e,t,n,r,s,a)=>{var o,i,l,c,u,f=t&7,m=!!(t&8),d=!!(t&16),h=f>3?e.length+1:f?m?1:2:0,v=Yu[f+5],g=f>3&&(e[h-1]=[]),y=e[h]||(e[h]=[]),b=f&&(!d&&!m&&(s=s.prototype),f<5&&(f>3||!d)&&dm(f<4?s:{get[n](){return Se(this,a)},set[n](w){return st(this,a,w)}},n));f?d&&f<4&&$l(a,(f>2?"set ":f>1?"get ":"")+n):$l(s,n);for(var _=r.length-1;_>=0;_--)c=hm(f,n,l={},e[3],y),f&&(c.static=m,c.private=d,u=c.access={has:d?w=>pm(s,w):w=>n in w},f^3&&(u.get=d?w=>(f^1?Se:hn)(w,s,f^4?a:b.get):w=>w[n]),f>2&&(u.set=d?(w,x)=>st(w,s,x,f^4?a:b.set):(w,x)=>w[n]=x)),i=(0,r[_])(f?f<4?d?a:b[v]:f>4?void 0:{get:b.get,set:b.set}:s,c),l._=1,f^4||i===void 0?cr(i)&&(f>4?g.unshift(i):f?d?a=i:b[v]=i:s=i):typeof i!="object"||i===null?Un("Object expected"):(cr(o=i.get)&&(b.get=o),cr(o=i.set)&&(b.set=o),cr(o=i.init)&&g.unshift(o));return f||yn(e,s),b&&ai(s,n,b),d?f^4?a:b:s},ii=(e,t,n)=>t.has(e)||Un("Cannot "+n),pm=(e,t)=>Object(t)!==t?Un('Cannot use the "in" operator on this value'):e.has(t),Se=(e,t,n)=>(ii(e,t,"read from private field"),n?n.call(e):t.get(e)),Oe=(e,t,n)=>t.has(e)?Un("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(ii(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),hn=(e,t,n)=>(ii(e,t,"access private method"),n),Rl={role:"button",roleDescription:"draggable"},mm="dnd-kit-description",gm="dnd-kit-announcement",vm={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},ym={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function bm(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function wm(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function _m(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var xm=["dragover","dragmove"],Cm=class extends dt{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=mm,announcement:s=gm}={},announcements:a=ym,screenReaderInstructions:o=vm,debounce:i=500}=t??{},l=n?`${r}-${n}`:Ka(r),c=n?`${s}-${n}`:Ka(s);let u,f,m,d;const h=(x=d)=>{!m||!x||m?.nodeValue!==x&&(m.nodeValue=x)},v=()=>Ms.schedule(h),g=Sm(v,i),y=Object.entries(a).map(([x,S])=>this.manager.monitor.addEventListener(x,(k,E)=>{const M=m;if(!M)return;const T=S?.(k,E);T&&M.nodeValue!==T&&(d=T,xm.includes(x)?g():(v(),g.cancel()))})),b=()=>{let x=[];u?.isConnected||(u=wm(l,o.draggable),x.push(u)),f?.isConnected||(f=_m(c),m=document.createTextNode(""),f.appendChild(m),x.push(f)),x.length>0&&document.body.append(...x)},_=new Set;function w(){for(const x of _)x()}this.registerEffect(()=>{var x;_.clear();for(const S of this.manager.registry.draggables.value){const k=(x=S.handle)!=null?x:S.element;if(k){(!u||!f)&&_.add(b),(!bm(k)||Qo())&&!k.hasAttribute("tabindex")&&_.add(()=>k.setAttribute("tabindex","0")),!k.hasAttribute("role")&&k.tagName.toLowerCase()!=="button"&&_.add(()=>k.setAttribute("role",Rl.role)),k.hasAttribute("aria-roledescription")||_.add(()=>k.setAttribute("aria-roledescription",Rl.roleDescription)),k.hasAttribute("aria-describedby")||_.add(()=>k.setAttribute("aria-describedby",l));for(const M of["aria-pressed","aria-grabbed"]){const T=String(S.isDragging);k.getAttribute(M)!==T&&_.add(()=>k.setAttribute(M,T))}const E=String(S.disabled);k.getAttribute("aria-disabled")!==E&&_.add(()=>k.setAttribute("aria-disabled",E))}}_.size>0&&Ms.schedule(w)}),this.destroy=()=>{super.destroy(),u?.remove(),f?.remove(),y.forEach(x=>x())}}};function Sm(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var km=class extends dt{constructor(e,t){super(e,t),this.manager=e;const n=xs(()=>{var r;return vn((r=this.manager.dragOperation.source)==null?void 0:r.element)});this.destroy=_t(()=>{var r;const{dragOperation:s}=this.manager,{cursor:a="grabbing",nonce:o}=(r=this.options)!=null?r:{};if(s.status.initialized){const i=n.value,l=i.createElement("style");return o&&l.setAttribute("nonce",o),l.textContent=`* { cursor: ${a} !important; }`,i.head.appendChild(l),()=>l.remove()}})}},$s=new Map,Ku,qu,Ju,Qu,Ja,gr,Wt,li,Vn,ed,td,nd,rd,bn=class extends(Ja=Dr,Qu=[he],Ju=[Pe],qu=[Pe],Ku=[Pe],Ja){constructor(e){super(e),We(Wt,5,this),Oe(this,Vn),Oe(this,gr,new Set),Oe(this,li,We(Wt,8,this,new Set)),We(Wt,11,this),this.registerEffect(hn(this,Vn,ed))}register(e){return Se(this,gr).add(e),()=>{Se(this,gr).delete(e)}}addRoot(e){return we(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{we(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return ks((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return ks((e=t?.element)!=null?e:null)}get roots(){const{status:e}=this.manager.dragOperation;if(e.initializing||e.initialized){const t=[this.sourceRoot,this.targetRoot].filter(n=>n!=null);return new Set([...t,...this.additionalRoots])}return new Set}};Wt=Xn(Ja);gr=new WeakMap;li=new WeakMap;Vn=new WeakSet;ed=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Se(this,gr))t.push(hn(this,Vn,td).call(this,n,r));return()=>{for(const n of t)n()}};td=function(e,t){let n=$s.get(e);n||(n=new Map,$s.set(e,n));let r=n.get(t);if(!r){const a=Jo(e)?hn(this,Vn,nd).call(this,e,n,t):hn(this,Vn,rd).call(this,e,n,t);if(!a)return()=>{};r=a,n.set(t,r)}r.refCount++;let s=!1;return()=>{s||(s=!0,r.refCount--,r.refCount===0&&r.cleanup())}};nd=function(e,t,n){const r=e.createElement("style");r.textContent=n,e.head.prepend(r);const s=new MutationObserver(a=>{for(const o of a)for(const i of Array.from(o.removedNodes))if(i===r){e.head.prepend(r);return}});return s.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{s.disconnect(),r.remove(),t.delete(n),t.size===0&&$s.delete(e)}}};rd=function(e,t,n){!("adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets))&&process.env.NODE_ENV!=="production"&&console.error("Cannot inject styles: This browser doesn't support adoptedStyleSheets");const r=e.ownerDocument.defaultView,{CSSStyleSheet:s}=r??{};if(!s)return process.env.NODE_ENV!=="production"&&console.error("Cannot inject styles: CSSStyleSheet constructor not available"),null;const a=new s;return a.replaceSync(n),e.adoptedStyleSheets.push(a),{refCount:0,cleanup:()=>{var o;if(ei(e)&&((o=e.host)!=null&&o.isConnected)){const i=e.adoptedStyleSheets.indexOf(a);i!==-1&&e.adoptedStyleSheets.splice(i,1)}t.delete(n),t.size===0&&$s.delete(e)}}};gt(Wt,4,"additionalRoots",Qu,bn,li);gt(Wt,2,"sourceRoot",Ju,bn);gt(Wt,2,"targetRoot",qu,bn);gt(Wt,2,"roots",Ku,bn);yn(Wt,bn);var Fr="data-dnd-",Qa=`${Fr}dropping`,et="--dnd-",At=`${Fr}dragging`,Rs=`${Fr}placeholder`,Em=[At,Rs,"popover","aria-pressed","aria-grabbing"],Im=["view-transition-name"],Mm=`
|
|
9
9
|
:is(:root,:host) [${At}] {
|
|
10
10
|
position: fixed !important;
|
|
11
11
|
pointer-events: none !important;
|
|
12
12
|
touch-action: none;
|
|
13
13
|
z-index: calc(infinity);
|
|
14
14
|
will-change: translate;
|
|
15
|
-
top: var(${
|
|
16
|
-
left: var(${
|
|
15
|
+
top: var(${et}top, 0px) !important;
|
|
16
|
+
left: var(${et}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(${et}width, auto);
|
|
20
|
+
max-width: var(${et}width, auto);
|
|
21
|
+
height: var(${et}height, auto);
|
|
22
|
+
max-height: var(${et}height, auto);
|
|
23
|
+
transition: var(${et}transition) !important;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
:is(:root,:host) [${
|
|
26
|
+
:is(:root,:host) [${Rs}] {
|
|
27
27
|
transition: none;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
:is(:root,:host) [${
|
|
30
|
+
:is(:root,:host) [${Rs}='hidden'] {
|
|
31
31
|
visibility: hidden;
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
pointer-events: none !important;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
[${At}]:not([${
|
|
39
|
-
translate: var(${
|
|
38
|
+
[${At}]:not([${Qa}]) {
|
|
39
|
+
translate: var(${et}translate) !important;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
[${At}][style*='${
|
|
43
|
-
scale: var(${
|
|
44
|
-
transform-origin: var(${
|
|
42
|
+
[${At}][style*='${et}scale'] {
|
|
43
|
+
scale: var(${et}scale) !important;
|
|
44
|
+
transform-origin: var(${et}transform-origin) !important;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
@layer dnd-kit {
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
[${At}]::backdrop, [${
|
|
62
|
+
[${At}]::backdrop, [${Fr}overlay]:not([${At}]) {
|
|
63
63
|
display: none;
|
|
64
64
|
visibility: hidden;
|
|
65
65
|
}
|
|
66
|
-
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Mm(e,t="hidden"){return _e(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Am(n,r.registry.droppables),a=[],o=bp(n),{remove:i}=o;return Tm(s,o,a),$m(o,t),o.remove=()=>{a.forEach(l=>l()),i.call(o)},o})}function Am(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Pr}${Xa("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function Tm(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),El.set(i,o),n.push(()=>{El.delete(i),r.proxy=void 0})}}function $m(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute($s,t)}function rd(e,t){return e===t?!0:Bn(e)===Bn(t)}function Rl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&fn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>wr(t))}function Ja(e){return e.tagName==="TR"}function Rm(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-")||km.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(pr(e)&&pr(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(Em.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 Dm(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),wr(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),wr(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Pm(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=Pu();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(),Ja(e.element)&&Ja(e.placeholder)){const l=Array.from(e.element.cells),c=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(l.map(u=>u.style.width));for(const[u,f]of l.entries()){const m=c[u];f.style.width=`${m.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Lt(e.feedbackElement)})}var Fm=250,Om="ease";function Lm(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=Fm,easing:i=Om}=a??{};wr(e.feedbackElement);const[,l]=(t=mp(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:rd(e.feedbackElement,c)?null:void 0},f=new Lt(e.feedbackElement,u),m=(r=ei(Vt(e.feedbackElement).translate))!=null?r:e.translate,d=new Lt(c,u),h=Tr.delta(f,d,e.alignment),g={x:m.x-h.x,y:m.y-h.y},v=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},qe),e.feedbackElement.setAttribute(qa,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),Yp({element:e.feedbackElement,keyframes:si(_r(_r({},v),y),{translate:[`${m.x}px ${m.y}px 0`,`${g.x}px ${g.y}px 0`]}),options:{duration:Fu(St(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(qa),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var sd,Qa,xr,ii,ms,ad,od,Cr=class extends(Qa=dt,sd=[ge],Qa){constructor(t,n){super(t,n),De(this,ms),De(this,ii,Fe(xr,8,this)),Fe(xr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(bn),s=r?.register(Im);if(s){const a=this.destroy.bind(this);this.destroy=()=>{s(),a()}}this.registerEffect(hn(this,ms,ad).bind(this,r)),this.registerEffect(hn(this,ms,od))}};xr=Xn(Qa);ii=new WeakMap;ms=new WeakSet;ad=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Ss(t);if(n)return e.addRoot(n)};od=function(){var e,t,n;const{state:r,manager:s,options:a}=this,{dragOperation:o}=s,{position:i,source:l,status:c}=o;if(c.idle){r.current={},r.initial={};return}if(!l)return;const{element:u,feedback:f}=l;if(!u||f==="none"||!c.initialized||c.initializing)return;const{initial:m}=r,d=(e=this.overlay)!=null?e:u,h=Wn(d),g=Wn(u),v=!rd(u,d),y=new Lt(u,{frameTransform:v?g:null,ignoreTransforms:!v}),b={x:g.scaleX/h.scaleX,y:g.scaleY/h.scaleY};let{width:w,height:_,top:x,left:S}=y;v&&(w=w/b.x,_=_/b.y);const k=new tm(d),{transition:E,translate:I,boxSizing:T,paddingBlockStart:R,paddingBlockEnd:A,paddingInlineStart:M,paddingInlineEnd:$,borderInlineStartWidth:P,borderInlineEndWidth:O,borderBlockStartWidth:Z,borderBlockEndWidth:G}=Vt(u),Y=f==="clone",ee=T==="content-box",X=ee?parseInt(M)+parseInt($)+parseInt(P)+parseInt(O):0,K=ee?parseInt(R)+parseInt(A)+parseInt(Z)+parseInt(G):0,le=f!=="move"&&!this.overlay?Mm(l,Y?"clone":"hidden"):null,te=_e(()=>ni(s.dragOperation.activatorEvent));if(I!=="none"){const oe=ei(I);oe&&!m.translate&&(m.translate=oe)}if(!m.transformOrigin){const oe=_e(()=>i.current);m.transformOrigin={x:(oe.x-S*h.scaleX-h.x)/(w*h.scaleX),y:(oe.y-x*h.scaleY-h.y)/(_*h.scaleY)}}const{transformOrigin:fe}=m,de=x*h.scaleY+h.y,ne=S*h.scaleX+h.x;if(!m.coordinates&&(m.coordinates={x:ne,y:de},b.x!==1||b.y!==1)){const{scaleX:oe,scaleY:be}=g,{x:je,y:N}=fe;m.coordinates.x+=(w*oe-w)*je,m.coordinates.y+=(_*be-_)*N}m.dimensions||(m.dimensions={width:w,height:_}),m.frameTransform||(m.frameTransform=h);const z={x:m.coordinates.x-ne,y:m.coordinates.y-de},ae={width:(m.dimensions.width*m.frameTransform.scaleX-w*h.scaleX)*fe.x,height:(m.dimensions.height*m.frameTransform.scaleY-_*h.scaleY)*fe.y},ke={x:z.x/h.scaleX+ae.width,y:z.y/h.scaleY+ae.height},ue={left:S+ke.x,top:x+ke.y};d.setAttribute(At,"true");const xe=_e(()=>o.transform),B=(t=m.translate)!=null?t:{x:0,y:0},U=xe.x*h.scaleX+B.x,Je=xe.y*h.scaleY+B.y,Te=Pu();k.set({width:w-X,height:_-K,top:ue.top+Te.y,left:ue.left+Te.x,translate:`${U}px ${Je}px 0`,transition:E?`${E}, translate 0ms linear`:"",scale:v?`${b.x} ${b.y}`:"","transform-origin":`${fe.x*100}% ${fe.y*100}%`},qe),le&&(u.insertAdjacentElement("afterend",le),a?.rootElement&&(typeof a.rootElement=="function"?a.rootElement(l):a.rootElement).appendChild(u)),Ga(d)&&(d.hasAttribute("popover")||d.setAttribute("popover","manual"),wr(d),d.addEventListener("beforetoggle",Rl));let ce,He,Ne;const Qe=Pm({placeholder:le,element:u,feedbackElement:d,frameTransform:h,transformOrigin:fe,width:w,height:_,top:x,left:S,widthOffset:X,heightOffset:K,delta:ke,styles:k,dragOperation:o,getElementMutationObserver:()=>ce,getSavedCellWidths:()=>Ne,setSavedCellWidths:oe=>{Ne=oe}}),We=new Lt(d);_e(()=>o.shape=We);const Oe=St(d),ze=oe=>{this.manager.actions.stop({event:oe})},Xe=Fu(Oe);te&&Oe.addEventListener("resize",ze),_e(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),le&&(Qe.observe(le),ce=Rm(u,le,Y),He=Dm(u,le,d));const ft=(n=s.dragOperation.source)==null?void 0:n.id,bt=()=>{var oe;if(!te||ft==null)return;const be=s.registry.draggables.get(ft),je=(oe=be?.handle)!=null?oe:be?.element;dn(je)&&je.focus()},q=()=>{var oe;if(ce?.disconnect(),He?.disconnect(),Qe.disconnect(),Oe.removeEventListener("resize",ze),Ga(d)&&(d.removeEventListener("beforetoggle",Rl),d.removeAttribute("popover")),d.removeAttribute(At),k.reset(),Ne&&Ja(u)){const je=Array.from(u.cells);for(const[N,j]of je.entries())j.style.width=(oe=Ne[N])!=null?oe:""}l.status="idle";const be=r.current.translate!=null;le&&(be||le.parentElement!==d.parentElement)&&d.isConnected&&le.replaceWith(d),le?.remove()},pe=a?.dropAnimation,et=this,Ge=Ar(()=>{var oe;const{transform:be,status:je}=o;if(!(!be.x&&!be.y&&!r.current.translate)&&je.dragging){const N=(oe=m.translate)!=null?oe:{x:0,y:0},j={x:be.x/h.scaleX+N.x,y:be.y/h.scaleY+N.y},Q=r.current.translate,re=_e(()=>o.modifiers),me=_e(()=>{var J;return(J=o.shape)==null?void 0:J.current}),Le=te&&!Xe?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(k.set({transition:`${E}, translate ${Le}`,translate:`${j.x}px ${j.y}px 0`},qe),ce?.takeRecords(),me&&me!==We&&Q&&!re.length){const J=Tt.delta(j,Q);o.shape=Tr.from(me.boundingRectangle).translate(J.x*h.scaleX,J.y*h.scaleY)}else o.shape=new Lt(d);r.current.translate=j}},function(){if(o.status.dropped){this.dispose(),l.status="dropping";const oe=et.dropAnimation!==void 0?et.dropAnimation:pe;let be=r.current.translate;const je=be!=null;if(!be&&u!==d&&(be={x:0,y:0}),!be||oe===null){q();return}s.renderer.rendering.then(()=>{Lm({element:u,feedbackElement:d,placeholder:le,translate:be,moved:je,transition:E,alignment:l.alignment,styles:k,animation:oe??void 0,getElementMutationObserver:()=>ce,cleanup:q,restoreFocus:bt})})}});return()=>{q(),Ge()}};vt(xr,4,"overlay",sd,Cr,ii);yn(xr,Cr);Cr.configure=gn(Cr);var eo=Cr,Yn=!0,Bm=!1,id,ld,cd,ud,Ht,li,ci;ud=(cd=[ge],_t.Forward),ld=(id=[ge],_t.Reverse);var Sr=class{constructor(){De(this,li,Fe(Ht,8,this,Yn)),Fe(Ht,11,this),De(this,ci,Fe(Ht,12,this,Yn)),Fe(Ht,15,this)}isLocked(e){return e===_t.Idle?!1:e==null?this[_t.Forward]===Yn&&this[_t.Reverse]===Yn:this[e]===Yn}unlock(e){e!==_t.Idle&&(this[e]=Bm)}};Ht=Xn(null);li=new WeakMap;ci=new WeakMap;vt(Ht,4,ud,cd,Sr,li);vt(Ht,4,ld,id,Sr,ci);yn(Ht,Sr);var Wm=[_t.Forward,_t.Reverse],Dl=class{constructor(){this.x=new Sr,this.y=new Sr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Vm=class extends dt{constructor(e){super(e);const t=Mr(new Dl);let n=null;this.signal=t,Ct(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Dl;return}const{delta:s}=e.dragOperation.position;if(n){const a={x:Pl(s.x,n.x),y:Pl(s.y,n.y)},o=t.peek();Xt(()=>{for(const i of Nc)for(const l of Wm)a[i]===l&&o[i].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function Pl(e,t){return Math.sign(e-t)}var dd,to,kr,ui,jt,no,Gs=class extends(to=Rr,dd=[ge],to){constructor(e){super(e),De(this,ui,Fe(kr,8,this,!1)),Fe(kr,11,this),De(this,jt),De(this,no,()=>{if(!Se(this,jt))return;const{element:a,by:o}=Se(this,jt);o.y&&(a.scrollTop+=o.y),o.x&&(a.scrollLeft+=o.x)}),this.scroll=a=>{var o;if(this.disabled)return!1;const i=this.getScrollableElements();if(!i)return st(this,jt,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:u}=a??{},f=u?{x:Fl(u.x),y:Fl(u.y)}:void 0,m=f?void 0:this.scrollIntentTracker.current;if(m?.isLocked())return!1;for(const d of i){const h=Rp(d,u);if(h.x||h.y){const{speed:g,direction:v}=Zp(d,c,f);if(m)for(const y of Nc)m[y].isLocked(v[y])&&(g[y]=0,v[y]=0);if(v.x||v.y){const{x:y,y:b}=u??v,w=y*g.x,_=b*g.y;if(w||_){const x=(o=Se(this,jt))==null?void 0:o.by;if(this.autoScrolling&&x&&(x.x&&!w||x.y&&!_))continue;return st(this,jt,{element:d,by:{x:w,y:_}}),Is.schedule(Se(this,no)),!0}}}}}return st(this,jt,void 0),!1};let t=null,n=null;const r=_s(()=>{const{position:a,source:o}=e.dragOperation;if(!a)return null;const i=Ou(Ss(o?.element),a.current);return i&&(t=i),i??t}),s=_s(()=>{const a=r.value,{documentElement:o}=vn(a);if(!a||a===o){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=Ua(l,{excludeElement:!1});return n=c,c}}if(a){const i=Ua(a,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},yr);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new Vm(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!ni(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};kr=Xn(to);ui=new WeakMap;jt=new WeakMap;no=new WeakMap;vt(kr,4,"autoScrolling",dd,Gs,ui);yn(kr,Gs);function Fl(e){return e>0?_t.Forward:e<0?_t.Reverse:_t.Idle}var Nm=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 Nm(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),jm=10,fd=class extends dt{constructor(e,t){super(e);const n=e.registry.plugins.get(Gs);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=Ct(()=>{if(this.disabled)return;const{position:r,status:s}=e.dragOperation;if(s.dragging)if(n.scroll()){n.autoScrolling=!0;const o=setInterval(()=>zm.schedule(n.scroll),jm);return()=>{clearInterval(o)}}else n.autoScrolling=!1})}},Ol={capture:!0,passive:!0},cr,Zm=class extends Rr{constructor(e){super(e),De(this,cr),this.handleScroll=()=>{Se(this,cr)==null&&st(this,cr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),st(this,cr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=Ct(()=>{var n,r,s;if(t.status.dragging){const o=(s=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?s:document;return o.addEventListener("scroll",this.handleScroll,Ol),()=>{o.removeEventListener("scroll",this.handleScroll,Ol)}}})}};cr=new WeakMap;var Hm=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.destroy=Ct(()=>{var n;const{dragOperation:r}=this.manager,{nonce:s}=(n=this.options)!=null?n:{};if(r.status.initialized){const a=document.createElement("style");return s&&a.setAttribute("nonce",s),a.textContent="* { user-select: none !important; -webkit-user-select: none !important; }",document.head.appendChild(a),ya(),document.addEventListener("selectionchange",ya,{capture:!0}),()=>{document.removeEventListener("selectionchange",ya,{capture:!0}),a.remove()}}})}};function ya(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var ur=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),An,Rs=class extends Fn{constructor(t,n){super(t),this.manager=t,this.options=n,De(this,An,[]),this.listeners=new Lu,this.handleSourceKeyDown=(r,s,a)=>{if(this.disabled||r.defaultPrevented||!fn(r.target)||s.disabled)return;const{keyboardCodes:o=ur.keyboardCodes,preventActivation:i=ur.preventActivation}=a??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(i?.(r,s)||this.handleStart(r,s,a))}}bind(t,n=this.options){return Ct(()=>{var s;const a=(s=t.handle)!=null?s:t.element,o=i=>{ni(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(),Gp(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=vn(s),l=[this.listeners.bind(i,[{type:"keydown",listener:c=>this.handleKeyDown(c,n,r),options:{capture:!0}}])];Se(this,An).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=ur.keyboardCodes}=r??{};if(Cn(t,[...s.end,...s.cancel])){t.preventDefault();const a=Cn(t,s.cancel);this.handleEnd(t,a);return}Cn(t,s.up)?this.handleMove("up",t):Cn(t,s.down)&&this.handleMove("down",t),Cn(t,s.left)?this.handleMove("left",t):Cn(t,s.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,s;const{shape:a}=this.manager.dragOperation,o=n.shiftKey?5:1;let i={x:0,y:0},l=(s=(r=this.options)==null?void 0:r.offset)!=null?s:ur.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(fd);t?.disabled===!1&&(t.disable(),Se(this,An).push(()=>{t.enable()}))}cleanup(){Se(this,An).forEach(t=>t()),st(this,An,[])}destroy(){this.cleanup(),this.listeners.clear()}};An=new WeakMap;Rs.configure=gn(Rs);Rs.defaults=ur;var Gm=Rs;function Cn(e,t){return t.includes(e.code)}var ln,Um=class extends wu{constructor(){super(...arguments),De(this,ln)}onEvent(e){switch(e.type){case"pointerdown":st(this,ln,Ln(e));break;case"pointermove":if(!Se(this,ln))return;const{x:t,y:n}=Ln(e),r={x:t-Se(this,ln).x,y:n-Se(this,ln).y},{tolerance:s}=this.options;if(s&&Va(r,s)){this.abort();return}Va(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){st(this,ln,void 0)}};ln=new WeakMap;var Tn,cn,Xm=class extends wu{constructor(){super(...arguments),De(this,Tn),De(this,cn)}onEvent(e){switch(e.type){case"pointerdown":st(this,cn,Ln(e)),st(this,Tn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Se(this,cn))return;const{x:t,y:n}=Ln(e),r={x:t-Se(this,cn).x,y:n-Se(this,cn).y};Va(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Se(this,Tn)&&(clearTimeout(Se(this,Tn)),st(this,cn,void 0),st(this,Tn,void 0))}};Tn=new WeakMap;cn=new WeakMap;var Ft=class{};Ft.Delay=Xm;Ft.Distance=Um;var ro=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&fn(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Ft.Delay({value:250,tolerance:5})]:rm(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||!fn(r)||(n=t.handle)!=null&&n.contains(r)?!1:_p(r)}}),$n,Ds=class extends Fn{constructor(t,n){super(t),this.manager=t,this.options=n,De(this,$n,new Set),this.listeners=new Lu,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=ro.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return Ct(()=>{var s;const a=new AbortController,{signal:o}=a,i=c=>{nm(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&&(qm(c.ownerDocument.defaultView),c.addEventListener("pointerdown",i,{signal:o}));return()=>a.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!fn(t.target)||n.disabled||Ym(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=ro.preventActivation}=r??{};if(s?.(t,n))return;const{target:a}=t,o=dn(a)&&a.draggable&&a.getAttribute("draggable")==="true",i=Wn(n.element),{x:l,y:c}=Ln(t);this.initialCoordinates={x:l*i.scaleX+i.x,y:c*i.scaleY+i.y};const u=this.activationConstraints(t,n,r);t.sensor=this;const f=new dp(u,g=>this.handleStart(n,g));f.signal.onabort=()=>this.handleCancel(t),f.onEvent(t),this.controller=f;const m=Za(),d=this.listeners.bind(m,[{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:rs,options:{capture:!0}}]),h=()=>{d(),this.initialCoordinates=void 0};Se(this,$n).add(h)}handlePointerMove(t,n){var r,s;if(((r=this.controller)==null?void 0:r.activated)===!1){(s=this.controller)==null||s.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const a=Ln(t),o=Wn(n.element);a.x=a.x*o.scaleX+o.x,a.y=a.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=a,Is.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:s}=this;if(!s||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:s,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const i=vn(n.target).body;i.setPointerCapture(n.pointerId);const l=fn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:rs,options:{passive:!1}},{type:"click",listener:rs},{type:"contextmenu",listener:rs},{type:"keydown",listener:this.handleKeyDown}]);Se(this,$n).add(c)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){this.latest={event:void 0,coordinates:void 0},Se(this,$n).forEach(t=>t()),Se(this,$n).clear()}destroy(){this.cleanup(),this.listeners.clear()}};$n=new WeakMap;Ds.configure=gn(Ds);Ds.defaults=ro;var so=Ds;function Ym(e){return"sensor"in e}function rs(e){e.preventDefault()}function Km(){}var Ll=new WeakSet;function qm(e){!e||Ll.has(e)||(e.addEventListener("touchmove",Km,{capture:!1,passive:!1}),Ll.add(e))}var Dn={modifiers:[],plugins:[xm,fd,Sm,eo,Hm],sensors:[so,Gm]},di=class extends pp{constructor(e={}){const t=Ot(e.plugins,Dn.plugins),n=Ot(e.sensors,Dn.sensors),r=Ot(e.modifiers,Dn.modifiers);super(si(_r({},e),{plugins:[Zm,Gs,bn,...t],sensors:n,modifiers:r}))}},hd,pd,md,ao,Et,fi,hi,pi,Fr=class extends(ao=$t,md=[ge],pd=[ge],hd=[ge],ao){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:a,feedback:o="default"}=n,i=Uu(n,["element","effects","handle","feedback"]);super(_r({effects:()=>[...s(),()=>{var l,c;const{manager:u}=this;if(!u)return;const m=((c=(l=this.sensors)==null?void 0:l.map(Eo))!=null?c:[...u.sensors]).map(d=>{const h=d instanceof Fn?d:u.registry.register(d.plugin),g=d instanceof Fn?void 0:d.options;return h.bind(this,g)});return function(){m.forEach(h=>h())}}]},i),t),De(this,fi,Fe(Et,8,this)),Fe(Et,11,this),De(this,hi,Fe(Et,12,this)),Fe(Et,15,this),De(this,pi,Fe(Et,16,this)),Fe(Et,19,this),this.element=r,this.handle=a,this.feedback=o}};Et=Xn(ao);fi=new WeakMap;hi=new WeakMap;pi=new WeakMap;vt(Et,4,"handle",md,Fr,fi);vt(Et,4,"element",pd,Fr,hi);vt(Et,4,"feedback",hd,Fr,pi);yn(Et,Fr);var gd,vd,oo,Gt,mi,ba,yd,bd,gr,gi,wd=class extends(oo=Rt,vd=[ge],gd=[ge],oo){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,a=Uu(n,["element","effects"]);const{collisionDetector:o=im}=a,i=c=>{const{manager:u,element:f}=this;if(!f||c===null){this.shape=void 0;return}if(!u)return;const m=new Lt(f),d=_e(()=>this.shape);return m&&d?.equals(m)?d:(this.shape=m,m)},l=Mr(!1);super(si(_r({},a),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:c,manager:u}=this;if(!u)return;const{dragOperation:f}=u,{source:m}=f;l.value=!!(m&&f.status.initialized&&c&&!this.disabled&&this.accepts(m))},()=>{const{element:c}=this;if(l.value&&c){const u=new $p(c,i);return()=>{u.disconnect(),this.shape=void 0}}},()=>{var c;if((c=this.manager)!=null&&c.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),De(this,gr),De(this,mi,Fe(Gt,8,this)),Fe(Gt,11,this),De(this,gi,Fe(Gt,12,this)),Fe(Gt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){st(this,gr,e,bd)}get element(){var e;return(e=this.proxy)!=null?e:Se(this,gr,yd)}};Gt=Xn(oo);mi=new WeakMap;gr=new WeakSet;gi=new WeakMap;ba=vt(Gt,20,"#element",vd,gr,mi),yd=ba.get,bd=ba.set;vt(Gt,4,"proxy",gd,wd,gi);yn(Gt,wd);function Jm(e){return e!=null&&typeof e=="object"&&"current"in e}function Ps(e){var t;if(e!=null)return Jm(e)?(t=e.current)!=null?t:void 0:e}var Qm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Us=Qm?p.useLayoutEffect:p.useEffect;function eg(){const e=p.useState(0)[1];return p.useCallback(()=>{e(t=>t+1)},[e])}function tg(e,t){const n=p.useRef(new Map),r=eg();return Us(()=>{if(!e){n.current.clear();return}return Ct(()=>{var s;let a=!1,o=!1;for(const i of n.current){const[l]=i,c=_e(()=>i[1]),u=e[l];c!==u&&(a=!0,n.current.set(l,u),o=(s=t?.(l,c,u))!=null?s:!1)}a&&(o?go.flushSync(r):r())})},[e]),p.useMemo(()=>e&&new Proxy(e,{get(s,a){const o=s[a];return n.current.set(a,o),o}}),[e])}function rn(e,t,n=p.useEffect,r=Object.is){const s=p.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}function Bl(e,t){const n=p.useRef(Ps(e));Us(()=>{const r=Ps(e);r!==n.current&&(n.current=r,t(r))})}var ng=Object.defineProperty,rg=Object.defineProperties,sg=Object.getOwnPropertyDescriptors,Wl=Object.getOwnPropertySymbols,ag=Object.prototype.hasOwnProperty,og=Object.prototype.propertyIsEnumerable,Vl=(e,t,n)=>t in e?ng(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ig=(e,t)=>{for(var n in t||(t={}))ag.call(t,n)&&Vl(e,n,t[n]);if(Wl)for(var n of Wl(t))og.call(t,n)&&Vl(e,n,t[n]);return e},lg=(e,t)=>rg(e,sg(t)),cg=new di,ug=p.createContext(cg);p.memo(p.forwardRef(({children:e},t)=>{const[n,r]=p.useState(0),s=p.useRef(null),a=p.useRef(null),o=p.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{a.current=l})),p.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Us(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),p.useImperativeHandle(t,()=>o),null}));function dg(){return p.useContext(ug)}function fg(e){var t;const n=(t=dg())!=null?t:void 0,[r]=p.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Us(r.register,[n,r]),r}function wa(e){const{disabled:t,data:n,element:r,handle:s,id:a,modifiers:o,sensors:i}=e,l=fg(u=>new Fr(lg(ig({},e),{register:!1,handle:Ps(s),element:Ps(r)}),u)),c=tg(l,hg);return rn(a,()=>l.id=a),Bl(s,u=>l.handle=u),Bl(r,u=>l.element=u),rn(n,()=>n&&(l.data=n)),rn(t,()=>l.disabled=t===!0),rn(i,()=>l.sensors=i),rn(o,()=>l.modifiers=o,void 0,yr),rn(e.feedback,()=>{var u;return l.feedback=(u=e.feedback)!=null?u:"default"}),rn(e.alignment,()=>l.alignment=e.alignment),{draggable:c,get isDragging(){return c.isDragging},get isDropping(){return c.isDropping},get isDragSource(){return c.isDragSource},handleRef:p.useCallback(u=>{l.handle=u??void 0},[l]),ref:p.useCallback(u=>{var f,m;!u&&((f=l.element)!=null&&f.isConnected)&&!((m=l.manager)!=null&&m.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function hg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var pg=Object.create,_d=Object.defineProperty,mg=Object.getOwnPropertyDescriptor,xd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Xs=e=>{throw TypeError(e)},gg=(e,t,n)=>t in e?_d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vg=e=>{var t;return[,,,pg((t=e?.[xd("metadata")])!=null?t:null)]},Cd=["class","method","getter","setter","accessor","field","value","get","set"],Sd=e=>e!==void 0&&typeof e!="function"?Xs("Function expected"):e,yg=(e,t,n,r,s)=>({kind:Cd[e],name:t,metadata:r,addInitializer:a=>n._?Xs("Already initialized"):s.push(Sd(a||null))}),bg=(e,t)=>gg(t,xd("metadata"),e[3]),wg=(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},kd=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=Cd[u+5],g=e[d]||(e[d]=[]),v=(s=s.prototype,mg(s,n)),y=r.length-1;y>=0;y--)l=yg(u,n,i={},e[3],g),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(v[h],l),i._=1,Sd(o)&&(v[h]=o);return v&&_d(s,n,v),s},Ed=(e,t,n)=>t.has(e)||Xs("Cannot "+n),_g=(e,t,n)=>(Ed(e,t,"read from private field"),t.get(e)),xg=(e,t,n)=>t.has(e)?Xs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Cg=(e,t,n,r)=>(Ed(e,t,"write to private field"),t.set(e,n),n),Kn=class io{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new io(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 io(t,n)}},Id,Md,lo,gs,Or,vi=class extends(lo=Kt,Md=[$e],Id=[$e],lo){constructor(t){const n=Kn.from(t);super(n,(r,s)=>Kn.equals(r,s)),wg(Or,5,this),xg(this,gs,0),this.velocity={x:0,y:0}}get delta(){return Kn.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=Kn.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-_g(this,gs),i=l=>Math.round(l/o*100);Xt(()=>{Cg(this,gs,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Kn.from(t)),this.velocity={x:0,y:0}}};Or=vg(lo);gs=new WeakMap;kd(Or,2,"delta",Md,vi);kd(Or,2,"direction",Id,vi);bg(Or,vi);var Ad=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ad||{});Object.values(Ad);const Sg=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"}))]]),kg=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"}))]]),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,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"}))]]),Ig=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"}))]]),Mg=p.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Lr=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:m="regular",mirrored:d=!1,...h}=D.useContext(Mg);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??m))});Lr.displayName="IconBase";const Td=D.forwardRef((e,t)=>D.createElement(Lr,{ref:t,...e,weights:Sg}));Td.displayName="DotsThreeIcon";const $d=D.forwardRef((e,t)=>D.createElement(Lr,{ref:t,...e,weights:kg}));$d.displayName="SpeakerHighIcon";const Rd=D.forwardRef((e,t)=>D.createElement(Lr,{ref:t,...e,weights:Eg}));Rd.displayName="SpeakerLowIcon";const Dd=D.forwardRef((e,t)=>D.createElement(Lr,{ref:t,...e,weights:Ig}));Dd.displayName="XIcon";const Ag=Dd;F.span`
|
|
66
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Am(e,t="hidden"){return we(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Tm(n,r.registry.droppables),a=[],o=wp(n),{remove:i}=o;return $m(s,o,a),Rm(o,t),o.remove=()=>{a.forEach(l=>l()),i.call(o)},o})}function Tm(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Fr}${Ka("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function $m(e,t,n){for(const[r,s]of e){if(!r.element)continue;const a=`[${s}]`,o=t.matches(a)?t:t.querySelector(a);if(r.element.removeAttribute(s),!o)continue;const i=r.element;r.proxy=o,o.removeAttribute(s),Il.set(i,o),n.push(()=>{Il.delete(i),r.proxy=void 0})}}function Rm(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Rs,t)}function sd(e,t){return e===t?!0:Bn(e)===Bn(t)}function Dl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&fn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>_r(t))}function eo(e){return e.tagName==="TR"}function Dm(e,t,n){const r=new MutationObserver(s=>{let a=!1;for(const o of s){if(o.target!==e){a=!0;continue}if(o.type!=="attributes")continue;const i=o.attributeName;if(i.startsWith("aria-")||Em.includes(i))continue;const l=e.getAttribute(i);if(i==="style"){if(mr(e)&&mr(t)){const c=e.style;for(const u of Array.from(t.style))c.getPropertyValue(u)===""&&t.style.removeProperty(u);for(const u of Array.from(c)){if(Im.includes(u)||u.startsWith(et))continue;const f=c.getPropertyValue(u);t.style.setProperty(u,f)}}}else l!==null?t.setAttribute(i,l):t.removeAttribute(i)}a&&n&&(t.innerHTML=e.innerHTML)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function Pm(e,t,n){const r=new MutationObserver(s=>{for(const a of s)if(a.addedNodes.length!==0)for(const o of Array.from(a.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),_r(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),_r(n);return}}});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Fm(e){return new ResizeObserver(()=>{var t,n;const r=new Bt(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},a=(e.width-r.width)*s.x+e.delta.x,o=(e.height-r.height)*s.y+e.delta.y,i=Fu();if(e.styles.set({width:r.width-e.widthOffset,height:r.height-e.heightOffset,top:e.top+o+i.y,left:e.left+a+i.x},et),(n=e.getElementMutationObserver())==null||n.takeRecords(),eo(e.element)&&eo(e.placeholder)){const l=Array.from(e.element.cells),c=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(l.map(u=>u.style.width));for(const[u,f]of l.entries()){const m=c[u];f.style.width=`${m.getBoundingClientRect().width}px`}}e.dragOperation.shape=new Bt(e.feedbackElement)})}var Om=250,Lm="ease";function Bm(e){var t,n,r,s;const{animation:a}=e;if(typeof a=="function"){const b=a({element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(b).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=Om,easing:i=Lm}=a??{};_r(e.feedbackElement);const[,l]=(t=gp(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:sd(e.feedbackElement,c)?null:void 0},f=new Bt(e.feedbackElement,u),m=(r=ni(Nt(e.feedbackElement).translate))!=null?r:e.translate,d=new Bt(c,u),h=$r.delta(f,d,e.alignment),v={x:m.x-h.x,y:m.y-h.y},g=Math.round(f.intrinsicHeight)!==Math.round(d.intrinsicHeight)?{minHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`],maxHeight:[`${f.intrinsicHeight}px`,`${d.intrinsicHeight}px`]}:{},y=Math.round(f.intrinsicWidth)!==Math.round(d.intrinsicWidth)?{minWidth:[`${f.intrinsicWidth}px`,`${d.intrinsicWidth}px`],maxWidth:[`${f.intrinsicWidth}px`,`${d.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},et),e.feedbackElement.setAttribute(Qa,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),Kp({element:e.feedbackElement,keyframes:oi(xr(xr({},g),y),{translate:[`${m.x}px ${m.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:Ou(xt(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:i}}).then(()=>{e.feedbackElement.removeAttribute(Qa),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var ad,to,Cr,ci,gs,od,id,Sr=class extends(to=dt,ad=[he],to){constructor(t,n){super(t,n),Oe(this,gs),Oe(this,ci,We(Cr,8,this)),We(Cr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(bn),s=r?.register(Mm);if(s){const a=this.destroy.bind(this);this.destroy=()=>{s(),a()}}this.registerEffect(hn(this,gs,od).bind(this,r)),this.registerEffect(hn(this,gs,id))}};Cr=Xn(to);ci=new WeakMap;gs=new WeakSet;od=function(e){const{overlay:t}=this;if(!t||!e)return;const n=ks(t);if(n)return e.addRoot(n)};id=function(){var e,t,n;const{state:r,manager:s,options:a}=this,{dragOperation:o}=s,{position:i,source:l,status:c}=o;if(c.idle){r.current={},r.initial={};return}if(!l)return;const{element:u,feedback:f}=l;if(!u||f==="none"||!c.initialized||c.initializing)return;const{initial:m}=r,d=(e=this.overlay)!=null?e:u,h=Wn(d),v=Wn(u),g=!sd(u,d),y=new Bt(u,{frameTransform:g?v:null,ignoreTransforms:!g}),b={x:v.scaleX/h.scaleX,y:v.scaleY/h.scaleY};let{width:_,height:w,top:x,left:S}=y;g&&(_=_/b.x,w=w/b.y);const k=new nm(d),{transition:E,translate:M,boxSizing:T,paddingBlockStart:$,paddingBlockEnd:A,paddingInlineStart:I,paddingInlineEnd:R,borderInlineStartWidth:D,borderInlineEndWidth:O,borderBlockStartWidth:Z,borderBlockEndWidth:G}=Nt(u),Y=f==="clone",te=T==="content-box",X=te?parseInt(I)+parseInt(R)+parseInt(D)+parseInt(O):0,K=te?parseInt($)+parseInt(A)+parseInt(Z)+parseInt(G):0,le=f!=="move"&&!this.overlay?Am(l,Y?"clone":"hidden"):null,J=we(()=>si(s.dragOperation.activatorEvent));if(M!=="none"){const oe=ni(M);oe&&!m.translate&&(m.translate=oe)}if(!m.transformOrigin){const oe=we(()=>i.current);m.transformOrigin={x:(oe.x-S*h.scaleX-h.x)/(_*h.scaleX),y:(oe.y-x*h.scaleY-h.y)/(w*h.scaleY)}}const{transformOrigin:de}=m,ue=x*h.scaleY+h.y,ne=S*h.scaleX+h.x;if(!m.coordinates&&(m.coordinates={x:ne,y:ue},b.x!==1||b.y!==1)){const{scaleX:oe,scaleY:ve}=v,{x:Xe,y:kt}=de;m.coordinates.x+=(_*oe-_)*Xe,m.coordinates.y+=(w*ve-w)*kt}m.dimensions||(m.dimensions={width:_,height:w}),m.frameTransform||(m.frameTransform=h);const z={x:m.coordinates.x-ne,y:m.coordinates.y-ue},ae={width:(m.dimensions.width*m.frameTransform.scaleX-_*h.scaleX)*de.x,height:(m.dimensions.height*m.frameTransform.scaleY-w*h.scaleY)*de.y},ke={x:z.x/h.scaleX+ae.width,y:z.y/h.scaleY+ae.height},ce={left:S+ke.x,top:x+ke.y};d.setAttribute(At,"true");const xe=we(()=>o.transform),B=(t=m.translate)!=null?t:{x:0,y:0},_e=xe.x*h.scaleX+B.x,re=xe.y*h.scaleY+B.y,Me=Fu();k.set({width:_-X,height:w-K,top:ce.top+Me.y,left:ce.left+Me.x,translate:`${_e}px ${re}px 0`,transition:E?`${E}, translate 0ms linear`:"",scale:g?`${b.x} ${b.y}`:"","transform-origin":`${de.x*100}% ${de.y*100}%`},et),le&&(u.insertAdjacentElement("afterend",le),a?.rootElement&&(typeof a.rootElement=="function"?a.rootElement(l):a.rootElement).appendChild(u)),Xa(d)&&(d.hasAttribute("popover")||d.setAttribute("popover","manual"),_r(d),d.addEventListener("beforetoggle",Dl));let pe,Ae,He;const qe=Fm({placeholder:le,element:u,feedbackElement:d,frameTransform:h,transformOrigin:de,width:_,height:w,top:x,left:S,widthOffset:X,heightOffset:K,delta:ke,styles:k,dragOperation:o,getElementMutationObserver:()=>pe,getSavedCellWidths:()=>He,setSavedCellWidths:oe=>{He=oe}}),Ve=new Bt(d);we(()=>o.shape=Ve);const Le=xt(d),je=oe=>{this.manager.actions.stop({event:oe})},tt=Ou(Le);J&&Le.addEventListener("resize",je),we(()=>l.status)==="idle"&&requestAnimationFrame(()=>l.status="dragging"),le&&(qe.observe(le),pe=Dm(u,le,Y),Ae=Pm(u,le,d));const Ct=(n=s.dragOperation.source)==null?void 0:n.id,St=()=>{var oe;if(!J||Ct==null)return;const ve=s.registry.draggables.get(Ct),Xe=(oe=ve?.handle)!=null?oe:ve?.element;dn(Xe)&&Xe.focus()},j=()=>{var oe;if(pe?.disconnect(),Ae?.disconnect(),qe.disconnect(),Le.removeEventListener("resize",je),Xa(d)&&(d.removeEventListener("beforetoggle",Dl),d.removeAttribute("popover")),d.removeAttribute(At),k.reset(),He&&eo(u)){const Xe=Array.from(u.cells);for(const[kt,N]of Xe.entries())N.style.width=(oe=He[kt])!=null?oe:""}l.status="idle";const ve=r.current.translate!=null;le&&(ve||le.parentElement!==d.parentElement)&&d.isConnected&&le.replaceWith(d),le?.remove()},ge=a?.dropAnimation,Ge=this,Ue=Tr(()=>{var oe;const{transform:ve,status:Xe}=o;if(!(!ve.x&&!ve.y&&!r.current.translate)&&Xe.dragging){const kt=(oe=m.translate)!=null?oe:{x:0,y:0},N={x:ve.x/h.scaleX+kt.x,y:ve.y/h.scaleY+kt.y},q=r.current.translate,U=we(()=>o.modifiers),Q=we(()=>{var De;return(De=o.shape)==null?void 0:De.current}),Te=J&&!tt?"250ms cubic-bezier(0.25, 1, 0.5, 1)":"0ms linear";if(k.set({transition:`${E}, translate ${Te}`,translate:`${N.x}px ${N.y}px 0`},et),pe?.takeRecords(),Q&&Q!==Ve&&q&&!U.length){const De=Tt.delta(N,q);o.shape=$r.from(Q.boundingRectangle).translate(De.x*h.scaleX,De.y*h.scaleY)}else o.shape=new Bt(d);r.current.translate=N}},function(){if(o.status.dropped){this.dispose(),l.status="dropping";const oe=Ge.dropAnimation!==void 0?Ge.dropAnimation:ge;let ve=r.current.translate;const Xe=ve!=null;if(!ve&&u!==d&&(ve={x:0,y:0}),!ve||oe===null){j();return}s.renderer.rendering.then(()=>{Bm({element:u,feedbackElement:d,placeholder:le,translate:ve,moved:Xe,transition:E,alignment:l.alignment,styles:k,animation:oe??void 0,getElementMutationObserver:()=>pe,cleanup:j,restoreFocus:St})})}});return()=>{j(),Ue()}};gt(Cr,4,"overlay",ad,Sr,ci);yn(Cr,Sr);Sr.configure=gn(Sr);var no=Sr,Kn=!0,Wm=!1,ld,cd,ud,dd,Ut,ui,di;dd=(ud=[he],bt.Forward),cd=(ld=[he],bt.Reverse);var kr=class{constructor(){Oe(this,ui,We(Ut,8,this,Kn)),We(Ut,11,this),Oe(this,di,We(Ut,12,this,Kn)),We(Ut,15,this)}isLocked(e){return e===bt.Idle?!1:e==null?this[bt.Forward]===Kn&&this[bt.Reverse]===Kn:this[e]===Kn}unlock(e){e!==bt.Idle&&(this[e]=Wm)}};Ut=Xn(null);ui=new WeakMap;di=new WeakMap;gt(Ut,4,dd,ud,kr,ui);gt(Ut,4,cd,ld,kr,di);yn(Ut,kr);var Vm=[bt.Forward,bt.Reverse],Pl=class{constructor(){this.x=new kr,this.y=new kr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Nm=class extends dt{constructor(e){super(e);const t=Ar(new Pl);let n=null;this.signal=t,_t(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Pl;return}const{delta:s}=e.dragOperation.position;if(n){const a={x:Fl(s.x,n.x),y:Fl(s.y,n.y)},o=t.peek();Kt(()=>{for(const i of zc)for(const l of Vm)a[i]===l&&o[i].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function Fl(e,t){return Math.sign(e-t)}var fd,ro,Er,fi,Ht,so,Us=class extends(ro=Dr,fd=[he],ro){constructor(e){super(e),Oe(this,fi,We(Er,8,this,!1)),We(Er,11,this),Oe(this,Ht),Oe(this,so,()=>{if(!Se(this,Ht))return;const{element:a,by:o}=Se(this,Ht);o.y&&(a.scrollTop+=o.y),o.x&&(a.scrollLeft+=o.x)}),this.scroll=a=>{var o;if(this.disabled)return!1;const i=this.getScrollableElements();if(!i)return st(this,Ht,void 0),!1;const{position:l}=this.manager.dragOperation,c=l?.current;if(c){const{by:u}=a??{},f=u?{x:Ol(u.x),y:Ol(u.y)}:void 0,m=f?void 0:this.scrollIntentTracker.current;if(m?.isLocked())return!1;for(const d of i){const h=Dp(d,u);if(h.x||h.y){const{speed:v,direction:g}=Hp(d,c,f);if(m)for(const y of zc)m[y].isLocked(g[y])&&(v[y]=0,g[y]=0);if(g.x||g.y){const{x:y,y:b}=u??g,_=y*v.x,w=b*v.y;if(_||w){const x=(o=Se(this,Ht))==null?void 0:o.by;if(this.autoScrolling&&x&&(x.x&&!_||x.y&&!w))continue;return st(this,Ht,{element:d,by:{x:_,y:w}}),Ms.schedule(Se(this,so)),!0}}}}}return st(this,Ht,void 0),!1};let t=null,n=null;const r=xs(()=>{const{position:a,source:o}=e.dragOperation;if(!a)return null;const i=Lu(ks(o?.element),a.current);return i&&(t=i),i??t}),s=xs(()=>{const a=r.value,{documentElement:o}=vn(a);if(!a||a===o){const{target:i}=e.dragOperation,l=i?.element;if(l){const c=Ya(l,{excludeElement:!1});return n=c,c}}if(a){const i=Ya(a,{excludeElement:!1});return this.autoScrolling&&n&&i.size<n?.size?n:(n=i,i)}return n=null,null},br);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new Nm(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!si(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Er=Xn(ro);fi=new WeakMap;Ht=new WeakMap;so=new WeakMap;gt(Er,4,"autoScrolling",fd,Us,fi);yn(Er,Us);function Ol(e){return e>0?bt.Forward:e<0?bt.Reverse:bt.Idle}var zm=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},jm=new zm(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Zm=10,hd=class extends dt{constructor(e,t){super(e);const n=e.registry.plugins.get(Us);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=_t(()=>{if(this.disabled)return;const{position:r,status:s}=e.dragOperation;if(s.dragging)if(n.scroll()){n.autoScrolling=!0;const o=setInterval(()=>jm.schedule(n.scroll),Zm);return()=>{clearInterval(o)}}else n.autoScrolling=!1})}},Ll={capture:!0,passive:!0},ur,Hm=class extends Dr{constructor(e){super(e),Oe(this,ur),this.handleScroll=()=>{Se(this,ur)==null&&st(this,ur,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),st(this,ur,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=_t(()=>{var n,r,s;if(t.status.dragging){const o=(s=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?s:document;return o.addEventListener("scroll",this.handleScroll,Ll),()=>{o.removeEventListener("scroll",this.handleScroll,Ll)}}})}};ur=new WeakMap;var Gm=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.destroy=_t(()=>{var n;const{dragOperation:r}=this.manager,{nonce:s}=(n=this.options)!=null?n:{};if(r.status.initialized){const a=document.createElement("style");return s&&a.setAttribute("nonce",s),a.textContent="* { user-select: none !important; -webkit-user-select: none !important; }",document.head.appendChild(a),ba(),document.addEventListener("selectionchange",ba,{capture:!0}),()=>{document.removeEventListener("selectionchange",ba,{capture:!0}),a.remove()}}})}};function ba(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var dr=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),An,Ds=class extends Fn{constructor(t,n){super(t),this.manager=t,this.options=n,Oe(this,An,[]),this.listeners=new Bu,this.handleSourceKeyDown=(r,s,a)=>{if(this.disabled||r.defaultPrevented||!fn(r.target)||s.disabled)return;const{keyboardCodes:o=dr.keyboardCodes,preventActivation:i=dr.preventActivation}=a??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(i?.(r,s)||this.handleStart(r,s,a))}}bind(t,n=this.options){return _t(()=>{var s;const a=(s=t.handle)!=null?s:t.element,o=i=>{si(i)&&this.handleSourceKeyDown(i,t,n)};if(a)return a.addEventListener("keydown",o),()=>{a.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:s}=n;if(!s)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),Up(s);const{center:a}=new Bt(s);if(this.manager.actions.start({event:t,coordinates:{x:a.x,y:a.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const i=vn(s),l=[this.listeners.bind(i,[{type:"keydown",listener:c=>this.handleKeyDown(c,n,r),options:{capture:!0}}])];Se(this,An).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=dr.keyboardCodes}=r??{};if(Cn(t,[...s.end,...s.cancel])){t.preventDefault();const a=Cn(t,s.cancel);this.handleEnd(t,a);return}Cn(t,s.up)?this.handleMove("up",t):Cn(t,s.down)&&this.handleMove("down",t),Cn(t,s.left)?this.handleMove("left",t):Cn(t,s.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,s;const{shape:a}=this.manager.dragOperation,o=n.shiftKey?5:1;let i={x:0,y:0},l=(s=(r=this.options)==null?void 0:r.offset)!=null?s:dr.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!a){switch(t){case"up":i={x:0,y:-l.y*o};break;case"down":i={x:0,y:l.y*o};break;case"left":i={x:-l.x*o,y:0};break;case"right":i={x:l.x*o,y:0};break}(i.x||i.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:i}))}}sideEffects(){const t=this.manager.registry.plugins.get(hd);t?.disabled===!1&&(t.disable(),Se(this,An).push(()=>{t.enable()}))}cleanup(){Se(this,An).forEach(t=>t()),st(this,An,[])}destroy(){this.cleanup(),this.listeners.clear()}};An=new WeakMap;Ds.configure=gn(Ds);Ds.defaults=dr;var Um=Ds;function Cn(e,t){return t.includes(e.code)}var ln,Xm=class extends _u{constructor(){super(...arguments),Oe(this,ln)}onEvent(e){switch(e.type){case"pointerdown":st(this,ln,Ln(e));break;case"pointermove":if(!Se(this,ln))return;const{x:t,y:n}=Ln(e),r={x:t-Se(this,ln).x,y:n-Se(this,ln).y},{tolerance:s}=this.options;if(s&&za(r,s)){this.abort();return}za(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){st(this,ln,void 0)}};ln=new WeakMap;var Tn,cn,Ym=class extends _u{constructor(){super(...arguments),Oe(this,Tn),Oe(this,cn)}onEvent(e){switch(e.type){case"pointerdown":st(this,cn,Ln(e)),st(this,Tn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Se(this,cn))return;const{x:t,y:n}=Ln(e),r={x:t-Se(this,cn).x,y:n-Se(this,cn).y};za(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Se(this,Tn)&&(clearTimeout(Se(this,Tn)),st(this,cn,void 0),st(this,Tn,void 0))}};Tn=new WeakMap;cn=new WeakMap;var Ot=class{};Ot.Delay=Ym;Ot.Distance=Xm;var ao=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&fn(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Ot.Delay({value:250,tolerance:5})]:sm(s)&&!e.defaultPrevented?[new Ot.Delay({value:200,tolerance:0})]:[new Ot.Delay({value:200,tolerance:10}),new Ot.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;return r===t.element||r===t.handle||!fn(r)||(n=t.handle)!=null&&n.contains(r)?!1:xp(r)}}),$n,Ps=class extends Fn{constructor(t,n){super(t),this.manager=t,this.options=n,Oe(this,$n,new Set),this.listeners=new Bu,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:s}=this.latest;!r||!s||this.manager.actions.move({event:r,to:s})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:s=ao.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return _t(()=>{var s;const a=new AbortController,{signal:o}=a,i=c=>{rm(c)&&this.handlePointerDown(c,t,n)};let l=[(s=t.handle)!=null?s:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const c of l)c&&(Jm(c.ownerDocument.defaultView),c.addEventListener("pointerdown",i,{signal:o}));return()=>a.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!fn(t.target)||n.disabled||Km(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=ao.preventActivation}=r??{};if(s?.(t,n))return;const{target:a}=t,o=dn(a)&&a.draggable&&a.getAttribute("draggable")==="true",i=Wn(n.element),{x:l,y:c}=Ln(t);this.initialCoordinates={x:l*i.scaleX+i.x,y:c*i.scaleY+i.y};const u=this.activationConstraints(t,n,r);t.sensor=this;const f=new fp(u,v=>this.handleStart(n,v));f.signal.onabort=()=>this.handleCancel(t),f.onEvent(t),this.controller=f;const m=Ga(),d=this.listeners.bind(m,[{type:"pointermove",listener:v=>this.handlePointerMove(v,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:ss,options:{capture:!0}}]),h=()=>{d(),this.initialCoordinates=void 0};Se(this,$n).add(h)}handlePointerMove(t,n){var r,s;if(((r=this.controller)==null?void 0:r.activated)===!1){(s=this.controller)==null||s.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const a=Ln(t),o=Wn(n.element);a.x=a.x*o.scaleX+o.x,a.y=a.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=a,Ms.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:s}=this;if(!s||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:s,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const i=vn(n.target).body;i.setPointerCapture(n.pointerId);const l=fn(n.target)?[n.target,i]:i,c=this.listeners.bind(l,[{type:"touchmove",listener:ss,options:{passive:!1}},{type:"click",listener:ss},{type:"contextmenu",listener:ss},{type:"keydown",listener:this.handleKeyDown}]);Se(this,$n).add(c)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){this.latest={event:void 0,coordinates:void 0},Se(this,$n).forEach(t=>t()),Se(this,$n).clear()}destroy(){this.cleanup(),this.listeners.clear()}};$n=new WeakMap;Ps.configure=gn(Ps);Ps.defaults=ao;var oo=Ps;function Km(e){return"sensor"in e}function ss(e){e.preventDefault()}function qm(){}var Bl=new WeakSet;function Jm(e){!e||Bl.has(e)||(e.addEventListener("touchmove",qm,{capture:!1,passive:!1}),Bl.add(e))}var Dn={modifiers:[],plugins:[Cm,hd,km,no,Gm],sensors:[oo,Um]},hi=class extends mp{constructor(e={}){const t=Lt(e.plugins,Dn.plugins),n=Lt(e.sensors,Dn.sensors),r=Lt(e.modifiers,Dn.modifiers);super(oi(xr({},e),{plugins:[Hm,Us,bn,...t],sensors:n,modifiers:r}))}},pd,md,gd,io,It,pi,mi,gi,Or=class extends(io=$t,gd=[he],md=[he],pd=[he],io){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:a,feedback:o="default"}=n,i=Xu(n,["element","effects","handle","feedback"]);super(xr({effects:()=>[...s(),()=>{var l,c;const{manager:u}=this;if(!u)return;const m=((c=(l=this.sensors)==null?void 0:l.map(Mo))!=null?c:[...u.sensors]).map(d=>{const h=d instanceof Fn?d:u.registry.register(d.plugin),v=d instanceof Fn?void 0:d.options;return h.bind(this,v)});return function(){m.forEach(h=>h())}}]},i),t),Oe(this,pi,We(It,8,this)),We(It,11,this),Oe(this,mi,We(It,12,this)),We(It,15,this),Oe(this,gi,We(It,16,this)),We(It,19,this),this.element=r,this.handle=a,this.feedback=o}};It=Xn(io);pi=new WeakMap;mi=new WeakMap;gi=new WeakMap;gt(It,4,"handle",gd,Or,pi);gt(It,4,"element",md,Or,mi);gt(It,4,"feedback",pd,Or,gi);yn(It,Or);var vd,yd,lo,Xt,vi,wa,bd,wd,vr,yi,_d=class extends(lo=Rt,yd=[he],vd=[he],lo){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,a=Xu(n,["element","effects"]);const{collisionDetector:o=lm}=a,i=c=>{const{manager:u,element:f}=this;if(!f||c===null){this.shape=void 0;return}if(!u)return;const m=new Bt(f),d=we(()=>this.shape);return m&&d?.equals(m)?d:(this.shape=m,m)},l=Ar(!1);super(oi(xr({},a),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:c,manager:u}=this;if(!u)return;const{dragOperation:f}=u,{source:m}=f;l.value=!!(m&&f.status.initialized&&c&&!this.disabled&&this.accepts(m))},()=>{const{element:c}=this;if(l.value&&c){const u=new Rp(c,i);return()=>{u.disconnect(),this.shape=void 0}}},()=>{var c;if((c=this.manager)!=null&&c.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),Oe(this,vr),Oe(this,vi,We(Xt,8,this)),We(Xt,11,this),Oe(this,yi,We(Xt,12,this)),We(Xt,15,this),this.element=r,this.refreshShape=()=>i()}set element(e){st(this,vr,e,wd)}get element(){var e;return(e=this.proxy)!=null?e:Se(this,vr,bd)}};Xt=Xn(lo);vi=new WeakMap;vr=new WeakSet;yi=new WeakMap;wa=gt(Xt,20,"#element",yd,vr,vi),bd=wa.get,wd=wa.set;gt(Xt,4,"proxy",vd,_d,yi);yn(Xt,_d);function Qm(e){return e!=null&&typeof e=="object"&&"current"in e}function Fs(e){var t;if(e!=null)return Qm(e)?(t=e.current)!=null?t:void 0:e}var eg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Xs=eg?p.useLayoutEffect:p.useEffect;function tg(){const e=p.useState(0)[1];return p.useCallback(()=>{e(t=>t+1)},[e])}function ng(e,t){const n=p.useRef(new Map),r=tg();return Xs(()=>{if(!e){n.current.clear();return}return _t(()=>{var s;let a=!1,o=!1;for(const i of n.current){const[l]=i,c=we(()=>i[1]),u=e[l];c!==u&&(a=!0,n.current.set(l,u),o=(s=t?.(l,c,u))!=null?s:!1)}a&&(o?yo.flushSync(r):r())})},[e]),p.useMemo(()=>e&&new Proxy(e,{get(s,a){const o=s[a];return n.current.set(a,o),o}}),[e])}function rn(e,t,n=p.useEffect,r=Object.is){const s=p.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}function Wl(e,t){const n=p.useRef(Fs(e));Xs(()=>{const r=Fs(e);r!==n.current&&(n.current=r,t(r))})}var rg=Object.defineProperty,sg=Object.defineProperties,ag=Object.getOwnPropertyDescriptors,Vl=Object.getOwnPropertySymbols,og=Object.prototype.hasOwnProperty,ig=Object.prototype.propertyIsEnumerable,Nl=(e,t,n)=>t in e?rg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lg=(e,t)=>{for(var n in t||(t={}))og.call(t,n)&&Nl(e,n,t[n]);if(Vl)for(var n of Vl(t))ig.call(t,n)&&Nl(e,n,t[n]);return e},cg=(e,t)=>sg(e,ag(t)),ug=new hi,dg=p.createContext(ug);p.memo(p.forwardRef(({children:e},t)=>{const[n,r]=p.useState(0),s=p.useRef(null),a=p.useRef(null),o=p.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{a.current=l})),p.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Xs(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),p.useImperativeHandle(t,()=>o),null}));function fg(){return p.useContext(dg)}function hg(e){var t;const n=(t=fg())!=null?t:void 0,[r]=p.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Xs(r.register,[n,r]),r}function _a(e){const{disabled:t,data:n,element:r,handle:s,id:a,modifiers:o,sensors:i}=e,l=hg(u=>new Or(cg(lg({},e),{register:!1,handle:Fs(s),element:Fs(r)}),u)),c=ng(l,pg);return rn(a,()=>l.id=a),Wl(s,u=>l.handle=u),Wl(r,u=>l.element=u),rn(n,()=>n&&(l.data=n)),rn(t,()=>l.disabled=t===!0),rn(i,()=>l.sensors=i),rn(o,()=>l.modifiers=o,void 0,br),rn(e.feedback,()=>{var u;return l.feedback=(u=e.feedback)!=null?u:"default"}),rn(e.alignment,()=>l.alignment=e.alignment),{draggable:c,get isDragging(){return c.isDragging},get isDropping(){return c.isDropping},get isDragSource(){return c.isDragSource},handleRef:p.useCallback(u=>{l.handle=u??void 0},[l]),ref:p.useCallback(u=>{var f,m;!u&&((f=l.element)!=null&&f.isConnected)&&!((m=l.manager)!=null&&m.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function pg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}var mg=Object.create,xd=Object.defineProperty,gg=Object.getOwnPropertyDescriptor,Cd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ys=e=>{throw TypeError(e)},vg=(e,t,n)=>t in e?xd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yg=e=>{var t;return[,,,mg((t=e?.[Cd("metadata")])!=null?t:null)]},Sd=["class","method","getter","setter","accessor","field","value","get","set"],kd=e=>e!==void 0&&typeof e!="function"?Ys("Function expected"):e,bg=(e,t,n,r,s)=>({kind:Sd[e],name:t,metadata:r,addInitializer:a=>n._?Ys("Already initialized"):s.push(kd(a||null))}),wg=(e,t)=>vg(t,Cd("metadata"),e[3]),_g=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},Ed=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=Sd[u+5],v=e[d]||(e[d]=[]),g=(s=s.prototype,gg(s,n)),y=r.length-1;y>=0;y--)l=bg(u,n,i={},e[3],v),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(g[h],l),i._=1,kd(o)&&(g[h]=o);return g&&xd(s,n,g),s},Id=(e,t,n)=>t.has(e)||Ys("Cannot "+n),xg=(e,t,n)=>(Id(e,t,"read from private field"),t.get(e)),Cg=(e,t,n)=>t.has(e)?Ys("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Sg=(e,t,n,r)=>(Id(e,t,"write to private field"),t.set(e,n),n),qn=class co{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new co(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new co(t,n)}},Md,Ad,uo,vs,Lr,bi=class extends(uo=Jt,Ad=[Pe],Md=[Pe],uo){constructor(t){const n=qn.from(t);super(n,(r,s)=>qn.equals(r,s)),_g(Lr,5,this),Cg(this,vs,0),this.velocity={x:0,y:0}}get delta(){return qn.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=qn.from(t),s={x:r.x-n.x,y:r.y-n.y},a=Date.now(),o=a-xg(this,vs),i=l=>Math.round(l/o*100);Kt(()=>{Sg(this,vs,a),this.velocity={x:i(s.x),y:i(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(qn.from(t)),this.velocity={x:0,y:0}}};Lr=yg(uo);vs=new WeakMap;Ed(Lr,2,"delta",Ad,bi);Ed(Lr,2,"direction",Md,bi);wg(Lr,bi);var Td=(e=>(e.Horizontal="x",e.Vertical="y",e))(Td||{});Object.values(Td);const kg=new Map([["bold",P.createElement(P.Fragment,null,P.createElement("path",{d:"M144,128a16,16,0,1,1-16-16A16,16,0,0,1,144,128ZM60,112a16,16,0,1,0,16,16A16,16,0,0,0,60,112Zm136,0a16,16,0,1,0,16,16A16,16,0,0,0,196,112Z"}))],["duotone",P.createElement(P.Fragment,null,P.createElement("path",{d:"M240,96v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V96A16,16,0,0,1,32,80H224A16,16,0,0,1,240,96Z",opacity:"0.2"}),P.createElement("path",{d:"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"}))],["fill",P.createElement(P.Fragment,null,P.createElement("path",{d:"M224,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V96A16,16,0,0,0,224,80ZM60,140a12,12,0,1,1,12-12A12,12,0,0,1,60,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,196,140Z"}))],["light",P.createElement(P.Fragment,null,P.createElement("path",{d:"M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM60,118a10,10,0,1,0,10,10A10,10,0,0,0,60,118Zm136,0a10,10,0,1,0,10,10A10,10,0,0,0,196,118Z"}))],["regular",P.createElement(P.Fragment,null,P.createElement("path",{d:"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z"}))],["thin",P.createElement(P.Fragment,null,P.createElement("path",{d:"M136,128a8,8,0,1,1-8-8A8,8,0,0,1,136,128Zm-76-8a8,8,0,1,0,8,8A8,8,0,0,0,60,120Zm136,0a8,8,0,1,0,8,8A8,8,0,0,0,196,120Z"}))]]),Eg=new Map([["bold",P.createElement(P.Fragment,null,P.createElement("path",{d:"M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,1,1-18-15.88,20,20,0,0,0,0-26.43,12,12,0,0,1,18-15.86A43.94,43.94,0,0,1,212,128Zm40,0a83.87,83.87,0,0,1-21.39,56,12,12,0,0,1-17.89-16,60,60,0,0,0,0-80,12,12,0,1,1,17.88-16A83.87,83.87,0,0,1,252,128Z"}))],["duotone",P.createElement(P.Fragment,null,P.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),P.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55Zm54-106.08a40,40,0,0,1,0,52.88,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,0,1,12-10.58ZM248,128a79.9,79.9,0,0,1-20.37,53.34,8,8,0,0,1-11.92-10.67,64,64,0,0,0,0-85.33,8,8,0,1,1,11.92-10.67A79.83,79.83,0,0,1,248,128Z"}))],["fill",P.createElement(P.Fragment,null,P.createElement("path",{d:"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z"}))],["light",P.createElement(P.Fragment,null,P.createElement("path",{d:"M154.64,26.61a6,6,0,0,0-6.32.65L77.94,82H32A14,14,0,0,0,18,96v64a14,14,0,0,0,14,14H77.94l70.38,54.74A6,6,0,0,0,158,224V32A6,6,0,0,0,154.64,26.61ZM30,160V96a2,2,0,0,1,2-2H74v68H32A2,2,0,0,1,30,160Zm116,51.73L86,165.07V90.93l60-46.66Zm50.53-108.85a38,38,0,0,1,0,50.24,6,6,0,1,1-9-7.94,26,26,0,0,0,0-34.37,6,6,0,0,1,9-7.93ZM246,128a77.86,77.86,0,0,1-19.86,52,6,6,0,1,1-8.94-8,66,66,0,0,0,0-88,6,6,0,1,1,8.94-8A77.86,77.86,0,0,1,246,128Z"}))],["regular",P.createElement(P.Fragment,null,P.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55Zm54-106.08a40,40,0,0,1,0,52.88,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,0,1,12-10.58ZM248,128a79.9,79.9,0,0,1-20.37,53.34,8,8,0,0,1-11.92-10.67,64,64,0,0,0,0-85.33,8,8,0,1,1,11.92-10.67A79.83,79.83,0,0,1,248,128Z"}))],["thin",P.createElement(P.Fragment,null,P.createElement("path",{d:"M153.76,28.41a4,4,0,0,0-4.22.43L78.63,84H32A12,12,0,0,0,20,96v64a12,12,0,0,0,12,12H78.63l70.91,55.16A4.07,4.07,0,0,0,152,228a3.92,3.92,0,0,0,1.76-.41A4,4,0,0,0,156,224V32A4,4,0,0,0,153.76,28.41ZM28,160V96a4,4,0,0,1,4-4H76v72H32A4,4,0,0,1,28,160Zm120,55.82L84,166V90l64-49.78Zm47-111.61a36,36,0,0,1,0,47.59,4,4,0,1,1-6-5.3,28,28,0,0,0,0-37,4,4,0,0,1,6-5.28ZM244,128a75.88,75.88,0,0,1-19.35,50.67,4,4,0,0,1-6-5.34,68,68,0,0,0,0-90.66,4,4,0,0,1,6-5.34A75.88,75.88,0,0,1,244,128Z"}))]]),Ig=new Map([["bold",P.createElement(P.Fragment,null,P.createElement("path",{d:"M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,0,1-18-15.88,20,20,0,0,0,0-26.44,12,12,0,0,1,18-15.85A43.94,43.94,0,0,1,212,128Z"}))],["duotone",P.createElement(P.Fragment,null,P.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),P.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55ZM208,128a39.93,39.93,0,0,1-10,26.46,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,1,1,12-10.58A40,40,0,0,1,208,128Z"}))],["fill",P.createElement(P.Fragment,null,P.createElement("path",{d:"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80ZM198,101.56a8,8,0,1,0-12,10.58,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88Z"}))],["light",P.createElement(P.Fragment,null,P.createElement("path",{d:"M154.64,26.61a6,6,0,0,0-6.32.65L77.94,82H32A14,14,0,0,0,18,96v64a14,14,0,0,0,14,14H77.94l70.38,54.74A6,6,0,0,0,158,224V32A6,6,0,0,0,154.64,26.61ZM30,160V96a2,2,0,0,1,2-2H74v68H32A2,2,0,0,1,30,160Zm116,51.73L86,165.07V90.93l60-46.66ZM206,128a37.94,37.94,0,0,1-9.5,25.14,6,6,0,1,1-9-7.94,26,26,0,0,0,0-34.37,6,6,0,0,1,9-7.93A38,38,0,0,1,206,128Z"}))],["regular",P.createElement(P.Fragment,null,P.createElement("path",{d:"M155.51,24.81a8,8,0,0,0-8.42.88L77.25,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H77.25l69.84,54.31A8,8,0,0,0,160,224V32A8,8,0,0,0,155.51,24.81ZM32,96H72v64H32ZM144,207.64,88,164.09V91.91l56-43.55ZM208,128a39.93,39.93,0,0,1-10,26.46,8,8,0,0,1-12-10.58,24,24,0,0,0,0-31.72,8,8,0,1,1,12-10.58A40,40,0,0,1,208,128Z"}))],["thin",P.createElement(P.Fragment,null,P.createElement("path",{d:"M153.76,28.41a4,4,0,0,0-4.22.43L78.63,84H32A12,12,0,0,0,20,96v64a12,12,0,0,0,12,12H78.63l70.91,55.16A4.07,4.07,0,0,0,152,228a3.92,3.92,0,0,0,1.76-.41A4,4,0,0,0,156,224V32A4,4,0,0,0,153.76,28.41ZM28,160V96a4,4,0,0,1,4-4H76v72H32A4,4,0,0,1,28,160Zm120,55.82L84,166V90l64-49.78ZM204,128a36,36,0,0,1-9,23.82,4,4,0,1,1-6-5.3,28,28,0,0,0,0-37,4,4,0,0,1,6-5.28A36,36,0,0,1,204,128Z"}))]]),Mg=new Map([["bold",P.createElement(P.Fragment,null,P.createElement("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"}))],["duotone",P.createElement(P.Fragment,null,P.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),P.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["fill",P.createElement(P.Fragment,null,P.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["light",P.createElement(P.Fragment,null,P.createElement("path",{d:"M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"}))],["regular",P.createElement(P.Fragment,null,P.createElement("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"}))],["thin",P.createElement(P.Fragment,null,P.createElement("path",{d:"M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"}))]]),Ag=p.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Br=P.forwardRef((e,t)=>{const{alt:n,color:r,size:s,weight:a,mirrored:o,children:i,weights:l,...c}=e,{color:u="currentColor",size:f,weight:m="regular",mirrored:d=!1,...h}=P.useContext(Ag);return P.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:s??f,height:s??f,fill:r??u,viewBox:"0 0 256 256",transform:o||d?"scale(-1, 1)":void 0,...h,...c},!!n&&P.createElement("title",null,n),i,l.get(a??m))});Br.displayName="IconBase";const $d=P.forwardRef((e,t)=>P.createElement(Br,{ref:t,...e,weights:kg}));$d.displayName="DotsThreeIcon";const Rd=P.forwardRef((e,t)=>P.createElement(Br,{ref:t,...e,weights:Eg}));Rd.displayName="SpeakerHighIcon";const Dd=P.forwardRef((e,t)=>P.createElement(Br,{ref:t,...e,weights:Ig}));Dd.displayName="SpeakerLowIcon";const Pd=P.forwardRef((e,t)=>P.createElement(Br,{ref:t,...e,weights:Mg}));Pd.displayName="XIcon";const Tg=Pd;F.span`
|
|
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 wi=F.button`
|
|
73
73
|
display: inline-flex;
|
|
74
74
|
align-items: center;
|
|
75
75
|
justify-content: center;
|
|
@@ -100,37 +100,37 @@
|
|
|
100
100
|
opacity: 0.6;
|
|
101
101
|
cursor: not-allowed;
|
|
102
102
|
}
|
|
103
|
-
`;F(
|
|
103
|
+
`;F(wi)`
|
|
104
104
|
padding: 0.25rem 0.5rem;
|
|
105
105
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
106
|
-
`;F(
|
|
106
|
+
`;F(wi)`
|
|
107
107
|
padding: 0.5rem;
|
|
108
108
|
min-width: 2.25rem;
|
|
109
109
|
min-height: 2.25rem;
|
|
110
|
-
`;F(
|
|
110
|
+
`;F(wi)`
|
|
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 $g=F.div`
|
|
116
116
|
display: inline-flex;
|
|
117
117
|
align-items: center;
|
|
118
118
|
gap: 0.5rem;
|
|
119
|
-
|
|
119
|
+
`,Rg=F.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
|
+
`,Dg=F.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
|
+
`,vt=F.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
|
+
`,Fd=F.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,10 +182,10 @@
|
|
|
182
182
|
opacity: 0.6;
|
|
183
183
|
cursor: not-allowed;
|
|
184
184
|
}
|
|
185
|
-
`;F(
|
|
185
|
+
`;F(Fd)`
|
|
186
186
|
padding: 0.25rem 0.5rem;
|
|
187
187
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
188
|
-
`;var
|
|
188
|
+
`;var Pg=F.label`
|
|
189
189
|
font-family: ${e=>e.theme.fontFamily};
|
|
190
190
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
191
191
|
font-weight: 500;
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
align-items: center;
|
|
201
201
|
gap: 0.5rem;
|
|
202
202
|
cursor: pointer;
|
|
203
|
-
`;var
|
|
203
|
+
`;var Fg=F.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
|
+
`,Od=F.select`
|
|
214
214
|
padding: 0.5rem 2rem 0.5rem 0.75rem;
|
|
215
215
|
font-family: ${e=>e.theme.fontFamily};
|
|
216
216
|
font-size: ${e=>e.theme.fontSize};
|
|
@@ -243,10 +243,10 @@
|
|
|
243
243
|
color: ${e=>e.theme.inputText};
|
|
244
244
|
background-color: ${e=>e.theme.inputBackground};
|
|
245
245
|
}
|
|
246
|
-
`;F(
|
|
246
|
+
`;F(Od)`
|
|
247
247
|
padding: 0.25rem 1.75rem 0.25rem 0.5rem;
|
|
248
248
|
font-size: ${e=>e.theme.fontSizeSmall};
|
|
249
|
-
`;var
|
|
249
|
+
`;var Ld=F.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
|
+
`,Og=({checked:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.checked)};return C.jsxs($g,{className:r,children:[C.jsx(Rg,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:e,onChange:s,disabled:n}),C.jsx(Dg,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Bd(e){return typeof e=="object"&&e!==null&&"type"in e}function qt(e){if(!Bd(e))return e;const t=e.direction==="vertical"?"to bottom":"to right",n=e.stops.map(r=>`${r.color} ${r.offset*100}%`).join(", ");return`linear-gradient(${t}, ${n})`}var Wd={waveformDrawMode:"inverted",waveOutlineColor:"#ffffff",waveFillColor:"#1a7f8e",waveProgressColor:"rgba(0, 0, 0, 0.10)",selectedWaveOutlineColor:"#ffffff",selectedWaveFillColor:"#00b4d8",selectedTrackControlsBackground:"#d9e9ff",timeColor:"#000",timescaleBackgroundColor:"#fff",playheadColor:"#f00",selectionColor:"rgba(255, 105, 180, 0.7)",loopRegionColor:"rgba(59, 130, 246, 0.3)",loopMarkerColor:"#3b82f6",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",pianoRollNoteColor:"#2a7070",pianoRollSelectedNoteColor:"#3d9e9e",pianoRollBackgroundColor:"#1a1a2e",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},Lg=class{constructor(e){this._listeners=new Set,this._notifyRafId=null,this.subscribe=r=>(this._listeners.add(r),()=>this._listeners.delete(r)),this.getSnapshot=()=>this._state;const t=e?.clientWidth??(typeof window<"u"?window.innerWidth:1024),n=t*1.5;this._state={scrollLeft:0,containerWidth:t,visibleStart:0,visibleEnd:t+n}}update(e,t){const n=t*1.5,r=Math.max(0,e-n),s=e+t+n;this._state&&this._state.containerWidth===t&&Math.abs(this._state.scrollLeft-e)<100||(this._state={scrollLeft:e,containerWidth:t,visibleStart:r,visibleEnd:s},this._notifyRafId===null&&(this._notifyRafId=requestAnimationFrame(()=>{this._notifyRafId=null;for(const a of this._listeners)a()})))}cancelPendingNotification(){this._notifyRafId!==null&&(cancelAnimationFrame(this._notifyRafId),this._notifyRafId=null)}},Vd=p.createContext(null),Bg=()=>()=>{},Wg=({containerRef:e,children:t})=>{const n=p.useRef(null);n.current===null&&(n.current=new Lg(e.current));const r=n.current,s=p.useRef(null),a=p.useCallback(()=>{const i=e.current;i&&r.update(i.scrollLeft,i.clientWidth)},[e,r]),o=p.useCallback(()=>{s.current===null&&(s.current=requestAnimationFrame(()=>{s.current=null,a()}))},[a]);return p.useLayoutEffect(()=>{a()},[a]),p.useEffect(()=>{const i=e.current;if(!i)return;i.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(()=>{o()});return l.observe(i),()=>{i.removeEventListener("scroll",o),l.disconnect(),s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),r.cancelPendingNotification()}},[e,o,r]),C.jsx(Vd.Provider,{value:r,children:t})};function Vg(e){const t=p.useContext(Vd);return p.useSyncExternalStore(t?t.subscribe:Bg,()=>e(t?t.getSnapshot():null),()=>e(null))}function Ks(e,t,n=0){const r=Vg(s=>{const a=Math.ceil(e/t),o=[];for(let i=0;i<a;i++){const l=i*t,c=Math.min(e-l,t);if(s){const u=n+l;if(u+c<=s.visibleStart||u>=s.visibleEnd)continue}o.push(i)}return o.join(",")});return p.useMemo(()=>r?r.split(",").map(Number):[],[r])}var Nd=p.createContext(0),Ng=({originX:e,children:t})=>C.jsx(Nd.Provider,{value:e,children:t}),_i=()=>p.useContext(Nd);function qs(){const e=p.useRef(new Map),t=p.useCallback(n=>{if(n!==null){const r=parseInt(n.dataset.index,10);e.current.set(r,n)}},[]);return p.useEffect(()=>{const n=e.current;for(const[r,s]of n.entries())s.isConnected||n.delete(r)}),{canvasRef:t,canvasMapRef:e}}function zg(e,t,n,r){if(n*2+1>=e.length)return null;const s=2**(t-1);let a=e[n*2]/s,o=e[n*2+1]/s;for(let i=n+1;i<r&&!(i*2+1>=e.length);i++){const l=e[i*2]/s,c=e[i*2+1]/s;l<a&&(a=l),c>o&&(o=c)}return{min:a,max:o}}function jg(e,t,n,r,s,a){const o=Math.abs(r*n),i=Math.abs(s*n);return a==="normal"?[{x:e,y:n-i,width:t,height:i+o}]:[{x:e,y:0,width:t,height:n-i},{x:e,y:n+o,width:t,height:n-o}]}function Zg(e,t,n){return Math.floor((e-t+n)/n)*n}function Hg(e,t,n,r){if(!Bd(t))return t;let s;t.direction==="vertical"?s=e.createLinearGradient(0,0,0,r):s=e.createLinearGradient(0,0,n,0);for(const a of t.stops)s.addColorStop(a.offset,a.color);return s}var Gg=F.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
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
|
+
`,Ug=F.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
|
+
`,zl=e=>{const{data:t,bits:n,length:r,index:s,className:a,devicePixelRatio:o=1,waveHeight:i=80,waveOutlineColor:l="#E0EFF1",waveFillColor:c="grey",barWidth:u=1,barGap:f=0,transparentBackground:m=!1,drawMode:d="inverted"}=e,{canvasRef:h,canvasMapRef:v}=qs(),g=_i(),y=Ks(r,Be,g);p.useLayoutEffect(()=>{const x=u+f;for(const[S,k]of v.current.entries()){const E=S*Be,M=k.getContext("2d"),T=Math.floor(i/2);if(M){M.resetTransform(),M.clearRect(0,0,k.width,k.height),M.imageSmoothingEnabled=!1,M.scale(o,o);const $=k.width/o;let A;d==="normal"?A=c:A=l,M.fillStyle=Hg(M,A,$,i);const I=E,R=E+$,D=Zg(I,u,x);for(let O=Math.max(0,D);O<R;O+=x){const Z=O-I;if(Z+u<=0)continue;const G=Math.min(O+x,r),Y=zg(t,n,O,G);if(Y){const te=jg(Z,u,T,Y.min,Y.max,d);for(const X of te)M.fillRect(X.x,X.y,X.width,X.height)}}}}},[v,t,n,i,l,c,o,r,u,f,d,y,s]);const b=y.map(x=>{const S=x*Be,k=Math.min(r-S,Be);return C.jsx(Gg,{$cssWidth:k,$left:S,width:k*o,height:i*o,$waveHeight:i,"data-index":x,ref:h},`${r}-${x}`)}),w=m?"transparent":qt(c);return C.jsx(Ug,{$index:s,$cssWidth:r,className:a,$waveHeight:i,$waveFillColor:w,children:b})},Xg={padding:"16px",background:"#1a1a2e",color:"#e0e0e0",border:"1px solid #d08070",borderRadius:"4px",fontFamily:"monospace",fontSize:"13px",minHeight:"60px",display:"flex",alignItems:"center",justifyContent:"center"};(class extends p.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[waveform-playlist] Render error:",e,t.componentStack)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:C.jsx("div",{style:Xg,children:"Waveform playlist encountered an error. Check console for details."}):this.props.children}});var xi=22,zd=F.div`
|
|
342
342
|
position: relative;
|
|
343
|
-
height: ${
|
|
343
|
+
height: ${xi}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
|
+
`,jd=F.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
|
+
`,Yg=({trackName:e,isSelected:t=!1})=>C.jsx(zd,{$interactive:!1,$isSelected:t,children:C.jsx(jd,{title:e,children:e})}),Kg=({clipId:e,trackIndex:t,clipIndex:n,trackName:r,isSelected:s=!1,disableDrag:a=!1,dragHandleProps:o})=>{if(a||!o)return C.jsx(Yg,{trackName:r,isSelected:s});const{handleRef:i}=o;return C.jsx(zd,{ref:i,"data-clip-id":e,$interactive:!0,$isSelected:s,children:C.jsx(jd,{title:r,children:r})})},qg=8,Jg=24,Qg=F.div`
|
|
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?qg
|
|
378
|
+
width: ${e=>e.$touchOptimized?Jg:qg}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
|
+
`,jl=({clipId:e,trackIndex:t,clipIndex:n,edge:r,dragHandleProps:s,touchOptimized:a=!1})=>{const[o,i]=p.useState(!1);if(!s)return null;const{ref:l,isDragging:c}=s;return C.jsx(Qg,{ref:l,"data-clip-id":e,"data-boundary-edge":r,$edge:r,$isDragging:c,$isHovered:o,$touchOptimized:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1)})},ev=F.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
402
402
|
position: absolute;
|
|
403
403
|
top: 0;
|
|
404
404
|
bottom: 0;
|
|
405
405
|
pointer-events: none;
|
|
406
406
|
z-index: 50;
|
|
407
|
-
`,
|
|
407
|
+
`,tv=F.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 nv(e,t,n="logarithmic"){const r=[],s=Math.max(20,Math.min(e,100));for(let a=0;a<=s;a++){const o=a/s*e,i=a/s;let l;switch(n){case"linear":l=i;break;case"exponential":l=i*i;break;case"sCurve":l=(1-Math.cos(i*Math.PI))/2;break;case"logarithmic":default:l=Math.log10(1+i*9)/Math.log10(10);break}const c=(1-l)*t;r.push(`${o},${c}`)}return`M 0,${t} L ${r.join(" L ")} L ${e},0 L 0,0 Z`}var Zl=({left:e,width:t,type:n,curveType:r="logarithmic",color:s})=>{const a=F.useTheme();if(t<1)return null;const o=s||a?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return C.jsx(ev,{$left:e,$width:t,$type:n,children:C.jsx(tv,{$type:n,viewBox:`0 0 ${t} 100`,preserveAspectRatio:"none",children:C.jsx("path",{d:nv(t,100,r),fill:o})})})},rv=F.div.attrs(e=>({style:e.$isOverlay?{}:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
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
|
+
`,sv=F.div`
|
|
423
423
|
flex: 1;
|
|
424
424
|
position: relative;
|
|
425
425
|
overflow: ${e=>e.$isOverlay?"visible":"hidden"};
|
|
426
|
-
`,
|
|
426
|
+
`,fo=({children:e,className:t,clipId:n,trackIndex:r,clipIndex:s,trackName:a,startSample:o,durationSamples:i,samplesPerPixel:l,showHeader:c=!1,disableHeaderDrag:u=!1,isOverlay:f=!1,isSelected:m=!1,onMouseDown:d,trackId:h,fadeIn:v,fadeOut:g,sampleRate:y=44100,showFades:b=!1,touchOptimized:_=!1})=>{const w=Math.floor(o/l),x=hc(o,i,l),S=c&&!u&&!f,k=`clip-${r}-${s}`,{ref:E,handleRef:M,isDragSource:T}=_a({id:k,data:{clipId:n,trackIndex:r,clipIndex:s,startSample:o,durationSamples:i},disabled:!S}),$=`clip-boundary-left-${r}-${s}`,{ref:A,isDragSource:I}=_a({id:$,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"left",startSample:o,durationSamples:i},disabled:!S,feedback:"none"}),R=`clip-boundary-right-${r}-${s}`,{ref:D,isDragSource:O}=_a({id:R,data:{clipId:n,trackIndex:r,clipIndex:s,boundary:"right",startSample:o,durationSamples:i},disabled:!S,feedback:"none"}),Z=T?{zIndex:100}:void 0;return C.jsxs(rv,{ref:E,style:Z,className:t,$left:w,$width:x,$isOverlay:f,"data-clip-container":"true","data-track-id":h,onMouseDown:d,tabIndex:-1,children:[c&&C.jsx(Kg,{clipId:n,trackIndex:r,clipIndex:s,trackName:a,isSelected:m,disableDrag:u,dragHandleProps:S?{handleRef:M}:void 0}),C.jsx(Ng,{originX:w,children:C.jsxs(sv,{$isOverlay:f,children:[e,b&&v&&v.duration>0&&C.jsx(Zl,{left:0,width:Math.floor(v.duration*y/l),type:"fadeIn",curveType:v.type}),b&&g&&g.duration>0&&C.jsx(Zl,{left:x-Math.floor(g.duration*y/l),width:Math.floor(g.duration*y/l),type:"fadeOut",curveType:g.type})]})}),c&&!u&&!f&&C.jsxs(C.Fragment,{children:[C.jsx(jl,{clipId:n,trackIndex:r,clipIndex:s,edge:"left",touchOptimized:_,dragHandleProps:{ref:A,isDragging:I}}),C.jsx(jl,{clipId:n,trackIndex:r,clipIndex:s,edge:"right",touchOptimized:_,dragHandleProps:{ref:D,isDragging:O}})]})]})},av=F.div`
|
|
427
427
|
display: inline-flex;
|
|
428
428
|
align-items: center;
|
|
429
429
|
gap: 0.5rem;
|
|
430
|
-
`,
|
|
430
|
+
`,ov=F(Pg)`
|
|
431
431
|
margin: 0;
|
|
432
432
|
white-space: nowrap;
|
|
433
|
-
`,
|
|
433
|
+
`,iv=F(Ld)`
|
|
434
434
|
width: 120px;
|
|
435
|
-
`,
|
|
435
|
+
`,lv=({volume:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(parseFloat(a.target.value)/100)};return C.jsxs(av,{className:r,children:[C.jsx(ov,{htmlFor:"master-gain",children:"Master Volume"}),C.jsx(iv,{min:"0",max:"100",value:e*100,onChange:s,disabled:n,id:"master-gain"})]})},cv=F.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
436
436
|
position: absolute;
|
|
437
437
|
top: 0;
|
|
438
438
|
image-rendering: pixelated;
|
|
439
439
|
image-rendering: crisp-edges;
|
|
440
|
-
`,
|
|
440
|
+
`,uv=F.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
|
+
`,dv=({index:e,midiNotes:t,length:n,waveHeight:r,devicePixelRatio:s,samplesPerPixel:a,sampleRate:o,clipOffsetSeconds:i,noteColor:l="#2a7070",selectedNoteColor:c="#3d9e9e",isSelected:u=!1,transparentBackground:f=!1,backgroundColor:m="#1a1a2e"})=>{const{canvasRef:d,canvasMapRef:h}=qs(),v=_i(),g=Ks(n,Be,v),{minMidi:y,maxMidi:b}=p.useMemo(()=>{if(t.length===0)return{minMidi:0,maxMidi:127};let S=127,k=0;for(const E of t)E.midi<S&&(S=E.midi),E.midi>k&&(k=E.midi);return{minMidi:Math.max(0,S-1),maxMidi:Math.min(127,k+1)}},[t]),_=u?c:l;p.useLayoutEffect(()=>{const S=b-y+1,k=Math.max(2,r/S),E=o/a;for(const[M,T]of h.current.entries()){const $=M*Be,A=T.width/s,I=T.getContext("2d");if(!I)continue;I.resetTransform(),I.clearRect(0,0,T.width,T.height),I.imageSmoothingEnabled=!1,I.scale(s,s);const R=$*a/o,D=($+A)*a/o;for(const O of t){const Z=O.time-i;if(Z+O.duration<=R||Z>=D)continue;const Y=Z*E-$,te=Math.max(2,O.duration*E),X=(b-O.midi)/S*r,K=.3+O.velocity*.7;I.fillStyle=_,I.globalAlpha=K;const le=1;I.beginPath(),I.roundRect(Y,X,te,k,le),I.fill()}I.globalAlpha=1}},[h,t,r,s,a,o,i,_,y,b,n,g,e]);const w=g.map(S=>{const k=S*Be,E=Math.min(n-k,Be);return C.jsx(cv,{$cssWidth:E,$left:k,width:E*s,height:r*s,$waveHeight:r,"data-index":S,ref:d},`${n}-${S}`)}),x=f?"transparent":m;return C.jsx(uv,{$index:e,$cssWidth:n,$waveHeight:r,$backgroundColor:x,children:w})};F.div.attrs(e=>({style:{transform:`translate3d(${e.$position}px, 0, 0)`}}))`
|
|
446
446
|
position: absolute;
|
|
447
447
|
top: 0;
|
|
448
448
|
left: 0;
|
|
@@ -476,32 +476,32 @@
|
|
|
476
476
|
width: 2px;
|
|
477
477
|
height: 100%;
|
|
478
478
|
background: ${e=>e.$color};
|
|
479
|
-
`;var
|
|
479
|
+
`;var fv=F.div`
|
|
480
480
|
display: flex;
|
|
481
481
|
overflow-y: hidden;
|
|
482
482
|
position: relative;
|
|
483
|
-
`,
|
|
483
|
+
`,hv=F.div.attrs(e=>({style:{width:`${e.$width}px`}}))`
|
|
484
484
|
flex-shrink: 0;
|
|
485
485
|
overflow: hidden;
|
|
486
|
-
`,
|
|
486
|
+
`,pv=F.div.attrs(e=>({style:{height:`${e.$height}px`}}))``,mv=F.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
|
+
`,gv=F.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
|
+
`,vv=F.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
|
+
`,yv=F.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
|
+
`,bv=F.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
|
+
`,Ci=({children:e,backgroundColor:t,timescaleBackgroundColor:n,timescale:r,timescaleWidth:s,tracksWidth:a,controlsWidth:o,onTracksClick:i,onTracksMouseDown:l,onTracksMouseMove:c,onTracksMouseUp:u,scrollContainerRef:f,isSelecting:m,"data-playlist-state":d,trackControlsSlots:h,timescaleGapHeight:v=0})=>{const g=p.useRef(null),y=p.useCallback(_=>{g.current=_,f?.(_)},[f]),b=o!==void 0&&o>0;return C.jsxs(fv,{"data-playlist-state":d,children:[b&&C.jsxs(hv,{$width:o,children:[v>0&&C.jsx(pv,{$height:v}),h]}),C.jsx(mv,{"data-scroll-container":"true",ref:y,children:C.jsx(Wg,{containerRef:g,children:C.jsxs(gv,{$backgroundColor:t,$width:a,children:[r&&C.jsx(vv,{$width:s,$backgroundColor:n,children:r}),C.jsxs(yv,{$width:a,$backgroundColor:t,children:[e,(i||l)&&C.jsx(bv,{$isSelecting:m,onClick:i,onMouseDown:l,onMouseMove:c,onMouseUp:u})]})]})})})]})};F.withTheme(Ci);var wv=F.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
514
514
|
position: absolute;
|
|
515
515
|
top: 0;
|
|
516
516
|
background: ${e=>e.$color};
|
|
@@ -518,7 +518,7 @@
|
|
|
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
|
+
`,Zd=({startPosition:e,endPosition:t,color:n="#00ff00"})=>{const r=Math.max(0,t-e);return r<=0?null:C.jsx(wv,{$left:e,$width:r,$color:n,"data-selection":!0})};F.div.attrs(e=>({style:{left:`${e.$left}px`,width:`${e.$width}px`}}))`
|
|
522
522
|
position: absolute;
|
|
523
523
|
top: 0;
|
|
524
524
|
background: ${e=>e.$color};
|
|
@@ -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 Hl=F.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
|
+
`,_v=F.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
|
+
`,xv=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopStartChange:s,onLoopEndChange:a,onLoopRegionMove:o,minPosition:i=0,maxPosition:l=1/0})=>{const[c,u]=p.useState(null),f=p.useRef(0),m=p.useRef(0),d=p.useRef(0),h=Math.max(0,t-e),v=p.useCallback((y,b)=>{y.preventDefault(),y.stopPropagation(),u(b),f.current=y.clientX,m.current=b==="start"?e:t;const _=x=>{const S=x.clientX-f.current,k=m.current+S;if(b==="start"){const E=Math.max(i,Math.min(t-10,k));s?.(E)}else{const E=Math.max(e+10,Math.min(l,k));a?.(E)}},w=()=>{u(null),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",w)},[e,t,i,l,s,a]),g=p.useCallback(y=>{y.preventDefault(),y.stopPropagation(),u("region"),f.current=y.clientX,m.current=e,d.current=t;const b=t-e,_=x=>{const S=x.clientX-f.current;let k=m.current+S,E=d.current+S;k<i&&(k=i,E=i+b),E>l&&(E=l,k=l-b),o?.(k,E)},w=()=>{u(null),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",w)},[e,t,i,l,o]);return h<=0?null:C.jsxs(C.Fragment,{children:[C.jsx(_v,{$left:e,$width:h,$color:r,$isDragging:c==="region",onMouseDown:g,"data-loop-region-timescale":!0}),C.jsx(Hl,{$left:e,$color:n,$isStart:!0,$isDragging:c==="start",onMouseDown:y=>v(y,"start"),"data-loop-marker-handle":"start"}),C.jsx(Hl,{$left:t,$color:n,$isStart:!1,$isDragging:c==="end",onMouseDown:y=>v(y,"end"),"data-loop-marker-handle":"end"})]})},Cv=F.div`
|
|
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
|
+
`,Sv=({startPosition:e,endPosition:t,markerColor:n="#3b82f6",regionColor:r="rgba(59, 130, 246, 0.3)",onLoopRegionChange:s,minPosition:a=0,maxPosition:o=1/0})=>{const[,i]=p.useState(!1),l=p.useRef(0),c=p.useRef(null),u=t>e,f=p.useCallback(m=>{const d=m.target;if(d.closest("[data-loop-marker-handle]")||d.closest("[data-loop-region-timescale]"))return;m.preventDefault(),i(!0);const h=c.current?.getBoundingClientRect();if(!h)return;const v=m.clientX-h.left,g=Math.max(a,Math.min(o,v));l.current=g,s?.(g,g);const y=_=>{const w=_.clientX-h.left,x=Math.max(a,Math.min(o,w)),S=Math.min(l.current,x),k=Math.max(l.current,x);s?.(S,k)},b=()=>{i(!1),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",b)};document.addEventListener("mousemove",y),document.addEventListener("mouseup",b)},[a,o,s]);return C.jsx(Cv,{ref:c,onMouseDown:f,"data-timescale-loop-creator":!0,children:u&&C.jsx(xv,{startPosition:e,endPosition:t,markerColor:n,regionColor:r,minPosition:a,maxPosition:o,onLoopStartChange:m=>s?.(m,t),onLoopEndChange:m=>s?.(e,m),onLoopRegionMove:(m,d)=>s?.(m,d)})})};function Jn(e,t){const n=Math.floor(e/3600)%24,r=Math.floor(e/60)%60,s=(e%60).toFixed(t);return String(n).padStart(2,"0")+":"+String(r).padStart(2,"0")+":"+s.padStart(t>0?t+3:2,"0")}function Pn(e,t){switch(t){case"seconds":return e.toFixed(0);case"thousandths":return e.toFixed(3);case"hh:mm:ss":return Jn(e,0);case"hh:mm:ss.u":return Jn(e,1);case"hh:mm:ss.uu":return Jn(e,2);case"hh:mm:ss.uuu":return Jn(e,3);default:return Jn(e,3)}}function Hd(e,t){if(!e)return 0;switch(t){case"seconds":case"thousandths":return parseFloat(e)||0;case"hh:mm:ss":case"hh:mm:ss.u":case"hh:mm:ss.uu":case"hh:mm:ss.uuu":{const n=e.split(":");if(n.length!==3)return 0;const r=parseInt(n[0],10)||0,s=parseInt(n[1],10)||0,a=parseFloat(n[2])||0;return r*3600+s*60+a}default:return 0}}var Gl=({id:e,label:t,value:n,format:r,className:s,onChange:a,readOnly:o=!1})=>{const[i,l]=p.useState("");p.useEffect(()=>{const m=Pn(n,r);l(m)},[n,r,e]);const c=m=>{const d=m.target.value;l(d)},u=()=>{if(a){const m=Hd(i,r);a(m)}l(Pn(n,r))},f=m=>{m.key==="Enter"&&m.currentTarget.blur()};return C.jsxs(C.Fragment,{children:[C.jsx(Fg,{as:"label",htmlFor:e,children:t}),C.jsx(Fd,{type:"text",className:s,id:e,value:i,onChange:c,onBlur:u,onKeyDown:f,readOnly:o})]})},kv=({selectionStart:e,selectionEnd:t,onSelectionChange:n,className:r})=>{const[s,a]=p.useState("hh:mm:ss.uuu");p.useEffect(()=>{const l=document.querySelector(".time-format"),c=()=>{l&&a(l.value)};return l&&(a(l.value),l.addEventListener("change",c)),()=>{l?.removeEventListener("change",c)}},[]);const o=l=>{n&&n(l,t)},i=l=>{n&&n(e,l)};return C.jsxs("div",{className:r,children:[C.jsx(Gl,{id:"audio_start",label:"Start of audio selection",value:e,format:s,className:"audio-start form-control mr-sm-2",onChange:o}),C.jsx(Gl,{id:"audio_end",label:"End of audio selection",value:t,format:s,className:"audio-end form-control mr-sm-2",onChange:i})]})},Ev=p.createContext(null);function Gd(){return p.useContext(Ev)}function ys(){return window.devicePixelRatio}var Ud=p.createContext(ys()),Xd=({children:e})=>{const[t,n]=p.useState(ys());return matchMedia(`(resolution: ${ys()}dppx)`).addEventListener("change",()=>{n(ys())},{once:!0}),C.jsx(Ud.Provider,{value:Math.ceil(t),children:e})},Si=()=>p.useContext(Ud),Wr=p.createContext({sampleRate:48e3,samplesPerPixel:1e3,zoomLevels:[1e3,1500,2e3,2500],waveHeight:80,timeScaleHeight:15,controls:{show:!1,width:150},duration:3e4,barWidth:1,barGap:0}),Js=()=>p.useContext(Wr),Vr=()=>p.useContext(F.ThemeContext);p.createContext(C.jsx(p.Fragment,{}));var Iv=0,Mv=!1,Av=0,Tv=0,$v={progress:Iv,isPlaying:Mv,selectionStart:Av,selectionEnd:Tv};p.createContext($v);p.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var Rv=(e,t,n)=>(e-t)/(n-t),Dv=F.div.attrs(e=>({style:{top:`${e.$waveHeight*e.$index}px`,width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`}}))`
|
|
605
605
|
position: absolute;
|
|
606
606
|
background: #000;
|
|
607
607
|
transform: translateZ(0);
|
|
608
608
|
backface-visibility: hidden;
|
|
609
|
-
`,
|
|
609
|
+
`,Pv=F.canvas.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$waveHeight}px`,left:`${e.$left}px`}}))`
|
|
610
610
|
position: absolute;
|
|
611
611
|
top: 0;
|
|
612
612
|
image-rendering: pixelated;
|
|
613
613
|
image-rendering: crisp-edges;
|
|
614
|
-
`;function
|
|
614
|
+
`;function Fv(){const e=new Uint8Array(768);for(let t=0;t<256;t++)e[t*3]=e[t*3+1]=e[t*3+2]=t;return e}var Ov=Fv(),Ul=({index:e,channelIndex:t,data:n,length:r,waveHeight:s,devicePixelRatio:a=1,samplesPerPixel:o,colorLUT:i,frequencyScaleFn:l,minFrequency:c=0,maxFrequency:u,workerApi:f,clipId:m,onCanvasesReady:d})=>{const h=t??e,{canvasRef:v,canvasMapRef:g}=qs(),y=p.useRef([]),b=p.useRef(new WeakSet),_=p.useRef(f),w=p.useRef(d),x=!!(f&&m),S=_i(),k=Ks(r,Be,S),E=i??Ov,M=u??(n?n.sampleRate/2:22050),T=l??Rv,$=!!l;p.useEffect(()=>{_.current=f},[f]),p.useEffect(()=>{w.current=d},[d]),p.useEffect(()=>{if(!x)return;const I=_.current;if(!I||!m)return;const R=y.current.length,D=[];for(const G of y.current){const Y=G.match(/chunk(\d+)$/);if(!Y){D.push(G);continue}const te=parseInt(Y[1],10),X=g.current.get(te);if(X&&X.isConnected)D.push(G);else try{I.unregisterCanvas(G)}catch(K){console.warn(`[spectrogram] unregisterCanvas failed for ${G}:`,K)}}y.current=D;const O=[];for(const[G,Y]of g.current.entries()){if(b.current.has(Y))continue;const te=`${m}-ch${h}-chunk${G}`;let X;try{X=Y.transferControlToOffscreen()}catch(K){console.warn(`[spectrogram] transferControlToOffscreen failed for ${te}:`,K);continue}b.current.add(Y);try{I.registerCanvas(te,X),O.push(te)}catch(K){console.warn(`[spectrogram] registerCanvas failed for ${te}:`,K);continue}}if(O.length>0&&(y.current=[...y.current,...O]),O.length>0||D.length<R){const G=y.current,Y=G.map(te=>{const X=te.match(/chunk(\d+)$/);if(!X)return console.warn(`[spectrogram] Unexpected canvas ID format: ${te}`),Be;const K=parseInt(X[1],10);return Math.min(r-K*Be,Be)});w.current?.(G,Y)}},[g,x,m,h,r,k]),p.useEffect(()=>()=>{const I=_.current;if(I){for(const R of y.current)try{I.unregisterCanvas(R)}catch(D){console.warn(`[spectrogram] unregisterCanvas failed for ${R}:`,D)}y.current=[]}},[]),p.useLayoutEffect(()=>{if(x||!n)return;const{frequencyBinCount:I,frameCount:R,hopSize:D,sampleRate:O,gainDb:Z,rangeDb:G}=n,Y=G===0?1:G,te=X=>X/I*(O/2);for(const[X,K]of g.current.entries()){const le=X*Be,J=K.getContext("2d");if(!J)continue;const de=K.width/a,ue=s;J.resetTransform(),J.clearRect(0,0,K.width,K.height),J.imageSmoothingEnabled=!1,J.scale(a,a);const ne=J.createImageData(de,ue),z=ne.data;for(let ae=0;ae<de;ae++){const ce=(le+ae)*o,xe=Math.floor(ce/D);if(xe<0||xe>=R)continue;const B=xe*I;for(let _e=0;_e<ue;_e++){const re=1-_e/ue;let Me=Math.floor(re*I);if($){let Ve=0,Le=I-1;for(;Ve<Le;){const je=Ve+Le>>1,tt=te(je);T(tt,c,M)<re?Ve=je+1:Le=je}Me=Ve}if(Me<0||Me>=I)continue;const pe=n.data[B+Me],Ae=Math.max(0,Math.min(1,(pe+Y+Z)/Y)),He=Math.floor(Ae*255),qe=(_e*de+ae)*4;z[qe]=E[He*3],z[qe+1]=E[He*3+1],z[qe+2]=E[He*3+2],z[qe+3]=255}}if(J.resetTransform(),J.putImageData(ne,0,0),a!==1){const ae=document.createElement("canvas");ae.width=de,ae.height=ue;const ke=ae.getContext("2d");if(!ke)continue;ke.putImageData(ne,0,0),J.clearRect(0,0,K.width,K.height),J.imageSmoothingEnabled=!1,J.drawImage(ae,0,0,K.width,K.height)}}},[g,x,n,r,s,a,o,E,c,M,T,$,k]);const A=k.map(I=>{const R=I*Be,D=Math.min(r-R,Be);return C.jsx(Pv,{$cssWidth:D,$left:R,width:D*a,height:s*a,$waveHeight:s,"data-index":I,ref:v},`${r}-${I}`)});return C.jsx(Dv,{$index:e,$cssWidth:r,$waveHeight:s,children:A})},Yd=({isSelected:e,transparentBackground:t,renderMode:n="waveform",spectrogramData:r,spectrogramColorLUT:s,samplesPerPixel:a,spectrogramFrequencyScaleFn:o,spectrogramMinFrequency:i,spectrogramMaxFrequency:l,spectrogramWorkerApi:c,spectrogramClipId:u,spectrogramOnCanvasesReady:f,midiNotes:m,sampleRate:d,clipOffsetSeconds:h,...v})=>{const g=Vr(),{waveHeight:y,barWidth:b,barGap:_,samplesPerPixel:w,sampleRate:x}=Js(),S=Si(),k=a??w,E=e&&g?g.selectedWaveOutlineColor:g?.waveOutlineColor,M=e&&g?g.selectedWaveFillColor:g?.waveFillColor,T=g?.waveformDrawMode||"inverted",$=r||c;if(n==="spectrogram"&&$)return C.jsx(Ul,{index:v.index,data:r,length:v.length,waveHeight:y,devicePixelRatio:S,samplesPerPixel:k,colorLUT:s,frequencyScaleFn:o,minFrequency:i,maxFrequency:l,workerApi:c,clipId:u,onCanvasesReady:f});if(n==="both"&&$){const A=Math.floor(y/2);return C.jsxs(C.Fragment,{children:[C.jsx(Ul,{index:v.index*2,channelIndex:v.index,data:r,length:v.length,waveHeight:A,devicePixelRatio:S,samplesPerPixel:k,colorLUT:s,frequencyScaleFn:o,minFrequency:i,maxFrequency:l,workerApi:c,clipId:u,onCanvasesReady:f}),C.jsx("div",{style:{position:"absolute",top:(v.index*2+1)*A,width:v.length,height:A},children:C.jsx(zl,{...v,index:0,waveOutlineColor:E,waveFillColor:M,waveHeight:A,devicePixelRatio:S,barWidth:b,barGap:_,transparentBackground:t,drawMode:T})})]})}return n==="piano-roll"?C.jsx(dv,{index:v.index,midiNotes:m??[],length:v.length,waveHeight:y,devicePixelRatio:S,samplesPerPixel:k,sampleRate:d??x,clipOffsetSeconds:h??0,noteColor:g?.pianoRollNoteColor,selectedNoteColor:g?.pianoRollSelectedNoteColor,isSelected:e,transparentBackground:t,backgroundColor:g?.pianoRollBackgroundColor}):C.jsx(zl,{...v,waveOutlineColor:E,waveFillColor:M,waveHeight:y,devicePixelRatio:S,barWidth:b,barGap:_,transparentBackground:t,drawMode:T})},Xl=72,Lv=F.div`
|
|
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 Bv(e,t,n){const s=[20,50,100,200,500,1e3,2e3,3e3,4e3,5e3,8e3,1e4,12e3,16e3,2e4].filter(l=>l>=e&&l<=t),a=Math.max(2,Math.floor(n/20));if(s.length<=a)return s;const o=(s.length-1)/(a-1),i=[];for(let l=0;l<a;l++)i.push(s[Math.round(l*o)]);return i}var Wv=({waveHeight:e,numChannels:t,frequencyScaleFn:n,minFrequency:r,maxFrequency:s,labelsColor:a="#ccc",labelsBackground:o="rgba(0,0,0,0.6)",renderMode:i="spectrogram",hasClipHeaders:l=!1})=>{const c=p.useRef(null),u=Si(),f=i==="both"?Math.floor(e/2):e,m=t*e,d=l?22:0;return p.useLayoutEffect(()=>{const h=c.current;if(!h)return;const v=h.getContext("2d");if(!v)return;v.resetTransform(),v.clearRect(0,0,h.width,h.height),v.scale(u,u);const g=Bv(r,s,f);for(let y=0;y<t;y++){const b=y*e+d;v.font="11px monospace",v.textBaseline="middle";for(const _ of g){const w=n(_,r,s);if(w<0||w>1)continue;const x=b+f*(1-w),S=_>=1e3?`${(_/1e3).toFixed(1)}k`:`${_} Hz`,k=v.measureText(S),E=3;v.fillStyle=o,v.fillRect(0,x-7,k.width+E*2,14),v.fillStyle=a,v.fillText(S,E,x)}}},[e,t,n,r,s,a,o,u,f,d]),C.jsx(Lv,{$height:m+d,children:C.jsx("canvas",{ref:c,width:Xl*u,height:(m+d)*u,style:{width:Xl,height:m+d,pointerEvents:"none"}})})},Vv=F.div.attrs(e=>({style:{width:`${e.$cssWidth}px`,height:`${e.$timeScaleHeight}px`}}))`
|
|
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
|
+
`,Nv=F.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
|
+
`,zv=e=>{const{theme:{timeColor:t},tickData:n}=e,{canvasRef:r,canvasMapRef:s}=qs(),{timeScaleHeight:a}=p.useContext(Wr),o=Si(),{widthX:i,canvasInfo:l,timeMarkersWithPositions:c}=n,u=Ks(i,Be),f=u.map(v=>{const g=v*Be,y=Math.min(i-g,Be);return C.jsx(Nv,{$cssWidth:y,$left:g,$timeScaleHeight:a,width:y*o,height:a*o,"data-index":v,ref:r},`timescale-${v}`)}),m=u.length>0?u[0]*Be:0,d=u.length>0?(u[u.length-1]+1)*Be:1/0,h=u.length>0?c.filter(({pix:v})=>v>=m&&v<d).map(({element:v})=>v):c.map(({element:v})=>v);return p.useLayoutEffect(()=>{for(const[v,g]of s.current.entries()){const y=g.getContext("2d");if(!y)continue;const b=v*Be,_=g.width/o;y.resetTransform(),y.clearRect(0,0,g.width,g.height),y.imageSmoothingEnabled=!1,y.fillStyle=t,y.scale(o,o);for(const[w,x]of l.entries()){if(w<b||w>=b+_)continue;const S=w-b,k=a-x;y.fillRect(S,k,1,x)}}},[s,o,t,a,l,u]),C.jsxs(Vv,{$cssWidth:i,$timeScaleHeight:a,children:[h,f]})},jv=F.withTheme(zv),Yl=new Map([[700,{marker:1e3,bigStep:500,smallStep:100}],[1500,{marker:2e3,bigStep:1e3,smallStep:200}],[2500,{marker:2e3,bigStep:1e3,smallStep:500}],[5e3,{marker:5e3,bigStep:1e3,smallStep:500}],[1e4,{marker:1e4,bigStep:5e3,smallStep:1e3}],[12e3,{marker:15e3,bigStep:5e3,smallStep:1e3}],[1/0,{marker:3e4,bigStep:1e4,smallStep:5e3}]]);function ho(e){const t=Yl.keys();let n;for(const r of t)if(e<r){n=Yl.get(r);break}return n===void 0&&(n={marker:3e4,bigStep:1e4,smallStep:5e3}),n}function Zv(e){const t=Math.floor(e/1e3),n=t%60;return`${(t-n)/60}:${String(n).padStart(2,"0")}`}var Hv=F.div.attrs(e=>({style:{left:`${e.$left+4}px`}}))`
|
|
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
|
+
`,Kd=({renderTick:e})=>{const{samplesPerPixel:t,sampleRate:n,duration:r,timeScaleHeight:s}=p.useContext(Wr),a=Gd(),o=p.useMemo(()=>{const i=ah(r/1e3,t,n);if(a&&a.scaleMode==="beats"){const{bpm:g,timeSignature:y,ticksPerBar:b,ticksPerBeat:_}=a,w=new Map,x=[],S=r/1e3,k=Math.ceil(S*g*Nn/60),E=Rn(_,g,n)/t,M=Rn(b,g,n)/t,T=10,$=30;let A;if(E>=T)A=_;else if(M>=T)A=b;else{const R=Math.ceil(T/M);A=b*R}let I;if(E>=$)I=_;else if(M>=$)I=b;else{const R=Math.ceil($/M);I=b*R}for(let R=0;R<=k;R+=A){const D=Rn(R,g,n),O=sh(D,t);if(O>=i)break;const Z=R%b===0,G=R%I===0,Y=Z?s:Math.floor(G?s/2:s/5);if(w.set(O,Y),G){const te=oh(R,y),X=e?C.jsx(p.Fragment,{children:e(te,O)},`bb-${R}`):C.jsx("div",{style:{position:"absolute",left:`${O+4}px`,fontSize:"0.75rem",whiteSpace:"nowrap"},children:te},`bb-${R}`);x.push({pix:O,element:X})}}return{widthX:i,canvasInfo:w,timeMarkersWithPositions:x}}const l=ho(t),{marker:c,bigStep:u,smallStep:f}=l,m=new Map,d=[],h=n/t;let v=0;for(let g=0;g<i;g+=h*f/1e3){const y=Math.floor(g);if(v%c===0){const b=Zv(v),_=e?C.jsx(p.Fragment,{children:e(b,y)},`timestamp-${v}`):C.jsx(Hv,{$left:y,children:b},b);d.push({pix:y,element:_}),m.set(y,s)}else v%u===0?m.set(y,Math.floor(s/2)):v%f===0&&m.set(y,Math.floor(s/5));v+=f}return{widthX:i,canvasInfo:m,timeMarkersWithPositions:d}},[a,r,t,n,s,e]);return C.jsx(jv,{tickData:o})},Gv=F.div`
|
|
636
636
|
display: inline-flex;
|
|
637
637
|
align-items: center;
|
|
638
638
|
gap: 0.5rem;
|
|
639
|
-
`,
|
|
639
|
+
`,Uv=[{value:"seconds",label:"seconds"},{value:"thousandths",label:"thousandths"},{value:"hh:mm:ss",label:"hh:mm:ss"},{value:"hh:mm:ss.u",label:"hh:mm:ss + tenths"},{value:"hh:mm:ss.uu",label:"hh:mm:ss + hundredths"},{value:"hh:mm:ss.uuu",label:"hh:mm:ss + milliseconds"}],Xv=({value:e,onChange:t,disabled:n=!1,className:r})=>{const s=a=>{t(a.target.value)};return C.jsx(Gv,{className:r,children:C.jsx(Od,{className:"time-format",value:e,onChange:s,disabled:n,"aria-label":"Time format selection",children:Uv.map(a=>C.jsx("option",{value:a.value,children:a.label},a.value))})})},Yv=F.div.attrs(e=>({style:{height:`${e.$waveHeight*e.$numChannels+(e.$hasClipHeaders?xi:0)}px`}}))`
|
|
640
640
|
position: relative;
|
|
641
641
|
${e=>e.$width!==void 0&&`width: ${e.$width}px;`}
|
|
642
|
-
`,
|
|
642
|
+
`,Kv=F.div.attrs(e=>({style:{paddingLeft:`${e.$offset||0}px`}}))`
|
|
643
643
|
position: relative;
|
|
644
644
|
background: ${e=>e.$backgroundColor||"transparent"};
|
|
645
645
|
height: 100%;
|
|
646
|
-
`,
|
|
646
|
+
`,qd=({numChannels:e,children:t,className:n,backgroundColor:r,offset:s=0,width:a,hasClipHeaders:o=!1,onClick:i,trackId:l,isSelected:c=!1})=>{const{waveHeight:u}=Js();return C.jsx(Yv,{$numChannels:e,className:n,$waveHeight:u,$width:a,$hasClipHeaders:o,children:C.jsx(Kv,{$backgroundColor:r,$offset:s,onClick:i,"data-track-id":l,children:t})})},Kl=F.button.attrs({type:"button"})`
|
|
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
|
+
`,qv=F.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
|
+
`,Jv=F.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
|
+
`,Qv=({onClick:e,title:t="Remove track"})=>C.jsx(Jv,{onClick:e,title:t,children:C.jsx(Tg,{size:12,weight:"bold"})}),e0=F.div`
|
|
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
|
+
`,t0=F.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
|
+
`,n0=e=>C.jsx(Dd,{weight:"light",...e}),r0=e=>C.jsx(Rd,{weight:"light",...e}),s0=e=>C.jsx($d,{weight:"bold",...e}),ql=F(Ld)`
|
|
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
|
+
`,Jl=F.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
|
+
`,a0=F.div`
|
|
824
824
|
position: relative;
|
|
825
825
|
display: inline-block;
|
|
826
|
-
`,
|
|
826
|
+
`,o0=F.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
|
+
`,bs=180,i0=F.div`
|
|
841
841
|
position: fixed;
|
|
842
842
|
top: ${e=>e.$top}px;
|
|
843
843
|
left: ${e=>e.$left}px;
|
|
@@ -847,14 +847,14 @@
|
|
|
847
847
|
border: 1px solid rgba(128, 128, 128, 0.4);
|
|
848
848
|
border-radius: 6px;
|
|
849
849
|
padding: 0.5rem 0;
|
|
850
|
-
min-width: ${
|
|
850
|
+
min-width: ${bs}px;
|
|
851
851
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
852
|
-
`,
|
|
852
|
+
`,l0=F.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 w0(e,t,n){var r;return function(a){return r=r||b0(e),new Worker(r,a)}}var _0=w0("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function gt(e){if(m0(e)&&(e=v0(e)),g0(e)){this._data=new DataView(e),this._offset=this._version()===2?24:20,this._channels=[];for(var t=0;t<this.channels;t++)this._channels[t]=new wn(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var Jn={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function x0(e){var t={scale:e.scale||Jn.scale,bits:e.bits||Jn.bits,amplitude_scale:e.amplitude_scale||Jn.amplitude_scale,split_channels:e.split_channels||Jn.split_channels,disable_worker:e.disable_worker||Jn.disable_worker};return t}function C0(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function qd(e,t,n){var r=C0(e);if(t.disable_worker){var s=p0({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 gt(s),e)}else{var a=new _0;a.onmessage=function(o){n(void 0,new gt(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 S0(e,t,n,r){function s(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var a=e.decodeAudioData(t,function(o){qd(o,n,r)},s);a&&a.catch(s)}gt.create=function(t){return new gt(t)};gt.createFromAudio=function(e,t){var n=x0(e);if(e.audio_context&&e.array_buffer)return S0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return qd(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Js(e){this._inputData=e.waveformData,this._output_samples_per_pixel=e.scale,this._scale=this._inputData.scale,this._input_buffer_size=this._inputData.length;var t=this._input_buffer_size*this._inputData.scale,n=Math.ceil(t/this._output_samples_per_pixel),r=24,s=this._inputData.bits===8?1:2,a=r+n*2*this._inputData.channels*s;this._output_data=new ArrayBuffer(a),this.output_dataview=new DataView(this._output_data),this.output_dataview.setInt32(0,2,!0),this.output_dataview.setUint32(4,this._inputData.bits===8,!0),this.output_dataview.setInt32(8,this._inputData.sample_rate,!0),this.output_dataview.setInt32(12,this._output_samples_per_pixel,!0),this.output_dataview.setInt32(16,n,!0),this.output_dataview.setInt32(20,this._inputData.channels,!0),this._outputWaveformData=new gt(this._output_data),this._input_index=0,this._output_index=0;var o=this._inputData.channels;this._min=new Array(o),this._max=new Array(o);for(var i=0;i<o;++i)this._input_buffer_size>0?(this._min[i]=this._inputData.channel(i).min_sample(this._input_index),this._max[i]=this._inputData.channel(i).max_sample(this._input_index)):(this._min[i]=0,this._max[i]=0);this._min_value=this._inputData.bits===8?-128:-32768,this._max_value=this._inputData.bits===8?127:32767,this._where=0,this._prev_where=0,this._stop=0,this._last_input_index=0}Js.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};Js.prototype.next=function(){for(var e=0,t=1e3,n=this._inputData.channels,r;this._input_index<this._input_buffer_size&&e<t;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(var s=0;s<n;++s)r=this._outputWaveformData.channel(s),r.set_min_sample(this._output_index-1,this._min[s]),r.set_max_sample(this._output_index-1,this._max[s]);if(this._last_input_index=this._input_index,this._output_index++,this._where=this.sample_at_pixel(this._output_index),this._prev_where=this.sample_at_pixel(this._output_index-1),this._where!==this._prev_where)for(var a=0;a<n;++a)this._min[a]=this._max_value,this._max[a]=this._min_value}for(this._where=this.sample_at_pixel(this._output_index),this._stop=Math.floor(this._where/this._scale),this._stop>this._input_buffer_size&&(this._stop=this._input_buffer_size);this._input_index<this._stop;){for(var o=0;o<n;++o){r=this._inputData.channel(o);var i=r.min_sample(this._input_index);i<this._min[o]&&(this._min[o]=i),i=r.max_sample(this._input_index),i>this._max[o]&&(this._max[o]=i)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var l=0;l<n;++l)r=this._outputWaveformData.channel(l),r.set_min_sample(this._output_index-1,this._min[l]),r.set_max_sample(this._output_index-1,this._max[l]);return!0};Js.prototype.getOutputData=function(){return this._output_data};gt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Sn(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Sn(n.scale)&&(typeof n.scale!="number"||n.scale<=0))throw new RangeError("WaveformData.resample(): scale should be a positive integer value");if(!n.scale&&!n.width)throw new Error("WaveformData.resample(): Missing scale or width option");if(n.width&&(n.scale=Math.floor(this.duration*this.sample_rate/n.width)),n.scale<this.scale)throw new Error("WaveformData.resample(): Zoom level "+n.scale+" too low, minimum: "+this.scale);return n.abortSignal=t.abortSignal,n},resample:function(t){t=this._getResampleOptions(t),t.waveformData=this;for(var n=new Js(t);!n.next(););return new gt(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 gt.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,s=0,a=[this].concat(t).map(function(y){return y._data.buffer}),o=0;o<a.length;o++){var i=a[o],l=new DataView(i).getInt32(16,!0);r+=i.byteLength-n,s+=l}for(var c=new ArrayBuffer(r),u=new DataView(a[0]),f=new DataView(c),m=0;m<n;m++)f.setUint8(m,u.getUint8(m));f.setInt32(16,s,!0);for(var d=0,h=new Uint8Array(c,n),g=0;g<a.length;g++){var v=a[g];h.set(new Uint8Array(v,n),d),d+=v.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!Sn(t.startIndex)&&!Sn(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Sn(t.startTime)&&!Sn(t.endTime)&&(n=this.at_time(t.startTime),r=this.at_time(t.endTime)),n<0)throw new RangeError("startIndex or startTime must not be negative");if(r<0)throw new RangeError("endIndex or endTime must not be negative");n>this.length&&(n=this.length),r>this.length&&(r=this.length),n>r&&(n=r);var s=r-n,a=24,o=this.bits===8?1:2,i=a+s*2*this.channels*o,l=new ArrayBuffer(i),c=new DataView(l);c.setInt32(0,2,!0),c.setUint32(4,this.bits===8,!0),c.setInt32(8,this.sample_rate,!0),c.setInt32(12,this.scale,!0),c.setInt32(16,s,!0),c.setInt32(20,this.channels,!0);for(var u=0;u<s*this.channels*2;u++){var f=this._at(n*this.channels*2+u);this.bits===8?c.setInt8(a+u,f):c.setInt16(a+u*2,f,!0)}return new gt(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 Ci(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 gt.create(r)}else{const r=await t.json();return gt.create(r)}}function Jd(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 k0(e,t=0){const n=await Ci(e);return Jd(n,t)}async function E0(e){const t=await Ci(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function Qd(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 I0(e,t,n=0,r,s){const a=Qd(e,t,r,s);if(a===null){const m=e.bits;return{data:m===8?new Int8Array(0):new Int16Array(0),bits:m,length:0}}const o=a.channel(n),i=a.bits,l=o.min_array(),c=o.max_array(),u=l.length,f=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let m=0;m<u;m++)f[m*2]=l[m],f[m*2+1]=c[m];return{data:f,bits:i,length:u}}function Jl(e,t,n,r,s){const a=Qd(e,t,r,s);if(a===null){const u=e.bits;return{length:0,data:[],bits:u}}const o=a.channels,i=a.bits,l=[];for(let u=0;u<o;u++){const f=a.channel(u),m=f.min_array(),d=f.max_array(),h=m.length,g=i===8?new Int8Array(h*2):new Int16Array(h*2);for(let v=0;v<h;v++)g[v*2]=m[v],g[v*2+1]=d[v];l.push(g)}if(n&&l.length>1){const u=1/l.length,f=l[0].length/2,m=i===8?new Int8Array(f*2):new Int16Array(f*2);for(let d=0;d<f;d++){let h=0,g=0;for(let v=0;v<l.length;v++)h+=u*l[v][d*2],g+=u*l[v][d*2+1];m[d*2]=h,m[d*2+1]=g}return{length:f,data:[m],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function ef(){const[e,t]=p.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Pn(s,e),parseTime:s=>Zd(s,e)}}function tf({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=p.useState(t),[s,a]=p.useState(!0),[o,i]=p.useState(!0),l=p.useRef(!0),c=p.useRef(!0),u=p.useRef(t),f=p.useCallback(()=>{e.current?.zoomIn()},[e]),m=p.useCallback(()=>{e.current?.zoomOut()},[e]),d=p.useCallback(h=>{h.samplesPerPixel!==u.current&&(u.current=h.samplesPerPixel,p.startTransition(()=>{r(h.samplesPerPixel)})),h.canZoomIn!==l.current&&(l.current=h.canZoomIn,a(h.canZoomIn)),h.canZoomOut!==c.current&&(c.current=h.canZoomOut,i(h.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:f,zoomOut:m,canZoomIn:s,canZoomOut:o,onEngineState:d}}function nf({engineRef:e,initialVolume:t=1}){const[n,r]=p.useState(t),s=p.useRef(t),a=p.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),o=p.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:a,masterVolumeRef:s,onEngineState:o}}function M0({engineRef:e}){const[t,n]=p.useState(0),[r,s]=p.useState(0),a=p.useRef(0),o=p.useRef(0),i=p.useCallback((c,u)=>{e.current?.setSelection(c,u)},[e]),l=p.useCallback(c=>{c.selectionStart!==a.current&&(a.current=c.selectionStart,n(c.selectionStart)),c.selectionEnd!==o.current&&(o.current=c.selectionEnd,s(c.selectionEnd))},[]);return{selectionStart:t,selectionEnd:r,setSelection:i,selectionStartRef:a,selectionEndRef:o,onEngineState:l}}function A0({engineRef:e}){const[t,n]=p.useState(!1),[r,s]=p.useState(0),[a,o]=p.useState(0),i=p.useRef(!1),l=p.useRef(0),c=p.useRef(0),u=p.useCallback(h=>{e.current?.setLoopEnabled(h)},[e]),f=p.useCallback((h,g)=>{e.current?.setLoopRegion(h,g)},[e]),m=p.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),d=p.useCallback(h=>{h.isLoopEnabled!==i.current&&(i.current=h.isLoopEnabled,n(h.isLoopEnabled)),h.loopStart!==l.current&&(l.current=h.loopStart,s(h.loopStart)),h.loopEnd!==c.current&&(c.current=h.loopEnd,o(h.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:a,setLoopEnabled:u,setLoopRegion:f,clearLoopRegion:m,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:d}}function T0({engineRef:e}){const[t,n]=p.useState(null),r=p.useRef(null),s=p.useCallback(o=>{e.current?.selectTrack(o)},[e]),a=p.useCallback(o=>{o.selectedTrackId!==r.current&&(r.current=o.selectedTrackId,n(o.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:a,selectedTrackIdRef:r}}const $0=(e=256)=>{const t=p.useRef(null),n=p.useCallback((r,s,a)=>{const o=new L.Analyser("fft",e);return r.connect(o),r.connect(s),t.current=o,function(){o.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:n}},R0=48e3;function ss(e,t,n,r){const s=n??e.audioBuffer,a=s?.sampleRate??e.waveformData?.sample_rate??R0,o=s?.duration??e.waveformData?.duration??(e.duration!=null?e.duration+(e.offset??0):void 0);if(o===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 i=cc({audioBuffer:s,sampleRate:a,sourceDuration:o,startTime:e.startTime??0,duration:e.duration??o,offset:e.offset??0,name:e.name||`Track ${t+1}`,fadeIn:e.fadeIn,fadeOut:e.fadeOut,waveformData:e.waveformData});if(isNaN(i.startSample)||isNaN(i.durationSamples)||isNaN(i.offsetSamples))return console.error(`[waveform-playlist] Invalid clip values for track ${t+1} ("${e.name??"unnamed"}"): startSample=${i.startSample}, durationSamples=${i.durationSamples}, offsetSamples=${i.offsetSamples}`),null;const l={...uc({name:e.name||`Track ${t+1}`,clips:[i],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},c=r.get(t);return c?(l.id=c.trackId,l.clips[0]={...l.clips[0],id:c.clipId}):r.set(t,{trackId:l.id,clipId:l.clips[0].id}),l}function D0(e,t={}){const{immediate:n=!1,progressive:r=!1}=t,s=n||r,[a,o]=p.useState(!0),[i,l]=p.useState(null),[c,u]=p.useState(0),f=e.length,[m,d]=p.useState(new Map),h=p.useRef(new Map),g=p.useMemo(()=>{if(!s)return null;const w=[];for(let _=0;_<e.length;_++){const x=ss(e[_],_,m.get(_),h.current);x&&w.push(x)}return w},[s,e,m]),[v,y]=p.useState(g??[]),b=p.useRef(g);return g!==b.current&&(b.current=g,g&&y(g)),p.useEffect(()=>{if(e.length===0){y([]),o(!1),u(0);return}let w=!1;const _=new AbortController;return(async()=>{try{o(!0),l(null),u(0),s&&d(new Map);const S=lc.getContext().rawContext,k=e.map(async(I,T)=>{if(I.audioBuffer){if(s&&!w){d($=>{const P=new Map($);return P.set(T,I.audioBuffer),P}),u($=>$+1);return}return ss(I,T,I.audioBuffer,h.current)}if(!I.src&&I.waveformData){if(s&&!w){u($=>$+1);return}return ss(I,T,void 0,h.current)}if(!I.src)throw new Error(`Track ${T+1}: Must provide src, audioBuffer, or waveformData`);const R=await fetch(I.src,{signal:_.signal});if(!R.ok)throw new Error(`Failed to fetch ${I.src}: ${R.statusText}`);const A=await R.arrayBuffer(),M=await S.decodeAudioData(A);if(!M||!M.sampleRate||!M.duration)throw new Error(`Invalid audio buffer for ${I.src}`);if(s&&!w){d($=>{const P=new Map($);return P.set(T,M),P}),u($=>$+1);return}return ss(I,T,M,h.current)}),E=await Promise.all(k);if(!w){if(!s){const I=E.filter(T=>T!=null);y(I),u(I.length)}o(!1)}}catch(S){if(!w){const k=S instanceof Error?S.message:"Unknown error loading audio";l(k),o(!1),console.error(`[waveform-playlist] Error loading audio tracks: ${k}`)}}})(),()=>{w=!0,_.abort()}},[e,s]),{tracks:v,loading:a,error:i,loadedCount:c,totalCount:f}}function P0({originalClip:e,clip:t,pixelDelta:n,samplesPerPixel:r,sampleRate:s,boundary:a,sortedClips:o,sortedIndex:i}){const l=n*r,c=Math.floor(.1*s),u={...t,startSample:e.startSample,offsetSamples:e.offsetSamples,durationSamples:e.durationSamples},f=gc(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 rf({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:a,snapSamplePosition:o}){const i=p.useRef(o);i.current=o;const l=p.useRef(null),c=p.useRef(0),u=p.useCallback(d=>{const h=d.operation.source?.data;if(!h)return;if(!h.boundary){l.current=null;return}const v=e[h.trackIndex]?.clips[h.clipIndex];v&&(l.current={offsetSamples:v.offsetSamples,durationSamples:v.durationSamples,startSample:v.startSample},a.current=!0)},[e,a]),f=p.useCallback(d=>{const h=d.operation.source?.data;if(!h||!h.boundary||!l.current)return;const{boundary:g,trackIndex:v,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,T)=>{if(T!==v)return I;const R=[...I.clips].sort(($,P)=>$.startSample-P.startSample),A=R.findIndex($=>$===I.clips[y]),M=I.clips.map(($,P)=>{if(P!==y)return $;let O=P0({originalClip:x,clip:$,pixelDelta:w,samplesPerPixel:n,sampleRate:r,boundary:g,sortedClips:R,sortedIndex:A});if(S)if(g==="left"){const Z=S(O.startSample),G=Z-O.startSample;O={startSample:Z,durationSamples:O.durationSamples-G,offsetSamples:O.offsetSamples+G},k=Z-x.startSample}else{const Z=O.startSample+O.durationSamples,G=S(Z);O={...O,durationSamples:G-O.startSample},k=O.durationSamples-x.durationSamples}return{...$,startSample:O.startSample,durationSamples:O.durationSamples,offsetSamples:O.offsetSamples}});return{...I,clips:M}});c.current=k,t(E)},[e,t,n,r]),m=p.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,T)=>{if(T!==x)return I;const R=I.clips.map((A,M)=>M!==S?A:{...A,offsetSamples:k.offsetSamples,durationSamples:k.durationSamples,startSample:k.startSample});return{...I,clips:R}});t(E)}}a.current=!1,l.current=null,c.current=0;return}const h=d.operation.source?.data;if(!h)return;const{trackIndex:g,clipId:v,boundary:y}=h,b=y?c.current:d.operation.transform.x*n,w=e[g]?.id;if(y){a.current=!1,w?s.current?s.current.trimClip(w,v,y,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,v,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:m}}const _a=.01;function sf({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:a}){const o=p.useRef(null),i=p.useCallback(u=>{const f=u.operation.source?.data;if(!f||f.annotationIndex===void 0){o.current=null;return}const m=e[f.annotationIndex];m&&(o.current={start:m.start,end:m.end,annotationIndex:f.annotationIndex})},[e]),l=p.useCallback(u=>{if(!o.current)return;const f=u.operation.source?.data;if(!f)return;const{edge:m,annotationIndex:d}=f,h=o.current,y=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n/r,b=m==="start"?h.start+y:h.end+y,w=F0({annotationIndex:d,newTime:b,isDraggingStart:m==="start",annotations:e,duration:s,linkEndpoints:a});t(w)},[e,t,n,r,s,a]),c=p.useCallback(u=>{if(u.canceled&&o.current){const{annotationIndex:f,start:m,end:d}=o.current,h=e.map((g,v)=>v!==f?g:{...g,start:m,end:d});t(h)}o.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function F0({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:s,linkEndpoints:a}){const o=[...r],i=r[e];if(n){const l=Math.min(i.end-.1,Math.max(0,t)),c=l-i.start;if(o[e]={...i,start:l},a&&e>0){const u=o[e-1];Math.abs(u.end-i.start)<_a?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)<_a){const f=u.start+c;o[e+1]={...u,start:Math.min(u.end-.1,f)};let m=e+1;for(;m<o.length-1;){const d=o[m],h=o[m+1];if(Math.abs(h.start-d.end)<_a){const g=d.end-r[m].end;o[m+1]={...h,start:Math.min(h.end-.1,h.start+g)},m++}else break}}else l>=u.start&&(o[e]={...o[e],end:u.start})}else if(!a&&e<o.length-1&&l>o[e+1].start){const u=o[e+1];o[e+1]={...u,start:l};let f=e+1;for(;f<o.length-1;){const m=o[f],d=o[f+1];if(m.end>d.start)o[f+1]={...d,start:m.end},f++;else break}}}return o}function af(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return p.useMemo(()=>t?[so.configure({activationConstraints(a){return a.pointerType==="touch"?[new Ft.Delay({value:n,tolerance:r})]:[new Ft.Distance({value:s})]}})]:[so.configure({activationConstraints:[new Ft.Distance({value:s})]})],[t,n,r,s])}const of=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=ot(),{selectedTrackId:a}=it(),o=p.useCallback((l,c,u)=>{const{samplesPerPixel:f}=e,m=t[l];if(!m)return!1;const d=m.clips[c];if(!d)return!1;const h=Math.round(u*n),g=vh(h,f),v=Math.floor(.1*n);if(!vc(d,g,v))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const y=r.current;return y?(y.splitClip(m.id,d.id,g),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:p.useCallback(()=>{if(!a)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const l=t.findIndex(f=>f.id===a);if(l===-1)return console.warn("Selected track not found"),!1;const c=t[l],u=s.current??0;for(let f=0;f<c.clips.length;f++){const m=c.clips[f],d=m.startSample/n,h=(m.startSample+m.durationSamples)/n;if(u>d&&u<h)return o(l,f,u)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${c.name}"`),!1},[t,s,a,o,n]),splitClipAt:o}},Os=e=>{const{shortcuts:t,enabled:n=!0}=e,r=p.useCallback(s=>{if(!n)return;const a=s.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const o=t.find(i=>{const l=s.key.toLowerCase()===i.key.toLowerCase()||s.key===i.key,c=i.ctrlKey===void 0||s.ctrlKey===i.ctrlKey,u=i.shiftKey===void 0||s.shiftKey===i.shiftKey,f=i.metaKey===void 0||s.metaKey===i.metaKey,m=i.altKey===void 0||s.altKey===i.altKey;return l&&c&&u&&f&&m});o&&(o.preventDefault!==!1&&s.preventDefault(),o.action())},[t,n]);p.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},O0=e=>{const t=[],n=typeof navigator<"u"&&navigator.platform.includes("Mac");return e.metaKey&&t.push(n?"Cmd":"Ctrl"),e.ctrlKey&&!e.metaKey&&t.push("Ctrl"),e.altKey&&t.push(n?"Option":"Alt"),e.shiftKey&&t.push("Shift"),t.push(e.key.toUpperCase()),t.join("+")},lf=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=ot(),{setCurrentTime:a,play:o,pause:i,stop:l}=Ie(),c=p.useCallback(()=>{s?i():o()},[s,o,i]),u=p.useCallback(()=>{l()},[l]),f=p.useCallback(()=>{a(0),s&&o(0)},[s,a,o]),d=r??[...[{key:" ",action:c,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:u,description:"Stop",preventDefault:!0},{key:"0",action:f,description:"Rewind to start",preventDefault:!0}],...n];return Os({shortcuts:d,enabled:t}),{rewindToStart:f,togglePlayPause:c,stopPlayback:u,shortcuts:d}},xa=.01,as=.01;function cf({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:s,linkEndpoints:a,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:c,sampleRate:u,onPlay:f}){const m=p.useMemo(()=>t?e.findIndex(E=>E.id===t):-1,[e,t]),d=p.useCallback(E=>{if(!l?.current||!c||!u)return;const I=e.find(G=>G.id===E);if(!I)return;const T=l.current,R=T.clientWidth,A=I.start*u/c,M=I.end*u/c,$=(A+M)/2,P=T.scrollLeft,O=P,Z=P+R;if(A<O||M>Z){const G=Math.max(0,$-R/2);T.scrollTo({left:G,behavior:"smooth"})}},[e,l,c,u]);p.useEffect(()=>{t&&l?.current&&c&&u&&d(t)},[t,d,l,c,u]);const h=p.useCallback(E=>{if(m<0)return;const I=e[m],T=Math.max(0,Math.min(I.end-.1,I.start+E)),R=T-I.start,A=[...e];if(A[m]={...I,start:T},a&&m>0){const M=A[m-1];Math.abs(M.end-I.start)<xa&&(A[m-1]={...M,end:Math.max(M.start+.1,M.end+R)})}else if(!a&&m>0){const M=A[m-1];T<M.end&&(A[m-1]={...M,end:T})}n(A)},[e,m,a,n]),g=p.useCallback(E=>{if(m<0)return;const I=e[m],T=Math.max(I.start+.1,Math.min(s,I.end+E)),R=T-I.end,A=[...e];if(A[m]={...I,end:T},a&&m<e.length-1){const M=A[m+1];if(Math.abs(M.start-I.end)<xa){const $=Math.min(M.end-.1,M.start+R);A[m+1]={...M,start:$};let P=m+1;for(;P<A.length-1;){const O=A[P],Z=A[P+1];if(Math.abs(Z.start-e[P].end)<xa){const G=O.end-e[P].end;A[P+1]={...Z,start:Math.min(Z.end-.1,Z.start+G)},P++}else break}}}else if(!a&&m<e.length-1){const M=A[m+1];if(T>M.start){A[m+1]={...M,start:T};let $=m+1;for(;$<A.length-1;){const P=A[$],O=A[$+1];if(P.end>O.start)A[$+1]={...O,start:P.end},$++;else break}}}n(A)},[e,m,s,a,n]),v=p.useCallback(()=>{!r||e.length===0||(m<=0?r(e[e.length-1].id):r(e[m-1].id))},[e,m,r]),y=p.useCallback(()=>{!r||e.length===0||(m<0||m>=e.length-1?r(e[0].id):r(e[m+1].id))},[e,m,r]),b=p.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),w=p.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),_=p.useCallback(()=>{r&&r(null)},[r]),x=p.useCallback(()=>{if(m<0||!f)return;const E=e[m],I=o?void 0:E.end-E.start;f(E.start,I)},[e,m,o,f]),S=p.useMemo(()=>[{key:"[",action:()=>h(-as),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>h(as),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>g(-as),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>g(as),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:x,description:"Play selected annotation",preventDefault:!0}],[h,g,x]),k=p.useMemo(()=>[{key:"ArrowUp",action:v,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:v,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}],[v,y,b,w,_]);return Os({shortcuts:S,enabled:i&&m>=0}),Os({shortcuts:k,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:h,moveEndBoundary:g,selectPrevious:v,selectNext:y,selectFirst:b,selectLast:w,clearSelection:_,scrollToAnnotation:d,playActiveAnnotation:x}}const Vr=[{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}]}],Si=e=>Vr.find(t=>t.id===e),L0=e=>Vr.filter(t=>t.category===e),B0=[{id:"reverb",name:"Reverb"},{id:"delay",name:"Delay"},{id:"modulation",name:"Modulation"},{id:"filter",name:"Filter"},{id:"distortion",name:"Distortion"},{id:"dynamics",name:"Dynamics"},{id:"spatial",name:"Spatial"}];const W0={reverb:L.Reverb,freeverb:L.Freeverb,jcReverb:L.JCReverb,feedbackDelay:L.FeedbackDelay,pingPongDelay:L.PingPongDelay,chorus:L.Chorus,phaser:L.Phaser,tremolo:L.Tremolo,vibrato:L.Vibrato,autoPanner:L.AutoPanner,autoFilter:L.AutoFilter,autoWah:L.AutoWah,eq3:L.EQ3,distortion:L.Distortion,bitCrusher:L.BitCrusher,chebyshev:L.Chebyshev,compressor:L.Compressor,limiter:L.Limiter,gate:L.Gate,stereoWidener:L.StereoWidener};let V0=0;const N0=()=>`effect_${Date.now()}_${++V0}`;function Er(e,t){const n=W0[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(i=>{const l=t?.[i.name]??i.default;r[i.name]=l});const s=new n(r),a=N0(),o=s;return{effect:s,id:e.id,instanceId:a,dispose(){try{s.disconnect(),s.dispose()}catch(i){console.warn(`[waveform-playlist] Error disposing effect "${e.id}" (${a}):`,i)}},setParameter(i,l){const c=o[i];if(i==="wet"){const u=o.wet;if(u&&typeof u=="object"&&"value"in u){u.value=l;return}}c!==void 0&&(c&&typeof c=="object"&&"value"in c?c.value=l:o[i]=l)},getParameter(i){if(i==="wet"){const c=o.wet;if(c&&typeof c=="object"&&"value"in c)return c.value}const l=o[i];if(l!==void 0)return l&&typeof l=="object"&&"value"in l?l.value:l},connect(i){s.connect(i)},disconnect(){try{s.disconnect()}catch(i){console.warn(`[waveform-playlist] Error disconnecting effect "${e.id}" (${a}):`,i)}}}}function z0(e){if(e.length===0)throw new Error("Cannot create effect chain with no effects");for(let t=0;t<e.length-1;t++)e[t].effect.connect(e[t+1].effect);return{input:e[0].effect,output:e[e.length-1].effect,dispose(){e.forEach(t=>t.dispose())}}}function j0(e=256){const[t,n]=p.useState([]),r=p.useRef(t);r.current=t;const s=p.useRef(new Map),a=p.useRef(null),o=p.useRef(null),i=p.useCallback(v=>{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=v.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=p.useCallback(v=>{const y=Si(v);if(!y){console.error(`Unknown effect: ${v}`);return}const b={};y.parameters.forEach(x=>{b[x.name]=x.default});const w=Er(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=p.useCallback(v=>{const y=s.current.get(v);y&&(y.dispose(),s.current.delete(v)),n(b=>b.filter(w=>w.instanceId!==v))},[]),u=p.useCallback((v,y,b)=>{const w=s.current.get(v);w&&w.setParameter(y,b),n(_=>_.map(x=>x.instanceId===v?{...x,params:{...x.params,[y]:b}}:x))},[]),f=p.useCallback(v=>{const y=r.current.find(_=>_.instanceId===v);if(!y)return;const b=!y.bypassed,w=s.current.get(v);if(w){const _=y.params.wet??1;w.setParameter("wet",b?0:_)}n(_=>_.map(x=>x.instanceId===v?{...x,bypassed:b}:x))},[]),m=p.useCallback((v,y)=>{n(b=>{const w=[...b],[_]=w.splice(v,1);return w.splice(y,0,_),w})},[]),d=p.useCallback(()=>{s.current.forEach(v=>v.dispose()),s.current.clear(),n([])},[]);p.useEffect(()=>{i(t)},[t,i]);const h=p.useCallback((v,y,b)=>{const w=new L.Analyser("fft",e);a.current=w,o.current={masterGainNode:v,destination:y,analyserNode:w};const x=r.current.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)v.connect(w),w.connect(y);else{let S=v;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]);p.useEffect(()=>{const v=s.current;return()=>{v.forEach(y=>y.dispose()),v.clear()}},[]);const g=p.useCallback(()=>{const v=t.filter(y=>!y.bypassed);if(v.length!==0)return(y,b,w)=>{const _=[];for(const x of v){const S=Er(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:Vr,addEffect:l,removeEffect:c,updateParameter:u,toggleBypass:f,reorderEffects:m,clearAllEffects:d,masterEffects:h,createOfflineEffectsFunction:g,analyserRef:a}}function Z0(){const[e,t]=p.useState(new Map),n=p.useRef(new Map),r=p.useRef(new Map),s=p.useCallback((d,h)=>{const g=r.current.get(d);if(!g)return;const{graphEnd:v,masterGainNode:y}=g,b=n.current.get(d);try{v.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)v.connect(y);else{let _=v;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=p.useCallback((d,h)=>{const g=Si(h);if(!g){console.error(`Unknown effect: ${h}`);return}const v={};g.parameters.forEach(w=>{v[w.name]=w.default});const y=Er(g,v);n.current.has(d)||n.current.set(d,new Map),n.current.get(d).set(y.instanceId,y);const b={instanceId:y.instanceId,effectId:g.id,definition:g,params:v,bypassed:!1};t(w=>{const _=new Map(w),x=_.get(d)||[];return _.set(d,[...x,b]),_})},[]),o=p.useCallback((d,h)=>{const g=n.current.get(d),v=g?.get(h);v&&(v.dispose(),g?.delete(h)),t(y=>{const b=new Map(y),w=b.get(d)||[];return b.set(d,w.filter(_=>_.instanceId!==h)),b})},[]),i=p.useCallback((d,h,g,v)=>{const b=n.current.get(d)?.get(h);b&&b.setParameter(g,v),t(w=>{const _=new Map(w),x=_.get(d)||[];return _.set(d,x.map(S=>S.instanceId===h?{...S,params:{...S.params,[g]:v}}:S)),_})},[]),l=p.useCallback((d,h)=>{const v=(u.current.get(d)||[]).find(_=>_.instanceId===h);if(!v)return;const y=!v.bypassed,w=n.current.get(d)?.get(h);if(w){const _=v.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=p.useCallback(d=>{const h=n.current.get(d);h&&(h.forEach(g=>g.dispose()),h.clear()),t(g=>{const v=new Map(g);return v.set(d,[]),v})},[]),u=p.useRef(e);u.current=e;const f=p.useCallback(d=>(h,g,v)=>{r.current.set(d,{graphEnd:h,masterGainNode:g});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(g);else{let _=h;w.forEach(x=>{_.connect(x.effect),_=x.effect}),_.connect(g)}return function(){r.current.delete(d)}},[]);p.useEffect(()=>{e.forEach((d,h)=>{s(h,d)})},[e,s]),p.useEffect(()=>{const d=n.current;return()=>{d.forEach(h=>{h.forEach(g=>g.dispose()),h.clear()}),d.clear()}},[]);const m=p.useCallback(d=>{const g=(e.get(d)||[]).filter(v=>!v.bypassed);if(g.length!==0)return(v,y,b)=>{const w=[];for(const _ of g){const x=Er(_.definition,_.params);w.push(x)}if(w.length===0)v.connect(y);else{let _=v;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:m,availableEffects:Vr}}function H0(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,s=e.sampleRate,a=e.length,o=n/8,i=r*o,l=s*i,c=a*i,u=44,f=u+c,m=new ArrayBuffer(f),d=new DataView(m);os(d,0,"RIFF"),d.setUint32(4,f-8,!0),os(d,8,"WAVE"),os(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),os(d,36,"data"),d.setUint32(40,c,!0);const h=[];for(let v=0;v<r;v++)h.push(e.getChannelData(v));let g=u;if(n===16)for(let v=0;v<a;v++)for(let y=0;y<r;y++){const b=h[y][v],w=Math.max(-1,Math.min(1,b)),_=w<0?w*32768:w*32767;d.setInt16(g,_,!0),g+=2}else for(let v=0;v<a;v++)for(let y=0;y<r;y++)d.setFloat32(g,h[y][v],!0),g+=4;return new Blob([m],{type:"audio/wav"})}function os(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function G0(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}function uf(){const[e,t]=p.useState(!1),[n,r]=p.useState(0),[s,a]=p.useState(null);return{exportWav:p.useCallback(async(i,l,c={})=>{const{filename:u="export",mode:f="master",trackIndex:m,autoDownload:d=!0,applyEffects:h=!0,effectsFunction:g,createOfflineTrackEffects:v,bitDepth:y=16,onProgress:b}=c;t(!0),r(0),a(null);try{if(i.length===0)throw new Error("No tracks to export");if(f==="individual"&&(m===void 0||m<0||m>=i.length))throw new Error("Invalid track index for individual export");const w=i[0].clips[0]?.sampleRate||44100;let _=0;for(const R of i)for(const A of R.clips){const M=A.startSample+A.durationSamples;_=Math.max(_,M)}_+=Math.round(w*.1);const x=_/w,S=f==="individual"?[{track:i[m],state:l[m],index:m}]:i.map((R,A)=>({track:R,state:l[A],index:A})),k=l.some(R=>R.soloed),E=!!v;let I;if((g||E)&&h)I=await U0(S,l,k,x,w,g,v,R=>{r(R),b?.(R)});else{const R=new OfflineAudioContext(2,_,w);let A=0;const M=S.reduce(($,{track:P})=>$+P.clips.length,0);for(const{track:$,state:P}of S)if(!(P.muted&&!P.soloed)&&!(k&&!P.soloed))for(const O of $.clips){await Y0(R,O,P,w,h),A++;const Z=A/M*.5;r(Z),b?.(Z)}r(.5),b?.(.5),I=await R.startRendering()}r(.9),b?.(.9);const T=H0(I,{bitDepth:y});if(r(1),b?.(1),d){const R=f==="individual"?`${u}_${i[m].name}`:u;G0(T,`${R}.wav`)}return{audioBuffer:I,blob:T,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 U0(e,t,n,r,s,a,o,i){const{Offline:l,Volume:c,Gain:u,Panner:f,Player:m,ToneAudioBuffer:d}=await import("tone");i(.1);let h;try{h=await l(async({transport:g,destination:v})=>{const y=new c(0);let b;a?b=a(y,v,!0):y.connect(v);for(const{track:w,state:_}of e){if(_.muted&&!_.soloed||n&&!_.soloed)continue;const x=new c(X0(_.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:T,startSample:R,durationSamples:A,offsetSamples:M,gain:$,fadeIn:P,fadeOut:O}=I,Z=R/s,G=A/s,Y=M/s,ee=new d(T),X=new m(ee),K=new u($);if(X.connect(K),K.connect(x),P){const le=Z,te=Z+P.duration,fe=vr(K.gain);fe&&(fe.setValueAtTime(0,le),fe.linearRampToValueAtTime($,te))}if(O){const le=Z+G-O.duration,te=Z+G,fe=vr(K.gain);fe&&(fe.setValueAtTime($,le),fe.linearRampToValueAtTime(0,te))}X.start(Z,Y,G)}}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 X0(e){return 20*Math.log10(Math.max(e,1e-4))}async function Y0(e,t,n,r,s){const{audioBuffer:a,startSample:o,durationSamples:i,offsetSamples:l,gain:c,fadeIn:u,fadeOut:f}=t;if(!a){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const m=o/r,d=i/r,h=l/r,g=e.createBufferSource();g.buffer=a;const v=e.createGain(),y=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,g.connect(v),v.connect(b),b.connect(e.destination),s){if(u?v.gain.setValueAtTime(0,m):v.gain.setValueAtTime(y,m),u){const w=m,_=m+u.duration;Ql(v.gain,w,_,0,y,u.type||"linear")}if(f){const w=m+d-f.duration,_=m+d;(!u||u.duration<d-f.duration)&&v.gain.setValueAtTime(y,w),Ql(v.gain,w,_,y,0,f.type||"linear")}}else v.gain.setValueAtTime(y,m);g.start(m,h,d)}function Ql(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=ec(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,o);break}case"sCurve":{const i=ec(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,o);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function ec(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 df=()=>{const e=p.useRef(null),t=p.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=p.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return p.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},K0=`
|
|
856
|
+
`,c0=({items:e})=>{const[t,n]=p.useState(!1),r=p.useCallback(()=>n(!1),[]),s=typeof e=="function"?e(r):e,[a,o]=p.useState({top:0,left:0}),i=p.useRef(null),l=p.useRef(null),c=p.useCallback(()=>{if(!i.current)return;const u=i.current.getBoundingClientRect(),f=window.innerWidth,m=window.innerHeight,d=l.current?.offsetHeight??160;let h=u.right+4;h+bs>f&&(h=u.left-bs-4),h=Math.max(4,Math.min(h,f-bs-4));let v=u.top;v+d>m-4&&(v=Math.max(4,u.bottom-d)),o({top:v,left:h})},[]);return p.useEffect(()=>{if(!t)return;c();const u=requestAnimationFrame(()=>c()),f=()=>c(),m=()=>c();return window.addEventListener("scroll",f,!0),window.addEventListener("resize",m),()=>{cancelAnimationFrame(u),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",m)}},[t,c]),p.useEffect(()=>{if(!t)return;const u=m=>{const d=m.target;i.current&&!i.current.contains(d)&&l.current&&!l.current.contains(d)&&n(!1)},f=m=>{m.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[t]),C.jsxs(a0,{children:[C.jsx(o0,{ref:i,onClick:u=>{u.stopPropagation(),n(f=>!f)},onMouseDown:u=>u.stopPropagation(),title:"Track menu","aria-label":"Track menu",children:C.jsx(s0,{size:16})}),t&&typeof document<"u"&&yo.createPortal(C.jsx(i0,{ref:l,$top:a.top,$left:a.left,onMouseDown:u=>u.stopPropagation(),children:s.map((u,f)=>C.jsxs(p.Fragment,{children:[f>0&&C.jsx(l0,{}),u.content]},u.id))}),document.body)]})};function wn(e,t){this._waveformData=e,this._channelIndex=t}wn.prototype.min_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(t)};wn.prototype.max_sample=function(e){var t=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(t)};wn.prototype.set_min_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(n,t)};wn.prototype.set_max_sample=function(e,t){var n=(e*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(n,t)};wn.prototype.min_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.min_sample(n));return t};wn.prototype.max_array=function(){for(var e=this._waveformData.length,t=[],n=0;n<e;n++)t.push(this.max_sample(n));return t};var u0=127,d0=-128,f0=32767,h0=-32768;function p0(e,t){var n=Math.floor(e/t),r=e-n*t;return r>0&&n++,n}function m0(e){for(var t=e.scale,n=e.amplitude_scale,r=e.split_channels,s=e.length,a=e.sample_rate,o=e.channels.map(function($){return new Float32Array($)}),i=r?o.length:1,l=24,c=p0(s,t),u=e.bits===8?1:2,f=l+c*2*u*i,m=new ArrayBuffer(f),d=new DataView(m),h=0,v=l,g=new Array(i),y=new Array(i),b=0;b<i;b++)g[b]=1/0,y[b]=-1/0;var _=e.bits===8?d0:h0,w=e.bits===8?u0:f0;d.setInt32(0,2,!0),d.setUint32(4,e.bits===8,!0),d.setInt32(8,a,!0),d.setInt32(12,t,!0),d.setInt32(16,c,!0),d.setInt32(20,i,!0);for(var x=0;x<s;x++){var S=0;if(i===1){for(var k=0;k<o.length;++k)S+=o[k][x];S=Math.floor(w*S*n/o.length),S<g[0]&&(g[0]=S,g[0]<_&&(g[0]=_)),S>y[0]&&(y[0]=S,y[0]>w&&(y[0]=w))}else for(var E=0;E<i;++E)S=Math.floor(w*o[E][x]*n),S<g[E]&&(g[E]=S,g[E]<_&&(g[E]=_)),S>y[E]&&(y[E]=S,y[E]>w&&(y[E]=w));if(++h===t){for(var M=0;M<i;M++)e.bits===8?(d.setInt8(v++,g[M]),d.setInt8(v++,y[M])):(d.setInt16(v,g[M],!0),d.setInt16(v+2,y[M],!0),v+=4),g[M]=1/0,y[M]=-1/0;h=0}}if(h>0)for(var T=0;T<i;T++)e.bits===8?(d.setInt8(v++,g[T]),d.setInt8(v++,y[T])):(d.setInt16(v,g[T],!0),d.setInt16(v+2,y[T],!0));return m}function Os(e){"@babel/helpers - typeof";return Os=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Os(e)}function g0(e){return e&&Os(e)==="object"&&"sample_rate"in e&&"samples_per_pixel"in e&&"bits"in e&&"length"in e&&"data"in e}function v0(e){var t=e&&Os(e)==="object"&&"byteLength"in e;if(t){var n=new DataView(e),r=n.getInt32(0,!0);if(r!==1&&r!==2)throw new TypeError("WaveformData.create(): This waveform data version not supported")}return t}function y0(e){var t=e.data,n=e.channels||1,r=24,s=e.bits===8?1:2,a=e.length*2*n;if(t.length!==a)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=r+t.length*s,i=new ArrayBuffer(o),l=new DataView(i);l.setInt32(0,2,!0),l.setUint32(4,e.bits===8,!0),l.setInt32(8,e.sample_rate,!0),l.setInt32(12,e.samples_per_pixel,!0),l.setInt32(16,e.length,!0),l.setInt32(20,n,!0);var c=r;if(e.bits===8)for(var u=0;u<t.length;u++)l.setInt8(c++,t[u],!0);else for(var f=0;f<t.length;f++)l.setInt16(c,t[f],!0),c+=2;return i}function Sn(e){return e==null}function b0(e,t){var n=atob(e);return n}function w0(e,t,n){var r=b0(e),s=r.indexOf(`
|
|
857
|
+
`,10)+1,a=r.substring(s)+"",o=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(o)}function _0(e,t,n){var r;return function(a){return r=r||w0(e),new Worker(r,a)}}var x0=_0("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function mt(e){if(g0(e)&&(e=y0(e)),v0(e)){this._data=new DataView(e),this._offset=this._version()===2?24:20,this._channels=[];for(var t=0;t<this.channels;t++)this._channels[t]=new wn(this,t)}else throw new TypeError("WaveformData.create(): Unknown data format")}var Qn={scale:512,bits:8,amplitude_scale:1,split_channels:!1,disable_worker:!1};function C0(e){var t={scale:e.scale||Qn.scale,bits:e.bits||Qn.bits,amplitude_scale:e.amplitude_scale||Qn.amplitude_scale,split_channels:e.split_channels||Qn.split_channels,disable_worker:e.disable_worker||Qn.disable_worker};return t}function S0(e){for(var t=[],n=0;n<e.numberOfChannels;++n)t.push(e.getChannelData(n).buffer);return t}function Jd(e,t,n){var r=S0(e);if(t.disable_worker){var s=m0({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:r});n(void 0,new mt(s),e)}else{var a=new x0;a.onmessage=function(o){n(void 0,new mt(o.data),e)},a.postMessage({scale:t.scale,bits:t.bits,amplitude_scale:t.amplitude_scale,split_channels:t.split_channels,length:e.length,sample_rate:e.sampleRate,channels:r},r)}}function k0(e,t,n,r){function s(o){o||(o=new DOMException("EncodingError")),r(o),r=function(){}}var a=e.decodeAudioData(t,function(o){Jd(o,n,r)},s);a&&a.catch(s)}mt.create=function(t){return new mt(t)};mt.createFromAudio=function(e,t){var n=C0(e);if(e.audio_context&&e.array_buffer)return k0(e.audio_context,e.array_buffer,n,t);if(e.audio_buffer)return Jd(e.audio_buffer,n,t);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Qs(e){this._inputData=e.waveformData,this._output_samples_per_pixel=e.scale,this._scale=this._inputData.scale,this._input_buffer_size=this._inputData.length;var t=this._input_buffer_size*this._inputData.scale,n=Math.ceil(t/this._output_samples_per_pixel),r=24,s=this._inputData.bits===8?1:2,a=r+n*2*this._inputData.channels*s;this._output_data=new ArrayBuffer(a),this.output_dataview=new DataView(this._output_data),this.output_dataview.setInt32(0,2,!0),this.output_dataview.setUint32(4,this._inputData.bits===8,!0),this.output_dataview.setInt32(8,this._inputData.sample_rate,!0),this.output_dataview.setInt32(12,this._output_samples_per_pixel,!0),this.output_dataview.setInt32(16,n,!0),this.output_dataview.setInt32(20,this._inputData.channels,!0),this._outputWaveformData=new mt(this._output_data),this._input_index=0,this._output_index=0;var o=this._inputData.channels;this._min=new Array(o),this._max=new Array(o);for(var i=0;i<o;++i)this._input_buffer_size>0?(this._min[i]=this._inputData.channel(i).min_sample(this._input_index),this._max[i]=this._inputData.channel(i).max_sample(this._input_index)):(this._min[i]=0,this._max[i]=0);this._min_value=this._inputData.bits===8?-128:-32768,this._max_value=this._inputData.bits===8?127:32767,this._where=0,this._prev_where=0,this._stop=0,this._last_input_index=0}Qs.prototype.sample_at_pixel=function(e){return Math.floor(e*this._output_samples_per_pixel)};Qs.prototype.next=function(){for(var e=0,t=1e3,n=this._inputData.channels,r;this._input_index<this._input_buffer_size&&e<t;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(var s=0;s<n;++s)r=this._outputWaveformData.channel(s),r.set_min_sample(this._output_index-1,this._min[s]),r.set_max_sample(this._output_index-1,this._max[s]);if(this._last_input_index=this._input_index,this._output_index++,this._where=this.sample_at_pixel(this._output_index),this._prev_where=this.sample_at_pixel(this._output_index-1),this._where!==this._prev_where)for(var a=0;a<n;++a)this._min[a]=this._max_value,this._max[a]=this._min_value}for(this._where=this.sample_at_pixel(this._output_index),this._stop=Math.floor(this._where/this._scale),this._stop>this._input_buffer_size&&(this._stop=this._input_buffer_size);this._input_index<this._stop;){for(var o=0;o<n;++o){r=this._inputData.channel(o);var i=r.min_sample(this._input_index);i<this._min[o]&&(this._min[o]=i),i=r.max_sample(this._input_index),i>this._max[o]&&(this._max[o]=i)}this._input_index++}e++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var l=0;l<n;++l)r=this._outputWaveformData.channel(l),r.set_min_sample(this._output_index-1,this._min[l]),r.set_max_sample(this._output_index-1,this._max[l]);return!0};Qs.prototype.getOutputData=function(){return this._output_data};mt.prototype={_getResampleOptions:function(t){var n={};if(n.scale=t.scale,n.width=t.width,!Sn(n.width)&&(typeof n.width!="number"||n.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Sn(n.scale)&&(typeof n.scale!="number"||n.scale<=0))throw new RangeError("WaveformData.resample(): scale should be a positive integer value");if(!n.scale&&!n.width)throw new Error("WaveformData.resample(): Missing scale or width option");if(n.width&&(n.scale=Math.floor(this.duration*this.sample_rate/n.width)),n.scale<this.scale)throw new Error("WaveformData.resample(): Zoom level "+n.scale+" too low, minimum: "+this.scale);return n.abortSignal=t.abortSignal,n},resample:function(t){t=this._getResampleOptions(t),t.waveformData=this;for(var n=new Qs(t);!n.next(););return new mt(n.getOutputData())},concat:function(){var t=this,n=Array.prototype.slice.call(arguments);n.forEach(function(s){if(t.channels!==s.channels||t.sample_rate!==s.sample_rate||t.bits!==s.bits||t.scale!==s.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")});var r=this._concatBuffers.apply(this,n);return mt.create(r)},_concatBuffers:function(){for(var t=Array.prototype.slice.call(arguments),n=this._offset,r=n,s=0,a=[this].concat(t).map(function(y){return y._data.buffer}),o=0;o<a.length;o++){var i=a[o],l=new DataView(i).getInt32(16,!0);r+=i.byteLength-n,s+=l}for(var c=new ArrayBuffer(r),u=new DataView(a[0]),f=new DataView(c),m=0;m<n;m++)f.setUint8(m,u.getUint8(m));f.setInt32(16,s,!0);for(var d=0,h=new Uint8Array(c,n),v=0;v<a.length;v++){var g=a[v];h.set(new Uint8Array(g,n),d),d+=g.byteLength-n}return c},slice:function(t){var n=0,r=0;if(!Sn(t.startIndex)&&!Sn(t.endIndex)?(n=t.startIndex,r=t.endIndex):!Sn(t.startTime)&&!Sn(t.endTime)&&(n=this.at_time(t.startTime),r=this.at_time(t.endTime)),n<0)throw new RangeError("startIndex or startTime must not be negative");if(r<0)throw new RangeError("endIndex or endTime must not be negative");n>this.length&&(n=this.length),r>this.length&&(r=this.length),n>r&&(n=r);var s=r-n,a=24,o=this.bits===8?1:2,i=a+s*2*this.channels*o,l=new ArrayBuffer(i),c=new DataView(l);c.setInt32(0,2,!0),c.setUint32(4,this.bits===8,!0),c.setInt32(8,this.sample_rate,!0),c.setInt32(12,this.scale,!0),c.setInt32(16,s,!0),c.setInt32(20,this.channels,!0);for(var u=0;u<s*this.channels*2;u++){var f=this._at(n*this.channels*2+u);this.bits===8?c.setInt8(a+u,f):c.setInt16(a+u*2,f,!0)}return new mt(l)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){var e=!!this._data.getUint32(4,!0);return e?8:16},get duration(){return this.length*this.scale/this.sample_rate},get pixels_per_second(){return this.sample_rate/this.scale},get seconds_per_pixel(){return this.scale/this.sample_rate},get channels(){return this._version()===2?this._data.getInt32(20,!0):1},channel:function(t){if(t>=0&&t<this._channels.length)return this._channels[t];throw new RangeError("Invalid channel: "+t)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(t){return this.bits===8?this._data.getInt8(this._offset+t):this._data.getInt16(this._offset+t*2,!0)},_set_at:function(t,n){return this.bits===8?this._data.setInt8(this._offset+t,n):this._data.setInt16(this._offset+t*2,n,!0)},at_time:function(t){return Math.floor(t*this.sample_rate/this.scale)},time:function(t){return t*this.scale/this.sample_rate},toJSON:function(){for(var t={version:2,channels:this.channels,sample_rate:this.sample_rate,samples_per_pixel:this.scale,bits:this.bits,length:this.length,data:[]},n=0;n<this.length;n++)for(var r=0;r<this.channels;r++)t.data.push(this.channel(r).min_sample(n)),t.data.push(this.channel(r).max_sample(n));return t},toArrayBuffer:function(){return this._data.buffer}};async function ki(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch waveform data: ${t.statusText}`);if(e.endsWith(".dat")){const r=await t.arrayBuffer();return mt.create(r)}else{const r=await t.json();return mt.create(r)}}function Qd(e,t=0){const n=e.channel(t),r=e.bits,s=n.min_array(),a=n.max_array(),o=s.length,i=r===8?new Int8Array(o*2):new Int16Array(o*2);for(let l=0;l<o;l++)i[l*2]=s[l],i[l*2+1]=a[l];return{data:i,bits:r,length:o,sampleRate:e.sample_rate}}async function E0(e,t=0){const n=await ki(e);return Qd(n,t)}async function I0(e){const t=await ki(e);return{sampleRate:t.sample_rate,channels:t.channels,duration:t.duration,samplesPerPixel:t.scale,length:t.length,bits:t.bits}}function ef(e,t,n,r){let s=e;if(n!==void 0&&r!==void 0)if(s.scale!==t){const a=e.scale,o=t/a,i=Math.floor(n/t),l=Math.ceil((n+r)/t),c=Math.floor(i*o),u=Math.min(e.length,Math.ceil(l*o));if(c>=u)return null;s=s.slice({startIndex:c,endIndex:u}),s=s.resample({scale:t})}else{const a=Math.floor(n/t),o=Math.ceil((n+r)/t);s=s.slice({startIndex:a,endIndex:o})}else s.scale!==t&&(s=s.resample({scale:t}));return s}function M0(e,t,n=0,r,s){const a=ef(e,t,r,s);if(a===null){const m=e.bits;return{data:m===8?new Int8Array(0):new Int16Array(0),bits:m,length:0}}const o=a.channel(n),i=a.bits,l=o.min_array(),c=o.max_array(),u=l.length,f=i===8?new Int8Array(u*2):new Int16Array(u*2);for(let m=0;m<u;m++)f[m*2]=l[m],f[m*2+1]=c[m];return{data:f,bits:i,length:u}}function Ql(e,t,n,r,s){const a=ef(e,t,r,s);if(a===null){const u=e.bits;return{length:0,data:[],bits:u}}const o=a.channels,i=a.bits,l=[];for(let u=0;u<o;u++){const f=a.channel(u),m=f.min_array(),d=f.max_array(),h=m.length,v=i===8?new Int8Array(h*2):new Int16Array(h*2);for(let g=0;g<h;g++)v[g*2]=m[g],v[g*2+1]=d[g];l.push(v)}if(n&&l.length>1){const u=1/l.length,f=l[0].length/2,m=i===8?new Int8Array(f*2):new Int16Array(f*2);for(let d=0;d<f;d++){let h=0,v=0;for(let g=0;g<l.length;g++)h+=u*l[g][d*2],v+=u*l[g][d*2+1];m[d*2]=h,m[d*2+1]=v}return{length:f,data:[m],bits:i}}return{length:l.length>0?l[0].length/2:0,data:l,bits:i}}function tf(){const[e,t]=p.useState("hh:mm:ss.uuu");return{timeFormat:e,setTimeFormat:t,formatTime:s=>Pn(s,e),parseTime:s=>Hd(s,e)}}function nf({engineRef:e,initialSamplesPerPixel:t}){const[n,r]=p.useState(t),[s,a]=p.useState(!0),[o,i]=p.useState(!0),l=p.useRef(!0),c=p.useRef(!0),u=p.useRef(t),f=p.useCallback(()=>{e.current?.zoomIn()},[e]),m=p.useCallback(()=>{e.current?.zoomOut()},[e]),d=p.useCallback(h=>{h.samplesPerPixel!==u.current&&(u.current=h.samplesPerPixel,p.startTransition(()=>{r(h.samplesPerPixel)})),h.canZoomIn!==l.current&&(l.current=h.canZoomIn,a(h.canZoomIn)),h.canZoomOut!==c.current&&(c.current=h.canZoomOut,i(h.canZoomOut))},[]);return{samplesPerPixel:n,zoomIn:f,zoomOut:m,canZoomIn:s,canZoomOut:o,onEngineState:d}}function rf({engineRef:e,initialVolume:t=1}){const[n,r]=p.useState(t),s=p.useRef(t),a=p.useCallback(i=>{e.current?e.current.setMasterVolume(i):(s.current=i,r(i))},[e]),o=p.useCallback(i=>{i.masterVolume!==s.current&&(s.current=i.masterVolume,r(i.masterVolume))},[]);return{masterVolume:n,setMasterVolume:a,masterVolumeRef:s,onEngineState:o}}function A0({engineRef:e}){const[t,n]=p.useState(0),[r,s]=p.useState(0),a=p.useRef(0),o=p.useRef(0),i=p.useCallback((c,u)=>{e.current?.setSelection(c,u)},[e]),l=p.useCallback(c=>{c.selectionStart!==a.current&&(a.current=c.selectionStart,n(c.selectionStart)),c.selectionEnd!==o.current&&(o.current=c.selectionEnd,s(c.selectionEnd))},[]);return{selectionStart:t,selectionEnd:r,setSelection:i,selectionStartRef:a,selectionEndRef:o,onEngineState:l}}function T0({engineRef:e}){const[t,n]=p.useState(!1),[r,s]=p.useState(0),[a,o]=p.useState(0),i=p.useRef(!1),l=p.useRef(0),c=p.useRef(0),u=p.useCallback(h=>{e.current?.setLoopEnabled(h)},[e]),f=p.useCallback((h,v)=>{e.current?.setLoopRegion(h,v)},[e]),m=p.useCallback(()=>{e.current?.setLoopRegion(0,0)},[e]),d=p.useCallback(h=>{h.isLoopEnabled!==i.current&&(i.current=h.isLoopEnabled,n(h.isLoopEnabled)),h.loopStart!==l.current&&(l.current=h.loopStart,s(h.loopStart)),h.loopEnd!==c.current&&(c.current=h.loopEnd,o(h.loopEnd))},[]);return{isLoopEnabled:t,loopStart:r,loopEnd:a,setLoopEnabled:u,setLoopRegion:f,clearLoopRegion:m,isLoopEnabledRef:i,loopStartRef:l,loopEndRef:c,onEngineState:d}}function $0({engineRef:e}){const[t,n]=p.useState(null),r=p.useRef(null),s=p.useCallback(o=>{e.current?.selectTrack(o)},[e]),a=p.useCallback(o=>{o.selectedTrackId!==r.current&&(r.current=o.selectedTrackId,n(o.selectedTrackId))},[]);return{selectedTrackId:t,setSelectedTrackId:s,onEngineState:a,selectedTrackIdRef:r}}const R0=(e=256)=>{const t=p.useRef(null),n=p.useCallback((r,s,a)=>{const o=new L.Analyser("fft",e);return r.connect(o),r.connect(s),t.current=o,function(){o.dispose(),t.current=null}},[e]);return{analyserRef:t,masterEffects:n}};function as(e,t,n,r,s=48e3){const a=n??e.audioBuffer,o=a?.sampleRate??e.waveformData?.sample_rate??s,i=a?.duration??e.waveformData?.duration??(e.duration!=null?e.duration+(e.offset??0):void 0);if(i===void 0)return console.warn(`[waveform-playlist] Track ${t+1} ("${e.name??"unnamed"}"): Cannot create track — provide duration, audioBuffer, or waveformData with duration.`),null;const l=uc({audioBuffer:a,sampleRate:o,sourceDuration:i,startTime:e.startTime??0,duration:e.duration??i,offset:e.offset??0,name:e.name||`Track ${t+1}`,fadeIn:e.fadeIn,fadeOut:e.fadeOut,waveformData:e.waveformData});if(isNaN(l.startSample)||isNaN(l.durationSamples)||isNaN(l.offsetSamples))return console.error(`[waveform-playlist] Invalid clip values for track ${t+1} ("${e.name??"unnamed"}"): startSample=${l.startSample}, durationSamples=${l.durationSamples}, offsetSamples=${l.offsetSamples}`),null;const c={...dc({name:e.name||`Track ${t+1}`,clips:[l],muted:e.muted??!1,soloed:e.soloed??!1,volume:e.volume??1,pan:e.pan??0,color:e.color}),effects:e.effects,renderMode:e.renderMode,spectrogramConfig:e.spectrogramConfig,spectrogramColorMap:e.spectrogramColorMap},u=r.get(t);return u?(c.id=u.trackId,c.clips[0]={...c.clips[0],id:u.clipId}):r.set(t,{trackId:c.id,clipId:c.clips[0].id}),c}function D0(e,t={}){const{immediate:n=!1,progressive:r=!1}=t,s=n||r,[a,o]=p.useState(!0),[i,l]=p.useState(null),[c,u]=p.useState(0),f=e.length,[m,d]=p.useState(new Map),h=p.useRef(new Map),v=p.useRef(48e3),g=p.useMemo(()=>{if(!s)return null;const w=[];for(let x=0;x<e.length;x++){const S=as(e[x],x,m.get(x),h.current,v.current);S&&w.push(S)}return w},[s,e,m]),[y,b]=p.useState(g??[]),_=p.useRef(g);return g!==_.current&&(_.current=g,g&&b(g)),p.useEffect(()=>{if(e.length===0){b([]),o(!1),u(0);return}let w=!1;const x=new AbortController;return(async()=>{try{o(!0),l(null),u(0),s&&d(new Map);const k=cc.getContext().rawContext;v.current=k.sampleRate;const E=e.map(async(T,$)=>{if(T.audioBuffer){if(s&&!w){d(D=>{const O=new Map(D);return O.set($,T.audioBuffer),O}),u(D=>D+1);return}return as(T,$,T.audioBuffer,h.current,k.sampleRate)}if(!T.src&&T.waveformData){if(s&&!w){u(D=>D+1);return}return as(T,$,void 0,h.current,k.sampleRate)}if(!T.src)throw new Error(`Track ${$+1}: Must provide src, audioBuffer, or waveformData`);const A=await fetch(T.src,{signal:x.signal});if(!A.ok)throw new Error(`Failed to fetch ${T.src}: ${A.statusText}`);const I=await A.arrayBuffer(),R=await k.decodeAudioData(I);if(!R||!R.sampleRate||!R.duration)throw new Error(`Invalid audio buffer for ${T.src}`);if(s&&!w){d(D=>{const O=new Map(D);return O.set($,R),O}),u(D=>D+1);return}return as(T,$,R,h.current,k.sampleRate)}),M=await Promise.all(E);if(!w){if(!s){const T=M.filter($=>$!=null);b(T),u(T.length)}o(!1)}}catch(k){if(!w){const E=k instanceof Error?k.message:"Unknown error loading audio";l(E),o(!1),console.error(`[waveform-playlist] Error loading audio tracks: ${E}`)}}})(),()=>{w=!0,x.abort()}},[e,s]),{tracks:y,loading:a,error:i,loadedCount:c,totalCount:f}}function P0({originalClip:e,clip:t,pixelDelta:n,samplesPerPixel:r,sampleRate:s,boundary:a,sortedClips:o,sortedIndex:i}){const l=n*r,c=Math.floor(.1*s),u={...t,startSample:e.startSample,offsetSamples:e.offsetSamples,durationSamples:e.durationSamples},f=vc(u,Math.floor(l),a,o,i,c);return a==="left"?{startSample:e.startSample+f,durationSamples:e.durationSamples-f,offsetSamples:e.offsetSamples+f}:{startSample:e.startSample,durationSamples:e.durationSamples+f,offsetSamples:e.offsetSamples}}function sf({tracks:e,onTracksChange:t,samplesPerPixel:n,sampleRate:r,engineRef:s,isDraggingRef:a,snapSamplePosition:o}){const i=p.useRef(o);i.current=o;const l=p.useRef(null),c=p.useRef(0),u=p.useCallback(d=>{const h=d.operation.source?.data;if(!h)return;if(!h.boundary){l.current=null;return}const g=e[h.trackIndex]?.clips[h.clipIndex];g&&(l.current={offsetSamples:g.offsetSamples,durationSamples:g.durationSamples,startSample:g.startSample},a.current=!0)},[e,a]),f=p.useCallback(d=>{const h=d.operation.source?.data;if(!h||!h.boundary||!l.current)return;const{boundary:v,trackIndex:g,clipIndex:y}=h,_=(d.to?.x??d.operation.position.current.x)-d.operation.position.initial.x,w=_*n,x=l.current,S=i.current;let k=w;const E=e.map((M,T)=>{if(T!==g)return M;const $=[...M.clips].sort((R,D)=>R.startSample-D.startSample),A=$.findIndex(R=>R===M.clips[y]),I=M.clips.map((R,D)=>{if(D!==y)return R;let O=P0({originalClip:x,clip:R,pixelDelta:_,samplesPerPixel:n,sampleRate:r,boundary:v,sortedClips:$,sortedIndex:A});if(S)if(v==="left"){const Z=S(O.startSample),G=Z-O.startSample;O={startSample:Z,durationSamples:O.durationSamples-G,offsetSamples:O.offsetSamples+G},k=Z-x.startSample}else{const Z=O.startSample+O.durationSamples,G=S(Z);O={...O,durationSamples:G-O.startSample},k=O.durationSamples-x.durationSamples}return{...R,startSample:O.startSample,durationSamples:O.durationSamples,offsetSamples:O.offsetSamples}});return{...M,clips:I}});c.current=k,t(E)},[e,t,n,r]),m=p.useCallback(d=>{if(d.canceled){if(l.current){const w=d.operation.source?.data;if(w){const{trackIndex:x,clipIndex:S}=w,k=l.current,E=e.map((M,T)=>{if(T!==x)return M;const $=M.clips.map((A,I)=>I!==S?A:{...A,offsetSamples:k.offsetSamples,durationSamples:k.durationSamples,startSample:k.startSample});return{...M,clips:$}});t(E)}}a.current=!1,l.current=null,c.current=0;return}const h=d.operation.source?.data;if(!h)return;const{trackIndex:v,clipId:g,boundary:y}=h,b=y?c.current:d.operation.transform.x*n,_=e[v]?.id;if(y){a.current=!1,_?s.current?s.current.trimClip(_,g,y,Math.floor(b)):console.warn("[waveform-playlist] engineRef is null — trim not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${v} not found — trim not synced to adapter`),l.current=null,c.current=0;return}_?s.current?s.current.moveClip(_,g,Math.floor(b)):console.warn("[waveform-playlist] engineRef is null — move not synced to adapter"):console.warn(`[waveform-playlist] onDragEnd: track at index ${v} not found — move not synced to adapter`)},[e,t,n,s,a]);return{onDragStart:u,onDragMove:f,onDragEnd:m}}const xa=.01;function af({annotations:e,onAnnotationsChange:t,samplesPerPixel:n,sampleRate:r,duration:s,linkEndpoints:a}){const o=p.useRef(null),i=p.useCallback(u=>{const f=u.operation.source?.data;if(!f||f.annotationIndex===void 0){o.current=null;return}const m=e[f.annotationIndex];m&&(o.current={start:m.start,end:m.end,annotationIndex:f.annotationIndex})},[e]),l=p.useCallback(u=>{if(!o.current)return;const f=u.operation.source?.data;if(!f)return;const{edge:m,annotationIndex:d}=f,h=o.current,y=((u.to?.x??u.operation.position.current.x)-u.operation.position.initial.x)*n/r,b=m==="start"?h.start+y:h.end+y,_=F0({annotationIndex:d,newTime:b,isDraggingStart:m==="start",annotations:e,duration:s,linkEndpoints:a});t(_)},[e,t,n,r,s,a]),c=p.useCallback(u=>{if(u.canceled&&o.current){const{annotationIndex:f,start:m,end:d}=o.current,h=e.map((v,g)=>g!==f?v:{...v,start:m,end:d});t(h)}o.current=null},[e,t]);return{onDragStart:i,onDragMove:l,onDragEnd:c}}function F0({annotationIndex:e,newTime:t,isDraggingStart:n,annotations:r,duration:s,linkEndpoints:a}){const o=[...r],i=r[e];if(n){const l=Math.min(i.end-.1,Math.max(0,t)),c=l-i.start;if(o[e]={...i,start:l},a&&e>0){const u=o[e-1];Math.abs(u.end-i.start)<xa?o[e-1]={...u,end:Math.max(u.start+.1,u.end+c)}:l<=u.end&&(o[e]={...o[e],start:u.end})}else!a&&e>0&&l<o[e-1].end&&(o[e-1]={...o[e-1],end:l})}else{const l=Math.max(i.start+.1,Math.min(t,s)),c=l-i.end;if(o[e]={...i,end:l},a&&e<o.length-1){const u=o[e+1];if(Math.abs(u.start-i.end)<xa){const f=u.start+c;o[e+1]={...u,start:Math.min(u.end-.1,f)};let m=e+1;for(;m<o.length-1;){const d=o[m],h=o[m+1];if(Math.abs(h.start-d.end)<xa){const v=d.end-r[m].end;o[m+1]={...h,start:Math.min(h.end-.1,h.start+v)},m++}else break}}else l>=u.start&&(o[e]={...o[e],end:u.start})}else if(!a&&e<o.length-1&&l>o[e+1].start){const u=o[e+1];o[e+1]={...u,start:l};let f=e+1;for(;f<o.length-1;){const m=o[f],d=o[f+1];if(m.end>d.start)o[f+1]={...d,start:m.end},f++;else break}}}return o}function of(e={}){const{touchOptimized:t=!1,touchDelay:n=250,touchTolerance:r=5,mouseDistance:s=1}=e;return p.useMemo(()=>t?[oo.configure({activationConstraints(a){return a.pointerType==="touch"?[new Ot.Delay({value:n,tolerance:r})]:[new Ot.Distance({value:s})]}})]:[oo.configure({activationConstraints:[new Ot.Distance({value:s})]})],[t,n,r,s])}const lf=e=>{const{tracks:t,sampleRate:n,engineRef:r}=e,{currentTimeRef:s}=ot(),{selectedTrackId:a}=it(),o=p.useCallback((l,c,u)=>{const{samplesPerPixel:f}=e,m=t[l];if(!m)return!1;const d=m.clips[c];if(!d)return!1;const h=Math.round(u*n),v=yh(h,f),g=Math.floor(.1*n);if(!yc(d,v,g))return console.warn("Split point is invalid (outside bounds or too close to edge)"),!1;const y=r.current;return y?(y.splitClip(m.id,d.id,v),!0):(console.warn("[waveform-playlist] engineRef is null — split not synced to adapter"),!1)},[t,e,n,r]);return{splitClipAtPlayhead:p.useCallback(()=>{if(!a)return console.warn("[waveform-playlist] No track selected — click a clip to select a track first"),!1;const l=t.findIndex(f=>f.id===a);if(l===-1)return console.warn("Selected track not found"),!1;const c=t[l],u=s.current??0;for(let f=0;f<c.clips.length;f++){const m=c.clips[f],d=m.startSample/n,h=(m.startSample+m.durationSamples)/n;if(u>d&&u<h)return o(l,f,u)}return console.warn(`[waveform-playlist] No clip found at playhead position on track "${c.name}"`),!1},[t,s,a,o,n]),splitClipAt:o}},Ls=e=>{const{shortcuts:t,enabled:n=!0}=e,r=p.useCallback(s=>{if(!n)return;const a=s.target;if(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable)return;const o=t.find(i=>{const l=s.key.toLowerCase()===i.key.toLowerCase()||s.key===i.key,c=i.ctrlKey===void 0||s.ctrlKey===i.ctrlKey,u=i.shiftKey===void 0||s.shiftKey===i.shiftKey,f=i.metaKey===void 0||s.metaKey===i.metaKey,m=i.altKey===void 0||s.altKey===i.altKey;return l&&c&&u&&f&&m});o&&(o.preventDefault!==!1&&s.preventDefault(),o.action())},[t,n]);p.useEffect(()=>{if(n)return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[r,n])},O0=e=>{const t=[],n=typeof navigator<"u"&&navigator.platform.includes("Mac");return e.metaKey&&t.push(n?"Cmd":"Ctrl"),e.ctrlKey&&!e.metaKey&&t.push("Ctrl"),e.altKey&&t.push(n?"Option":"Alt"),e.shiftKey&&t.push("Shift"),t.push(e.key.toUpperCase()),t.join("+")},cf=(e={})=>{const{enabled:t=!0,additionalShortcuts:n=[],shortcuts:r}=e,{isPlaying:s}=ot(),{setCurrentTime:a,play:o,pause:i,stop:l}=Ie(),c=p.useCallback(()=>{s?i():o()},[s,o,i]),u=p.useCallback(()=>{l()},[l]),f=p.useCallback(()=>{a(0),s&&o(0)},[s,a,o]),d=r??[...[{key:" ",action:c,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:u,description:"Stop",preventDefault:!0},{key:"0",action:f,description:"Rewind to start",preventDefault:!0}],...n];return Ls({shortcuts:d,enabled:t}),{rewindToStart:f,togglePlayPause:c,stopPlayback:u,shortcuts:d}},Ca=.01,os=.01;function uf({annotations:e,activeAnnotationId:t,onAnnotationsChange:n,onActiveAnnotationChange:r,duration:s,linkEndpoints:a,continuousPlay:o=!1,enabled:i=!0,scrollContainerRef:l,samplesPerPixel:c,sampleRate:u,onPlay:f}){const m=p.useMemo(()=>t?e.findIndex(E=>E.id===t):-1,[e,t]),d=p.useCallback(E=>{if(!l?.current||!c||!u)return;const M=e.find(G=>G.id===E);if(!M)return;const T=l.current,$=T.clientWidth,A=M.start*u/c,I=M.end*u/c,R=(A+I)/2,D=T.scrollLeft,O=D,Z=D+$;if(A<O||I>Z){const G=Math.max(0,R-$/2);T.scrollTo({left:G,behavior:"smooth"})}},[e,l,c,u]);p.useEffect(()=>{t&&l?.current&&c&&u&&d(t)},[t,d,l,c,u]);const h=p.useCallback(E=>{if(m<0)return;const M=e[m],T=Math.max(0,Math.min(M.end-.1,M.start+E)),$=T-M.start,A=[...e];if(A[m]={...M,start:T},a&&m>0){const I=A[m-1];Math.abs(I.end-M.start)<Ca&&(A[m-1]={...I,end:Math.max(I.start+.1,I.end+$)})}else if(!a&&m>0){const I=A[m-1];T<I.end&&(A[m-1]={...I,end:T})}n(A)},[e,m,a,n]),v=p.useCallback(E=>{if(m<0)return;const M=e[m],T=Math.max(M.start+.1,Math.min(s,M.end+E)),$=T-M.end,A=[...e];if(A[m]={...M,end:T},a&&m<e.length-1){const I=A[m+1];if(Math.abs(I.start-M.end)<Ca){const R=Math.min(I.end-.1,I.start+$);A[m+1]={...I,start:R};let D=m+1;for(;D<A.length-1;){const O=A[D],Z=A[D+1];if(Math.abs(Z.start-e[D].end)<Ca){const G=O.end-e[D].end;A[D+1]={...Z,start:Math.min(Z.end-.1,Z.start+G)},D++}else break}}}else if(!a&&m<e.length-1){const I=A[m+1];if(T>I.start){A[m+1]={...I,start:T};let R=m+1;for(;R<A.length-1;){const D=A[R],O=A[R+1];if(D.end>O.start)A[R+1]={...O,start:D.end},R++;else break}}}n(A)},[e,m,s,a,n]),g=p.useCallback(()=>{!r||e.length===0||(m<=0?r(e[e.length-1].id):r(e[m-1].id))},[e,m,r]),y=p.useCallback(()=>{!r||e.length===0||(m<0||m>=e.length-1?r(e[0].id):r(e[m+1].id))},[e,m,r]),b=p.useCallback(()=>{!r||e.length===0||r(e[0].id)},[e,r]),_=p.useCallback(()=>{!r||e.length===0||r(e[e.length-1].id)},[e,r]),w=p.useCallback(()=>{r&&r(null)},[r]),x=p.useCallback(()=>{if(m<0||!f)return;const E=e[m],M=o?void 0:E.end-E.start;f(E.start,M)},[e,m,o,f]),S=p.useMemo(()=>[{key:"[",action:()=>h(-os),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>h(os),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>v(-os),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>v(os),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:x,description:"Play selected annotation",preventDefault:!0}],[h,v,x]),k=p.useMemo(()=>[{key:"ArrowUp",action:g,description:"Select previous annotation",preventDefault:!0},{key:"ArrowLeft",action:g,description:"Select previous annotation",preventDefault:!0},{key:"ArrowDown",action:y,description:"Select next annotation",preventDefault:!0},{key:"ArrowRight",action:y,description:"Select next annotation",preventDefault:!0},{key:"Home",action:b,description:"Select first annotation",preventDefault:!0},{key:"End",action:_,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:w,description:"Deselect annotation",preventDefault:!0}],[g,y,b,_,w]);return Ls({shortcuts:S,enabled:i&&m>=0}),Ls({shortcuts:k,enabled:i&&e.length>0&&!!r}),{moveStartBoundary:h,moveEndBoundary:v,selectPrevious:g,selectNext:y,selectFirst:b,selectLast:_,clearSelection:w,scrollToAnnotation:d,playActiveAnnotation:x}}const Nr=[{id:"reverb",name:"Reverb",category:"reverb",description:"Simple convolution reverb with adjustable decay time",parameters:[{name:"decay",label:"Decay",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"s"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"freeverb",name:"Freeverb",category:"reverb",description:"Classic Schroeder/Moorer reverb with room size and dampening",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.7},{name:"dampening",label:"Dampening",type:"number",min:0,max:1e4,step:100,default:3e3,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"jcReverb",name:"JC Reverb",category:"reverb",description:"Attempt at Roland JC-120 chorus reverb emulation",parameters:[{name:"roomSize",label:"Room Size",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"feedbackDelay",name:"Feedback Delay",category:"delay",description:"Delay line with feedback for echo effects",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"pingPongDelay",name:"Ping Pong Delay",category:"delay",description:"Stereo delay bouncing between left and right channels",parameters:[{name:"delayTime",label:"Delay Time",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"feedback",label:"Feedback",type:"number",min:0,max:.95,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"chorus",name:"Chorus",category:"modulation",description:"Creates thickness by layering detuned copies of the signal",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1.5,unit:"Hz"},{name:"delayTime",label:"Delay",type:"number",min:0,max:20,step:.5,default:3.5,unit:"ms"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.7},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"phaser",name:"Phaser",category:"modulation",description:"Classic phaser effect using allpass filters",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:.5,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:6,step:1,default:3},{name:"baseFrequency",label:"Base Freq",type:"number",min:100,max:2e3,step:10,default:350,unit:"Hz"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:.5}]},{id:"tremolo",name:"Tremolo",category:"modulation",description:"Rhythmic volume modulation",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:4,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.5},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"vibrato",name:"Vibrato",category:"modulation",description:"Pitch modulation effect",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:20,step:.1,default:5,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:.1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoPanner",name:"Auto Panner",category:"modulation",description:"Automatic left-right panning",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoFilter",name:"Auto Filter",category:"filter",description:"Automated filter sweep with LFO",parameters:[{name:"frequency",label:"Rate",type:"number",min:.1,max:10,step:.1,default:1,unit:"Hz"},{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:2e3,step:10,default:200,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:.5,max:8,step:.5,default:2.6},{name:"depth",label:"Depth",type:"number",min:0,max:1,step:.01,default:1},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"autoWah",name:"Auto Wah",category:"filter",description:"Envelope follower filter effect",parameters:[{name:"baseFrequency",label:"Base Freq",type:"number",min:20,max:500,step:10,default:100,unit:"Hz"},{name:"octaves",label:"Octaves",type:"number",min:1,max:8,step:1,default:6},{name:"sensitivity",label:"Sensitivity",type:"number",min:-40,max:0,step:1,default:0,unit:"dB"},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"eq3",name:"3-Band EQ",category:"filter",description:"Three band equalizer with low, mid, and high controls",parameters:[{name:"low",label:"Low",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"mid",label:"Mid",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"high",label:"High",type:"number",min:-24,max:24,step:.5,default:0,unit:"dB"},{name:"lowFrequency",label:"Low Freq",type:"number",min:20,max:500,step:10,default:400,unit:"Hz"},{name:"highFrequency",label:"High Freq",type:"number",min:1e3,max:1e4,step:100,default:2500,unit:"Hz"}]},{id:"distortion",name:"Distortion",category:"distortion",description:"Wave shaping distortion effect",parameters:[{name:"distortion",label:"Drive",type:"number",min:0,max:1,step:.01,default:.4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"bitCrusher",name:"Bit Crusher",category:"distortion",description:"Reduces bit depth for lo-fi digital texture",parameters:[{name:"bits",label:"Bits",type:"number",min:1,max:16,step:1,default:4},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"chebyshev",name:"Chebyshev",category:"distortion",description:"Waveshaping distortion using Chebyshev polynomials",parameters:[{name:"order",label:"Order",type:"number",min:1,max:100,step:1,default:50},{name:"wet",label:"Mix",type:"number",min:0,max:1,step:.01,default:1}]},{id:"compressor",name:"Compressor",category:"dynamics",description:"Dynamic range compressor",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-60,max:0,step:1,default:-24,unit:"dB"},{name:"ratio",label:"Ratio",type:"number",min:1,max:20,step:.5,default:4},{name:"attack",label:"Attack",type:"number",min:0,max:1,step:.001,default:.003,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:1,step:.01,default:.25,unit:"s"},{name:"knee",label:"Knee",type:"number",min:0,max:40,step:1,default:30,unit:"dB"}]},{id:"limiter",name:"Limiter",category:"dynamics",description:"Hard limiter to prevent clipping",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-12,max:0,step:.5,default:-6,unit:"dB"}]},{id:"gate",name:"Gate",category:"dynamics",description:"Noise gate to silence signal below threshold",parameters:[{name:"threshold",label:"Threshold",type:"number",min:-100,max:0,step:1,default:-40,unit:"dB"},{name:"attack",label:"Attack",type:"number",min:0,max:.3,step:.001,default:.001,unit:"s"},{name:"release",label:"Release",type:"number",min:0,max:.5,step:.01,default:.1,unit:"s"}]},{id:"stereoWidener",name:"Stereo Widener",category:"spatial",description:"Expands or narrows the stereo image",parameters:[{name:"width",label:"Width",type:"number",min:0,max:1,step:.01,default:.5}]}],Ei=e=>Nr.find(t=>t.id===e),L0=e=>Nr.filter(t=>t.category===e),B0=[{id:"reverb",name:"Reverb"},{id:"delay",name:"Delay"},{id:"modulation",name:"Modulation"},{id:"filter",name:"Filter"},{id:"distortion",name:"Distortion"},{id:"dynamics",name:"Dynamics"},{id:"spatial",name:"Spatial"}];const W0={reverb:L.Reverb,freeverb:L.Freeverb,jcReverb:L.JCReverb,feedbackDelay:L.FeedbackDelay,pingPongDelay:L.PingPongDelay,chorus:L.Chorus,phaser:L.Phaser,tremolo:L.Tremolo,vibrato:L.Vibrato,autoPanner:L.AutoPanner,autoFilter:L.AutoFilter,autoWah:L.AutoWah,eq3:L.EQ3,distortion:L.Distortion,bitCrusher:L.BitCrusher,chebyshev:L.Chebyshev,compressor:L.Compressor,limiter:L.Limiter,gate:L.Gate,stereoWidener:L.StereoWidener};let V0=0;const N0=()=>`effect_${Date.now()}_${++V0}`;function Ir(e,t){const n=W0[e.id];if(!n)throw new Error(`Unknown effect type: ${e.id}`);const r={};e.parameters.forEach(i=>{const l=t?.[i.name]??i.default;r[i.name]=l});const s=new n(r),a=N0(),o=s;return{effect:s,id:e.id,instanceId:a,dispose(){try{s.disconnect(),s.dispose()}catch(i){console.warn(`[waveform-playlist] Error disposing effect "${e.id}" (${a}):`,i)}},setParameter(i,l){const c=o[i];if(i==="wet"){const u=o.wet;if(u&&typeof u=="object"&&"value"in u){u.value=l;return}}c!==void 0&&(c&&typeof c=="object"&&"value"in c?c.value=l:o[i]=l)},getParameter(i){if(i==="wet"){const c=o.wet;if(c&&typeof c=="object"&&"value"in c)return c.value}const l=o[i];if(l!==void 0)return l&&typeof l=="object"&&"value"in l?l.value:l},connect(i){s.connect(i)},disconnect(){try{s.disconnect()}catch(i){console.warn(`[waveform-playlist] Error disconnecting effect "${e.id}" (${a}):`,i)}}}}function z0(e){if(e.length===0)throw new Error("Cannot create effect chain with no effects");for(let t=0;t<e.length-1;t++)e[t].effect.connect(e[t+1].effect);return{input:e[0].effect,output:e[e.length-1].effect,dispose(){e.forEach(t=>t.dispose())}}}function j0(e=256){const[t,n]=p.useState([]),r=p.useRef(t);r.current=t;const s=p.useRef(new Map),a=p.useRef(null),o=p.useRef(null),i=p.useCallback(g=>{const y=o.current;if(!y)return;const{masterGainNode:b,destination:_,analyserNode:w}=y;try{b.disconnect()}catch(S){console.warn("[waveform-playlist] Error disconnecting master effects chain:",S)}const x=g.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)b.connect(w),w.connect(_);else{let S=b;x.forEach(k=>{try{k.disconnect()}catch(E){console.warn(`[waveform-playlist] Error disconnecting effect "${k.id}":`,E)}S.connect(k.effect),S=k.effect}),S.connect(w),w.connect(_)}},[]),l=p.useCallback(g=>{const y=Ei(g);if(!y){console.error(`Unknown effect: ${g}`);return}const b={};y.parameters.forEach(x=>{b[x.name]=x.default});const _=Ir(y,b);s.current.set(_.instanceId,_);const w={instanceId:_.instanceId,effectId:y.id,definition:y,params:b,bypassed:!1};n(x=>[...x,w])},[]),c=p.useCallback(g=>{const y=s.current.get(g);y&&(y.dispose(),s.current.delete(g)),n(b=>b.filter(_=>_.instanceId!==g))},[]),u=p.useCallback((g,y,b)=>{const _=s.current.get(g);_&&_.setParameter(y,b),n(w=>w.map(x=>x.instanceId===g?{...x,params:{...x.params,[y]:b}}:x))},[]),f=p.useCallback(g=>{const y=r.current.find(w=>w.instanceId===g);if(!y)return;const b=!y.bypassed,_=s.current.get(g);if(_){const w=y.params.wet??1;_.setParameter("wet",b?0:w)}n(w=>w.map(x=>x.instanceId===g?{...x,bypassed:b}:x))},[]),m=p.useCallback((g,y)=>{n(b=>{const _=[...b],[w]=_.splice(g,1);return _.splice(y,0,w),_})},[]),d=p.useCallback(()=>{s.current.forEach(g=>g.dispose()),s.current.clear(),n([])},[]);p.useEffect(()=>{i(t)},[t,i]);const h=p.useCallback((g,y,b)=>{const _=new L.Analyser("fft",e);a.current=_,o.current={masterGainNode:g,destination:y,analyserNode:_};const x=r.current.map(S=>s.current.get(S.instanceId)).filter(S=>S!==void 0);if(x.length===0)g.connect(_),_.connect(y);else{let S=g;x.forEach(k=>{S.connect(k.effect),S=k.effect}),S.connect(_),_.connect(y)}return function(){_.dispose(),a.current=null,o.current=null}},[e]);p.useEffect(()=>{const g=s.current;return()=>{g.forEach(y=>y.dispose()),g.clear()}},[]);const v=p.useCallback(()=>{const g=t.filter(y=>!y.bypassed);if(g.length!==0)return(y,b,_)=>{const w=[];for(const x of g){const S=Ir(x.definition,x.params);w.push(S)}if(w.length===0)y.connect(b);else{let x=y;w.forEach(S=>{x.connect(S.effect),x=S.effect}),x.connect(b)}return function(){w.forEach(S=>S.dispose())}}},[t]);return{activeEffects:t,availableEffects:Nr,addEffect:l,removeEffect:c,updateParameter:u,toggleBypass:f,reorderEffects:m,clearAllEffects:d,masterEffects:h,createOfflineEffectsFunction:v,analyserRef:a}}function Z0(){const[e,t]=p.useState(new Map),n=p.useRef(new Map),r=p.useRef(new Map),s=p.useCallback((d,h)=>{const v=r.current.get(d);if(!v)return;const{graphEnd:g,masterGainNode:y}=v,b=n.current.get(d);try{g.disconnect()}catch(w){console.warn(`[waveform-playlist] Error disconnecting track "${d}" effect chain:`,w)}const _=h.map(w=>b?.get(w.instanceId)).filter(w=>w!==void 0);if(_.length===0)g.connect(y);else{let w=g;_.forEach(x=>{try{x.disconnect()}catch(S){console.warn(`[waveform-playlist] Error disconnecting effect "${x.id}" on track "${d}":`,S)}w.connect(x.effect),w=x.effect}),w.connect(y)}},[]),a=p.useCallback((d,h)=>{const v=Ei(h);if(!v){console.error(`Unknown effect: ${h}`);return}const g={};v.parameters.forEach(_=>{g[_.name]=_.default});const y=Ir(v,g);n.current.has(d)||n.current.set(d,new Map),n.current.get(d).set(y.instanceId,y);const b={instanceId:y.instanceId,effectId:v.id,definition:v,params:g,bypassed:!1};t(_=>{const w=new Map(_),x=w.get(d)||[];return w.set(d,[...x,b]),w})},[]),o=p.useCallback((d,h)=>{const v=n.current.get(d),g=v?.get(h);g&&(g.dispose(),v?.delete(h)),t(y=>{const b=new Map(y),_=b.get(d)||[];return b.set(d,_.filter(w=>w.instanceId!==h)),b})},[]),i=p.useCallback((d,h,v,g)=>{const b=n.current.get(d)?.get(h);b&&b.setParameter(v,g),t(_=>{const w=new Map(_),x=w.get(d)||[];return w.set(d,x.map(S=>S.instanceId===h?{...S,params:{...S.params,[v]:g}}:S)),w})},[]),l=p.useCallback((d,h)=>{const g=(u.current.get(d)||[]).find(w=>w.instanceId===h);if(!g)return;const y=!g.bypassed,_=n.current.get(d)?.get(h);if(_){const w=g.params.wet??1;_.setParameter("wet",y?0:w)}t(w=>{const x=new Map(w),S=x.get(d)||[];return x.set(d,S.map(k=>k.instanceId===h?{...k,bypassed:y}:k)),x})},[]),c=p.useCallback(d=>{const h=n.current.get(d);h&&(h.forEach(v=>v.dispose()),h.clear()),t(v=>{const g=new Map(v);return g.set(d,[]),g})},[]),u=p.useRef(e);u.current=e;const f=p.useCallback(d=>(h,v,g)=>{r.current.set(d,{graphEnd:h,masterGainNode:v});const y=u.current.get(d)||[],b=n.current.get(d),_=y.map(w=>b?.get(w.instanceId)).filter(w=>w!==void 0);if(_.length===0)h.connect(v);else{let w=h;_.forEach(x=>{w.connect(x.effect),w=x.effect}),w.connect(v)}return function(){r.current.delete(d)}},[]);p.useEffect(()=>{e.forEach((d,h)=>{s(h,d)})},[e,s]),p.useEffect(()=>{const d=n.current;return()=>{d.forEach(h=>{h.forEach(v=>v.dispose()),h.clear()}),d.clear()}},[]);const m=p.useCallback(d=>{const v=(e.get(d)||[]).filter(g=>!g.bypassed);if(v.length!==0)return(g,y,b)=>{const _=[];for(const w of v){const x=Ir(w.definition,w.params);_.push(x)}if(_.length===0)g.connect(y);else{let w=g;_.forEach(x=>{w.connect(x.effect),w=x.effect}),w.connect(y)}return function(){_.forEach(x=>x.dispose())}}},[e]);return{trackEffectsState:e,addEffectToTrack:a,removeEffectFromTrack:o,updateTrackEffectParameter:i,toggleBypass:l,clearTrackEffects:c,getTrackEffectsFunction:f,createOfflineTrackEffectsFunction:m,availableEffects:Nr}}function H0(e,t={}){const{bitDepth:n=16}=t,r=e.numberOfChannels,s=e.sampleRate,a=e.length,o=n/8,i=r*o,l=s*i,c=a*i,u=44,f=u+c,m=new ArrayBuffer(f),d=new DataView(m);is(d,0,"RIFF"),d.setUint32(4,f-8,!0),is(d,8,"WAVE"),is(d,12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,n===32?3:1,!0),d.setUint16(22,r,!0),d.setUint32(24,s,!0),d.setUint32(28,l,!0),d.setUint16(32,i,!0),d.setUint16(34,n,!0),is(d,36,"data"),d.setUint32(40,c,!0);const h=[];for(let g=0;g<r;g++)h.push(e.getChannelData(g));let v=u;if(n===16)for(let g=0;g<a;g++)for(let y=0;y<r;y++){const b=h[y][g],_=Math.max(-1,Math.min(1,b)),w=_<0?_*32768:_*32767;d.setInt16(v,w,!0),v+=2}else for(let g=0;g<a;g++)for(let y=0;y<r;y++)d.setFloat32(v,h[y][g],!0),v+=4;return new Blob([m],{type:"audio/wav"})}function is(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function G0(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}function df(){const[e,t]=p.useState(!1),[n,r]=p.useState(0),[s,a]=p.useState(null);return{exportWav:p.useCallback(async(i,l,c={})=>{const{filename:u="export",mode:f="master",trackIndex:m,autoDownload:d=!0,applyEffects:h=!0,effectsFunction:v,createOfflineTrackEffects:g,bitDepth:y=16,onProgress:b}=c;t(!0),r(0),a(null);try{if(i.length===0)throw new Error("No tracks to export");if(f==="individual"&&(m===void 0||m<0||m>=i.length))throw new Error("Invalid track index for individual export");const _=i[0].clips[0]?.sampleRate||44100;let w=0;for(const $ of i)for(const A of $.clips){const I=A.startSample+A.durationSamples;w=Math.max(w,I)}w+=Math.round(_*.1);const x=w/_,S=f==="individual"?[{track:i[m],state:l[m],index:m}]:i.map(($,A)=>({track:$,state:l[A],index:A})),k=l.some($=>$.soloed),E=!!g;let M;if((v||E)&&h)M=await U0(S,l,k,x,_,v,g,$=>{r($),b?.($)});else{const $=new OfflineAudioContext(2,w,_);let A=0;const I=S.reduce((R,{track:D})=>R+D.clips.length,0);for(const{track:R,state:D}of S)if(!(D.muted&&!D.soloed)&&!(k&&!D.soloed))for(const O of R.clips){await Y0($,O,D,_,h),A++;const Z=A/I*.5;r(Z),b?.(Z)}r(.5),b?.(.5),M=await $.startRendering()}r(.9),b?.(.9);const T=H0(M,{bitDepth:y});if(r(1),b?.(1),d){const $=f==="individual"?`${u}_${i[m].name}`:u;G0(T,`${$}.wav`)}return{audioBuffer:M,blob:T,duration:x}}catch(_){const w=_ instanceof Error?_.message:"Export failed";throw a(w),_}finally{t(!1)}},[]),isExporting:e,progress:n,error:s}}async function U0(e,t,n,r,s,a,o,i){const{Offline:l,Volume:c,Gain:u,Panner:f,Player:m,ToneAudioBuffer:d}=await import("tone");i(.1);let h;try{h=await l(async({transport:v,destination:g})=>{const y=new c(0);let b;a?b=a(y,g,!0):y.connect(g);for(const{track:_,state:w}of e){if(w.muted&&!w.soloed||n&&!w.soloed)continue;const x=new c(X0(w.volume)),S=new f(w.pan),k=new u(w.muted?0:1),E=o?.(_.id);E?E(k,y,!0):k.connect(y),S.connect(k),x.connect(S);for(const M of _.clips){const{audioBuffer:T,startSample:$,durationSamples:A,offsetSamples:I,gain:R,fadeIn:D,fadeOut:O}=M,Z=$/s,G=A/s,Y=I/s,te=new d(T),X=new m(te),K=new u(R);if(X.connect(K),K.connect(x),D){const le=Z,J=Z+D.duration,de=yr(K.gain);de&&(de.setValueAtTime(0,le),de.linearRampToValueAtTime(R,J))}if(O){const le=Z+G-O.duration,J=Z+G,de=yr(K.gain);de&&(de.setValueAtTime(R,le),de.linearRampToValueAtTime(0,J))}X.start(Z,Y,G)}}v.start(0)},r,2,s)}catch(v){throw v instanceof Error?v:new Error(`Tone.Offline rendering failed: ${String(v)}`)}return i(.9),h.get()}function X0(e){return 20*Math.log10(Math.max(e,1e-4))}async function Y0(e,t,n,r,s){const{audioBuffer:a,startSample:o,durationSamples:i,offsetSamples:l,gain:c,fadeIn:u,fadeOut:f}=t;if(!a){console.warn(`Skipping clip "${t.name||t.id}" - no audioBuffer for export`);return}const m=o/r,d=i/r,h=l/r,v=e.createBufferSource();v.buffer=a;const g=e.createGain(),y=c*n.volume,b=e.createStereoPanner();if(b.pan.value=n.pan,v.connect(g),g.connect(b),b.connect(e.destination),s){if(u?g.gain.setValueAtTime(0,m):g.gain.setValueAtTime(y,m),u){const _=m,w=m+u.duration;ec(g.gain,_,w,0,y,u.type||"linear")}if(f){const _=m+d-f.duration,w=m+d;(!u||u.duration<d-f.duration)&&g.gain.setValueAtTime(y,_),ec(g.gain,_,w,y,0,f.type||"linear")}}else g.gain.setValueAtTime(y,m);v.start(m,h,d)}function ec(e,t,n,r,s,a){const o=n-t;if(!(o<=0))switch(a){case"linear":e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n);break;case"exponential":{const i=Math.max(r,1e-4),l=Math.max(s,1e-4);e.setValueAtTime(i,t),e.exponentialRampToValueAtTime(l,n),s===0&&e.setValueAtTime(0,n);break}case"logarithmic":{const i=tc(r,s,256,"logarithmic");e.setValueCurveAtTime(i,t,o);break}case"sCurve":{const i=tc(r,s,256,"sCurve");e.setValueCurveAtTime(i,t,o);break}default:e.setValueAtTime(r,t),e.linearRampToValueAtTime(s,n)}}function tc(e,t,n,r){const s=new Float32Array(n),a=t-e;for(let o=0;o<n;o++){const i=o/(n-1);let l;r==="logarithmic"?a>0?l=Math.log10(1+i*9)/Math.log10(10):l=1-Math.log10(1+(1-i)*9)/Math.log10(10):l=i*i*(3-2*i),s[o]=e+a*l}return s}const ff=()=>{const e=p.useRef(null),t=p.useCallback(()=>{e.current!==null&&(cancelAnimationFrame(e.current),e.current=null)},[]),n=p.useCallback(r=>{t(),e.current=requestAnimationFrame(r)},[t]);return p.useEffect(()=>()=>{t()},[t]),{animationFrameRef:e,startAnimationFrameLoop:n,stopAnimationFrameLoop:t}},K0=`
|
|
858
858
|
"use strict";
|
|
859
859
|
|
|
860
860
|
var INT8_MAX = 127;
|
|
@@ -1001,13 +1001,13 @@ self.onmessage = function(e) {
|
|
|
1001
1001
|
self.postMessage({ id: msg.id, error: err.message || String(err) });
|
|
1002
1002
|
}
|
|
1003
1003
|
};
|
|
1004
|
-
`;let q0=0;function J0(){let e;try{const r=new Blob([K0],{type:"application/javascript"}),s=URL.createObjectURL(r);e=new Worker(s),URL.revokeObjectURL(s)}catch(r){return console.warn("[waveform-playlist] Failed to create peaks worker (CSP restriction?):",r),{generate(){return Promise.reject(new Error("Worker creation failed"))},terminate(){}}}const t=new Map;let n=!1;return e.onmessage=r=>{const s=r.data,a=t.get(s.id);if(a)if(t.delete(s.id),s.error)a.reject(new Error(s.error));else try{const o=gt.create(s.buffer);a.resolve(o)}catch(o){a.reject(o)}},e.onerror=r=>{n=!0,e.terminate();for(const[,s]of t)s.reject(r.error??new Error(r.message));t.clear()},{generate(r){if(n)return Promise.reject(new Error("Worker terminated"));const s=String(++q0);return new Promise((a,o)=>{t.set(s,{resolve:a,reject:o}),e.postMessage({id:s,scale:r.scale,bits:r.bits,amplitude_scale:1,split_channels:r.splitChannels,length:r.length,sample_rate:r.sampleRate,channels:r.channels},r.channels)})},terminate(){n=!0,e.terminate();for(const[,r]of t)r.reject(new Error("Worker terminated"));t.clear()}}}function Q0(e,t){const[n,r]=p.useState(()=>new Map),[s,a]=p.useState(!1),o=p.useRef(null),i=p.useRef(new WeakMap),l=p.useRef(new WeakMap),c=p.useRef(new WeakMap),u=p.useRef(0),f=p.useCallback(()=>(o.current||(o.current=J0()),o.current),[]);return p.useEffect(()=>{let m=!1;const d=i.current,h=l.current,g=c.current,v=[],y=new Map;for(const w of e)for(const _ of w.clips){if(!_.audioBuffer||_.waveformData)continue;const x=d.get(_.audioBuffer);if(x){v.push({clipId:_.id,waveformData:x});continue}if(h.get(_.audioBuffer)){const k=g.get(_.audioBuffer);k?k.add(_.id):g.set(_.audioBuffer,new Set([_.id]));continue}const S=y.get(_.audioBuffer);S?S.add(_.id):y.set(_.audioBuffer,new Set([_.id]))}if(v.length>0&&r(w=>{const _=new Map(w);for(const x of v)_.set(x.clipId,x.waveformData);return _}),y.size===0)return;u.current+=y.size,a(!0);const b=f();for(const[w,_]of y){g.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=g.get(w)??new Set;g.delete(w),h.delete(w),!m&&(r(T=>{const R=new Map(T);for(const A of I)R.set(A,E);return R}),u.current--,u.current<=0&&(u.current=0,a(!1)))}).catch(E=>{g.delete(w),h.delete(w),!m&&(console.warn("[waveform-playlist] Worker peak generation failed:",E),u.current--,u.current<=0&&(u.current=0,a(!1)))});h.set(w,k)}return()=>{m=!0,l.current=new WeakMap,c.current=new WeakMap,u.current=0,a(!1)}},[e,t,f]),p.useEffect(()=>()=>{o.current?.terminate(),o.current=null},[]),{cache:n,isGenerating:s}}function fo(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=fo(e);if(e instanceof Blob){const l=await e.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(l),name:r}}const s=typeof e=="string"?e:e.src,a=await fetch(s,{signal:n});if(!a.ok)throw new Error(`Failed to fetch ${s}: ${a.statusText}`);const o=await a.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(o),name:r}}function ty(){const[e,t]=p.useState([]),[n,r]=p.useState(0),[s,a]=p.useState([]),o=p.useRef(!1),i=p.useRef(new Set),l=p.useRef(new Map);p.useEffect(()=>{const f=l.current;return()=>{o.current=!0;for(const m of f.values())m.abort();f.clear()}},[]);const c=p.useCallback(f=>{if(f.length===0)return;const m=mh(),d=f.map(h=>({track:uc({name:`${fo(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 v=new AbortController;l.current.set(h.id,v),(async()=>{try{const{audioBuffer:y,name:b}=await ey(g,m,v.signal),w=cc({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:fo(g),error:y instanceof Error?y:new Error(String(y))}]))}finally{l.current.delete(h.id),!o.current&&i.current.delete(h.id)&&r(y=>y-1)}})()}},[]),u=p.useCallback(f=>{t(d=>d.filter(h=>h.id!==f));const m=l.current.get(f);m&&(m.abort(),l.current.delete(f)),i.current.delete(f)&&r(d=>d-1)},[]);return{tracks:e,addTracks:c,removeTrack:u,loadingCount:n,isLoading:n>0,errors:s}}const ff=p.createContext(null),hf=p.createContext(null),pf=p.createContext(null),mf=p.createContext(null),ny=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:s=1024,zoomLevels:a,automaticScroll:o=!1,theme:i,controls:l={show:!1,width:0},annotationList:c,effects:u,onReady:f,onAnnotationUpdate:m,onAnnotationsChange:d,barWidth:h=1,barGap:g=0,progressBarWidth:v,onTracksChange:y,soundFontCache:b,deferEngineRebuild:w=!1,children:_})=>{const x=v??h+g,S=p.useMemo(()=>a,[a?.join(",")]),k=p.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const V=c.annotations[0];if(typeof V.start!="number"||typeof V.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof V.start),[]}return c.annotations},[c?.annotations]),E=p.useRef(k);E.current=k;const[I,T]=p.useState(null),[R,A]=p.useState(!1),[M,$]=p.useState(0),[P,O]=p.useState(0),[Z,G]=p.useState([]),[Y,ee]=p.useState([]),[X,K]=p.useState([]),[le,te]=p.useState(o),[fe,de]=p.useState(c?.isContinuousPlay??!1),[ne,z]=p.useState(c?.linkEndpoints??!1),[ae,ke]=p.useState(c?.editable??!1),[ue,xe]=p.useState(!1),B=p.useRef(null),U=p.useRef(!1),Je=p.useRef(!1);Je.current=R;const Te=p.useRef(0),ce=p.useRef(0),He=p.useRef(e),Ne=p.useRef(b);Ne.current=b;const Qe=p.useRef(X),We=p.useRef(0),Oe=p.useRef(0),ze=p.useRef(null),Xe=p.useRef(null),ft=p.useRef(!1),bt=p.useRef(c?.isContinuousPlay??!1),q=p.useRef(null),pe=p.useRef(null),et=p.useRef(0),Ge=p.useRef(!1),oe=p.useRef(!1),be=p.useRef(s),je=p.useRef(44100),{timeFormat:N,setTimeFormat:j,formatTime:Q}=ef(),re=tf({engineRef:B,initialSamplesPerPixel:s}),{samplesPerPixel:me,onEngineState:Le}=re,J=nf({engineRef:B,initialVolume:1}),{masterVolume:Ye,setMasterVolume:tt,masterVolumeRef:Be,onEngineState:kt}=J,{selectionStart:Dt,selectionEnd:Jt,setSelection:Qt,selectionStartRef:Mt,selectionEndRef:en,onEngineState:jr}=M0({engineRef:B}),{isLoopEnabled:Zr,loopStart:Ai,loopEnd:Ti,setLoopEnabled:$i,setLoopRegion:Hr,clearLoopRegion:Ri,isLoopEnabledRef:Di,loopStartRef:Pi,loopEndRef:Fi,onEngineState:Oi}=A0({engineRef:B}),{selectedTrackId:Li,setSelectedTrackId:Bi,onEngineState:Wi,selectedTrackIdRef:Vi}=T0({engineRef:B}),{animationFrameRef:Ni,startAnimationFrameLoop:ra,stopAnimationFrameLoop:Gr}=df(),Nf=p.useMemo(()=>Math.min(...S??[256,512,1024,2048,4096,8192]),[S]),{cache:zi}=Q0(e,Nf),ji=p.useCallback(V=>{bt.current=V,de(V)},[]),Pt=p.useCallback(V=>{q.current=V,T(V)},[]),Zi=p.useCallback(()=>{const V=Mt.current??0,H=en.current??0;V!==H&&H>V&&Hr(V,H)},[Hr,Mt,en]);p.useEffect(()=>{ft.current=le},[le]),p.useEffect(()=>{Qe.current=X},[X]),He.current=e;const sa=e===pe.current;Ge.current=sa||oe.current,p.useEffect(()=>{if(!Xe.current||P===0)return;const V=Xe.current,H=be.current,ve=me;if(H===ve)return;const W=V.clientWidth,Me=V.scrollLeft+W/2,Ee=je.current,la=Me*H/Ee*Ee/ve,Kr=Math.max(0,la-W/2);V.scrollLeft=Kr,be.current=ve},[me,P]);const Ur=p.useRef(null);p.useEffect(()=>{if(sa||oe.current){sa&&(pe.current=null);let W=0;e.forEach(Ce=>{Ce.clips.forEach(Me=>{const Ee=(Me.startSample+Me.durationSamples)/Me.sampleRate;W=Math.max(W,Ee)})}),O(W);return}if(w){let W=0;e.forEach(Ce=>{Ce.clips.forEach(Me=>{const Ee=(Me.startSample+Me.durationSamples)/Me.sampleRate;W=Math.max(W,Ee)})}),O(W);return}if(xe(!1),e.length===0){G([]),O(0),K([]),ee([]),B.current&&(B.current.dispose(),B.current=null);return}const V=Je.current,H=ce.current;return B.current&&V&&(B.current.stop(),Gr(),Ur.current={position:H}),(async()=>{try{const W=[];e.forEach(Ae=>{Ae.clips.length>0&&Ae.clips[0].audioBuffer&&W.push(Ae.clips[0].audioBuffer)});let Ce=0;e.forEach(Ae=>{Ae.clips.forEach(pt=>{const Nt=pt.sampleRate,Xf=(pt.startSample+pt.durationSamples)/Nt;Ce=Math.max(Ce,Xf)})}),G(W),O(Ce),K(Ae=>Ae.length===e.length?Ae.map((pt,Nt)=>({...pt,name:e[Nt].name})):e.map(pt=>({name:pt.name,muted:pt.muted,soloed:pt.soloed,volume:pt.volume,pan:pt.pan}))),B.current&&B.current.dispose(),et.current=0,pe.current=null,U.current=!1;const Me=gh({effects:u,soundFontCache:Ne.current}),Ee=new Ch({adapter:Me,samplesPerPixel:be.current,zoomLevels:S});Ee.setSelection(Mt.current??0,en.current??0),Ee.setLoopRegion(Pi.current??0,Fi.current??0),Di.current&&Ee.setLoopEnabled(!0),Ee.setMasterVolume(Be.current??1),Vi.current&&Ee.selectTrack(Vi.current);const Yr=Qe.current,la=e.map((Ae,pt)=>{const Nt=Yr[pt];return{...Ae,volume:Nt?.volume??Ae.volume,muted:Nt?.muted??Ae.muted,soloed:Nt?.soloed??Ae.soloed,pan:Nt?.pan??Ae.pan}});let Kr=!0;Ee.on("statechange",Ae=>{jr(Ae),Oi(Ae),Wi(Ae),Le(Ae),kt(Ae),!Kr&&Ae.tracksVersion!==et.current&&(et.current=Ae.tracksVersion,pe.current=Ae.tracks,y?y(Ae.tracks):console.warn("[waveform-playlist] Engine tracks changed but onTracksChange prop is not set — UI will revert on next render. Pass onTracksChange to WaveformPlaylistProvider."))}),Ee.setTracks(la),Kr=!1,et.current=Ee.getState().tracksVersion,B.current=Ee,xe(!0);const Uf=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:Ce}});window.dispatchEvent(Uf),f?.()}catch(W){console.error("Error loading audio:",W)}})(),()=>{if(Ge.current){Ge.current=!1;return}Gr(),B.current&&B.current.dispose()}},[e,f,u,Gr,jr,Oi,Wi,Le,kt,y,Be,Mt,en,Pi,Fi,Di,S,b,w]),p.useEffect(()=>{if(e.length===0)return;const V=e.map(H=>H.clips.map(W=>{let Ce;if(W.waveformData)try{Ce=Jl(W.waveformData,me,n,W.offsetSamples,W.durationSamples)}catch(Me){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",Me)}if(!Ce){const Me=zi.get(W.id);if(Me)try{Ce=Jl(Me,me,n,W.offsetSamples,W.durationSamples)}catch(Ee){console.warn("[waveform-playlist] Failed to extract peaks from cache:",Ee)}}if(!Ce){!w&&!W.audioBuffer&&!W.waveformData&&!W.midiNotes&&console.warn(`[waveform-playlist] Clip "${W.id}" has no audio data or waveform data`);const Me=n?1:W.audioBuffer?.numberOfChannels??1,Ee=W.midiNotes?Math.ceil(W.durationSamples/me):0;Ce={length:Ee,data:Array.from({length:Me},()=>new Int16Array(Ee*2)),bits:16}}return{clipId:W.id,trackName:H.name,peaks:Ce,startSample:W.startSample,durationSamples:W.durationSamples,fadeIn:W.fadeIn,fadeOut:W.fadeOut,midiNotes:W.midiNotes,sampleRate:W.sampleRate,offsetSamples:W.offsetSamples}}));ee(V)},[e,me,n,zi,w]);const Hi=p.useRef(!1),xn=p.useCallback(()=>{if(B.current)return B.current.getCurrentTime();Hi.current||(Hi.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-(We.current??0);return(Oe.current??0)+V},[]),tn=p.useCallback(()=>{const V=()=>{const H=xn();ce.current=H;const ve=E.current;if(ve.length>0){const W=ve.find(Ce=>H>=Ce.start&&H<Ce.end);if(bt.current)W&&W.id!==q.current?Pt(W.id):!W&&q.current!==null&&Pt(null);else if(q.current){const Ce=ve.find(Me=>Me.id===q.current);if(Ce&&H>=Ce.end){B.current&&B.current.stop(),A(!1),ce.current=Te.current,$(Te.current);return}}else W&&Pt(W.id)}if(ft.current&&Xe.current&&P>0){const W=Xe.current,Ce=je.current,Me=H*Ce/be.current,Ee=W.clientWidth,Yr=Math.max(0,Me-Ee/2);W.scrollLeft=Yr}if(ze.current!==null&&H>=ze.current){B.current&&B.current.stop(),A(!1),ce.current=ze.current,$(ze.current),ze.current=null;return}if(H>=P){B.current&&B.current.stop(),A(!1),ce.current=Te.current,$(Te.current),Pt(null);return}ra(V)};ra(V)},[P,Pt,ra,xn]),ht=Gr;p.useEffect(()=>{(async()=>{if(R&&Ni.current&&B.current)if(fe){const H=ce.current;B.current.stop(),ht();const W=L.getContext().currentTime;We.current=W,Oe.current=H,B.current.play(H),tn()}else ht(),tn()})().catch(H=>{console.warn("[waveform-playlist] Failed to reschedule playback:",H),A(!1),ht()})},[fe,R,tn,ht,Ni]),p.useEffect(()=>{(async()=>{if(Ur.current&&B.current){const{position:H}=Ur.current;Ur.current=null;const W=L.getContext().currentTime;We.current=W,Oe.current=H,U.current||(await B.current.init(),U.current=!0),B.current.play(H),A(!0),tn()}})().catch(H=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",H),A(!1),ht()})},[e,tn,ht]);const Xr=p.useCallback(async(V,H)=>{if(!B.current||P===0)return;const ve=V??ce.current;Te.current=ve,ce.current=ve,B.current.stop(),B.current.seek(ve),ht();const Ce=L.getContext().currentTime;We.current=Ce,Oe.current=ve,ze.current=H!==void 0?ve+H:null,U.current||(await B.current.init(),U.current=!0);const Me=H!==void 0?ve+H:void 0;try{B.current.play(ve,Me)}catch(Ee){console.warn("[waveform-playlist] Playback failed to start:",Ee),ht();return}A(!0),tn()},[P,tn,ht]),Gi=p.useCallback(()=>{if(!B.current)return;const V=xn();B.current.pause(),A(!1),ht(),ce.current=V,$(V)},[ht,xn]),Ui=p.useCallback(()=>{B.current&&(B.current.stop(),A(!1),ht(),ce.current=Te.current,$(Te.current),Pt(null))},[ht,Pt]),Xi=p.useCallback(V=>{const H=Math.max(0,Math.min(V,P));ce.current=H,$(H),R&&B.current&&Xr(H)},[P,R,Xr]),Yi=p.useCallback((V,H)=>{const ve=He.current[V]?.id;if(!ve)return;const W=[...X];W[V]={...W[V],muted:H},K(W),B.current&&B.current.setTrackMute(ve,H)},[X]),Ki=p.useCallback((V,H)=>{const ve=He.current[V]?.id;if(!ve)return;const W=[...X];W[V]={...W[V],soloed:H},K(W),B.current&&B.current.setTrackSolo(ve,H)},[X]),qi=p.useCallback((V,H)=>{const ve=He.current[V]?.id;if(!ve)return;const W=[...X];W[V]={...W[V],volume:H},K(W),B.current&&B.current.setTrackVolume(ve,H)},[X]),Ji=p.useCallback((V,H)=>{const ve=He.current[V]?.id;if(!ve)return;const W=[...X];W[V]={...W[V],pan:H},K(W),B.current&&B.current.setTrackPan(ve,H)},[X]),Qi=p.useCallback((V,H)=>{Qt(V,H),ce.current=V,$(V),R&&B.current&&(B.current.stop(),B.current.seek(V),B.current.play(V))},[R,Qt]),el=p.useCallback(V=>{Xe.current=V},[]),aa=p.useRef(d);aa.current=d;const tl=p.useCallback(V=>{const H=typeof V=="function"?V(E.current):V;if(!aa.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}aa.current(H)},[]),oa=Z[0]?.sampleRate||e[0]?.clips[0]?.sampleRate||44100;je.current=oa;const ia=t?30:0,nl=e.length*r+ia,zf=p.useMemo(()=>({isPlaying:R,currentTime:M,currentTimeRef:ce,playbackStartTimeRef:We,audioStartPositionRef:Oe,getPlaybackTime:xn}),[R,M,ce,We,Oe,xn]),jf=p.useMemo(()=>({continuousPlay:fe,linkEndpoints:ne,annotationsEditable:ae,isAutomaticScroll:le,isLoopEnabled:Zr,annotations:k,activeAnnotationId:I,selectionStart:Dt,selectionEnd:Jt,selectedTrackId:Li,loopStart:Ai,loopEnd:Ti}),[fe,ne,ae,le,Zr,k,I,Dt,Jt,Li,Ai,Ti]),rl=p.useCallback(V=>{ce.current=V,$(V)},[ce]),sl=p.useCallback(V=>{te(V)},[]),Zf=p.useMemo(()=>({play:Xr,pause:Gi,stop:Ui,seekTo:Xi,setCurrentTime:rl,setTrackMute:Yi,setTrackSolo:Ki,setTrackVolume:qi,setTrackPan:Ji,setSelection:Qi,setSelectedTrackId:Bi,setTimeFormat:j,formatTime:Q,zoomIn:re.zoomIn,zoomOut:re.zoomOut,setMasterVolume:tt,setAutomaticScroll:sl,setScrollContainer:el,scrollContainerRef:Xe,setContinuousPlay:ji,setLinkEndpoints:z,setAnnotationsEditable:ke,setAnnotations:tl,setActiveAnnotationId:Pt,setLoopEnabled:$i,setLoopRegion:Hr,setLoopRegionFromSelection:Zi,clearLoopRegion:Ri}),[Xr,Gi,Ui,Xi,rl,Yi,Ki,qi,Ji,Qi,Bi,j,Q,re.zoomIn,re.zoomOut,tt,sl,el,Xe,ji,z,ke,tl,Pt,$i,Hr,Zi,Ri]),Hf=p.useMemo(()=>({duration:P,audioBuffers:Z,peaksDataArray:Y,trackStates:X,tracks:e,sampleRate:oa,waveHeight:r,timeScaleHeight:ia,minimumPlaylistHeight:nl,controls:l,playoutRef:B,samplesPerPixel:me,timeFormat:N,masterVolume:Ye,canZoomIn:re.canZoomIn,canZoomOut:re.canZoomOut,barWidth:h,barGap:g,progressBarWidth:x,isReady:ue,mono:n,isDraggingRef:oe,onTracksChange:y}),[P,Z,Y,X,e,oa,r,ia,nl,l,B,me,N,Ye,re.canZoomIn,re.canZoomOut,h,g,x,ue,n,oe,y]),Gf={...Bd,...i};return C.jsx(F.ThemeProvider,{theme:Gf,children:C.jsx(ff.Provider,{value:zf,children:C.jsx(hf.Provider,{value:jf,children:C.jsx(pf.Provider,{value:Zf,children:C.jsx(mf.Provider,{value:Hf,children:_})})})})})},ot=()=>{const e=p.useContext(ff);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},it=()=>{const e=p.useContext(hf);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},Ie=()=>{const e=p.useContext(pf);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},lt=()=>{const e=p.useContext(mf);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var ry=class{constructor(e){this._playbackRate=1,this.handleEnded=()=>{this.onStopCallback&&this.onStopCallback()},this.handleTimeUpdate=()=>{this.onTimeUpdateCallback&&this.onTimeUpdateCallback(this.audioElement.currentTime)},this._peaks=e.peaks,this._id=e.id??`track-${Date.now()}`,this._name=e.name??"Track",this._playbackRate=e.playbackRate??1,typeof e.source=="string"?(this.audioElement=new Audio(e.source),this.ownsElement=!0):(this.audioElement=e.source,this.ownsElement=!1),this.audioElement.preload="auto",this.audioElement.volume=e.volume??1,this.audioElement.playbackRate=this._playbackRate;const t=this.audioElement;"preservesPitch"in this.audioElement?t.preservesPitch=!0:"mozPreservesPitch"in this.audioElement?t.mozPreservesPitch=!0:"webkitPreservesPitch"in this.audioElement&&(t.webkitPreservesPitch=!0),this.audioElement.addEventListener("ended",this.handleEnded),this.audioElement.addEventListener("timeupdate",this.handleTimeUpdate)}play(e=0){this.audioElement.currentTime=e,this.audioElement.play().catch(t=>{console.warn("MediaElementTrack: play() failed:",t)})}pause(){this.audioElement.pause()}stop(){this.audioElement.pause(),this.audioElement.currentTime=0}seekTo(e){this.audioElement.currentTime=Math.max(0,Math.min(e,this.duration))}setVolume(e){this.audioElement.volume=Math.max(0,Math.min(1,e))}setPlaybackRate(e){const t=Math.max(.5,Math.min(2,e));this._playbackRate=t,this.audioElement.playbackRate=t}setMuted(e){this.audioElement.muted=e}setOnStopCallback(e){this.onStopCallback=e}setOnTimeUpdateCallback(e){this.onTimeUpdateCallback=e}dispose(){this.audioElement.removeEventListener("ended",this.handleEnded),this.audioElement.removeEventListener("timeupdate",this.handleTimeUpdate),this.audioElement.pause(),this.ownsElement&&(this.audioElement.src="",this.audioElement.load())}get id(){return this._id}get name(){return this._name}get peaks(){return this._peaks}get currentTime(){return this.audioElement.currentTime}get duration(){return this.audioElement.duration||this._peaks.duration}get isPlaying(){return!this.audioElement.paused&&!this.audioElement.ended}get volume(){return this.audioElement.volume}get playbackRate(){return this._playbackRate}get muted(){return this.audioElement.muted}get element(){return this.audioElement}},sy=class{constructor(e={}){this.track=null,this._isPlaying=!1,this._masterVolume=e.masterVolume??1,this._playbackRate=e.playbackRate??1}async init(){}addTrack(e){return this.track&&(console.warn("MediaElementPlayout: Only one track is supported. Disposing previous track. For multi-track, use TonePlayout."),this.track.dispose()),this.track=new ry({...e,volume:this._masterVolume*(e.volume??1),playbackRate:this._playbackRate}),this.track.setOnStopCallback(()=>{this._isPlaying=!1,this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback()}),this.track}removeTrack(e){this.track&&this.track.id===e&&(this.track.dispose(),this.track=null)}getTrack(e){if(this.track&&this.track.id===e)return this.track}play(e,t,n){if(!this.track){console.warn("MediaElementPlayout: No track to play");return}const r=t??0;if(this._isPlaying=!0,this.track.play(r),n!==void 0){const s=n/this._playbackRate;setTimeout(()=>{this._isPlaying&&(this.pause(),this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())},s*1e3)}}pause(){this.track&&this.track.pause(),this._isPlaying=!1}stop(){this.track&&this.track.stop(),this._isPlaying=!1}seekTo(e){this.track&&this.track.seekTo(e)}getCurrentTime(){return this.track?this.track.currentTime:0}setMasterVolume(e){this._masterVolume=Math.max(0,Math.min(1,e)),this.track&&this.track.setVolume(this._masterVolume)}setPlaybackRate(e){this._playbackRate=Math.max(.5,Math.min(2,e)),this.track&&this.track.setPlaybackRate(this._playbackRate)}setMute(e,t){const n=this.getTrack(e);n&&n.setMuted(t)}setSolo(e,t){console.warn("MediaElementPlayout: Solo is not applicable for single-track playback")}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}dispose(){this.track&&(this.track.dispose(),this.track=null)}get isPlaying(){return this._isPlaying}get masterVolume(){return this._masterVolume}get playbackRate(){return this._playbackRate}get duration(){return this.track?.duration??0}get sampleRate(){return this.track?.peaks.sample_rate??44100}};const gf=p.createContext(null),vf=p.createContext(null),yf=p.createContext(null),bf=p.createContext(null),ay=({track:e,samplesPerPixel:t=1024,waveHeight:n=100,timescale:r=!1,playbackRate:s=1,automaticScroll:a=!1,theme:o,controls:i={show:!1,width:0},annotationList:l,barWidth:c=1,barGap:u=0,progressBarWidth:f,onAnnotationsChange:m,onReady:d,children:h})=>{const g=f??c+u,[v,y]=p.useState(!1),[b,w]=p.useState(0),[_,x]=p.useState(0),[S,k]=p.useState([]),[E,I]=p.useState(s),T=p.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const q=l.annotations[0];if(typeof q.start!="number"||typeof q.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 q.start),[]}return l.annotations},[l?.annotations]),R=p.useRef(T);R.current=T;const[A,M]=p.useState(null),[$,P]=p.useState(l?.isContinuousPlay??!1),[O]=p.useState(t),[Z,G]=p.useState(a),Y=p.useRef(null),ee=p.useRef(0),X=p.useRef($),K=p.useRef(null),le=p.useRef(null),te=p.useRef(a),fe=p.useRef(t),{startAnimationFrameLoop:de,stopAnimationFrameLoop:ne}=df();p.useEffect(()=>{X.current=$},[$]),p.useEffect(()=>{te.current=Z},[Z]);const z=p.useCallback(q=>{K.current=q,M(q)},[]),ae=p.useCallback(q=>{X.current=q,P(q)},[]),ke=p.useCallback(q=>{le.current=q},[]),ue=e.waveformData.sample_rate;p.useEffect(()=>{const q=new sy({playbackRate:s});q.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const pe=q.getTrack(q.track?.id??"");return pe&&pe.setOnTimeUpdateCallback(et=>{ee.current=et}),q.setOnPlaybackComplete(()=>{ne(),y(!1),z(null),ee.current=0,w(0)}),Y.current=q,x(e.waveformData.duration),d?.(),()=>{ne(),q.dispose()}},[e.source,e.waveformData,e.name,s,d,ne,z]),p.useEffect(()=>{try{const q=I0(e.waveformData,O,0,0,Math.ceil(e.waveformData.duration*ue)),pe={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:q.length,data:[q.data],bits:q.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*ue)};k([[pe]])}catch(q){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",q)}},[e.waveformData,e.name,O,ue]);const xe=p.useCallback(()=>{const q=()=>{const pe=Y.current?.getCurrentTime()??0;ee.current=pe;const et=R.current;if(et.length>0){const Ge=et.find(oe=>pe>=oe.start&&pe<oe.end);if(X.current)Ge&&Ge.id!==K.current?z(Ge.id):!Ge&&K.current!==null&&z(null);else if(K.current){const oe=et.find(be=>be.id===K.current);if(oe&&pe>=oe.end){Y.current?.stop(),y(!1);return}}else Ge&&z(Ge.id)}if(te.current&&le.current){const Ge=le.current,oe=pe*ue/fe.current,be=Ge.clientWidth,je=Math.max(0,oe-be/2);Ge.scrollLeft=je}de(q)};de(q)},[z,ue,de]),B=ne,U=p.useCallback(q=>{if(!Y.current)return;const pe=q??ee.current;Y.current.play(void 0,pe),y(!0),xe()},[xe]),Je=p.useCallback(()=>{Y.current&&(Y.current.pause(),y(!1),B(),w(Y.current.getCurrentTime()))},[B]),Te=p.useCallback(()=>{Y.current&&(Y.current.stop(),y(!1),B(),ee.current=0,w(0),z(null))},[B,z]),ce=p.useCallback(q=>{const pe=Math.max(0,Math.min(q,_));ee.current=pe,w(pe),Y.current&&Y.current.seekTo(pe)},[_]),He=p.useCallback(q=>{const pe=Math.max(.5,Math.min(2,q));I(pe),Y.current&&Y.current.setPlaybackRate(pe)},[]),Ne=r?30:0,Qe=p.useMemo(()=>({isPlaying:v,currentTime:b,currentTimeRef:ee}),[v,b]),We=p.useMemo(()=>({continuousPlay:$,annotations:T,activeAnnotationId:A,playbackRate:E,isAutomaticScroll:Z}),[$,T,A,E,Z]),Oe=p.useRef(m);Oe.current=m;const ze=p.useCallback(q=>{const pe=typeof q=="function"?q(R.current):q;if(!Oe.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}Oe.current(pe)},[]),Xe=p.useMemo(()=>({play:U,pause:Je,stop:Te,seekTo:ce,setPlaybackRate:He,setContinuousPlay:ae,setAnnotations:ze,setActiveAnnotationId:z,setAutomaticScroll:q=>{G(q)},setScrollContainer:ke,scrollContainerRef:le}),[U,Je,Te,ce,He,ae,ze,z,ke]),ft=p.useMemo(()=>({duration:_,peaksDataArray:S,sampleRate:ue,waveHeight:n,timeScaleHeight:Ne,samplesPerPixel:O,playoutRef:Y,controls:i,barWidth:c,barGap:u,progressBarWidth:g}),[_,S,ue,n,Ne,O,i,c,u,g]),bt={...Bd,...o};return C.jsx(F.ThemeProvider,{theme:bt,children:C.jsx(gf.Provider,{value:Qe,children:C.jsx(vf.Provider,{value:We,children:C.jsx(yf.Provider,{value:Xe,children:C.jsx(bf.Provider,{value:ft,children:h})})})})})},Nr=()=>{const e=p.useContext(gf);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},Qs=()=>{const e=p.useContext(vf);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},ki=()=>{const e=p.useContext(yf);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},ea=()=>{const e=p.useContext(bf);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},oy=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=ot(),{selectionStart:r,selectionEnd:s,isLoopEnabled:a}=it(),{play:o}=Ie(),i=async()=>{if(r!==s&&s>r&&!a){const c=s-r;await o(r,c)}else await o(n.current??0)};return C.jsx(yt,{onClick:i,disabled:t,className:e,children:"Play"})},iy=({className:e})=>{const{isPlaying:t}=ot(),{pause:n}=Ie();return C.jsx(yt,{onClick:n,disabled:!t,className:e,children:"Pause"})},ly=({className:e})=>{const{isPlaying:t}=ot(),{stop:n}=Ie();return C.jsx(yt,{onClick:n,disabled:!t,className:e,children:"Stop"})},cy=({className:e})=>{const{isPlaying:t}=ot(),{play:n,setCurrentTime:r}=Ie(),s=()=>{r(0),t&&n(0)};return C.jsx(yt,{onClick:s,className:e,children:"Rewind"})},uy=({className:e})=>{const{isPlaying:t}=ot(),{play:n,setCurrentTime:r}=Ie(),{duration:s}=lt(),a=()=>{r(s),t&&n(s)};return C.jsx(yt,{onClick:a,className:e,children:"Fast Forward"})},dy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ot(),{play:s,setCurrentTime:a}=Ie(),o=()=>{const i=Math.max(0,(n.current??0)-e);a(i),r&&s(i)};return C.jsx(yt,{onClick:o,className:t,children:"Skip Backward"})},fy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ot(),{play:s,setCurrentTime:a}=Ie(),{duration:o}=lt(),i=()=>{const l=Math.min(o,(n.current??0)+e);a(l),r&&s(l)};return C.jsx(yt,{onClick:i,className:t,children:"Skip Forward"})},hy=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=it(),{setLoopEnabled:s,setLoopRegion:a}=Ie(),{duration:o}=lt(),i=n!==r&&r>n,l=()=>{if(!t&&!i){const c=Math.min(10,o*.25);a(0,Math.max(1,c))}s(!t)};return C.jsx(yt,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},py=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=it(),{setLoopRegionFromSelection:a,clearLoopRegion:o}=Ie(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?o():a()};return C.jsx(yt,{onClick:c,disabled:!i&&!l,className:e,title:l?"Clear loop region":i?"Set loop region from selection":"Create a selection first",children:l?"Clear Loop":"Set Loop"})},my=({onClearAll:e,label:t="Clear All",className:n})=>{const{stop:r}=Ie(),s=p.useCallback(()=>{r(),e()},[r,e]);return C.jsx(yt,{onClick:s,className:n,title:"Remove all tracks",children:t})},gy=({className:e,disabled:t})=>{const{zoomIn:n}=Ie(),{canZoomIn:r}=lt();return C.jsx(yt,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},vy=({className:e,disabled:t})=>{const{zoomOut:n}=Ie(),{canZoomOut:r}=lt();return C.jsx(yt,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},yy=({className:e})=>{const{masterVolume:t}=lt(),{setMasterVolume:n}=Ie();return C.jsx(iv,{volume:t,onChange:n,className:e})},by=({className:e})=>{const{timeFormat:t}=lt(),{setTimeFormat:n}=Ie();return C.jsx(Uv,{value:t,onChange:n,className:e})},wy=F.span`
|
|
1004
|
+
`;let q0=0;function J0(){let e;try{const r=new Blob([K0],{type:"application/javascript"}),s=URL.createObjectURL(r);e=new Worker(s),URL.revokeObjectURL(s)}catch(r){return console.warn("[waveform-playlist] Failed to create peaks worker (CSP restriction?):",r),{generate(){return Promise.reject(new Error("Worker creation failed"))},terminate(){}}}const t=new Map;let n=!1;return e.onmessage=r=>{const s=r.data,a=t.get(s.id);if(a)if(t.delete(s.id),s.error)a.reject(new Error(s.error));else try{const o=mt.create(s.buffer);a.resolve(o)}catch(o){a.reject(o)}},e.onerror=r=>{n=!0,e.terminate();for(const[,s]of t)s.reject(r.error??new Error(r.message));t.clear()},{generate(r){if(n)return Promise.reject(new Error("Worker terminated"));const s=String(++q0);return new Promise((a,o)=>{t.set(s,{resolve:a,reject:o}),e.postMessage({id:s,scale:r.scale,bits:r.bits,amplitude_scale:1,split_channels:r.splitChannels,length:r.length,sample_rate:r.sampleRate,channels:r.channels},r.channels)})},terminate(){n=!0,e.terminate();for(const[,r]of t)r.reject(new Error("Worker terminated"));t.clear()}}}function Q0(e,t){const[n,r]=p.useState(()=>new Map),[s,a]=p.useState(!1),o=p.useRef(null),i=p.useRef(new WeakMap),l=p.useRef(new WeakMap),c=p.useRef(new WeakMap),u=p.useRef(0),f=p.useCallback(()=>(o.current||(o.current=J0()),o.current),[]);return p.useEffect(()=>{let m=!1;const d=i.current,h=l.current,v=c.current,g=[],y=new Map;for(const _ of e)for(const w of _.clips){if(!w.audioBuffer||w.waveformData)continue;const x=d.get(w.audioBuffer);if(x){g.push({clipId:w.id,waveformData:x});continue}if(h.get(w.audioBuffer)){const k=v.get(w.audioBuffer);k?k.add(w.id):v.set(w.audioBuffer,new Set([w.id]));continue}const S=y.get(w.audioBuffer);S?S.add(w.id):y.set(w.audioBuffer,new Set([w.id]))}if(g.length>0&&r(_=>{const w=new Map(_);for(const x of g)w.set(x.clipId,x.waveformData);return w}),y.size===0)return;u.current+=y.size,a(!0);const b=f();for(const[_,w]of y){v.set(_,new Set(w));const x=[];for(let E=0;E<_.numberOfChannels;E++)x.push(_.getChannelData(E).slice().buffer);const S=`buffer-${Math.random().toString(36).slice(2,11)}`,k=b.generate({id:S,channels:x,length:_.length,sampleRate:_.sampleRate,scale:t,bits:16,splitChannels:!0}).then(E=>{d.set(_,E);const M=v.get(_)??new Set;v.delete(_),h.delete(_),!m&&(r(T=>{const $=new Map(T);for(const A of M)$.set(A,E);return $}),u.current--,u.current<=0&&(u.current=0,a(!1)))}).catch(E=>{v.delete(_),h.delete(_),!m&&(console.warn("[waveform-playlist] Worker peak generation failed:",E),u.current--,u.current<=0&&(u.current=0,a(!1)))});h.set(_,k)}return()=>{m=!0,l.current=new WeakMap,c.current=new WeakMap,u.current=0,a(!1)}},[e,t,f]),p.useEffect(()=>()=>{o.current?.terminate(),o.current=null},[]),{cache:n,isGenerating:s}}function po(e){return e instanceof File?e.name.replace(/\.[^/.]+$/,""):e instanceof Blob?"Untitled":typeof e=="string"?e.split("/").pop()?.replace(/\.[^/.]+$/,"")??"Untitled":e.name??e.src.split("/").pop()?.replace(/\.[^/.]+$/,"")??"Untitled"}async function ey(e,t,n){const r=po(e);if(e instanceof Blob){const l=await e.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(l),name:r}}const s=typeof e=="string"?e:e.src,a=await fetch(s,{signal:n});if(!a.ok)throw new Error(`Failed to fetch ${s}: ${a.statusText}`);const o=await a.arrayBuffer();return n?.throwIfAborted(),{audioBuffer:await t.decodeAudioData(o),name:r}}function ty(){const[e,t]=p.useState([]),[n,r]=p.useState(0),[s,a]=p.useState([]),o=p.useRef(!1),i=p.useRef(new Set),l=p.useRef(new Map);p.useEffect(()=>{const f=l.current;return()=>{o.current=!0;for(const m of f.values())m.abort();f.clear()}},[]);const c=p.useCallback(f=>{if(f.length===0)return;const m=gh(),d=f.map(h=>({track:dc({name:`${po(h)} (loading...)`,clips:[]}),source:h}));t(h=>[...h,...d.map(v=>v.track)]),r(h=>h+f.length);for(const{track:h,source:v}of d){i.current.add(h.id);const g=new AbortController;l.current.set(h.id,g),(async()=>{try{const{audioBuffer:y,name:b}=await ey(v,m,g.signal),_=uc({audioBuffer:y,startTime:0,duration:y.duration,offset:0,name:b});!o.current&&i.current.has(h.id)&&t(w=>w.map(x=>x.id===h.id?{...x,name:b,clips:[_]}:x))}catch(y){if(y instanceof DOMException&&y.name==="AbortError")return;console.warn("[waveform-playlist] Error loading audio:",y),!o.current&&i.current.has(h.id)&&(t(b=>b.filter(_=>_.id!==h.id)),a(b=>[...b,{name:po(v),error:y instanceof Error?y:new Error(String(y))}]))}finally{l.current.delete(h.id),!o.current&&i.current.delete(h.id)&&r(y=>y-1)}})()}},[]),u=p.useCallback(f=>{t(d=>d.filter(h=>h.id!==f));const m=l.current.get(f);m&&(m.abort(),l.current.delete(f)),i.current.delete(f)&&r(d=>d-1)},[]);return{tracks:e,addTracks:c,removeTrack:u,loadingCount:n,isLoading:n>0,errors:s}}const hf=p.createContext(null),pf=p.createContext(null),mf=p.createContext(null),gf=p.createContext(null),ny=({tracks:e,timescale:t=!1,mono:n=!1,waveHeight:r=80,samplesPerPixel:s=1024,zoomLevels:a,automaticScroll:o=!1,theme:i,controls:l={show:!1,width:0},annotationList:c,effects:u,onReady:f,onAnnotationUpdate:m,onAnnotationsChange:d,barWidth:h=1,barGap:v=0,progressBarWidth:g,onTracksChange:y,soundFontCache:b,deferEngineRebuild:_=!1,children:w})=>{const x=g??h+v,S=p.useMemo(()=>a,[a?.join(",")]),k=p.useMemo(()=>{if(!c?.annotations)return[];if(process.env.NODE_ENV!=="production"&&c.annotations.length>0){const V=c.annotations[0];if(typeof V.start!="number"||typeof V.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof V.start),[]}return c.annotations},[c?.annotations]),E=p.useRef(k);E.current=k;const[M,T]=p.useState(null),[$,A]=p.useState(!1),[I,R]=p.useState(0),[D,O]=p.useState(0),[Z,G]=p.useState([]),[Y,te]=p.useState([]),[X,K]=p.useState([]),[le,J]=p.useState(o),[de,ue]=p.useState(c?.isContinuousPlay??!1),[ne,z]=p.useState(c?.linkEndpoints??!1),[ae,ke]=p.useState(c?.editable??!1),[ce,xe]=p.useState(!1),B=p.useRef(null),_e=p.useRef(!1),re=p.useRef(!1);re.current=$;const Me=p.useRef(0),pe=p.useRef(0),Ae=p.useRef(e),He=p.useRef(b);He.current=b;const qe=p.useRef(X),Ve=p.useRef(0),Le=p.useRef(0),je=p.useRef(null),tt=p.useRef(null),Ct=p.useRef(!1),St=p.useRef(c?.isContinuousPlay??!1),j=p.useRef(null),ge=p.useRef(null),Ge=p.useRef(0),Ue=p.useRef(!1),oe=p.useRef(!1),ve=p.useRef(s),Xe=p.useRef(44100),{timeFormat:kt,setTimeFormat:N,formatTime:q}=tf(),U=nf({engineRef:B,initialSamplesPerPixel:s}),{samplesPerPixel:Q,onEngineState:Te}=U,De=rf({engineRef:B,initialVolume:1}),{masterVolume:ee,setMasterVolume:Ne,masterVolumeRef:Je,onEngineState:Ye}=De,{selectionStart:Et,selectionEnd:Dt,setSelection:en,selectionStartRef:Pt,selectionEndRef:zt,onEngineState:Yn}=A0({engineRef:B}),{isLoopEnabled:Zr,loopStart:Hr,loopEnd:$i,setLoopEnabled:Ri,setLoopRegion:Gr,clearLoopRegion:Di,isLoopEnabledRef:Pi,loopStartRef:Fi,loopEndRef:Oi,onEngineState:Li}=T0({engineRef:B}),{selectedTrackId:Bi,setSelectedTrackId:Wi,onEngineState:Vi,selectedTrackIdRef:Ni}=$0({engineRef:B}),{animationFrameRef:zi,startAnimationFrameLoop:sa,stopAnimationFrameLoop:Ur}=ff(),zf=p.useMemo(()=>Math.min(...S??[256,512,1024,2048,4096,8192]),[S]),{cache:ji}=Q0(e,zf),Zi=p.useCallback(V=>{St.current=V,ue(V)},[]),Ft=p.useCallback(V=>{j.current=V,T(V)},[]),Hi=p.useCallback(()=>{const V=Pt.current??0,H=zt.current??0;V!==H&&H>V&&Gr(V,H)},[Gr,Pt,zt]);p.useEffect(()=>{Ct.current=le},[le]),p.useEffect(()=>{qe.current=X},[X]),Ae.current=e;const aa=e===ge.current;Ue.current=aa||oe.current,p.useEffect(()=>{if(!tt.current||D===0)return;const V=tt.current,H=ve.current,me=Q;if(H===me)return;const W=V.clientWidth,$e=V.scrollLeft+W/2,Ee=Xe.current,ca=$e*H/Ee*Ee/me,qr=Math.max(0,ca-W/2);V.scrollLeft=qr,ve.current=me},[Q,D]);const Xr=p.useRef(null);p.useEffect(()=>{if(aa||oe.current){aa&&(ge.current=null);let W=0;e.forEach(Ce=>{Ce.clips.forEach($e=>{const Ee=($e.startSample+$e.durationSamples)/$e.sampleRate;W=Math.max(W,Ee)})}),O(W);return}if(_){let W=0;e.forEach(Ce=>{Ce.clips.forEach($e=>{const Ee=($e.startSample+$e.durationSamples)/$e.sampleRate;W=Math.max(W,Ee)})}),O(W);return}if(xe(!1),e.length===0){G([]),O(0),K([]),te([]),B.current&&(B.current.dispose(),B.current=null);return}const V=re.current,H=pe.current;return B.current&&V&&(B.current.stop(),Ur(),Xr.current={position:H}),(async()=>{try{const W=[];e.forEach(Re=>{Re.clips.length>0&&Re.clips[0].audioBuffer&&W.push(Re.clips[0].audioBuffer)});let Ce=0;e.forEach(Re=>{Re.clips.forEach(ht=>{const jt=ht.sampleRate,Yf=(ht.startSample+ht.durationSamples)/jt;Ce=Math.max(Ce,Yf)})}),G(W),O(Ce),K(Re=>Re.length===e.length?Re.map((ht,jt)=>({...ht,name:e[jt].name})):e.map(ht=>({name:ht.name,muted:ht.muted,soloed:ht.soloed,volume:ht.volume,pan:ht.pan}))),B.current&&B.current.dispose(),Ge.current=0,ge.current=null,_e.current=!1;const $e=vh({effects:u,soundFontCache:He.current}),Ee=new Sh({adapter:$e,samplesPerPixel:ve.current,zoomLevels:S});Ee.setSelection(Pt.current??0,zt.current??0),Ee.setLoopRegion(Fi.current??0,Oi.current??0),Pi.current&&Ee.setLoopEnabled(!0),Ee.setMasterVolume(Je.current??1),Ni.current&&Ee.selectTrack(Ni.current);const Kr=qe.current,ca=e.map((Re,ht)=>{const jt=Kr[ht];return{...Re,volume:jt?.volume??Re.volume,muted:jt?.muted??Re.muted,soloed:jt?.soloed??Re.soloed,pan:jt?.pan??Re.pan}});let qr=!0;Ee.on("statechange",Re=>{Yn(Re),Li(Re),Vi(Re),Te(Re),Ye(Re),!qr&&Re.tracksVersion!==Ge.current&&(Ge.current=Re.tracksVersion,ge.current=Re.tracks,y?y(Re.tracks):console.warn("[waveform-playlist] Engine tracks changed but onTracksChange prop is not set — UI will revert on next render. Pass onTracksChange to WaveformPlaylistProvider."))}),Ee.setTracks(ca),qr=!1,Ge.current=Ee.getState().tracksVersion,B.current=Ee,xe(!0);const Xf=new CustomEvent("waveform-playlist:ready",{detail:{trackCount:e.length,duration:Ce}});window.dispatchEvent(Xf),f?.()}catch(W){console.error("Error loading audio:",W)}})(),()=>{if(Ue.current){Ue.current=!1;return}Ur(),B.current&&B.current.dispose()}},[e,f,u,Ur,Yn,Li,Vi,Te,Ye,y,Je,Pt,zt,Fi,Oi,Pi,S,b,_]),p.useEffect(()=>{if(e.length===0)return;const V=e.map(H=>H.clips.map(W=>{let Ce;if(W.waveformData)try{Ce=Ql(W.waveformData,Q,n,W.offsetSamples,W.durationSamples)}catch($e){console.warn("[waveform-playlist] Failed to extract peaks from waveformData:",$e)}if(!Ce){const $e=ji.get(W.id);if($e)try{Ce=Ql($e,Q,n,W.offsetSamples,W.durationSamples)}catch(Ee){console.warn("[waveform-playlist] Failed to extract peaks from cache:",Ee)}}if(!Ce){!_&&!W.audioBuffer&&!W.waveformData&&!W.midiNotes&&console.warn(`[waveform-playlist] Clip "${W.id}" has no audio data or waveform data`);const $e=n?1:W.audioBuffer?.numberOfChannels??1,Ee=W.midiNotes?Math.ceil(W.durationSamples/Q):0;Ce={length:Ee,data:Array.from({length:$e},()=>new Int16Array(Ee*2)),bits:16}}return{clipId:W.id,trackName:H.name,peaks:Ce,startSample:W.startSample,durationSamples:W.durationSamples,fadeIn:W.fadeIn,fadeOut:W.fadeOut,midiNotes:W.midiNotes,sampleRate:W.sampleRate,offsetSamples:W.offsetSamples}}));te(V)},[e,Q,n,ji,_]);const Gi=p.useRef(!1),xn=p.useCallback(()=>{if(B.current)return B.current.getCurrentTime();Gi.current||(Gi.current=!0,console.warn("[waveform-playlist] getPlaybackTime called without engine. Falling back to manual elapsed time (loop wrapping will not work)."));const V=L.getContext().currentTime-(Ve.current??0);return(Le.current??0)+V},[]),tn=p.useCallback(()=>{const V=()=>{const H=xn();pe.current=H;const me=E.current;if(me.length>0){const W=me.find(Ce=>H>=Ce.start&&H<Ce.end);if(St.current)W&&W.id!==j.current?Ft(W.id):!W&&j.current!==null&&Ft(null);else if(j.current){const Ce=me.find($e=>$e.id===j.current);if(Ce&&H>=Ce.end){B.current&&B.current.stop(),A(!1),pe.current=Me.current,R(Me.current);return}}else W&&Ft(W.id)}if(Ct.current&&tt.current&&D>0){const W=tt.current,Ce=Xe.current,$e=H*Ce/ve.current,Ee=W.clientWidth,Kr=Math.max(0,$e-Ee/2);W.scrollLeft=Kr}if(je.current!==null&&H>=je.current){B.current&&B.current.stop(),A(!1),pe.current=je.current,R(je.current),je.current=null;return}if(H>=D){B.current&&B.current.stop(),A(!1),pe.current=Me.current,R(Me.current),Ft(null);return}sa(V)};sa(V)},[D,Ft,sa,xn]),ft=Ur;p.useEffect(()=>{(async()=>{if($&&zi.current&&B.current)if(de){const H=pe.current;B.current.stop(),ft();const W=L.getContext().currentTime;Ve.current=W,Le.current=H,B.current.play(H),tn()}else ft(),tn()})().catch(H=>{console.warn("[waveform-playlist] Failed to reschedule playback:",H),A(!1),ft()})},[de,$,tn,ft,zi]),p.useEffect(()=>{(async()=>{if(Xr.current&&B.current){const{position:H}=Xr.current;Xr.current=null;const W=L.getContext().currentTime;Ve.current=W,Le.current=H,_e.current||(await B.current.init(),_e.current=!0),B.current.play(H),A(!0),tn()}})().catch(H=>{console.warn("[waveform-playlist] Failed to resume playback after track change:",H),A(!1),ft()})},[e,tn,ft]);const Yr=p.useCallback(async(V,H)=>{if(!B.current||D===0)return;const me=V??pe.current;Me.current=me,pe.current=me,B.current.stop(),B.current.seek(me),ft();const Ce=L.getContext().currentTime;Ve.current=Ce,Le.current=me,je.current=H!==void 0?me+H:null,_e.current||(await B.current.init(),_e.current=!0);const $e=H!==void 0?me+H:void 0;try{B.current.play(me,$e)}catch(Ee){console.warn("[waveform-playlist] Playback failed to start:",Ee),ft();return}A(!0),tn()},[D,tn,ft]),Ui=p.useCallback(()=>{if(!B.current)return;const V=xn();B.current.pause(),A(!1),ft(),pe.current=V,R(V)},[ft,xn]),Xi=p.useCallback(()=>{B.current&&(B.current.stop(),A(!1),ft(),pe.current=Me.current,R(Me.current),Ft(null))},[ft,Ft]),Yi=p.useCallback(V=>{const H=Math.max(0,Math.min(V,D));pe.current=H,R(H),$&&B.current&&Yr(H)},[D,$,Yr]),Ki=p.useCallback((V,H)=>{const me=Ae.current[V]?.id;if(!me)return;const W=[...X];W[V]={...W[V],muted:H},K(W),B.current&&B.current.setTrackMute(me,H)},[X]),qi=p.useCallback((V,H)=>{const me=Ae.current[V]?.id;if(!me)return;const W=[...X];W[V]={...W[V],soloed:H},K(W),B.current&&B.current.setTrackSolo(me,H)},[X]),Ji=p.useCallback((V,H)=>{const me=Ae.current[V]?.id;if(!me)return;const W=[...X];W[V]={...W[V],volume:H},K(W),B.current&&B.current.setTrackVolume(me,H)},[X]),Qi=p.useCallback((V,H)=>{const me=Ae.current[V]?.id;if(!me)return;const W=[...X];W[V]={...W[V],pan:H},K(W),B.current&&B.current.setTrackPan(me,H)},[X]),el=p.useCallback((V,H)=>{en(V,H),pe.current=V,R(V),$&&B.current&&(B.current.stop(),B.current.seek(V),B.current.play(V))},[$,en]),tl=p.useCallback(V=>{tt.current=V},[]),oa=p.useRef(d);oa.current=d;const nl=p.useCallback(V=>{const H=typeof V=="function"?V(E.current):V;if(!oa.current){process.env.NODE_ENV!=="production"&&console.warn("waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to WaveformPlaylistProvider to handle annotation updates.");return}oa.current(H)},[]),ia=Z[0]?.sampleRate||e[0]?.clips[0]?.sampleRate||44100;Xe.current=ia;const la=t?30:0,rl=e.length*r+la,jf=p.useMemo(()=>({isPlaying:$,currentTime:I,currentTimeRef:pe,playbackStartTimeRef:Ve,audioStartPositionRef:Le,getPlaybackTime:xn}),[$,I,pe,Ve,Le,xn]),Zf=p.useMemo(()=>({continuousPlay:de,linkEndpoints:ne,annotationsEditable:ae,isAutomaticScroll:le,isLoopEnabled:Zr,annotations:k,activeAnnotationId:M,selectionStart:Et,selectionEnd:Dt,selectedTrackId:Bi,loopStart:Hr,loopEnd:$i}),[de,ne,ae,le,Zr,k,M,Et,Dt,Bi,Hr,$i]),sl=p.useCallback(V=>{pe.current=V,R(V)},[pe]),al=p.useCallback(V=>{J(V)},[]),Hf=p.useMemo(()=>({play:Yr,pause:Ui,stop:Xi,seekTo:Yi,setCurrentTime:sl,setTrackMute:Ki,setTrackSolo:qi,setTrackVolume:Ji,setTrackPan:Qi,setSelection:el,setSelectedTrackId:Wi,setTimeFormat:N,formatTime:q,zoomIn:U.zoomIn,zoomOut:U.zoomOut,setMasterVolume:Ne,setAutomaticScroll:al,setScrollContainer:tl,scrollContainerRef:tt,setContinuousPlay:Zi,setLinkEndpoints:z,setAnnotationsEditable:ke,setAnnotations:nl,setActiveAnnotationId:Ft,setLoopEnabled:Ri,setLoopRegion:Gr,setLoopRegionFromSelection:Hi,clearLoopRegion:Di}),[Yr,Ui,Xi,Yi,sl,Ki,qi,Ji,Qi,el,Wi,N,q,U.zoomIn,U.zoomOut,Ne,al,tl,tt,Zi,z,ke,nl,Ft,Ri,Gr,Hi,Di]),Gf=p.useMemo(()=>({duration:D,audioBuffers:Z,peaksDataArray:Y,trackStates:X,tracks:e,sampleRate:ia,waveHeight:r,timeScaleHeight:la,minimumPlaylistHeight:rl,controls:l,playoutRef:B,samplesPerPixel:Q,timeFormat:kt,masterVolume:ee,canZoomIn:U.canZoomIn,canZoomOut:U.canZoomOut,barWidth:h,barGap:v,progressBarWidth:x,isReady:ce,mono:n,isDraggingRef:oe,onTracksChange:y}),[D,Z,Y,X,e,ia,r,la,rl,l,B,Q,kt,ee,U.canZoomIn,U.canZoomOut,h,v,x,ce,n,oe,y]),Uf={...Wd,...i};return C.jsx(F.ThemeProvider,{theme:Uf,children:C.jsx(hf.Provider,{value:jf,children:C.jsx(pf.Provider,{value:Zf,children:C.jsx(mf.Provider,{value:Hf,children:C.jsx(gf.Provider,{value:Gf,children:w})})})})})},ot=()=>{const e=p.useContext(hf);if(!e)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return e},it=()=>{const e=p.useContext(pf);if(!e)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return e},Ie=()=>{const e=p.useContext(mf);if(!e)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return e},lt=()=>{const e=p.useContext(gf);if(!e)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return e};var ry=class{constructor(e){this._playbackRate=1,this.handleEnded=()=>{this.onStopCallback&&this.onStopCallback()},this.handleTimeUpdate=()=>{this.onTimeUpdateCallback&&this.onTimeUpdateCallback(this.audioElement.currentTime)},this._peaks=e.peaks,this._id=e.id??`track-${Date.now()}`,this._name=e.name??"Track",this._playbackRate=e.playbackRate??1,typeof e.source=="string"?(this.audioElement=new Audio(e.source),this.ownsElement=!0):(this.audioElement=e.source,this.ownsElement=!1),this.audioElement.preload="auto",this.audioElement.volume=e.volume??1,this.audioElement.playbackRate=this._playbackRate;const t=this.audioElement;"preservesPitch"in this.audioElement?t.preservesPitch=!0:"mozPreservesPitch"in this.audioElement?t.mozPreservesPitch=!0:"webkitPreservesPitch"in this.audioElement&&(t.webkitPreservesPitch=!0),this.audioElement.addEventListener("ended",this.handleEnded),this.audioElement.addEventListener("timeupdate",this.handleTimeUpdate)}play(e=0){this.audioElement.currentTime=e,this.audioElement.play().catch(t=>{console.warn("MediaElementTrack: play() failed:",t)})}pause(){this.audioElement.pause()}stop(){this.audioElement.pause(),this.audioElement.currentTime=0}seekTo(e){this.audioElement.currentTime=Math.max(0,Math.min(e,this.duration))}setVolume(e){this.audioElement.volume=Math.max(0,Math.min(1,e))}setPlaybackRate(e){const t=Math.max(.5,Math.min(2,e));this._playbackRate=t,this.audioElement.playbackRate=t}setMuted(e){this.audioElement.muted=e}setOnStopCallback(e){this.onStopCallback=e}setOnTimeUpdateCallback(e){this.onTimeUpdateCallback=e}dispose(){this.audioElement.removeEventListener("ended",this.handleEnded),this.audioElement.removeEventListener("timeupdate",this.handleTimeUpdate),this.audioElement.pause(),this.ownsElement&&(this.audioElement.src="",this.audioElement.load())}get id(){return this._id}get name(){return this._name}get peaks(){return this._peaks}get currentTime(){return this.audioElement.currentTime}get duration(){return this.audioElement.duration||this._peaks.duration}get isPlaying(){return!this.audioElement.paused&&!this.audioElement.ended}get volume(){return this.audioElement.volume}get playbackRate(){return this._playbackRate}get muted(){return this.audioElement.muted}get element(){return this.audioElement}},sy=class{constructor(e={}){this.track=null,this._isPlaying=!1,this._masterVolume=e.masterVolume??1,this._playbackRate=e.playbackRate??1}async init(){}addTrack(e){return this.track&&(console.warn("MediaElementPlayout: Only one track is supported. Disposing previous track. For multi-track, use TonePlayout."),this.track.dispose()),this.track=new ry({...e,volume:this._masterVolume*(e.volume??1),playbackRate:this._playbackRate}),this.track.setOnStopCallback(()=>{this._isPlaying=!1,this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback()}),this.track}removeTrack(e){this.track&&this.track.id===e&&(this.track.dispose(),this.track=null)}getTrack(e){if(this.track&&this.track.id===e)return this.track}play(e,t,n){if(!this.track){console.warn("MediaElementPlayout: No track to play");return}const r=t??0;if(this._isPlaying=!0,this.track.play(r),n!==void 0){const s=n/this._playbackRate;setTimeout(()=>{this._isPlaying&&(this.pause(),this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())},s*1e3)}}pause(){this.track&&this.track.pause(),this._isPlaying=!1}stop(){this.track&&this.track.stop(),this._isPlaying=!1}seekTo(e){this.track&&this.track.seekTo(e)}getCurrentTime(){return this.track?this.track.currentTime:0}setMasterVolume(e){this._masterVolume=Math.max(0,Math.min(1,e)),this.track&&this.track.setVolume(this._masterVolume)}setPlaybackRate(e){this._playbackRate=Math.max(.5,Math.min(2,e)),this.track&&this.track.setPlaybackRate(this._playbackRate)}setMute(e,t){const n=this.getTrack(e);n&&n.setMuted(t)}setSolo(e,t){console.warn("MediaElementPlayout: Solo is not applicable for single-track playback")}setOnPlaybackComplete(e){this.onPlaybackCompleteCallback=e}dispose(){this.track&&(this.track.dispose(),this.track=null)}get isPlaying(){return this._isPlaying}get masterVolume(){return this._masterVolume}get playbackRate(){return this._playbackRate}get duration(){return this.track?.duration??0}get sampleRate(){return this.track?.peaks.sample_rate??44100}};const vf=p.createContext(null),yf=p.createContext(null),bf=p.createContext(null),wf=p.createContext(null),ay=({track:e,samplesPerPixel:t=1024,waveHeight:n=100,timescale:r=!1,playbackRate:s=1,automaticScroll:a=!1,theme:o,controls:i={show:!1,width:0},annotationList:l,barWidth:c=1,barGap:u=0,progressBarWidth:f,onAnnotationsChange:m,onReady:d,children:h})=>{const v=f??c+u,[g,y]=p.useState(!1),[b,_]=p.useState(0),[w,x]=p.useState(0),[S,k]=p.useState([]),[E,M]=p.useState(s),T=p.useMemo(()=>{if(!l?.annotations)return[];if(process.env.NODE_ENV!=="production"&&l.annotations.length>0){const j=l.annotations[0];if(typeof j.start!="number"||typeof j.end!="number")return console.error("[waveform-playlist] Annotations must have numeric start/end values. In v6, use parseAeneas() from @waveform-playlist/annotations before passing annotations. Received start type: "+typeof j.start),[]}return l.annotations},[l?.annotations]),$=p.useRef(T);$.current=T;const[A,I]=p.useState(null),[R,D]=p.useState(l?.isContinuousPlay??!1),[O]=p.useState(t),[Z,G]=p.useState(a),Y=p.useRef(null),te=p.useRef(0),X=p.useRef(R),K=p.useRef(null),le=p.useRef(null),J=p.useRef(a),de=p.useRef(t),{startAnimationFrameLoop:ue,stopAnimationFrameLoop:ne}=ff();p.useEffect(()=>{X.current=R},[R]),p.useEffect(()=>{J.current=Z},[Z]);const z=p.useCallback(j=>{K.current=j,I(j)},[]),ae=p.useCallback(j=>{X.current=j,D(j)},[]),ke=p.useCallback(j=>{le.current=j},[]),ce=e.waveformData.sample_rate;p.useEffect(()=>{const j=new sy({playbackRate:s});j.addTrack({source:e.source,peaks:e.waveformData,name:e.name});const ge=j.getTrack(j.track?.id??"");return ge&&ge.setOnTimeUpdateCallback(Ge=>{te.current=Ge}),j.setOnPlaybackComplete(()=>{ne(),y(!1),z(null),te.current=0,_(0)}),Y.current=j,x(e.waveformData.duration),d?.(),()=>{ne(),j.dispose()}},[e.source,e.waveformData,e.name,s,d,ne,z]),p.useEffect(()=>{try{const j=M0(e.waveformData,O,0,0,Math.ceil(e.waveformData.duration*ce)),ge={clipId:"media-element-clip",trackName:e.name??"Track",peaks:{length:j.length,data:[j.data],bits:j.bits},startSample:0,durationSamples:Math.ceil(e.waveformData.duration*ce)};k([[ge]])}catch(j){console.warn("[waveform-playlist] Failed to extract peaks from waveform data:",j)}},[e.waveformData,e.name,O,ce]);const xe=p.useCallback(()=>{const j=()=>{const ge=Y.current?.getCurrentTime()??0;te.current=ge;const Ge=$.current;if(Ge.length>0){const Ue=Ge.find(oe=>ge>=oe.start&&ge<oe.end);if(X.current)Ue&&Ue.id!==K.current?z(Ue.id):!Ue&&K.current!==null&&z(null);else if(K.current){const oe=Ge.find(ve=>ve.id===K.current);if(oe&&ge>=oe.end){Y.current?.stop(),y(!1);return}}else Ue&&z(Ue.id)}if(J.current&&le.current){const Ue=le.current,oe=ge*ce/de.current,ve=Ue.clientWidth,Xe=Math.max(0,oe-ve/2);Ue.scrollLeft=Xe}ue(j)};ue(j)},[z,ce,ue]),B=ne,_e=p.useCallback(j=>{if(!Y.current)return;const ge=j??te.current;Y.current.play(void 0,ge),y(!0),xe()},[xe]),re=p.useCallback(()=>{Y.current&&(Y.current.pause(),y(!1),B(),_(Y.current.getCurrentTime()))},[B]),Me=p.useCallback(()=>{Y.current&&(Y.current.stop(),y(!1),B(),te.current=0,_(0),z(null))},[B,z]),pe=p.useCallback(j=>{const ge=Math.max(0,Math.min(j,w));te.current=ge,_(ge),Y.current&&Y.current.seekTo(ge)},[w]),Ae=p.useCallback(j=>{const ge=Math.max(.5,Math.min(2,j));M(ge),Y.current&&Y.current.setPlaybackRate(ge)},[]),He=r?30:0,qe=p.useMemo(()=>({isPlaying:g,currentTime:b,currentTimeRef:te}),[g,b]),Ve=p.useMemo(()=>({continuousPlay:R,annotations:T,activeAnnotationId:A,playbackRate:E,isAutomaticScroll:Z}),[R,T,A,E,Z]),Le=p.useRef(m);Le.current=m;const je=p.useCallback(j=>{const ge=typeof j=="function"?j($.current):j;if(!Le.current){process.env.NODE_ENV!=="production"&&console.warn("waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to MediaElementPlaylistProvider to handle annotation updates.");return}Le.current(ge)},[]),tt=p.useMemo(()=>({play:_e,pause:re,stop:Me,seekTo:pe,setPlaybackRate:Ae,setContinuousPlay:ae,setAnnotations:je,setActiveAnnotationId:z,setAutomaticScroll:j=>{G(j)},setScrollContainer:ke,scrollContainerRef:le}),[_e,re,Me,pe,Ae,ae,je,z,ke]),Ct=p.useMemo(()=>({duration:w,peaksDataArray:S,sampleRate:ce,waveHeight:n,timeScaleHeight:He,samplesPerPixel:O,playoutRef:Y,controls:i,barWidth:c,barGap:u,progressBarWidth:v}),[w,S,ce,n,He,O,i,c,u,v]),St={...Wd,...o};return C.jsx(F.ThemeProvider,{theme:St,children:C.jsx(vf.Provider,{value:qe,children:C.jsx(yf.Provider,{value:Ve,children:C.jsx(bf.Provider,{value:tt,children:C.jsx(wf.Provider,{value:Ct,children:h})})})})})},zr=()=>{const e=p.useContext(vf);if(!e)throw new Error("useMediaElementAnimation must be used within MediaElementPlaylistProvider");return e},ea=()=>{const e=p.useContext(yf);if(!e)throw new Error("useMediaElementState must be used within MediaElementPlaylistProvider");return e},Ii=()=>{const e=p.useContext(bf);if(!e)throw new Error("useMediaElementControls must be used within MediaElementPlaylistProvider");return e},ta=()=>{const e=p.useContext(wf);if(!e)throw new Error("useMediaElementData must be used within MediaElementPlaylistProvider");return e},oy=({className:e})=>{const{isPlaying:t,currentTimeRef:n}=ot(),{selectionStart:r,selectionEnd:s,isLoopEnabled:a}=it(),{play:o}=Ie(),i=async()=>{if(r!==s&&s>r&&!a){const c=s-r;await o(r,c)}else await o(n.current??0)};return C.jsx(vt,{onClick:i,disabled:t,className:e,children:"Play"})},iy=({className:e})=>{const{isPlaying:t}=ot(),{pause:n}=Ie();return C.jsx(vt,{onClick:n,disabled:!t,className:e,children:"Pause"})},ly=({className:e})=>{const{isPlaying:t}=ot(),{stop:n}=Ie();return C.jsx(vt,{onClick:n,disabled:!t,className:e,children:"Stop"})},cy=({className:e})=>{const{isPlaying:t}=ot(),{play:n,setCurrentTime:r}=Ie(),s=()=>{r(0),t&&n(0)};return C.jsx(vt,{onClick:s,className:e,children:"Rewind"})},uy=({className:e})=>{const{isPlaying:t}=ot(),{play:n,setCurrentTime:r}=Ie(),{duration:s}=lt(),a=()=>{r(s),t&&n(s)};return C.jsx(vt,{onClick:a,className:e,children:"Fast Forward"})},dy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ot(),{play:s,setCurrentTime:a}=Ie(),o=()=>{const i=Math.max(0,(n.current??0)-e);a(i),r&&s(i)};return C.jsx(vt,{onClick:o,className:t,children:"Skip Backward"})},fy=({skipAmount:e=5,className:t})=>{const{currentTimeRef:n,isPlaying:r}=ot(),{play:s,setCurrentTime:a}=Ie(),{duration:o}=lt(),i=()=>{const l=Math.min(o,(n.current??0)+e);a(l),r&&s(l)};return C.jsx(vt,{onClick:i,className:t,children:"Skip Forward"})},hy=({className:e})=>{const{isLoopEnabled:t,loopStart:n,loopEnd:r}=it(),{setLoopEnabled:s,setLoopRegion:a}=Ie(),{duration:o}=lt(),i=n!==r&&r>n,l=()=>{if(!t&&!i){const c=Math.min(10,o*.25);a(0,Math.max(1,c))}s(!t)};return C.jsx(vt,{onClick:l,className:e,title:t?"Disable loop":"Enable loop",children:t?"Loop On":"Loop Off"})},py=({className:e})=>{const{selectionStart:t,selectionEnd:n,loopStart:r,loopEnd:s}=it(),{setLoopRegionFromSelection:a,clearLoopRegion:o}=Ie(),i=t!==n&&n>t,l=r!==s&&s>r,c=()=>{l?o():a()};return C.jsx(vt,{onClick:c,disabled:!i&&!l,className:e,title:l?"Clear loop region":i?"Set loop region from selection":"Create a selection first",children:l?"Clear Loop":"Set Loop"})},my=({onClearAll:e,label:t="Clear All",className:n})=>{const{stop:r}=Ie(),s=p.useCallback(()=>{r(),e()},[r,e]);return C.jsx(vt,{onClick:s,className:n,title:"Remove all tracks",children:t})},gy=({className:e,disabled:t})=>{const{zoomIn:n}=Ie(),{canZoomIn:r}=lt();return C.jsx(vt,{onClick:n,disabled:t||!r,className:e,children:"Zoom In"})},vy=({className:e,disabled:t})=>{const{zoomOut:n}=Ie(),{canZoomOut:r}=lt();return C.jsx(vt,{onClick:n,disabled:t||!r,className:e,children:"Zoom Out"})},yy=({className:e})=>{const{masterVolume:t}=lt(),{setMasterVolume:n}=Ie();return C.jsx(lv,{volume:t,onChange:n,className:e})},by=({className:e})=>{const{timeFormat:t}=lt(),{setTimeFormat:n}=Ie();return C.jsx(Xv,{value:t,onChange:n,className:e})},wy=F.span`
|
|
1005
1005
|
font-family: 'Courier New', Monaco, monospace;
|
|
1006
1006
|
font-size: 1rem;
|
|
1007
1007
|
font-weight: 600;
|
|
1008
1008
|
color: ${e=>e.theme?.textColor||"#333"};
|
|
1009
1009
|
user-select: none;
|
|
1010
|
-
`,_y=({className:e})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=ot(),{timeFormat:o}=lt();return p.useEffect(()=>{const i=()=>{if(t.current){const l=r?a():s.current??0;t.current.textContent=Pn(l,o)}r&&(n.current=requestAnimationFrame(i))};return r?n.current=requestAnimationFrame(i):i(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,o,s,a]),p.useEffect(()=>{!r&&t.current&&(t.current.textContent=Pn(s.current??0,o))}),C.jsx(wy,{ref:t,className:e,"aria-label":"Audio position",children:Pn(s.current??0,o)})},xy=({className:e})=>{const{selectionStart:t,selectionEnd:n}=it(),{setSelection:r}=Ie();return C.jsx(
|
|
1010
|
+
`,_y=({className:e})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=ot(),{timeFormat:o}=lt();return p.useEffect(()=>{const i=()=>{if(t.current){const l=r?a():s.current??0;t.current.textContent=Pn(l,o)}r&&(n.current=requestAnimationFrame(i))};return r?n.current=requestAnimationFrame(i):i(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,o,s,a]),p.useEffect(()=>{!r&&t.current&&(t.current.textContent=Pn(s.current??0,o))}),C.jsx(wy,{ref:t,className:e,"aria-label":"Audio position",children:Pn(s.current??0,o)})},xy=({className:e})=>{const{selectionStart:t,selectionEnd:n}=it(),{setSelection:r}=Ie();return C.jsx(kv,{selectionStart:t,selectionEnd:n,onSelectionChange:r,className:e})},Cy=({className:e})=>{const{isAutomaticScroll:t}=it(),{setAutomaticScroll:n}=Ie();return C.jsx(Og,{checked:t,onChange:n,className:e})},na=p.createContext(null),Sy=na.Provider;function _n(){const e=p.useContext(na);if(!e)throw new Error("useAnnotationIntegration must be used within <AnnotationProvider>. Install @waveform-playlist/annotations and wrap your app with <AnnotationProvider>. See: https://waveform-playlist.naomiaro.com/docs/guides/annotations");return e}const ky=({className:e})=>{const{ContinuousPlayCheckbox:t}=_n(),{continuousPlay:n}=it(),{setContinuousPlay:r}=Ie();return C.jsx(t,{checked:n,onChange:r,className:e})},Ey=({className:e})=>{const{LinkEndpointsCheckbox:t}=_n(),{linkEndpoints:n}=it(),{setLinkEndpoints:r}=Ie();return C.jsx(t,{checked:n,onChange:r,className:e})},Iy=({className:e})=>{const{EditableCheckbox:t}=_n(),{annotationsEditable:n}=it(),{setAnnotationsEditable:r}=Ie();return C.jsx(t,{checked:n,onChange:r,className:e})},My=({filename:e,className:t})=>{const{DownloadAnnotationsButton:n}=_n(),{annotations:r}=it();return C.jsx(n,{annotations:r,filename:e,className:t})},Ay=({label:e="Export WAV",filename:t="export",mode:n="master",trackIndex:r,bitDepth:s=16,applyEffects:a=!0,effectsFunction:o,createOfflineTrackEffects:i,className:l,onExportComplete:c,onExportError:u})=>{const{tracks:f,trackStates:m}=lt(),{exportWav:d,isExporting:h,progress:v}=df(),g=async()=>{try{const b=await d(f,m,{filename:t,mode:n,trackIndex:r,bitDepth:s,applyEffects:a,effectsFunction:o,createOfflineTrackEffects:i,autoDownload:!0});c?.(b.blob)}catch(b){u?.(b instanceof Error?b:new Error("Export failed"))}},y=h?`Exporting ${Math.round(v*100)}%`:e;return C.jsx(vt,{onClick:g,disabled:h||f.length===0,className:l,children:y})},_f=p.createContext(!1),Ty=_f.Provider;function xf(){return p.useContext(_f)}const $y=F.div.attrs(e=>({style:{width:`${e.$width}px`,background:e.$color}}))`
|
|
1011
1011
|
position: absolute;
|
|
1012
1012
|
top: 0;
|
|
1013
1013
|
left: 0;
|
|
@@ -1017,7 +1017,7 @@ self.onmessage = function(e) {
|
|
|
1017
1017
|
will-change: transform;
|
|
1018
1018
|
`,Ry=({color:e="#ff0000"})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s,getPlaybackTime:a}=ot(),{samplesPerPixel:o,sampleRate:i,progressBarWidth:l}=lt();return p.useEffect(()=>{const c=()=>{if(t.current){const f=(r?a():s.current??0)*i/o;t.current.style.transform=`translate3d(${f}px, 0, 0)`}r&&(n.current=requestAnimationFrame(c))};return r?n.current=requestAnimationFrame(c):c(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,i,o,s,a]),p.useEffect(()=>{if(!r&&t.current){const u=(s.current??0)*i/o;t.current.style.transform=`translate3d(${u}px, 0, 0)`}}),C.jsx($y,{ref:t,$color:e,$width:l,"data-playhead":!0})},Dy=F.div`
|
|
1019
1019
|
position: relative;
|
|
1020
|
-
`,
|
|
1020
|
+
`,Sa=F.div.attrs(e=>({style:{top:`${e.$top}px`,width:`${e.$width}px`,height:`${e.$height}px`,background:e.$color}}))`
|
|
1021
1021
|
position: absolute;
|
|
1022
1022
|
left: 0;
|
|
1023
1023
|
z-index: 0;
|
|
@@ -1035,13 +1035,13 @@ self.onmessage = function(e) {
|
|
|
1035
1035
|
`,Fy=F.div`
|
|
1036
1036
|
position: relative;
|
|
1037
1037
|
z-index: 2;
|
|
1038
|
-
`,
|
|
1038
|
+
`,nc=({clipStartSample:e,clipDurationSamples:t,midiNotes:n,clipSampleRate:r,clipOffsetSeconds:s,...a})=>{const o=p.useRef(null),i=p.useRef(null),l=Vr(),{waveHeight:c}=Js(),{isPlaying:u,currentTimeRef:f,getPlaybackTime:m}=ot(),{samplesPerPixel:d,sampleRate:h}=lt(),v=l?.waveProgressColor||"rgba(0, 0, 0, 0.1)",g=hc(e,t,d);p.useEffect(()=>{const $=()=>{if(o.current){const I=(u?m():f.current??0)*h,R=e+t;let D=0;I<=e?D=0:I>=R?D=1:D=(I-e)/t,o.current.style.transform=`scaleX(${D})`}u&&(i.current=requestAnimationFrame($))};return u?i.current=requestAnimationFrame($):$(),()=>{i.current&&(cancelAnimationFrame(i.current),i.current=null)}},[u,h,e,t,g,f,m]),p.useEffect(()=>{if(!u&&o.current){const A=(f.current??0)*h,I=e+t;let R=0;A<=e?R=0:A>=I?R=1:R=(A-e)/t,o.current.style.transform=`scaleX(${R})`}});const y=l?.waveformDrawMode||"inverted";let b;y==="inverted"?b=a.isSelected&&l?l.selectedWaveFillColor:l?.waveFillColor||"white":b=a.isSelected&&l?l.selectedWaveOutlineColor:l?.waveOutlineColor||"grey";const _=a.renderMode==="spectrogram"||a.renderMode==="both",w=a.renderMode==="piano-roll",x=a.renderMode==="both",S=_?"#000":w?l?.pianoRollBackgroundColor||"#1a1a2e":qt(b),k=Math.floor(c/2),E=c,M=a.index*c,T=qt(b);return C.jsxs(Dy,{children:[x?C.jsxs(C.Fragment,{children:[C.jsx(Sa,{$color:"#000",$height:k,$top:M,$width:a.length}),C.jsx(Sa,{$color:T,$height:k,$top:M+k,$width:a.length})]}):C.jsx(Sa,{$color:S,$height:E,$top:M,$width:a.length}),!w&&C.jsx(Py,{ref:o,$color:v,$height:E,$top:M,$width:g}),C.jsx(Fy,{children:C.jsx(Yd,{...a,transparentBackground:!0,midiNotes:n,sampleRate:r,clipOffsetSeconds:s})})]})},Mi=p.createContext(null),Oy=Mi.Provider;function Ly(){const e=p.useContext(Mi);if(!e)throw new Error("useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>.");return e}const By=60,Wy=F.div.attrs(e=>({style:{height:`${e.$height}px`}}))`
|
|
1039
1039
|
overflow: hidden;
|
|
1040
1040
|
pointer-events: auto;
|
|
1041
1041
|
background: ${e=>e.theme.surfaceColor};
|
|
1042
1042
|
transition: background 0.15s ease-in-out;
|
|
1043
1043
|
${e=>e.$isSelected&&`background: ${e.theme.selectedTrackControlsBackground};`}
|
|
1044
|
-
`,Vy=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:a,playbackStartTimeRef:o,audioStartPositionRef:i,getPlaybackTime:l}=ot();return e({position:(a.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:a,playbackStartTimeRef:o,audioStartPositionRef:i,samplesPerPixel:n,sampleRate:r,controlsOffset:0,getAudioContextTime:()=>L.getContext().currentTime,getPlaybackTime:l})},xf=({renderTrackControls:e,renderTick:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:s,className:a,showClipHeaders:o=!1,interactiveClips:i=!1,showFades:l=!1,touchOptimized:c=!1,onRemoveTrack:u,recordingState:f})=>{const m=Wr(),{isPlaying:d}=ot(),{selectionStart:h,selectionEnd:g,annotations:v,activeAnnotationId:y,annotationsEditable:b,linkEndpoints:w,continuousPlay:_,selectedTrackId:x,loopStart:S,loopEnd:k,isLoopEnabled:E}=it(),I=p.useContext(ta),{setAnnotations:T,setActiveAnnotationId:R,setTrackMute:A,setTrackSolo:M,setTrackVolume:$,setTrackPan:P,setSelection:O,play:Z,setScrollContainer:G,setSelectedTrackId:Y,setCurrentTime:ee,setLoopRegion:X}=Ie(),{peaksDataArray:K,trackStates:le,tracks:te,duration:fe,samplesPerPixel:de,sampleRate:ne,waveHeight:z,timeScaleHeight:ae,controls:ke,barWidth:ue,barGap:xe,isReady:B}=lt(),U=p.useContext(Ei),Je=p.useMemo(()=>{if(!U)return new Map;const N=new Map;return te.forEach(j=>{if((U.trackSpectrogramOverrides.get(j.id)?.renderMode??j.renderMode??"waveform")==="waveform")return;const re=U.trackSpectrogramOverrides.get(j.id),me=re?.colorMap??j.spectrogramColorMap??U.spectrogramColorMap??"viridis",Le=re?.config??j.spectrogramConfig??U.spectrogramConfig;N.set(j.id,{colorLUT:U.getColorMap(me),frequencyScaleFn:U.getFrequencyScale(Le?.frequencyScale??"mel"),config:Le})}),N},[te,U]),Te=p.useMemo(()=>{if(U?.spectrogramWorkerApi)return{registerCanvas:U.spectrogramWorkerApi.registerCanvas.bind(U.spectrogramWorkerApi),unregisterCanvas:U.spectrogramWorkerApi.unregisterCanvas.bind(U.spectrogramWorkerApi)}},[U?.spectrogramWorkerApi]),[ce,He]=p.useState(null),[Ne,Qe]=p.useState(!1),We=p.useRef(0),Oe=p.useRef(null),ze=p.useCallback(N=>{Oe.current=N,G(N)},[G]),Xe=te.reduce((N,j)=>j.clips.reduce((Q,re)=>{const me=(re.startSample+re.durationSamples)/re.sampleRate;return Math.max(Q,me)},N),0);let ft=Xe>0?Xe:fe>0?fe:By;if(f?.isRecording){const j=(f.startSample+f.durationSamples)/ne;ft=Math.max(ft,j+10)}const bt=Math.floor(ft*ne/de),q=async N=>{R(N.id);const j=_?void 0:N.end-N.start;try{await Z(N.start,j)}catch(Q){console.error("waveform-playlist: Failed to start playback for annotation",N.id,Q)}},pe=p.useCallback(N=>{if(N>=0&&N<te.length){const j=te[N];Y(j.id)}},[te,Y]),et=N=>{const j=N.currentTarget.getBoundingClientRect(),re=(N.clientX-j.left)*de/ne,Le=N.clientY-j.top;let J=0,Ye=-1;for(let tt=0;tt<K.length;tt++){const Be=K[tt],kt=Be.length>0?Math.max(1,...Be.map(Mt=>Mt.peaks.data.length)):1,Qt=((U?.trackSpectrogramOverrides.get(te[tt]?.id)?.renderMode??te[tt]?.renderMode??"waveform")==="both"?kt*2:kt)*z+(o?22:0);if(Le>=J&&Le<J+Qt){Ye=tt;break}J+=Qt}Ye!==-1&&pe(Ye),We.current=re,Qe(!0),ee(re),O(re,re)},Ge=N=>{if(!Ne||d)return;const j=N.currentTarget.getBoundingClientRect(),re=(N.clientX-j.left)*de/ne,me=Math.min(h,re),Le=Math.max(h,re);O(me,Le)},oe=N=>{if(!Ne)return;if(Qe(!1),d){const J=Math.max(0,We.current);ee(J),O(J,J),Z(J);return}const j=N.currentTarget.getBoundingClientRect(),re=(N.clientX-j.left)*de/ne,me=Math.min(h,re),Le=Math.max(h,re);Math.abs(Le-me)<.1?ee(me):O(me,Le)};if(te.some(N=>N.clips.length>0)&&K.length===0)return C.jsx("div",{className:a,children:"Loading waveform..."});const je=ke.show?K.map((N,j)=>{const Q=te[j];if(!Q)return null;const re=le[j]||{name:`Track ${j+1}`,muted:!1,soloed:!1,volume:1,pan:0},me=Q.clips.some(Be=>Be.midiNotes&&Be.midiNotes.length>0),Le=U?.trackSpectrogramOverrides.get(Q.id)?.renderMode??Q.renderMode??(me?"piano-roll":"waveform"),J=N.length>0?Math.max(1,...N.map(Be=>Be.peaks.data.length)):1,Ye=z*J+(o?wi:0),tt=e?e(j):C.jsxs(Qv,{onClick:()=>pe(j),children:[C.jsxs(e0,{style:{justifyContent:"center",position:"relative"},children:[u&&C.jsx(Jv,{onClick:Be=>{Be.stopPropagation(),u(j)}}),C.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:re.name||`Track ${j+1}`}),U?.renderMenuItems&&C.jsx("span",{style:{position:"absolute",right:0,top:0},children:C.jsx(l0,{items:Be=>U.renderMenuItems({renderMode:Le,onRenderModeChange:kt=>U.setTrackRenderMode(Q.id,kt),onOpenSettings:()=>He(Q.id),onClose:Be})})})]}),C.jsxs(Kv,{children:[C.jsx(Yl,{$variant:re.muted?"danger":"outline",onClick:()=>A(j,!re.muted),children:"Mute"}),C.jsx(Yl,{$variant:re.soloed?"info":"outline",onClick:()=>M(j,!re.soloed),children:"Solo"})]}),C.jsxs(ql,{children:[C.jsx(t0,{}),C.jsx(Kl,{min:"0",max:"1",step:"0.01",value:re.volume,onChange:Be=>$(j,parseFloat(Be.target.value))}),C.jsx(n0,{})]}),C.jsxs(ql,{children:[C.jsx("span",{children:"L"}),C.jsx(Kl,{min:"-1",max:"1",step:"0.01",value:re.pan,onChange:Be=>P(j,parseFloat(Be.target.value))}),C.jsx("span",{children:"R"})]})]});return C.jsx(Wy,{$height:Ye,$isSelected:Q.id===x,children:tt},Q.id)}):void 0;return C.jsxs(Ud,{children:[C.jsx(Br.Provider,{value:{samplesPerPixel:de,sampleRate:ne,zoomLevels:[de],waveHeight:z,timeScaleHeight:ae,duration:ft*1e3,controls:ke,barWidth:ue,barGap:xe},children:C.jsx(_i,{theme:m,backgroundColor:m.playlistBackgroundColor||Yt(m.waveOutlineColor),timescaleBackgroundColor:m.timescaleBackgroundColor,timescaleWidth:bt,tracksWidth:bt,controlsWidth:ke.show?ke.width:0,onTracksMouseDown:et,onTracksMouseMove:Ge,onTracksMouseUp:oe,scrollContainerRef:ze,isSelecting:Ne,"data-playlist-state":B?"ready":"loading",trackControlsSlots:je,timescaleGapHeight:ae>0?ae+1:0,timescale:ae>0?C.jsxs(C.Fragment,{children:[C.jsx(Yd,{renderTick:t}),E&&C.jsx(Cv,{startPosition:Math.min(S,k)*ne/de,endPosition:Math.max(S,k)*ne/de,markerColor:m.loopMarkerColor,regionColor:m.loopRegionColor,minPosition:0,maxPosition:bt,onLoopRegionChange:(N,j)=>{const Q=N*de/ne,re=j*de/ne;X(Q,re)}})]}):void 0,children:C.jsxs(C.Fragment,{children:[K.map((N,j)=>{const Q=te[j];if(!Q)return null;const re=Q.clips.some(J=>J.midiNotes&&J.midiNotes.length>0),me=U?.trackSpectrogramOverrides.get(Q.id)?.renderMode??Q.renderMode??(re?"piano-roll":"waveform"),Le=N.length>0?Math.max(1,...N.map(J=>J.peaks.data.length)):1;return C.jsxs(Kd,{numChannels:Le,backgroundColor:me==="piano-roll"?m.pianoRollBackgroundColor||"#1a1a2e":Yt(m.waveOutlineColor),offset:0,width:bt,hasClipHeaders:o,trackId:Q.id,isSelected:Q.id===x,children:[me!=="waveform"&&(()=>{const J=Je.get(Q.id),Ye=J?.config;return!Ye?.labels||!J?null:C.jsx(Bv,{waveHeight:z,numChannels:Le,frequencyScaleFn:J.frequencyScaleFn,minFrequency:Ye.minFrequency??0,maxFrequency:Ye.maxFrequency??ne/2,labelsColor:Ye.labelsColor,labelsBackground:Ye.labelsBackground,renderMode:me,hasClipHeaders:o})})(),N.map((J,Ye)=>{const tt=J.peaks,Be=tt.length;return C.jsx(co,{clipId:J.clipId,trackIndex:j,clipIndex:Ye,trackName:J.trackName,startSample:J.startSample,durationSamples:J.durationSamples,samplesPerPixel:de,showHeader:o,disableHeaderDrag:!i,isSelected:Q.id===x,trackId:Q.id,fadeIn:J.fadeIn,fadeOut:J.fadeOut,sampleRate:ne,showFades:l,touchOptimized:c,onMouseDown:kt=>{kt.target.closest('[role="button"][aria-roledescription="draggable"]')||pe(j)},children:tt.data.map((kt,Dt)=>{const Jt=U?.spectrogramDataMap.get(J.clipId),Qt=Jt?.[Dt]??Jt?.[0],Mt=Je.get(Q.id),en=Mt?.config;return C.jsx(tc,{index:Dt,data:kt,bits:tt.bits,length:Be,isSelected:Q.id===x,clipStartSample:J.startSample,clipDurationSamples:J.durationSamples,renderMode:J.midiNotes?"piano-roll":me,midiNotes:J.midiNotes,clipSampleRate:J.sampleRate,clipOffsetSeconds:J.offsetSamples!=null?J.offsetSamples/(J.sampleRate||ne):0,spectrogramData:Qt,samplesPerPixel:de,spectrogramColorLUT:Mt?.colorLUT,spectrogramFrequencyScaleFn:Mt?.frequencyScaleFn,spectrogramMinFrequency:en?.minFrequency,spectrogramMaxFrequency:en?.maxFrequency,spectrogramWorkerApi:Te,spectrogramClipId:J.clipId,spectrogramOnCanvasesReady:U?(jr,Zr)=>{U.registerSpectrogramCanvases(J.clipId,Dt,jr,Zr)}:void 0},`${J.clipId}-${Dt}`)})},J.clipId)}),f?.isRecording&&f.trackId===Q.id&&f.peaks.length>0&&C.jsx(co,{clipId:"recording-preview",trackIndex:j,clipIndex:N.length,trackName:"Recording...",startSample:f.startSample,durationSamples:f.durationSamples,samplesPerPixel:de,showHeader:o,disableHeaderDrag:!0,isSelected:Q.id===x,trackId:Q.id,children:C.jsx(tc,{index:0,data:f.peaks,bits:16,length:Math.floor(f.peaks.length/2),isSelected:Q.id===x,clipStartSample:f.startSample,clipDurationSamples:f.durationSamples},`${Q.id}-recording-0`)},`${Q.id}-recording`)]},Q.id)}),v.length>0&&I&&C.jsx(I.AnnotationBoxesWrapper,{height:30,width:bt,children:v.map((N,j)=>{const Q=N.start*ne/de,re=N.end*ne/de,me=s?s(N,j):N.id;return C.jsx(I.AnnotationBox,{annotationId:N.id,annotationIndex:j,startPosition:Q,endPosition:re,label:me,color:"#ff9800",isActive:N.id===y,onClick:()=>q(N),editable:b},N.id)})}),h!==g&&C.jsx(jd,{startPosition:Math.min(h,g)*ne/de,endPosition:Math.max(h,g)*ne/de,color:m.selectionColor}),(d||h===g)&&(n?C.jsx(Vy,{renderPlayhead:n,color:m.playheadColor,samplesPerPixel:de,sampleRate:ne}):C.jsx(Ry,{color:m.playheadColor}))]})})}),U?.SettingsModal&&typeof document<"u"&&go.createPortal(C.jsx(U.SettingsModal,{open:ce!==null,onClose:()=>He(null),config:ce!==null?U.trackSpectrogramOverrides.get(ce)?.config??te.find(N=>N.id===ce)?.spectrogramConfig??U.spectrogramConfig??{}:{},colorMap:ce!==null?U.trackSpectrogramOverrides.get(ce)?.colorMap??te.find(N=>N.id===ce)?.spectrogramColorMap??U.spectrogramColorMap??"viridis":"viridis",onApply:(N,j)=>{ce!==null&&U.setTrackSpectrogramConfig(ce,N,j)}}),document.body)]})},Cf=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,controls:r,annotationListConfig:s,scrollActivePosition:a="center",scrollActiveContainer:o="nearest"})=>{const{annotations:i,activeAnnotationId:l,annotationsEditable:c,linkEndpoints:u,continuousPlay:f}=it(),m=_n(),{setAnnotations:d}=Ie(),h=s??{linkEndpoints:u,continuousPlay:f},g=p.useCallback(y=>{d(y),n?.(y)},[d,n]),{AnnotationText:v}=m;return C.jsx(v,{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})},Ny=({renderTrackControls:e,renderTick:t,renderTimestamp:n,renderPlayhead:r,annotationControls:s,annotationListConfig:a,annotationTextHeight:o,renderAnnotationItem:i,getAnnotationBoxLabel:l,scrollActivePosition:c="center",scrollActiveContainer:u="nearest",className:f,showClipHeaders:m=!1,interactiveClips:d=!1,showFades:h=!1,touchOptimized:g=!1,onRemoveTrack:v,recordingState:y})=>{const{annotations:b}=it(),w=_f(),_=d||w;return C.jsxs(C.Fragment,{children:[C.jsx(xf,{renderTrackControls:e,renderTick:t??(n?(x,S)=>n(parseFloat(x)||0,S):void 0),renderPlayhead:r,annotationControls:s,getAnnotationBoxLabel:l,className:f,showClipHeaders:m,interactiveClips:_,showFades:h,touchOptimized:g,onRemoveTrack:v,recordingState:y}),b.length>0&&C.jsx(Cf,{height:o,renderAnnotationItem:i,controls:s,annotationListConfig:a,scrollActivePosition:c,scrollActiveContainer:u})]})};var zy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Sf=zy?p.useLayoutEffect:p.useEffect;function kn(e){const t=p.useRef(e);return Sf(()=>{t.current=e},[e]),t}function Sa(e,t,n=p.useEffect,r=Object.is){const s=p.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}var nc=Object.getOwnPropertySymbols,jy=Object.prototype.hasOwnProperty,Zy=Object.prototype.propertyIsEnumerable,Hy=(e,t)=>{var n={};for(var r in e)jy.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&nc)for(var r of nc(e))t.indexOf(r)<0&&Zy.call(e,r)&&(n[r]=e[r]);return n},Gy=new di,Uy=p.createContext(Gy),Xy=p.memo(p.forwardRef(({children:e},t)=>{const[n,r]=p.useState(0),s=p.useRef(null),a=p.useRef(null),o=p.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{a.current=l})),p.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return Sf(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),p.useImperativeHandle(t,()=>o),null})),ka=[void 0,yr];function kf(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:a,onDragMove:o,onDragOver:i,onDragEnd:l}=t,c=Hy(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=p.useRef(null),{plugins:f,modifiers:m,sensors:d}=c,h=Ot(f,Dn.plugins),g=Ot(d,Dn.sensors),v=Ot(m,Dn.modifiers),y=kn(s),b=kn(a),w=kn(i),_=kn(o),x=kn(l),S=kn(r),k=Yy(()=>{var E;return(E=c.manager)!=null?E:new di(c)});return p.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:E,trackRendering:I}=u.current,{monitor:T}=k;k.renderer=E;const R=[T.addEventListener("beforedragstart",A=>{const M=y.current;M&&I(()=>M(A,k))}),T.addEventListener("dragstart",A=>{var M;return(M=b.current)==null?void 0:M.call(b,A,k)}),T.addEventListener("dragover",A=>{const M=w.current;M&&I(()=>M(A,k))}),T.addEventListener("dragmove",A=>{const M=_.current;M&&I(()=>M(A,k))}),T.addEventListener("dragend",A=>{const M=x.current;M&&I(()=>M(A,k))}),T.addEventListener("collision",A=>{var M;return(M=S.current)==null?void 0:M.call(S,A,k)})];return()=>R.forEach(A=>A())},[k]),Sa(h,()=>k&&(k.plugins=h),...ka),Sa(g,()=>k&&(k.sensors=g),...ka),Sa(v,()=>k&&(k.modifiers=v),...ka),C.jsxs(Uy.Provider,{value:k,children:[C.jsx(Xy,{ref:u,children:n}),n]})}function Yy(e){const t=p.useRef(null);return t.current||(t.current=e()),p.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var Ky=Object.create,Ef=Object.defineProperty,qy=Object.getOwnPropertyDescriptor,If=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),na=e=>{throw TypeError(e)},Jy=(e,t,n)=>t in e?Ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qy=e=>{var t;return[,,,Ky((t=e?.[If("metadata")])!=null?t:null)]},Mf=["class","method","getter","setter","accessor","field","value","get","set"],Af=e=>e!==void 0&&typeof e!="function"?na("Function expected"):e,eb=(e,t,n,r,s)=>({kind:Mf[e],name:t,metadata:r,addInitializer:a=>n._?na("Already initialized"):s.push(Af(a||null))}),tb=(e,t)=>Jy(t,If("metadata"),e[3]),nb=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},Tf=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=Mf[u+5],g=e[d]||(e[d]=[]),v=(s=s.prototype,qy(s,n)),y=r.length-1;y>=0;y--)l=eb(u,n,i={},e[3],g),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(v[h],l),i._=1,Af(o)&&(v[h]=o);return v&&Ef(s,n,v),s},$f=(e,t,n)=>t.has(e)||na("Cannot "+n),rb=(e,t,n)=>($f(e,t,"read from private field"),t.get(e)),sb=(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),ab=(e,t,n,r)=>($f(e,t,"write to private field"),t.set(e,n),n),Qn=class ho{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ho(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 ho(t,n)}},Rf,Df,po,bs,zr,Ii=class extends(po=Kt,Df=[$e],Rf=[$e],po){constructor(e){const t=Qn.from(e);super(t,(n,r)=>Qn.equals(n,r)),nb(zr,5,this),sb(this,bs,0),this.velocity={x:0,y:0}}get delta(){return Qn.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=Qn.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),a=s-rb(this,bs),o=i=>Math.round(i/a*100);Xt(()=>{ab(this,bs,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Qn.from(e)),this.velocity={x:0,y:0}}};zr=Qy(po);bs=new WeakMap;Tf(zr,2,"delta",Df,Ii);Tf(zr,2,"direction",Rf,Ii);tb(zr,Ii);var Pf=(e=>(e.Horizontal="x",e.Vertical="y",e))(Pf||{});Object.values(Pf);var ob=Object.defineProperty,ib=Object.defineProperties,lb=Object.getOwnPropertyDescriptors,rc=Object.getOwnPropertySymbols,cb=Object.prototype.hasOwnProperty,ub=Object.prototype.propertyIsEnumerable,sc=(e,t,n)=>t in e?ob(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ff=(e,t)=>{for(var n in t||(t={}))cb.call(t,n)&&sc(e,n,t[n]);if(rc)for(var n of rc(t))ub.call(t,n)&&sc(e,n,t[n]);return e},Of=(e,t)=>ib(e,lb(t)),mo=class extends On{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return Of(Ff({},t),{[n]:r})}};mo.configure=gn(mo);var Lf=mo;Lf.configure({axis:"x",value:0});var Bf=Lf.configure({axis:"y",value:0}),ac=class extends On{apply({transform:t}){var n;const{size:r=20}=(n=this.options)!=null?n:{},s=typeof r=="number"?r:r.x,a=typeof r=="number"?r:r.y;return Of(Ff({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/a)*a})}};ac.configure=gn(ac);const Mi=e=>{let t=!1;const n=e.map(r=>r===eo?(t=!0,eo.configure({dropAnimation:null})):r);return t||console.warn("[waveform-playlist] noDropAnimationPlugins: Feedback plugin not found in defaults — drop animation may not be disabled. Check @dnd-kit/dom version."),n},db=F.div`
|
|
1044
|
+
`,Vy=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:a,playbackStartTimeRef:o,audioStartPositionRef:i,getPlaybackTime:l}=ot();return e({position:(a.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:a,playbackStartTimeRef:o,audioStartPositionRef:i,samplesPerPixel:n,sampleRate:r,controlsOffset:0,getAudioContextTime:()=>L.getContext().currentTime,getPlaybackTime:l})};function ka(e,t,n,r){const s=e.length>0?Math.max(1,...e.map(o=>o.peaks.data.length)):1,a=t?.isRecording&&t.trackId===n?r?1:t.peaks.length:0;return Math.max(s,a)}const Cf=({renderTrackControls:e,renderTick:t,renderPlayhead:n,annotationControls:r,getAnnotationBoxLabel:s,className:a,showClipHeaders:o=!1,interactiveClips:i=!1,showFades:l=!1,touchOptimized:c=!1,onRemoveTrack:u,recordingState:f})=>{const m=Vr(),{isPlaying:d}=ot(),{selectionStart:h,selectionEnd:v,annotations:g,activeAnnotationId:y,annotationsEditable:b,linkEndpoints:_,continuousPlay:w,selectedTrackId:x,loopStart:S,loopEnd:k,isLoopEnabled:E}=it(),M=p.useContext(na),{setAnnotations:T,setActiveAnnotationId:$,setTrackMute:A,setTrackSolo:I,setTrackVolume:R,setTrackPan:D,setSelection:O,play:Z,setScrollContainer:G,setSelectedTrackId:Y,setCurrentTime:te,setLoopRegion:X}=Ie(),{peaksDataArray:K,trackStates:le,tracks:J,duration:de,samplesPerPixel:ue,sampleRate:ne,waveHeight:z,timeScaleHeight:ae,controls:ke,barWidth:ce,barGap:xe,isReady:B,mono:_e}=lt(),re=p.useContext(Mi),Me=p.useMemo(()=>{if(!re)return new Map;const N=new Map;return J.forEach(q=>{if((re.trackSpectrogramOverrides.get(q.id)?.renderMode??q.renderMode??"waveform")==="waveform")return;const Q=re.trackSpectrogramOverrides.get(q.id),Te=Q?.colorMap??q.spectrogramColorMap??re.spectrogramColorMap??"viridis",De=Q?.config??q.spectrogramConfig??re.spectrogramConfig;N.set(q.id,{colorLUT:re.getColorMap(Te),frequencyScaleFn:re.getFrequencyScale(De?.frequencyScale??"mel"),config:De})}),N},[J,re]),pe=p.useMemo(()=>{if(re?.spectrogramWorkerApi)return{registerCanvas:re.spectrogramWorkerApi.registerCanvas.bind(re.spectrogramWorkerApi),unregisterCanvas:re.spectrogramWorkerApi.unregisterCanvas.bind(re.spectrogramWorkerApi)}},[re?.spectrogramWorkerApi]),[Ae,He]=p.useState(null),[qe,Ve]=p.useState(!1),Le=p.useRef(0),je=p.useRef(null),tt=p.useCallback(N=>{je.current=N,G(N)},[G]),Ct=J.reduce((N,q)=>q.clips.reduce((U,Q)=>{const Te=(Q.startSample+Q.durationSamples)/Q.sampleRate;return Math.max(U,Te)},N),0);let St=Ct>0?Ct:de>0?de:By;if(f?.isRecording){const q=(f.startSample+f.durationSamples)/ne;St=Math.max(St,q+10)}const j=Math.floor(St*ne/ue),ge=async N=>{$(N.id);const q=w?void 0:N.end-N.start;try{await Z(N.start,q)}catch(U){console.error("waveform-playlist: Failed to start playback for annotation",N.id,U)}},Ge=p.useCallback(N=>{if(N>=0&&N<J.length){const q=J[N];Y(q.id)}},[J,Y]),Ue=N=>{const q=N.currentTarget.getBoundingClientRect(),Q=(N.clientX-q.left)*ue/ne,De=N.clientY-q.top;let ee=0,Ne=-1;for(let Je=0;Je<K.length;Je++){const Ye=K[Je],Et=ka(Ye,f,J[Je]?.id,_e),Pt=((re?.trackSpectrogramOverrides.get(J[Je]?.id)?.renderMode??J[Je]?.renderMode??"waveform")==="both"?Et*2:Et)*z+(o?22:0);if(De>=ee&&De<ee+Pt){Ne=Je;break}ee+=Pt}Ne!==-1&&Ge(Ne),Le.current=Q,Ve(!0),te(Q),O(Q,Q)},oe=N=>{if(!qe||d)return;const q=N.currentTarget.getBoundingClientRect(),Q=(N.clientX-q.left)*ue/ne,Te=Math.min(h,Q),De=Math.max(h,Q);O(Te,De)},ve=N=>{if(!qe)return;if(Ve(!1),d){const ee=Math.max(0,Le.current);te(ee),O(ee,ee),Z(ee);return}const q=N.currentTarget.getBoundingClientRect(),Q=(N.clientX-q.left)*ue/ne,Te=Math.min(h,Q),De=Math.max(h,Q);Math.abs(De-Te)<.1?te(Te):O(Te,De)};if(J.some(N=>N.clips.length>0)&&K.length===0)return C.jsx("div",{className:a,children:"Loading waveform..."});const kt=ke.show?K.map((N,q)=>{const U=J[q];if(!U)return null;const Q=le[q]||{name:`Track ${q+1}`,muted:!1,soloed:!1,volume:1,pan:0},Te=U.clips.some(Ye=>Ye.midiNotes&&Ye.midiNotes.length>0),De=re?.trackSpectrogramOverrides.get(U.id)?.renderMode??U.renderMode??(Te?"piano-roll":"waveform"),ee=ka(N,f,U.id,_e),Ne=z*ee+(o?xi:0),Je=e?e(q):C.jsxs(e0,{onClick:()=>Ge(q),children:[C.jsxs(t0,{style:{justifyContent:"center",position:"relative"},children:[u&&C.jsx(Qv,{onClick:Ye=>{Ye.stopPropagation(),u(q)}}),C.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 24px",display:"block"},children:Q.name||`Track ${q+1}`}),re?.renderMenuItems&&C.jsx("span",{style:{position:"absolute",right:0,top:0},children:C.jsx(c0,{items:Ye=>re.renderMenuItems({renderMode:De,onRenderModeChange:Et=>re.setTrackRenderMode(U.id,Et),onOpenSettings:()=>He(U.id),onClose:Ye})})})]}),C.jsxs(qv,{children:[C.jsx(Kl,{$variant:Q.muted?"danger":"outline",onClick:()=>A(q,!Q.muted),children:"Mute"}),C.jsx(Kl,{$variant:Q.soloed?"info":"outline",onClick:()=>I(q,!Q.soloed),children:"Solo"})]}),C.jsxs(Jl,{children:[C.jsx(n0,{}),C.jsx(ql,{min:"0",max:"1",step:"0.01",value:Q.volume,onChange:Ye=>R(q,parseFloat(Ye.target.value))}),C.jsx(r0,{})]}),C.jsxs(Jl,{children:[C.jsx("span",{children:"L"}),C.jsx(ql,{min:"-1",max:"1",step:"0.01",value:Q.pan,onChange:Ye=>D(q,parseFloat(Ye.target.value))}),C.jsx("span",{children:"R"})]})]});return C.jsx(Wy,{$height:Ne,$isSelected:U.id===x,children:Je},U.id)}):void 0;return C.jsxs(Xd,{children:[C.jsx(Wr.Provider,{value:{samplesPerPixel:ue,sampleRate:ne,zoomLevels:[ue],waveHeight:z,timeScaleHeight:ae,duration:St*1e3,controls:ke,barWidth:ce,barGap:xe},children:C.jsx(Ci,{theme:m,backgroundColor:m.playlistBackgroundColor||qt(m.waveOutlineColor),timescaleBackgroundColor:m.timescaleBackgroundColor,timescaleWidth:j,tracksWidth:j,controlsWidth:ke.show?ke.width:0,onTracksMouseDown:Ue,onTracksMouseMove:oe,onTracksMouseUp:ve,scrollContainerRef:tt,isSelecting:qe,"data-playlist-state":B?"ready":"loading",trackControlsSlots:kt,timescaleGapHeight:ae>0?ae+1:0,timescale:ae>0?C.jsxs(C.Fragment,{children:[C.jsx(Kd,{renderTick:t}),E&&C.jsx(Sv,{startPosition:Math.min(S,k)*ne/ue,endPosition:Math.max(S,k)*ne/ue,markerColor:m.loopMarkerColor,regionColor:m.loopRegionColor,minPosition:0,maxPosition:j,onLoopRegionChange:(N,q)=>{const U=N*ue/ne,Q=q*ue/ne;X(U,Q)}})]}):void 0,children:C.jsxs(C.Fragment,{children:[K.map((N,q)=>{const U=J[q];if(!U)return null;const Q=U.clips.some(ee=>ee.midiNotes&&ee.midiNotes.length>0),Te=re?.trackSpectrogramOverrides.get(U.id)?.renderMode??U.renderMode??(Q?"piano-roll":"waveform"),De=ka(N,f,U.id,_e);return C.jsxs(qd,{numChannels:De,backgroundColor:Te==="piano-roll"?m.pianoRollBackgroundColor||"#1a1a2e":qt(m.waveOutlineColor),offset:0,width:j,hasClipHeaders:o,trackId:U.id,isSelected:U.id===x,children:[Te!=="waveform"&&(()=>{const ee=Me.get(U.id),Ne=ee?.config;return!Ne?.labels||!ee?null:C.jsx(Wv,{waveHeight:z,numChannels:De,frequencyScaleFn:ee.frequencyScaleFn,minFrequency:Ne.minFrequency??0,maxFrequency:Ne.maxFrequency??ne/2,labelsColor:Ne.labelsColor,labelsBackground:Ne.labelsBackground,renderMode:Te,hasClipHeaders:o})})(),N.map((ee,Ne)=>{const Je=ee.peaks,Ye=Je.length;return C.jsx(fo,{clipId:ee.clipId,trackIndex:q,clipIndex:Ne,trackName:ee.trackName,startSample:ee.startSample,durationSamples:ee.durationSamples,samplesPerPixel:ue,showHeader:o,disableHeaderDrag:!i,isSelected:U.id===x,trackId:U.id,fadeIn:ee.fadeIn,fadeOut:ee.fadeOut,sampleRate:ne,showFades:l,touchOptimized:c,onMouseDown:Et=>{Et.target.closest('[role="button"][aria-roledescription="draggable"]')||Ge(q)},children:Je.data.map((Et,Dt)=>{const en=re?.spectrogramDataMap.get(ee.clipId),Pt=en?.[Dt]??en?.[0],zt=Me.get(U.id),Yn=zt?.config;return C.jsx(nc,{index:Dt,data:Et,bits:Je.bits,length:Ye,isSelected:U.id===x,clipStartSample:ee.startSample,clipDurationSamples:ee.durationSamples,renderMode:ee.midiNotes?"piano-roll":Te,midiNotes:ee.midiNotes,clipSampleRate:ee.sampleRate,clipOffsetSeconds:ee.offsetSamples!=null?ee.offsetSamples/(ee.sampleRate||ne):0,spectrogramData:Pt,samplesPerPixel:ue,spectrogramColorLUT:zt?.colorLUT,spectrogramFrequencyScaleFn:zt?.frequencyScaleFn,spectrogramMinFrequency:Yn?.minFrequency,spectrogramMaxFrequency:Yn?.maxFrequency,spectrogramWorkerApi:pe,spectrogramClipId:ee.clipId,spectrogramOnCanvasesReady:re?(Zr,Hr)=>{re.registerSpectrogramCanvases(ee.clipId,Dt,Zr,Hr)}:void 0},`${ee.clipId}-${Dt}`)})},ee.clipId)}),f?.isRecording&&f.trackId===U.id&&f.peaks[0]?.length>0&&C.jsx(fo,{clipId:"recording-preview",trackIndex:q,clipIndex:N.length,trackName:"Recording...",startSample:f.startSample,durationSamples:f.durationSamples,samplesPerPixel:ue,showHeader:o,disableHeaderDrag:!0,isSelected:U.id===x,trackId:U.id,children:(_e?f.peaks.slice(0,1):f.peaks).map((ee,Ne)=>C.jsx(nc,{index:Ne,data:ee,bits:f.bits,length:Math.floor(ee.length/2),isSelected:U.id===x,clipStartSample:f.startSample,clipDurationSamples:f.durationSamples},`${U.id}-recording-${Ne}`))},`${U.id}-recording`)]},U.id)}),g.length>0&&M&&C.jsx(M.AnnotationBoxesWrapper,{height:30,width:j,children:g.map((N,q)=>{const U=N.start*ne/ue,Q=N.end*ne/ue,Te=s?s(N,q):N.id;return C.jsx(M.AnnotationBox,{annotationId:N.id,annotationIndex:q,startPosition:U,endPosition:Q,label:Te,color:"#ff9800",isActive:N.id===y,onClick:()=>ge(N),editable:b},N.id)})}),h!==v&&C.jsx(Zd,{startPosition:Math.min(h,v)*ne/ue,endPosition:Math.max(h,v)*ne/ue,color:m.selectionColor}),(d||h===v)&&(n?C.jsx(Vy,{renderPlayhead:n,color:m.playheadColor,samplesPerPixel:ue,sampleRate:ne}):C.jsx(Ry,{color:m.playheadColor}))]})})}),re?.SettingsModal&&typeof document<"u"&&yo.createPortal(C.jsx(re.SettingsModal,{open:Ae!==null,onClose:()=>He(null),config:Ae!==null?re.trackSpectrogramOverrides.get(Ae)?.config??J.find(N=>N.id===Ae)?.spectrogramConfig??re.spectrogramConfig??{}:{},colorMap:Ae!==null?re.trackSpectrogramOverrides.get(Ae)?.colorMap??J.find(N=>N.id===Ae)?.spectrogramColorMap??re.spectrogramColorMap??"viridis":"viridis",onApply:(N,q)=>{Ae!==null&&re.setTrackSpectrogramConfig(Ae,N,q)}}),document.body)]})},Sf=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,controls:r,annotationListConfig:s,scrollActivePosition:a="center",scrollActiveContainer:o="nearest"})=>{const{annotations:i,activeAnnotationId:l,annotationsEditable:c,linkEndpoints:u,continuousPlay:f}=it(),m=_n(),{setAnnotations:d}=Ie(),h=s??{linkEndpoints:u,continuousPlay:f},v=p.useCallback(y=>{d(y),n?.(y)},[d,n]),{AnnotationText:g}=m;return C.jsx(g,{annotations:i,activeAnnotationId:l??void 0,shouldScrollToActive:!0,scrollActivePosition:a,scrollActiveContainer:o,editable:c,controls:c?r:void 0,annotationListConfig:h,height:e,onAnnotationUpdate:v,renderAnnotationItem:t})},Ny=({renderTrackControls:e,renderTick:t,renderTimestamp:n,renderPlayhead:r,annotationControls:s,annotationListConfig:a,annotationTextHeight:o,renderAnnotationItem:i,getAnnotationBoxLabel:l,scrollActivePosition:c="center",scrollActiveContainer:u="nearest",className:f,showClipHeaders:m=!1,interactiveClips:d=!1,showFades:h=!1,touchOptimized:v=!1,onRemoveTrack:g,recordingState:y})=>{const{annotations:b}=it(),_=xf(),w=d||_;return C.jsxs(C.Fragment,{children:[C.jsx(Cf,{renderTrackControls:e,renderTick:t??(n?(x,S)=>n(parseFloat(x)||0,S):void 0),renderPlayhead:r,annotationControls:s,getAnnotationBoxLabel:l,className:f,showClipHeaders:m,interactiveClips:w,showFades:h,touchOptimized:v,onRemoveTrack:g,recordingState:y}),b.length>0&&C.jsx(Sf,{height:o,renderAnnotationItem:i,controls:s,annotationListConfig:a,scrollActivePosition:c,scrollActiveContainer:u})]})};var zy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kf=zy?p.useLayoutEffect:p.useEffect;function kn(e){const t=p.useRef(e);return kf(()=>{t.current=e},[e]),t}function Ea(e,t,n=p.useEffect,r=Object.is){const s=p.useRef(e);n(()=>{const a=s.current;r(e,a)||(s.current=e,t(e,a))},[t,e])}var rc=Object.getOwnPropertySymbols,jy=Object.prototype.hasOwnProperty,Zy=Object.prototype.propertyIsEnumerable,Hy=(e,t)=>{var n={};for(var r in e)jy.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&rc)for(var r of rc(e))t.indexOf(r)<0&&Zy.call(e,r)&&(n[r]=e[r]);return n},Gy=new hi,Uy=p.createContext(Gy),Xy=p.memo(p.forwardRef(({children:e},t)=>{const[n,r]=p.useState(0),s=p.useRef(null),a=p.useRef(null),o=p.useMemo(()=>({renderer:{get rendering(){var i;return(i=s.current)!=null?i:Promise.resolve()}},trackRendering(i){s.current||(s.current=new Promise(l=>{a.current=l})),p.startTransition(()=>{i(),r(l=>l+1)})}}),[]);return kf(()=>{var i;(i=a.current)==null||i.call(a),s.current=null},[e,n]),p.useImperativeHandle(t,()=>o),null})),Ia=[void 0,br];function Ef(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:a,onDragMove:o,onDragOver:i,onDragEnd:l}=t,c=Hy(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=p.useRef(null),{plugins:f,modifiers:m,sensors:d}=c,h=Lt(f,Dn.plugins),v=Lt(d,Dn.sensors),g=Lt(m,Dn.modifiers),y=kn(s),b=kn(a),_=kn(i),w=kn(o),x=kn(l),S=kn(r),k=Yy(()=>{var E;return(E=c.manager)!=null?E:new hi(c)});return p.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:E,trackRendering:M}=u.current,{monitor:T}=k;k.renderer=E;const $=[T.addEventListener("beforedragstart",A=>{const I=y.current;I&&M(()=>I(A,k))}),T.addEventListener("dragstart",A=>{var I;return(I=b.current)==null?void 0:I.call(b,A,k)}),T.addEventListener("dragover",A=>{const I=_.current;I&&M(()=>I(A,k))}),T.addEventListener("dragmove",A=>{const I=w.current;I&&M(()=>I(A,k))}),T.addEventListener("dragend",A=>{const I=x.current;I&&M(()=>I(A,k))}),T.addEventListener("collision",A=>{var I;return(I=S.current)==null?void 0:I.call(S,A,k)})];return()=>$.forEach(A=>A())},[k]),Ea(h,()=>k&&(k.plugins=h),...Ia),Ea(v,()=>k&&(k.sensors=v),...Ia),Ea(g,()=>k&&(k.modifiers=g),...Ia),C.jsxs(Uy.Provider,{value:k,children:[C.jsx(Xy,{ref:u,children:n}),n]})}function Yy(e){const t=p.useRef(null);return t.current||(t.current=e()),p.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}var Ky=Object.create,If=Object.defineProperty,qy=Object.getOwnPropertyDescriptor,Mf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ra=e=>{throw TypeError(e)},Jy=(e,t,n)=>t in e?If(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qy=e=>{var t;return[,,,Ky((t=e?.[Mf("metadata")])!=null?t:null)]},Af=["class","method","getter","setter","accessor","field","value","get","set"],Tf=e=>e!==void 0&&typeof e!="function"?ra("Function expected"):e,eb=(e,t,n,r,s)=>({kind:Af[e],name:t,metadata:r,addInitializer:a=>n._?ra("Already initialized"):s.push(Tf(a||null))}),tb=(e,t)=>Jy(t,Mf("metadata"),e[3]),nb=(e,t,n,r)=>{for(var s=0,a=e[t>>1],o=a&&a.length;s<o;s++)a[s].call(n);return r},$f=(e,t,n,r,s,a)=>{for(var o,i,l,c,u=t&7,f=!1,m=!1,d=2,h=Af[u+5],v=e[d]||(e[d]=[]),g=(s=s.prototype,qy(s,n)),y=r.length-1;y>=0;y--)l=eb(u,n,i={},e[3],v),l.static=f,l.private=m,c=l.access={has:b=>n in b},c.get=b=>b[n],o=(0,r[y])(g[h],l),i._=1,Tf(o)&&(g[h]=o);return g&&If(s,n,g),s},Rf=(e,t,n)=>t.has(e)||ra("Cannot "+n),rb=(e,t,n)=>(Rf(e,t,"read from private field"),t.get(e)),sb=(e,t,n)=>t.has(e)?ra("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ab=(e,t,n,r)=>(Rf(e,t,"write to private field"),t.set(e,n),n),er=class mo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new mo(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new mo(t,n)}},Df,Pf,go,ws,jr,Ai=class extends(go=Jt,Pf=[Pe],Df=[Pe],go){constructor(e){const t=er.from(e);super(t,(n,r)=>er.equals(n,r)),nb(jr,5,this),sb(this,ws,0),this.velocity={x:0,y:0}}get delta(){return er.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=er.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),a=s-rb(this,ws),o=i=>Math.round(i/a*100);Kt(()=>{ab(this,ws,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(er.from(e)),this.velocity={x:0,y:0}}};jr=Qy(go);ws=new WeakMap;$f(jr,2,"delta",Pf,Ai);$f(jr,2,"direction",Df,Ai);tb(jr,Ai);var Ff=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ff||{});Object.values(Ff);var ob=Object.defineProperty,ib=Object.defineProperties,lb=Object.getOwnPropertyDescriptors,sc=Object.getOwnPropertySymbols,cb=Object.prototype.hasOwnProperty,ub=Object.prototype.propertyIsEnumerable,ac=(e,t,n)=>t in e?ob(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Of=(e,t)=>{for(var n in t||(t={}))cb.call(t,n)&&ac(e,n,t[n]);if(sc)for(var n of sc(t))ub.call(t,n)&&ac(e,n,t[n]);return e},Lf=(e,t)=>ib(e,lb(t)),vo=class extends On{apply({transform:t}){if(!this.options)return t;const{axis:n,value:r}=this.options;return Lf(Of({},t),{[n]:r})}};vo.configure=gn(vo);var Bf=vo;Bf.configure({axis:"x",value:0});var Wf=Bf.configure({axis:"y",value:0}),oc=class extends On{apply({transform:t}){var n;const{size:r=20}=(n=this.options)!=null?n:{},s=typeof r=="number"?r:r.x,a=typeof r=="number"?r:r.y;return Lf(Of({},t),{x:Math.ceil(t.x/s)*s,y:Math.ceil(t.y/a)*a})}};oc.configure=gn(oc);const Ti=e=>{let t=!1;const n=e.map(r=>r===no?(t=!0,no.configure({dropAnimation:null})):r);return t||console.warn("[waveform-playlist] noDropAnimationPlugins: Feedback plugin not found in defaults — drop animation may not be disabled. Check @dnd-kit/dom version."),n},db=F.div`
|
|
1045
1045
|
position: absolute;
|
|
1046
1046
|
top: 0;
|
|
1047
1047
|
left: 0;
|
|
@@ -1051,7 +1051,7 @@ self.onmessage = function(e) {
|
|
|
1051
1051
|
z-index: 100;
|
|
1052
1052
|
pointer-events: none;
|
|
1053
1053
|
will-change: transform;
|
|
1054
|
-
`,fb=({color:e="#ff0000"})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s}=
|
|
1054
|
+
`,fb=({color:e="#ff0000"})=>{const t=p.useRef(null),n=p.useRef(null),{isPlaying:r,currentTimeRef:s}=zr(),{samplesPerPixel:a,sampleRate:o,progressBarWidth:i}=ta();return p.useEffect(()=>{const l=()=>{if(t.current){const u=(s.current??0)*o/a;t.current.style.transform=`translate3d(${u}px, 0, 0)`}r&&(n.current=requestAnimationFrame(l))};return r?n.current=requestAnimationFrame(l):l(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[r,o,a,s]),p.useEffect(()=>{if(!r&&t.current){const c=(s.current??0)*o/a;t.current.style.transform=`translate3d(${c}px, 0, 0)`}}),C.jsx(db,{ref:t,$color:e,$width:i,"data-playhead":!0})},hb=F.div`
|
|
1055
1055
|
position: relative;
|
|
1056
1056
|
`,pb=F.div`
|
|
1057
1057
|
position: absolute;
|
|
@@ -1075,5 +1075,5 @@ self.onmessage = function(e) {
|
|
|
1075
1075
|
`,gb=F.div`
|
|
1076
1076
|
position: relative;
|
|
1077
1077
|
z-index: 2;
|
|
1078
|
-
`,vb=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=p.useRef(null),s=p.useRef(null),a=Wr(),{waveHeight:o}=qs(),{isPlaying:i,currentTimeRef:l}=Nr(),{samplesPerPixel:c,sampleRate:u}=ea(),f=a?.waveProgressColor||"rgba(0, 0, 0, 0.1)";p.useEffect(()=>{const g=()=>{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(g))};return i?s.current=requestAnimationFrame(g):g(),()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i,u,c,e,t,n.length,l]),p.useEffect(()=>{if(!i&&r.current){const v=(l.current??0)*u,y=e+t;let b=0;if(v<=e)b=0;else if(v>=y)b=n.length;else{const w=v-e;b=Math.floor(w/c)}r.current.style.width=`${b}px`}});const m=a?.waveformDrawMode||"inverted";let d;m==="inverted"?d=a?.selectedWaveFillColor||a?.waveFillColor||"white":d=a?.selectedWaveOutlineColor||a?.waveOutlineColor||"grey";const h=Yt(d);return C.jsxs(hb,{children:[C.jsx(pb,{$color:h,$height:o,$top:n.index*o,$width:n.length}),C.jsx(mb,{ref:r,$color:f,$height:o,$top:n.index*o}),C.jsx(gb,{children:C.jsx(Xd,{...n,isSelected:!0,transparentBackground:!0})})]})},oc={current:0},yb=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:a}=Nr();return e({position:(a.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:a,playbackStartTimeRef:oc,audioStartPositionRef:oc,samplesPerPixel:n,sampleRate:r,controlsOffset:0})},Wf=({getAnnotationBoxLabel:e,editable:t=!1,linkEndpoints:n=!1,onAnnotationUpdate:r,renderPlayhead:s,className:a})=>{const o=Wr(),{isPlaying:i}=Nr(),{annotations:l,activeAnnotationId:c}=Qs(),u=p.useContext(ta),{play:f,seekTo:m,setActiveAnnotationId:d,setAnnotations:h,setScrollContainer:g}=ki(),{duration:v,peaksDataArray:y,sampleRate:b,waveHeight:w,timeScaleHeight:_,samplesPerPixel:x,controls:S,playoutRef:k,barWidth:E,barGap:I}=ea(),[T,R]=p.useState(0),[A,M]=p.useState(0),[$,P]=p.useState(!1),O=p.useRef(null),Z=p.useCallback(z=>{O.current=z,g(z)},[g]),G=Math.floor(v*b/x),Y=p.useCallback(async z=>{d(z.id);try{await f(z.start)}catch(ae){console.error("waveform-playlist: Failed to start playback for annotation",z.id,ae)}},[d,f]),ee=p.useCallback(z=>{h(z),r?.(z)},[h,r]),{onDragStart:X,onDragMove:K,onDragEnd:le}=sf({annotations:l,onAnnotationsChange:ee,samplesPerPixel:x,sampleRate:b,duration:v,linkEndpoints:n}),te=p.useRef(0),fe=p.useCallback(z=>{const ae=z.currentTarget.getBoundingClientRect(),ue=(z.clientX-ae.left)*x/b;te.current=ue,P(!0),R(ue),M(ue)},[x,b]),de=p.useCallback(z=>{if(!$)return;const ae=z.currentTarget.getBoundingClientRect(),ue=(z.clientX-ae.left)*x/b;M(ue)},[$,x,b]),ne=p.useCallback(z=>{if(!$)return;if(P(!1),i&&k.current){const U=Math.max(0,te.current);m(U),R(U),M(U),k.current.stop(),f(U);return}const ae=z.currentTarget.getBoundingClientRect(),ue=(z.clientX-ae.left)*x/b,xe=Math.min(T,ue),B=Math.max(T,ue);Math.abs(B-xe)<.1?(m(xe),R(xe),M(xe)):(R(xe),M(B))},[$,T,x,b,m,i,k,f]);return y.length===0?C.jsx("div",{className:a,children:"Loading waveform..."}):C.jsx(Ud,{children:C.jsx(Br.Provider,{value:{samplesPerPixel:x,sampleRate:b,zoomLevels:[x],waveHeight:w,timeScaleHeight:_,duration:v*1e3,controls:S,barWidth:E,barGap:I},children:C.jsx(_i,{theme:o,backgroundColor:Yt(o.waveOutlineColor),timescaleBackgroundColor:o.timescaleBackgroundColor,timescaleWidth:G,tracksWidth:G,controlsWidth:S.show?S.width:0,onTracksMouseDown:fe,onTracksMouseMove:de,onTracksMouseUp:ne,scrollContainerRef:Z,isSelecting:$,timescale:_>0?C.jsx(Yd,{}):void 0,children:C.jsxs(C.Fragment,{children:[y.map((z,ae)=>{const ke=z.length>0?Math.max(...z.map(ue=>ue.peaks.data.length)):1;return C.jsx(Kd,{numChannels:ke,backgroundColor:Yt(o.waveOutlineColor),offset:0,width:G,hasClipHeaders:!1,trackId:`media-element-track-${ae}`,isSelected:!0,children:z.map((ue,xe)=>{const B=ue.peaks,U=B.length;return C.jsx(co,{clipId:ue.clipId,trackIndex:ae,clipIndex:xe,trackName:ue.trackName,startSample:ue.startSample,durationSamples:ue.durationSamples,samplesPerPixel:x,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${ae}`,children:B.data.map((Je,Te)=>C.jsx(vb,{index:Te,data:Je,bits:B.bits,length:U,clipStartSample:ue.startSample,clipDurationSamples:ue.durationSamples},`${ae}-${xe}-${Te}`))},`${ae}-${xe}`)})},ae)}),l.length>0&&u&&C.jsx(kf,{onDragStart:X,onDragMove:K,onDragEnd:le,modifiers:t?[Bf]:[],plugins:Mi,children:C.jsx(u.AnnotationBoxesWrapper,{height:30,width:G,children:l.map((z,ae)=>{const ke=z.start*b/x,ue=z.end*b/x,xe=e?e(z,ae):z.id;return C.jsx(u.AnnotationBox,{annotationId:z.id,annotationIndex:ae,startPosition:ke,endPosition:ue,label:xe,color:"#ff9800",isActive:z.id===c,onClick:()=>Y(z),editable:t},z.id)})})}),T!==A&&C.jsx(jd,{startPosition:Math.min(T,A)*b/x,endPosition:Math.max(T,A)*b/x,color:o.selectionColor}),s?C.jsx(yb,{renderPlayhead:s,color:o.playheadColor,samplesPerPixel:x,sampleRate:b}):C.jsx(fb,{color:o.playheadColor})]})})})})},Vf=({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=_n(),{setAnnotations:m}=ki(),d=a??{linkEndpoints:!1,continuousPlay:u},h=p.useCallback(v=>{m(v),n?.(v)},[m,n]),{AnnotationText:g}=f;return C.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})},bb=({annotationTextHeight:e,getAnnotationBoxLabel:t,renderAnnotationItem:n,editable:r=!1,linkEndpoints:s=!1,onAnnotationUpdate:a,scrollActivePosition:o="center",scrollActiveContainer:i="nearest",renderPlayhead:l,className:c})=>{const{annotations:u}=Qs();return C.jsxs(C.Fragment,{children:[C.jsx(Wf,{getAnnotationBoxLabel:t,editable:r,linkEndpoints:s,onAnnotationUpdate:a,renderPlayhead:l,className:c}),u.length>0&&C.jsx(Vf,{height:e,renderAnnotationItem:n,onAnnotationUpdate:a,editable:r,annotationListConfig:{linkEndpoints:s,continuousPlay:!1},scrollActivePosition:o,scrollActiveContainer:i})]})},wb=({playback:e=!1,clipSplitting:t=!1,annotations:n=!1,additionalShortcuts:r=[]})=>{const{tracks:s,samplesPerPixel:a,sampleRate:o,playoutRef:i,duration:l}=lt(),{annotations:c,linkEndpoints:u,activeAnnotationId:f,continuousPlay:m}=it(),{setAnnotations:d,setActiveAnnotationId:h,scrollContainerRef:g,play:v}=Ie(),{splitClipAtPlayhead:y}=of({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),lf({enabled:e||b.length>0,...e?{additionalShortcuts:b}:{shortcuts:b}}),cf({annotations:c,activeAnnotationId:f,onAnnotationsChange:d,onActiveAnnotationChange:h,duration:l,linkEndpoints:u,continuousPlay:m,scrollContainerRef:g,samplesPerPixel:a,sampleRate:o,onPlay:v,enabled:n&&c.length>0}),null},Bs=class Bs extends On{apply(t){const{transform:n,source:r}=t;if(!r?.data||!this.options)return n;const{boundary:s,trackIndex:a,clipIndex:o}=r.data;if(s)return{x:0,y:0};const{tracks:i,samplesPerPixel:l}=this.options,c=i[a];if(!c)return n;const u=c.clips[o];if(!u)return n;const f=n.x*l,m=[...c.clips].sort((g,v)=>g.startSample-v.startSample),d=m.findIndex(g=>g.id===u.id);return{x:mc(u,f,m,d)/l,y:0}}};Bs.configure=gn(Bs);let Ls=Bs;const Ws=class Ws extends On{apply(t){const{transform:n,source:r}=t;if(!this.options||!r?.data)return n;const{boundary:s,startSample:a}=r.data;if(s)return n;const{samplesPerPixel:o}=this.options;if(this.options.mode==="timescale"){const{gridSamples:v}=this.options;if(a!==void 0){const w=a+n.x*o;return{x:(Math.round(w/v)*v-a)/o,y:0}}const y=n.x*o;return{x:Math.round(y/v)*v/o,y:0}}const{snapTo:i,bpm:l,timeSignature:c,sampleRate:u}=this.options;if(i==="off")return n;const f=i==="bar"?vo(c):Vs(c);if(a!==void 0){const v=a+n.x*o,y=Ia(v,l,u),b=Ma(y,f);return{x:(Rn(b,l,u)-a)/o,y:0}}const m=n.x*o,d=Ia(m,l,u),h=Ma(d,f);return{x:Rn(h,l,u)/o,y:0}}};Ws.configure=gn(Ws);let Ir=Ws;const _b=()=>{},xb=({snap:e=!1,touchOptimized:t=!1,children:n})=>{const{tracks:r,samplesPerPixel:s,sampleRate:a,playoutRef:o,isDraggingRef:i,onTracksChange:l}=lt(),{setSelectedTrackId:c}=Ie(),u=Hd(),f=e&&u!=null&&u.scaleMode==="beats"&&u.snapTo!=="off",m=e&&!f;p.useEffect(()=>{l==null&&console.warn("[waveform-playlist] ClipInteractionProvider: onTracksChange is not set on WaveformPlaylistProvider. Drag and trim edits will not be persisted.")},[l]);const d=p.useMemo(()=>{if(f&&u){const{bpm:_,timeSignature:x,snapTo:S}=u,k=S==="bar"?vo(x):Vs(x);return E=>{const I=Ia(E,_,a),T=Ma(I,k);return Rn(T,_,a)}}if(m){const _=Math.round(uo(s).smallStep/1e3*a);return x=>Math.round(x/_)*_}},[f,m,u,a,s]),h=af({touchOptimized:t}),{onDragStart:g,onDragMove:v,onDragEnd:y}=rf({tracks:r,onTracksChange:l??_b,samplesPerPixel:s,sampleRate:a,engineRef:o,isDraggingRef:i,snapSamplePosition:d}),b=p.useCallback(_=>{const x=_.operation?.source?.data?.trackIndex;x!==void 0&&r[x]&&c(r[x].id),g(_)},[g,r,c]),w=p.useMemo(()=>{const _=[Bf];return f&&u?_.push(Ir.configure({mode:"beats",snapTo:u.snapTo,bpm:u.bpm,timeSignature:u.timeSignature,samplesPerPixel:s,sampleRate:a})):m&&_.push(Ir.configure({mode:"timescale",gridSamples:Math.round(uo(s).smallStep/1e3*a),samplesPerPixel:s})),_.push(Ls.configure({tracks:r,samplesPerPixel:s})),_},[f,m,u,r,s,a]);return C.jsx(Ty,{value:!0,children:C.jsx(kf,{sensors:h,onDragStart:b,onDragMove:v,onDragEnd:y,modifiers:w,plugins:Mi,children:n})})};exports.Tone=lc;exports.AnnotationIntegrationProvider=Sy;exports.AudioPosition=_y;exports.AutomaticScrollCheckbox=Cy;exports.ClearAllButton=my;exports.ClipCollisionModifier=Ls;exports.ClipInteractionProvider=xb;exports.ContinuousPlayCheckbox=ky;exports.DownloadAnnotationsButton=My;exports.EditableCheckbox=Iy;exports.ExportWavButton=Ay;exports.FastForwardButton=uy;exports.KeyboardShortcuts=wb;exports.LinkEndpointsCheckbox=Ey;exports.LoopButton=hy;exports.MasterVolumeControl=yy;exports.MediaElementAnnotationList=Vf;exports.MediaElementPlaylist=Wf;exports.MediaElementPlaylistProvider=ay;exports.MediaElementWaveform=bb;exports.PauseButton=iy;exports.PlayButton=oy;exports.PlaylistAnnotationList=Cf;exports.PlaylistVisualization=xf;exports.RewindButton=cy;exports.SelectionTimeInputs=xy;exports.SetLoopRegionButton=py;exports.SkipBackwardButton=dy;exports.SkipForwardButton=fy;exports.SnapToGridModifier=Ir;exports.SpectrogramIntegrationProvider=Oy;exports.StopButton=ly;exports.TimeFormatSelect=by;exports.Waveform=Ny;exports.WaveformPlaylistProvider=ny;exports.ZoomInButton=gy;exports.ZoomOutButton=vy;exports.createEffectChain=z0;exports.createEffectInstance=Er;exports.effectCategories=B0;exports.effectDefinitions=Vr;exports.getEffectDefinition=Si;exports.getEffectsByCategory=L0;exports.getShortcutLabel=O0;exports.getWaveformDataMetadata=E0;exports.loadPeaksFromWaveformData=k0;exports.loadWaveformData=Ci;exports.noDropAnimationPlugins=Mi;exports.useAnnotationDragHandlers=sf;exports.useAnnotationIntegration=_n;exports.useAnnotationKeyboardControls=cf;exports.useAudioTracks=D0;exports.useClipDragHandlers=rf;exports.useClipInteractionEnabled=_f;exports.useClipSplitting=of;exports.useDragSensors=af;exports.useDynamicEffects=j0;exports.useDynamicTracks=ty;exports.useExportWav=uf;exports.useKeyboardShortcuts=Os;exports.useMasterAnalyser=$0;exports.useMasterVolume=nf;exports.useMediaElementAnimation=Nr;exports.useMediaElementControls=ki;exports.useMediaElementData=ea;exports.useMediaElementState=Qs;exports.usePlaybackAnimation=ot;exports.usePlaybackShortcuts=lf;exports.usePlaylistControls=Ie;exports.usePlaylistData=lt;exports.usePlaylistState=it;exports.useSpectrogramIntegration=Ly;exports.useTimeFormat=ef;exports.useTrackDynamicEffects=Z0;exports.useZoomControls=tf;exports.waveformDataToPeaks=Jd;
|
|
1078
|
+
`,vb=({clipStartSample:e,clipDurationSamples:t,...n})=>{const r=p.useRef(null),s=p.useRef(null),a=Vr(),{waveHeight:o}=Js(),{isPlaying:i,currentTimeRef:l}=zr(),{samplesPerPixel:c,sampleRate:u}=ta(),f=a?.waveProgressColor||"rgba(0, 0, 0, 0.1)";p.useEffect(()=>{const v=()=>{if(r.current){const y=(l.current??0)*u,b=e+t;let _=0;if(y<=e)_=0;else if(y>=b)_=n.length;else{const w=y-e;_=Math.floor(w/c)}r.current.style.width=`${_}px`}i&&(s.current=requestAnimationFrame(v))};return i?s.current=requestAnimationFrame(v):v(),()=>{s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[i,u,c,e,t,n.length,l]),p.useEffect(()=>{if(!i&&r.current){const g=(l.current??0)*u,y=e+t;let b=0;if(g<=e)b=0;else if(g>=y)b=n.length;else{const _=g-e;b=Math.floor(_/c)}r.current.style.width=`${b}px`}});const m=a?.waveformDrawMode||"inverted";let d;m==="inverted"?d=a?.selectedWaveFillColor||a?.waveFillColor||"white":d=a?.selectedWaveOutlineColor||a?.waveOutlineColor||"grey";const h=qt(d);return C.jsxs(hb,{children:[C.jsx(pb,{$color:h,$height:o,$top:n.index*o,$width:n.length}),C.jsx(mb,{ref:r,$color:f,$height:o,$top:n.index*o}),C.jsx(gb,{children:C.jsx(Yd,{...n,isSelected:!0,transparentBackground:!0})})]})},ic={current:0},yb=({renderPlayhead:e,color:t,samplesPerPixel:n,sampleRate:r})=>{const{isPlaying:s,currentTimeRef:a}=zr();return e({position:(a.current??0)*r/n,color:t,isPlaying:s,currentTimeRef:a,playbackStartTimeRef:ic,audioStartPositionRef:ic,samplesPerPixel:n,sampleRate:r,controlsOffset:0})},Vf=({getAnnotationBoxLabel:e,editable:t=!1,linkEndpoints:n=!1,onAnnotationUpdate:r,renderPlayhead:s,className:a})=>{const o=Vr(),{isPlaying:i}=zr(),{annotations:l,activeAnnotationId:c}=ea(),u=p.useContext(na),{play:f,seekTo:m,setActiveAnnotationId:d,setAnnotations:h,setScrollContainer:v}=Ii(),{duration:g,peaksDataArray:y,sampleRate:b,waveHeight:_,timeScaleHeight:w,samplesPerPixel:x,controls:S,playoutRef:k,barWidth:E,barGap:M}=ta(),[T,$]=p.useState(0),[A,I]=p.useState(0),[R,D]=p.useState(!1),O=p.useRef(null),Z=p.useCallback(z=>{O.current=z,v(z)},[v]),G=Math.floor(g*b/x),Y=p.useCallback(async z=>{d(z.id);try{await f(z.start)}catch(ae){console.error("waveform-playlist: Failed to start playback for annotation",z.id,ae)}},[d,f]),te=p.useCallback(z=>{h(z),r?.(z)},[h,r]),{onDragStart:X,onDragMove:K,onDragEnd:le}=af({annotations:l,onAnnotationsChange:te,samplesPerPixel:x,sampleRate:b,duration:g,linkEndpoints:n}),J=p.useRef(0),de=p.useCallback(z=>{const ae=z.currentTarget.getBoundingClientRect(),ce=(z.clientX-ae.left)*x/b;J.current=ce,D(!0),$(ce),I(ce)},[x,b]),ue=p.useCallback(z=>{if(!R)return;const ae=z.currentTarget.getBoundingClientRect(),ce=(z.clientX-ae.left)*x/b;I(ce)},[R,x,b]),ne=p.useCallback(z=>{if(!R)return;if(D(!1),i&&k.current){const _e=Math.max(0,J.current);m(_e),$(_e),I(_e),k.current.stop(),f(_e);return}const ae=z.currentTarget.getBoundingClientRect(),ce=(z.clientX-ae.left)*x/b,xe=Math.min(T,ce),B=Math.max(T,ce);Math.abs(B-xe)<.1?(m(xe),$(xe),I(xe)):($(xe),I(B))},[R,T,x,b,m,i,k,f]);return y.length===0?C.jsx("div",{className:a,children:"Loading waveform..."}):C.jsx(Xd,{children:C.jsx(Wr.Provider,{value:{samplesPerPixel:x,sampleRate:b,zoomLevels:[x],waveHeight:_,timeScaleHeight:w,duration:g*1e3,controls:S,barWidth:E,barGap:M},children:C.jsx(Ci,{theme:o,backgroundColor:qt(o.waveOutlineColor),timescaleBackgroundColor:o.timescaleBackgroundColor,timescaleWidth:G,tracksWidth:G,controlsWidth:S.show?S.width:0,onTracksMouseDown:de,onTracksMouseMove:ue,onTracksMouseUp:ne,scrollContainerRef:Z,isSelecting:R,timescale:w>0?C.jsx(Kd,{}):void 0,children:C.jsxs(C.Fragment,{children:[y.map((z,ae)=>{const ke=z.length>0?Math.max(...z.map(ce=>ce.peaks.data.length)):1;return C.jsx(qd,{numChannels:ke,backgroundColor:qt(o.waveOutlineColor),offset:0,width:G,hasClipHeaders:!1,trackId:`media-element-track-${ae}`,isSelected:!0,children:z.map((ce,xe)=>{const B=ce.peaks,_e=B.length;return C.jsx(fo,{clipId:ce.clipId,trackIndex:ae,clipIndex:xe,trackName:ce.trackName,startSample:ce.startSample,durationSamples:ce.durationSamples,samplesPerPixel:x,showHeader:!1,disableHeaderDrag:!0,isSelected:!0,trackId:`media-element-track-${ae}`,children:B.data.map((re,Me)=>C.jsx(vb,{index:Me,data:re,bits:B.bits,length:_e,clipStartSample:ce.startSample,clipDurationSamples:ce.durationSamples},`${ae}-${xe}-${Me}`))},`${ae}-${xe}`)})},ae)}),l.length>0&&u&&C.jsx(Ef,{onDragStart:X,onDragMove:K,onDragEnd:le,modifiers:t?[Wf]:[],plugins:Ti,children:C.jsx(u.AnnotationBoxesWrapper,{height:30,width:G,children:l.map((z,ae)=>{const ke=z.start*b/x,ce=z.end*b/x,xe=e?e(z,ae):z.id;return C.jsx(u.AnnotationBox,{annotationId:z.id,annotationIndex:ae,startPosition:ke,endPosition:ce,label:xe,color:"#ff9800",isActive:z.id===c,onClick:()=>Y(z),editable:t},z.id)})})}),T!==A&&C.jsx(Zd,{startPosition:Math.min(T,A)*b/x,endPosition:Math.max(T,A)*b/x,color:o.selectionColor}),s?C.jsx(yb,{renderPlayhead:s,color:o.playheadColor,samplesPerPixel:x,sampleRate:b}):C.jsx(fb,{color:o.playheadColor})]})})})})},Nf=({height:e,renderAnnotationItem:t,onAnnotationUpdate:n,editable:r=!1,controls:s,annotationListConfig:a,scrollActivePosition:o="center",scrollActiveContainer:i="nearest"})=>{const{annotations:l,activeAnnotationId:c,continuousPlay:u}=ea(),f=_n(),{setAnnotations:m}=Ii(),d=a??{linkEndpoints:!1,continuousPlay:u},h=p.useCallback(g=>{m(g),n?.(g)},[m,n]),{AnnotationText:v}=f;return C.jsx(v,{annotations:l,activeAnnotationId:c??void 0,shouldScrollToActive:!0,scrollActivePosition:o,scrollActiveContainer:i,editable:r,controls:r?s:void 0,annotationListConfig:d,height:e,onAnnotationUpdate:h,renderAnnotationItem:t})},bb=({annotationTextHeight:e,getAnnotationBoxLabel:t,renderAnnotationItem:n,editable:r=!1,linkEndpoints:s=!1,onAnnotationUpdate:a,scrollActivePosition:o="center",scrollActiveContainer:i="nearest",renderPlayhead:l,className:c})=>{const{annotations:u}=ea();return C.jsxs(C.Fragment,{children:[C.jsx(Vf,{getAnnotationBoxLabel:t,editable:r,linkEndpoints:s,onAnnotationUpdate:a,renderPlayhead:l,className:c}),u.length>0&&C.jsx(Nf,{height:e,renderAnnotationItem:n,onAnnotationUpdate:a,editable:r,annotationListConfig:{linkEndpoints:s,continuousPlay:!1},scrollActivePosition:o,scrollActiveContainer:i})]})},wb=({playback:e=!1,clipSplitting:t=!1,annotations:n=!1,additionalShortcuts:r=[]})=>{const{tracks:s,samplesPerPixel:a,sampleRate:o,playoutRef:i,duration:l}=lt(),{annotations:c,linkEndpoints:u,activeAnnotationId:f,continuousPlay:m}=it(),{setAnnotations:d,setActiveAnnotationId:h,scrollContainerRef:v,play:g}=Ie(),{splitClipAtPlayhead:y}=lf({tracks:s,sampleRate:o,samplesPerPixel:a,engineRef:i}),b=[];return t&&b.push({key:"s",action:y,description:"Split clip at playhead",preventDefault:!0}),r.length>0&&b.push(...r),cf({enabled:e||b.length>0,...e?{additionalShortcuts:b}:{shortcuts:b}}),uf({annotations:c,activeAnnotationId:f,onAnnotationsChange:d,onActiveAnnotationChange:h,duration:l,linkEndpoints:u,continuousPlay:m,scrollContainerRef:v,samplesPerPixel:a,sampleRate:o,onPlay:g,enabled:n&&c.length>0}),null},Ws=class Ws extends On{apply(t){const{transform:n,source:r}=t;if(!r?.data||!this.options)return n;const{boundary:s,trackIndex:a,clipIndex:o}=r.data;if(s)return{x:0,y:0};const{tracks:i,samplesPerPixel:l}=this.options,c=i[a];if(!c)return n;const u=c.clips[o];if(!u)return n;const f=n.x*l,m=[...c.clips].sort((v,g)=>v.startSample-g.startSample),d=m.findIndex(v=>v.id===u.id);return{x:gc(u,f,m,d)/l,y:0}}};Ws.configure=gn(Ws);let Bs=Ws;const Vs=class Vs extends On{apply(t){const{transform:n,source:r}=t;if(!this.options||!r?.data)return n;const{boundary:s,startSample:a}=r.data;if(s)return n;const{samplesPerPixel:o}=this.options;if(this.options.mode==="timescale"){const{gridSamples:g}=this.options;if(a!==void 0){const _=a+n.x*o;return{x:(Math.round(_/g)*g-a)/o,y:0}}const y=n.x*o;return{x:Math.round(y/g)*g/o,y:0}}const{snapTo:i,bpm:l,timeSignature:c,sampleRate:u}=this.options;if(i==="off")return n;const f=i==="bar"?bo(c):Ns(c);if(a!==void 0){const g=a+n.x*o,y=Aa(g,l,u),b=Ta(y,f);return{x:(Rn(b,l,u)-a)/o,y:0}}const m=n.x*o,d=Aa(m,l,u),h=Ta(d,f);return{x:Rn(h,l,u)/o,y:0}}};Vs.configure=gn(Vs);let Mr=Vs;const _b=()=>{},xb=({snap:e=!1,touchOptimized:t=!1,children:n})=>{const{tracks:r,samplesPerPixel:s,sampleRate:a,playoutRef:o,isDraggingRef:i,onTracksChange:l}=lt(),{setSelectedTrackId:c}=Ie(),u=Gd(),f=e&&u!=null&&u.scaleMode==="beats"&&u.snapTo!=="off",m=e&&!f;p.useEffect(()=>{l==null&&console.warn("[waveform-playlist] ClipInteractionProvider: onTracksChange is not set on WaveformPlaylistProvider. Drag and trim edits will not be persisted.")},[l]);const d=p.useMemo(()=>{if(f&&u){const{bpm:w,timeSignature:x,snapTo:S}=u,k=S==="bar"?bo(x):Ns(x);return E=>{const M=Aa(E,w,a),T=Ta(M,k);return Rn(T,w,a)}}if(m){const w=Math.round(ho(s).smallStep/1e3*a);return x=>Math.round(x/w)*w}},[f,m,u,a,s]),h=of({touchOptimized:t}),{onDragStart:v,onDragMove:g,onDragEnd:y}=sf({tracks:r,onTracksChange:l??_b,samplesPerPixel:s,sampleRate:a,engineRef:o,isDraggingRef:i,snapSamplePosition:d}),b=p.useCallback(w=>{const x=w.operation?.source?.data?.trackIndex;x!==void 0&&r[x]&&c(r[x].id),v(w)},[v,r,c]),_=p.useMemo(()=>{const w=[Wf];return f&&u?w.push(Mr.configure({mode:"beats",snapTo:u.snapTo,bpm:u.bpm,timeSignature:u.timeSignature,samplesPerPixel:s,sampleRate:a})):m&&w.push(Mr.configure({mode:"timescale",gridSamples:Math.round(ho(s).smallStep/1e3*a),samplesPerPixel:s})),w.push(Bs.configure({tracks:r,samplesPerPixel:s})),w},[f,m,u,r,s,a]);return C.jsx(Ty,{value:!0,children:C.jsx(Ef,{sensors:h,onDragStart:b,onDragMove:g,onDragEnd:y,modifiers:_,plugins:Ti,children:n})})};exports.Tone=cc;exports.AnnotationIntegrationProvider=Sy;exports.AudioPosition=_y;exports.AutomaticScrollCheckbox=Cy;exports.ClearAllButton=my;exports.ClipCollisionModifier=Bs;exports.ClipInteractionProvider=xb;exports.ContinuousPlayCheckbox=ky;exports.DownloadAnnotationsButton=My;exports.EditableCheckbox=Iy;exports.ExportWavButton=Ay;exports.FastForwardButton=uy;exports.KeyboardShortcuts=wb;exports.LinkEndpointsCheckbox=Ey;exports.LoopButton=hy;exports.MasterVolumeControl=yy;exports.MediaElementAnnotationList=Nf;exports.MediaElementPlaylist=Vf;exports.MediaElementPlaylistProvider=ay;exports.MediaElementWaveform=bb;exports.PauseButton=iy;exports.PlayButton=oy;exports.PlaylistAnnotationList=Sf;exports.PlaylistVisualization=Cf;exports.RewindButton=cy;exports.SelectionTimeInputs=xy;exports.SetLoopRegionButton=py;exports.SkipBackwardButton=dy;exports.SkipForwardButton=fy;exports.SnapToGridModifier=Mr;exports.SpectrogramIntegrationProvider=Oy;exports.StopButton=ly;exports.TimeFormatSelect=by;exports.Waveform=Ny;exports.WaveformPlaylistProvider=ny;exports.ZoomInButton=gy;exports.ZoomOutButton=vy;exports.createEffectChain=z0;exports.createEffectInstance=Ir;exports.effectCategories=B0;exports.effectDefinitions=Nr;exports.getEffectDefinition=Ei;exports.getEffectsByCategory=L0;exports.getShortcutLabel=O0;exports.getWaveformDataMetadata=I0;exports.loadPeaksFromWaveformData=E0;exports.loadWaveformData=ki;exports.noDropAnimationPlugins=Ti;exports.useAnnotationDragHandlers=af;exports.useAnnotationIntegration=_n;exports.useAnnotationKeyboardControls=uf;exports.useAudioTracks=D0;exports.useClipDragHandlers=sf;exports.useClipInteractionEnabled=xf;exports.useClipSplitting=lf;exports.useDragSensors=of;exports.useDynamicEffects=j0;exports.useDynamicTracks=ty;exports.useExportWav=df;exports.useKeyboardShortcuts=Ls;exports.useMasterAnalyser=R0;exports.useMasterVolume=rf;exports.useMediaElementAnimation=zr;exports.useMediaElementControls=Ii;exports.useMediaElementData=ta;exports.useMediaElementState=ea;exports.usePlaybackAnimation=ot;exports.usePlaybackShortcuts=cf;exports.usePlaylistControls=Ie;exports.usePlaylistData=lt;exports.usePlaylistState=it;exports.useSpectrogramIntegration=Ly;exports.useTimeFormat=tf;exports.useTrackDynamicEffects=Z0;exports.useZoomControls=nf;exports.waveformDataToPeaks=Qd;
|
|
1079
1079
|
//# sourceMappingURL=index.js.map
|